Commit graph

11893 commits

Author SHA1 Message Date
Solomon Peachy
bb605c91a4 usb_storage: Support 12/16-byte ATA passthrough
This is an unofficial command that many USB<->ATA chipsets support,
allowing direct passthrough of ATA commands to the device.

We don't pass things through as-is; instead we only intercept and handle
requests for IDENFITY INFO and SMART.  Everything else will return an
error.

Change-Id: I3bbb76990e5f6f0512f6eb42825fa505475b2ecd
2025-09-15 18:04:11 -04:00
Solomon Peachy
14157860b9 rgnano: Shrink CODEC and PLUGIN buffer sizes to reasonable sizes
(From 4MB->2MB and 8MB->2MB, respectively)

This is a hosted platform with a decent amount of free RAM; however
plugins and codecs are dlopen() which doesn't count against those
buffers.  Furthermore, the rgnano uses musl libc which does NOT
implement dlclose() so plugins, codecs, etc stick around in RAM
indefinitely even if they are never used again.

By shrinking these buffers we free up a bit more headroom for dlopen()
to leak, and for the host OS to provide disk caches and whatnot.

Change-Id: Ie657bd3b9fc8bd2a1f4bbc07debe3b10538c41c3
2025-09-13 08:44:38 -04:00
Solomon Peachy
19ee9363d1 ibasso: Rejigger RAM and buffer sizes a little
Shrink audio buffer from ~256MB to ~192MB.  Increase plugin buffer size
to 2MB, not that it should matter given how much extra RAM this platform has.

This leaves plenty of room for the base OS to do what it needs to do.

Change-Id: I59ca235b9cf80cf86d406e4a144fee7d7784ed5d
2025-09-13 08:44:38 -04:00
Solomon Peachy
b497e71708 hibylinux: Shrink PLUGIN_BUFFER to 512K
Hosted platforms use dlopen() for plugin loading, and hibylinux is
relatively RAM constrained, so shrink this will free up more memory to
the OS for plugins to use.

Change-Id: I6b7cb17b964eaf5afc4958db242dfe4b82178e2e
2025-09-13 08:44:38 -04:00
Solomon Peachy
32d52e0415 hosted: Shrink audiobuffer to (MEMORY_SIZE-1) megabytes
This represents a 256K increase from the former (MEMORYSIZE-0.75), and
is necessary due to the growth in our binary sizes over the past decade
or so.

It is debatable if this is enough given that our actual memory
usage is approximately (MEMORYSIZE+3) megabytes (plus runtime OS
overhead) for the typical hosted build, but giving the host OS a bit
more breathing room is warranted.

Change-Id: I53e044585a32efd50a85e68d64fd21921eda01a3
2025-09-12 23:15:11 -04:00
Solomon Peachy
a2c10f6189 unicode: Support characters beyond the first unicode plane
We used 16-bit variables to store the 'character code' everywhere but
this won't let us represent anything beyond U+FFFF.

This patch changes those variables to a custom type that can be 32 or 16
bits depending on the build, and adjusts numerous internal APIs and
datastructures to match.  This includes:

 * utf8decode() and friends
 * font manipulation, caching, rendering, and generation
 * on-screen keyboard
 * FAT filesystem (parsing and generating utf16 LFNs)
 * WIN32 simulator platform code

Note that this patch doesn't _enable_ >16bit unicode support; a followup
patch will turn that on for appropriate targets.

Appears to work on:

  * hosted linux, native, linux simulator in both 16/32-bit modes.

Needs testing on:

  * windows and macos simulator (16bit+32bit)

Change-Id: Iba111b27d2433019b6bff937cf1ebd2c4353a0e8
2025-09-12 09:24:30 -04:00
Solomon Peachy
c6db7114f8 as3525: Fix build warning with newer toolchains
Change-Id: I3dad32caf0dc087b717ed76b900f414aa1608bc2
2025-09-09 10:03:22 -04:00
Solomon Peachy
3f71709152 s5l77xx: Correct definitions of VICADDRESS(n) and AESINADDR
By switching them from (const void* volatile*) to (void* volatile*)

