Commit graph

11136 commits

Author SHA1 Message Date
Aidan MacDonald
e532714d1f pcm: Remove unused function pcm_play_dma_get_peak_buffer()
Change-Id: Ifd20fb14a22489cdb99154c01f69809a1e70d0c5
2021-07-25 14:07:41 +00:00
Solomon Peachy
cb92280eca usb_storage: Fix a memset in SCSI_INQUIRY that overflowed its buffer
The funny thing is that the memset() for the field in question was
redundant, as the overall inquiry structure was memset(0) already.

Change-Id: I8bec0c93c9317823ff39cf7133535e3bf58fb987
2021-07-23 00:26:35 +00:00
William Wilgus
b91ad60d63 timefuncs.c valid_time() should return false if tm == NULL and not try to deref
luckily no one has
yet..

Change-Id: I4117db84b013fa826958aea635daa0a24ee534b6
2021-07-20 23:25:31 +00:00
Aidan MacDonald
07a3f6bcdb add Eros Q native simulator build
Change-Id: Ifdc882d19020da2e18234d6276409ad3e7efa138
2021-07-18 13:51:30 +01:00
Dana Conrad
3e7a09cb0d New Port: Eros Q Native
What works:
- LCD: 16-bit RGB565
- all buttons, including scrollwheel
- SD Card
- Battery level and charging/not charging status
- USB
- audio
- sample rate switching
- HP / LO detect, with "safe" fixed LO volume -
   LO volume will only be put to user-defined max volume
   if headphones are not present.
- rtc
- Plugins build, tried a couple and they seem OK
- Bootloader, installable to nand via usbboot

What doesn't work:
- Dual Boot
- power on/off has intermittent, low volume audio click
   (sometimes it's completely silent, sometimes there's
    a click)
- Audio uses 16-bit volume scaling, so clicking/popping
   is pretty bad at lower volumes - need 32 bit volume
   scaling, 24 bit I2S data
- USB HID keys not yet defined
- no jztool support

Unknowns:
- Stereo Switch pins: Direction select, AC_DC
   (probably not even hooked up)
- What is the actual purpose of the Stereo Swtich?
- How does the bluetooth module connect?

"Someday" stuff:
- get LCD working at higher bit depth
- Bluetooth

Change-Id: I70dda8fc092c6e3f4352f2245e4164193f803c33
2021-07-18 12:14:35 +00:00
James Buren
64a24591ae crc32: add fast variant of regular crc_32r function
This relies on a macro, CRC32R_FAST, to select which version to
compile with. In tests the fast version is 2x faster at the expense
of requiring 960 more bytes for the lookup table. For now the default
is the space optimized version but in the future I would like to enable
this for ports where we can afford the extra storage and/or memory
requirements.

Change-Id: I25397dadedc3187bb02b2444f8b8ded77c2509b6
2021-07-18 05:17:31 +00:00
Solomon Peachy
cd17decd5a xduoox3ii: Add "Super Slow" filter roll-off
I'm not happy with the proliferation of filter-roll-off options
but I don't have a less ugly solution.

Change-Id: I740fca006fa0c3443a467acfea55b6574d48346b
2021-07-17 08:18:31 -04:00
Aidan MacDonald
4c60bc9e68 New port: Shanling Q1 native
- Audio playback works
- Touchscreen and buttons work
- Bootloader works and is capable of dual boot
- Plugins are working
- Cabbiev2 theme has been ported
- Stable for general usage

Thanks to Marc Aarts for porting Cabbiev2 and plugin bitmaps.

There's a few minor known issues:

- Bootloader must be installed manually using 'usbboot' as there is
  no support in jztool yet.

- Keymaps may be lacking, need further testing and feedback.

- Some plugins may not be fully adapted to the screen size and could
  benefit from further tweaking.

- LCD shows abnormal effects under some circumstances: for example,
  after viewing a mostly black screen an afterimage appears briefly
  when going back to a brightly-lit screen. Sudden power-off without
  proper shutdown of the backlight causes a "dissolving" effect.

- CW2015 battery reporting driver is buggy, and disabled for now.
  Battery reporting is currently voltage-based using the AXP192.

Change-Id: I635e83f02a880192c5a82cb0861ad3a61c137c3a
2021-07-13 22:01:33 +01:00
Aidan MacDonald
3abb7c5dd5 x1000: revamp MSC driver card detection logic
Debounce logic now handles both removal and insertion and verifies
the detection is stable for 100ms before taking any action.

