Commit graph

3898 commits

Author SHA1 Message Date
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
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
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
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
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
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
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ń
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
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
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
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
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
Moshe Piekarski
b895fb6643 Add tm->yday to RTC ports missing it
Change-Id: I86882262bafb8d06f925aabb87ebd1b5dcb0cd53
2021-05-12 10:52:03 +00:00
Solomon Peachy
7d0d32dbc6 Nuke the never-functional iriver ifp-7xx port
It never worked, and hasn't compiled in something like a decade, Given
the HW capabilities (limited onboard flash, no expandability) there's
really no point in trying to fix/complete it.

Change-Id: I7d175089840396f8891645bd10010d730dd5bfdc
2021-04-26 07:42:58 -04:00
Solomon Peachy
3ba2f6e5c7 Nuke all TCC77x targets: iAudio 7, Sansa C100, M200(v1-3), Logik DAX
They were never finished, never saw any release ever, and haven't
compiled for the better part of a decade.  Given their HW capabilities [1],
they are not worth trying to fix.

[1] 1-2MB RAM, ~256MB onboard flash, no expandability

Change-Id: I7b2a5806d687114c22156bb0458d4a10a9734190
2021-04-26 07:41:51 -04:00
Aidan MacDonald
c71a47f649 Move usb-designware out of ARM target tree
Change-Id: Ic981737976655596ea622b7b4d15a2d841bd993d
2021-04-18 18:45:28 +01:00
James Buren
448f98d9c0 pp: fix adc mistake where base 10 was used instead of base 16
Change-Id: I8562af8a11a22cd9edec149b2519ac0205d2b2dc
2021-04-10 01:13:09 +00:00
Solomon Peachy
afec380a0d gigabeats: Fix hang on startup caused by a stack overflow
headphone ADC thread stack was slightly too small.  Bump it up a bit.

(it was _perfectly_ sized for the prior older toolchain+optimization flags...)

Change-Id: I2ca67c2b85c54f879892a31e281d7696f893389c
2021-04-01 20:24:59 -04:00
Solomon Peachy
2f785c7797 PP: More cache invalidation fixes
Take into account the size of the pointer in the loop termination
condition.

Change-Id: Ib4f7625ef143149a0d691a2109bad67aece6241c
2021-04-01 10:57:29 -04:00
Solomon Peachy
9f7f1a841a PP: Use CURRENT_CORE instead of IF_COP_CORE(CPU)
Use of IF_COP_CORE was mistakenly introduced as part of 89acde6af2,
effectively short-circuiting multiple tests resulting in the code
paths always being executed, on both cores.

Use the correct macro, so per-CPU paths are handled properly.

Change-Id: Id346cf759fc1b06b7d56694d7af1f469caf785a4
2021-04-01 08:45:43 -04:00
William Wilgus
89acde6af2 H10 PP Crash -- Fixed
This appears to finally fix the issue
turns out the status register we were writing was only for the CPU
COP cache flush wiped out the CPU cache
--

Added some defines to cut down on the magic numbers
Added some comments explaining such

Set the address to full 20 bit address
0x1FFFFF which is then left shifted 11 internally --  somewhere around 4GB?

Link explains the cache status bits
https://daniel.haxx.se/sansa/memory_controller.txt

Change-Id: I57b7187c2f71a5b54ce145bf3a21ed492a8993cb
2021-04-01 00:52:57 -04:00
Solomon Peachy
83fcbedc65 rk27xx: Take advantage of STORAGE_NEEDS_BOUNCE_BUFFER
(And get rid of its custom realignment code)

Change-Id: Iff27d717b870d3db239310421776744ea6863373
2021-03-27 17:18:21 -04:00
Christian Soffke
7d7850368e Disable UDMA 2 on iPod4G target
ATA DMA was enabled for all PP502x targets in d118f47 after previously reported instabilities were thought to have been fixed. The iPod 4G target remains unstable when UDMA 2 is enabled. File system corruption will eventually occur even using stock hardware in normal usage, according to both my own experience and that of several other forum users. UDMA 1 appears to be stable.

Change-Id: I8526bad9e879f5dad5174cfe07cd8828d8b72406
2021-02-27 14:38:49 +00:00
Solomon Peachy
a5961c944b FS#5320: Keypad hold doesn't let go until scrolling is used (ipod 4g/5g)
Patch by Boris Gjenero

Change-Id: I7df956fb63478bbbe891104faf5ab35096da7576
2020-11-29 08:51:37 -05:00
Solomon Peachy
388adff3cc pcm: Further cleanup of unused bits of the PCM ACPI:
* pcm_get_bytes_remaining()
 * pcm_calculate_peaks()
 * pcm_get_peak_buffer()

Nothing in-tree uses these at all (except for the lua plugin wrapper)

