Commit graph

3705 commits

Author SHA1 Message Date
Solomon Peachy
f11c89aae2 usb: Fix usb mode not initialized/restored on the DX50/DX90
* Devices with ADB now have HAVE_USB_ADB
 * DX50/DX90 no longer set USB_NONE
   * stub out necessary functions
 * usb_set_mode() and global_settings.usb_mode are now:
   * called for all devices with (HAVE_USB_ADB | HAVE_USB_POWER)
   * wrapped with consistent #ifdefs

Fixes regression in ce88de54b8

Change-Id: Ib0c16082fe237e8159cd42847355186ea5c74589
2026-07-03 12:26:34 -04:00
William Wilgus
d87755c535 FS#13944 - FONT_UI loads the last loaded font not global_status.font_id
FONT_UI scans from MAXFONTS-1 to 0 to maximize the chances of getting a loaded
font but this may result in global_status.font_id being ignored even
if set through setuifont

this should take care of all the plugin woes dues to this
by setting the lcd font to the ui font before loading the plugin
and also making FONT_UI map to this font when font_get(FONT_UI) is called
if the desired font is not loaded then fallback to the previous behavior

Change-Id: I101d6f91910c17b08fca2b988a0a99c9e6899bee
2026-06-30 13:29:23 -04:00
William Wilgus
3e08b86e4b FixRed a824085 skin: add %pX tag checkwps, ATA builds
ata_disk_isssd() return 0 for SIMULATOR

Change-Id: If281b5ce7a98f338dfd81635c8936dd90c41b9bb
2026-06-27 13:27:35 -04:00
Solomon Peachy
5462f203d3 bidi: Expand+Correct the list of RTL codepoints in is_rtl_char()
Was missing:

 * Arabic Supplement
 * Arabic Extended B
 * Arabic Extended A
 * Rumi Numerals
 * Arabic Extended C
 * Indic Isqaq Numerals
 * Ottoman Siyaq Numerals
 * Arabic Mathematical Alphabet Symbols

Worth noting that most of these are vanishingly unlikely to ever show up
in the context of Rockbox.  (The exceptions are "Arabic Supplement" and
possibly the Mathematical Symbols)

Also corrected "Arabic Presentation" into two distint blocks, as
the characters between them (fe00-fe6f) are NOT indicative of RTL.

Change-Id: I0c5c547921c789d32425682c8c75edb21428f549
2026-06-27 10:20:03 -04:00
elishay
0e3355de50 keyboard: fix RTL (Hebrew/Arabic) on-screen keyboard
Commit d1be73c ("keyboard.c Use viewports, move text box pos")
moved the picker and edit line into dedicated viewports. Under an
RTL UI language these viewports get VP_FLAG_ALIGN_RIGHT, so
lcd_putsxy mirrors every call; with the per-character cell drawing
this reversed the picker grid and the edit line (Hebrew shown
reversed, Latin filenames backwards, wrong caret).

- Clear the alignment flag on the keyboard own viewports so the
  picker grid and cell layout are no longer mirrored.
- Draw the edit line as a single string so the bidi engine reorders
  mixed Hebrew/Latin correctly, and use the full line width.
- Compute the caret from the bidi (LTR-base) visual layout so it
  lands at the insertion point, including mixed Hebrew+Latin text.
- Pick the edit-line direction and invert the left/right cursor
  keys based on the text first strong character.

Change-Id: I79f1c444bc9121fd5018ad5f6f4148afe2c1a3e1
2026-06-27 07:45:12 -04:00
Adam N. Burke
383e227671 Sansa Clip Zip: Implement LCD flip (180 degree rotation)
Enable HAVE_LCD_FLIP for the Clip Zip and implement lcd_set_flip()
in the LCD driver, making the Display -> Flip Display setting work.
This lets the player be used upside down, e.g. clipped to clothing
with the control buttons pointing up and screen on the bottom.

Defining HAVE_LCD_FLIP also activates the existing button remap in
button_flip() (firmware/drivers/button.c) for this target: while the
display is flipped, LEFT/RIGHT, UP/DOWN and the volume keys are all
swapped to match the new orientation, so the whole device is usable
upside down, not just readable.

The flip is done in hardware by reversing the controller's GRAM write
direction and mirroring the write window in lcd_setup_rect, so partial
updates keep working and there is no per-frame cost. Both panel
variants are handled: the type 0 WiseChip/SEPS114A via MEMORY_WRITE/READ
(1Dh, 0x02), and the type 1 Visionox/LD7134 via the Graphic RAM Writing
Direction register (05h, 0x03). The direction register is written in
lcd_enable(), so it is set while the panel is powered and is re-applied
after display standby; lcd_set_flip() cycles the panel off and on so a
change to the setting takes effect immediately.

