Commit graph

10501 commits

Author SHA1 Message Date
Cástor Muñoz
201f57171a iPod Classic: remove ATA_HAVE_BBT
Change-Id: I45e26a413c13e401164a01996b0b4c6788096a7f
2016-05-15 21:47:22 +02:00
Cástor Muñoz
dbcde01835 iPod Classic: remove emCORE HDD endianess warning
Change-Id: I91aa2dca7e748fe043c16014661985c42ab84b1a
2016-05-15 21:38:37 +02:00
Cástor Muñoz
469d645390 iPod Classic: prepare i2c and PMU for bootloader
When the bootloader starts only IRAM is available, the first task is to
ask the PMU to verify if the iPod has previously been hibernated by OF.
Due to memory limitations, the kernel cannot be used on this stage.

This patch modifies I2C and PMU low level functions to not to depend
on kernel (removes mutexes, and uses HW timer instead of current_tick),
actual kernel functions are modified to be 'mutexed' wrappers of the new
functions.

Change-Id: I7cef9e95dedaf176dc0659315f3dc33166d5b116
2016-05-15 21:16:54 +02:00
Cástor Muñoz
44ce4eebd6 iPOd Classic: skip emCORE HDD endianness warning for bootloader
Change-Id: I274511cc1061c396a0642e8496d46a3b9c1228d3
2016-05-15 21:16:54 +02:00
Amaury Pouly
187ce123f1 dx90: fix spurious button events
The kernel on this device reports nonexistent key presses, in particular it
reports right presses when pressing the left button... Since when it happens,
the right press comes after the left one, the new code simply ignores any
right press when the left button in pressed.

Change-Id: Ib6ced02682d9cecf4c7f6c58834907a667419cd7
2016-05-14 23:32:36 +01:00
Cástor Muñoz
9a4cd2eaee iPod Nano2G: add IPOD_ACCESSORY_PROTOCOL
Change-Id: I78a19972624504bc802d96b9b8e9cec132164c2c
2016-05-14 19:39:09 +02:00
Cástor Muñoz
d405026ca8 iPod Nano2G: add HAVE_SERIAL
Change-Id: I46dca69c6708d3e6189f66e70badf0a594bac00b
2016-05-13 23:23:35 +02:00
Cástor Muñoz
5017523a6b Add UART suuport for s5l8700 and s5l8701
Add UART support for s5l8700/1 using the UC870X UART controller,
actually the functionallity is disabled and must be enabled for
each individual target. Tested on iPod Nano 2G (s5l8701), not
tested on s5l8700.

Change-Id: Ic0f216bb871502d355a70e4b658e536a2c0976a9
2016-05-13 23:23:01 +02:00
Cástor Muñoz
8fb67f48ab iPod Classic: updates for uc8702 driver
- Small rework on the UC8702 UART controller to make it compatible with
  other s5l870x SOCs. Files moved and renamed, many conditional code
  added to deal with capabilities and 'features' of the different CPUs.

- A couple of optimizacions that should not affect the functionality.

Change-Id: I705169f7e8b18d5d1da642f81ffc31c4089780a6
2016-05-13 23:21:42 +02:00
Michael Giacomelli
18fecd9461 Update runtime estimation after recent power optimizations.
Values taken from Mihail's Clip Zip, should be similar
on all AMSv2 devices.

Change-Id: I9432ecffea94afae224391a86f1d3fa46cd87bc0
2016-04-22 22:42:05 +02:00
Mihail Zenkov
7cb1e5ae8b Fix AMSv2 variant 1 detection if rockbox loaded from SD card
Change-Id: Ie7c9c06170601e109f8d3de9686773c38a6e224a
2016-04-22 20:43:45 +00:00
Mihail Zenkov
79ca6d4e3c AMS: enable SD card support in bootloader
With this changes rockbox can be loaded from SD card when internal storage
can't be mount (due to hardware or software problem).

Change-Id: I32b20d3f341566364def747a708a54ba6b4a7f8b
2016-04-20 15:53:33 +00:00
Mihail Zenkov
8a0360dd1e AMSv2: enable voltage scaling
Change-Id: I8d64b8578d28884e326f8b43100b3b4691f95acf
2016-04-13 23:10:30 +00:00
Mihail Zenkov
c537e05784 Fix (D)EBUG compilation
Change-Id: I5cb6d9ec3d14389b03ae43edb15b9c6199df322b
2016-04-07 10:28:15 +00:00
Mihail Zenkov
e4e0b18daa AMS: power off while charging enabled
Change-Id: Icddf1ea0a03f0426e0cf9b99f05ea065f532fed5
2016-04-07 02:35:58 +00:00
Mihail Zenkov
98c15fe85d Red Alert
Change-Id: I5ddb6e6b4f84e036a7464b142fa9496446708beb
2016-04-06 00:39:23 +00:00
Mihail Zenkov
f791f5ef78 fix red again
Change-Id: I8e7ccbcf8a856bc3e08145a795695fb675794495
2016-04-06 00:17:59 +00:00
Mihail Zenkov
c5c4ea4648 fix red
Change-Id: Iaec43120ef213d9a3c77201bdf50ebbedd1c5b76
2016-04-06 00:00:57 +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
Mihail Zenkov
e599810ffa Don't add new message to logf when we dump it to file
Fix log file corruption if we have new messages at dumping log to file. Comment
removed as it incorrect. We store all messages in direct order (last message at
end of file).

Change-Id: I4acfa8a0935cc41a889e08f6bc42974fefd1ade2
2016-04-04 11:07:44 +02:00
Michael Giacomelli
7ba50cfdc1 Disable voltage scaling.
Crashes immediately.  Something was wrong with the last commit.

Change-Id: Ie8a05095369a6312dc151e0a393e97d3a3fc7a09
2016-03-27 23:56:19 +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
fe9a3ceb0e GUI boost for any button
It improve responsiveness for all targets with frequency scaling.

Change-Id: I72c94daf58cee10c1772decbd0443856c111cc47
2016-03-18 21:39:37 +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
a24abd2a47 Fix NUM_ADC_CHANNELS for AS3525v2
Change-Id: If523d9fe24711ffe571623aae54f141f00b0ee41
2016-03-18 20:24:40 +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
d0d66f3aac usb-s3c6400x: prevent calling usb_enable(enable) twice on USB insert
First time we call usb_enable(enable) on USB_INSERTED event from usb_stack_enable()

Change-Id: I76f66517e1d571ee02553972a7de8414e6f340ba
2016-03-18 14:55:53 +01:00
Mihail Zenkov
4c6871cffa usb-s3c6400x: prevent lockup if usb extracted during data sending
Change-Id: I5e87a9c47defa90e15800666e8ab4608ef5de299
2016-03-18 14:02:17 +01:00
Szymon Dziok
2c7bb67302 HDD16X0: remove unnecessary define.
Change-Id: If0e8174044b71765190cca89f2e37104b9e673e4
2016-03-13 21:44:58 +01:00
Szymon Dziok
e0a4dc5113 HDD63X0: add a note about poweroff while charging to the config file.
Change-Id: I1e523dd3ddc5ddf198302cdb69cc90ad79df0563
2016-03-13 20:51:39 +01:00
Szymon Dziok
164f50b60c HDD16X0: disable poweroff while charging, add a note to the config file why.
Change-Id: I90511b019f45d06e3154c986e1abf87a91d79570
2016-03-13 20:48:14 +01:00
Szymon Dziok
663abe3027 HDD16X0: fix voltage values and simplify voltage calculation.
Change-Id: If3156c3d86145c66bc81e7cd371709ad91b8ee3c
2016-03-13 20:34:51 +01:00
Szymon Dziok
78311e07c3 HDD63X0: fix values for charging (based on OF).
Change-Id: I382b7a037bf9648f993a38d247725ec8c966147f
2016-03-13 20:25:50 +01:00
Cástor Muñoz
51389955fb usb-s3c6400x: fix broken build for LOGF_ENABLE
Change-Id: I4513425b887a0a79b03420ef82fd82bd90e7bafa
2016-02-16 21:42:43 +01:00
Michael Sparmann
bc56811a0e iPod Nano 2G and Classic: Fix power and charging detection.
This should allow FireWire charging to work on these devices.
It also adds charging state detection on the iPod Classic.

(cherry picked from commit fa86fec4fb)

On Classic (and probably Nano 2G), it seems that the 100/500mA limit
applies only to USB chargers, when FW is connected it supplies all the
power (even if USB is also connected) and USB current limit does not
affect to FW charging, therefore the limit is only set when USB is
connected.

Change-Id: I7c6bab1b6a0f295367999c45faeda6085c3fb091
Signed-off-by: Cástor Muñoz <cmvidal@gmail.com>
2016-02-14 15:42:54 +01:00
Cástor Muñoz
929be521d4 iPod Classic: fix buffer alignment on HDD driver
Read/write buffers who are aligned to 16 were not re-aligned to 32 as
it should be. Althrough USB storage and buffering are always passing
buffers aligned to 32, a few unaligned buffers are being received from
other tasks, so this patch could solve some rare random issues.

Also fixes DMA configuration for HDDs that support any MDMA mode but
only UDMA0 (probably will never happen).

Change-Id: I00219ae434205681c69293fc563e0526224c9adf
2016-02-14 15:19:31 +01:00
Cástor Muñoz
3216f390c5 iPod Classic: fix build when ATA_HAVE_BBT is not defined
Change-Id: I186c24259cc28941ef21c54ae9ba23c1ba77133e
2016-02-14 15:19:03 +01:00
Cástor Muñoz
e9497dbf6d iPod Classic: ATA SMART updates
- Add description for attributes supported by Samsung HS081HA (80Gb)
  and HS161JQ (CEATA 160Gb).
