Commit graph

311 commits

Author SHA1 Message Date
Aidan MacDonald
7e5fc4076a Add INIT_ATTR to i2c_init()
It's usually only called from init() in main.c, so this is safe.

There is one more call in system-dm320.c from system_init(), but
that's also "safe". I don't know if it's okay to call i2c_init()
twice, but presumably it works...

Change-Id: I9c1cd918d162d9955f7cf03209e836cbd5e30c57
2023-01-12 06:33:50 -05:00
Aidan MacDonald
39439f6909 Add INIT_ATTR to system_init()
On single-core targets, system_init() is only called from init()
in main.c, which is also INIT_ATTR, so this is safe.

Multi-core targets additionally call system_init() from cop_main(),
which isn't marked INIT_ATTR. I'm fairly certain that it would be
safe to add INIT_ATTR to cop_main() with a bit of refactoring, but
I don't have a way of testing it. So for now, leave INIT_ATTR off
for multi-core targets.

Change-Id: I8fe4358f975880ca317d46bda01d7d9db529d3e3
2023-01-12 06:05:55 -05: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
e532714d1f pcm: Remove unused function pcm_play_dma_get_peak_buffer()
Change-Id: Ifd20fb14a22489cdb99154c01f69809a1e70d0c5
2021-07-25 14:07:41 +00:00
Solomon Peachy
afec380a0d gigabeats: Fix hang on startup caused by a stack overflow
headphone ADC thread stack was slightly too small.  Bump it up a bit.

(it was _perfectly_ sized for the prior older toolchain+optimization flags...)

Change-Id: I2ca67c2b85c54f879892a31e281d7696f893389c
2021-04-01 20:24:59 -04:00
Solomon Peachy
388adff3cc pcm: Further cleanup of unused bits of the PCM ACPI:
* pcm_get_bytes_remaining()
 * pcm_calculate_peaks()
 * pcm_get_peak_buffer()

Nothing in-tree uses these at all (except for the lua plugin wrapper)

Change-Id: I971b7beed6760250c8b1ce58f401a601e1e2d585
2020-11-12 15:59:09 +00:00
Solomon Peachy
fe2d52cc7d pcm: Get rid of pcm_play_pause() and associated APIs
Nothing in the core has used it for some time.  It's exported to the
plugin API but the last plugins to use it were switched to the mixer API
back in 2011.

This allows us to get rid of pcm_play_dma_pause() from all audio drivers

Change-Id: Ic3fa02592316f84963e41d792d1cabb436d1ff6b
2020-10-31 01:18:27 +00:00
Solomon Peachy
431caa4311 imx31: Work around an apparently not-quite-kosher abuse of CPP
(we were trying to foward-declare functions from within static
 initializer context.  GCC no longer accepts this)

Change-Id: I58f316ecc84c8ab45fffc054955727a55714b0a3
2020-10-13 15:48:31 -04:00
Solomon Peachy
495c8e2a69 imx31: Fix regression in bootloader caused by cd9906
Change-Id: I1b561c9136a727f49e02e53798e46ef9197a3958
2020-07-05 04:52:29 +00:00
Solomon Peachy
cd9906847b arm: Fix PortalPlayer linker scripts with binutils 2.21+
For reasons that are still unclear, the 'ncbss' region was overlapping
the "audiobuffer" when linked with 2.21, but okay with 2.20.

Fixed it by making the audiobuffer explcitly use the current position
instead of relying on it being implicit.

With this change, portalplayer-based targets generate working binaries
when built with binutils 2.21 or newer.

This bug also theoretically affects imx233/imx31 targets as they
also have NOCACHE_BASE games in their linker scripts, but I lack
access to one to test with.

Change-Id: Idb38ab20f03599b9ed3d4bc0eafe519f38677438
2020-07-05 03:34:30 +00:00
Michael Sevakis
a1123de28f Gigabeat S: Remove unwanted partitions on the fly
Windows now ignores the hidden flag, so just nullify the entries
to hide depending upon whether or not bootloader install mode is
activated.

Change-Id: I00d0797e40ea3b5f5d5d8e1243b50cfcdd029bb4
2018-01-14 08:23:48 -05:00
Michael Sevakis
f4c4221306 Convert i.MX31 and AMS target to use RTC interrupt
Instead of checking ticks, set a sticky dirty flag that indicates
that the RTC needs to be read. This gives a timely update and more
accurate readout without actually reading the RTC until it changes.
The implementation should atomically read the flag and clear it.
Setting the flag would typically happen in an RTC tick ISR.

