Commit graph

11091 commits

Author SHA1 Message Date
James Buren
581081a3df mi4: replace chksum_crc32 with crc_32r
This uses an equivalent algorithm but with a different initial value
than we normally use (all bits off vs all bits on). Use the new crc_32r
to replace the original MI4 crc32 implementation.

This frees up some extra space on mi4 targets which gives us more
room on a few very space constrained targets (sansa c200/e200, etc).

Change-Id: Iaaac3ae353b30566156b1404cbf31ca32926203d
2021-06-21 09:36:54 +00:00
James Buren
fc92081080 rockbox: add a crc32 reverse polynomial function
This uses the reverse of the polynomial used by the current crc_32
function. The code for this was derived from the implementation used
by tinf. This version is space optimized and should be a good way to
reduce code duplication in other parts of rockbox that use the same
crc32 algorithm. This is mainly of use in areas where DEFLATE is in
use.

Change-Id: I918da5b4ea4dc441c0e7e6b5007abcc2da463bcb
2021-06-21 03:37:17 +00:00
Tomasz Moń
2ca5774cf9 Sansa Connect: Indicate charging status
Consider battery level down to 0 as safe as OF continues to operate
normally even when at level 0.

Change-Id: Ie3889e5662b9fa6588e20ad02d8953f29e28800c
2021-06-20 10:33:46 +00:00
Aidan MacDonald
a3f2b64a46 Enable float formatting in printf
Needed for g#3415, and if the comment is to be believed, this needed
updating for recent MIPS targets anyway.

Just blanket enable everything for all targets with >= 8 MiB of RAM.
The only targets with less than this are the Sansa Clip, c200v2, and
m200v4, which all have 2 MB of RAM.

The added code size is around 4 KiB to 7 KiB, depending on the target.

Change-Id: I5773482a13543dabb1f93f713a21f1382a9c5a22
2021-06-16 19:49:55 +00:00
Tomasz Moń
f6c7407cc3 DM320: Use SD/MMC data done interrupt
Wait on semaphore until DMA finishes instead of busy waiting. This
allows the CPU to be used by other tasks during transfers.

Increase peripheral clock frequency, divide AHB by 2 instead of 3.
Function clock frequency is AHB divided by MMC divider + 1.

Change-Id: Ic890634da7e3541962ea3501eae8fa2ca2db606a
2021-06-15 07:31:29 +00:00
Aidan MacDonald
95408f2117 FiiO M3K: Add dual boot support
Change-Id: Ic34d50855b317b5f4073b232dbf458edf82f55e1
2021-06-14 20:45:14 +01:00
Aidan MacDonald
89f4064743 x1000: Extend CPM registers for dual boot
Change-Id: I283834a653506fd95ff8b56897e5f3afaf375cf5
2021-06-14 20:45:14 +01:00
Aidan MacDonald
2d6ddd0c5b x1000: NAND driver bugfixes
- Missing mutex unlock in nand_open()
- SET_FEATURE command incorrectly issued as a read operation
- Inverted protection bits, not sure how that happened...
- Block erase skipped ahead by a wrong amount, causing erases
  spanning multiple blocks to erase the wrong blocks

This code was buggy as hell... it's in need of a major overhaul.
It's not very flexible or reliable, and access to the flash is
useful during development of a new port, even if not useful once
the port is complete.

Change-Id: Ib85ee7453beab9657e3d19798ebaa09174b3649e
2021-06-14 20:45:14 +01:00
Tomasz Moń
02c4ec294c Sansa Connect: Properly setup internal speaker
Switch to internal speaker when headphones are disconnected.

Change-Id: I7c04ac139ad540d85f960e9dadc2faaf4f856055
2021-06-14 12:48:16 +00:00
Tomasz Moń
f3f9d1fb95 USB Serial: Implement Abstract Control Management
On devices that can assign interrupt IN, bulk IN and bulk OUT endpoints
this change results in the serial interface working out of the box on
Linux and Windows. On Linux it is registered as ttyACM device and on
Windows it is assigned a COM port number.