- Show error code when ata_read_smart() fails.

Change-Id: I618cc4f37d139fc90f596e2cf3a751346b27deb6
2016-02-14 15:17:42 +01:00
Cástor Muñoz
31d9084a8c iPod Classic: fix USB_DEVBSS_ATTR alignment
After previous commit 0b6647f2e9
this alignment should not be needed, but not sure at all, so it
is aligned to cache line length for safety.

Change-Id: I5b2b9a30c913d2a609acc1bdf30bdec6811a2551
2016-02-14 15:10:55 +01:00
Cástor Muñoz
0b6647f2e9 usb-s3c6400x: set alignment for ep0_setup_pkt
Align USB_DEVBSS buffers to 32 (as other USB drivers are doing), this
could solve rare random memory corruption issues on iPod Classic.

Change-Id: I86a28e10415eabedab7bf4a534530900284f81e5
2016-02-14 14:51:13 +01:00
Amaury Pouly
6f54a86360 as3514: fix bug in volume management on AS3543 targets which are not AS3525v2
Some old code made the assumption that CONFIG_CPU == AS3525v2 if and only if
HAVE_AS3543, which is not true on targets like the Samsung YP-R0. This fixes
several issues on such targets like a huge volume gap between -39dB and -40dB
and a volume artificially capped at -72dB instead of -82dB.

Change-Id: Ib1c883ac593c0c3ce5e2bf4eb408924ce5f5ad93
2016-02-12 23:04:33 +00:00
Mihail Zenkov
840dacc718 AS3543: Fix increasing noise and power consumption if booted through rolo
Change-Id: I99fe6d09b15689e5dd0179714bbe363aed922d10
2016-02-01 03:20:06 +00:00
Cástor Muñoz
e2f943f229 iPod Classic: revert "set initial USB current limit to 500mA"
Reverts commit ead38dbc9d

It was introduced as a temporal workaround to avoid the endless restart
loop when battery is low, but really it is useless. The bootloader should
ensure that there is enough power to launch Rockbox even in the worst
scenario.

Change-Id: Iabebed40c9241af915c16c3c6c4d3c6deef7680e
2016-01-29 19:39:03 +01:00
Cástor Muñoz
4605df1e3c iPod Classic: remove uninteresting info in HW debug screen
CPU type and frequency of the PLLs are fixed and have no interest
at this moment.

Change-Id: I9524127add872908c062a5cfa2fca348a03e846e
2016-01-29 19:28:22 +01:00
Sebastian Leonhardt
e6cd53ad53 Replace SAMSUNG_YH920_PAD with YH92X
seems more logical to me, and is more consistent, since
"SAMSUNG_YH92X_PAD" is already used in the tex files.

Change-Id: Ie9a9d850ea86155a7dcf86c88a22a420a10a3837
2016-01-25 09:23:09 +01:00
Michael Giacomelli
11c8b3927d Fix warning in rolo.
Change-Id: Idb902f44a6aa2648e5cbd0e19ee2d14394479de8
2016-01-24 00:04:18 +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
Szymon Dziok
7800aaca2f Samsung YH92X: Remove unneeded line.
Change-Id: Icc2618391e831af7bc1998f7627176315443bcdb
2016-01-12 21:02:16 +01:00
Cástor Muñoz
a953964167 iPod Classic: fix wake-up from power-off on USB insert
Change-Id: I57897aa1bb98b652bc6c953680bf548648f5915b
2016-01-12 14:24:54 +01:00
Cástor Muñoz
9e24d5df1a iPod Classic: update documentation on PMU target
Change-Id: I936889872f83521731e81a972657086a357bb5eb
2016-01-12 14:24:44 +01:00
Cástor Muñoz
2d23c0310e iPod Classic: use uncached memory for USB driver
Change-Id: I0e72b4a452a17ec894c975dfee4baee878113ff8
2015-12-17 10:53:00 +01:00
Cástor Muñoz
00bda90a21 iPod Classic: add non-cached memory region
Configures uncached memory region and adds some defines for misc HW,
for compability with the bootloader and other future use, current
functionality should not be affected.

Change-Id: I390e79bea1aef5b10dfbc72ad327d7fe438ec6f5
2015-12-17 10:52:49 +01:00
Cástor Muñoz
348bfc5c8f iPod Classic: clickwheel fixes
Uses GPIO.E2 (Request To Send) to detect the holdswitch status,
it is a temporal workaround that seems to work on all models.

Holdswitch status must be detected to drive low GPIO.E2 (RTS)
and GPIO.E4 (Data Out) when the holdswitch is locked, otherwise
battery life decreases about 25%.

Holdswitch unlock action is detected by reading the HELLO message
that the external wheel controller sends when it is powered on,
this allows to quickly capture clickwheel activity after unlock.
GPIO.E2 is also used in case the HELLO message is missed because
the holdswitch was unlocked before Rockbox/bootloader starts.

These 2 lines (RTS and DOUT) can not be used to transmit messages
to the external clickwheel controller, not a problem, actually no
messages are sent while normal operation, only at initialization
stage.

Change-Id: I415fe54bfcbc2086d0f56d7affe6f789ce81a6db
2015-12-17 10:26:51 +01:00
Cástor Muñoz
ead38dbc9d iPod Classic: set initial USB current limit to 500mA
Change-Id: Ie56951457e45da04d8e93b53f5cc8f80f9a69de3
2015-12-17 10:09:07 +01:00
Cástor Muñoz
5c67ebbc33 iPod Classic: prepare LCD driver for the bootloader
Optimizes encoding of LCD command sequences.

Change-Id: I9d1eb735e5a972c1a176177ed570a3fe991d7b9f
2015-12-17 09:14:58 +01:00
Cástor Muñoz
f753b8ead1 iPod Classic: s5l8702 clocking rewrite+documentation
This is a rewrite of the clocking section, the resulting system
frequencies are the same as the current git version.

This pàtch uses fixed FClk and just one register is written to switch
all system frequencies, it needs less steps than the current git
version to reach the desired frequency, so it is faster and safer.
Includes functions to step-up/down over a table of predefined set of
frequencies.

The major difference is that Vcore is decreased from 1050 to 1000 mV.

See clocking-s5l8702.h for more information.

Change-Id: I58ac6634e1996adbe1c0c0918a7ce94ad1917d8e
2015-12-17 07:05:53 +01:00
Sebastian Leonhardt
a507bb2837 YH8xx,YH9xx: Keymap improvement
The main "innovation" in this patch are two "virtual buttons"
for the record switch on YH92x targets. When the switch state
changes, a single BUTTON_REC_SW_ON or .._OFF button event will
be generated. Thus keymap code can react on switching, but
not on the actual state of the switch.

Wherever sensible, the following user scheme is applied:
- use PLAY as confirm button
- use REW button or Long REW to exit
- use REC (YH820) or FFWD (YH92X) as modifier key for button combos

Change-Id: Ic8d1db9cc6869daed8dda98990dfdf7f6fd5d5a1
2015-11-15 23:46:39 +01:00
Cástor Muñoz
d57e65109a iPod Classic: enable AB repeat
Change-Id: I58f3b0a3e4d8a1649d5549c312e6a259bce697a4
2015-10-17 03:33:31 +02:00
Szymon Dziok
2172c11849 Samsung YH820/YH92X: different way of powering off to avoid powering
on after powering off in a loop on YH92X.

Change-Id: I5e5a4fe23c87286045ac82aff5c38bff6331a7f4
2015-10-14 21:23:46 +02:00
Cástor Muñoz
c7fc5ca6eb Fix (D)EBUG compilation errors on targets using FAT
Change-Id: I9517f9b470076a6febeafae76d735c2436812e7c
2015-10-09 20:45:01 +02:00
Cástor Muñoz
d20185ac96 iPod Classic: reads HDD S.M.A.R.T. data
Adds ata_read_smart() function to storage ATA driver, current
SMART data can be displayed and optionally written to hard
disk using System->Debug menu.

Change-Id: Ie8817bb311d5d956df2f0fbfaf554e2d53e89a93
2015-10-07 06:15:04 +02:00
Cástor Muñoz
32b4558511 iPod Classic: initialize USB power configuration
This patch limits the drawn USB current to 100/500mA, instead of
the actual 200/1000mA settings. It also initializes other USB power
related GPIOs.

Solves some USB disconnect issues: FS#12990, FS#12956. I am using a
powered USB HUB with no problems (Vusb=5.05V unloaded), but there
are lots of USB disconnects when using the motherboard USB ports
(Vusb=4.91V), this patch solves all my issues.

Actually, it seems that the USB current drain is limited to 1000mA,
when a load peak occurs most USB2 ports deliver more than 500mA, as
current consumption increases the USB voltage decreases, an excesive
voltage drop produces USB disconnections. Limiting USB current drain
to 500mA also limits the voltage drop, preventing subsequent USB
failures.

Anyway, to minimize voltage drop, it is recommended to use quality
cables and preferably connect to USB ports with higher Vusb.

Change-Id: I1b931aa18ec93bfd1214e475a72e42893eff52f6
2015-10-07 06:15:04 +02:00
Cástor Muñoz
be5fc0ff7f iAP: lingo 1 (microphone)
Change-Id: I65da2064951972368a2880d271280e5b5ae878fe
2015-10-07 06:15:04 +02:00
Cástor Muñoz
efd047a08b iPod Classic: implement IPOD_ACCESSORY_PROTOCOL
Change-Id: I0f0950c42ae5bf5c5b4c2c2f097f8c68a92ba4dd
2015-10-07 06:15:03 +02:00
Cástor Muñoz
38ae0d53e8 iPod Classic: implement HAVE_SERIAL
Change-Id: I24a861cd45095d858d1a7db39969f6eda17cc563
2015-10-07 06:15:03 +02:00
Cástor Muñoz
9f27dc2103 iPod Classic: introduce s5l8702 UART driver
- polling/IRQ modes for Tx/Rx (TODO?: DMA)
- fine adjust for Tx/Rx bitrates
- auto bauding using HW circuitry
- status and stats in debug screen

