Commit graph

1008 commits

Author SHA1 Message Date
William Wilgus
6a568761c8 CLIPPLUS -- Remove un-needed handling for power button button button_read_device()
switching GPIOB in order to read GPIOD96)
(power button) is apparently unneeded

Change-Id: I1fbf13f67f938806086754cdd5e389ef6746ae5f
2018-07-25 06:01:56 +02:00
Michael Sevakis
19b2964d78 AMS v1/v2: Remove sd_enabled as an externally-visible variable.
Also removes the sd_enable() function call. It was only used in
the debug screen on AMSv1 and not used at all on AMS v2.

For v1,obtain debug info in a struture passed to a dedicated
debug info function so that enabling and disabling the controller
isn't racy.

Change-Id: I7c44693bc2df5a1f16168b05b3abfe622f9584ce
2018-07-04 15:20:47 +02: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
8ef33f479e AMS: Convert ascodec_endofch() to use bit mod function's return value.
It cleans up the code and it was the initial inspiring reason to
change them.

Change-Id: I299499117b8a12d93d13d6563683bab89ab80555
2017-10-30 22:12:58 -04: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 Giacomelli
365a005038 Slightly increase CVDD2 on AMSv2.
At least one person found an SD card that wouldn't work at 2.7v.

Change-Id: I84001f07acc9ce36c71165706cce28c2899ac6bf
2017-06-14 17:37:29 +02:00
Michael Sevakis
6db80020b4 Do some housekeeping with fat.h and SECTOR_SIZE
Many includes of fat.h are pointless. Some includes are just for
SECTOR_SIZE. Add a file 'firmware/include/fs_defines.h' for that
and to define tuneable values that were scattered amongst various
headers.

Remove some local definitions of SECTOR_SIZE since they have to be
in agreement with the rest of the fs code anyway.

(We'll see what's in fact pointless in a moment ;)

Change-Id: I9ba183bf58bd87f5c45eba7bd675c7e2c1c18ed5
2017-03-12 22:05:44 -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
Mihail Zenkov
0d0b163dd1 Slightly increase CVDD1 for Clip Zip
Change-Id: Ic784c72a643546c8e31affa820f701eb7982b7c7
2017-02-07 17:28:42 +01:00
Mihail Zenkov
d4303ac900 sd-as3525v2: simplify logic and cleanup
Remove "low power mode clocking" as we stop clocking by hands after each transfer.
Remove CGU_IDE and CGU_MEMSTICK as we don't use them.
Simplify logic in sd_transfer_sectors.

Change-Id: I120396d7ec5c99c62f3a746306aa8edd8686e08a
2017-01-27 23:29:55 +01:00
Michael Sevakis
783c77531c AMS: Return ascodec to interrupt-based I2C2 driver
1. Slightly revised and regularized internal interface. Callback is used
for read and write to provide completion signal instead of having two
mechanisms.

2. Lower overhead for asynchronous or alterate completion callbacks. We
now only init what is required by the transfer. A couple unneeded
structure members were also nixed.

3. Fixes a bug that would neglect a semaphore wait if pumping the I2C
interrupts in a loop when not in thread state or interrupts are masked.

4. Corrects broken initialization order by defining KDEV_INIT, which
makes kernel_init() call kernel_device_init() to initialize additional
devices _after_ the kernel, threading and synchronization objects are
safe to use.

5. Locking set_cpu_frequency has to be done at the highest level in
system.c to ensure the boost counter and the frequency are both set in
agreement. Reconcile the locking inteface between PP and AMS (the only
two currently using locking there) to keep it clean.

Now works fine with voltages in GIT HEAD on my Fuze v2, type 0.
Previously, everything crashed and died instantly. action.c calling
set_cpu_frequency from a tick was part of it. The rest may have been
related to 3. and 4. Honestly, I'm not certain!

Testing by Mihail Zenkov indicates it solves our problems. This will
get the developer builds running again after the kernel assert code
push.

Change-Id: Ie245994fb3e318dd5ef48e383ce61fdd977224d4
2017-01-25 00:05:13 +01:00
Cástor Muñoz
6a1644c52a as3525v2: use the new USB DesignWare driver
Targets: sansaclipplus, samsaclipv2, sansaclipzip, sansafuzev2.

Change-Id: I7773528a4e26707dd33fe9cb8948750d49570701
2016-08-15 02:56:23 +02:00
Mihail Zenkov
a25d0c58aa Increase CVDD1 only for Clip+ version 0
Change-Id: I839ba2191a5c52ef6f58fd4a273db628b690a05c
2016-08-11 19:49:57 +00:00
Mihail Zenkov
cfa1c843f2 Increase CVDD1 for Clip+ to prevent ATA error
Change-Id: I0424d02196a6c5fb6d0185b007df5ece24b10b82
2016-08-10 01:36:11 +00:00
Mihail Zenkov
c7daef36c5 as3525: reverting I2C2 to non-interrupts version
Interrupts version is cause of freeze on USB extraction.
Also non-interrupts version much simpler and faster.