On devices that cannot assign the interrupt IN this change won't have
any effect.

Implement minimum required interface control requests. Respond with
whatever line coding was set to make terminal programs happy.

Change-Id: Id7d3899d8546e45d7cb4ecc3fe464908cb59e810
2021-06-12 14:47:15 +00:00
Tomasz Moń
663d846cf3 Sansa Connect: Disable endpoint double buffering
Disabling double buffering results in expected CPPI TX behaviour. With
the double buffering enabled, sending single ZLP resulted in two ZLPs
being available. The two ZLPs is problematic because this causes Windows
to reset USB device after failed SCSI command.

The problematic sequence on Windows 10 was as follows:
  * Host sends SCSI Mode Sense(6) Informational Exceptions Control(0x1C)
  * Device sends ZLP
  * Device sends command failed response

With endpoint double buffering enabled the ZLP was read twice by host.
As host was expecting command response on the second read (and got ZLP
instead), host attempts recovery by resetting USB device and retrying.

Change-Id: I64e95998f429ffb7b14143d956b1f29d20218d14
2021-06-12 13:54:54 +00:00
Aidan MacDonald
d01f3192f2 Spin off common ft6x06 code to a driver
Allows for the i2c boilerplate to be shared between the M3K and
Shanling Q1 ports. M3K-specific quirks remain in button-fiiom3k.

Change-Id: I8879b603cefc16416bb200f1c484ca916d935c6a
2021-06-11 20:09:38 +01:00
Tomasz Moń
551c74da55
Sansa Connect: Remove fake battery voltage scale
Use battery percentage as reported by AVR.

Change-Id: Id697d460b240798eb0b103f9e1f419906b87e9ca
2021-06-10 08:43:32 +02:00
Tomasz Moń
f26499bd67
Sansa Connect: Add missing include
Include usb.h to have usb_acknowledge() prototype.

Change-Id: I2dd951315a93e7c1c456358d715f9ec44bf9e5af
2021-06-10 08:02:23 +02:00
Tomasz Moń
163e3507f8
Sansa Connect: Working USB Mass Storage
Acknowledge SYS_USB_CONNECTED in all queues so USB task can gain
exclusive access to the storage.

Reduce CPPI requeue timeout to speed up disk access.

Change-Id: I322aae4cac679696bb8186ccacf838a18f0715e9
2021-06-09 20:52:36 +02:00
Tomasz Moń
a11c88e0df
Sansa Connect: Fix sending ZLP on non-zero endpoint
This fixes panic when mass storage driver sends failed result.

Change-Id: I14ae975b1f23aee7bc2f7bad6ed68dde29cf5e36
2021-06-09 19:13:49 +02:00
Tomasz Moń
efa173a923 Sansa Connect: Fix bulk transfers greater than 64 bytes
Correctly set endpoint maximum packet size so host will not consider
end of transfer after receiving first packet when transfer is larger
than 64 bytes (at High Speed the endpoint max packet size was set to
64 but according to descriptor it is 512).

Split DMA transfers up to CPPI_MAX_FRAG so we get single interrupt
after each call to tnetv_cppi_send().

Change-Id: I385b66bc5d71975a4e3e9167efac0b1334bd3ffc
2021-06-09 10:21:06 +00:00
Tomasz Moń
7f3d0ce814 DM320: Fix SDHC response format 2 handling
Return complete R2 response to caller. Due to incorrect bitfield
handling only bits [127-96] were ever returned to caller.

Change-Id: I83726af35fb24a8051fcca8b8d019ad89d17500e
2021-06-09 10:09:50 +00:00
Aidan MacDonald
55c95a9cf5 FiiO M3K: filter touchpad input when it's disabled
I had hoped this would fix FS#13297, but no luck. Might as well
do this change anyway, because it's the "right" thing to do.