Change-Id: I8650957063bc6d274d92eba2779d93ae73453fb6
2015-10-07 06:15:03 +02:00
Cástor Muñoz
291b2338c9 ipod Classic: implement HAVE_RECORDING
This patch has been tested on iPod 80 and 160slim, actually
it works but some updates must be done to the final version:

 - unlimitted input buffer
 - decrease CHUNK_SIZE
 - use non-cached addresses instead of discard d-cache ???

Capture hardware versions:

 Ver  iPod models   capture support
 ---  -----------   ---------------
 0    80/160fat     dock line-in
 1    120/160slim   dock line-in + jack mic

 HW version 1 includes an amplifier for the jack plug mic.

 Capture HW detection only tested on iPod 80 and 160slim.

CODEC power:

 AFAIK, OF powers CS42L55 at VA=2.4V for capture (1.8V for
 playback) and turns on the ADC charge pump. CODEC datasheet
 recommmends to disable the charge pump for VA>2.1V.

 CS42L55 DS, s4.13 (Required Initialization Settings): for
 VA>2.1V, some adjustments "must" be done using undocummented
 "control port compensation" registers. OF does not modifies
 these registers when VA=2.4V.

 This patch configures capture HW in the same way as OF does.

TODO:
 - ADC full scale voltage depends on VA, perform tests to find
   clipping levels for VA=1.8V and VA=2.4V

Change-Id: I7e20fd3ecaa83b1c58d5c746f5153fe5c3891d75
2015-10-07 06:15:03 +02:00
Cástor Muñoz
42abc6a496 iPod Classic: capture support for CS42L55 codec
There are a couple of power saving options that can be selected using
defines, they configure the CODEC in a different way than OF does:

 MONO_MIC: jack microphone is connected to left channel, disabling
 right channel saves ~1 mW, there is no reason to not to do it.

 BYPASS_PGA: this option only applies to the line-in, OF does not
 bypass the PGA and configures it to 0 dB gain. At the beginning,
 this patch was written based on CODEC datasheet, bypassing PGA
 because it saves power and incrementes dinamic range ~1dB, i have
 used this setup for a while without problems. Finally this option
 was disabled at the last minute, i decided to do it after reviewing
 the OF and realizing that CS42L55 datasheet recommends to bypass the
 PGA only if the HW includes a couple of capacitors (see Typical
 Connection Diagram, Note 4), at this moment i don't know if Classic
 includes these capacitors (probably not). Anyway, i am not able to
 tell the difference listening to voice recodings.

TODO:
- Use variable PGA gain for jack microphone (it is fixed to +12 dB.
  as OF does).
- I am not a fan of having lots of unused #define options, these could
  be useful for a generic driver but actually this driver is Classic
  oriented, i am not sure if it could be considered disirable to
  eliminate them in the final version.

Change-Id: I3dadf2341f44d5e13f3847e6c9de4a76cd6f0918
2015-10-07 06:15:03 +02:00
Cástor Muñoz
67b4e7f958 iPod Classic: use new PL080 DMA driver
This patch uses the new pl080 DMA driver for I2S playback and LCD
update. I have tried to be as fiel as possible to the current
behaviour, algorithms and configurations are the same, but using
the new driver. Other modifications:

Playback:

 - CHUNK_SIZE is decreased from 42988 to 8188 bytes, it does not
   affect normal playback (block size 1024), was tested using
   metronome (block size 46080). This change is needed because the
   new code commits d-cache range instead of commiting the whole
   d-cache, maximum time spent commiting the range should be
   limited, CHUNK_SIZE can be decreased even more if necessary.

 - pcm_play_dma_start() calls pcm_play_dma_stop() to stop the
   channel when it is running (metronome replays the tick sound
   without stopping the channel).

 - pcm_play_dma_get_peak_buffer(): same as actual SVN function but
   returns samples count instead of bytes count.
   TODO: AFAIK, actually this function is not used in RB. Not tested,
   but probably this function will fail because it returns pointers
   to the internal double buffer.

LCD update:

 - suppresses lcd_wakeup semaphore and uses yield()

Change-Id: I79b8aa47a941e0dd91847150618f3f7f676c26ef
2015-10-07 06:15:03 +02:00
Cástor Muñoz
d6ee2c9eaf iPod Classic: introduce PL080 DMA controller driver
Motivation:

 This driver began as a set of functions to help to test and
 experiment with different DMA configurations. It is cumbersome,
 time consuming, and leads to mistakes to handle LLIs and DMA
 registers dispersed along the code.

 Later, i decided to adapt an old DMA queue driver written in the
 past for a similar (scatter-gather) controller, all task/queue
 code is based on the old driver.

 Finally, some cleaning and dmac_ch_get_info() function was added
 to complete RB needs.

Description:

 - Generic, can be used by other targets including the same
   controller. Not difficult to adapt for other similar
   controllers if necesary.

 - Easy to experiment and compare results using different
   setups and/or queue algorithms:

   Multi-controller and fully configurable from an unique place.

   All task and LLI management is done by the driver, user only
   has to (statically) allocate them.

 - Two queue modes:

   QUEUE_NORMAL: each task in the queue is launched using a new
   DMA transfer once previous task is finished.

   QUEUE_LINK: when a task is queued, it is linked with the last
   queued task, creating a single continuous DMA transfer. New
   tasks must be queued while the channel is running, otherwise
   the continuous DMA transfer will be broken.

   On Classic, QUEUE_LINK mode is needed for I2S continuous
   transfers, QUEUE_NORMAL is used for LCD and could be useful
   in the future for I2C or UART (non-blocking serial debug) if
   necessary.

 - Robust DMA transfer progress info (peak meter), needs final
   testing, see below.

Technical details about DMA progress:

 There are comments in the code related to the method actually
 used (sequence method), it reads progress without halting the
 DMA transfer. Althought the datasheet does not recommend to do
 that, the sequence method seems to be robust, I ran tests calling
 dmac_ch_get_info() millions of times and the results were always
 as expected (tests done at 2:1 CPU/AHB clock ratio, no other
 ratios were tried but probably sequence method will work for any
 typical ratio).

 This controller allows to halt the transfer and drain the DMAC
 FIFO, DMA requests are ignored when the DMA channel is halted.
 This method is not suitable for playback because FIFO is never
 drained to I2S peripheral (who raises the DMA requests). This
 method probably works for capture, the FIFO is drained to memory
 before halting.

 Another way is to disable (stop) the playback channel. When the
 channel is disabled, all FIFO data is lost. It is unknown how much
 the FIFO was filled when it was cleared, SRCADDR counter includes
 the lost data, therefore the only useful information is LINK and
 COUNT, that is the same information disponible when using the
 sequence method. At this point we must procced in the same way as
 in sequence method, in addition the playback channel should be
 relaunched (configure + start) after calculating real SRCADDR.

 The stop+relaunch method should work, it is a bit complicated,
 and not valid for all peripheral FIFO configurations (depending
 on stream rate). Moreover, due to the way the COUNT register is
 implemented in HW, I suspect that this method will fail when
 source and destination bus widths doesn't match. And more
 important, it is not easy to garantize that no sample is lost
 here or there, using the sequence method we can always be sure
 that playback is ok.

Change-Id: Ib12a1e2992e2b6da4fc68431128c793a21b4b540
2015-10-07 06:15:03 +02:00
Cástor Muñoz
609cde9468 iPod Classic: s5l8702 GPIO interrupt controller.
This patch implements a simple API to use the external interrupt
hardware present on s5l8702 (GPIO interrupt controller). This
GPIOIC has been fully tested using emcore apps.

Code is based on openiBoot project, there are a few modifications
to optimize space considering we will only use two or three external
interrupts. The API compiles and works, but has been never used,
therefore probably will need some changes to the final version.

External interrupts are necessary for jack remote+mic controller
(see iAP Interface Specifiction: Headphone Remote and Mic System),
this controller is located at I2C bus address 0x72, there is a IRQ
line for remote button press/release events routed to GPIO E6. At
this moment, the functionallity of this controller has been
extensively tested using emcore, getting a lot of information about
how it works. Microphone is already working on RB, jack accessory
detection and button events are work in progress.

PMU IRQ line is also routed to GPIO F3, it signals many events:
holdswitch, usb plug, wall adapter, low battery... The use of PMU
interrupts is the orthodox way of doing things, at this moment
there is no work done in this direction, there are a lot of PMU
events and i think it is a matter of discursion what to do and how.

Change-Id: Icc2e48965e664ca56c9518d84a81c9d9fdd31736
2015-10-07 06:15:03 +02:00
Sebastian Leonhardt
399904a916 Samsung YHxxx: reduce pop noise on power down
Change-Id: Ifc82ac1051ed05527393838d8aa93bde65287b5d
2015-09-24 23:06:18 +02:00
Cástor Muñoz
983c8084c9 iPod Classic: do not use HDD features on CE-ATA drives
Fix an 'ATA error' issue that affects CE-ATA devices.

Change-Id: I246348bb0506155b096ed8559dcf1b0b0fab3596
2015-07-17 01:03:51 +02:00
Mihail Zenkov
3e5e9cf7d7 AS3543: Fix recording volume setting and voice
Fix regressions introduced by 42219b6e7

