Commit graph

398 commits

Author SHA1 Message Date
Hairo R. Carela
8e7fa2932e simulator: Fix battery level for targets with PERCENTAGE_MEASURE
Previous code returned 0 in targets using only `PERCENTAGE_MEASURE` which means the simulator closed itself (due to low battery) shortly after boot.

Change-Id: I8b66dd085e02a8e565893aad4c8b643233dd3852
2025-08-04 02:01:26 -04:00
William Wilgus
4f3bbeaffc Remove BATTERY_TYPES
Change-Id: I4fa03a10d0032fd6f92722bbe1d4b7eec0b95cb4
2025-03-11 02:26:38 -04:00
William Wilgus
10f8312db4 FS#13538 export and import battery level tables
when battery_bench is run
exports a file in the rockbox directory called 'battery_levels.default'

if the user wants their own levels they can rename the file battery_levels.cfg
and it will be loaded at boot

some minimal error checking is performed prior to using the values

added manual entry

Change-Id: Ia0126faced0c7229fcf8385a1bcb584b5a9dc378
2025-03-06 11:54:21 -05:00
Solomon Peachy
8f8fb13edb dbtool: Fix build when we have HOTSWAP but not MULTIVOLUME
(Not sure how that can happen, but... eh)

Change-Id: I7754f1678698e8781df76c2f88bdf12cc43a5e0e
2024-09-22 10:41:25 -04:00
William Wilgus
a2cc7546d8 Add DeviceData to bootloaders
same vein as bootdata but for devices that need to pass info back to a
running firmware

Change-Id: I0cdcdc0475804dfbbee415ab487104ae8fc8ac69
2024-09-02 13:29:43 -04:00
Solomon Peachy
ad0c131918 sim: stub out volume_partition() for sim targets
Not sure why this doesn't blow up in more places, but eh..

Change-Id: I45214243c0d03a2156dca8f727caadde5f34c23f
2024-08-12 16:10:12 -04:00
Solomon Peachy
13830439fa Fix multidrive/multivolume hosted builds.
Generalize the fix in 2348779ae6 to apply to hosted as well as simulator
builds.  Original regression introduced in c0ac043c6d