The 'const' bit was causing GCC>4 to optimize away writes to those
addresses when compiled with -Os, badly breaking the interrupt handler.

Change-Id: Ia4b0ca37e082bddf78e084b80a5e550894645f1a
2025-09-07 10:02:40 -04:00
Solomon Peachy
da02b5921f s5l8702: Clean up the IRQ handler code slightly
* move all state into IRAM
 * eliminate dummy variables
 * get rid of 'naked' attribute and (slightly wasteful) hand-written asm
   in favor of auto-created 'interrupt' code

Change-Id: Ie6a2e12a4c1a0faa6ae89504cf931657044bd457
2025-09-07 09:59:45 -04:00
Solomon Peachy
fb8b52eaf1 s5l8702: CONSTify the clocking setup
Change-Id: I88f7a2e176606b718d778a5a4a5756c4c4b58c03
2025-09-07 09:11:11 -04:00
Solomon Peachy
34f34bb7f1 misc: Fix a small pile of warnings found with diagnostics turned way up
* possible null pointer dereferences
 * non-annotated fallthroughs in case statements

Change-Id: I2332e0e0a4203ceca0999291ead112b8ab94c613
2025-09-06 21:31:58 -04:00
Solomon Peachy
4de25f7020 font: glpyh_cache_load() is now NO_INLINE
It is particularly stack-heavy (>1.25K, >2.25K with 32-bit unicode)

Its only caller was font_load_ex() but that can be called recursively
which _really_ blew up the stack.

Change-Id: I211cd33ca3478b2bd01d3ddcf6c890399af2fb9c
2025-09-05 20:02:46 -04:00
Solomon Peachy
16c9ef64b0 misc: Ensure stacks are always aligned with the native pointer size.
Change-Id: Ie7efae914dcb43be98bbb71bae9b765b2d87d817
2025-09-05 19:43:11 -04:00
Amaury Pouly
ac6822debb zen/zenxfi: fix incorrect dotclk polarity
By default STMP3700 launches from negative edge for capture on positive edge.
If we leave DPL (bit 13 of reg 0x13) to 0, it will be captured on falling edge,
resulting in a potentially undefined behavior. Some make sure LCD captures on
rising edge. Alternatively we could change the dotclk polarity in VDCTRL0.

Change-Id: I4ceb2f5a9be88e07f0af9bf493b7881883320fda
2025-08-31 20:50:22 -04:00
Solomon Peachy
4ad041e17a disk: Always try to mount the first partition on a disk.
We've received multiple reports from users of 6th gen iPods where we
fail to find any mountable partition.  A user was able to supply an MBR
dump, which showed that the "type" listed for parition 0 was set to 0x00
(ie "unused"), leading us to (correctly) completely ignore that entry.
However, it looks like the stock firmware ignores the type and
unconditionally uses the first entry even if it's nominally "invalid"

So, to deal with this, always try to mount partition 0 if it is not one
of the two "extended partition table" types.  If that speculative mount
succeeds, we now treat it as type 0x0c (Fat32 w/LBA) internally.

Note that this will not allow the partition to be mountable over USB, as
the MBR is still incorrect, leading the host OS to ignore the partition.
Further complicating things, the stock Apple firmware always constructs
a fake MBR to hand to the host!

To prevent user confusion with these devices, we may consider faking the
MBR too; alternatively we could correct the MBR and write it back to
disk, perhaps via a debug menu option.

Change-Id: I1e9392d20401eb94ecc6d70263fb0e45392a9bd4
2025-08-31 19:31:20 -04:00
Hairo R. Carela
268a282da6 rgnano: Proper keylock support
Can use the advanced keylock menu options now.

Change-Id: If59b16ef5649c328558a74dd0601bc2f272c37b7
2025-08-30 17:20:31 -04:00
Solomon Peachy
7de9d8dae5 limits: define PATH_MAX in only one place.
(This is the first step towards making it larger)

Change-Id: I4cea522074c455e04c8d228cf6463fb6500c41a0
2025-08-25 10:10:38 -04:00
Hairo R. Carela
6f107430f4 rgnano: Voltage and current measure support
Battery time estimation works now.

