Commit Graph

11211 Commits

Author SHA1 Message Date
Solomon Peachy 5e663f0420 xduoox3ii: Ignore the remote events when headphones aren't plugged in
This prevents the actual insertion/removal from triggering false events

Change-Id: I54114ce903e110c31eca6b2ce258a0cf5f6b782b
2021-11-03 13:16:40 -04:00
William Wilgus 684565b8f3 USB fix red for device without HAVE_USB_POWER again.
Change-Id: I3122d532cbb8d5b5cb9040f08707c1514bc1b18e
2021-10-31 21:36:21 -04:00
William Wilgus d72a0ed65d Use USB events for storing plugin_menu state
use usb connected callback to cancel menu reentry after USB plug/unplug

Change-Id: I8267deed6e8ada94ca527392f56f50ef22def1d7
2021-10-31 12:42:24 -04:00
William Wilgus 7a6737f471 USB Events fix red on devices without HAVE_USB_POWER
Change-Id: I112e6379d4bed019d7e047e5802f104e250d926e
2021-10-31 12:30:27 -04:00
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 0f68866ae5 fiiom3k: bump power on delay to 200ms
Needed due to a report that 80ms was not working.

Change-Id: I5f0f750b0530f5b84ffba58c5d7ff8b283095c4b
2021-10-18 23:03:04 +01:00
Aidan MacDonald 957add9d75 fiiom3k: adjust power on delay to 80ms
OST timer fix (7a5130a277) causes a boot failure on some units,
the battery voltage reading needs more time to stabilize.

Change-Id: Ic4a9ba90a16fab8ac6d27dbbe7af381f7c810f8f
2021-10-18 21:45:03 +01:00
Dana Conrad 6253cdebed ErosQNative: Fix mdelay calls due to g3859
The battery stabilization delay call seems to need to be
about 170 at minimum now, let's do 190 for safety (+20ms).

Change-Id: Ifd0248891abe827dfcc3e6baf48cc5bef0d0cc1c
2021-10-16 16:58:19 -04:00
Aidan MacDonald 7a5130a277 x1000: fix broken OST2 timer prescaler
It turns out the prescaler fields in OST_CTRL are 2 bits wide,
not 3. The programming manual (as usual) is ambiguous and its
diagram shows 2-bit wide fields, but the bit positions in the
text give a 3-bit wide field. Ingenic's Linux code and my own
testing shows that they are, in fact, 2 bits wide.

This caused the OST2 divisor to be 16 instead of 4; the OST1
divisor was correct. This means that all udelay/mdelay calls
took 4x longer than they should've. After this change the OST2
prescaler will be 4, as intended, and udelay/mdelay calls will
wait for the intended duration.

Change-Id: I2ac0a9190f49b59a840c649bf586131f5f9fde82
2021-10-16 16:58:19 -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 24294bda15 usb: ensure RX buffers are a multiple of the packet size
When performing an OUT transfer which is not a multiple of the
max packet size, the last packet of the OUT transfer should be
a short packet. However, there's no guarantee the host sends
the expected amount of data in the final packet.

The DWC2 USB controller handles this case by accepting any size
packet and copying it out to memory. So if the packet is bigger
than expected, it'll overrun the caller's buffer and Bad Things
will happen.

The USB 2.0 spec seems to endorse this behavior. Section 8.5.1
says "an ACK handshake indicates the endpoint has space for a
wMaxPacketSize data payload." So it is possible that other USB
controllers share the DWC2's behavior.

The simplest solution is to force all USB RX buffers to be big
enough to hold the transfer size, rounded up to a multiple of
the max packet size. For example, a transfer of 700 bytes would
require a 1024-byte buffer if the MPS = 512 bytes.

