Commit Graph

3359 Commits

Author SHA1 Message Date
William Wilgus 894a9d9063 USB add Insertion and Extraction callback events
We have this nice event library laying around probably a few more places
we could use event callbacks

Change-Id: I9180fa9d78788d161f2587110644ca3e08df6f50
2021-10-31 12:02:38 -04:00
Aidan MacDonald d085d01f5e x1000: enable DMA for USB driver
This boosts USB transfer performance a bit, ~10% for reads and
~25% for writes, for large-ish file transfers. Rockbox is still
around 33-50% slower than the OF.

Change-Id: I236a1e5c69a290c47ed27b70cb2631111fc157ed
2021-10-16 21:14:42 +01:00
Aidan MacDonald 4fc37eb47f usb-designware: port to new USB API
List of all platforms using this driver:

- Sansa Clip+ (tested, works)
- Sansa Clip v2 (untested)
- Sansa Clip Zip (tested, works)
- Sansa Fuze v2 (untested)
- iPod 6G (untested)
- iPod Nano 2G (untested)
- FiiO M3K (tested, works)
- Shanling Q1 (tested, works)
- Eros Q (tested, works)

Change-Id: I403ec64b030ea38f22cb52b31865639a78cd11e4
2021-10-16 21:14:42 +01:00
Aidan MacDonald 82efb1150e usb: implement new API with legacy emulation layer
All existing USB drivers now define USB_LEGACY_CONTROL_API to
enable the emulation layer.

Control request handlers will be ported in follow-up commits.

Change-Id: I4be1ce7c372f2f6fee5978a4858c841b72e77405
2021-10-16 21:14:42 +01:00
Aidan MacDonald b69d43c247 usb: give USB transfer completion events two data pointers
Change-Id: I036cc7f02c2f86a364d2dba59493a6aa893f2c16
2021-10-16 21:14:42 +01:00
Aidan MacDonald ec164c389c usb: introduce new control request API
Change-Id: I6545d8985ab683c026f28f6a7c0e23b40d0a6506
2021-10-16 15:58:43 -04:00
James Buren c0a59b9a6a usbstack: Revise usb string descriptor table to use enum values for indices
This makes it possible for macros of conditionally included string
descriptors to get a correct index no matter what other usb drivers
are enabled or disabled due to the nature behavior of enums.

Change-Id: I8ccebbd316605bed0f5d90b6b73fab4a333c02fa
2021-10-06 17:59:17 -04:00
Aidan MacDonald 75524a7eec Shanling Q1: default to USB force charging
Force charging must be set or the Q1 will not draw 500 mA from
an AC adapter (see 0ca0940f01).

Change-Id: I4ec6dc7728a5aa4d7f07580556efb960948c24a8
2021-10-02 16:14:17 +01:00
Aidan MacDonald 3a89fdee96 x1000: fix hang that may occur in USB mode
Upon getting a USB reset, the USB core will update charging
current by calling usb_charging_maxcurrent_change(). On all
current X1000 targets this may cause a hang, since changing
the charge current involves a blocking I2C transaction.

Eg. if the host issues a reset when we're already configured
as part of error recovery, the change from 500 mA -> 100 mA
will cause a hang.

Change-Id: I5b45272c01fa16b179ae3d16bbc50c7fab9a416b
2021-10-02 15:09:46 +01:00
Aidan MacDonald 672bbe434b usb: rename usb_drv_recv() to usb_recv_recv_nonblocking()
IMHO the current name is somewhat misleading:

- usb_drv_send() is blocking and we have usb_drv_send_nonblocking()
  for the non-blocking case. This inconsistent naming can only
  promote confusion. (And what would we call a blocking receive?)

- Other hardware abstraction APIs in Rockbox are usually blocking:
  storage, LCD, backlight, audio... in other words, blocking is the
  default expected behavior, with non-blocking calls being a rarity.

Change-Id: I05b41088d09eab582697674f4f06fdca0c8950af
2021-09-20 22:41:29 +01:00
Dana Conrad 0ca0940f01 Make USB Charging default value configurable per device
A reasonable default assumption for a user
would be that they can plug their device into
a USB AC adapter and it will charge with as much
current as it reasonably can. With the previous
default, an AC adapter will only do 100mA, basically
a trickle charge.

Make this configurable default per-device, so as not
to break old devices without testing.