This commit also changes the mksquashfs path to FUNKEY_SDK_PATH.

Change-Id: Ic0aa4c40011b0716f1c36c014377eaccb486e841
2025-08-23 13:44:25 -04:00
Solomon Peachy
97ebba1fbd SD: Move sd_parse_csd() into common sdmmc code
This leaves firmware/driver/sd.c only containing storage API wrappers

Change-Id: I94f3f38c180f3802f479cdc54723fcd1b7782421
2025-08-22 14:48:28 -04:00
Solomon Peachy
84504c7471 Revert "internals: Support characters beyond the first unicode plane (WIP)"
This reverts commit d05c59f35b.
2025-08-20 16:09:49 -04:00
Solomon Peachy
d05c59f35b internals: Support characters beyond the first unicode plane (WIP)
We used 16-bit variables to store the 'character code' everywhere but
this won't let us represent anything beyond U+FFFF.

This patch changes those variables to a custom type that can be 32 or 16
bits depending on the build, and adjusts numerous internal APIs and
datastructures to match.  This includes:

 * utf8decode() and friends
 * on-screen keyboard
 * font manipulation, caching, rendering, and generation
 * VFAT code parses and generates utf16 dirents
 * WIN32 simulator reads and writes utf16 filenames

Note that this patch doesn't _enable_ >16bit unicode support; a followup
patch will turn that on for appropriate targets.

Known bugs:

  * Native players in 32-bit unicode mode generate mangled filename
    entries if they include UTF16 surrogate codepoints.  Root cause
    is unclear, and may reside in core dircache code.

Needs testing on:

 * windows simulator (16bit+32bit)

Change-Id: I193a00fe2a11a4181ddc82df2d71be52bf00b6e6
2025-08-20 16:08:43 -04:00
Solomon Peachy
0456ec5630 IAP: First steps towards true multiport state
iap_reset_state() and iap_getc() are now passed the logical IAP port
(0 is dock/only connector, 1 is headphone connector)