Change-Id: I6fd325f22845029a485c502c884812d3676026ea
2017-11-21 07:52:02 -05:00
Michael Sevakis
1654efc313 Unify storage threads into one
* Editing a bunch of drivers' thread routines in order to
implement a new feature is tedious.

* No matter the number of storage drivers, they share one thread.
No extra threads needed for CONFIG_STORAGE_MULTI.

* Each has an event callback called by the storage thread.

* A default callback is provided to fake sleeping in order to
trigger idle callbacks. It could also do other default processing.
Changes to it will be part of driver code without editing each
one.

* Drivers may sleep and wake as they please as long as they give
a low pulse on their storage bit to ask to go into sleep mode.
Idle callback is called on its behalf and driver immediately put
into sleep mode.

* Drivers may indicate they are to continue receiving events in
USB mode, otherwise they receve nothing until disconnect (they
do receive SYS_USB_DISCONNECTED no matter what).

* Rework a few things to keep the callback implementation sane
and maintainable. ata.c was dreadful with all those bools; make
it a state machine and easier to follow. Remove last_user_activity;
it has no purpose that isn't served by keeping the disk active
through last_disk_activity instead.

* Even-out stack sizes partly because of a lack of a decent place
to define them by driver or SoC or whatever; it doesn't seem too
critical to do that anyway. Many are simply too large while at
least one isn't really adequate. They may be individually
overridden if necessary (figure out where). The thread uses the
greatest size demanded. Newer file code is much more frugal with
stack space. I barely see use crack 50% after idle callbacks
(usually mid-40s). Card insert/eject doesn't demand much.

* No forcing of idle callbacks. If it isn't necessary for one or
more non-disk storage types, it really isn't any more necessary for
disk storage. Besides, it makes the whole thing easier to implement.

Change-Id: Id30c284d82a8af66e47f2cfe104c52cbd8aa7215
2017-10-26 14:35:41 -04:00
Michael Sevakis
fc9695eb47 Improve radio RDS driver and framework
* Remove unused bits like the radio event and simplify basic
radio interface. It can be more self-contained with rds.h only
required by radio and tuner code.

* Add post-processing to text a-la Silicon Labs AN243. The chip's
error correction can only do so much; additional checks are highly
recommended. Simply testing for two identical messages in a row
is extremely effective and I've never seen corrupted text since
doing that, even with mediocre reception.

Groups segments must arrive in order, not randomly; logic change
only accepts them in order, starting at 0.

Time readout was made a bit better but really we'd need to use
verbose mode and ensure that no errors were seen during receiving
of time and more checks would be need to have a stable PI. The
text is the important bit anyway.

* Time out of stale text.

* Text is no longer updated until a complete group has been
received, as is specified in the standard. Perhaps go back to
scrolling text lines in the radio screen?

* Add proper character conversion to UTF-8. Only the default G0
table for the moment. The other two could be added in.

* Add variants "RDS_CFG_PROCESS" and "RDS_CFG_PUSH" to allow
the option for processed RDS data to be pushed to the driver and
still do proper post-processing (only text conversion for now for
the latter).

Change-Id: I4d83f8b2e89a209a5096d15ec266477318c66925
2017-02-11 22:19:32 -05:00
Michael Sevakis
324ad2483a i.MX31: Restore screen clearing in DVFS/DPTC debug screen
Somewhere along the line the screen stopped being cleared prior to
writing new text on each frame, which left visible bits of
previously-displayed text when it changed.

Change-Id: I344e03c234daa77f4e64ed89281c40db887e4498
2017-01-29 19:53:49 -05:00
Michael Sevakis
2220a4b695 Improve imx31 interrupt code for PMIC and GPIO
Fix stuff that was bugging me about the way I did it at first.

While messing around I found RDS code wasn't masking its GPIO
ISR as it should, which might lead to two different interrupts
messing with the static data.

Change-Id: I54626809ea3039a842af0cc9e3e42853326c4193
2017-01-29 19:07:55 -05: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
Michael Sevakis
669fa9a130 Gigabeat S: Improve headphone thread implementation.
Implement scanning as binary tree in array.

Make the ADC calls fewer without compromising read quality.

Declare the thread function as 'noreturn' to save some stack. Reduce
stack size (regardless, % use is now a bit lower).

