Commit graph

35549 commits

Author SHA1 Message Date
Aidan MacDonald
02860d67c3 Touchscreen: adjust calculation of bar touch position
Increased the precision of the bar from 100 steps to 1000 steps so
it is possible to make finer adjustments, and made it possible to
pick the maximum value in a bar rather than just the maximum - 1.

Change-Id: I2e694d3e86e4a151e014da1bd15ab3ade4c4b95e
2021-06-22 21:37:02 +01:00
Aidan MacDonald
8a6b2f3abc Touchscreen: make volume bars respect volume step increment
Change-Id: I449b305ec4070e61f3619f8b7ac01a74c3ac59a6
2021-06-22 21:37:02 +01:00
Tomasz Moń
b5c40d9991
Sansa Connect: Refactor AVR command handling
Add defines for all commands handled by AVR, including the unknown
opcodes (0xC5, 0xD3, 0xD4, 0xD5, 0xD6).

Properly synchronize with AVR and keep repeating command until it looks
like AVR has accepted it.

Change-Id: I3d42e973f135e33092c71c9887421906a900ab58
2021-06-22 19:18:17 +02:00
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
Solomon Peachy
0faf978c3d build: Add an 'xz' target to generate a .tar.xz image
Improve the tarball generation a bit too

Change-Id: Ie68bea4e876bad5cd101dd396ec2247127b1b390
2021-06-17 11:56:59 -04:00
James Buren
3831051c47 mknkboot: optimize verifyfirm
The checksum only needs to be calculated once. A small oversight on
my initial implementation.

Change-Id: Ie23faf36f5add7ed7f146769b604dbd8204c2605
2021-06-17 15:30:51 +00:00
Solomon Peachy
2ed4bf8a43 FS#13299: Handle MP3 files with more than 128K of headers before audio data
Encountered a file with ~600K of ID3v1 headers.

Optimize the potential overhead by minimizing reverse seeks.

Change-Id: I972dbf1af1c36659f19c7ab4eed0b9149c642880
2021-06-16 17:37:29 -04:00
Solomon Peachy
fa9ddd5af9 Revert "FS#13299: Simplify VBR frame parsing in the metadata decoder."
This reverts commit 756c0d2ac8.

Change-Id: I5f98972f69e7645239fd9218c9d4eeb9bd2ec7a5
2021-06-16 16:58:47 -04:00
Aidan MacDonald
7aade87863 Fix yellow from 9ccae042
Change-Id: Iad4eaab8b766d1d0aad051971fd49a64126ca4be
2021-06-16 21:22:49 +01:00
Moshe Piekarski
9ccae0421a Implement x^y in calculator
Change-Id: I868b703131675876bd91198b8a53a921152aecba
2021-06-16 19:50:14 +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
Solomon Peachy
756c0d2ac8 FS#13299: Simplify VBR frame parsing in the metadata decoder.
The old code would seek forward by the frame length, expecting to see a
frame header there, perform a validity check, and then seek back to the
current header.

Unfortunately this doesn't handle situations where there is extra padding
between the frames, leading us to potentially read garbage, causing the
validity tests to fail and rejecting the file outright.

Instead, keep track of the previous valid header/position, and if we find
"valid" headers in a row return the first after seeking back to it.

This change allows the file referenced in FS13299 to be properly parsed, but
further work is needed to get the file to be playable.  (file reports itself
as layer 1, variable bit rate, variable sample rate!)

Change-Id: I85f61a6360cc041a172db4b7a6b5516e5b60ceee
2021-06-13 12:13:03 -04:00
Dana Conrad
c067b344e8 FS#13297: M3K Autolock allows one action before disabling touchpad
Intercept buttonpress and action, and nullify both if the button
is part of the touchpad. Only affects autolock functionality.

Adding removal of note about autolock in the manual - the lock
button no longer needs to be pressed at least once to prime
the autolock, if enabled, since commit 14f7a95

Change-Id: Ic3582764df490d96abc2d78116f23cbe0fdd6173
2021-06-12 21:11:28 +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
James Buren
a90ef8195b mknkboot/beastpatcher: implement basic firmware validation
This imports the MD5 code used by other utilities and creates
a function for checking the provided NK.bin against known original
firmware checksums. Integration into mknkboot and beastpatcher is
also added.

For the sake of consistency with beastpatcher, mknkboot had its
printf statements rewrote to print to stderr like beastpatcher
does.

Change-Id: I0e52271d8d627a5b02302ab5cd1da2815b7cec1e
2021-06-12 06:32:08 +00:00
James Buren
fe9bcd0468 beastpatcher: fix some minor issues
This mainly fixes some compiler warnings and makes it
work with mingw64.

Change-Id: Iabd13b5bed3427869ae78ceeb7e2255e68a6f7bd
2021-06-11 19:32:55 +00:00
James Buren
ab0f23c4b1 sendfirm: fix some minor issues
This patches some compile warnings and also makes it work correctly
with modern mingw64.

Change-Id: I8cd292bc989ae04bbaa1d7149d58d6d833a51c0a
2021-06-11 19:32:35 +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
Dana Conrad
41ced369f6 ErosQ Simulator: fix keymap
The eros q simulator keys have been weird for a while, found out why.

Change-Id: Icb4209774448bc3c0d67dd87f802661cf12874b2
2021-06-07 22:01:47 +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
Dana Conrad
4c94c17913 ErosQ: undo ACTION_YESNO_ACCEPT button release
I accidentally left this in commit 8056b7f, and I think I'm giving
up on this for now - it just gets too complicated in the usb use
case. Revert to BUTTON_PLAY.

Change-Id: I9e392a3d7f2c18f34de54ecbafdb27cdf863b28c
2021-06-06 21:44:24 +00: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
Aidan MacDonald
695d1701cd jztool: add correct compiler flags for building on Mac
Change-Id: Ic89b5a2e65754891fedd63fec1e7235ed424e5f9
2021-06-06 11:52:23 +01: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
62098a0cc9 toolchain: To build GCC for hosted targets, we need -std=gnu++11 for stage2.
But for stage1 (and non-hosted targets) we can stick with -std=gnu++03.

This keeps everyone happy with no apparent regerssions on older
host compilers.

Change-Id: I1300574557bc8d4d13e5cf07d4ae85645998f071
2021-06-04 10:05:05 -04:00
Aidan MacDonald
49dfc8be27 rockboxdev.sh fixes for hosted MIPS toolchain
Add --with-sysroot= to the configure args of glib and dbus because
otherwise they get confused and try to use host system dependencies.

Also fix the broken restart logic so you can actually restart a build.

Change-Id: Ib456c04845d80cc923dcc6b83e57f67a0868104b
2021-06-04 13:06:57 +00:00
Solomon Peachy
18288fcce6 toolchains: Fix gcc 4,9.4 compilation using GCC11.
Basically it defaults to using C++17, which breaks the GCC compilation.
Instead, explicitly specify -std=c++03, which should work everywhere.

Change-Id: I821591dbbac4fab4b1d930702ed66c7c767b5c92
2021-06-04 08:38:35 -04: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
Dana Conrad
14f7a958af Softlock Improvements
Add a check to see if the keys are currently locked and allow
them to be unlocked to ensure we don't get stuck when the current
playlist ends while the WPS is locked.
(Original by Aidan MacDonald)

Adding initialization for unlock_combo and to arm the autolock
(if enabled) without the user needing to press the lock button
at least once every boot (which is the prior behavior).

Removing screen_has_lock check from is_keys_locked()

Change-Id: I0fbf9b9746b011a7086ec8505a7ecc4b84f2d332
2021-06-04 00:00:57 +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