This solves the bootloader "file not found" issue on the Shanling Q1.
It seems a false removal event was generated, causing the filesystem
to be automatically unmounted. Probably this is due to some transient
noise at boot. Delays didn't solve the problem, probably because the
bogus hotplug event was queued, and normal mdelay() would simply delay
event delivery.

Change-Id: I8b03fb3550309f5a7ab4be0be7465a3dab2d3450
2021-07-13 22:01:17 +01:00
James Buren
3c4fdf10e2 crc32: add fast variant of regular crc_32 function
This relies on a macro, CRC32_FAST, to select which version to compile
with. In tests the fast version is 2x faster at the expense of requiring
960 more bytes for the lookup table. For now the default is the speed
optimized version but in the future I would like to enable this for ports
where we can afford the extra storage and/or memory requirements.

Change-Id: I8c7fde6b6ff130f0fdc7c8e472825e25bcdba022
2021-07-13 04:41:32 +00:00
Aidan MacDonald
84362141a0 x1000: Unified flash bootloader installer
Change-Id: Ib1d41d4e7d663ff8a21eb08108c13568f7408533
2021-07-11 15:39:50 +01:00
James Buren
1298e47134 zip: include strlcpy.h
Change-Id: Ic26a95e35a005837cbd3c8d9318d2cced9b726ff
2021-07-11 13:17:54 +00:00
James Buren
fa743258ea filesystem: implement os_modtime for unix
Change-Id: If030d526f29aa786b5a37402413d804752286cf5
2021-07-11 12:40:08 +00:00
James Buren
8846e087c0 zip: implement zip extraction support
This adds code sufficient to extract files to available storage given a
suitable root directory to extract to. It works on an already open zip
handle and also supports chain-loading a secondary callback in the event
that integration into the process is desired.

Change-Id: Id200d8f20d84a0cbd22906470de8bbd21d4525ef
2021-07-11 05:14:20 +00:00
James Buren
a1bcca645b zip: rename modts field to mtime
This brings it more in line with other structs with this exact same data
type and usage.

Change-Id: I5fe8564750ef28ccd0b12efedca2e6958369f712
2021-07-10 13:44:03 +00:00
Tomasz Moń
6c084ac3ea
Sansa Connect: Ensure LCD starts before backlight
Extra delay prevents white flash after hold switch release.

Change-Id: Ib0d33937dcbb738b913388e7df92ffdf9346c9f9
2021-07-10 13:20:29 +02:00
Tomasz Moń
b4ecd612f7
Sansa Connect: Use deviceid in USB Serial Number
Atmel AT88SC6416C CryptoMemory is almost I2C compatible. The device
is connected to bitbanged I2C bus shared with compliant I2C devices.

Change-Id: Iec54702db1bdfb93c01291eef18ec60391c63b16
2021-07-10 08:56:32 +02:00
Tomasz Moń
8de163b8ae
Sansa Connect: Fix reported CPU frequency
Make frequency related comments accurate. Disable UART0 clock.

Change-Id: I224a3d6656ad53165dcff68ed716fa2c6863240d
2021-07-09 14:16:05 +02:00
Tomasz Moń
60e2cd6de9 DM320: Regorganize LCD and TTB memory layout
Do not introduce any change for M:Robe 500 as it uses the two LCD frames
in non-obvious way.

Sansa Connect and Creative ZVM use only single front framebuffer.
Place TTB at DRAM end to minimize memory loss due to alignment.
Reserve as little as possible memory for the LCD frames.
On Sansa Connect this change extends audio buffer by 858 KiB.

Change-Id: I21bdeec4cfba86d71803a39acd651a87e73767e6
2021-07-09 09:24:38 +00:00
James Buren
a9f36efa62 file/fat: rework utime function as modtime extension
This eliminates the dependence on a special struct since we were only
using the modtime anyway. But it no longer fits any known standard APIs
so I have converted it to our own extension instead. This can still be
adapted to existing hosted APIs if the need arises.

Change-Id: Ic8800698ddfd3a1a48b7cf921c0d0f865302d034
2021-07-08 17:47:51 +00:00
Solomon Peachy
a0f1236e88 Fix yellow in android builds.
Change-Id: Ic22908e249f2db85c029e1644c9531a12ed87993
2021-07-08 13:06:41 -04:00
Aidan MacDonald
0e1a90ea1d x1000: SPL refactoring
This streamlines the boot code a bit and reduces target specific
boilerplate. The clock init hack used by the bootloader has been
"standardized" and works for the main Rockbox binary now, so you
can boot rockbox.bin over USB without special hacks.