Change-Id: I971b7beed6760250c8b1ce58f401a601e1e2d585
2020-11-12 15:59:09 +00:00
Moshe Piekarski
c4254d10fc Fuze+: Fix misplaced rectangle when lcd_flip set
Change-Id: Ic5197d8dffd66cfefdb42242869b48b33aa4d042
2020-11-08 03:19:04 +00:00
Torne Wuff
5db83c155a pp5020: use ipod firmware timings for ATA PIO.
Some mSATA adapters seem to have trouble working with Rockbox using our
normal PIO timings; the timing value we use is probably out of spec and
is different to the OF. Switch to using the OF's timings according to
which PIO mode we select. This may not completely resolve problems with
these adapters but allows Rockbox to boot and play audio.

Change-Id: If73210700eb4af01864b373709ee1d15c775fb11
2020-11-04 03:03:19 +00:00
Solomon Peachy
fe2d52cc7d pcm: Get rid of pcm_play_pause() and associated APIs
Nothing in the core has used it for some time.  It's exported to the
plugin API but the last plugins to use it were switched to the mixer API
back in 2011.

This allows us to get rid of pcm_play_dma_pause() from all audio drivers

Change-Id: Ic3fa02592316f84963e41d792d1cabb436d1ff6b
2020-10-31 01:18:27 +00:00
William Wilgus
299c237075 'Fix RED e200 Framebuffer_viewport_rewrite
Free malloc in checkwps too

Change-Id: I2b8fcbc94beb0644b643d3b7a9cb53bc26fc8a51
2020-10-26 15:50:42 -04:00
William Wilgus
3237ae4a4f LCD core move buf ptr and address look up function viewport struct
I'm currently running up against the limitations of the lcd_draw functions
I want these functions to be able to be used on any size buffer not
just buffers with a stride matching the underlying device

[DONE] allow the framebuffer to be decoupled from the device framebuffer
[DONE need examples] allow for some simple blit like transformations
[DONE] remove the device framebuffer from the plugin api
[DONE}ditto remote framebuffer
[DONE] remove _viewport_get_framebuffer you can call struct *vp = lcd_set_viewport(NULL) and vp->buffer->fb_ptr

while remote lcds may compile (and work in the sim) its not been tested on targets

[FIXED] backdrops need work to be screen agnostic

[FIXED] screen statusbar is not being combined into the main viewport correctly yet

[FIXED] screen elements are displayed incorrectly  after switch to void*

[FIXED] core didn't restore proper viewport on splash etc.

[NEEDS TESTING] remote lcd garbled data

[FIXED] osd lib garbled screen on bmp_part

[FIXED] grey_set_vp needs to return old viewport like lcd_set_viewport

[FIXED] Viewport update now handles viewports with differing buffers/strides by copying to the main buffer

[FIXED] splash on top of WPS leaves old framebuffer data (doesn't redraw)
[UPDATE] refined this a bit more to have clear_viewport set the clean bit and have skin_render do its own screen clear
scrolling viewports no longer trigger wps refresh
also fixed a bug where guisyncyesno was displaying and then disappearing

[ADDED!] New LCD macros that allow you to create properly size frame buffers in you desired size without wasting bytes
(LCD_ and LCD_REMOTE_)
LCD_STRIDE(w, h) same as STRIDE_MAIN
LCD_FBSTRIDE(w, h) returns target specific stride for a buffer W x H
LCD_NBELEMS(w, h) returns the number of fb_data sized elemenst needed for a buffer W x H
LCD_NATIVE_STRIDE(s) conversion between rockbox native vertical and lcd native stride (2bitH)
test_viewports.c has an example of usage

[FIXED!!] 2bit targets don't respect non-native strides
[FIXED] Few define snags

Change-Id: I0d04c3834e464eca84a5a715743a297a0cefd0af
2020-10-26 12:28:48 -04:00
Solomon Peachy
19d45c9257 Work around wonky inline asm issue with creativezenvm build.
The right thing here probably to just not bother at all, as this
bootloader can't launch rockbox yet anyway.

Change-Id: I62bd22353b6adc9dbe35b94f3b60a6a67348356a
2020-10-13 21:48:23 -04:00
Solomon Peachy
26bebd77ab Fix more red.
Change-Id: Id1a45b420f8eb70a25010b058822b78f80db33d8
2020-10-13 19:45:03 -04:00
Solomon Peachy
09785a8499 fix more yellow
Change-Id: I74bad58707d05ea167169d4315c05eb0cd1c8b7b
2020-10-13 17:23:56 -04:00
Solomon Peachy
b94db707fb Fix more warnings.
Change-Id: Ib3a9fc622a46b1fc72e94dcbc6d29d2e430cd81b
2020-10-13 15:48:31 -04:00