Change-Id: Ia786533cc318555e3bb842eb21a73a1f76888379
2024-07-26 10:54:07 -04:00
Solomon Peachy
e8d7a8baaf simulator: Fix browsing into secondary drive on multidrive targets
Change-Id: I4e993acdedb516f0ae4fc230a62cb00de8dcef86
2024-07-25 21:28:01 -04:00
William Wilgus
2348779ae6 [Bugfix #2] initialize the volume names for the sim
and fix red for the devices that don't have ext drives

Change-Id: I66b8ea1e1b22a42cee2957a504756e7f785bd0ae
2024-07-25 00:32:40 -04:00
William Wilgus
67db38e766 [Bugfix] initialize the volume names for the sim
init_volume_names() wasn't being called by the sim

Change-Id: Ife0d345cf29bd4a0a658ed194ee85ca4852bc92f
2024-07-24 23:43:36 -04:00
Solomon Peachy
4628009503 simulator: A few MULTIVOLUME cleanups in the code.
Change-Id: Ia170c06df7624a801ce043e49e078afffa79eee2
2024-07-19 22:04:00 -04:00
Solomon Peachy
07cf874191 simulator: Fix one set of errors, a new set crops up.
Change-Id: I86d6cbee8eec52f04e760b45ab849249ae7162c4
2024-07-07 16:45:48 -04:00
Solomon Peachy
c51a9821e7 rk27xx: Fix simulator errors brought upon by HAVE_MULTIDRIVE but not HAVE_HOTSWAP
Change-Id: I0171d01dfffbb936e8041c0e2fc5207c620ddce3
2024-07-07 16:02:38 -04:00
Solomon Peachy
60c3fdbc11 More red fixes:
* hostfs_removeable()/present() needed IF_MDVOID() in their prototypes
 * SIM_EXT_INSERTED/EXTRACTED are gated by HAVE_HOTSWAP

Change-Id: Id8c688f3538db99586a4f5062c83466374451883
2024-07-07 15:40:27 -04:00
Solomon Peachy
5a2bd580cd Hopefully fix the last of the stragglers.
* xDuoo X3 fix some warnings due to an incorrect #ifdef
 * stub storage_removeable() and storage_present() for non-HOTSWAP builds
 * sim_trigger_external() is gated by HOTSWAP, not MULTIDRIVE

Change-Id: I38f14fdfeba13957899c378051d49afc2e8245e5
2024-07-07 15:13:53 -04:00
Solomon Peachy
1528b44349 More red fixes
Change-Id: If22cdb286edac47b08b158bee6910ba7a539b041
2024-07-07 14:47:07 -04:00
Solomon Peachy
520875ff00 simulator: Fix numerous latent issues
Interactions between HAVE_MULTIVOLUME, HAVE_MULTIDRIVE, and HAVE_HOTSWAP

Change-Id: Ia93792d6a778bf1e5b9bfbc46d982bbba7544651
2024-07-07 13:18:17 -04:00
William Wilgus
aca41be3ca [Feature] Simulator add headphone and lineout toggling
Change-Id: I0b019414643e5c9037c0128093488da49e1a4c0d
2024-05-30 12:12:29 -04:00
William Wilgus
efcea66280 Revert "readdir_r use in tagcache.check_dir, ft_load"
This reverts commit 0c737d3b2e.

Reason for revert: Not really a concern as open_stream returns an independent buffer since g#566

Change-Id: Idbd2f4a7cc2ea6362b7714629469eeb7b3d19b3b
2024-05-02 13:38:32 -04:00
William Wilgus
0c737d3b2e readdir_r use in tagcache.check_dir, ft_load
Change-Id: Ibcde39ed247e100dd47ae877fb2a3625bbb38d8b
2024-05-02 09:33:29 -04:00
William Wilgus
fdc3668a6a [BugFix] Multiboot Database duplicate files
When the sd card is mounted into the root namespace the database
picks up files through both paths

previously we hid the mounted drive but this causes issues with users
databases when the drive letter changes

Adds a way to keep track of volumes mounted in the root namespace

Hides the enumerated volume in root

Database:
we can just parse the root directory ('/') and get to any mounted
volume but we can also enumerate a volume in the root directory
when this occurs it leads to multiple entries since the files can
be reached through multiple paths ex, /Foo could also be /SD1/Foo
Instead we will attempt to rewrite the root with any non-hidden volumes
failing that just leave the paths alone

Change-Id: I7bdba8cfaf63902d2a3852d28484bcf8ca317ebd
2024-03-23 01:03:33 -04:00
Aidan MacDonald
85232fadbb simulator: fix off by one error in USB ack calculations
The sim's printout of the number of expected USB acks was off by one.
Since the sim queue is not registered for broadcasts, it will not
receive an ack message and does not need to account for itself when
determining the number of acks to expect, unlike the USB code.

Change-Id: I6715039c05c1ea95099716c5251d401e37f5b085
2022-05-22 15:34:42 +01: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
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
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
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
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
James Buren
d6dcb99684 uisimulator: implement sim_modtime
Change-Id: I1094632df092ba63605631333e939cf30b585a59
2021-07-11 13:48:26 +00:00
Solomon Peachy
e9ae1e9a8b Fix red introduced in 841e704fc3
Change-Id: I5a924f77231a4764f3ad9b196875f5bf073945d6
2021-07-07 13:49:24 +00:00
Solomon Peachy
4cdb28c167 Fix sim build for STORAGE_USB
Change-Id: Ie738fbc834523796a08af31f1a649632246e2bb4
2020-10-17 21:30:07 -04:00
William Wilgus
f850bbbbc4 Revert root_redirect :(
This reverts commit 31fc46ded6.

Change-Id: Ia78618c0e8b25ca65f7c8ae0db1cb9c9b321bad9
2020-08-20 21:54:00 -04:00
William Wilgus
5ef28cccf9 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: I90b5c0a1c949283d3102c16734b0b6ac73901a30
2020-08-20 23:08:57 +00:00
Solomon Peachy
8cb555460f [3/4] Completely remove HWCODEC support
'swcodec' is now always set (and recording_swcodec for recording-capable
units) in feature.txt so the manual and language strings don't need to
all be fixed up.

Change-Id: Ib2c9d5d157af8d33653e2d4b4a12881b9aa6ddb0
2020-07-24 21:20:13 +00:00
Solomon Peachy
0c4f89370d [2/4] get rid of HAVE_LCD_CHARCELLS
HAVE_LCD_BITMAP is now redundant.

lcd_bitmap is always-on in features.txt so manual and lang strings
don't have to change

Change-Id: I08eeb20de48099ffc2dc23782711af368c2ec794
2020-07-24 21:20:13 +00:00
Solomon Peachy
092c340a20 [1/4] Remove SH support and all archos targets
This removes all code specific to SH targets

Change-Id: I7980523785d2596e65c06430f4638eec74a06061
2020-07-24 21:20:13 +00:00
Solomon Peachy
b0e257ccc6 simulator: Add a stub for lineout_inserted()
Change-Id: I86e4fd75fa9e1bf69b5c9bb5995f4bc77bbdd5de
2020-04-05 21:16:32 +02:00
Sebastian Leonhardt
ed269affb5 Fix simulator/transflective: Display wasn't enabled on first keypress when backlight always off
Change-Id: Ibfa09e7bf839d4d12ef01e4812b5c47c9e32a3be
2019-02-08 15:06:16 +01:00
Sebastian Leonhardt
168e242498 Fix the fix
Change-Id: I54b97fd0c208f775e4ee22cf8499f1da423ebc39
2019-02-08 00:52:37 +01:00
Sebastian Leonhardt
26e0c64e34 Fix red and remove duplicated function declaration
Change-Id: I5fed7fdad077eedfc1e36fbd9e1669f11b90288d
2019-02-08 00:04:20 +01:00
Sebastian Leonhardt
666405f346 Simulator: improve simulation of transflective screens
This patch simulates the three possible states of a transflective
LCD: backlight on (bright screen as usual), backlight off (dimmed
screen) and LCD off (black screen).
Makes use of already defined 'BACKLIGHT_OFF_ALPHA'.

Change-Id: I9b0fc79b8d50c29e024ba1e6d9c2501119a7e0e0
2019-02-07 22:52:07 +01:00
William Wilgus
7b5ce736db Fix playersim CHAR_WIDTH re-definition
Change-Id: I49d2b3635c62277723665d0bdd68808cc82ca1a9
2018-07-25 20:16:02 +02:00
Michael Sevakis
523ef4edbd Fix warnings and errors from fc9695e
* fmradio.c needs an implementation of tuner_get_rds_info() for the
sim (kill all the sims).

* Some macro bitflags shouldn't be seen unless HAVE_RDS_CAP is
defined.

Change-Id: Idd00c94ca2fc43cf32f9223aa4530d5a02fb3454
2017-02-11 23:16:39 -05:00
Marcin Bukat
200ca66963 Fix red/yellow round #2
Change-Id: Ife25eac11fc6f6cedeca8f3fa59536bce0efe2cd
2015-01-12 13:25:14 +01:00
Marcin Bukat
9ffd9327e3 Fix red/yellow
Change-Id: Ie01251af2cd843979b5fdefcfa541ba377d13bd7
2015-01-12 12:02:24 +01:00
Marcin Bukat
89ba7e818c Get rid of stupid _backlight_* function names
_remote_backlight_* and _buttonlight_* are cleaned as well

Change-Id: I73653752831bbe170c26ba95d3bc04c2e3a5cf30
2015-01-12 11:09:27 +01:00
Amaury Pouly
dc127f213c Clarify usb_powered() and fix some code.
Either by mistake or because its meaning changed, usb_powered() doesn't mean
what the name suggest, so clarify its meaning by renaming it to usb_powered_only.
So use of usb_powered() are replaced by usb_inserted() when it makes more sense.

Change-Id: I112887e2d8560e84587bee5f55c826dde8c806d8
Reviewed-on: http://gerrit.rockbox.org/1097
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2015-01-08 16:45:32 +01:00
Michael Sevakis
da4938d6ee Get the last errors I hope!
Change-Id: Ia285b95480cc9ac6494b745d80892c4b1b912341
2014-08-30 01:29:18 -04:00
Michael Sevakis
7d1a47cf13 Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.

Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.

Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.

Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.

2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.

3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.

4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.

Key core changes:
1) Files and directories share core code and data structures.

2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).

3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.

4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".

5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.

6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).

Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:

1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).

2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.

3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.

4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.

5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.

Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.

2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.

3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).

4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).

5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).

Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.

To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.

2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.

Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2014-08-30 03:48:23 +02:00
Thomas Martitz
3505ad3753 Fix reds
Change-Id: Ib2036d0786bd6fa39c5dadeeed83d74c7bd5c273
2014-02-23 22:33:35 +01:00