Change-Id: I30a2993cdcaa85abfba77ca06bfacd5b6b4353e2
2016-04-05 01:55:38 +00:00
Mihail Zenkov
ce90c0481a Fix checking for CONFIG_CHARGING
Change-Id: I53b9a129679fd7b322770025106ef92033226d2a
2016-04-04 11:19:51 +02:00
Michael Giacomelli
7be692e806 Enable voltage scaling on AMSv2.
Voltage is reduced when the CPU is unboosted, resulting in a large
reduction in power consumption. In analogy with the AMSv1 voltage
scaling code (currently disabled due to problems with SD cards),
I have defined a config file option to enable/disable it.

Change-Id: Ia89c31ec06dd012354b4d53435e7b5b36243b206
2016-03-27 23:14:51 +02:00
Mihail Zenkov
775b21ebc4 AMSv2: additional delay for voltage scaling
We need additional delay since ascodec_write_pmu() working faster in
non-interrupts version of I2C2.

Change-Id: If4af3e42b3c8e8214baa36e54353b8adb527552d
2016-03-27 21:59:22 +02:00
Mihail Zenkov
77a35363c5 AMSv2: DBOP frequency divided by 2
After setting new PCLK (96 Mhz) we have too high DBOP (96 / 16 = 6 MHz).
According to datasheet DBOP should be maximum 4 MHz.

Change-Id: I1cbec054f41a76a6f18eadccb902c5b174ad6e3a
2016-03-27 21:06:27 +00:00
Michael Giacomelli
ece9303c2b Slightly increase VDD2 on AMSv2.
The old value was unstable on some devices.

Change-Id: I016906ec076384589bef9ece6156e0ee7b31609a
2016-03-24 19:18:14 +01:00
Mihail Zenkov
219e116fdf sd-as3525v2: prevent DTO error and DMA problems
We should check sd_wait_for_tran_state() after transfering to prevent data
timeout error. Also we should disable DMA channel manually.

Should be used with g#1270, without it freezes still can occur on data
transfering.

Change-Id: If8c6e5547ab14d66237bccf65f83affc7a346e5e
2016-03-18 21:13:36 +01:00
Mihail Zenkov
e65478c693 sd-as3525v2: exit with error if transfer failure
Change-Id: Ic94cf7d3e058a876bbafdb5a35f26f240e1384fd
2016-03-18 14:56:31 +01:00
Mihail Zenkov
2d8a785bc7 sd-as3525v2: Limit number of retry
With current setting we spend few minutes for reading one sector if we have
data timeout error. With new setting system (linux) show error after ~10 seconds.

Change-Id: Id3922acb2ea146c6ea2f89f26206df9488e6ee4e
2016-03-18 14:56:12 +01:00
Mihail Zenkov
3f54101858 Enable frequency scaling on AMSv2 devices.
Voltage scaling is not yet enabled, but will follow once we are sure
these changes are stable.  Preliminary testing suggests a large
increase in battery life, which will be further improved by voltage
scaling.  Patch by Mihail Zenkov with help from myself and others on
the forums.

Change-Id: I171d20bbee19a48c13cd14efb0d023883cc8c687
2016-01-21 19:26:00 +01:00
Michael Giacomelli
7432af0958 Make sure the system is boosted before enabling USB hardware.
Change-Id: Ib44d29384f359dff24f0ce012667d9ce93328dc2
2016-01-18 23:55:22 +01:00
Michael Giacomelli
9f364a13c6 Increase button delays in preperation for frequency scaling.
When run at lower clock speeds, delays seem to need to be a little
longer in absolute time.

Change-Id: I5373f43094302e6fa3f0a79126e54cfccd90f5a4
2016-01-18 23:51:25 +01:00
Michael Giacomelli
784790dbec Change the clipv2 button driver to use fixed delays rather than processor cycle counting.
Also introduce a new delay needed for frequency scaling.

Change-Id: I575a503a8ca44358fcd5512fd951fe9c7bbde31c
2016-01-18 22:35:56 +01:00
Mihail Zenkov
e7550a4f6e AMS: Change DMA transfer size for audio.
Slightly reduces power consumption due to DMA overhead.

Change-Id: I8576e9e243ce13a71cde710c3a726dce19bafb97
2015-06-01 18:23:57 +02:00
Mihail Zenkov
f775870a5a AMS: Fix pop-clicks noise on play/stop.
This noise itroduced by starting/stopping I2SO MCLK.
Enable MCLK permanently fix it.

Change-Id: I6d9c51e5ea5bca13026833d2bfdda49d94c6b723
2015-04-09 19:26:05 +02:00
Michael Sevakis
36480c259f Fix a race condition in as3525 I2C driver caused by stacked ISRs.
It was possible for interrupts of higher priority than the current IRQ
level to attempt to restart the interface while it was still active on
a transfer. The list modification also wasn't protected within the I2C
ISR itself.

