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): {