Change-Id: I1f3edb5f269f60e9431b45a43c4370836ecac733
2015-06-02 02:04:34 +02: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
Franklin Wei
55f1d9486f Fix warnings in firmware/screendump.c
Change-Id: If01caf8a124e925b308bdefc6327420dde355ac9
2015-02-24 16:55:26 -05:00
Franklin Wei
17ee90ccdb Fix whitespace in firmware/screendump.c
Change-Id: Id3b4f259a6ae77bde02c040fe67fd21e29e2aa04
2015-02-24 16:35:17 -05:00
Franklin Wei
e4108a3726 Fix warning in firmware/common/structec.c
Change-Id: I3de9891042b7ae7ce695209c651bd075c861928d
2015-02-24 16:27:16 -05:00
Franklin Wei
08724860a8 Whitespace fixes in firmware/common/structec.c
Change-Id: I2a6c5d5bd0c5b8fb516e167df74dc1f18508d702
2015-02-24 16:21:59 -05:00
Amaury Pouly
27c7e477ca Revert "usb_storage: make it a bit more correct"
Clearly this was a stupid commit, no idea why I did that.

This reverts commit 074e911859.
2015-02-16 14:06:28 +01:00
Eduard Kutuev
8a078d7853 iBasso DX90 sound enabling fix
Writing 0 instead of '0' to /sys/class/codec/wm8740_mute enables sound on DX90.

Change-Id: Ie8e3980cac6b9298ef2c94f2faac023811d47b32
2015-02-14 18:10:54 +03:00
Udo Schläpfer
d81b36222a iBasso DX50: Digital filter roll off setting.
This patch enables "Settings -> Sound Settings -> DAC's filter roll-off" for the
iBasso DX50.

Confirmed working on iBasso DX50, firmware 1.6.

Change-Id: I901615541d8fa4f6550c5156cf8c6069f5bdf9d0
2015-02-07 13:34:06 +01:00
Udo Schläpfer
95fdad5e28 iBasso DX50/DX90: User selectable USB mode.
Depends on http://gerrit.rockbox.org/r/#/c/1043/.

This patch adds a new setting in Settings -> General -> System: USB Mode.

Usable in Quickscreen and Shortcuts.

Possible settings are:
- Mass Storage: The default, on USB connect export the internal and external
drives as usual. Rockbox will exit gracefully in this case, since the internal
drive (/mnt/sdcard) is exported as mass storage device and Android prevents
Rockbox from continued execution.
- Charge Only: USB charge only, do not export the internal and external drives.
This will not close Rockbox.
- ADB: Enable the Android Debug Bridge. This will not close Rockbox.

Charge only and ADB are actually the same, since it is not yet established if
charge only is doable without adb and major hooks into Android.

German translation provided.

This may be genric for Android based devices but is only enabled
for iBasso Devices. Other maintainers may choose do adopt this.

Change-Id: I616247c29946c6595ebcf8f0c14b2410c9f0498b
2015-02-02 22:43:46 +01:00
Udo Schläpfer
040306a716 iBasso DX50/DX90: User selectable freq scaling governor.
Depends on http://gerrit.rockbox.org/r/#/c/1043/.

This patch adds a new setting in Settings -> General
-> System: Freq Scaling Governor

Usable in Quickscreen and Shortcuts.

Possible settings are:
- Conservative: Slow frequency switching.
- Ondemand or Interactive: Fast frequency switching.
- Powersave: Allways lowest frequency.
- Performance: Allways highest frequency.

German translation provided.

This may be genric for Android kernel based devices but is only enabled
for iBasso Devices. Other maintainers may choose do adopt this.

Change-Id: I10296f5be9586ad3a409105db0cd03682a30e9c1
2015-02-02 21:58:25 +01:00
Udo Schläpfer
dbabd0d9c3 iBasso DX50/DX90: Major code cleanup and reorganization.
Reorganization

- Separated iBasso devices from PLATFORM_ANDROID. These are now standlone
  hosted targets. Most device specific code is in the
  firmware/target/hosted/ibasso directory.
- No dependency on Android SDK, only the Android NDK is needed.
  32 bit Android NDK and Android API Level 16.
- Separate implementation for each device where feasible.

Code cleanup

- Rewrite of existing code, from simple reformat to complete reimplementation.
- New backlight interface, seperating backlight from touchscreen.
- Rewrite of device button handler, removing unneeded code and fixing memory
  leaks.
- New Debug messages interface logging to Android adb logcat (DEBUGF, panicf,
  logf).
- Rewrite of lcd device handler, removing unneeded code and fixing memory leaks.
- Rewrite of audiohw device handler/pcm interface, removing unneeded code and
  fixing memory leaks, enabling 44.1/48kHz pthreaded playback.
- Rewrite of power and powermng, proper shutdown, using batterylog results
  (see http://gerrit.rockbox.org/r/#/c/1047/).
- Rewrite of configure (Android NDK) and device specific config.
- Rewrite of the Android NDK specific Makefile.

Misc

- All plugins/games/demos activated.
- Update tinyalsa to latest from https://github.com/tinyalsa/tinyalsa.

Includes

- http://gerrit.rockbox.org/r/#/c/993/
- http://gerrit.rockbox.org/r/#/c/1010/
- http://gerrit.rockbox.org/r/#/c/1035/

Does not include http://gerrit.rockbox.org/r/#/c/1007/ due to new backlight
interface and new option for hold switch, touchscreen, physical button
interaction.

Rockbox needs the iBasso DX50/DX90 loader for startup, see
http://gerrit.rockbox.org/r/#/c/1099/

The loader expects Rockbox to be installed in /mnt/sdcard/.rockbox/. If
/mnt/sdcard/ is accessed as USB mass storage device, Rockbox will exit
gracefully and the loader will restart Rockbox on USB disconnect.

Tested on iBasso DX50.
Compiled (not tested) for iBasso DX90.
Compiled (not tested) for PLATFORM_ANDROID.

Change-Id: I5f5e22e68f5b4cf29c28e2b40b2c265f2beb7ab7
2015-02-02 21:57:55 +01:00
Udo Schläpfer
a312ca1c50 CPUFreq scaling governor interface for Linux/Android hosted devices.
For a usage example see http://gerrit.rockbox.org/r/#/c/1074/

Change-Id: I1d61e0eba6552a9b5d6e15a2e3169435b2f7079d
2015-01-30 20:15:58 +01:00
Udo Schläpfer
6d3dc8fce0 iBasso DX50/DX90: CPU info enhancements.
System -> Debug (Keep Out) -> View CPU stats

Will now show the current cpufreq scaling governor, minimum, current and
maximum cpufreq scaling frequency for each CPU.

This may be genric for Android kernel based devices but is only enabled
for iBasso Devices. Other maintainers may choose do adopt this.

Change-Id: I53e212f8707bf2abaa557e297293fb559ac37058
2015-01-30 20:15:21 +01:00
Lorenzo Miori
f35d63bc21 ypr0/ypr1: GPIO handling API refactoring
The GPIO APIs for ypr0 and ypr1 targets was messy, requiring a
direct communication via several ioctls calls.
Since it is planned to add support to other devices, more GPIO are
going to be used. For that reason the functions shall be clear and
easy to use.

Change-Id: Ia2304335e1fed1305cc2c4320bd4c097e13079be
2015-01-29 20:28:59 +01:00
Lorenzo Miori
6879dec6ec yp-r0: improve the charging code
Some people reported strange charging times and
strange battery life.
Charging by OF: 25 hours; RB: 18 hours
It has been found that there are at least two issues here:

1) the way of getting battery charging status wasn't
really accurate. This attempts to fix that issue.
This patch also simplifies some code (opening a
device is no more needed, for example).

To technically explain, battery charging implies first a constant
current mode (where the voltage increases) and then a constant
voltage mode (where, obviously, the voltage reads more or less
the same). The old way the End Of Charge was detected was based solely
on the voltage, while now it is based on chip's EOC interrupt,
which should be more accurate.

2) OF explicitly sets a constant current 350 mA, while we usually had
55 mA (by as3543 default).
This wasn't discovered before since there is a caching problem
("an accurate guess") in the Samsung power mgmt Linux module,
thus its debugging dumper wasn't really working, reporting a 55 mA current.
Strangely this option should have been set by the bootloader
but apparently it does not.

Some testing is still needed, but I confirm that with this patch
I could run a benchmark for 25 hours (vs. 18 hours), by charging
within Rockbox of course.

Change-Id: I3bd921e86b9018d1cc3c720d15cc46896e8490b3
2015-01-29 20:28:07 +01:00
Mihail Zenkov
42219b6e79 Bypass the AS3543 audio mixer at higher volumes.
This change reduces noise and distortion very slightly at higher volumes.

Change-Id: I1a2eb160c2956de90764c0bb11677fdac8d96dec
2015-01-19 22:38:51 +01:00
Thomas Jarosch
1212edd352 Don't return pointer to array allocated on the stack
It will be out of scope once the function is left.

cppcheck reported:
[firmware/drivers/rtc/rtc_zenvisionm.c:31]: (error) Pointer to local array variable returned.
[firmware/drivers/rtc/rtc_zenvisionm.c:38]: (error) Pointer to local array variable returned.