Change-Id: I70635c307a1443bba6801c588cf1efde299db9a4
2015-03-16 03:27:08 -04: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
66690ca987 Get rid of USE_ROCKBOX_USB
Except for unfinished or experimental ports, it isthe case that
USE_ROCKBOX_USB and HAVE_USBSTACK are both defined or both undefined.
Furthermore, it is a leftover of some early developments on the USB stack and
doesn't make sense anymore.

Change-Id: Ic87a865b6bb4c7c9a8d45d1f0bb0f2fb536b8cad
Reviewed-on: http://gerrit.rockbox.org/1091
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2015-01-08 16:07:12 +01:00
Michael Giacomelli
7c20d8f686 Fix compilation on amsv1.
Change-Id: Ie8fb5cacacd6f875c7b0063fdea1c1865941f1bd
2014-09-29 01:10:35 +02:00
Michael Giacomelli
f014a76866 Add various additional AS3525v2 SOC voltages to the debug screen.
Change-Id: I8c110771f73f5248e949b027fbe1c281c6b1f6f7
Reviewed-on: http://gerrit.rockbox.org/991
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
Tested: Michael Giacomelli <giac2000@hotmail.com>
2014-09-28 21:36:17 +02:00
Mihail Zenkov
23dc0b0179 Don't enable the current sink for the Clip Zip backlight until its actually needed.
Patch by Mihail Zenkov who measured a modest increase in power consumption with
the current sink enabled.

Change-Id: Ib1c1639318de35d449ca51a9bd480005cb6a2ee0
Reviewed-on: http://gerrit.rockbox.org/989
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
Tested: Michael Giacomelli <giac2000@hotmail.com>
2014-09-28 21:07:58 +02: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
463d343102 Add missing kernel.h includes (hopefully all of them), take #3.
Change-Id: I68ed0e914239f0caf83082a41c2480a01b69285a
2014-01-05 20:51:25 +01:00
Thomas Martitz
22b33d6eb8 Add missing kernel.h includes (hopefully all of them), take #2.
Change-Id: I62cedf992bb096987050621cfc34f0432e9da170
2014-01-05 20:42:48 +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
Thomas Martitz
281d1fadb3 Do not include kernel.h in system.h.
system.h doesn't need it on its own and this change makes it less
dependant on Rockbox internals.

Change-Id: I4e1e4108a52a7b599627a829204eb82b392fc6d6
2014-01-05 19:35:23 +01:00
Michael Sevakis
a56f1ca1ed Cleanup MV/MD macros a little.
When using variadic macros there's no need for IF_MD2/IF_MV2 to deal
with function parameters. IF_MD/IF_MV are enough.

Throw in IF_MD_DRV/ID_MV_VOL that return the parameter if MD/MV, or 0
if not.

Change-Id: I7605e6039f3be19cb47110c84dcb3c5516f2c3eb
2013-08-17 12:18:22 -04:00
Rafaël Carré
5ce81fde37 AMS: make sure ROM clock is always on
Change-Id: Ib73b21b944cb609cc26f7f6955d2c894628f65ad
2012-11-12 21:52:55 +01:00
Michael Giacomelli
b61b14f5e8 Revert my previous commit disabling the internal ROM clock during normal
operation.

The interal ROM clock seems to be needed to reboot the player, so disabling
it is too dangerous.  Hopefully this will prevent problems where crashes during
the abort handler resulted in a stock player that needed the battery to drain
in order to reboot.

Change-Id: I7d1e64743dde15b64d718ad3255dada3d570736f
2012-07-22 19:21:54 -04:00
Michael Sevakis
c2e9c93563 lcd-ssd1303: Fix big oops putting height where there should've been width.
Rid code of dar commasar and substitute huggy braces while we're at it. :P

Change-Id: If91974b93660bb0de32a0c92629eb83cea99d266
2012-05-19 17:21:54 -04:00
Michael Sevakis
b1dcd298c7 ssd1303: make sure sansa clip and whatever others clip updates properly.
Sometimes I do want to update outside the screen boundaries and it was
messing it up; such things should not cause display problems.

Change-Id: Ic9deec609b19e5a1c603601b20c66599dd44f892
2012-05-19 14:05:11 -04:00
Rafaël Carré
7ca2081036 remove debug-target.h 2012-05-07 00:55:59 -04:00
Rafaël Carré
cf090209a4 Sansa AMS: more compat irq names 2012-05-07 00:02:13 -04:00
Rafaël Carré
2eccc02d7d sansa AMS: i2s_reset() is never used 2012-05-06 23:47:05 -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
Rafaël Carré
d7ead706a7 AMSv1: rename USB interrupt handler
Fix FS#12660 (broken in c9c13497)
2012-04-30 14:24:34 -04:00