Commit graph

11226 commits

Author SHA1 Message Date
Aidan MacDonald
44acbc6629 Shanling Q1: enable multi-touch reporting
The FT6x06 driver used for the Shanling Q1's touchscreen
has been extended to report more than one touch point. It
can also return the gesture detected by the controller,
but this doesn't seem to report anything useful on the Q1.

Multi-touch is only useful in 3x3 grid mode since the Rockbox
button API cannot report more than one touch point.

The FiiO M3K uses the same driver so it's been updated to the
multi-touch API, but functionality is unchanged.

Change-Id: I4de42f44808d6eb902e3da212d8f936b7a5042c7
2021-11-24 18:49:03 -05:00
Solomon Peachy
3d07ec46ee jz47x0: Minor code quality improvements in the jz47xx USB drivers
* Replace magic nubmers with #defined constant
 * Tweak some logf messages

No functional changes!

Change-Id: I6a5e4c371a471197a8edbb853967e461621d73f8
2021-11-22 08:08:12 -05:00
Aidan MacDonald
bff63a4f90 touchscreen: change odd sentinel value for time of last touch
Using tick 0xffff does not make any sense, use -1 instead.

Change-Id: Id574eb35418c6713c4fc91ed539aadc42fd29aa5
2021-11-21 20:26:20 +00:00
Aidan MacDonald
ad66c3b807 touchscreen: use repeat acceleration for button input
Touch devices have physical buttons too, and these should be
subject to repeat acceleration. That feature was disabled for
the sake of better touch event responsiveness (apparently).

So, re-enable the acceleration feature & add a special case
to exempt BUTTON_TOUCHSCREEN from acceleration.

Change-Id: I9e097e27457fbd6b824f098e8b325ff35c59dde4
2021-11-21 20:26:20 +00:00
Wolfram Sang
336ea51af6 WIP: Samsung YPR0/1: switch to generic SI47xx polling
Should work(tm). But I don't have the hardware, so it needs to be
tested.

Change-Id: Ic086434f570dcddacb5b7e7a1acce4b8cafc5c03
2021-11-18 16:53:57 -05:00
Wolfram Sang
de0346065b Sansa Clip+: add RDS support
Based on a patch by Amaury Pouly which was based on a patch from Ryan
Hitchman.

I mainly moved the code for polling into the tuner driver so it can be
reused by other targets. I added the CONFIG parameter for the polling
frequency (in ticks) to save energy. Also, I did some minor cleanups.

Change-Id: I95a62e7e1e42c62dbf47ecb27a3b312a42be62aa
2021-11-18 16:44:21 -05:00
Aidan MacDonald
701d4ba77e x1000: Merge makefiles used for the bootloader
All three X1000 native targets turned out to have a very
similar boot configuration and used a nearly identical
makefile. Eliminate this duplication by moving the logic
into the main makefile.

Change-Id: I13044b9675c0abd605b8accdb2fee4f54549b020
2021-11-18 14:14:54 -05:00
Aidan MacDonald
6e61e6f0c8 usb_core: don't buffer control request unnecessarily
Due to how the old control request API worked, the request
pointer (and the pointed-to contents) passed by the driver
must remain valid for the lifetime of the request.

The buffered copy wasn't used consistently anyway, so it
should be safe to just get rid of it.

(This only affects the old API compatibility layer.)

Change-Id: I00294c718a7515a91b84f7c7cae5220c73aa5960
2021-11-14 17:58:39 +00:00
Aidan MacDonald
f8810be6de usb_core: More legacy control API fixes
In the old API, usb_core_transfer_complete() would ignore
any completions on EP0. The legacy control API will also
ignore most completions on EP0, but it only did so after
filling in the completion event.

If the driver submits a spurious completion on EP0, then
this could clobber a previously queued completion event.

Fix this by deciding whether to ignore the completion
*before* modifying the event data.

Change-Id: I68526898a96efa594ada4e94bb6851aaaf12e92a
2021-11-13 18:37:33 +00:00
Dana Conrad
59ef877c94 x1000: delay power thread until valid battery read
Appears to return 0 until the axp has (presumably) completed
its first real measurement.

Note about erosq: keep the power_inint() delay large to ensure
nothing breaks in the bootloader for the time being.

Change-Id: I444e858207cc401c42f1e6ceacf067ad543d4ff8
2021-11-12 16:31:27 -05:00
Wolfram Sang
67fb558c89 as3525: debug: use 'kHz' where applicable instead of "MHz" or "KHz"
Change-Id: I84c24402d664b5a1a37c81aebfc438bd04bc8af4
2021-11-10 21:53:15 -05:00
Dana Conrad
9ee321cf90 ErosqNative: increase battery stabilization delay again
Hopefully 250 is long enough for any devices out there!

Change-Id: I80e084dceb62acd8d1f51d873b18a4be9c3447d8
2021-11-10 07:22:57 -05:00
Aidan MacDonald
7af98ce6bb usb: Fix possible SET ADDRESS data corruption
The address from the packet needs to be saved before sending
the response -- after the response the request being pointed
to could get overwritten. This used to be done correctly but
I unintentionally broke it when updating the handler to the
new control request API.

Change-Id: I9b11548baf20dce44a82301731405dc8e8f1cef3
2021-11-09 14:45:07 +00:00
William Wilgus
9f1cab154c lcd-16bit-common move bugfix to sim only
Ive seen no ill effects having this disabled on target so
limit it to the sim to stop Address Sanitizer from dumping
on the extra byte read. the bad data is never used AFAICT
since the loop ends

Change-Id: I8cb54e9d1f8fe28747867d861a015edb3dbfa5ff
2021-11-08 17:52:09 -05:00
Aidan MacDonald
8c954c68e5 usb: Attempt to fix race condition in compatibility layer
Because usb_core_legacy_control_request() is called by an
interrupt handler the global variables used to track the
current control request at the very least need to be volatile.

It might also be necessary to disable IRQs but I'm not sure
of that.

Change-Id: I0f0bb86d0ad63734e8d3c73cb1c52fedf5a98120
2021-11-08 21:46:36 +00:00
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