Change-Id: I7c1fac37df5a45873583ce6818eaedb9f71a782b
2021-07-08 16:01:38 +00:00
Aidan MacDonald
65aa9ce570 x1000: more CPM register definitions
Change-Id: Ie6fa343a65a6bd19e578664b10bac771289ed0b3
2021-07-08 16:01:38 +00:00
Solomon Peachy
39b82afb45 Fix warnings introduced in c174d3a5 (redux)
Change-Id: Icc871bd9875aa0d092a4fba3e8a6c3a598053854
2021-07-08 14:16:25 +00:00
Solomon Peachy
78eb87f453 Revert "Hosted & tool builds need utime.h"
This reverts commit a8fd590003.

Reason for revert: Inverted polarity and it didn't work anyway.

Change-Id: Ife548ce4608405e3243c84a1d72090603fd2decc
2021-07-08 14:07:58 +00:00
Solomon Peachy
a8fd590003 Hosted & tool builds need utime.h
Should fix the warnings introduced in c174d3a5

Change-Id: Ib4bd863caef4dedf28dadab8b58b9a165ed4ef9b
2021-07-08 13:55:12 +00:00
James Buren
c174d3a544 file/fat: add utime function
This emulates the traditional utime function from UNIX clones to allow
for manual updates of the modification timestamp on files and directories.

This should only prove useful for non-native targets as those usually
have a libc version of utime.

Change-Id: Iea8a1d328e78b92c400d3354ee80689c7cf53af8
2021-07-08 13:15:30 +00:00
James Buren
49ca4b3e5e timefuncs: add dostime_localtime function
This does the opposite of dostime_mktime, converting time_t back to
the two dos date time values. We use gmtime_r for native because that
is what is available and acts the same as localtime_r on other platforms
with a regular libc available.

Change-Id: If79469d0aae2d7c5dcdd905fbf04963669aa1138
2021-07-07 17:31:00 +00:00
Tomasz Moń
bce6771730
Sansa Connect: Reduce USB RX buffers from 129 to 2
Reducing number of fake RX buffers saves a bit more than 127 KiB RAM.
Fix compilation with CPPI logging enabled.

Change-Id: If1ad3a6fc251e284caaac78c2406a58f3d6547bb
2021-07-07 18:48:24 +02:00
Tomasz Moń
99bf506407 Sansa Connect: Prevent unresponsive interface
AVR interrupt signal can remain active if the state has changed during
state read. In such case, there won't be intterupt and the interface
would appear unresponsive until AVR thread received event (e.g. USB
connection/disconnect). Solve the issue by not waiting for event if AVR
interrupt signal is active prior to event wait.

Change-Id: I86e388c7cd6da76e3abe7bf7114940f331e4c308
2021-07-07 14:51:15 +00:00
Solomon Peachy
e9ae1e9a8b Fix red introduced in 841e704fc3
Change-Id: I5a924f77231a4764f3ad9b196875f5bf073945d6
2021-07-07 13:49:24 +00:00
Tomasz Moń
841e704fc3
Sansa Connect: Read HDQ battery data
Make it possible for target to provide voltage, percentage and time to
empty values. The voltage measurement is nice to have in debug menu even
if the actions are taken only based on percentage. Perform battery level
estimation based on voltage only if percentage is not available.

Use time to empty based on actual power consumption. This makes the
estimated runtime displayed in Rockbox Info to react to backlight
setting. The bq27000 updates time to empty estimate every 5.12 seconds
so it is possible to see the estimate with backlight off on the screen
if user enters Rockbox Info, activates hold switch, waits 11 seconds and
releases the hold switch.

Change-Id: Iafe3fa0fb334e3428e3a0ad05b2c020d208dc934
2021-07-07 08:24:01 +02:00
James Buren
b87e75f768 zip: import initial module
This provides rudimentary support for parsing the contents of a ZIP
file. For now this just supports uncompressed file entries but DEFLATE
support is planned. This also only implements a low level public API
so more work will be needed to make it usable by application code.