Change-Id: Ibf28ba9b3d20cadcaff22398e143488c86746660
2015-01-13 21:40:19 +01: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
Thomas Jarosch
2a3e1628a5 Limit more variables to file scope
Change-Id: I30219d626316776eb73b4205d63376fa3dbc6361
2015-01-11 21:40:51 +01:00
Thomas Jarosch
85c98bc63c Improve readability by adding parenthesis
Change-Id: Iff51ab441a59f1ba842132b809a49d1fe7232e05
2015-01-11 18:19:26 +01:00
Thomas Jarosch
cfbd9cb22f Make a few local variables static
Change-Id: Ieb77a7f2cdf765afa3121320d03c0478cd97eb0f
2015-01-11 18:02:43 +01:00
Thomas Jarosch
5f5a83e1c9 maemo: Clean up unused variables
Change-Id: I5fbb0b0cc56fa565499345844464d1c94ff3ba1a
2015-01-11 17:45:56 +01:00
Amaury Pouly
761e7987c8 usb: finally get rid of USE_ROCKBOX_USB in Sansa bootloader, use bootloader usb
For some reason, the bootloader and config files didn't define
HAVE_BOOTLOADER_USB_MODE, also remove the special cases in usb.c which they
implied.

Change-Id: I68c29be7d03627e64cac4ff7678e0c211e087a8c
2015-01-08 22:30:22 +01:00
Amaury Pouly
3aebdfa642 usb: make usb_release_exclusive_storage private
Change-Id: I0383760b7d8e67cc99bbe4e4979bca92ef436c8d
Reviewed-on: http://gerrit.rockbox.org/1098
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2015-01-08 16:45:41 +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
Amaury Pouly
1ab91550e6 usb: document usb states, powering and detection
Change-Id: Ia3b7d6c6294bfb9272355c3f28a994dd0e83cbce
Reviewed-on: http://gerrit.rockbox.org/1096
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2015-01-08 16:45:22 +01:00
Amaury Pouly
ae37d1944f usb: document usb_status_event and #ifdef it with USB_STATUS_BY_EVENT
Change-Id: I62cdb8ad71a598279fe99cc91d87eafda26cbbc7
Reviewed-on: http://gerrit.rockbox.org/1095
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2015-01-08 16:45:11 +01:00
Amaury Pouly
268114ee66 usb: move usb charging function prototype from usb_core.h to usb.h
Change-Id: Id29c60d3aa26f8badca6c38c1cbb2e5a39c554dc
Reviewed-on: http://gerrit.rockbox.org/1094
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2015-01-08 16:44:55 +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
Thomas Jarosch
fdd4aef340 Make thirty functions static to reduce binary size
If any of those functions should be (unused) API functions,
they can easily be turned back once really needed.

Detected using a new cppcheck check that
uses the internal symbol database to catch
functions that are only used in the current file.

Change-Id: Ic2b1e5b8020b76397f11cefc4e205f3b7ac1f184
2015-01-05 18:44:36 +01:00
Thomas Jarosch
b43fcbdab2 mktime(): Remove redundant assignment of 'result'
Checked with upstream lynx source code and the
second calculation line is the upstream one, too.
(In fact I diffed the whole function to check for changes)

cppcheck reported:
[rockbox/firmware/libc/mktime.c:43] -> [rockbox/firmware/libc/mktime.c:44]: (performance) Variable 'result' is reassigned a value before the old one has been used.

Change-Id: Ia04c5f55da7d86cd74cff4fce675a9c85ddce3e2
2015-01-04 17:37:35 +01:00
Thomas Jarosch
404ebb8b0b hosted target: Fix uninitialized variable in dirinfo.attribute
cppcheck reported:
[rockbox/firmware/target/hosted/filesystem-app.c:509]: (error) Uninitialized struct member: ret.attribute
[rockbox/firmware/target/hosted/filesystem-app.c:517]: (error) Uninitialized struct member: ret.attribute

Change-Id: Ie8cab727faa8110a6fe3926dbcf852e8b9e96ca7
2015-01-04 13:52:29 +01:00
Thomas Jarosch
c5933f4a81 Add and adapt buflib shrink tests
Change-Id: I8aad86226c9c9b2c04727a3703941615638b3a49
2015-01-03 18:17:11 +01:00
Thomas Jarosch
77aa94bdac Add buflib test for maximum allocation
Change-Id: I9076b81d2fd2609ab3e9c8c5a087f8a387480f46
2015-01-03 18:17:11 +01:00
Thomas Jarosch
5f824e21e0 Add and adapt buflib move tests
Change-Id: I57929f8f6a18cf9570f7358d48ad33f285b9ab0f
2015-01-03 18:17:11 +01:00
Thomas Jarosch
7d5f133007 Bring abroad second buflib test
Interfaces with core_alloc_* instead of buflib directly.

Provide UT_core_allocator_init() with
a fixed buffer size for predictable results.

Change-Id: I26a7b3101f7782063547940bded52d8202638394
2015-01-03 18:17:11 +01:00
Thomas Jarosch
e7d94323bc Enable printing of buflib allocations
Change-Id: Ie446177931032d585f69e0651f05ff88ebc6e8ba
2015-01-03 18:17:11 +01:00
Thomas Jarosch
e138016256 Initial import of simple buflib unit test
Taken from kugel's out-of-tree version:
https://github.com/kugel-/buflib

Needs some API adaptions. More test will follow.

Note: The expected output needs an update since
the in-tree version of buflib does buffer alignment
and also progressed a bit. Still the tests are a very good start.

Added Rockbox copyright header during import were needed.

Change-Id: Ib39ec4301285f1dd53059b7bed0c0d6646297dc5
2015-01-03 18:15:07 +01:00
Thomas Jarosch
eb9c845db5 Fix up some DEBUGF statements
The last big filesystem code refactoring
broke a lot of debug statements.

firmware/test/fat/ doesn't build anymore,
but that's more or less unrelated.

Change-Id: I4c9e1289eeabe1b59d436b176f1d35a02176614f
2015-01-03 16:01:39 +01:00
Thomas Jarosch
5f603d36a1 Fix syntax error (missing semicolon)
Reported by TheSeven on IRC.

Change-Id: Ie4bb331f9db050a90d99732e46c23f6402c7c320
2015-01-03 15:02:23 +01:00
Thomas Jarosch
bce72e6f2c buflib: Switch from term "cookie" to "metadata"
The documentation of buflib first mentions metadata
and then changes to "cookie" without explaining it.

Fix it by sticking to metadata.

Change-Id: I0b36b18f4f2590132901c10326481975f8b9b9da
2015-01-02 19:26:03 +01:00
Thomas Jarosch
66df5f3891 Improve core_alloc() / buflib_alloc() documentation
Document the fact that buffers are movable by default.
Care must be taken to not pass them to functions that yield().

Also clarify other things:
- Passing NULL as "ops" to buflib_alloc_ex() causes
  buffers to be movable by default (but not shrinkable).

- If you want shrinkable buffers during compaction,
  you have to provide a shrink callback.

- To disable buffer movement, you have to pass NULL
  for the move_callback inside the callback structure.

- The concept of default callbacks was removed
  long ago, remove the only reference of it.

Change-Id: I3bf0ea6b08b507d80a19f3c2c835aca32b3f7800
2015-01-02 18:51:15 +01:00
Thomas Jarosch
9076b433d1 PictureFlow: Add move callback for buflib allocations
If we don't provide a callback to buflib_alloc(),
the buffer is always movable (to reduce fragmentation).

Since we pass our buffer to functions that call yield(),
this could lead to memory corruption on buflib compaction.

Change-Id: Id1fad1822479d692551c55cb8bc87cea7b78f759
2015-01-01 23:49:41 +01:00
Thomas Jarosch
812406f430 Limit "struct dircache_runinfo" to file scope
Change-Id: Ib3edef9a4568605a36bdacde174dfa6bca2d26fa
2015-01-01 13:51:08 +01:00
Thomas Jarosch
09f7bb82ca Add missing newline in debug output
Change-Id: Ifd67dbcc80db328391464ec93316c48f914bc590
2014-12-30 00:17:38 +01:00
Thomas Jarosch
da5a36d6d2 Document 'union buflib_data'
Change-Id: Ia98fa8e7887338d6c0b7a5795a0ae5c7a13014ba
2014-12-29 23:49:12 +01:00
Thomas Jarosch
d68262eede Two more typo fixes
Change-Id: Id3ec7c1da356cb7c617a1d9ad57c9e0ae9fa6611
2014-12-27 02:00:15 +01:00
Thomas Jarosch
91f1393f75 Fix typos in documentation
Change-Id: I3c7e204bcf67bf0004314fe4b2aec98cae145273
2014-12-27 01:38:11 +01:00
Thomas Jarosch
1eb1bc24f2 DX 50: Fix file descriptor leak on error
Unimportant change, still good style.

cppcheck reported:
[rockbox/firmware/target/hosted/android/dx50/button-dx50.c:92]: (error) Resource leak: fd
[rockbox/firmware/target/hosted/android/dx50/button-dx50.c:98]: (error) Resource leak: fd

Change-Id: Ic1831382219c44e7bef71cb2391646c9910d2369
2014-12-20 14:59:19 +01:00
Thomas Jarosch
575ec8902e mini2440: Fix bogus buffer access in LCD backlight driver
The backlight driver always writes a bogus value
from memory into the LCD brightness register.

Fix it up by adding bounds checks and
use a more sane default value.

While looking at the code, I noticed
that BACKLIGHT_CONTROL_SET probably ignores
the desired brightness level, too.

Note: Please test on real hardware, I don't own it.

cppcheck reported:
[rockbox/firmware/target/arm/s3c2440/mini2440/backlight-mini2440.c:53]: (error) Array 'log_brightness[13]' accessed at index 255, which is out of bounds.