Change-Id: I55819c881d2141dd565e1c1f21460578c9114ff6
2021-06-07 22:28:58 +01:00
Aidan MacDonald
2b23d3ecaf x1000: Allow setting IRQ handlers dynamically
Avoids having to #define the names of GPIO pin interrupt handlers,
as they can now be set at runtime instead.

Change-Id: Ib5da1bdb475ff7b64280fe7cdd00adab63389152
2021-06-06 11:06:43 +00:00
Aidan MacDonald
e85bc74b30 x1000: GPIO refactor
The GPIO API was pretty clunky and pin settings were decentralized,
making it hard to see what was happening and making GPIO stuff look
like a mess, frankly.

Instead of passing clunky (port, pin) pairs everywhere, GPIOs are now
identified with a single int. The extra overhead should be minimal as
GPIO configuration is generally not on a performance-critical path.

Pin assignments are now mostly consolidated in gpio-target.h and put
in various tables so gpio_init() can assign most pins at boot time.

Most drivers no longer need to touch GPIOs and basic pin I/O stuff
can happen without config since pins are put into the right state.
IRQ pins still need to be configured manually before use.

Change-Id: Ic5326284b0b2a2f613e9e76a41cb50e24af3aa47
2021-06-06 11:06:14 +00:00
Tomasz Moń
474293a12b Sansa Connect: Initial TNETV105 driver port
Port USB driver from Sansa Connect Linux kernel sources. The device
successfully enumerates and responds to SCSI commands but actual disk
access does not work. The SCSI response sent to host mentions that both
internal storage and microsd card are not present.

Change-Id: Ic6c07da12382c15c0b069f23a75f7df9765b7525
2021-06-06 07:57:38 +00:00
Tomasz Moń
77603c344d DM320: Fix buffer overrun in sdmmc driver
Modify count, buffer and start address only after successful transfer.
This makes the retry operation to use the same address and buffer as the
just failed transfer.

Change-Id: I4f49bbdc861d634e33ea5e939a9693474411d24d
2021-06-05 18:41:02 +00:00
Solomon Peachy
ce5fe4d108 ata: fix a typo in a definition that's thankfully not used.
Change-Id: I6f2d4d05249dc01b48caa1507ee0e71496c67ba6
2021-06-03 21:04:29 -04:00
Solomon Peachy
00440f2137 ipod6g:: Get rid of magic command numbers in ata driver
Use CMD_* macros instead.  Makes the code a bit easier to follow.

No functional change.

Change-Id: Ieb3d8f6fcca503421d3067aafbd0011a908368e0
2021-06-04 01:03:51 +00:00
Aidan MacDonald
cec6422ace x1000: LCD driver minor fixes & improvements
- Use unsigned bitfields in 'lcd_tgt_config'
- Set DTIMES when using an 8-bit bus width
- Allow using DMA big-endian mode
- Provide an #ifdef to avoid stopping DMA in the middle of a frame
- Correctly #ifdef LCD sleep code when target does not implement it

Change-Id: I327c6b05223638b876d5ab62cb6e48f82e6d5fa5
2021-06-03 22:54:59 +00:00
Aidan MacDonald
a6b5de6a89 x1000: minor adjustments to PWM code
- Change busy loop to wait on the timer flag instead of hoping to
  catch the timer at exactly the right moment... unsurprisingly,
  that did not work well with higher frequency PWM outputs.
- Put GPIO data into a dedicated const array.

Change-Id: I2a920ed265c192da197a18c7242f3205d11636d3
2021-06-02 23:52:53 +01:00
Aidan MacDonald
0187fca640 axp173 driver: rename to "axp-pmu" + other changes
The old name was a bit misleading. AXP173 is sort of the lowest common
denominator of a series of related chips. The M3K uses an AXP192 which
has a few extra features vs. the AXP173.

New voltage regulator stuff was added for the sake of the Shanling Q1
native port (that player also uses an AXP192).