Change-Id: Ia68b3078e5276666a0e5023f4bc7a9f94272738a
2021-07-05 19:30:05 +00:00
Tomasz Moń
2acf8db3e1
Sansa Connect: Power off LCD to save power
Prevent startup screen flash by properly using AVR LCM functions. Power
off LCD when not needed to improve battery runtime.

Change-Id: I76e3c5c0208774f189fbc6f7d7b3c9e22c062285
2021-07-05 15:19:52 +02:00
Tomasz Moń
89d3ca77b6
Sansa Connect: Fix power off panic screen
Queue power off requests because power_off() can be called within tick
context that must not acquire mutex.

Change-Id: I6f1a8f81d15518876cd03556118fc9eb37b8175f
2021-07-04 13:08:42 +02:00
Tomasz Moń
e11fa5f74e Sansa Connect: Initial libertas WiFi driver port
Import non-free firmware image from linux-firmware package.

Firmware loading works but is disabled at compile time because just
loading firmware without configuring device results in higher power
consumption without any benefit to end user.

Change-Id: I8fd252c49385ede1ea4e0f9b1e29adeb331ab8ae
2021-07-04 07:41:44 +00:00
James Buren
c9f2308a1d fat: move fattime_mktime to timefuncs
This moves the time conversion function to timefuncs since it has
uses on ports that don't use the FAT driver. This function has no
dependency on the FAT driver as it is so this should not cause any
issues. To reflect this separation the function was renamed to
dostime_mktime since it is really for DOS timestamps. The places
where it was used have also been updated.

Change-Id: Id98b1448d5c6fcda286846e1d2c736db682bfb52
2021-07-03 00:19:58 +00:00
Aidan MacDonald
9f950d8bbf x1000: NAND rewrite
This new design saves on binary size and stack usage. The API is
also block- and page-based, requiring awareness of the chip layout
to use properly. Out-of-band areas are also exposed for reading
and writing.

The byte-oriented routines are kept for compatibility with the
existing installer and SPL.

Change-Id: Iaacc694d2f651ab74d45330e0434ee778a0d91bc
2021-06-27 19:09:03 +01:00
Tomasz Moń
3c7c71030f
Sansa Connect: Ensure adequate AVR Slave Select delay
Waiting 10 us between selecting slave and transmitting data on SPI
resolves spurious startup glitches.

Cache last read monotime value as it can differ from the first one.

Change-Id: Ia6ac5696f6ee2bc3c6a8be27e33aaddd9ff4ce2a
2021-06-27 13:32:20 +02:00
Tomasz Moń
1b81bd8a61
Sansa Connect: Discard invalid monotime reads
Read monotime twice in a row and only accept the value if it matches or
the two reads are 1 second apart.

Change-Id: Ibd289103a20404dd1b2bbd131fdfa8905852c788
2021-06-27 13:14:11 +02:00
Tomasz Moń
a4ab636423
Sansa Connect: More reliable AVR communication
AVR requires bigger delays between retries. Read state instead of
version for synchronization purposes as it shifts more bytes.

Change-Id: Ib7fa980496d3bc7744a086b45e1865861ef58b88
2021-06-27 12:20:56 +02:00
Tomasz Moń
ead4bc0769
Sansa Connect: Retry AVR commands only 3 times
If the commands repeatedly fail it is likely that the AVR is not
programmed. In such case simply continue normal operation. This is
especially important in bootloader as it makes it possible to load new
rockbox build using bootloader USB mode. Otherwise, the only recovery
option would be to use I2C serial.

Change-Id: I4b0999833e9a906ec6353bdfdd5b68211f07ac81
2021-06-25 18:30:11 +02:00
Tomasz Moń
3738510953
Sansa Connect: Implement RTC functionality
Use 32-bit monotime AVR counter for time tracking. Set the time by
adding fixed offset to the counter value. Store the offset in rockbox
directory to make it persistent between reboots.

Do not implement alarm functionality as wakeup is only possible from
sleep and not from complete power off.

Change-Id: I615c7eb4df8ab0619dcbfcff107bc7051a15aace
2021-06-25 16:12:06 +02:00
Tomasz Moń
635ec5bbbd Sansa Connect: Manually drive SPI Slave Select
Keep Slave Select active during command transmission. This relaxes
timing requirements on the AVR side.

Change-Id: Ia1a6cf45aba3c11f6aeaa7441c6793807ca827f0
2021-06-25 14:10:15 +00: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
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