Change-Id: Iaafa929a8adaa97b93ebcb66e1f6bd3bf0dad84e
2014-12-20 14:47:09 +01:00
Thomas Jarosch
d62e1b3c5f vibe 500: Fix ide_powered() always returning false
While the right GPIO location is accessed,
the result of the logical AND was tested wrong.

I don't have this hardware, but I can imagine
that bug caused ide_power_enable() to be called
more times than it needed to be.

cppcheck reported:
[rockbox/firmware/target/arm/pbell/vibe500/power-vibe500.c:101]: (style) Expression '(X & 0x8) == 0x1' is always false.

Change-Id: I98498f79d383c6f29869e170bfc94ba9a0d2ba7e
2014-12-20 14:03:23 +01:00
Thomas Jarosch
ef1497c3df Add missing va_end() call when the log is full
No need to go out of memory, too ;)

cppcheck reported:
[rockbox/firmware/logf.c:338]: (error) va_list 'ap' was opened but not closed by va_end().

Change-Id: I00e4c04d7e3d5d1415aa5066487ce1d9209e53aa
2014-12-20 13:48:43 +01:00
Thomas Jarosch
c55be3b83a maemo port: Fix startup crash exposed by audio thread refactoring
The refactoring of the audio thread in this commit
-----------------------------------------------
commit 5857c44017
Author: Michael Sevakis <jethead71@rockbox.org>
Date:   Fri May 31 02:41:02 2013 -0400

    Refactor audio thread to run both recording and playback.
-----------------------------------------------

moved pcm_init() next to dsp_init() in apps/main.c:init().
Before that pcm_init() was called by audio_init().

Unfortunately the maemo init code didn't properly
wait until the maemo thread was fully initialized,
leading to dangling pointers when the code called
by pcm_init() tried to access maemo's variables.

Fix it by refactoring the "very fast shutdown" semaphore
to wait until maemo is initialized in any case.

This should also fix very rare rockbox crashes
on startup that I got once a year or so.
The new code has been tested by a script that
starts and kills rockbox after one second.

Change-Id: I464efce5f2b71ca869c72a5bc578555b8022e459
2014-12-20 02:23:15 +01:00
Thomas Jarosch
3add6c7435 Fix up maemo port after byte swap header refactoring
Turns out maemo's old gcc 4.2.1 doesn't include any arch
optimized swapXX() functions, just plain C implementations.

Before we pull in lots of linux kernel headers for the
C implementation, just stick to rockbox's own version.

Change-Id: Ic28b41b52fe47f814c7f3897ce15334a42b6c5e2
2014-12-17 23:29:44 +01:00
Cástor Muñoz
b320bbaf61 iPod Classic: YUV to RGB optimizations for ARM v5+
Optimizes YUV to RGB conversion using ARMv5 multiply-accumulate
intructions for operations and data tables for saturation.

This first patch set includes the three versions i have developed.
Although iPod Classic need to use the latest version to reach 30fps,
old versions may serve other targets.

All versions are based on current SVN algorithm (round->scale->add)
using the same coefficients, so output results are identical.

Version history:

  ARMv4:
   - use all available registers to calculate four pixels within each
     loop iteration.
   - avoid LDR interlocks.

  ARMv5TE:
   - use ARMv5TE+ 1-cycle multiply-accumulate instructions.

  ARMv5TE_WST:
   - use data tables (256 bytes) for RBG565 saturation.

Benchmarks results using iPod Classic (ARM926EJ 216Mhz):

                 size    test_fps (1)    mpegplayer (2)
                 bytes   YUV  YUV1/4     average  min/max
                 -----   -----------     ------------------
  SVN-20141107   528     27.8  110.0     11035  10864/13397
  ARMv4          480     28.8  114.0      9767   9586/12126
  ARMv5TE        468     29.7  117.5      8751   8584/11118
  ARMv5TE_WST    544     33.6  133.0      6355   6316/6403

  (1) boosted
  (2) play full elephants_dream_320x240.mpg file (15693 frames) using
      mpegplayer, patched RB measures YUV to RGB565 frame conversion
      time (microseconds)

  Compared against the WST version, the ARMV5TE version w/o cached
  saturation tables is slower, but it is smaller and i have doubts
  about the power consumption.

Change-Id: I2b6a81804636658d85a1bb104ccb2055e77ac120
Reviewed-on: http://gerrit.rockbox.org/1034
Reviewed-by: Cástor Muñoz <cmvidal@gmail.com>
Tested: Cástor Muñoz <cmvidal@gmail.com>
2014-12-10 20:39:34 +01:00
Thomas Martitz
a2136a811f ypr0: Get it up and running again
7d1a47cf13 introduced a regression that broke it completely so that
it couldn't boot into the main menu anymore. It had a faulty call to
get_volume_name() which made handle_special_links() act up. This broke
every open() and opendir() (and friends) library calls.

Change-Id: I399960ca8fb6e3bcc1f25c9b4a3c19a6d28b77bd
2014-12-09 23:20:00 +01:00
Cástor Muñoz
9454ad4c97 iPod Classic: configure piezo GPIO ports
Configures piezo GPIO ports for the lowest power consumption
when not in use.

Change-Id: If80b0c947f197277972fd9319b8ab283cca96d3c
2014-12-08 03:11:34 +01:00
Cástor Muñoz
bfb63f8017 iPod Classic: minor modifications in TIMER
The current behaviour should not change.

Change-Id: Ia8f44cdccf41dbc3881722f9aebab91de51a9bc5
2014-12-08 03:07:44 +01:00
Andrew Ryabinin
8618f2c227 rk27xx: sd: properly align buffer used for DMA transfers.
Commit 7d1a47cf ("Rewrite filesystem code (WIP)") exposed
bug in rk27xx sd driver. Buffer passed to sd_read/write_sectors()
doesn't has to be cacheline aligned. DMA transfers on
unaligned buffers is quiet dangerous thing.
Make sure that the buffer is aligned to cacheline size,
If not use a temporary aligned buffer for DMA transfer.

Change-Id: I91420f2b8d58159c80c3f15f4b35e88ea0dfd14c
2014-11-29 21:00:11 +03:00
Andrew Ryabinin
d1fcfe950a Add IS_ALIGNED(x, a) macro helper
Change-Id: Ic5799e4bc03cabddece80cbc129b16f3a19ff9c5
2014-11-29 20:59:18 +03:00
Cástor Muñoz
794169a18f iPod Classic: fix HW_FREQ_32
Change-Id: I1e1b4e6ceb92eb793affaefc61ab082d5da735b4
2014-11-18 06:22:32 +01:00
Cástor Muñoz
57969698ce iPod Classic: update timer API using 32-bit timers.
Change-Id: I49dab8ae955a339ad0a27402fa21caa411c4ecf6
Reviewed-on: http://gerrit.rockbox.org/1032
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2014-11-16 14:18:32 +01:00
Cástor Muñoz
edb0c6c92f iPod Classic: fix s5l8702 cache line length.
Use 32 bytes for cache line length (arm926ej-s), this prevents
misalignments of ATA storage buffer which in some builds could
cause weird faults.

Change-Id: I88dc595d251315620ec49b0251ddc039ff47181e
Reviewed-on: http://gerrit.rockbox.org/1031
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2014-11-13 23:00:33 +01:00
Szymon Dziok
bcca111438 HDD1630/HDD6330/SA9200: Integration of the clicker with the "Keyclick" menu.
Change-Id: Ieb26f2252c1f2613cc9bd83c8349f49113f46d87
2014-11-10 21:40:47 +01:00
Amaury Pouly
73a780265a zen: typo
Change-Id: I68be3c768c092d7e43df8fa233f3a954e56f4d93
2014-11-10 20:30:16 +01:00
Amaury Pouly
6677f9786b Fix YUV generic C performance function on 24-bit framebuffer
When changed to handle 24-bit framebuffer, some places were missed.