Change-Id: I239792fd2a0a2c019d1ec4af1d6d4b466cdf0ef5
2014-03-06 17:28:26 -05:00
Thomas Martitz
68768260e8 Fix more reds.
Change-Id: I4b58dda0953b7f9799238c32b78037b0a5403c04
2014-03-03 20:26:08 +01:00
Thomas Martitz
22a28f9caa Add missing kernel.h includes (hopefully all of them).
Change-Id: I9c1825296a788587b8d494d8514b3314847b0ff0
2014-01-05 20:32:09 +01:00
Michael Sevakis
91b850ec42 Get rid of usb_drv_attach() from USB code.
'Twas an idiosyncrasy of detecting a host upon bus reset, which is
obsolete.

Change-Id: I0adb25e1805022544f52cd0cb766819a367dbde4
2013-05-14 22:13:38 -04:00
Michael Sevakis
af4c55bd11 Set the right variable type for ucallback :)
Change-Id: I19eace9452d9d0b2a6c7770549930c83ece05c80
2013-05-11 21:20:49 -04:00
Michael Sevakis
0a7d941fb9 i.MX31: Remove long udelay from DVFS interrupt handler
Split the ISR into two parts and alllow quick return from first half.

Introduces a uevent() API to have a callback happen in a specified
number of microseconds. Right now only one event is supported.

Change-Id: Ib1666165be2f6082e5275d64961f083cab104f9f
2013-05-11 21:09:01 -04:00
Michael Sevakis
5c36e2f21c Gigabeat S: Fix the recording locking upon using it a second time.
Apparently I got the "just-in-case" RXFIFO purge in there before the
RXFIFO was enabled, causing severe hardware spasms.

Change-Id: I2ea4b6d28e06372b61cb3f21ab2fce71dd408213
2012-05-23 10:21:22 -04:00
Rafaël Carré
7ca2081036 remove debug-target.h 2012-05-07 00:55:59 -04:00
Michael Sevakis
b4eec0dd42 Make INITDATA_ATTR work on everything that has INIT_ATTR enabled for code.
Change-Id: If9936bfbbd3bc3eb2a3e3e290701b8517eabfb13
2012-05-01 01:28:50 -04:00
Amaury Pouly
f33330c0ff arm: factor all exception handlers out of the crt0.S files
Remove the implementations of all exceptions handlers from the
various crt0.S files and have a single implementation in system-arm.h
The new implementation is weak so that it can be overwritten by some
specific code (like the unwinder)

Change-Id: Ib3e041ed6037376bbe0e79286057e1051640dd90
Reviewed-on: http://gerrit.rockbox.org/205
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2012-04-06 13:46:32 +02:00
Michael Sevakis
286a4c5caa Revise the PCM callback system after adding multichannel audio.
Additional status callback is added to pcm_play/rec_data instead of
using a special function to set it. Status includes DMA error
reporting to the status callback. Playback and recording callback
become more alike except playback uses "const void **addr" (because
the data should not be altered) and recording  uses "void **addr".
"const" is put in place throughout where appropriate.

Most changes are fairly trivial. One that should be checked in
particular because it isn't so much is telechips, if anyone cares to
bother. PP5002 is not so trivial either but that tested as working.