Change-Id: Id0c162c23094bb03d13fae2d6c332e3047968d6e
2021-06-01 19:57:41 +00:00
Aidan MacDonald
2066465b78 FiiO M3K: minor fixes
- Drop obsolete NAND patch script (it's simpler to use 'dd' directly)
- Remove an outdated comment
- Fix missing 'void' in a function definition
- Reset the poweroff timer when we poke the backlight

Change-Id: I752624386f30ac95f41a731d2b6be837e12275a9
2021-06-01 00:26:20 +01:00
Aidan MacDonald
663c5268ac AK4376 driver: refactoring
Some audiohw API calls are shared between playback and recording,
eg. frequency settings. Implementing these in the DAC driver won't
work for the M3K, as it uses a separate codec for microphone input.

Change-Id: Ieb0a267f8a81b9e2bbf0bbca951c5778f8dcd203
2021-05-31 23:00:14 +01:00
Aidan MacDonald
f63edb52ef x1000: refactor AIC initialization
Have pcm-x1000 handle most work, so target's audiohw code touches
only the relevant settings.

Change-Id: Icf3d1b7ca428ac50a5a16ecec39ed8186ac5ae13
2021-05-30 19:17:50 +00:00
Aidan MacDonald
c78ba1aa68 MIPS: add another mipsr2 endian function
Used by WAV and AIFF encoders for recording.

Change-Id: If1bf05583c6b5c123c91eb9c4dfe0e11efd3a0f7
2021-05-29 15:35:50 +00:00
Aidan MacDonald
f64e8dc33c x1000: Complete the register definitions
I think this covers everything now, although some fields are missing
enum values. Those can be added in if and when they are needed.

Change-Id: Ib1a94ba9c9a5949b6a038f8c1a49786823fae58f
2021-05-29 16:34:32 +01:00
Aidan MacDonald
5cbeb88541 FiiO M3K: keymap improvements & fixes
- Add support for skip and seek while the player is locked.
  (Thanks to @bahus for the suggestion)
- Fix touch zones because the down button zone ended up being
  a lot smaller than expected due to the touchpad's wonkiness.
  Also added a visual display of the touchpad to its debug menu.
- Fixes the pictureflow keymap because it was mostly unusable.

Change-Id: Ic0da4f8df3613ff7828ce1cb940ed9e77ada3281
2021-05-22 12:20:44 +00:00
Tomasz Moń
00b4626790 Sansa Connect: Clear recoverzap parameter
Clearing recoverzap parameter exists the Recovery Mode. This makes it
possible to run Rockbox on Sansa Connect without relying on original
Linux firmware.

Enable write-through cache on flash memory as write-back complicates
handling without any real benefits. The flash memory accepts commands
as series of writes at predefined addresses, so it is important that
the cache does not interfere with the writes.

Change-Id: I219f962f20953d84df43012cf16bbb16d673add8
2021-05-21 18:55:14 +00:00
Solomon Peachy
0c62177575 FS12845: Fix uninitialized read
Change-Id: If0e5b65a70e10b624416e2a15e0b3df29c2b4591
2021-05-19 17:09:48 -04:00
Aidan MacDonald
ad64293ae6 X1000: fix SD driver issues
- Added panic check for unaligned addresses
- Properly set 50 MHz high-speed mode timings

Change-Id: Ia0b3e5a6612c2053a28c2c3125de8ea92100912e
2021-05-14 10:30:58 +00:00
Aidan MacDonald
eb0336eded FAT: align writes when bounce buffering is enabled
Motivation: turns out the DMA in the M3K's MSC controller is buggy,
and can't handle unaligned addresses properly despite the HW docs
claiming otherwise.

Extending the FAT driver bounce buffering code is the easiest way
to work around the problem (but probably not the most efficient).

Change-Id: I1b59b0eb4bbc881d317ff10c64ecadb1f9041236
2021-05-14 10:30:41 +00:00
Solomon Peachy
ff28d238b8 ibasso: DX50/DX90 support 192KHz audio
Also bump max battery capacity to 7300mAh, to accomodate
oversized aftermarket units that require case mods.

Change-Id: I743e550b0c0843ab17529e70b5d592ea0e9a79d8
2021-05-13 21:40:22 -04:00
Dana Conrad
84a3cbe24d ErosQ: Small keymap changes
- Move WPS Stop to Power (Hold)
- Add WPS Hotkey to Wheel scroll Fwd/Back
- Add WPS Quickscreen to Play (Hold)
- Add Tree Hotkey to Play (Hold)

Change-Id: Id74622138353521f736c0de1009a354307b108eb
2021-05-12 11:01:27 +00:00
Moshe Piekarski
b895fb6643 Add tm->yday to RTC ports missing it
Change-Id: I86882262bafb8d06f925aabb87ebd1b5dcb0cd53
2021-05-12 10:52:03 +00:00
Aidan MacDonald
3f26fcf340 FiiO M3K: New bootloader
SPL and UCL-compressed bootloader are now packed into one output,
bootloader.m3k, eliminating the separate SPL build phase.

The Rockbox bootloader now has a recovery menu, accessible by
holding VOL+ when booting, that lets you back up, restore, and
update the bootloader from the device.

Change-Id: I642c6e5fb83587a013ab2fbfd1adab439561ced2
2021-05-12 10:35:20 +00:00
Aidan MacDonald
3748117ee3 Add standalone UCL decompressor
Change-Id: Ibdb128ad66a7dcdd617dc83dfd294c0b24d4901d
2021-05-12 10:35:20 +00:00
Aidan MacDonald
15ad1c42db X1000: simplify NAND driver
- Removed unnecessary layers of generic code
- Software ECC is gone since we don't need it now (and maybe not ever)
- Removed bounce buffering, so callers must now align buffers

Change-Id: I33fbac9d9d12a4657980b8618c7d62bfa91e2ea0
2021-05-06 08:37:26 +01:00
William Wilgus
49edfc237b lcd_putsxyofs 16 bit lcd_mono_bitmap_part [AS]
'Bugfix' mono_bitmap_part reads ahead in the buffer,
if the height is <= char bit pixels other memory gets read
found with [Address Sanitizer]

also g#3332 since this is clearly a problem across the code
instead place the check for height < 8 in the lcd_mono_bitmap_part function

Change-Id: I917cbbd568fd5474b76a98c8919467e2538e0f0c
2021-04-30 21:26:06 -04:00
Aidan MacDonald
16a1993cad x1000: Remove some #ifdef SPL in the sfc/nand code
Change-Id: I554d590bfa700e521a74b5216e09f9673902d676
2021-04-28 20:04:10 +01:00
Aidan MacDonald
423fcf951a x1000: Rewrite clk_get code so it's more data driven
This is not pretty, but at least it should be usable by the SPL.

Change-Id: I1c0cdb910109c882160e3effd7c778e4d961842c
2021-04-28 20:04:10 +01:00
Aidan MacDonald
20fc928221 x1000: Centralize common definitions, memory layout
Change-Id: I8daad058ae55d4b750b1ae407153e4917de5d095
2021-04-28 20:04:10 +01:00
Aidan MacDonald
ed8c977e2f x1000: Fix stupid bug in the SPL
This overwrote the first 2 instructions of crt0 in the bootloader!
I'm really not sure how this *didn't* cause a fatal exception.

This address isn't special as far as I know, so just move it to the
TCSM by making it a static variable.

Change-Id: I58e1486804aeb2b68325e8de2aa1874c97abef19
2021-04-28 20:04:10 +01:00
Aidan MacDonald
d5695822a7 MIPS: remove .MIPS.abiflags section
The abiflags data is only used to communicate ABI information to a
program loader -- you can see what info is stored with readelf -A.
Dropping it shaves 24 bytes off of every binary (including plugins).

Change-Id: Iae78eeffe5c840ff67717707fb94821d24aac8ec
2021-04-26 12:41:06 +00:00