From 56e79c0af94360241b4a616e5f81427fb297c305 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Mon, 8 Dec 2014 17:04:23 +0000 Subject: [PATCH 1/5] Explicit feedback endpoint removed from Audio Class 2.0 descriptors when input stream is available (or UAC_FORCE_FEEDBACK_EP is defined) --- module_usb_audio/endpoint0/descriptors.h | 44 +++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index ca50bbf3..06b27d1f 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -1267,24 +1267,30 @@ typedef struct USB_Descriptor_Audio_Format_Type1_t Audio_Out_Format; USB_Descriptor_Endpoint_t Audio_Out_Endpoint; USB_Descriptor_Audio_Class_AS_Endpoint_t Audio_Out_ClassEndpoint; +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) USB_Descriptor_Endpoint_t Audio_Out_Fb_Endpoint; +#endif #if (OUTPUT_FORMAT_COUNT > 1) USB_Descriptor_Interface_t Audio_Out_StreamInterface_Alt2; USB_Descriptor_Audio_Interface_AS_t Audio_Out_ClassStreamInterface_2; USB_Descriptor_Audio_Format_Type1_t Audio_Out_Format_2; USB_Descriptor_Endpoint_t Audio_Out_Endpoint_2; USB_Descriptor_Audio_Class_AS_Endpoint_t Audio_Out_ClassEndpoint_2; +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) USB_Descriptor_Endpoint_t Audio_Out_Fb_Endpoint_2; #endif +#endif #if (OUTPUT_FORMAT_COUNT > 2) USB_Descriptor_Interface_t Audio_Out_StreamInterface_Alt3; USB_Descriptor_Audio_Interface_AS_t Audio_Out_ClassStreamInterface_3; USB_Descriptor_Audio_Format_Type1_t Audio_Out_Format_3; USB_Descriptor_Endpoint_t Audio_Out_Endpoint_3; USB_Descriptor_Audio_Class_AS_Endpoint_t Audio_Out_ClassEndpoint_3; +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) USB_Descriptor_Endpoint_t Audio_Out_Fb_Endpoint_3; #endif #endif +#endif #if (NUM_USB_CHAN_IN > 0) /* Audio Streaming: Input stream */ USB_Descriptor_Interface_t Audio_In_StreamInterface_Alt0; /* Zero bandwith alternative */ @@ -1745,7 +1751,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= /* Output Terminal Descriptor (USB Streaming) */ .bLength = 0x0C, .bDescriptorType = UAC_CS_DESCTYPE_INTERFACE, - .bDescriptorSubtype = UAC_CS_AC_INTERFACE_SUBTYPE_OUTPUT_TERMINAL, + .bDescriptorSubtype = UAC_CS_AC_INTERFACE_SUBTYPE_OUTPUT_TERMINAL, .bTerminalID = ID_OT_USB, .wTerminalType = USB_TERMTYPE_USB_STREAMING, .bAssocTerminal = 0x00, @@ -1893,7 +1899,11 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= USB_DESCTYPE_INTERFACE, /* 1 bDescriptorType: INTERFACE */ INTERFACE_NUMBER_AUDIO_OUTPUT, /* 2 bInterfaceNumber: Number of interface */ 1, /* 3 bAlternateSetting */ +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) 2, /* 4 bNumEndpoints */ +#else + 1, /* 4 bNumEndpoints */ +#endif USB_CLASS_AUDIO, /* 5 bInterfaceClass: AUDIO */ UAC_INT_SUBCLASS_AUDIOSTREAMING, /* 6 bInterfaceSubClass: AUDIO_STREAMING */ UAC_INT_PROTOCOL_IP_VERSION_02_00,/* 7 bInterfaceProtocol: IP_VERSION_02_00 */ @@ -1949,6 +1959,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= 0x0008, /* 6:7 bLockDelay */ }, +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) .Audio_Out_Fb_Endpoint = { 0x07, /* 0 bLength: 7 */ @@ -1958,6 +1969,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= 0x0004, /* 4 wMaxPacketSize */ 4, /* 6 bInterval. Only values <= 1 frame (4) supported by MS */ }, +#endif #if (OUTPUT_FORMAT_COUNT > 1) /* Standard AS Interface Descriptor (4.9.1) (Alt) */ .Audio_Out_StreamInterface_Alt2 = @@ -1966,7 +1978,11 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= USB_DESCTYPE_INTERFACE, /* 1 bDescriptorType: INTERFACE */ INTERFACE_NUMBER_AUDIO_OUTPUT, /* 2 bInterfaceNumber: Number of interface */ 2, /* 3 bAlternateSetting */ +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) 2, /* 4 bNumEndpoints */ +#else + 1, /* 4 bNumEndpoints */ +#endif USB_CLASS_AUDIO, /* 5 bInterfaceClass: AUDIO */ UAC_INT_SUBCLASS_AUDIOSTREAMING, /* 6 bInterfaceSubClass: AUDIO_STREAMING */ UAC_INT_PROTOCOL_IP_VERSION_02_00,/* 7 bInterfaceProtocol: IP_VERSION_02_00 */ @@ -2021,6 +2037,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= 0x0008, /* 6:7 bLockDelay */ }, +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) .Audio_Out_Fb_Endpoint_2 = { 0x07, /* 0 bLength: 7 */ @@ -2031,6 +2048,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= 4, /* 6 bInterval. Only values <= 1 frame (4) supported by MS */ }, #endif +#endif #if (OUTPUT_FORMAT_COUNT > 2) /* Standard AS Interface Descriptor (4.9.1) (Alt) */ .Audio_Out_StreamInterface_Alt3 = @@ -2039,7 +2057,11 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= USB_DESCTYPE_INTERFACE, /* 1 bDescriptorType: INTERFACE */ INTERFACE_NUMBER_AUDIO_OUTPUT, /* 2 bInterfaceNumber: Number of interface */ 3, /* 3 bAlternateSetting */ +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) 2, /* 4 bNumEndpoints */ +#else + 1, /* 4 bNumEndpoints */ +#endif USB_CLASS_AUDIO, /* 5 bInterfaceClass: AUDIO */ UAC_INT_SUBCLASS_AUDIOSTREAMING, /* 6 bInterfaceSubClass: AUDIO_STREAMING */ UAC_INT_PROTOCOL_IP_VERSION_02_00,/* 7 bInterfaceProtocol: IP_VERSION_02_00 */ @@ -2095,6 +2117,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .wLockDelay = 0x0008, }, +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) .Audio_Out_Fb_Endpoint_3 = { .bLength = 0x07, @@ -2104,6 +2127,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .wMaxPacketSize = 0x0004, .bInterval = 4, /* Only values <= 1 frame (4) supported by MS */ }, +#endif #endif /* OUTPUT_FORMAT_COUNT > 2 */ #endif /* OUTPUT */ #if (NUM_USB_CHAN_IN > 0) @@ -2169,7 +2193,11 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .bLength = 0x07, .bDescriptorType = USB_DESCTYPE_ENDPOINT, .bEndpointAddress = 0x82, - .bmAttributes = 5, +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) + .bmAttributes = 0x05, /* Iso, async, data endpoint */ +#else + .bmAttributes = 0x25, /* Iso, async, implicit feedback data endpoint */ +#endif .wMaxPacketSize = HS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE, .bInterval = 0x01, }, @@ -2233,7 +2261,11 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .bLength = 0x07, .bDescriptorType = USB_DESCTYPE_ENDPOINT, .bEndpointAddress = 0x82, - .bmAttributes = 5, +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) + .bmAttributes = 0x05, /* Iso, async, data endpoint */ +#else + .bmAttributes = 0x25, /* Iso, async, implicit feedback data endpoint */ +#endif .wMaxPacketSize = HS_STREAM_FORMAT_INPUT_2_MAXPACKETSIZE, .bInterval = 0x01, }, @@ -2298,7 +2330,11 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .bLength = 0x07, .bDescriptorType = USB_DESCTYPE_ENDPOINT, .bEndpointAddress = 0x82, - .bmAttributes = 5, +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) + .bmAttributes = 0x05, /* Iso, async, data endpoint */ +#else + .bmAttributes = 0x25, /* Iso, async, implicit feedback data endpoint */ +#endif .wMaxPacketSize = HS_STREAM_FORMAT_INPUT_3_MAXPACKETSIZE, .bInterval = 0x01, }, From 8d2b65127e062192d82f8c742190b677d10796b0 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Mon, 8 Dec 2014 18:19:56 +0000 Subject: [PATCH 2/5] First attempt at complete removal of feedback EP code when not required. --- module_usb_audio/devicedefines.h | 2 ++ module_usb_audio/endpoint0/descriptors.h | 44 +++++++++++------------ module_usb_audio/main.xc | 10 +++--- module_usb_audio/usb_buffer/usb_buffer.h | 2 ++ module_usb_audio/usb_buffer/usb_buffer.xc | 13 +++++-- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/module_usb_audio/devicedefines.h b/module_usb_audio/devicedefines.h index 60e71691..ac0505a7 100644 --- a/module_usb_audio/devicedefines.h +++ b/module_usb_audio/devicedefines.h @@ -1044,7 +1044,9 @@ enum USBEndpointNumber_In { ENDPOINT_NUMBER_IN_CONTROL, /* Endpoint 0 */ +#if (NUM_USB_CHAN_IN == 0) || (defined UAC_FORCE_FEEDBACK_EP) ENDPOINT_NUMBER_IN_FEEDBACK, +#endif ENDPOINT_NUMBER_IN_AUDIO, #if defined(SPDIF_RX) || defined(ADAT_RX) ENDPOINT_NUMBER_IN_INTERRUPT, /* Audio interrupt/status EP */ diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index 06b27d1f..54da9fda 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -1928,12 +1928,12 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= /* Type 1 Format Type Descriptor */ .Audio_Out_Format = { - 0x06, /* 0 bLength (in bytes): 6 */ - UAC_CS_DESCTYPE_INTERFACE, /* 1 bDescriptorType: 0x24 */ - UAC_CS_AS_INTERFACE_SUBTYPE_FORMAT_TYPE, /* 2 bDescriptorSubtype: FORMAT_TYPE */ - UAC_FORMAT_TYPE_I, /* 3 bFormatType: FORMAT_TYPE_1 */ - .bSubslotSize = HS_STREAM_FORMAT_OUTPUT_1_SUBSLOT_BYTES, - .bBitResolution = HS_STREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS, + .bLength = 0x06, + .bDescriptorType = UAC_CS_DESCTYPE_INTERFACE, + .bDescriptorSubtype = UAC_CS_AS_INTERFACE_SUBTYPE_FORMAT_TYPE, + .bFormatType = UAC_FORMAT_TYPE_I, + .bSubslotSize = HS_STREAM_FORMAT_OUTPUT_1_SUBSLOT_BYTES, + .bBitResolution = HS_STREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS, }, /* Standard AS Isochronous Audio Data Endpoint Descriptor (4.10.1.1) */ @@ -1941,7 +1941,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= { .bLength = sizeof(USB_Descriptor_Endpoint_t), .bDescriptorType = USB_DESCTYPE_ENDPOINT, - .bEndpointAddress = 0x01, /* (D7: 0:out, 1:in) */ + .bEndpointAddress = ENDPOINT_ADDRESS_OUT_AUDIO, .bmAttributes = 0x05, /* (bitmap) */ .wMaxPacketSize = HS_STREAM_FORMAT_OUTPUT_1_MAXPACKETSIZE, .bInterval = 1, @@ -1962,12 +1962,12 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= #if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) .Audio_Out_Fb_Endpoint = { - 0x07, /* 0 bLength: 7 */ - USB_DESCTYPE_ENDPOINT, /* 1 bDescriptorType: ENDPOINT */ - 0x81, /* 2 bEndpointAddress (D7: 0:out, 1:in) */ - 17, /* 3 bmAttributes (bitmap) */ - 0x0004, /* 4 wMaxPacketSize */ - 4, /* 6 bInterval. Only values <= 1 frame (4) supported by MS */ + .bLength = 0x07, + .bDescriptorType = USB_DESCTYPE_ENDPOINT, + .bEndpointAddress = ENDPOINT_ADDRESS_IN_FEEDBACK, + .bmAttributes = 17, /* (bitmap) */ + .wMaxPacketSize = 0x0004, + .bInterval = 4, /* Only values <= 1 frame (4) supported by MS */ }, #endif #if (OUTPUT_FORMAT_COUNT > 1) @@ -2019,7 +2019,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= { .bLength = sizeof(USB_Descriptor_Endpoint_t), .bDescriptorType = USB_DESCTYPE_ENDPOINT, - .bEndpointAddress = 0x01, + .bEndpointAddress = ENDPOINT_ADDRESS_OUT_AUDIO, .bmAttributes = 0x05, .wMaxPacketSize = HS_STREAM_FORMAT_OUTPUT_2_MAXPACKETSIZE, .bInterval = 1, @@ -2042,7 +2042,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= { 0x07, /* 0 bLength: 7 */ USB_DESCTYPE_ENDPOINT, /* 1 bDescriptorType: ENDPOINT */ - 0x81, /* 2 bEndpointAddress (D7: 0:out, 1:in) */ + ENDPOINT_ADDRESS_IN_FEEDBACK, /* 2 bEndpointAddress (D7: 0:out, 1:in) */ 17, /* 3 bmAttributes (bitmap) */ 0x0004, /* 4 wMaxPacketSize */ 4, /* 6 bInterval. Only values <= 1 frame (4) supported by MS */ @@ -2099,7 +2099,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= { .bLength = 0x07, .bDescriptorType = USB_DESCTYPE_ENDPOINT, - .bEndpointAddress = 0x01, + .bEndpointAddress = ENDPOINT_ADDRESS_OUT_AUDIO, .bmAttributes = 0x05, .wMaxPacketSize = HS_STREAM_FORMAT_OUTPUT_3_MAXPACKETSIZE, .bInterval = 1, @@ -2122,7 +2122,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= { .bLength = 0x07, .bDescriptorType = USB_DESCTYPE_ENDPOINT, - .bEndpointAddress = 0x81, + .bEndpointAddress = ENDPOINT_ADDRESS_IN_FEEDBACK, .bmAttributes = 17, /* (bitmap) */ .wMaxPacketSize = 0x0004, .bInterval = 4, /* Only values <= 1 frame (4) supported by MS */ @@ -2192,7 +2192,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= { .bLength = 0x07, .bDescriptorType = USB_DESCTYPE_ENDPOINT, - .bEndpointAddress = 0x82, + .bEndpointAddress = ENDPOINT_ADDRESS_IN_AUDIO, #if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) .bmAttributes = 0x05, /* Iso, async, data endpoint */ #else @@ -2260,7 +2260,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= { .bLength = 0x07, .bDescriptorType = USB_DESCTYPE_ENDPOINT, - .bEndpointAddress = 0x82, + .bEndpointAddress = ENDPOINT_ADDRESS_IN_AUDIO, #if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) .bmAttributes = 0x05, /* Iso, async, data endpoint */ #else @@ -2329,7 +2329,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= { .bLength = 0x07, .bDescriptorType = USB_DESCTYPE_ENDPOINT, - .bEndpointAddress = 0x82, + .bEndpointAddress = ENDPOINT_ADDRESS_IN_AUDIO, #if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) .bmAttributes = 0x05, /* Iso, async, data endpoint */ #else @@ -2927,7 +2927,7 @@ unsigned char cfgDesc_Audio1[] = /* Feedback EP */ 0x09, 0x05, /* bDescriptorType: ENDPOINT */ - 0x81, /* bEndpointAddress (D3:0 - EP no. D6:4 - reserved 0. D7 - 0:out, 1:in) */ + ENDPOINT_ADDRESS_IN_FEEDBACK, /* bEndpointAddress (D3:0 - EP no. D6:4 - reserved 0. D7 - 0:out, 1:in) */ 0x01, /* bmAttributes (bitmap) */ 0x03,0x0, /* wMaxPacketSize */ 0x01, /* bInterval - Must be 1 for compliance */ @@ -2994,7 +2994,7 @@ unsigned char cfgDesc_Audio1[] = /* Standard Endpoint Descriptor */ 0x09, 0x05, /* ENDPOINT */ - 0x82, /* EndpointAddress */ + ENDPOINT_ADDRESS_IN_AUDIO, /* EndpointAddress */ 0x05, /* Attributes - isochronous async */ FS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE&0xff, /* 4 wMaxPacketSize (Typically 294 bytes)*/ (FS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE&0xff00)>>8, /* 5 wMaxPacketSize */ diff --git a/module_usb_audio/main.xc b/module_usb_audio/main.xc index fe609211..9b46c2e2 100755 --- a/module_usb_audio/main.xc +++ b/module_usb_audio/main.xc @@ -332,12 +332,14 @@ void usb_audio_core(chanend c_mix_out asm("setclk res[%0], %1"::"r"(p_for_mclk_count), "r"(x)); #endif //:buffer - buffer(c_xud_out[ENDPOINT_NUMBER_OUT_AUDIO],/* Audio Out*/ - c_xud_in[ENDPOINT_NUMBER_IN_AUDIO], /* Audio In */ + buffer(c_xud_out[ENDPOINT_NUMBER_OUT_AUDIO], /* Audio Out*/ + c_xud_in[ENDPOINT_NUMBER_IN_AUDIO], /* Audio In */ +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) c_xud_in[ENDPOINT_NUMBER_IN_FEEDBACK], /* Audio FB */ +#endif #ifdef MIDI - c_xud_out[ENDPOINT_NUMBER_OUT_MIDI], /* MIDI Out */ // 2 - c_xud_in[ENDPOINT_NUMBER_IN_MIDI], /* MIDI In */ // 4 + c_xud_out[ENDPOINT_NUMBER_OUT_MIDI], /* MIDI Out */ // 2 + c_xud_in[ENDPOINT_NUMBER_IN_MIDI], /* MIDI In */ // 4 c_midi, #endif #ifdef IAP diff --git a/module_usb_audio/usb_buffer/usb_buffer.h b/module_usb_audio/usb_buffer/usb_buffer.h index ff405347..3541cf22 100644 --- a/module_usb_audio/usb_buffer/usb_buffer.h +++ b/module_usb_audio/usb_buffer/usb_buffer.h @@ -19,7 +19,9 @@ */ void buffer(chanend c_aud_out, chanend c_aud_in, +#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_ENDPOINT) chanend c_aud_fb, +#endif #ifdef MIDI chanend c_midi_from_host, chanend c_midi_to_host, diff --git a/module_usb_audio/usb_buffer/usb_buffer.xc b/module_usb_audio/usb_buffer/usb_buffer.xc index e6671aee..af84386f 100644 --- a/module_usb_audio/usb_buffer/usb_buffer.xc +++ b/module_usb_audio/usb_buffer/usb_buffer.xc @@ -94,7 +94,10 @@ unsigned char fb_clocks[16]; * @param c_aud_fb chanend for feeback to xud * @return void */ -void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud_fb, +void buffer(register chanend c_aud_out, register chanend c_aud_in, +#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_ENDPOINT) + chanend c_aud_fb, +#endif #ifdef MIDI chanend c_midi_from_host, chanend c_midi_to_host, @@ -131,7 +134,9 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud { XUD_ep ep_aud_out = XUD_InitEp(c_aud_out); XUD_ep ep_aud_in = XUD_InitEp(c_aud_in); +#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_ENDPOINT) XUD_ep ep_aud_fb = XUD_InitEp(c_aud_fb); +#endif #ifdef MIDI XUD_ep ep_midi_from_host = XUD_InitEp(c_midi_from_host); XUD_ep ep_midi_to_host = XUD_InitEp(c_midi_to_host); @@ -344,6 +349,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud SET_SHARED_GLOBAL(g_formatChange_DataFormat, formatChange_DataFormat); SET_SHARED_GLOBAL(g_formatChange_SampRes, formatChange_SampRes); +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) /* Host is starting up the output stream. Setup (or potentially resize) feedback packet based on bus-speed * This is only really important on inital start up (when bus-speed was unknown) and when changing bus-speeds */ @@ -357,7 +363,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud { XUD_SetReady_In(ep_aud_fb, fb_clocks, 3); } - +#endif } /* Pass on sample freq change to decouple() via global flag (saves a chanend) */ /* Note: freqChange flags now used to communicate other commands also */ @@ -460,6 +466,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud #endif #if (NUM_USB_CHAN_OUT > 0) +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) /* Feedback Pipe */ case XUD_SetData_Select(c_aud_fb, ep_aud_fb, result): { @@ -477,7 +484,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud } } break; - +#endif /* Received Audio packet HOST -> DEVICE. Datalength written to length */ case XUD_GetData_Select(c_aud_out, ep_aud_out, length, result): { From 129c9390cf852f636823a541ec1bf7788c018265 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Mon, 12 Jan 2015 18:12:59 +0000 Subject: [PATCH 3/5] UAC1 descriptors now use implicit feedback when sensible --- module_usb_audio/endpoint0/descriptors.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index 922f94d2..77a0278d 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -3399,7 +3399,11 @@ unsigned char cfgDesc_Null[] = /* Note, this is different that INTERFACE_COUNT since we dont support items such as MIDI, iAP etc in UAC1 mode */ #define NUM_INTERFACES_A1 (1+INPUT_INTERFACES_A1 + OUTPUT_INTERFACES_A1) +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) #define CFG_TOTAL_LENGTH_A1 (18 + AC_TOTAL_LENGTH + (INPUT_INTERFACES_A1 * 61) + (OUTPUT_INTERFACES_A1 * 70)) +#else +#define CFG_TOTAL_LENGTH_A1 (18 + AC_TOTAL_LENGTH + (INPUT_INTERFACES_A1 * 61) + (OUTPUT_INTERFACES_A1 * 61)) +#endif /* In UAC1 supported sample rates are listed in descriptor */ /* Note, we always report 4 freqs, doing otherwise seems to cause an enumeration issue on Windows */ @@ -3537,7 +3541,11 @@ unsigned char cfgDesc_Audio1[] = 0x04, /* INTERFACE */ 0x01, /* Interface no */ 0x01, /* AlternateSetting */ - 0x02, /* num endpoints 2: audio EP and feedback EP */ +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) + 0x02, /* bNumEndpoints 2: audio EP and feedback EP */ +#else + 0x01, /* bNumEndpoints */ +#endif 0x01, /* Interface class - AUDIO */ 0x02, /* subclass - AUDIO_STREAMING */ 0x00, /* Unused */ @@ -3587,7 +3595,11 @@ unsigned char cfgDesc_Audio1[] = (FS_STREAM_FORMAT_OUTPUT_1_MAXPACKETSIZE&0xff00)>>8, /* 5 wMaxPacketSize */ 0x01, /* bInterval */ 0x00, /* bRefresh */ - 0x81, /* bSynchAdddress - address of EP used to communicate sync info */ +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) + ENDPOINT_ADDRESS_IN_FEEDBACK, /* bSynchAdddress - address of EP used to communicate sync info */ +#else + ENDPOINT_ADDRESS_IN_AUDIO, +#endif /* CS_Endpoint Descriptor ?? */ 0x07, @@ -3597,6 +3609,7 @@ unsigned char cfgDesc_Audio1[] = 0x02, /* bLockDelayUnits */ 0x00, 0x00, /* bLockDelay */ +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) /* Feedback EP */ 0x09, 0x05, /* bDescriptorType: ENDPOINT */ @@ -3607,6 +3620,7 @@ unsigned char cfgDesc_Audio1[] = 0x04, /* bRefresh 2^x */ 0x0, /* bSynchAddress */ #endif +#endif #if (NUM_USB_CHAN_IN > 0) /* Standard Interface Descriptor - Audio streaming IN */ @@ -3668,7 +3682,11 @@ unsigned char cfgDesc_Audio1[] = 0x09, 0x05, /* ENDPOINT */ ENDPOINT_ADDRESS_IN_AUDIO, /* EndpointAddress */ - 0x05, /* Attributes - isochronous async */ +#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) + 0x05, /* Iso, async, data endpoint */ +#else + 0x25, /* Iso, async, implicit feedback data endpoint */ +#endif FS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE&0xff, /* 4 wMaxPacketSize (Typically 294 bytes)*/ (FS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE&0xff00)>>8, /* 5 wMaxPacketSize */ 0x01, /* bInterval */ From b36a7ab5556ad0384457c24678dcc04962087d76 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Mon, 12 Jan 2015 18:13:38 +0000 Subject: [PATCH 4/5] Audio Class endpoint checks now use ENDPOIN_ADDRESS defines --- module_usb_audio/endpoint0/endpoint0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module_usb_audio/endpoint0/endpoint0.c b/module_usb_audio/endpoint0/endpoint0.c index fd546cad..3b89073c 100755 --- a/module_usb_audio/endpoint0/endpoint0.c +++ b/module_usb_audio/endpoint0/endpoint0.c @@ -529,7 +529,7 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, { unsigned epNum = sp.wIndex & 0xff; - if ((epNum == 0x82) || (epNum == 0x01)) + if ((epNum == ENDPOINT_ADDRESS_OUT_AUDIO) || (epNum == ENDPOINT_ADDRESS_IN_AUDIO)) { #if (AUDIO_CLASS == 2) && defined(AUDIO_CLASS_FALLBACK) if(g_curUsbSpeed == XUD_SPEED_FS) From cfca7b347e1abb87fda387cb2467e47192dc092c Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Mon, 12 Jan 2015 18:14:07 +0000 Subject: [PATCH 5/5] Fixed build issue due to bad define name (EP vs ENDPOINT) --- module_usb_audio/usb_buffer/usb_buffer.h | 2 +- module_usb_audio/usb_buffer/usb_buffer.xc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module_usb_audio/usb_buffer/usb_buffer.h b/module_usb_audio/usb_buffer/usb_buffer.h index 3541cf22..038bbdbc 100644 --- a/module_usb_audio/usb_buffer/usb_buffer.h +++ b/module_usb_audio/usb_buffer/usb_buffer.h @@ -19,7 +19,7 @@ */ void buffer(chanend c_aud_out, chanend c_aud_in, -#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_ENDPOINT) +#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_EP) chanend c_aud_fb, #endif #ifdef MIDI diff --git a/module_usb_audio/usb_buffer/usb_buffer.xc b/module_usb_audio/usb_buffer/usb_buffer.xc index af84386f..2201b1fc 100644 --- a/module_usb_audio/usb_buffer/usb_buffer.xc +++ b/module_usb_audio/usb_buffer/usb_buffer.xc @@ -95,7 +95,7 @@ unsigned char fb_clocks[16]; * @return void */ void buffer(register chanend c_aud_out, register chanend c_aud_in, -#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_ENDPOINT) +#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_EP) chanend c_aud_fb, #endif #ifdef MIDI @@ -134,7 +134,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, { XUD_ep ep_aud_out = XUD_InitEp(c_aud_out); XUD_ep ep_aud_in = XUD_InitEp(c_aud_in); -#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_ENDPOINT) +#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_EP) XUD_ep ep_aud_fb = XUD_InitEp(c_aud_fb); #endif #ifdef MIDI