Change-Id: I4928d69b3b3be7fb93e259f81635232df9bd1df2
Reviewed-on: http://gerrit.rockbox.org/166
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
2012-03-03 07:23:38 +01:00
Rafaël Carré
95cf63b294 button-target.h : move prototypes to button.h
no need to define BUTTON_REMOTE anymore

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31620 a1c6a512-1295-4272-9138-f99709370657
2012-01-08 00:07:19 +00:00
Rafaël Carré
63ead774d5 charging_algorithm_close() declaration has moved
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31619 a1c6a512-1295-4272-9138-f99709370657
2012-01-07 22:43:53 +00:00
Rafaël Carré
19fba5fb30 powermgmt-target.h: move prototypes to powermgmt.h
Implement empty stubs if needed instead of empty static inline

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31617 a1c6a512-1295-4272-9138-f99709370657
2012-01-07 22:32:52 +00:00
Frank Gevaerts
4fcffcbdf3 Reorganise USB initialisation to not depend on a specific enumeration sequence, by Bartosz Fabianowski, with minor tweaks by Michael Sevakis (FS#12497)
FreeBSD apparently sends a SET_ADDRESS first, which confused our code.
This patch fixes that, and also simplifies the connection handling a bit.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31582 a1c6a512-1295-4272-9138-f99709370657
2012-01-04 21:55:09 +00:00
Rafaël Carré
8b69989811 imx31: move DEBUG_CANCEL definition to .c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31564 a1c6a512-1295-4272-9138-f99709370657
2012-01-04 06:33:59 +00:00
Rafaël Carré
393f427a11 dbg_hw_info(): remove duplicate prototypes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31560 a1c6a512-1295-4272-9138-f99709370657
2012-01-04 05:29:30 +00:00
Rafaël Carré
b959497670 dbg_ports(): remove duplicate prototype
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31558 a1c6a512-1295-4272-9138-f99709370657
2012-01-04 05:21:52 +00:00
Thomas Martitz
d6db4cc105 Fix beast warning.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31552 a1c6a512-1295-4272-9138-f99709370657
2012-01-04 00:13:06 +00:00
Thomas Martitz
c1bd9b0361 Rework powermgmt to enable code re-use on appliation and sims.
* Introduce CONFIG_BATTERY_MEASURE define, to allow targets (application)
to break powermgmt.c's assumption about the ability to read battery voltage.
There's now additionally percentage (android) and remaining time measure
(maemo). No measure at all also works (sdl app). If voltage can't be measured,
then battery_level() is king and it'll be used for power_history and runtime
estimation.

* Implement target's API in the simulator, i.e. _battery_voltage(), so it
doesn't need to implement it's own powermgmt.c and other stubs. Now
the sim behaves much more like a native target, although it still
changes the simulated battery voltage quickly,

* Other changes include include renaming battery_adc_voltage() to
_battery_voltage(), for consistency with the new target functions and
making some of the apps code aware that voltage and runtime estimation
is not always available.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31548 a1c6a512-1295-4272-9138-f99709370657
2012-01-03 23:44:38 +00:00
Michael Sevakis
c9dad05554 i.MX31: need an additional ISR lockout instance when closing driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31539 a1c6a512-1295-4272-9138-f99709370657
2012-01-03 16:08:28 +00:00
Michael Sevakis
68ccefed5a Gigabeat S: Dump some now-irrelevant comments.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31538 a1c6a512-1295-4272-9138-f99709370657
2012-01-03 15:57:55 +00:00
Michael Sevakis
30c4efcd16 i.MX31: Fix a couple oopses from r31528
Enabled a PMIC event where it should be disabled. Used constant from wrong enum
to get sense bits (??) which messed up main charger detection.

Also remove an obsolete struct declaration.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31536 a1c6a512-1295-4272-9138-f99709370657
2012-01-03 06:13:59 +00:00
Michael Sevakis
5a8da163c8 i.MX31 - Dethreading operations continue
Dispense with "pmic" thread and process PMIC events directly within ISR. Add
sense bit reading as part of the handling.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31528 a1c6a512-1295-4272-9138-f99709370657
2012-01-02 18:32:35 +00:00
Michael Sevakis
36bc6a1fd5 Gigabeat S: Revert removal of usb_plugged in r31489
Synchronous cable read is still required because the timing of the receipt of
the cable event cannot be known for sure-- basically it introduced a thread
race between main and pmic. If a keypress is desired instead to enter BL USB
mode a la AS3525, then it's possible to remove that.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31510 a1c6a512-1295-4272-9138-f99709370657
2012-01-01 03:19:52 +00:00
Rafaël Carré
568c441fd8 usb-target.h: remove
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31498 a1c6a512-1295-4272-9138-f99709370657
2011-12-31 18:44:55 +00:00
Rafaël Carré
4d5dff4eae gigabeats usb-target: merge in system-target.h
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31493 a1c6a512-1295-4272-9138-f99709370657
2011-12-31 18:44:22 +00:00
Rafaël Carré
2115eac7bb usb_plugged() is PP only
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31489 a1c6a512-1295-4272-9138-f99709370657
2011-12-31 18:43:59 +00:00
Rafaël Carré
bce42fdc31 usb_init_device(): move prototype to usb.h
Get rid of some usb-target.h files

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31487 a1c6a512-1295-4272-9138-f99709370657
2011-12-31 18:43:41 +00:00
Michael Sevakis
ea55ad07b7 Forgot a "static" in r31462.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31463 a1c6a512-1295-4272-9138-f99709370657
2011-12-29 13:16:54 +00:00
Michael Sevakis
7b596416bf Gigabeat S: Update RDS processing to use asynchronous I2C rather than thread.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31462 a1c6a512-1295-4272-9138-f99709370657
2011-12-29 12:02:49 +00:00
Michael Sevakis
20d81d979a i.MX31: Implement asynchronous version of I2C driver.
Scheme is more flexible and should help to enable threadless RDS.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31461 a1c6a512-1295-4272-9138-f99709370657
2011-12-29 05:15:36 +00:00
Michael Sevakis
ad9a0588db i.MX31: Some tweaks with variable declaration in SPI driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31460 a1c6a512-1295-4272-9138-f99709370657
2011-12-29 04:22:20 +00:00