Change-Id: Iaa7e09ea723e5b40bd88b2042c93dafaa7311fee
2014-11-10 20:30:16 +01:00
Udo Schläfer
fe519c7e4d Enable battery charging detection for iBasso DX50/DX90.
This changes iBasso DX50/DX90 config from CHARGING_SIMPLE (Simple, hardware
controlled charging (CPU cannot read charger state but may read when power is
plugged-in) to CHARGING_MONITOR (Hardware controlled charging with monitoring
(CPU is able to read HW charging state and when power is plugged-in)).

Not really usefull at the moment, since USB connection (charging) is not (yet)
gracefully handled for iBasso devices.

Change-Id: I55da81b10637d4de88d713ea5eba08eb59bc629f
Reviewed-on: http://gerrit.rockbox.org/1010
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
2014-10-18 05:31:34 +02:00
Szymon Dziok
aa8ba60fea YH820/YH92X: Properly enable morse input.
Change-Id: I6a35d64d0859b7ef429919c260a69974d6fdfafb
2014-10-08 16:31:39 +02:00
Szymon Dziok
193ea0909d Samsung yh820/yh92x: add HID keymaps.
Change-Id: I575e0e858aef0090d6864837d40a7b51e996ab43
2014-10-03 00:20:09 +02:00
Szymon Dziok
174523ab58 YH920: fix the battery capacity.
Change-Id: I6c7a771d8f1f1284fc13f1b0d16744fa03741c43
2014-10-02 20:58:20 +02:00
nialv7
4a396ac1ed ipod6g, ata: Fix audio drop off while waiting for ata not busy
Change-Id: Id8fe39593fe3e6c5f0801bfa47ee1e04f7e7045f
Reviewed-on: http://gerrit.rockbox.org/970
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
Tested: Nial Shui <nialv7@gmail.com>
2014-10-02 12:59:25 +02:00
Steffen Butzer
f5e2c25cb8 iPod Classic: Fix bidirectional clickwheel communication.
This restores functionality that was broken in g#194 and committed as
revision 7ec426e497.

Bidirectional communication is required to ask the clickwheel controller
for the initial button state during boot. Otherwise our driver would only
know about pressed buttons when the first change event is received,
which is too late for e.g. prevention of USB connection during boot.

This fix is also required to support the selection of OF, Rockbox,
Disk Mode, etc. in the iPod Classic Rockbox bootloader.

Change-Id: I127d54cf9e630d8075dd6d66f95dacb2816bfbc8
Reviewed-on: http://gerrit.rockbox.org/938
Reviewed-by: Michael Sparmann <theseven@gmx.net>
Tested: Michael Sparmann <theseven@gmx.net>
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2014-10-02 12:56:37 +02: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
Mihail Zenkov
02414bf286 Make sure the USB PHY is disabled after use. Patch by Mihail Zenkov who has
measured several milliamps power reduction from having the PHY disabled.

Change-Id: I29e55222eb50acf2023ac1113a90612029c580af
Reviewed-on: http://gerrit.rockbox.org/988
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
Tested: Michael Giacomelli <giac2000@hotmail.com>
2014-09-28 21:07:45 +02:00
Michael Sparmann
582035c5cb iPod Classic: Fix several ATA driver bugs.
This improves compatibility with various HDD and CF/SD card mods.
It should also reduce power consumption while the drive is powered down.

Change-Id: I4b22c59b5d9ae2daea2ec5892e348e7e1934ca3e
Reviewed-on: http://gerrit.rockbox.org/897
Tested: Franklin Wei <frankhwei536@gmail.com>
Tested: Nial Shui <nialv7@gmail.com>
Tested: Michael Sparmann <theseven@gmx.net>
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2014-09-22 10:16:35 +02:00
nialv7
5fd5b13939 unicode: Fix getle16 and getbe16
Change-Id: I8e1df113eee156491fc9624d148eb64c388bd962
Reviewed-on: http://gerrit.rockbox.org/958
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
Tested: Chiwen Chang <rock1104.tw@yahoo.com.tw>
Reviewed-by: Nick Peskett <rockbox@peskett.co.uk>
Tested: Nick Peskett <rockbox@peskett.co.uk>
2014-09-21 07:42:49 +02:00
Simon Rothen
0b5ad60c26 Introducing Targets iBasso DX50 & iBasso DX90
The port to for this two targets has been entirely developped by Ilia Sergachev (alias Il or xzcc). His source
can be found at https://bitbucket.org/isergachev/rockbox . The few necesary modifications for the DX90 port
was done by headwhacker form head-fi.org. Unfortunately i could not try out the final state of the DX90 port.
The port is hosted on android (without java) as standalone app. The official Firmware is required to run this port.
Ilia did modify the source files for the "android" target in the rockbox source to make the DX port work. The work I did
was to separate the code for DX50 (&DX90) from the android target.
On this Target Ilia used source from tinyalsa from AOSP. I did not touch that part of the code because I do not understand it.
What else I changed from Ilias sources besides the separation from the target "android":
* removed a dirty hack to keep backlight off
* changed value battery meter to voltage battery meter
* made all plugins compile (named target as "standalone") and added keymaps
* i added the graphics for the manual but did not do anything else for the manual yet
* minor optimizations

known bugs:
* timers are slowed donw when playback is active (tinyalsa related?)
* some minor bugs

Things to do:
* The main prolem will be how to install the app correctly. A guy called DOC2008 added a CWM (by androtab.info) to the
  official firmware and Ilia made a CWM installation script and a dualboot selector (rbutils/ibassoboot, build with
  ndk-build). We will have to find a way to install rockbox in a proper way without breaking any copyrights.
  Maybe ADB is an option but it is not enable with OF by default. Patching the OF is probably the way to go.
* All the wiki and manual

to build:
needed: android ndk installed, android sdk installed with additional build-tools 19.1.0 installed

./tools/configure
select iBasso DX50 or iBasso DX90
make -j apk

the content of rockbox.zip/.rockbox needs to be copied to /system/rockbox/app_rockbox/rockbox/ (rockbox app not needed)
the content of libs/armeabi to /system/rockbox/lib/ (rockbox app needed)

The boot selector is needed as /system/bin/MangoPlayer and the iBasso app as /system/bin/MangoPlayer_original. There
is also the "vold" file. The one from OF does not work with DX50 rockbox (DX90 works!?), the one from Ilia is necessary.

Until we have found a proper way to install it, it can only be installed following the instructions of Ilia on his
bitbucket page, using the CWM-OF and his installation script package.

Change-Id: Ic4faaf84824c162aabcc08e492cee6e0068719d0
Reviewed-on: http://gerrit.rockbox.org/941
Tested: Chiwen Chang <rock1104.tw@yahoo.com.tw>
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
2014-09-18 18:19:01 +02:00
Michael Sevakis
c1bbaf4050 Fix path_trim_whitespace() sign extension.
It should have been implemented as interpreting chars as unsigned
so that code points >= 0x80 would not get sign-extended and seen as
negative values.

Fixes FS#12995 - path_trim_whitespace() assumes unsigned char

Change-Id: I514e369681e00151588585311a0b6c66b9b5200c
2014-09-15 23:07:34 -04:00
Amaury Pouly
8146b40e73 Fuze+: add a configurable deadzone area for touchpad buttons
To stop erroneous button presses, allow users to add a deadzone between
the button via the Settings > General > System menu > Touch Dead Zone.

The configuration was chosen this way: the touchpad has the same DPI
in both direction so the setting applies the same on both the X and Y
axis. The setting ranges from 0 to 100 and is internally multiplied by 2
giving a maximum deadzone of 2*100 = 200 around each button, which
account for 400 total (once around each button), effectively reducing
each virtual button from 1000x600 to 600x200 when using the maximum value.

Change-Id: I8683c63d2950200eb32d1dda0a00bbd92d83d5be
Reviewed-on: http://gerrit.rockbox.org/677
Reviewed-by: Benjamin Brown <foolshperson@gmail.com>
Tested: Benjamin Brown <foolshperson@gmail.com>
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2014-09-08 11:21:54 +02:00
Dmitry Gamza
50778c82f1 optimize WSPLL work for iriver h100 and h300 series
For Iriver h100 & h300 series we don't need always use WSPLL,
because in most cases WSPLL clock and SYSCLK has the same value,
and we have additional WSPLL errors to the output clock. Now that is fixed.

Change-Id: I04aebee659c57c45dc8603e409b9db42bdde534a
Reviewed-on: http://gerrit.rockbox.org/434
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2014-09-05 09:14:53 +02:00
Michael Sevakis
0a66545487 Clean up a bit and get switch statement out of loop in walk_path()
It's nicer to look at and it obfuscated a bug where it should have
exited the loop instead of the case (you probably wouldn't observe
the effect very often).

Change-Id: I33f3c72c8bb7e11b9d418f66cf84efc3082a37b4
2014-09-02 15:57:18 -04:00
Michael Sevakis
802e0110db Fix a small late creep-in goof in path parsing on native targets
Anything of one dot and one character (e.g. ".a") would get treated as
"." because I left out a condition when converting to recursionless
parsing of relative components. Git 'er fixed up.

Change-Id: Id5603ce0858b419dc08b1d496b4b187a573595f9
2014-09-01 00:00:19 -04:00
Michael Sevakis
5b08f1a5b9 Remove I/O priority. It is harmful when used with the new file code.
HAVE_IO_PRIORITY was defined for native targets with dircache.

It is already effectively disabled for the most part since dircache no
longer lowers its thread's I/O priority. It existed primarily for the
aforementioned configuration.

Change-Id: Ia04935305397ba14df34647c8ea29c2acaea92aa
2014-08-30 14:01:21 -04:00
Michael Sevakis
da4938d6ee Get the last errors I hope!
Change-Id: Ia285b95480cc9ac6494b745d80892c4b1b912341
2014-08-30 01:29:18 -04:00
Michael Sevakis
f3d60aea34 Hopefully fix most of the errors and warnings from the last push
Change-Id: I1a466b2d55f120796910039a0296ca324c58e891
2014-08-29 23:36:11 -04:00
Michael Sevakis
17a007bc60 Add normal alloca() definition and implement a strdupa and friends
Change-Id: I21c9c21fd664fb11bc8496ace4a389f535a030d6
2014-08-29 22:06:59 -04:00
Michael Sevakis
77b3625763 Add mempcpy implementation
A GNU extension that returns dst + size instead of dst. It's a nice
shortcut when copying strings with a known size or back-to-back blocks
and you have to do it often.

May of course be called directly or alternately through
__builtin_mempcpy in some compiler versions.

For ASM on native targets, it is implemented as an alternate entrypoint
to memcpy which adds minimal code and overhead.

Change-Id: I4cbb3483f6df3c1007247fe0a95fd7078737462b
2014-08-29 22:06:57 -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
Michael Sevakis
21e2b595c2 Prevent spurious recompiles on account of changed version.
After a local commit, any file that included version.h would have to
be recompiled on account of the changed version string. This changes
version.h in the build directory to rbversion.h and includes the
preprocessor macro from rbversion.h in firmware/common/version.c so
that only that one file needs to be recompiled after a local commit
rather than a whole slew of them.

Change-Id: I900d97e3a24a0610698283416d97b4fa3a3a2cf6
Reviewed-on: http://gerrit.rockbox.org/937
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2014-08-28 15:48:56 +02:00
Michael Sevakis
25f73d6207 Patch up rbendian.h for Win32 cross-compile
MingW doesn't provide that stuff.

Change-Id: Ifa8310ed00f4f79f06adb71db71e58b70e7d2b60
2014-08-26 15:53:49 -04:00
Michael Sevakis
2cb274ca77 panicf doesn't return so why not tell GCC and $AVE :
Change-Id: I6096576f539bfb02b340b82fabc5019f6756b722
2014-08-25 13:55:16 -04:00
Michael Sevakis
6ffb8ffeee Do a better endian.h setup that isn't as fragile
We redefine the top-level macros to our own in order to maintain
compatibility with compound initializers by wrapping the mid or low
level definitions from the OS header.

This allows, hopefully optimized, macros from the host OS's headers to
be used when building any hosted target obviating the need for
NEED_GENERIC_BYTESWAPS unless the target simply doesn't define its
own optimized versions (MIPS!).

Throw in some 64-bit swaps for completeness' sake; they generate no code
if not yet used anyway.

Change-Id: I21b384b55fea46833d01ea3cad1ad8952ea01a11
2014-08-25 12:16:56 -04:00
Avi Eisenberg
d3cf366868 Fuze+: fixed brightness settings: previously there were 81 settings for only 26 possible brightnesses, now there are 33 for 33
Change-Id: Idc6e3a635850f3ee54ec23246795af88af960ab0
Reviewed-on: http://gerrit.rockbox.org/916
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2014-08-25 09:44:32 +02:00
Michael Sevakis
5fb370267f Make sure load_context is the last thing in switch_thread.
This should fix the android crash issue (fingers crossed).

Change-Id: I9d3f773dbdf7dde60bd76962dcf66a3bad8b0925
2014-08-20 05:58:59 -04:00
Michael Sevakis
a9713d89e7 thread-unix patchup!
The changed thread code may not wish to save the old context under
certain circumstances but thread-unix.c assumed it would, cached it
and used it unconditionally.

Also, prevent it from leaking away all the jump buffers (old problem).
Creating and removing threads would eventually run it out of buffers
and then it would crash after that. Plugins, like Pictureflow, which
have worker threads could only be started a few times. Implement a
simple O(1) allocator that will reuse them and stays self-contained
to its own types (as it appears the original author intended).

Change-Id: Icf65413c086b346fb79bf827102b725269e2812c
2014-08-18 10:40:44 -04:00
Michael Sevakis
030f51ce81 Oops. Broke an egg. Restore wrongly removed code in mutex.c.
Nice colorful diffs reveals some lines that should NOT have been
removed when !defined(HAVE_PRIORITY_SCHEDULING) in mutex_unlock.

Change-Id: I4152ea864b7706217c670e1b99250b09e69c5858
2014-08-16 06:37:29 -04:00
Michael Sevakis
528715a672 Fix warnings from 6ed0087
Forgot to (void) an unused parameter when priorityless.

usb-drv-rl27xx.c was using a compound init to initialize a semaphore
but the structure changed so that it is no longer correct. Use
designated initializers to avoid having to complete all fields.

Forgot to break compatibility on all plugins and codecs since the
kernel objects are now different. Take care of that too and do the
sort thing.

Change-Id: Ie2ab8da152d40be0c69dc573ced8d697d94b0674
2014-08-16 06:00:36 -04:00
Michael Sevakis
6ed00870ab Base scheduler queues off linked lists and do cleanup/consolidation
Abstracts threading from itself a bit, changes the way its queues are
handled and does type hiding for that as well.

Do alot here due to already required major brain surgery.

Threads may now be on a run queue and a wait queue simultaneously so
that the expired timer only has to wake the thread but not remove it
from the wait queue which simplifies the implicit wake handling.

List formats change for wait queues-- doubly-linked, not circular.
Timeout queue is now singly-linked. The run queue is still circular
as before.

Adds a better thread slot allocator that may keep the slot marked as
used regardless of the thread state. Assists in dumping special tasks
that switch_thread was tasked to perform (blocking tasks).

Deletes alot of code yet surprisingly, gets larger than expected.
Well, I'm not not minding that for the time being-- omlettes and break
a few eggs and all that.

Change-Id: I0834d7bb16b2aecb2f63b58886eeda6ae4f29d59
2014-08-16 05:15:37 -04:00
Michael Sevakis
eb63d8b4a2 Add common linked list functions
Forms implemented to a greater or lesser degree at the moment:
ll_*   = singly-linked list
lld_*  = doubly-linked list
lldc_* = doubly-linked circular list

Change-Id: Ieed5af50fc59165c8b14c3513b3b5d0e6f7de9fa
2014-08-16 00:27:01 -04:00
Michael Sevakis
9a3400a4a6 Fix some more straggling stuff
* HWCODEC bootloaders

* Remove references to thread structures outside the kernel. They are
private and should not be used elsewhere. The mrobe-100 is an offender
that gets squashed.

* The ata.c hack stuff for large sector disks on iPod Video gets squashed
for the same reason. I will no longer maintain it, period; please find
the real reason for its difficulties.

Change-Id: Iae1a675beac887754eb3cc59b560c941077523f5
2014-08-08 03:23:29 -04:00
Michael Sevakis
981d028c09 Do some kernel cleanup
* Seal away private thread and kernel definitions and declarations
into the internal headers in order to better hide internal structure.

* Add a thread-common.c file that keeps shared functions together.
List functions aren't messed with since that's about to be changed to
different ones.

* It is necessary to modify some ARM/PP stuff since GCC was complaining
about constant pool distance and I would rather not force dump it. Just
bl the cache calls in the startup and exit code and let it use veneers
if it must.

* Clean up redundant #includes in relevant areas and reorganize them.

* Expunge useless and dangerous stuff like remove_thread().

Change-Id: I6e22932fad61a9fac30fd1363c071074ee7ab382
2014-08-08 01:59:59 -04:00
Michael Sevakis
81ffd9bfee Fix some stuff for no priority and
thread_queue_wake() doesn't need the 2nd parameter. The original purpose
for it never came to be.

Non priority version mrsw_writer_wakeup_readers was left improperly
finished. Get that back into line.

Change-Id: Ic613a2479f3cc14dc7c761517670eb15178da9f5
2014-08-06 02:27:49 -04:00
Michael Sevakis
e7e302f255 One more shot; errno.h needs to be in the ARM one too :)
Change-Id: Icf5e5fb269c975eaaefc6e756f46d4530b982b1f
2014-08-05 22:20:28 -04:00
Michael Sevakis
0615cb8042 Hosted builds using thread.c have errno as thread context.
Never came up testing but I don't have those SDKs installed. Taking a
jab at it.