Change-Id: Ibb84d2b2d53aec8800a3a7c2449f7a17480acbcf
2021-10-16 21:14:42 +01:00
Aidan MacDonald a665c1faad usb: remove dead code in usb_storage driver
Change-Id: Id6fc3520dad1adace33fd1014288ccb4cf5818af
2021-10-16 21:14:42 +01:00
Aidan MacDonald 988f244c74 usb: port usb_storage control request handling to new API
Change-Id: I1a19e09fdc0f05473d53c39bab0761d5cb8f6ff0
2021-10-16 21:14:42 +01:00
Aidan MacDonald 1b2cc053d3 usb: port usb_hid control request handling to new API
Change-Id: I9028cf06e91c9fcbe271f6ad81d6b252cb4e7cec
2021-10-16 21:14:42 +01:00
Aidan MacDonald 3318ba4795 usb: port usb_serial control requests handling to new API
Change-Id: I1405c9279e0e8e490e2bb2d03ff192b36db2634b
2021-10-16 21:14:42 +01:00
Aidan MacDonald 77731c3579 usb: port usb_core control request handling to new API
Change-Id: I3850c9cfcb87831e56884c83e31f728590b76f83
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 dff8320a5d usb: add request data argument to all control request handlers
Change-Id: I237143fa0d95c914b8e25ed22f8acde96ec00551
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
Dana Conrad e0468074fe ErosQNative: Remove duplicate play_last_sample() call
My brain dun goofed, oops

Change-Id: Ifd57310f3ba105cdc37c4342691cbc589a492310
2021-10-06 17:36:53 -05: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 4be81c2385 x1000: tweak USB fifo sizes
The old sizes limited the number of usable endpoints and were
unnecessarily large.

Change-Id: Ia17d3b62ecc40c8ca289d78f2275c7842c09deed
2021-10-06 22:40:52 +01:00
Dana Conrad 67d4da5342 ErosQNative: Initialize AIC FIFO to -1
Write -1 to AIC_DR to initialize the "last sample"
to -1 in order to prevent power-on clicks.

It appears necessary to completely fill the FIFO,
otherwise I was able to get a click out of it, however
uncommon it was.

Not only does this prevent a click when first
playing a song after power-on, but it also seems to prevent
any click at all when powering on - previously, a small
click may have been heard when first booting.

Change-Id: I2b81c2fa6af9809ef1c354d7a08ca8f9893a7690
2021-10-06 17:31:30 -04:00
Aidan MacDonald 465c216636 Fix includes in usb_class_driver.h
Change-Id: I602ec80d02b5f4f586386026a6312d048fa7dac3
2021-10-06 21:31:42 +01:00
Aidan MacDonald 3ae6fbc600 x1000: default to sending 0 samples on underflow
Previously it used the last sample, which turns out to be broken.
The AIC appears to send out a random non-zero sample continously
after boot -- probably because the last sample is uninitialized by
the hardware. Disabling playback is supposed to make it send zero
samples irregardless of the LSMP bit according to the docs, but it
doesn't seem to work this way.

- Change eliminates the white noise heard on the M3K after boot.
- Change has no adverse effects on the Q1.
- Leave Eros Q on the old setting since sending zeros exacerbates
  clicking due to DAC's automute feature.

Change-Id: I9996793fc34f4475b19700d076b11505353b3836
2021-10-05 12:46:01 +01:00
Aidan MacDonald fd568d90a4 m3k: don't use mixer controls for volume control
According to a forum user, there's an audible click when changing
the volume between -32 and -32.5 dB with some headphones. Fix this
by not (ab)using the DAC digital mixer for volume control.

The mixer only provides an extra -6 dB of hardware volume range,
so the only side effect is that software volume will now kick in
at -32 dB instead of -38 dB.

Change-Id: If24d9bc0058eff3c1a29aefb155a2e378522623c
2021-10-05 12:46:00 +01:00
William Wilgus 7c67a48332 Sansa E200v1 Bootloader attempt at enabling USB in boot loader
there is a 1MB free region that is used to load the firmware but we
shouldn't need that till after a USB connection

so here is my 2nd try

