usbaudio: convert to asynchronous operation

Add feedback not based on samples used, but on buffers filled - idea
being we can do "PID" (someone who has actually implemented Real PID
could probably rewrite the calculation) based on how many buffers
we have filled versus the ideal buffer filled level (16).

Feedback is based on a historical average of the last two feedback
intervals.

This feedback math is done as fixed-point math to keep floats out of core. Note that a couple division operations needed to be strategically staged to avoid overflow or truncation.

Floats are still used for debug screen printout.

Also fixed a typo in the definition of usb_audio_control_request()

Host:
Linux: works
MacOS: works
Windows: Feedback does not work! It appears that Windows may not
         support asynchronous devices at all. Playback may "work",
         but results will vary as the number of buffers filled will
         drift over time.

Change-Id: I027feb16705e6e46c1144b1d08920b53de42cb26
This commit is contained in:
Dana Conrad 2025-10-08 00:37:33 +00:00
parent 9ce66e088e
commit 7c4293af64
5 changed files with 439 additions and 65 deletions

View file

@ -345,6 +345,10 @@ struct usb_endpoint_descriptor {
#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
#define USB_ENDPOINT_USAGE_DATA (0 << 4) /* in bmAttributes */
#define USB_ENDPOINT_USAGE_FEEDBACK (1 << 4)
#define USB_ENDPOINT_USAGE_IMPLICITFEEDBACK (2 << 4)
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
#define USB_ENDPOINT_XFER_CONTROL 0
#define USB_ENDPOINT_XFER_ISOC 1