For the simulator, which has no real LCD controller, lcd_set_flip() is
implemented in the SDL LCD driver (lcd-bitmap.c) as a software mirror of
the framebuffer, so the flip is visible in theme previews; the generic
uisimulator stub is guarded out when HAVE_LCD_FLIP is defined.

Tested on real type 1 / LD7134 hardware in both orientations: display
content, button remapping and album art are all correct, and test_fps
shows partial updates run at full speed when flipped (1/4 frame 325 fps,
matching the non-flipped rate). The type 0 / SEPS114A path uses the same
approach; the 0x02 direction value was confirmed to flip a type 0 panel
by William Wilgus during review.

Change-Id: I99ef13949102b344826e72d1d90c71e2271448a6
2026-06-14 23:16:17 -04:00
Solomon Peachy
59a42fbf61 pcm: Pull pcm_is_ready back out of the sink structure
It is referenced by multiple threads, and as such needs to be both
volatile and SHAREDBSS to keep everyone happy.

...should address hangs on startup observed on nano2g and mini2g when
voiced menus are enabled

Regression introduced in dfa33c2 and made far worse by 759ef27

Change-Id: I202ec6c0d5825ff3a319b7d95d600b4ce06dd685
2026-06-10 09:21:21 -04:00
Aidan MacDonald
722e4f10ad Cleanup some unnecessary HAVE_HOTSWAP uses
Always define storage_removable() and storage_present() so
that ifdefs are unnecessary. They were already defined as
constant for the CONFIG_STORAGE_MULTI case, but not in the
case of a single storage type.

Change-Id: I13073b3a72b201b5b11167deb050e6f27139c61c
2026-06-08 10:32:49 -04:00
Solomon Peachy
d54b9e6f8d chore: Get rid of *all* vestigal CVS '$Id:$' tags
Change-Id: I35c13a9768c582e4851aa252dd3ea5c89f760c8c
2026-06-01 16:01:18 -04:00
mojyack
6e31703289 fix incompatible pointer errors with clang
clang uses "unsigned int" for "uint32_t", which does not match gcc's
"unsigned long".
fix errors caused by this.

Change-Id: I05aaf23934167a56a6e400f49fcaf8b70bfaca13
2026-05-27 08:43:49 -04:00
mojyack
2291aa24f2 usb: refactor control request handling
this commit is a combination of the following changes, which
significantly refactors usb core and class drivers.

1. unify usb buffers of each class driver to reduce iram usage
currently, many class drivers allocate their own buffer to receive
control out data, which is a waste of iram.
share one common buffer for that usage to address the issue.

2. simplify control request handling by implicitly receiving write
   request data packets
change 1 above fixed the data destination. therefore, having the core
receive the data allows us to reduce the class driver's work and
simplifies the api.

3. enhance usb core's control request handling and unify the legacy
   driver api
in order to implement change 2, both the legacy and new driver apis
should be supported. so that, using the designware driver as a
reference, the new driver api functionality is move into usb core.
this simplifies the usb device drivers by requiring them to implement
only the functionalities equivalent to the legacy api.

tested with ipodvideo(arc) and erosqnative(designware)

Change-Id: I3627daa90278751f599e2108ec150ec3f8f6c524
2026-05-25 12:42:36 +01:00
William Wilgus
58f75311d8 merge font_getstringnsize and font_measurestring
measure string just needed a bit more to be a replacement

Change-Id: I25c760df5edd7224b50c0522b4e44b1f9b574c51
2026-05-18 01:36:50 -04:00
William Wilgus
db32a7f07e [bugfix] font_getstringnsize() incorrect count, add font_measurestring()
maxbytes counted final characters not actual bytes

font_measurestring() returns the number of bytes of a string that will
fit in a given width

Change-Id: Id73b763267e399bd558f87872b5e715076f9b7f7
2026-05-14 09:51:58 -04:00
mojyack
8873cbb57e usb: designware: support max packet size override
Change-Id: I75d3aca1599ce064c604c96f2b5ed4c041f975b8
2026-05-04 16:45:57 -04:00
Solomon Peachy
d92b42c70f Fix Yellow & Red in 41caf678fe
Change-Id: If111595271289878097c2a8b30bec3f18390a49c
2026-05-04 14:04:26 -04:00
mojyack
41caf678fe usb: allow more flexible endpoint allocation
the capabilities of endpoint of several devices such as dwc2 change during
runtime, so they cannot be determined during driver initialization.
therefore, allocation using ep_specs is inappropriate.

to support these devices, add functions to the driver that determine whether
endpoints are available and make allocation more flexible.

tested with ipodvideo(arc) and erosqnative(designware)

Change-Id: I8005c17f3d763cd17306bf49918e1cd8084bdeff
2026-05-04 13:31:21 -04:00
Vencislav Atanasov
02638c1cb8 s5l87xx: (Re)name the SHA-1 registers
Synced with the s5l8702-sha1 Linux driver in the freemyipod fork

Change-Id: I5243346205f7883f4271d4b272936dd125adb496
2026-05-04 07:16:29 -04:00
mojyack
3bb656625b usb: add usb iAP driver
add class driver source files.
also register iap audio sink.
usbstack/iap/libiap directory is imported from libiap.

Change-Id: I776c5caec33fe9efadc448e2e3b37d500bf19c9f
2026-05-03 12:40:54 -04:00
mojyack
2b9e4a8d70 config: define USB_ENABLE_IAP
iap is only enabled for idevices.
it will not work without apple vendor id anyway.

Change-Id: I1696dbc8a2304fc5eecc5432b4c52e25801c468e
2026-05-03 12:40:54 -04:00
Aidan MacDonald
bafc796ce7 Fix errors from stdint.h removal (cf6fb81346)
Change-Id: Ie9457121448f47db14300e035dc5b5eccd086884
2026-05-02 23:22:03 +01:00
mojyack
472acce401 reggen.h: fix broken stm32 build with gcc-14
Change-Id: Ib504e6a75ac88be325adc6dd19c88bf263178f2d
2026-05-02 17:28:45 -04:00
Aidan MacDonald
80e3c0b065 mips: require 8-byte stack alignment
The o32 ABI requires at least 8-byte alignment. This fixes
the float formatting weirdness seen in quake (FS#13821).

Change-Id: I4b587946884d7b35cef420e607c7e127664849e2
2026-04-25 12:36:46 +01:00
mojyack
6dc731dff2 include pcm.h in pcm_mixer.h for pcm_peaks
Change-Id: I074fff95b5147a343d23e22e876b33884a173c97
2026-04-24 20:07:29 +09:00
Solomon Peachy
9dce0c3258 Work around a false positive compiler warning in pcm_switch_sink()
CC firmware/pcm.c
firmware/pcm.c: In function ‘pcm_switch_sink’:
firmware/pcm.c:311:38: warning: array subscript 1 is above array bounds of ‘struct pcm_sink *[1]’ [-Warray-bounds]
  311 |     struct pcm_sink* old_sink = sinks[cur_sink];
      |                                 ~~~~~^~~~~~~~~~
firmware/pcm.c:79:25: note: while referencing ‘sinks’
   79 | static struct pcm_sink* sinks[PCM_SINK_NUM] = {
      |

PCM_SINK_NUM is 1, and cur_sink is initialized to 0.  It can never be set
above 0.  cur_sink can never be >= PCM_SINK_NUM, ie 0, but for some reason
the compiler thinks otherwise.... sometimes.

This only shows up on native ARM builds with GCC9.5.0

Change-Id: I1aa731a4ee21c46a264c8b70833e3b43e777e8a7
2026-04-17 21:56:38 -04:00
mojyack
9ffc8a00ce pcm_mixer: implement mixer_switch_sink
Change-Id: I1549470774f96a6f470817cbc5fe4611812de6fa
2026-04-17 20:54:10 -04:00
mojyack
be4b0591ee pcm: implement pcm_switch_sink
Change-Id: Iace01c2e97950cc794f3cf755dc358da6f3daa7f
2026-04-17 20:52:23 -04:00
Christian Soffke
cc7418dd8b dsp: add option to swap left and right channels
Change-Id: Id4b518638436576cfb5e747548f10ece6e58eba0
2026-04-16 21:08:53 -04:00
Solomon Peachy
41893b250f ipod4g: Pull LCD framebuffer out of IRAM
The recent pcm_mixer changes caused us to overflow IRAM by a whopping 8
bytes.  This can _probably_ be mitigated with some clever reworking but
we were clearly already on the hairy edge.

Future pending changes are likely to increase IRAM pressure so even if
we solve this issue the odds are it will reappear at a future point.

(the ipod4g's framebuffer is 5KB.  This doesn't affect the mini2g as its
 framebuffer is under 4KB, and the ipodcolor doesn't put its framebuffer
 in IRAM at all)

Change-Id: I2f50d998e969a706cc9d3a0e057cf8e6c303c9b4
2026-04-14 10:27:20 -04:00
mojyack
e2040cc98c pcm_mixer: introduce mixer_buffer_cbs
intended to add sampr_changed callback to buffer hook as well as mixer
playback

Change-Id: I9df6194a884cfb813342a827b7fdc3bccbe3d60c
2026-04-14 06:50:39 -04:00
mojyack
cb04b8167c pcm_mixer: introduce mixer_play_cbs
the added sampr_changed callback can be used to notify the mixer user of
frequency changes

Change-Id: I309db76576090fd5c019a1ba082af446129dd4a3
2026-04-14 06:47:36 -04:00
mojyack
03060090c9 usb: arc: implement batched request api
Change-Id: I9d677286589a336d7258cf2c9d3c7d2847243dfa
2026-03-29 09:04:10 -04:00
mojyack
f84003fa40 usb: add fallback implementation of emulated batch api
some targets can process requests fast enough without dedicated
batch api implementation.
provide generic implementationn for such targets.

Change-Id: I152681441e70e0e98396274d9305d371d2bbfbe3
2026-03-29 09:03:56 -04:00
mojyack
d2b76a99f3 usb: introduce batched request api
in order to implement iap digital audio interface, we have to send
a pcm packet every usb frame i.e. 1000 packets per second.
this rate can't be achieved with current standard request-response design,
even with fast_completion_handler.
this is why this new api is needed.

Change-Id: Id3d7dd037660871e2bdb69656f63ff13280c3804
2026-03-29 09:03:29 -04:00
Solomon Peachy
759ef2767a pcm: Make pcm_is_ready a per-sink property instead of a global.
All that matters is that the _current_ sink is ready, not all possible
sinks.  When switching sinks we will need to ensure tehy are initialized
before switching over.

Change-Id: I341f7e9dcb4e2add4d0b292b68b69eb08dec0194
2026-03-28 07:09:54 -04:00
Vencislav Atanasov
aa834e83aa 3ds: Fix crash on shutdown
It is required to call gfxExit() before exiting the app if gfxInit() was previously called. Otherwise, the GSP thread continues to run after the stack is invalidated. The missing code is already in lcd_shutdown(), but it was never called because HAVE_LCD_SHUTDOWN was not defined for the ctru target.

Change-Id: I8999df6372cd593c5b52478028ad7421b23d5f92
2026-03-11 22:26:44 +02:00
Aidan MacDonald
a24142b234 firmware: cleanup duplicated DM320 LCD memory defines
Move the rather large block of code that's been copied
in three separate linker scripts into the CPU header.

Change-Id: I9f38e4901fa4ff699f00d97064a9cdaf7cfd6aab
2026-03-06 15:55:35 -05:00
Aidan MacDonald
99dd797169 firmware: cleanup PortalPlayer NOCACHE_BASE defines
Move the definition of NOCACHE_BASE to the CPU headers
instead of having them copy-and-pasted in a few places.

Change-Id: Ibbab27a5a07906d46dbd4dd9065f2238bc885d6b
2026-03-06 14:15:29 -05:00
Solomon Peachy
408f155f53 build: fix red in 7eeb4e4302
STORAGE_WANTS_ALIGN needs to be ignored for simulator builds

Change-Id: I4d788f91d3d1ed81c0621b9adac985ca188d918c
2026-03-06 13:37:27 -05:00
Aidan MacDonald
7eeb4e4302 firmware: refactor CACHEALIGN_BITS/SIZE defines
Mostly motivated by PP needing CACHEALIGN_SIZE in linker
scripts, which can't include system.h, so move these to
cpu.h instead. Also gets rid of the default 32 byte line
size that was used if the target didn't define alignment
itself. RK24xx, DM320, and JZ4740 were missing this but
have been confirmed (from datasheets) to use 32-byte cache
lines.

Add checks to make sure the macros are appropriately
(un)defined based on the HAVE_CPU_CACHE_ALIGN define,
and make sure their values are consistent when they
are defined.

Disable HAVE_CPU_CACHE_ALIGN for hosted targets since it
arguably doesn't matter if there's a cache, if we aren't
responsible for cache maintenance.

A few files in rbcodec use CACHEALIGN_SIZE, but these
can be converted to MEM_ALIGN_SIZE, which is identical
to CACHEALIGN_SIZE if the latter is defined. On other
targets, it aligns to at least sizeof(intptr_t).

Change-Id: If8cf8f6ec327dc3732f4cd5022a858546b9e63d6
2026-03-06 14:49:00 +00:00
Aidan MacDonald
dbfedcd65e stm32h743: rename CPU header to match other platform conventions
Change-Id: Ie7564df983aed460947ebde3bf73f8147d5bc974
2026-03-06 14:01:38 +00:00
Aidan MacDonald
f44b6c78e0 misc: respect standard __ASSEMBLER__ define in CPU headers
The JZ47xx and S5L87xx processor families used their own
special defines (__ASSEMBLY__ and ASM respectively) in
their CPU headers to check if they were included from an
assembly source file.

For GCC the standard seems to be __ASSEMBLER__, so check
for that instead and remove the non-standard symbols.
Being more consistent across platforms makes it easier to
include cpu.h from cross-platform files (eg. plugin.lds).

Change-Id: I282930cad34e1a2ff18166f3b4338548b34f4a49
2026-03-05 21:13:50 +00:00
Aidan MacDonald
cf1e3fd5a3 misc: remove leftover pnx0101 support code
Remove now-unused stuff related to the PNX0101 processor,
which was missed during the removal of the IFP-7xx port.

Change-Id: I5ff248b3e83cb67a357743130c3e51ed84a720e5
2026-03-05 15:41:06 +00:00
Solomon Peachy
ea570c5728 pcm: Make more of the low-level PCM API private
* pcm_play_data
 * pcm_play_stop
 * pcm_play_stop_int
 * pcm_is_playing
 * pcm_set_frequency
 * pcm_get_frequency
 * pcm_apply_settings

Now, the only user of these functions are the mixer and recording layers
that provide a higher-level API to plugins and the main [playback]
application.

Outside of the PCM core, pcm_apply_settings() was only used immediately
following a call to mixer_set_frequency(), so the latter function
now always calls the former.

Change-Id: I61c3144dc156b9de9b7963160b525c6d10c6ad4b
2026-03-03 13:09:21 -05:00
Aidan MacDonald
5c1ae51193 echoplayer: implement audio playback
Playback is implemented using a target-specific PCM layer,
using the STM32H7 SAI & DMA registers directly. There are
a number of pop/click issues:

1. Slight click when powering up the amplifiers
2. Click when starting and stopping playback
3. Popping when changing playback frequency
4. Popping when shutting down

It should be possible to eliminate or at least mitigate
(2) to (4) in software, but (1) happens as a result of
powering on the amplifiers while everything is muted so
might be unavoidable.

Change-Id: I398b66596176fb2341beb7deba7bf6f4f3fb82b3
2026-03-03 09:23:23 -05:00
mojyack
dfa33c246b pcm: introduce pcm_sink
move target-specific pcm operations into builtin_pcm_sink.
in subsequent commits, another pcm_sink is added, and it becomes
possible to switch between them.

Change-Id: I8f8b9661e01d6e6472f34224ddc3760856778457
2026-03-02 10:09:11 +09:00
Aidan MacDonald
ad45b2910a echoplayer: disable recording
Though the rev1 hardware is capable of recording from a
headset mic, this feature seems likely to be dropped on
future hardware revisions, and I don't see much point to
implementing it now.

Change-Id: I77e403bdd1ca53f9018835d3c3042dc86ee0f8f3
2026-02-27 20:11:27 +00:00
Aidan MacDonald
df89a47c11 drivers: add TLV320AIC3104 codec driver
Change-Id: Ic8825fc8f057c28316e9f7cb6af3dd34e8200d48
2026-02-26 15:00:13 +00:00
Aidan MacDonald
33cdbf87d7 echoplayer: add echoplayer-specific codec header
Remove the generic TLV320AIC3104 codec header. The codec
is sufficiently complex that a one-size-fits-all driver
isn't really feasible, eg. due to different clocking and
output configurations.

It's easier for targets to have their own audio headers
tailored to their use case than a generic header with
lots of ifdefs.

Change-Id: I63d92d57c28ddd7da7aa3174bd583d8afb1aa56d
2026-02-26 15:00:13 +00:00
Paul Sauro
914760b54e config: USB_CHARGING_FORCE must be enabled for all iPods
If not, these devices will charge very slowly (0.07A) when plugged into a wall plug, and will all discharge slowly when docked & playing music.

Enabling this option (that is already enabled by default on some other devices like erosq and fiio m3k) make them pull between 0.20 and 0.30. They charge faster, just as fast as on Stock OS, and won't discharge when playing music while docked.

Change-Id: I90a59caaca463354772b1869f7333d8efce4f117
2026-02-23 16:11:38 -05:00
Solomon Peachy
922b5e9a4b vx767: Bring config in line with its siblings
* Single storage device type (SD) that can be hotswapped
 * Fix bootloader build

Change-Id: I494a46ccf0f7f70cfa149a0727977aa421891d6c
2026-02-23 08:32:44 -05:00