Define TARGET_USB_CHARGING_DEFAULT to USB_CHARGING_FORCE
to use the new default.

Tested on both erosQ Native and M3K.

Change-Id: I77265d356a41d67357ebc6e9f7e0c25a37b74931
2021-09-19 21:13:09 -04:00
James D. Smith 760277e096 Dir cache: Fix resume of relative path playlists.
Slightly modified from original patch by Fabrice Bellard.

Change-Id: I9ae04fa460f0f1b9c616e6f99505d4c5d4358f68
2021-09-19 21:05:58 -04:00
Dana Conrad 17263a813b ErosQ (both): avoid clipping due to DC offset bandaid
Set the maximum volume on both hosted and native ports
to -2 dB.

Verified behavior here on native and by borkitall on irc
for hosted.

Change-Id: I3aebc2bb4b9294a4137a33694c83139c0d76099a
2021-09-05 15:50:21 +00:00
Solomon Peachy b2386405b9 xduoox3: Disable bootloader USB mode entirely
It's not yet working and because all storage is removable (and the OF
works fine) it's of limited utility aynway.

Change-Id: I8a6a59ac16503d0f4574c3934f473cac54e86858
2021-08-26 11:59:01 -04:00
Aidan MacDonald 5a4cc8da3f Drop HAVE_RTC_RAM
Only Archos players ever used this feature and it isn't implemented
on any current targets.

Change-Id: I39c8455480a3fe33cd25b667e8d4d6ff3a092d3e
2021-08-15 20:41:58 +01:00
Solomon Peachy 04fe77a465 Remove the (very) incomplete port for the Tatung TPJ-1102
It was barely even a stub, and hasn't seen any development since 2009

Change-Id: I0aa15d9a7b90ae8c771924d9f401380d4cc0fab9
2021-08-14 16:29:39 -04:00
Aidan MacDonald 786d06742a Remove Samsung YP-Z5 port
It has only a couple GB of onboard flash storage with no storage
driver in Rockbox. It hasn't seen any meaningful development since
its initial commit, it's not on the build farm, and the bootloader
build is broken by other refactoring.

Change-Id: Idd9e3c46fac9b96f416ce444182f97a50770e747
2021-08-14 14:13:54 +01:00
Dana Conrad 6de6e1459d Eros Q Hosted: Apply DC Bias to PCM Data
Similar to the native port, the hosted port benefits from
adding a -1 dc bias to the PCM data. This prevents almost
all clicking artifacts.

Change-Id: Ic6378716774b6d88df23c476e2ef54d49f33dc72
2021-08-12 10:07:49 +00:00
Solomon Peachy 39fff5cb53 move PCM_NATIVE_BITDEPTH definiton into global config code
Change-Id: I391bcffca670916c2c88426e2ba2603351326cee
2021-08-07 11:18:19 -04:00
Dana Conrad 56b0dde545 Higher bitdepth software volume scaling
Operates between 0 and -74 dB (mute) without issue

Change-Id: I497e002bd8db43833a09ebbc29212fbb6cc8ebfd
2021-08-07 14:21:47 +00:00
Dana Conrad 16b0098256 ErosQ Native: Add DC Offset to PCM data
A small negative offset seems to silence all
play/pause clicking on the PCM5102A.

Also adding PCM soft muting, and muting the headphone amp
when the headphones are detected as removed. This has been
tested to not cause any unintended side effects on the
line out.

Also confirmed the numerical dB values are (approx.) correct.

Change-Id: I689d68887c86add9cc5e0ccb0c7de01aaa69b4d9
2021-08-07 14:21:47 +00:00
Solomon Peachy 835d0c737a logf: Fix two issues with logf_panic_dump()
* It had a (read) buffer overflow when dumping the stuff on the back half of the buffer
 * a highly questionable code construct was nuked

Change-Id: I7f6f119524fc2095f788fc9b3d356459955d3ace
2021-08-06 10:08:00 -04:00
Aidan MacDonald e532714d1f pcm: Remove unused function pcm_play_dma_get_peak_buffer()
Change-Id: Ifd20fb14a22489cdb99154c01f69809a1e70d0c5
2021-07-25 14:07:41 +00: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
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
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ń 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
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
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ń 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
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ń 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ń 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
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ń 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ń 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
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 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 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
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