Change-Id: I4d0de1c666e0895d41b3de41dd9024626bd37601
2014-08-05 22:05:20 -04:00
Michael Sevakis
29f5385263 Fix up some more red
find_first_set_bit() becomes a small inline on ARMv5+ and checkwps now gets
made with -std=gnu99 (it eats all the GCCOPTS) like the rest of things.

Change-Id: Ie6039b17fec057a3dcb0f453d8fd5efac984df89
2014-08-05 21:32:13 -04:00
Michael Sevakis
bb7700928a Oops. Somehow lost the track of the new files last push.
Change-Id: If3fad318bc2d620fa940de3f9595ff61024939df
2014-08-05 21:00:10 -04:00
Michael Sevakis
533d396761 Add multi-reader, single-writer locks to kernel.
Any number of readers may be in the critical section at a time and writers
are mutually exclusive to all other threads. They are a better choice when
data is rarely modified but often read and multiple threads can safely
access it for reading.

Priority inheritance is fully implemented along with other changes to the
kernel to fully support it on multiowner objects.

This also cleans up priority code in the kernel and updates some associated
structures in existing objects to the cleaner form.

Currently doesn't add the mrsw_lock.[ch] files since they're not yet
needed by anything but the supporting improvements are still useful.

This includes a typed bitarray API (bitarray.h) which is pretty basic
for now.

Change-Id: Idbe43dcd9170358e06d48d00f1c69728ff45b0e3
Reviewed-on: http://gerrit.rockbox.org/801
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2014-08-06 02:47:47 +02:00
Szymon Dziok
86fa139eac Support for remote on Samsung YH920/YH925.
Remote buttons are bound to the standard buttons in button-target.h, but they can
have a separate buttonmap, if someone wants.

Change-Id: Id8c78a3dfec0005bf588dc16416870b4c7c56836
2014-07-28 22:11:33 +02:00
Szymon Dziok
228c47be4c Samsung YH-925: Don't add anything to adc value while reading it.
OF doesn't do such thing. Values in mV are converted proportionally, so no change
 to the battery meter.

Change-Id: Ic545b0514535e7f17f0379ed02f6bdf515f69ac6
2014-07-28 22:11:33 +02:00
Szymon Dziok
f74edac8c7 Samsung YH-920: Proper values for battery monitoring, based on the OF formula.
Change-Id: I894eb6bad600bd059fe9a5ea1103737a736d4005
2014-07-28 22:11:33 +02:00
Sebastian Leonhardt
7e778c5f49 Samsung YH-820: enable battery monitoring
The "percent_to_volt_charge" values are quite arbitrary
and may need some more tweaking.

Change-Id: I9f177d46681030d615fe2c2e78cf9bd2dde026af
Reviewed-on: http://gerrit.rockbox.org/824
Reviewed-by: Szymon Dziok <b0hoon@o2.pl>
Tested: Szymon Dziok <b0hoon@o2.pl>
2014-07-27 12:09:36 +02:00
Szymon Dziok
6bbfb35560 SA9200: Implement clicker.
It's not integrated with key click option for now.

Change-Id: Ib0769b02bfebe7c55eca7b7ea61df5d6dd83cdd3
2014-07-26 15:38:49 +00:00