Change-Id: I97421146a8cab032b90c9b4eb55b50aa00d73312
2025-08-20 07:56:43 -04:00
Hairo R. Carela
69f27d4c66 rgnano: Use proper lcd depth and pixelformat
According to screen driver this device screen is actually 16 bit RGB565 (https://github.com/DrUm78/linux/blob/FunKey_S/drivers/staging/fbtft/fb_st7789v.c#L137).

This also fixes the color banding issues we had before and boomshine doesn't segfault anymore. Also building rockpaint now that's possible.

Change-Id: Icee49c347fbfabc79e0040314ec148cb77ca6325
2025-08-18 21:43:13 -04:00
Hairo R. Carela
c9e16e4888 rgnano: Sleep timer and idle poweroff support
Actually power off the handheld with the sleep timer and idle poweroff functions instead of closing rockbox.

This commit also moves setting system volume to max from the launch script to system-sdl.c so it works when running rockbox via instant play.

Change-Id: I174b67c6abef451faa05f4a8f52b8d9eeed98a22
2025-08-15 09:44:35 -04:00
Solomon Peachy
5ecb5832e1 as3525: Silence portability warning with GCC10+
Change-Id: I66ca05bd7b6029b7699d5534f82efe0c14da1291
2025-08-15 08:39:05 -04:00
Solomon Peachy
472a6a69c6 IAP: Reset IAP state upon headphone or dock unplug
Provides a semi-automatic way of recovering from desynchronization

Change-Id: I527b0bacc22ef38c1e7213653e522ea1b0ac155d
2025-08-14 20:41:14 -04:00
Solomon Peachy
6265bbbd97 sdl: Explicitly disable the cursor for non-touchscreen devices
...Except for simulators, those always need the cursor

In practice this only affects the RG Nano as it is currently our
only SDL target that lacks a touchscreen.

Change-Id: I292f923848528c233da518b062d9ccd8a03515dd
2025-08-07 09:36:51 -04:00
Solomon Peachy
209f833c7a rgnano: Fix simulator build
Change-Id: I2e6dfae25a2dae18e672c5584e8bd52c7bbd279a
2025-08-06 21:25:57 -04:00
Hairo R. Carela
46d10dda33 rgnano: Instant play support and proper system brightness/volume handling
Instant play is a Funkey OS feature that allows it to relaunch at boot the last program it was running before shutting down, which means that if the handheld is powered off (holding the power button) while rockbox is running the next time it's powered on rockbox will launch at boot.

This commit also handles system brightness/volume in rockbox itself instead of the launch script, so the values are properly reset when powering off the handheld while rockbox is running.

Change-Id: Ie1adbf71069aeed5fbf6670971718a2f718716a3
2025-08-06 20:21:02 -04:00
Solomon Peachy
16a6ad032f pp502x: Restructure UART code
* Move to a structure instead of pointers to registers
 * Autobaud operates per-uart
 * When explitily setting uart speed, it applies to all uarts

This allows both UARTs to be enabled and serviced simultaneously,
allowing either accessory port to be used.  Note that the last
port to receive something is where subsequent transmits are directed,
and only one set of IAP state is maintained.

To change this, we will need to revamp IAP to support more than
one state machine, and then extend the serial API to allow for both
UARTs to be used independently.  Probably not worth the effort.

Change-Id: I0142f0906706fc0c4ee6d6d7aa6b0515e1a749dd
2025-08-06 08:27:58 -04:00
Hairo R. Carela
7b0f408c71 rgnano: UI simulator support
Change-Id: Id488d16e01ef49a9d1b57641bc1c22ed2fef4931
2025-08-05 08:30:30 -04:00
Solomon Peachy
b52bf1bf65 gigabeats: Fix compilation with -fno-common
Change-Id: I02974bffd6def6bdfa6b15c593ac2eb82953ea73
2025-08-05 07:25:23 -04:00
Solomon Peachy
74508093f2 rk27xx: Fix compilation with -fno-common
Change-Id: I9fbe85fed23fe7b1b3fd88aa5e8a4a63c509fa62
2025-08-05 07:25:23 -04:00
Solomon Peachy
c33602375d pp500x: Switch to plain C sleep/wake code (instead of asm)
Supposedly this is responsible for startup crashes on ipod1g/2g.

Change-Id: I9d03ddc996f46db6fa782d1d8b1cd8baf9d23308
2025-08-04 10:02:52 -04:00
Vencislav Atanasov
68a5524a48 iPod 6G: Disable usage of deep standby mode on LCD type 2 and 3
This caused the devices to crash a few seconds after sending the command. A small power consumption increase is possible when the screen is off with this patch, but Rockbox doesn't crash anymore. Type 0 and 1 are not affected as they use a completely different sequence.

Tested on iPod 6G LCD type 1 and LCD type 2. Type 0 is similar to Type 1, Type 3 is similar to Type 2, so it should cover all available LCD types.

Change-Id: I3e8a653ca22bf59e3db38e1d26e747b358e62cb2
2025-07-30 09:51:15 -04:00
Solomon Peachy
5fa3b1ada3 SDL_MAJOR_VERSION isn't defined when parsing SOURCES
use RG_NANO instead for now.

Change-Id: I289432bfcd797b555da6e6e0e21fd62e5f342387
2025-07-29 23:03:21 -04:00
Solomon Peachy
2c0d70ccb2 build: Fix the large pile of yellow (and false red)
Introduced in 48392bab94

Change-Id: I848dad7ef8e830dafbe604909a4e8376890edc8e
2025-07-29 21:28:26 -04:00
Solomon Peachy
3dda9bd99b sdl: Turn on debugf in sdl-threads by default
Change-Id: I688732ad9bb52bd4eeb77d989e1a20e50ddd4a2c
2025-07-29 21:05:53 -04:00
Hairo R. Carela
48392bab94 New port: Anbernic RG Nano
A bit of context, this device is a clone of the FunKey-S with a different form factor, hardware is mostly identical, the relevant difference is it has audio out (via usb-c, adapter to 3.5mm is included), this is the reason why the FunKey-SDK is needed for bulding.

This port is based on the old SDL 1.2 code because the device doesn't have SDL2 support. Alongside what was supported in the SDL 1.2 builds this port supports battery level, charging status and backlight control.

Change-Id: I7fcb85be62748644b667c0efebabf59d6e9c5ade
2025-07-29 21:01:53 -04:00
Solomon Peachy
9d3e286454 ipod4g: Explicitly initialize both UARTs
This should allow either accesspory port to be used for IAP comms.

No regressions on an ipodphoto and mini2g through the dock connector,
but I don't have any headset-attached accessories to test against.

Change-Id: If217d8147ee871b20ad5f81ba95542379eb9f2dc
2025-07-28 11:05:13 -04:00
Solomon Peachy
f27de46472 PP502x: Hacky technique to switch UARTs based on which IRQ was triggered
This lets us have multiple serial ports enabled, which will help with
4th-gen ipods that have a serial port in the HP jack as well in the dock.

Change-Id: I6a00a776020848a6908413e05a6f27bad65b2d8e
2025-07-25 14:26:08 -04:00
Vencislav Atanasov
843ac237c1 ROLO: Ensure messages are not covering each other, change punctuation
Change-Id: I7c9a96afce39d95f120c8349d489f0b649f1ae11
2025-07-24 14:13:07 -04:00
Vencislav Atanasov
a901b530e0 Require HAVE_LCD_SLEEP when HAVE_LCD_SLEEP_SETTING is defined
Change-Id: I5429c538b8c46ab857100f3a290c4241c8991038
2025-07-23 20:46:41 +02:00
Solomon Peachy
efefe143bd ibasso: Fix a build warning that got lost
Change-Id: I51287f5cdd7f07d9407ed6aac949d4e389d6df0e
2025-05-25 11:02:27 -04:00
Solomon Peachy
adb49159ce winsim: Build fixes for current mingw64 cross compiles
Change-Id: I5d523a4aa0ca9044b8f83ae6aafd4f3705ff96d6
2025-05-25 07:56:05 -04:00
Solomon Peachy
08a6f804ce ibasso: Use correct API to query power input and charging state
Instead of using the generic hosted sysfs code, which expects
a full path, the ibasso code's sysfs code uses an enumeration.
Unfortunatley the generic power input/charging code used the former
API but linked with the latter.  oops.

Correct this by placing a private copy of these functions in
the ibasso-specific port, and removing the generic version from
that build.

(A "proper" fix would be to rework all 17 of the ibasso sysfs calls
 to use the generic sysfs API)

Change-Id: Ic13adc9782d85560f0c74d77f60a629619d38668
2025-05-22 07:15:15 -04:00
Roman Artiukhin
3cb4e63253 strnatcmp: Sort dots first
Moves special folders (like .rockbox) on top and makes filenames sorting look more consistent with folders sorting. See https://forums.rockbox.org/index.php/topic,55303

Change-Id: I6ffd9b3ea0acfcbab69f09415f4e9f53737e7769
2025-05-18 22:50:05 -04:00
Roman Artiukhin
e08b8fcc74 strcasecmp: Optimize size and speed
Applies changes similar to strncasecmp in 64c0cfb0.

Change-Id: I5f80b0031dd12c58d982578f5c5224c7f59cd915
2025-05-18 16:57:35 -04:00
Solomon Peachy
afcebf1b48 Fix sea of errors introduced in cde144233b
I swear I compiled this successfully; clearly I had not.

Change-Id: Id604abeeeb895aa9c61acaad261b7190f0140089
2025-05-17 18:40:47 -04:00
Solomon Peachy
cde144233b misc: Suppress -Wformat-security when building with GCC7
Making splash -> splashf means its arguments are now checked
at compile time, but the "format" is nearly
always one of our virtual pointers instead of a string/format
literal.

Our gcc494 (and upcoming gcc950) toolchains handle this fine,
but simulator builds with gcc7 complain about this, so suppress
the warning for those environments.

(GCC 12, GCC 14, and GCC15 all seem to be okay with this too)

Change-Id: Ifaf061f14e2552db73a7515f61950ad83116e8b5
2025-05-17 17:30:09 -04:00