mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-07 05:35:02 -05:00
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:
parent
9ce66e088e
commit
7c4293af64
5 changed files with 439 additions and 65 deletions
|
|
@ -18,6 +18,14 @@
|
|||
****************************************************************************/
|
||||
/* Parts of this file are based on Frank Gevaerts work and on audio.h from linux */
|
||||
|
||||
/* NOTE
|
||||
*
|
||||
* This is USBAudio 1.0. USBAudio 2.0 is notably _not backwards compatible!_
|
||||
* USBAudio 1.0 over _USB_ 2.0 is perfectly valid!
|
||||
*
|
||||
* Relevant specifications are USB 2.0 and USB Audio Class 1.0.
|
||||
*/
|
||||
|
||||
#ifndef USB_AUDIO_DEF_H
|
||||
#define USB_AUDIO_DEF_H
|
||||
|
||||
|
|
@ -188,25 +196,54 @@ struct usb_as_interface {
|
|||
#define USB_AS_EP_CS_SAMPLING_FREQ_CTL 0x01
|
||||
#define USB_AS_EP_CS_PITCH_CTL 0x02
|
||||
|
||||
struct usb_iso_audio_endpoint_descriptor {
|
||||
// Standard* AudioStreaming Isochronous Audio Data Endpoint Descriptor
|
||||
//
|
||||
// *Note, per usbaudio 1.0 this is explititly identical
|
||||
// to a standard endpoint descriptor but with extra information
|
||||
struct usb_as_iso_audio_endpoint {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bmAttributes;
|
||||
uint16_t wMaxPacketSize;
|
||||
uint8_t bInterval;
|
||||
uint8_t bRefresh;
|
||||
uint8_t bSynchAddress;
|
||||
uint8_t bInterval; /* MUST be set to 1 (full speed), +3 for high-speed? */
|
||||
uint8_t bRefresh; /* USB Audio Class 1.0 specific: set to 0 */
|
||||
uint8_t bSynchAddress; /* USB Audio Class 1.0 specific: used to identify synch ep */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct usb_as_iso_endpoint {
|
||||
// Class-Specific AudioStreaming Isochronous Audio* (Control) Data Endpoint Descriptor
|
||||
//
|
||||
// *The name is a bit misleading, this is for _control_ of audio,
|
||||
// such as sampling frequency or pitch.
|
||||
struct usb_as_iso_ctrldata_endpoint {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType; /* USB_DT_CS_ENDPOINT */
|
||||
uint8_t bDescriptorSubType; /* USB_AS_EP_GENERAL */
|
||||
uint8_t bmAttributes;
|
||||
uint8_t bLockDelayUnits;
|
||||
uint16_t wLockDelay;
|
||||
uint8_t bLockDelayUnits; /* USB Audio Class 1.0 specific */
|
||||
uint16_t wLockDelay; /* USB Audio Class 1.0 specific */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
// Standard* AudioStreaming Isochronous Synch (Feedback) Endpoint Descriptor
|
||||
//
|
||||
// *Note, per usbaudio 1.0 this is explititly identical
|
||||
// to a standard endpoint descriptor but with extra information
|
||||
struct usb_as_iso_synch_endpoint {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType; /* USB_DT_CS_ENDPOINT */
|
||||
|
||||
uint8_t bEndpointAddress; /* D7: direction (0 = source, 1 = sink)
|
||||
* D6..4: Zeros
|
||||
* D3..0: EP Number */
|
||||
uint8_t bmAttributes; /* USBAudio 1.0:
|
||||
* D3..2: Synch type (00 = None)
|
||||
* D1..0: Transfer type (01 = Isochronous)
|
||||
*/
|
||||
uint16_t wMaxPacketSize;
|
||||
uint8_t bInterval; /* MUST be set to 1 (full speed), +3 for high-speed? */
|
||||
uint8_t bRefresh; /* USB Audio Class 1.0 specific: Range of 1 to 9 (full-speed). high-speed, probably range of 1 to 16? */
|
||||
uint8_t bSynchAddress; /* USB Audio Class 1.0 specific: MUST be set to 0 */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define USB_AS_FORMAT_TYPE_I_UNDEFINED 0x0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue