Commit graph

11480 commits

Author SHA1 Message Date
Aidan MacDonald
e05aa27124 x1000: move NAND commands to header file
Change-Id: Ic95b80494a101f7b349e115d82e9dfe3a64b643f
2022-05-30 14:02:13 +01:00
Aidan MacDonald
5ee9a45126 mips: stop backtraces at main()
Initialize ra=0 before calling main so backtraces don't walk
through the startup code.

Change-Id: Ia8796ce38b32d14025b47b3e00061267ee25cbaf
2022-05-22 07:16:11 -04:00
Aidan MacDonald
981e972839 mips: add native backtrace implementation
Should make debugging crashes on native MIPS targets far easier.
This is by no means a 100% complete or robust implementation but
it seems to handle the vast majority of functions.

Change-Id: Id5f430270e02b5092b79026b6876675c784aa649
2022-05-22 07:16:11 -04:00
Aidan MacDonald
2315266628 kernel: remove unused function mutex_test()
No longer needed since the only user was in the Archos code.

Change-Id: I763f58050c70f2bb1d8cc0a044c63698f3157a8d
2022-05-14 11:29:55 -04:00
Aidan MacDonald
dafc8e5904 kernel: remove unused kernel/pthread/*.c files
These don't seem usable and it looks like the files were added by
accident by d66346789c "buflib: Check the validity of of handles
passed to buflib_get_data() in DEBUG builds."

Change-Id: I4d4601f1fef7901c08ae86448853d008f48d5f43
2022-05-14 11:29:55 -04:00
William Wilgus
79864c6ec2 add const to const * strings
I don't think this will amke any difference except maybe for hosted ports

Change-Id: I84f898aea92a6963901a6d889dd18b63f24c9a41
2022-05-03 23:00:58 -04:00
Aidan MacDonald
a234df30df Fix sim build for glibc >=2.34
Change-Id: If63787514b6bffc0afb71f9d651f8c6f0c328a2d
2022-04-18 09:54:07 -04:00
Aidan MacDonald
fca7b8e2ff Fix undefined behavior that blocks compiling with UBSan
Left shifts are not defined in C if they would cause signed overflow,
so these expressions get instrumented, which makes them unusable as
switch values and triggers compile errors when compiling with UBSan.

Change-Id: I0588d4be1e00ba1cfde0eac119ead368b20d10c9
2022-04-17 11:37:34 -04:00
William Wilgus
c4156b1909 viewports, set flags to VP_DEFAULT_FLAGS
flags were getting un-initialized memory
it really didn't matter with the flags getting initialized
anyway
But once I added a new flag that didn't explicitly
set or clear the flag at init well here we are

set flags to VP_DEFAULT_FLAGS in viewport_set_defaults()

add the flags variable to the default vp's set to 0
(it was already initialized to 0 by bss, make it explicit)

Change-Id: I3a9a062455b4cf66d2b8c70fdf05402a5c0c091c
2022-04-17 10:59:56 -04:00
Aidan MacDonald
d55dceff37 apps: Add ability to do a clean reboot
Allow a clean shutdown to end in either power off or reboot. Add a
new event SYS_REBOOT to signal it and sys_reboot() to trigger the
event. SYS_REBOOT signals a reboot request and should be listened
for alongside SYS_POWEROFF events.

Change-Id: I99ba7fb5feed2bb5a0a40a274e8466ad74fe3a43
2022-04-16 14:36:39 +01:00
William Wilgus
ff08841ea9 viewport FIX RED remote screens
Change-Id: I894a5c3e9053f44dee4803e9cdbbcb8f651ee318
2022-04-15 08:16:28 -04:00
William Wilgus
d56d96031c viewports add flag to disable updates
when drwing multiple areas of the screen with other gui elements
you might want to combine updates into a single screen redraw

Change-Id: Ie4130366fa13e25d3d14e937257d11547dd61134
2022-04-15 01:54:42 -04:00
Aidan MacDonald
98f762316f system: update MEM_ALIGN_ATTR for targets with CPU caches
MEM_ALIGN_ATTR should take advantage of cache line alignment on
all native CPUs which define it, not just ARM CPUs. (This could
arguably be done for hosted targets too, but we don't necessarily
know the size of a cache line there.)

Change-Id: Ife9302105ea57388afd55ce31da848b00b5b1b25
2022-04-01 12:08:41 -04:00
Dana Conrad
de285741bf ErosQ Native: Make power delay bootloader-only
gotta go fast

Change-Id: Ic01e4aa70a2bec4c48ae7cf8f32f8dfd366decad
2022-04-01 12:04:46 -04:00
Dana Conrad
7aa2a23b95 Eros Q Native: Add Original Firmware Boot option
Hold "Play" to boot the OF, or boot it from the recovery menu
by holding "Vol. Up". If you had the hosted port installed on your
player before installing the native port, you'll still have to go
through the hosted bootloader.

A couple notes:

- When booting from the menu, the recovery menu disappears, then
  reappears before going into the OF.

- You need to hold the play button for like a half second after the
  blue light comes on in order to get into the OF.

The recovery appears to be there, but it doesn't seem to be intended
for end users - it just says "Updater V1.1 - Insert TF Pls". I haven't
tested it beyond seeing that it boots, so I'm going to comment it out
for now.

Change-Id: Ie271ee479bb628cc74141b7fe07273b3f193f358
2022-04-01 12:04:30 -04:00
Aidan MacDonald
4f05a9d066 Add path_strip_last_volume
This gets the volume that the path eventually refers to by parsing
the last volume specifier and returning the part of the path after
it (which does not contain any volume specifiers). The initial part
of the path therefore contains everything up to and including the
last volume specifier.

Change-Id: I9a935543256f8f22e0b8b1e3c88d4e47bd9dae8a
2022-04-01 11:40:02 -04:00
Aidan MacDonald
412dbaeffe hosted: call 'sync' before poweroff
Might be needed to avoid filesystem corruption with buggy OF kernels.

Change-Id: I589eec6c1536beccf849716f11204b4b83a942a1
2022-03-31 21:40:04 -04:00
Aidan MacDonald
7243f6b343 x1000: Add multiboot support
Enables multiboot for the FiiO M3K, Shanling Q1, and Eros Q native port.
Note this requires an up-to-date Rockbox _and_ bootloader.

Usage instructions will (eventually) be found on the wiki:
https://www.rockbox.org/wiki/MultibootBootloader

Change-Id: Ia2da1ad6ef611e499d2fbafa93838387bc1023ba
2022-03-27 10:35:02 -04:00
Aidan MacDonald
bcbb5a8b00 multiboot: Allow searching in volume 0 for redirect file
Searching in volume 0 is necessary for multiboot targets with only
one drive, like the M3K/Q1/ErosQ. Without this the search code will
never look at the redirect file on these targets.

The search bound is configured with a setting MULTIBOOT_MIN_VOLUME,
which defaults to 0, but is defined to 1 for Sansa players so they
keep their old behavior.

Change-Id: I6dc5cf98db4258731de2c68c3ab1182b4a4a655b
2022-03-27 09:50:33 -04:00
Aidan MacDonald
5d0f697e87 x1000: remove the last vestiges of boot option support
There should be no need for any compatibility hacks since this
value was mostly used internally between the SPL and bootloader.
clk_init() was the only user in the main Rockbox binary which
accessed it, but when loaded by the Rockbox bootloader that code
will not be reached since BOOT_FLAG_CLK_INIT is already set.

Change-Id: Idd68b9834172e652b47432bfb1e00c923ea35407
2022-03-25 21:36:51 +00:00
Aidan MacDonald
3ae4a98e3b x1000: spl: remove selectable boot option support
Now the SPL boots the Rockbox bootloader unconditionally, which
allows for some simplification.

Change-Id: Id75c82db25a87e0e9043bb0771f622b1fc9482fb
2022-03-25 21:36:51 +00:00
Aidan MacDonald
2810c549a6 x1000: spl: remove dual boot support code
Removes the SPL's dual boot support code, and removes the dual
boot selection code on the M3K and Q1 since they can now do it
from the main bootloader.

Change-Id: Ie1b27e98c6ed4b3e37db86cfb485d6f3a6c5b25e
2022-03-25 21:36:51 +00:00
Aidan MacDonald
7cb49cfb33 x1000: spl: split off NAND storage to separate file
Just tidying. No functional changes.

Change-Id: I8aa85c789d1a6bd357797c6c95e38a7325eba809
2022-03-25 21:36:51 +00:00
Aidan MacDonald
5160c90690 x1000: bootloader: add screenshot function
Screenshots of the recovery menu will be useful for documentation.

This can be disabled by turning off HAVE_BOOTLOADER_SCREENDUMP in
the target config file if the bootloader should ever run up against
max size limits.

Change-Id: I62ec1e465df2ca7a8a0e78625d88b31f6c4ef078
2022-03-25 21:36:51 +00:00
Aidan MacDonald
5b011c8dca x1000: add bad block marker position to nand_chip info
Change-Id: I6f466d87f6f11bc3e23463c469f318ecb7049ba7
2022-03-24 23:40:07 +00:00
Aidan MacDonald
41a8b874d2 linuxboot: add meaningful error codes
Change-Id: Ied964e99c389902bb1786c414c5d0fa20056040d
2022-03-24 23:40:07 +00:00
Aidan MacDonald
6a6c6083fa x1000: bootloader: fix Linux self-extracting kernel boot
Basically, there's longstanding bug in Linux with self-extracting
kernels on MIPS which just happened to manifest now on the M3K as
a hang on boot. The fix is applied to the M3K and Q1 since they
both use this type of kernel image.

Change-Id: I17d2bad6eebd677cd6d2e0bf146450c71fcf1229
2022-03-24 23:40:07 +00:00
Aidan MacDonald
44fbb1a593 x1000: bootloader: add LCD dualboot cleanup for the M3K
Disable LCD interrupts before booting the OF - the OF kernel
hangs at boot if they are enabled.

Change-Id: I4f119818d0243953cdd620e17d9509b4fb16cc28
2022-03-24 23:40:07 +00:00
Aidan MacDonald
9bde653410 firmware: allow screendump in bootloader
Enabled if target defines HAVE_BOOTLOADER_SCREENDUMP

Change-Id: Idc135ef81e55d0f3eb8e7d2763d455c6455cf8fd
2022-03-24 18:59:50 -04:00
Aidan MacDonald
e956f7dc83 firmware: minor screendump related cleanups
- Remove unused redefinitions of screen_dump() from bootloaders
- Use empty do-while when screendump is compiled out

Change-Id: I3ccdb0390ddaa28d8f561ff744d0db6aaef17f5d
2022-03-24 18:59:50 -04:00
William Wilgus
cfeeb7889d Lcd save function pointer to frame buffer get_address_fn before loops
Calling multiple levels of indirection in a loop slows things down

Really these need to be rewritten to take a start and end address
like most of the rest of the codebase

But this is safer without having test hardware in hand

Change-Id: Idae7b92ee779d020ed7fcc9334e2d5a9c710e64d
2022-03-21 23:53:48 -04:00
William Wilgus
60e5786b48 lcd-bitmap-common optimize a few viewport functions
Change-Id: I71cd61f66e875280d07f17a9e828fbecc305bad2
2022-03-21 10:00:04 -04:00
William Wilgus
b65763bc10 [COV] fix uninitialized warning
Change-Id: Ib526aeac51d626d02b073b26efd3020115641caa
2022-03-18 20:19:18 -04:00
Aidan MacDonald
67f7d399e5 x1000: restore crt0.S cache flush
I-cache must be flushed after copying code to IRAM... duh.

Change-Id: I6eacc4b7c4385175724c947f6c53f7bbddcb6295
2022-03-16 23:21:29 +00:00
Aidan MacDonald
c676736792 x1000: optimize crt0.S, improve correctness
Replace inline section copy/fill loops with subroutines, which
reduces code size a bit and and handle zero size copies properly.

Remove the cache initialization loop as well. There's no actual
reason for this because the SPL initializes the caches and just
dropping the cache can even be harmful (in this case it wasn't,
because the SPL flushes the whole cache right before calling in).

Change-Id: I7cddc9ed6d060b1f1bdd75544297883d014cad2d
2022-03-16 12:02:24 -04:00
Wolfram Sang
0df71c952c rds: make newly added function static
It won't be called outside the RDS core.

Change-Id: I22f9d7984213f32ad1db49368327243ba2aa917b
2022-03-16 11:54:26 -04:00
William Wilgus
a5c16d2990 rb_namespace add logf
add logging to the namespace file to allow debug of root redirect

Change-Id: I6032aea880998c05dacf3d0d2e0d222205b9376e
2022-03-15 00:45:00 -04:00
William Wilgus
6fdc160fab dircache_redirect.h, hide root volume when only one mounted
there is no need to show the root of the drive when only the
internal is mounted

Change-Id: I310c48befa51742d05b6d5ce501d0b7c2c7c7ab7
2022-03-13 17:40:17 -04:00
Aidan MacDonald
8b4949381c x1000: add TCSM section to linker script
This is intended for debugging OF kernel boot problems and has
to be enabled manually at compile time to make it usable.

Change-Id: Ie5ce9f0a7639be0acf5e3879cfc3a7b8b89caa5c
2022-03-12 14:50:45 -05:00
Aidan MacDonald
d56964cc2b x1000: add dual boot helpers for the main bootloader
Two helpers (_init_clocktree and _init_uart2) already existed in
the SPL and are copied verbatim from there. The SPL versions are
still present and will be removed when dual boot works from the
main bootloader.

The other two helpers (_cleanup and _load_pdma_fw) are new.

Change-Id: I4661667966e26f52e6c5142f1947d2a34b7008ef
2022-03-12 18:25:10 +00:00
Aidan MacDonald
a87f93d8ff x1000: add function for booting linux kernels
Change-Id: I0750b084fe88d21a8686daf0681b32b1dcba8fec
2022-03-12 18:25:10 +00:00
Aidan MacDonald
58225bd2c8 x1000: remove plugin and codec buffers on bootloader
On the bootloader there's no point reserving memory for these,
the only users of codecbuf/pluginbuf are in the apps/ tree.

Change-Id: Ib57b4d59aff8f4dcc753d7993956ed15e61cdc52
2022-03-12 18:25:10 +00:00
Aidan MacDonald
38eafb60ff x1000: use core_alloc in bootloader for loading rockbox
Using the audio buffer directly is a bad idea because this will
render core_alloc non-functional if load_firmware() writes into
the buffer but then fails, for example on a checksum mismatch.

Change-Id: Ib2d17bcea53bdea1c4c5496cec0c4eee5dd66069
2022-03-12 18:25:10 +00:00
William Wilgus
97ec0a7e73 Root redirect un-hide root volume
this appears to be problematic for now

Change-Id: Ieb789f5ec10a0d25c559e9bfc2497cbc4f59c0ad
2022-03-11 20:11:31 -05:00
Aidan MacDonald
603412f447 x1000: Clarify definition & usage of RAM areas
Document what the symbols are supposed to mean, fixup SPL's
usage of DRAM_END which should really be SDRAM_END instead.
No functional changes.

Change-Id: Ie85b0ee35fea8b7858891e5b9d6634eaae42c9f8
2022-03-11 11:15:56 -05:00
Aidan MacDonald
428491df69 x1000: support new binary header in rolo
Change-Id: I192c3d69616c39534ff329174c4d8d4a357d014d
2022-03-11 11:15:56 -05:00
Aidan MacDonald
7fa48faeb5 multiboot: Refactor duplicated functions to a separate file
The implementation of write_bootdata() and get_redirect_dir() was
copied verbatim in two different places, obviously a bad thing for
maintainability. This moves them to a new file multiboot.c as they
are only used for multiboot.

Change-Id: Id0279216e4dd019f8bf612a81d3835eff010e506
2022-03-11 10:58:20 -05:00
Aidan MacDonald
439b4e8bca multiboot: Remove bad multiboot code from hosted RoLo
This looks like it was copy-pasted blindly from elsewhere and it
wouldn't even compile, since hosted RoLo is completely different
from native RoLo.

Change-Id: I4074f5323dcbdae85db8a04f222c858e9a228432
2022-03-11 10:58:20 -05:00
Aidan MacDonald
eae9f6f5b7 erosqnative: Fix missing END marker in LCD enable sequence
Change-Id: I75b3a396174e84d72e70c6f177bc1702021805f1
2022-03-11 10:42:18 -05:00
William Wilgus
f6a2bf28e1 BUGFIX file.c open failure leaves open file handle
Change-Id: Iad8eef2f65af0549da4dbec654c85adb2f325711
2022-03-11 03:18:38 -05:00
Aidan MacDonald
ca12478df6 x1000: add simple binary header to declare the load address
The header format is basic, a variable length list of values
tagged by 4-byte strings. The main application to to allow a
loader to determine the load address of the binary at runtime
instead of using a hardcoded address. But the header contents
aren't fixed and it could be extended for other purposes too.

Change-Id: If51d85b4c2eb53c919a91b54985b157e8e5c20ef
2022-03-06 23:22:49 +00:00
William Wilgus
bc3fa53937 Sansa Multiboot Root Redirect Enhance + bug fix
filename buffer was too small to retrieve redirect path

if redirected to sd root remove <SD1> as it is redundant

Change-Id: I1326601f1ba4a18d6bc173798759eb762b55528c
2022-03-06 16:42:26 -05:00
Aidan MacDonald
ee87bfb933 Add support code for dealing with U-Boot uImages
Adds a loader for the legacy uImage format that is commonly used on
embedded Linux systems. It verifies checksums and supports uncompressed
and gzipped images. Supports arbitrary reader functions to allow the
images to be streamed off any storage device, for optimal RAM use.

Change-Id: I93c35f9a6f323999a22a07300e05627fabfcbd2c
2022-03-04 09:02:56 -05:00
Aidan MacDonald
d541a3a191 x1000: fix nand driver reference counting
Somehow I screwed this up as well. Seems it didn't cause trouble.

Change-Id: I5ab99dd9182a4e60d55984fecbf20ca823dbd004
2022-03-04 08:57:35 -05:00
Aidan MacDonald
3cb7167e22 x1000: fix bug in nand_read_bytes
This didn't account for partial page reads properly which resulted
in corrupted data. Fortunately, current released bootloaders do not
perform such reads so they don't trigger this bug.

Change-Id: I426a95ef8d0f20f4567498530e216d80e1aceef2
2022-03-04 08:57:35 -05:00
Aidan MacDonald
3bd5f335f7 inflate: Add helper for getting decompressed data size
Helper for another semi-typical operation: find out how big of a
buffer should be allocated before decompressing. This can be useful
when the stream container doesn't specify the decompressed size.

Change-Id: I5f1536f809bb6f9bc6023120c024c3de7cea4269
2022-03-04 08:44:56 -05:00
Aidan MacDonald
ce4620413b inflate: Add helpers for using in-memory buffers
Using an in-memory buffer for the input or output data for 'inflate'
is likely to be extremely common and there's really only one way to
do it, so predefined helpers should be provided.

Change-Id: Ifd22e7b140a08e0e7dc05aec6b340dff5e2d9d0a
2022-03-04 08:44:56 -05:00
William Wilgus
fe4628fc30 Fix Red Multiboot Firmware Root Redirect
Exclude bootloaders

Change-Id: Id26120df0a047711efe49a43917dfec4c25107cb
2022-03-03 23:20:07 -05:00
William Wilgus
c9857098ac Multiboot Firmware Root Redirect - WIP
Loads external drive into root namespace
Root Redirects can now be put into different folders
For instance placing '/_test' into SD1/rockbox_main.<playername>
will redirect to /<1>/_test/.rockbox
Debug menu>Bootdata now has root directory listed in addition to RAW Bootdata

Redirect root work from Michael Sevakis g#1556, RESTORED -> g#4256

Change-Id: Ia97cf50ff5f5b440877f9c005da6f12c53af931e
2022-03-03 22:08:28 -05:00
William Wilgus
c7bbd5b090 Fix Red SDL, Android mounting root directory, and all the yellow too
Change-Id: Ic5077140fdcb1e3168111336bc428c27a782123c
2022-03-03 20:38:57 -05:00
William Wilgus
0ddac1fdaf Fix Red SDL, Android mounting root directory
Not actually used in either atm

Change-Id: I40e0143fdde1970ac485bf664962c62d4c493d57
2022-03-03 20:08:12 -05:00
William Wilgus
9daacabd65 [RESTORED!] Allow mounting of any directory as the root directory.
Provide definitions for the macros:
* RB_ROOT_VOL_HIDDEN(v) to exclude certain items from the root.
* RB_ROOT_CONTENTS to return a string with the name of the
directory to mount in the root.

Defaults are in export/rbpaths.h

It's a bit much for those that don't need the full functionality.
Some conditional define can cut it back a lot to cut out things only
needed if alternate root mounts are required. I'm just not bothering
yet. The basic concept would be applied to all targets to keep file
code from forking too much.

Change-Id: I3b5a14c530ff4b10d97f67636237d96875eb8969
Author: Michael Sevakis
2022-03-03 18:58:07 -05:00
Aidan MacDonald
e8faf2f2ad buflib: add a common dummy callbacks struct & use it
There are various allocations that can't be moved or shrunk.
Provide a global callback struct for this use case instead of
making each caller declare its own dummy struct.

Also fixed ROLO and x1000 installer code which incorrectly
used movable allocations.

Change-Id: I00088396b9826e02e69a4a33477fe1a7816374f1
2022-02-12 10:24:32 -05:00
Wolfram Sang
95dfc489b5 sync clock with RDS time
Tested with my SansaClip+. I don't think this will need extra battery
but let me know if I am wrong.

Change-Id: I287dae134113e0f8a138af68f5087b8ea45b0f4c
2022-02-07 22:04:10 +01:00
Wolfram Sang
5b8873bf33 RFT: convert Gigabeat RDS to thread
This kind of reverts 7b596416bf ("Gigabeat S: Update RDS processing to
use asynchronous I2C rather than thread."). However, requiring RDS to
run in thread context will a) allow more upcoming features and b) remove
quite some complexity from the codebase (see the diffstat here) because
Gigabeat is the only user. iMX31 should be able to handle one more
thread, as it can even run Linux.

Change-Id: I46130034595ba66392c5417c275d036f4bd26943
2022-02-07 22:01:20 +01:00
Aidan MacDonald
b25d8457bc Shanling Q1: fix DAC power mode switching
The OST prescaler bugfix (7a5130a277) broke runtime switching
between 1.0V and 2.0V modes. The 1ms delay after shutting down
the DAC isn't long enough to reset it, so it gets stuck in the
power mode assigned at boot. Change the delay back to 4ms, the
effective value prior to the OST bugfix.

Change-Id: Ic4583d1a6fa82540062aa185386f14bbf785a3f4
2022-01-30 17:37:24 +00:00
Wolfram Sang
76a2a00732 si4700: optimize RDS cache update a little
use si4700_read() instead of si4700_read_reg() to make it clear we are
not interested in the register itself but in the cache update. Also, a
tiny bit more efficient as we save a function call and don't request a
return value we don't use anyhow.

Change-Id: Ibbb66fd9e5ea748ba11ac3c2a0570f5219b72637
2022-01-30 12:27:30 -05:00
Aidan MacDonald
127bb1b6e1 FiiO M3K: remove volume setting on rec. screen
This controls the playback volume, which is not useful for
the M3K because it's impossible to play back and record at
the same time.

Change-Id: I5b0931c22b484f3ff6441d6c88079f18ec70f7f8
2022-01-29 15:13:54 -05:00
Aidan MacDonald
c1f1d91404 FiiO M3K: audio recording
Recording works now, although I'm sure there will be a few
things that need fine-tuning. A major issue is that writing
to the SD card creates noticable interference, which happens
on the original firmware too but seems worse under Rockbox.

(Since Rockbox waits until RAM fills up before writing data,
the interference will only be heard on >50 MiB recordings.)

Change-Id: I5561dd9668c3bdd34e92f34ef50848aef8c0b7eb
2022-01-29 19:28:03 +00:00
Aidan MacDonald
d93e054419 fiiom3k: power down amp before switching DAC power modes
As detailed in the <Low Power Mode> section of the AK4376A
datasheet, the amp should be powered down before switching
power modes (or to a sample rate <= 12 KHz).

Change-Id: I3ab0a21c78a3ad2bb418b64c916f7dbe2a843efa
2022-01-16 19:35:40 -05:00
Aidan MacDonald
dac3175445 audiohw: avoid magic numbers for DAC power mode
Define proper symbolic constants for power mode. Also allow
targets to define the default power mode setting.

Change-Id: Ia07cf854dce47d0a6aa88e067471f1ff9fbc45fb
2022-01-16 19:35:40 -05:00
Aidan MacDonald
18b3e91707 x1000: internal codec audio driver
Change-Id: I2eb551ec6b593951c33ae6b93df2a23dc6612c43
2022-01-16 19:17:25 -05:00
Aidan MacDonald
15e3d37110 x1000: core PCM recording support
Change-Id: I71883272cc3bffadc1235b0931c3f42bb38e4c1e
2022-01-16 19:17:25 -05:00
Aidan MacDonald
c62c323ebc axp-pmu: adc refactor
Remove the battery power ADC since it's not used right now,
and seems to fluctuate too rapidly to be of much use.

Change-Id: If115e4e3ce14d4c18ce899f5a889f7f99ab66489
2022-01-09 20:12:41 +00:00
Aidan MacDonald
b490f08b7c axp-pmu: remove chip ID code
It's useless except to developers, who can easily add code
somewhere to print the ID.

Change-Id: I486240f1c7b45808a1a830abdb22b9381d69cb3f
2022-01-09 19:58:35 +00:00
Aidan MacDonald
eee8243102 axp-pmu: clean up charge current setting
Change-Id: Ifac30f728887c376a83052c826b4bb6a98bbd27a
2022-01-09 19:58:35 +00:00
Aidan MacDonald
eaee5e7339 Revert "AXP PMU rewrite (again)"
This caused LCD problems on the ErosQ, where the screen would
go white until being put through a sleep/wake cycle. The exact
reason for this isn't obvious, but the problem didn't exist
prior to the AXP driver rewrite.

The two dependent changes,

42999913ba - x1000: Increase USB current limit to 500 mA at all times
90dd2f84a9 - x1000: Correctly limit USB charging current

ended up bringing the USB charging situation back to where it
was prior to the rewrite, so the cleanest option is to revert
the whole lot.

This reverts commit 42999913ba.
This reverts commit 90dd2f84a9.
This reverts commit 2d89143962.

Change-Id: I1cff2bfdd1b189df14bcf8cce42db725caa470d7
2022-01-09 19:58:34 +00:00
Aidan MacDonald
42999913ba x1000: Increase USB current limit to 500 mA at all times
The 100 mA USB current limit added in commit 90dd2f84a9
is a problem when booting with a completely dead battery.
Often 100 mA isn't enough to power the player, never mind
charge the battery, so revert to the old behavior of only
limiting charge current.

Given that the original firmware on these devices isn't
following the USB spec to the letter, it's probably not
worth trying to make Rockbox do so unless and until it
causes a real problem - which hasn't happened yet.

Change-Id: I179a08310c226fe01460680c62fd25fd69079256
2022-01-02 20:11:03 +00:00
Aidan MacDonald
83c2398384 x1000: Fix USB connection problems in bootloader
This problem actually had nothing to do with USB boot; it's
because the cable is plugged in when the USB mode menu item
is selected. The USB thread detected the select button press
and went into charge-only mode (as it usually does when you
hold down a key in Rockbox). This is fixed by having the USB
thread ignore most keys in the bootloader.

USB connect events are delivered via the button queue, and
there were also cases where the connection could be missed
if the event happened within another UI screen. This should
also be fixed.

Change-Id: I077d705a6ac845c8713219eee45d26aa6addfa61
2022-01-02 20:11:03 +00:00
Aidan MacDonald
af872b54ec powermgmt: Bugfixes to time estimation code
Guard against division by zero and prevent the time_now
value from going negative if the counter drops below zero.

Change-Id: Ia8cadfe76086d6d0200964c1f27bab0be708b135
2022-01-02 20:11:03 +00:00
Aidan MacDonald
96cfe329a6 powermgmt: Better time estimation
This method, while far from perfect, is able to make use of
real-time battery usage information and updates frequently
in fine-grained increments. This should make time estimates
a lot more useful than they previously were.

Change-Id: I66c6daba88210f60a27e239fbbcc56869be3b878
2021-12-28 10:47:40 -05:00
Aidan MacDonald
90dd2f84a9 x1000: Correctly limit USB charging current
The way this was done before was wrong - limiting the charge
current is not enough since the device will draw additional
power to run. Use the AXP192's vbus current limit control to
stay compliant with the USB specification.

Change-Id: I91b84e3480a432e49bec53cf2a17e4e3444404a4
2021-12-28 15:20:27 +00:00
Aidan MacDonald
2d89143962 AXP PMU rewrite (again)
I noticed a few mistakes in the old driver code and it was in
need of an overhaul anyway... I decided to scale things back,
simplify the code and remove most of the debug menus, netting
a nice code size savings.

One new feature is an advanced debug menu which is accessible
by recompiling the code with AXP_EXTRA_DEBUG. It adds quite a
bit of code size and isn't useful other than for development
so it must be manually enabled by editing the source.

Change-Id: I30e17c1194c14823decd726a574ed14451d4cb2d
2021-12-28 15:20:27 +00:00
Aidan MacDonald
22d0c4da70 Revert "powermgmt: Remove an unnecessary function"
This reverts commit 6ff1a935b9.

Reason: it created a mismatch between the displayed voltage
and percent since the voltage was unfiltered but percentage
was based off the filtered voltage.

Change-Id: I4cba099f2e1edf0ef7c4e17a32f566aa66f5b933
2021-12-23 11:40:22 +00:00
Aidan MacDonald
1a313dc9bf Report battery current on all X1000 native targets
This allows battery run time to be calculated from the
actual battery usage on the FiiO M3K and Shanling Q1.
This isn't very good for the time being and the estimate
tends to go all over the place due to small variations
in current or voltage.

The Eros Q can support this feature as well, but since
it already has fixed estimates defined and the quality
of the "real time" estimate is low I am not enabling it
there.

Change-Id: Id34a93ee4b7d66f9f7e56ef0f5149f67e8e72039
2021-12-23 11:39:58 +00:00
Aidan MacDonald
ad05c872fe powermgmt: Add battery current measurement
This allows targets to report the actual discharging or
charging current if they are able to.

Change-Id: I0b538e6ac94346f1434e45f83c8da8c1260a53a3
2021-12-23 11:39:58 +00:00
Aidan MacDonald
923f92cb12 Fix yellow from 4506f2b58d
Change-Id: I60bb56830ef5ba0fcde4564cdafef594af400c70
2021-12-23 11:37:15 +00:00
Aidan MacDonald
4506f2b58d powermgmt: Refactor battery measurement code
I've tried to clean up cruft and clarify what's being
done, prior to adding new features. The behavior should
be unchanged.

Change-Id: If8a68b7b48173d283df981a21cdd854b714e7695
2021-12-23 00:12:43 +00:00
William Wilgus
8060c79775 allow sim to shutdown while 'charging'
Change-Id: I28a9312d1ce6bf68d8ee6fc2cca680047bfec810
2021-12-11 09:59:39 -05:00
Christian Soffke
a3684e090e m3k simulator: remove white border
Change-Id: I1503dadc966af568c8a4482e1d7f5641092594f0
2021-12-10 19:46:09 +01:00
Christian Soffke
f1eb0483d6 m3k simulator: add screen bezel
Change-Id: I4a34e5be7a459f909b81266b70c30f2968068696
2021-12-10 18:01:38 +01:00
Christian Soffke
7e0e4fe888 Add setting to hide shutdown message
Also keeps display from lighting up before shutdown,
which reduces distractions, especially at night and
when the sleep timer is used by allowing the
screen to remain dark.

Change-Id: I1c2d1966f6fb9766532adf01e8828876a871857f
2021-12-08 22:26:38 -05:00
Aidan MacDonald
f02cd18ad0 powermgmt: Refactor battery current estimation
Create a new battery_current() function to report the
the battery's charging/discharging current. Move the
old runcurrent() implementation into it and clean up
some of the related defines.

Change-Id: I7dbe5b6532d291fa72add1cb23b30e3cbac8c3ca
2021-12-05 15:11:34 -05:00
Aidan MacDonald
6ff1a935b9 powermgmt: Remove an unnecessary function
Remove battery_read_info() which is a simple wrapper
function only used by debug screens. Use the polling
functions directly to save a bit of code size.

Change-Id: I2919f78105bab186f6933dc1823f9fa67fe74f3e
2021-12-05 14:18:32 -05:00
Aidan MacDonald
e3ee1908dd powermgmt: Small cleanups to battery capacity code
- Don't include the 'battery capacity' setting unless the
  target allows changing it.
- Clean up the preprocessor conditionals used to check for
  variable battery capacity support.
- Don't use a variable for battery capacity unless it is
  actually needed.

Change-Id: I3d8a338f107014f2c5098bc0a44ef0cfb4df9356
2021-12-05 13:37:25 -05:00
Aidan MacDonald
204be7f637 fiiom3k: Remove unneeded powermgmt-target.h
Change-Id: I6af46c860d62d9bc297467050d43e47bff2049b8
2021-12-05 13:14:47 -05:00
Aidan MacDonald
8eb685ffdf Remove a couple of #ifdefs
Give iBasso DX50/DX90 empty adc-target.h headers like all
the other hosted targets to avoid special cases.

Change-Id: Iaae15642fdec4ff18bc9ac01245753135128f676
2021-12-05 13:14:47 -05:00
Aidan MacDonald
a6e90d2355 powermgmt: Remove outdated defines
CHARGING_DEBUG_FILE is not referenced anywhere else so
just remove the #ifdef block.

Change-Id: Icf4bd4edb7d38bdc86477d7d1f4e7bf9cf697d31
2021-12-05 13:14:47 -05:00
Aidan MacDonald
34b7b715e8 lcd-16bit: rewrite mono_bitmap_part
Rewrite the loop to update the framebuffer by rows rather
than by columns. This should (a) be more efficient on the
majority of targets using horizontal stride framebuffers,
(b) skimp a bit on code size and (c) avoid AddressSanitizer
errors caused by reading past the end of the source buffer.

Change-Id: I238d191d63bfdecd25336fd8879a63d9d6ab7087
2021-12-05 13:13:36 -05:00
Aidan MacDonald
2512ed1c56 Make inline functions in headers 'static inline'
Future-proofing against newer versions of GCC/binutils which
are stricter about the use of 'inline' functions in headers.

Change-Id: Id620812ed340f0d790ba6c5b8b5cb1d700acfbbf
2021-12-02 21:31:54 +00:00
Solomon Peachy
4162a46184 config: Get rid of an (incorrect) duplicate definition for USB_DESIGNWARE
Change-Id: I9778a1a7b5e2e15b3775dbaed719c64b4e52194b
2021-11-29 20:14:41 -05:00
Aidan MacDonald
98f1271aec x1000: Fix AIC I2S divider clamping with EXCLK source
Change-Id: I19c2d25bbd7276ac5efd6f6b3b9ee64d6801f972
2021-11-27 15:27:45 -05:00
Aidan MacDonald
9eaa14dc02 usb-designware: fix setup packet error handling
This handles the case where the host sends a new setup packet
in the middle of an ongoing control transfer.

Change-Id: I1d2e02467e9b813c9827cc0699cb87a500515e31
2021-11-27 09:29:44 -05:00
Aidan MacDonald
e4d8431211 Update microtar users to new library API
Change-Id: I8e74efb53b8a8c9a4d69b2a20024434e2868e4e0
2021-11-27 13:13:39 +00:00
Aidan MacDonald
44acbc6629 Shanling Q1: enable multi-touch reporting
The FT6x06 driver used for the Shanling Q1's touchscreen
has been extended to report more than one touch point. It
can also return the gesture detected by the controller,
but this doesn't seem to report anything useful on the Q1.

Multi-touch is only useful in 3x3 grid mode since the Rockbox
button API cannot report more than one touch point.

The FiiO M3K uses the same driver so it's been updated to the
multi-touch API, but functionality is unchanged.

Change-Id: I4de42f44808d6eb902e3da212d8f936b7a5042c7
2021-11-24 18:49:03 -05:00
Solomon Peachy
3d07ec46ee jz47x0: Minor code quality improvements in the jz47xx USB drivers
* Replace magic nubmers with #defined constant
 * Tweak some logf messages

No functional changes!

Change-Id: I6a5e4c371a471197a8edbb853967e461621d73f8
2021-11-22 08:08:12 -05:00
Aidan MacDonald
bff63a4f90 touchscreen: change odd sentinel value for time of last touch
Using tick 0xffff does not make any sense, use -1 instead.

Change-Id: Id574eb35418c6713c4fc91ed539aadc42fd29aa5
2021-11-21 20:26:20 +00:00
Aidan MacDonald
ad66c3b807 touchscreen: use repeat acceleration for button input
Touch devices have physical buttons too, and these should be
subject to repeat acceleration. That feature was disabled for
the sake of better touch event responsiveness (apparently).

So, re-enable the acceleration feature & add a special case
to exempt BUTTON_TOUCHSCREEN from acceleration.

Change-Id: I9e097e27457fbd6b824f098e8b325ff35c59dde4
2021-11-21 20:26:20 +00:00
Wolfram Sang
336ea51af6 WIP: Samsung YPR0/1: switch to generic SI47xx polling
Should work(tm). But I don't have the hardware, so it needs to be
tested.

Change-Id: Ic086434f570dcddacb5b7e7a1acce4b8cafc5c03
2021-11-18 16:53:57 -05:00
Wolfram Sang
de0346065b Sansa Clip+: add RDS support
Based on a patch by Amaury Pouly which was based on a patch from Ryan
Hitchman.

I mainly moved the code for polling into the tuner driver so it can be
reused by other targets. I added the CONFIG parameter for the polling
frequency (in ticks) to save energy. Also, I did some minor cleanups.

Change-Id: I95a62e7e1e42c62dbf47ecb27a3b312a42be62aa
2021-11-18 16:44:21 -05:00
Aidan MacDonald
701d4ba77e x1000: Merge makefiles used for the bootloader
All three X1000 native targets turned out to have a very
similar boot configuration and used a nearly identical
makefile. Eliminate this duplication by moving the logic
into the main makefile.

Change-Id: I13044b9675c0abd605b8accdb2fee4f54549b020
2021-11-18 14:14:54 -05:00
Aidan MacDonald
6e61e6f0c8 usb_core: don't buffer control request unnecessarily
Due to how the old control request API worked, the request
pointer (and the pointed-to contents) passed by the driver
must remain valid for the lifetime of the request.

The buffered copy wasn't used consistently anyway, so it
should be safe to just get rid of it.

(This only affects the old API compatibility layer.)

Change-Id: I00294c718a7515a91b84f7c7cae5220c73aa5960
2021-11-14 17:58:39 +00:00
Aidan MacDonald
f8810be6de usb_core: More legacy control API fixes
In the old API, usb_core_transfer_complete() would ignore
any completions on EP0. The legacy control API will also
ignore most completions on EP0, but it only did so after
filling in the completion event.

If the driver submits a spurious completion on EP0, then
this could clobber a previously queued completion event.

Fix this by deciding whether to ignore the completion
*before* modifying the event data.

Change-Id: I68526898a96efa594ada4e94bb6851aaaf12e92a
2021-11-13 18:37:33 +00:00
Dana Conrad
59ef877c94 x1000: delay power thread until valid battery read
Appears to return 0 until the axp has (presumably) completed
its first real measurement.

Note about erosq: keep the power_inint() delay large to ensure
nothing breaks in the bootloader for the time being.

Change-Id: I444e858207cc401c42f1e6ceacf067ad543d4ff8
2021-11-12 16:31:27 -05:00
Wolfram Sang
67fb558c89 as3525: debug: use 'kHz' where applicable instead of "MHz" or "KHz"
Change-Id: I84c24402d664b5a1a37c81aebfc438bd04bc8af4
2021-11-10 21:53:15 -05:00
Dana Conrad
9ee321cf90 ErosqNative: increase battery stabilization delay again
Hopefully 250 is long enough for any devices out there!

Change-Id: I80e084dceb62acd8d1f51d873b18a4be9c3447d8
2021-11-10 07:22:57 -05:00
Aidan MacDonald
7af98ce6bb usb: Fix possible SET ADDRESS data corruption
The address from the packet needs to be saved before sending
the response -- after the response the request being pointed
to could get overwritten. This used to be done correctly but
I unintentionally broke it when updating the handler to the
new control request API.

Change-Id: I9b11548baf20dce44a82301731405dc8e8f1cef3
2021-11-09 14:45:07 +00:00
William Wilgus
9f1cab154c lcd-16bit-common move bugfix to sim only
Ive seen no ill effects having this disabled on target so
limit it to the sim to stop Address Sanitizer from dumping
on the extra byte read. the bad data is never used AFAICT
since the loop ends

Change-Id: I8cb54e9d1f8fe28747867d861a015edb3dbfa5ff
2021-11-08 17:52:09 -05:00
Aidan MacDonald
8c954c68e5 usb: Attempt to fix race condition in compatibility layer
Because usb_core_legacy_control_request() is called by an
interrupt handler the global variables used to track the
current control request at the very least need to be volatile.

It might also be necessary to disable IRQs but I'm not sure
of that.

Change-Id: I0f0bb86d0ad63734e8d3c73cb1c52fedf5a98120
2021-11-08 21:46:36 +00:00
Solomon Peachy
5e663f0420 xduoox3ii: Ignore the remote events when headphones aren't plugged in
This prevents the actual insertion/removal from triggering false events

Change-Id: I54114ce903e110c31eca6b2ce258a0cf5f6b782b
2021-11-03 13:16:40 -04:00
William Wilgus
684565b8f3 USB fix red for device without HAVE_USB_POWER again.
Change-Id: I3122d532cbb8d5b5cb9040f08707c1514bc1b18e
2021-10-31 21:36:21 -04:00
William Wilgus
d72a0ed65d Use USB events for storing plugin_menu state
use usb connected callback to cancel menu reentry after USB plug/unplug

Change-Id: I8267deed6e8ada94ca527392f56f50ef22def1d7
2021-10-31 12:42:24 -04:00
William Wilgus
7a6737f471 USB Events fix red on devices without HAVE_USB_POWER
Change-Id: I112e6379d4bed019d7e047e5802f104e250d926e
2021-10-31 12:30:27 -04:00
William Wilgus
894a9d9063 USB add Insertion and Extraction callback events
We have this nice event library laying around probably a few more places
we could use event callbacks

Change-Id: I9180fa9d78788d161f2587110644ca3e08df6f50
2021-10-31 12:02:38 -04:00
Aidan MacDonald
0f68866ae5 fiiom3k: bump power on delay to 200ms
Needed due to a report that 80ms was not working.

Change-Id: I5f0f750b0530f5b84ffba58c5d7ff8b283095c4b
2021-10-18 23:03:04 +01:00
Aidan MacDonald
957add9d75 fiiom3k: adjust power on delay to 80ms
OST timer fix (7a5130a277) causes a boot failure on some units,
the battery voltage reading needs more time to stabilize.

Change-Id: Ic4a9ba90a16fab8ac6d27dbbe7af381f7c810f8f
2021-10-18 21:45:03 +01:00
Dana Conrad
6253cdebed ErosQNative: Fix mdelay calls due to g3859
The battery stabilization delay call seems to need to be
about 170 at minimum now, let's do 190 for safety (+20ms).

Change-Id: Ifd0248891abe827dfcc3e6baf48cc5bef0d0cc1c
2021-10-16 16:58:19 -04:00
Aidan MacDonald
7a5130a277 x1000: fix broken OST2 timer prescaler
It turns out the prescaler fields in OST_CTRL are 2 bits wide,
not 3. The programming manual (as usual) is ambiguous and its
diagram shows 2-bit wide fields, but the bit positions in the
text give a 3-bit wide field. Ingenic's Linux code and my own
testing shows that they are, in fact, 2 bits wide.

This caused the OST2 divisor to be 16 instead of 4; the OST1
divisor was correct. This means that all udelay/mdelay calls
took 4x longer than they should've. After this change the OST2
prescaler will be 4, as intended, and udelay/mdelay calls will
wait for the intended duration.

Change-Id: I2ac0a9190f49b59a840c649bf586131f5f9fde82
2021-10-16 16:58:19 -04:00
Aidan MacDonald
d085d01f5e x1000: enable DMA for USB driver
This boosts USB transfer performance a bit, ~10% for reads and
~25% for writes, for large-ish file transfers. Rockbox is still
around 33-50% slower than the OF.

Change-Id: I236a1e5c69a290c47ed27b70cb2631111fc157ed
2021-10-16 21:14:42 +01:00
Aidan MacDonald
4fc37eb47f usb-designware: port to new USB API
List of all platforms using this driver:

- Sansa Clip+ (tested, works)
- Sansa Clip v2 (untested)
- Sansa Clip Zip (tested, works)
- Sansa Fuze v2 (untested)
- iPod 6G (untested)
- iPod Nano 2G (untested)
- FiiO M3K (tested, works)
- Shanling Q1 (tested, works)
- Eros Q (tested, works)

Change-Id: I403ec64b030ea38f22cb52b31865639a78cd11e4
2021-10-16 21:14:42 +01:00
Aidan MacDonald
24294bda15 usb: ensure RX buffers are a multiple of the packet size
When performing an OUT transfer which is not a multiple of the
max packet size, the last packet of the OUT transfer should be
a short packet. However, there's no guarantee the host sends
the expected amount of data in the final packet.

The DWC2 USB controller handles this case by accepting any size
packet and copying it out to memory. So if the packet is bigger
than expected, it'll overrun the caller's buffer and Bad Things
will happen.

The USB 2.0 spec seems to endorse this behavior. Section 8.5.1
says "an ACK handshake indicates the endpoint has space for a
wMaxPacketSize data payload." So it is possible that other USB
controllers share the DWC2's behavior.

The simplest solution is to force all USB RX buffers to be big
enough to hold the transfer size, rounded up to a multiple of
the max packet size. For example, a transfer of 700 bytes would
require a 1024-byte buffer if the MPS = 512 bytes.

Change-Id: Ibb84d2b2d53aec8800a3a7c2449f7a17480acbcf
2021-10-16 21:14:42 +01:00
Aidan MacDonald
a665c1faad usb: remove dead code in usb_storage driver
Change-Id: Id6fc3520dad1adace33fd1014288ccb4cf5818af
2021-10-16 21:14:42 +01:00
Aidan MacDonald
988f244c74 usb: port usb_storage control request handling to new API
Change-Id: I1a19e09fdc0f05473d53c39bab0761d5cb8f6ff0
2021-10-16 21:14:42 +01:00
Aidan MacDonald
1b2cc053d3 usb: port usb_hid control request handling to new API
Change-Id: I9028cf06e91c9fcbe271f6ad81d6b252cb4e7cec
2021-10-16 21:14:42 +01:00
Aidan MacDonald
3318ba4795 usb: port usb_serial control requests handling to new API
Change-Id: I1405c9279e0e8e490e2bb2d03ff192b36db2634b
2021-10-16 21:14:42 +01:00
Aidan MacDonald
77731c3579 usb: port usb_core control request handling to new API
Change-Id: I3850c9cfcb87831e56884c83e31f728590b76f83
2021-10-16 21:14:42 +01:00
Aidan MacDonald
82efb1150e usb: implement new API with legacy emulation layer
All existing USB drivers now define USB_LEGACY_CONTROL_API to
enable the emulation layer.

Control request handlers will be ported in follow-up commits.

Change-Id: I4be1ce7c372f2f6fee5978a4858c841b72e77405
2021-10-16 21:14:42 +01:00
Aidan MacDonald
dff8320a5d usb: add request data argument to all control request handlers
Change-Id: I237143fa0d95c914b8e25ed22f8acde96ec00551
2021-10-16 21:14:42 +01:00
Aidan MacDonald
b69d43c247 usb: give USB transfer completion events two data pointers
Change-Id: I036cc7f02c2f86a364d2dba59493a6aa893f2c16
2021-10-16 21:14:42 +01:00
Aidan MacDonald
ec164c389c usb: introduce new control request API
Change-Id: I6545d8985ab683c026f28f6a7c0e23b40d0a6506
2021-10-16 15:58:43 -04:00
Dana Conrad
e0468074fe ErosQNative: Remove duplicate play_last_sample() call
My brain dun goofed, oops

Change-Id: Ifd57310f3ba105cdc37c4342691cbc589a492310
2021-10-06 17:36:53 -05:00
James Buren
c0a59b9a6a usbstack: Revise usb string descriptor table to use enum values for indices
This makes it possible for macros of conditionally included string
descriptors to get a correct index no matter what other usb drivers
are enabled or disabled due to the nature behavior of enums.

Change-Id: I8ccebbd316605bed0f5d90b6b73fab4a333c02fa
2021-10-06 17:59:17 -04:00
Aidan MacDonald
4be81c2385 x1000: tweak USB fifo sizes
The old sizes limited the number of usable endpoints and were
unnecessarily large.

Change-Id: Ia17d3b62ecc40c8ca289d78f2275c7842c09deed
2021-10-06 22:40:52 +01:00
Dana Conrad
67d4da5342 ErosQNative: Initialize AIC FIFO to -1
Write -1 to AIC_DR to initialize the "last sample"
to -1 in order to prevent power-on clicks.

It appears necessary to completely fill the FIFO,
otherwise I was able to get a click out of it, however
uncommon it was.

Not only does this prevent a click when first
playing a song after power-on, but it also seems to prevent
any click at all when powering on - previously, a small
click may have been heard when first booting.

Change-Id: I2b81c2fa6af9809ef1c354d7a08ca8f9893a7690
2021-10-06 17:31:30 -04:00
Aidan MacDonald
465c216636 Fix includes in usb_class_driver.h
Change-Id: I602ec80d02b5f4f586386026a6312d048fa7dac3
2021-10-06 21:31:42 +01:00
Aidan MacDonald
3ae6fbc600 x1000: default to sending 0 samples on underflow
Previously it used the last sample, which turns out to be broken.
The AIC appears to send out a random non-zero sample continously
after boot -- probably because the last sample is uninitialized by
the hardware. Disabling playback is supposed to make it send zero
samples irregardless of the LSMP bit according to the docs, but it
doesn't seem to work this way.

- Change eliminates the white noise heard on the M3K after boot.
- Change has no adverse effects on the Q1.
- Leave Eros Q on the old setting since sending zeros exacerbates
  clicking due to DAC's automute feature.

Change-Id: I9996793fc34f4475b19700d076b11505353b3836
2021-10-05 12:46:01 +01:00
Aidan MacDonald
fd568d90a4 m3k: don't use mixer controls for volume control
According to a forum user, there's an audible click when changing
the volume between -32 and -32.5 dB with some headphones. Fix this
by not (ab)using the DAC digital mixer for volume control.

The mixer only provides an extra -6 dB of hardware volume range,
so the only side effect is that software volume will now kick in
at -32 dB instead of -38 dB.

Change-Id: If24d9bc0058eff3c1a29aefb155a2e378522623c
2021-10-05 12:46:00 +01:00
William Wilgus
7c67a48332 Sansa E200v1 Bootloader attempt at enabling USB in boot loader
there is a 1MB free region that is used to load the firmware but we
shouldn't need that till after a USB connection

so here is my 2nd try

Change-Id: I2552db3a7fba019d7e7188984432f758ddafe548
2021-10-04 10:56:33 -04:00
Aidan MacDonald
75524a7eec Shanling Q1: default to USB force charging
Force charging must be set or the Q1 will not draw 500 mA from
an AC adapter (see 0ca0940f01).

Change-Id: I4ec6dc7728a5aa4d7f07580556efb960948c24a8
2021-10-02 16:14:17 +01:00
William Wilgus
a62fdf4751 scroll engine, allow clipped text in viewport
loosen the requirements on the scroll viewport allow clipped text

Change-Id: I7099d423ccfbd7bae12e6ba43b8a6b4b864175b7
2021-10-02 10:31:04 -04:00
Aidan MacDonald
3a89fdee96 x1000: fix hang that may occur in USB mode
Upon getting a USB reset, the USB core will update charging
current by calling usb_charging_maxcurrent_change(). On all
current X1000 targets this may cause a hang, since changing
the charge current involves a blocking I2C transaction.

Eg. if the host issues a reset when we're already configured
as part of error recovery, the change from 500 mA -> 100 mA
will cause a hang.

Change-Id: I5b45272c01fa16b179ae3d16bbc50c7fab9a416b
2021-10-02 15:09:46 +01:00
William Wilgus
95b10ac74e Add ability to dump cpu boost log to disk, include thread names
0.) B 0 /rockbox/apps/main.c:405
1.) B 1 /rockbox/firmware/kernel/thread.c thread[dircache]:1508
2.) B 2 /rockbox/apps/tagcache.c:4772
3.) U 3 /rockbox/apps/tagcache.c:4793

add logic to show count after log rolls over
clean-up

Change-Id: Ibda0a56e5d8d89aa8b7649f4f9fa64eb1ff0e08f
2021-09-30 21:13:22 -04:00
William Wilgus
b662ff945a Bugfix AS3525 usb driver unboosted the cpu without first boosting it
Change-Id: Id2d45870a9128b19ace0e8d5c16d3b3fa4b923dd
2021-09-29 01:17:45 -04:00
Dana Conrad
6d98c9e6b2 ErosQ Native: Adjust battery % scale
Adjust the battery scale to be a little better. I've set
the 100% (discharge) point to be where the battery sags to
when it is done charging but still plugged in.

Not quite sure how best to set the charge scale, it's just
equal to the discharge scale for now.

Change-Id: I9a2730c0b2051300af9eeddb4f67164f38a29002
2021-09-26 18:27:53 -04:00
Solomon Peachy
38b2648f48 win32: Add a stub for os_modtime() to make sim builds happy
Change-Id: Iea90776df2a92777c8e07c5a6b6635b6734d6690
2021-09-26 09:31:58 -04:00
Aidan MacDonald
672bbe434b usb: rename usb_drv_recv() to usb_recv_recv_nonblocking()
IMHO the current name is somewhat misleading:

- usb_drv_send() is blocking and we have usb_drv_send_nonblocking()
  for the non-blocking case. This inconsistent naming can only
  promote confusion. (And what would we call a blocking receive?)

- Other hardware abstraction APIs in Rockbox are usually blocking:
  storage, LCD, backlight, audio... in other words, blocking is the
  default expected behavior, with non-blocking calls being a rarity.

Change-Id: I05b41088d09eab582697674f4f06fdca0c8950af
2021-09-20 22:41:29 +01:00
Aidan MacDonald
99f333c64f usb_hid: fix accidental fallthrough
Successful SET REPORT requests would spuriously fail because of the
fall through to GET REPORT.

Change-Id: I8e7d1a1120afc6975d07d47b11c12c9e9ca51dd2
2021-09-20 17:38:56 -04:00
Dana Conrad
0ca0940f01 Make USB Charging default value configurable per device
A reasonable default assumption for a user
would be that they can plug their device into
a USB AC adapter and it will charge with as much
current as it reasonably can. With the previous
default, an AC adapter will only do 100mA, basically
a trickle charge.

Make this configurable default per-device, so as not
to break old devices without testing.

Define TARGET_USB_CHARGING_DEFAULT to USB_CHARGING_FORCE
to use the new default.

Tested on both erosQ Native and M3K.

Change-Id: I77265d356a41d67357ebc6e9f7e0c25a37b74931
2021-09-19 21:13:09 -04:00
James D. Smith
760277e096 Dir cache: Fix resume of relative path playlists.
Slightly modified from original patch by Fabrice Bellard.

Change-Id: I9ae04fa460f0f1b9c616e6f99505d4c5d4358f68
2021-09-19 21:05:58 -04:00
Christian Soffke
67c4231e34 iPod mini backlight initialization
Fixes backlight not turning on after booting (tested on an iPod Mini 2G).

backlight_hw_init() copied from iPod 4G.

Change-Id: I9c32ca5ecd3dc74ea997e6cb843da79d303b0615
2021-09-12 13:35:35 -04:00
Dana Conrad
17263a813b ErosQ (both): avoid clipping due to DC offset bandaid
Set the maximum volume on both hosted and native ports
to -2 dB.

Verified behavior here on native and by borkitall on irc
for hosted.

Change-Id: I3aebc2bb4b9294a4137a33694c83139c0d76099a
2021-09-05 15:50:21 +00:00
William Wilgus
cab8cea0f0 lcd_putsxyofs 16 bit lcd_mono_bitmap_part [AS] part duex
'Bugfix' mono_bitmap_part reads ahead in the buffer,
if the height is <= char bit pixels other memory gets read
found with [Address Sanitizer]

also g#3332 since this is clearly a problem across the code
instead place the check for height < 8 in the lcd_mono_bitmap_part function

second try places the check above the negative y offset
this was causing glitches on the Q1 and likely other TS targets
since a negative y was added to height it made it < CHAR_BIT setting
stride = 0 even though the bitmap was >= CHAR_BIT high

Change-Id: I13bb8ab472c2ae61302a6de5d9e2c78243354460
2021-08-26 20:19:26 +00:00
Solomon Peachy
b2386405b9 xduoox3: Disable bootloader USB mode entirely
It's not yet working and because all storage is removable (and the OF
works fine) it's of limited utility aynway.

Change-Id: I8a6a59ac16503d0f4574c3934f473cac54e86858
2021-08-26 11:59:01 -04:00
William Wilgus
dbd051394e Revert "lcd_putsxyofs 16 bit lcd_mono_bitmap_part [AS]"
This reverts commit 49edfc237b.

Reason for revert: font rendering bug, https://gist.github.com/amachronic/5fa75da280432127de4b44ee2d760281

Change-Id: I13b5f0eedb2926bce67051c8f0bb2ae5dea9f299
2021-08-25 13:05:02 +00:00
Aidan MacDonald
4cbb5b4201 x1000: trigger the virtual LED on disk activity
Change-Id: Ic129e79e0b192cb0c39e5f05ad602e0ea7a9213f
2021-08-18 23:17:07 +01:00
Aidan MacDonald
5a4cc8da3f Drop HAVE_RTC_RAM
Only Archos players ever used this feature and it isn't implemented
on any current targets.

Change-Id: I39c8455480a3fe33cd25b667e8d4d6ff3a092d3e
2021-08-15 20:41:58 +01:00
Solomon Peachy
cc6b036ef5 logf: Fix an incorrect fix in 835d0c737a
Change-Id: I060033d9a7cd54bab75e4f82e3de002bdb027af2
2021-08-15 09:03:16 -04:00
Solomon Peachy
25cebf2f85 Fix red from 04fe77a4
Change-Id: I13a7b067e60eabe27be1fe983a7cced3ae8b18e3
2021-08-14 17:56:15 -04:00
Solomon Peachy
04fe77a465 Remove the (very) incomplete port for the Tatung TPJ-1102
It was barely even a stub, and hasn't seen any development since 2009

Change-Id: I0aa15d9a7b90ae8c771924d9f401380d4cc0fab9
2021-08-14 16:29:39 -04:00
Aidan MacDonald
786d06742a Remove Samsung YP-Z5 port
It has only a couple GB of onboard flash storage with no storage
driver in Rockbox. It hasn't seen any meaningful development since
its initial commit, it's not on the build farm, and the bootloader
build is broken by other refactoring.

Change-Id: Idd9e3c46fac9b96f416ce444182f97a50770e747
2021-08-14 14:13:54 +01:00
William Wilgus
2df306923a file_internal.c guard file_cache_reset() from null pointer
I feel this is probably unlikely to be called with a NULL pointer
for cachep but being that we are already doing the check why not
guard file_cache_reset as well

Change-Id: I1a13767ef28a4129ae3513f7aa999fb6c1d6fad8
2021-08-13 06:32:44 -04:00
Dana Conrad
6de6e1459d Eros Q Hosted: Apply DC Bias to PCM Data
Similar to the native port, the hosted port benefits from
adding a -1 dc bias to the PCM data. This prevents almost
all clicking artifacts.

Change-Id: Ic6378716774b6d88df23c476e2ef54d49f33dc72
2021-08-12 10:07:49 +00:00
Dana Conrad
77a98ada12 Eros Q Native: Make Mute logic channel-independent
An oversight on my part meant that setting channel balance to
100% L or 100% R would mute both channels - this logic will
prevent that.

Change-Id: I912c2745784fbbbd7a773e1234179801f2ca4680
2021-08-10 18:15:53 -05:00
James Buren
e4c5b082e8 inflate: fix public function pointers
Change-Id: I7f1273b832a04a7d7c1b386c08c17438e3d93fc2
2021-08-09 16:25:43 +00:00
William Wilgus
275c762bb2 As3525 wavpack_enc document some intentional switch fall through
Change-Id: I56bf439df2c05653d65f49238e886e4ef2291176
2021-08-08 09:27:27 -04:00
Solomon Peachy
39fff5cb53 move PCM_NATIVE_BITDEPTH definiton into global config code
Change-Id: I391bcffca670916c2c88426e2ba2603351326cee
2021-08-07 11:18:19 -04:00
Dana Conrad
a2bbd1a549 Fix warnings from 56b0dde545
Need a default bit depth in pcm-x1000.c

Change-Id: I2c6af227975d2f47609b51090638012d8406ec1e
2021-08-07 09:43:17 -05:00
Dana Conrad
56b0dde545 Higher bitdepth software volume scaling
Operates between 0 and -74 dB (mute) without issue

Change-Id: I497e002bd8db43833a09ebbc29212fbb6cc8ebfd
2021-08-07 14:21:47 +00:00
Dana Conrad
16b0098256 ErosQ Native: Add DC Offset to PCM data
A small negative offset seems to silence all
play/pause clicking on the PCM5102A.

Also adding PCM soft muting, and muting the headphone amp
when the headphones are detected as removed. This has been
tested to not cause any unintended side effects on the
line out.

Also confirmed the numerical dB values are (approx.) correct.

Change-Id: I689d68887c86add9cc5e0ccb0c7de01aaa69b4d9
2021-08-07 14:21:47 +00:00
James Buren
60933d98c6 inflate: import initial module for deflate decompression
This will eventually be used by the ZIP module and other things
that support DEFLATE based streams.

Change-Id: I4acc9561eb56c9c368d1defab9c14e0454d105e1
2021-08-07 03:03:27 +00:00
Aidan MacDonald
1a9a5fc279 Fix wrong printf format in system-hosted.c
Change-Id: I73722f0711a295152a98ab784cd6cf76379ef52e
2021-08-06 18:23:17 +00:00
Aidan MacDonald
b8b195a296 Fix hosted glibc backtrace
According to backtrace(3) man page, the string returned from
backtrace_symbols() contains the return address so we shouldn't
need to print it ourselves.

Change-Id: Ia779207285c9ea0052b9aee3d84ee8380bf46d82
2021-08-06 18:54:34 +01:00
Aidan MacDonald
34fcea0b20 Fix path buffer overflow in screendump
Overflow is due to a hidden assumption in create_datetime_filename()
and create_numbered_filename() where buffer must be >= MAX_PATH bytes.

Change-Id: I9d36517d861b6925352380d551afc5439edbb340
2021-08-06 15:46:53 +00:00
Solomon Peachy
835d0c737a logf: Fix two issues with logf_panic_dump()
* It had a (read) buffer overflow when dumping the stuff on the back half of the buffer
 * a highly questionable code construct was nuked

Change-Id: I7f6f119524fc2095f788fc9b3d356459955d3ace
2021-08-06 10:08:00 -04:00
Solomon Peachy
f3010c6a8e hosted: Fix rtc_write_datetime() error handling
(if mktime() fails, don't attempt to write its result to the RTC)

Change-Id: Ib09b8dccafdef032119db76f10af74dfc220cc21
2021-08-05 13:44:11 +00:00
William Wilgus
cb6b0d2c0e disk.c ensure a valid volume is returned from get_free_volume()
volume is used for element math and indexing into buffers
-1  volume is bad

Change-Id: I1ec75ef3a848c154ea80905224ea9a3a14bf8151
2021-08-05 11:01:29 +00:00
Aidan MacDonald
005c414e5f Document intentional fallthroughs + fix harmless unintended ones
Change-Id: I1ca5b1027ec30cbf61093bab35b980196ed14e6b
2021-08-04 18:59:46 +00:00
Solomon Peachy
37bfcab23f powermgmt: Clean up some convoluted #ifdefs
Makes it more explicit what code is used under which circumstances.

Change-Id: I0a482dd48e1eb4b119ca6d8dca2b8aa450445fd1
2021-08-04 09:39:37 -04:00
Dana Conrad
a2fd00cf38 Software Volume: Remove sample rounding
Change-Id: I630139333d64b4c8cae86939ecfc52c44a34ffea
2021-08-01 02:20:00 +00:00
James Buren
fad4c75163 crc32/adler32: add full copyright notice to source files
Change-Id: Ifa04be9a6e419772c18b21e81fe1f246f4248af7
2021-07-31 01:30:39 +00:00
James Buren
f32fc84ef6 adler32: import adapted implementation from tinf/zlib
This adds an adapted version of the adler32 algorithm from tinf/zlib
which will be necessary to support ZLIB deflate streams in the future.

Change-Id: Ie60e15acb288acf56a2d44e3d3e912e1b3eb2216
2021-07-30 23:11:49 +00:00
Solomon Peachy
7318d393ea libc: atoi() is supposed to return 0 if handed a NULL pointer
Change-Id: I2d77532536ca83e5c9c2d7622a0e672082969f75
2021-07-30 01:41:13 +00:00
Aidan MacDonald
05d4d6a4f2 Fix remaining yellow from e532714d1f
Change-Id: If0bdd1fb3c8ee3324562638bc4c4181357a8fd53
2021-07-25 14:36:47 +00:00
Aidan MacDonald
148fac6f34 Fix yellow from e532714d1f
Change-Id: I4f49e93fc1efa78874fb76de6a436ad1fc894cc5
2021-07-25 15:22:33 +01:00
Aidan MacDonald
e532714d1f pcm: Remove unused function pcm_play_dma_get_peak_buffer()
Change-Id: Ifd20fb14a22489cdb99154c01f69809a1e70d0c5
2021-07-25 14:07:41 +00:00
Solomon Peachy
cb92280eca usb_storage: Fix a memset in SCSI_INQUIRY that overflowed its buffer
The funny thing is that the memset() for the field in question was
redundant, as the overall inquiry structure was memset(0) already.

Change-Id: I8bec0c93c9317823ff39cf7133535e3bf58fb987
2021-07-23 00:26:35 +00:00
William Wilgus
b91ad60d63 timefuncs.c valid_time() should return false if tm == NULL and not try to deref
luckily no one has
yet..

Change-Id: I4117db84b013fa826958aea635daa0a24ee534b6
2021-07-20 23:25:31 +00:00
Aidan MacDonald
07a3f6bcdb add Eros Q native simulator build
Change-Id: Ifdc882d19020da2e18234d6276409ad3e7efa138
2021-07-18 13:51:30 +01:00
Dana Conrad
3e7a09cb0d New Port: Eros Q Native
What works:
- LCD: 16-bit RGB565
- all buttons, including scrollwheel
- SD Card
- Battery level and charging/not charging status
- USB
- audio
- sample rate switching
- HP / LO detect, with "safe" fixed LO volume -
   LO volume will only be put to user-defined max volume
   if headphones are not present.
- rtc
- Plugins build, tried a couple and they seem OK
- Bootloader, installable to nand via usbboot

What doesn't work:
- Dual Boot
- power on/off has intermittent, low volume audio click
   (sometimes it's completely silent, sometimes there's
    a click)
- Audio uses 16-bit volume scaling, so clicking/popping
   is pretty bad at lower volumes - need 32 bit volume
   scaling, 24 bit I2S data
- USB HID keys not yet defined
- no jztool support

Unknowns:
- Stereo Switch pins: Direction select, AC_DC
   (probably not even hooked up)
- What is the actual purpose of the Stereo Swtich?
- How does the bluetooth module connect?

"Someday" stuff:
- get LCD working at higher bit depth
- Bluetooth

Change-Id: I70dda8fc092c6e3f4352f2245e4164193f803c33
2021-07-18 12:14:35 +00:00
James Buren
64a24591ae crc32: add fast variant of regular crc_32r function
This relies on a macro, CRC32R_FAST, to select which version to
compile with. In tests the fast version is 2x faster at the expense
of requiring 960 more bytes for the lookup table. For now the default
is the space optimized version but in the future I would like to enable
this for ports where we can afford the extra storage and/or memory
requirements.

Change-Id: I25397dadedc3187bb02b2444f8b8ded77c2509b6
2021-07-18 05:17:31 +00:00