Change-Id: I2552db3a7fba019d7e7188984432f758ddafe548
2021-10-04 10:56:33 -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
William Wilgus a62fdf4751 scroll engine, allow clipped text in viewport
loosen the requirements on the scroll viewport allow clipped text

Change-Id: I7099d423ccfbd7bae12e6ba43b8a6b4b864175b7
2021-10-02 10:31:04 -04: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
William Wilgus 95b10ac74e Add ability to dump cpu boost log to disk, include thread names
0.) B 0 /rockbox/apps/main.c:405
1.) B 1 /rockbox/firmware/kernel/thread.c thread[dircache]:1508
2.) B 2 /rockbox/apps/tagcache.c:4772
3.) U 3 /rockbox/apps/tagcache.c:4793

add logic to show count after log rolls over
clean-up

Change-Id: Ibda0a56e5d8d89aa8b7649f4f9fa64eb1ff0e08f
2021-09-30 21:13:22 -04:00
William Wilgus b662ff945a Bugfix AS3525 usb driver unboosted the cpu without first boosting it
Change-Id: Id2d45870a9128b19ace0e8d5c16d3b3fa4b923dd
2021-09-29 01:17:45 -04:00
Dana Conrad 6d98c9e6b2 ErosQ Native: Adjust battery % scale
Adjust the battery scale to be a little better. I've set
the 100% (discharge) point to be where the battery sags to
when it is done charging but still plugged in.

Not quite sure how best to set the charge scale, it's just
equal to the discharge scale for now.

Change-Id: I9a2730c0b2051300af9eeddb4f67164f38a29002
2021-09-26 18:27:53 -04:00
Solomon Peachy 38b2648f48 win32: Add a stub for os_modtime() to make sim builds happy
Change-Id: Iea90776df2a92777c8e07c5a6b6635b6734d6690
2021-09-26 09:31:58 -04: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
Aidan MacDonald 99f333c64f usb_hid: fix accidental fallthrough
Successful SET REPORT requests would spuriously fail because of the
fall through to GET REPORT.

Change-Id: I8e7d1a1120afc6975d07d47b11c12c9e9ca51dd2
2021-09-20 17:38:56 -04: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
Christian Soffke 67c4231e34 iPod mini backlight initialization
Fixes backlight not turning on after booting (tested on an iPod Mini 2G).

backlight_hw_init() copied from iPod 4G.

Change-Id: I9c32ca5ecd3dc74ea997e6cb843da79d303b0615
2021-09-12 13:35:35 -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
William Wilgus cab8cea0f0 lcd_putsxyofs 16 bit lcd_mono_bitmap_part [AS] part duex
'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

second try places the check above the negative y offset
this was causing glitches on the Q1 and likely other TS targets
since a negative y was added to height it made it < CHAR_BIT setting
stride = 0 even though the bitmap was >= CHAR_BIT high

Change-Id: I13bb8ab472c2ae61302a6de5d9e2c78243354460
2021-08-26 20:19:26 +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
William Wilgus dbd051394e Revert "lcd_putsxyofs 16 bit lcd_mono_bitmap_part [AS]"
This reverts commit 49edfc237b.

Reason for revert: font rendering bug, https://gist.github.com/amachronic/5fa75da280432127de4b44ee2d760281

Change-Id: I13b5f0eedb2926bce67051c8f0bb2ae5dea9f299
2021-08-25 13:05:02 +00:00
Aidan MacDonald 4cbb5b4201 x1000: trigger the virtual LED on disk activity
Change-Id: Ic129e79e0b192cb0c39e5f05ad602e0ea7a9213f
2021-08-18 23:17:07 +01: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 cc6b036ef5 logf: Fix an incorrect fix in 835d0c737a
Change-Id: I060033d9a7cd54bab75e4f82e3de002bdb027af2
2021-08-15 09:03:16 -04:00
Solomon Peachy 25cebf2f85 Fix red from 04fe77a4
Change-Id: I13a7b067e60eabe27be1fe983a7cced3ae8b18e3
2021-08-14 17:56:15 -04: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