Commit graph

11282 commits

Author SHA1 Message Date
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