From 5a89ff85110f381501940a05db76f25294dcc784 Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Fri, 13 Jun 2014 17:11:51 +0100 Subject: [PATCH 01/48] Control iAP EA Protocol Native Transport #define --- module_usb_audio/devicedefines.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module_usb_audio/devicedefines.h b/module_usb_audio/devicedefines.h index 69a77662..0d8565e9 100644 --- a/module_usb_audio/devicedefines.h +++ b/module_usb_audio/devicedefines.h @@ -902,6 +902,11 @@ #undef IAP_INT_EP #endif +/* IAP EA Native Transport */ +#if defined(IAP_EA_NATIVE) && (IAP_EA_NATIVE == 0) +#undef IAP_EA_NATIVE +#endif + /* Endpoint addresses enums */ enum USBEndpointNumber_In { From f99e17d8780a15b9ce4ea8677a2fb5d0dbf71cb8 Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Fri, 13 Jun 2014 17:12:29 +0100 Subject: [PATCH 02/48] Define iAP EA Protocol Native transport EP numbers --- module_usb_audio/devicedefines.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/module_usb_audio/devicedefines.h b/module_usb_audio/devicedefines.h index 0d8565e9..c656db6f 100644 --- a/module_usb_audio/devicedefines.h +++ b/module_usb_audio/devicedefines.h @@ -927,6 +927,9 @@ enum USBEndpointNumber_In ENDPOINT_NUMBER_IN_IAP_INT, #endif ENDPOINT_NUMBER_IN_IAP, +#ifdef IAP_EA_NATIVE + ENDPOINT_NUMBER_IN_IAP_EA_NATIVE, +#endif #endif ENDPOINT_COUNT_IN /* End marker */ }; @@ -940,6 +943,9 @@ enum USBEndpointNumber_Out #endif #ifdef IAP ENDPOINT_NUMBER_OUT_IAP, +#ifdef IAP_EA_NATIVE + ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE, +#endif #endif ENDPOINT_COUNT_OUT /* End marker */ }; From ec845dfddcb772d083f80e032772789a66b4d46c Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Fri, 13 Jun 2014 17:25:58 +0100 Subject: [PATCH 03/48] Added iAP EA Native Transport interface and EPs --- module_usb_audio/endpoint0/descriptors.h | 103 ++++++++++++++++++++--- 1 file changed, 91 insertions(+), 12 deletions(-) diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index 631164c9..f2f57a4f 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -12,6 +12,19 @@ #include "usbaudiocommon.h" #include "usb_std_descriptors.h" +#ifdef IAP_EA_NATIVE +/* + * FIXME currently this will not build if IAP_EA_NATIVE_PROTOCOL_NAME is not defined in iap_conf.h, + * would be nice if a default string was used instead, and a warning issued. + * + * Could get a default define by including the following line, but iap2.h cannot currently be included from C + */ +//#include "iap2.h" /* Defines iAP EA Native Transport protocol name */ +#ifdef __iap_conf_h_exists__ +#include "iap_conf.h" +#endif +#endif + #define APPEND_VENDOR_STR(x) VENDOR_STR" "#x #define APPEND_PRODUCT_STR_A2(x) PRODUCT_STR_A2 " "#x @@ -172,6 +185,7 @@ typedef struct #error NUM_USB_CHAN > 18 #endif STR_TABLE_ENTRY(iAPInterfaceStr); + STR_TABLE_ENTRY(iAP_EANative_InterfaceStr); } StringDescTable_t; StringDescTable_t g_strTable = @@ -587,6 +601,7 @@ StringDescTable_t g_strTable = #error NUM_USB_CHAN > 18 #endif .iAPInterfaceStr = "iAP Interface", + .iAP_EANative_InterfaceStr = IAP_EA_NATIVE_PROTOCOL_NAME, }; @@ -609,6 +624,9 @@ enum USBInterfaceNumber #endif #if defined(IAP) && (IAP != 0) INTERFACE_NUMBER_IAP, +#if defined(IAP_EA_NATIVE) && (IAP_EA_NATIVE != 0) + INTERFACE_NUMBER_IAP_EA_NATIVE, +#endif #endif #if defined(HID_CONTROLS) && (HID_CONTROLS != 0) INTERFACE_NUMBER_HID, @@ -625,19 +643,21 @@ enum USBInterfaceNumber #endif /* Endpoint address defines */ -#define ENDPOINT_ADDRESS_IN_CONTROL (ENDPOINT_NUMBER_IN_CONTROL | 0x80) -#define ENDPOINT_ADDRESS_IN_FEEDBACK (ENDPOINT_NUMBER_IN_FEEDBACK | 0x80) -#define ENDPOINT_ADDRESS_IN_AUDIO (ENDPOINT_NUMBER_IN_AUDIO | 0x80) -#define ENDPOINT_ADDRESS_IN_INTERRUPT (ENDPOINT_NUMBER_IN_INTERRUPT | 0x80) -#define ENDPOINT_ADDRESS_IN_MIDI (ENDPOINT_NUMBER_IN_MIDI | 0x80) -#define ENDPOINT_ADDRESS_IN_HID (ENDPOINT_NUMBER_IN_HID | 0x80) -#define ENDPOINT_ADDRESS_IN_IAP_INT (ENDPOINT_NUMBER_IN_IAP_INT | 0x80) -#define ENDPOINT_ADDRESS_IN_IAP (ENDPOINT_NUMBER_IN_IAP | 0x80) +#define ENDPOINT_ADDRESS_IN_CONTROL (ENDPOINT_NUMBER_IN_CONTROL | 0x80) +#define ENDPOINT_ADDRESS_IN_FEEDBACK (ENDPOINT_NUMBER_IN_FEEDBACK | 0x80) +#define ENDPOINT_ADDRESS_IN_AUDIO (ENDPOINT_NUMBER_IN_AUDIO | 0x80) +#define ENDPOINT_ADDRESS_IN_INTERRUPT (ENDPOINT_NUMBER_IN_INTERRUPT | 0x80) +#define ENDPOINT_ADDRESS_IN_MIDI (ENDPOINT_NUMBER_IN_MIDI | 0x80) +#define ENDPOINT_ADDRESS_IN_HID (ENDPOINT_NUMBER_IN_HID | 0x80) +#define ENDPOINT_ADDRESS_IN_IAP_INT (ENDPOINT_NUMBER_IN_IAP_INT | 0x80) +#define ENDPOINT_ADDRESS_IN_IAP (ENDPOINT_NUMBER_IN_IAP | 0x80) +#define ENDPOINT_ADDRESS_IN_IAP_EA_NATIVE (ENDPOINT_NUMBER_IN_IAP_EA_NATIVE | 0x80) -#define ENDPOINT_ADDRESS_OUT_CONTROL (ENDPOINT_NUMBER_OUT_CONTROL) -#define ENDPOINT_ADDRESS_OUT_AUDIO (ENDPOINT_NUMBER_OUT_AUDIO) -#define ENDPOINT_ADDRESS_OUT_MIDI (ENDPOINT_NUMBER_OUT_MIDI) -#define ENDPOINT_ADDRESS_OUT_IAP (ENDPOINT_NUMBER_OUT_IAP) +#define ENDPOINT_ADDRESS_OUT_CONTROL (ENDPOINT_NUMBER_OUT_CONTROL) +#define ENDPOINT_ADDRESS_OUT_AUDIO (ENDPOINT_NUMBER_OUT_AUDIO) +#define ENDPOINT_ADDRESS_OUT_MIDI (ENDPOINT_NUMBER_OUT_MIDI) +#define ENDPOINT_ADDRESS_OUT_IAP (ENDPOINT_NUMBER_OUT_IAP) +#define ENDPOINT_ADDRESS_OUT_IAP_EA_NATIVE (ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE) /***** Device Descriptors *****/ @@ -919,6 +939,12 @@ typedef struct #ifdef IAP_INT_EP USB_Descriptor_Endpoint_t iAP_Interrupt_Endpoint; #endif +#ifdef IAP_EA_NATIVE + USB_Descriptor_Interface_t iAP_EANativeTransport_Interface_Alt0; + USB_Descriptor_Interface_t iAP_EANativeTransport_Interface_Alt1; + USB_Descriptor_Endpoint_t iAP_EANatvieTransport_Out_Endpoint; + USB_Descriptor_Endpoint_t iAP_EANativeTransport_In_Endpoint; +#endif #endif #ifdef HID_CONTROLS @@ -1839,6 +1865,59 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= 0x08, /* 6 bInterval : (2^(bInterval-1))/8 ms. Must be between 4 and 32ms (field size 1 bytes) */ }, #endif +#ifdef IAP_EA_NATIVE + /* Zero bandwidth alternative 0 */ + /* iAP EA Native Transport Interface descriptor */ + .iAP_EANativeTransport_Interface_Alt0 = + { + .bLength = sizeof(USB_Descriptor_Interface_t), + .bDescriptorType = USB_DESCTYPE_INTERFACE, + .bInterfaceNumber = INTERFACE_NUMBER_IAP_EA_NATIVE, + .bAlternateSetting = 0x00, + .bNumEndpoints = 0x00, + .bInterfaceClass = USB_CLASS_VENDOR_SPECIFIC, + .bInterfaceSubClass = 0xF0, /* MFI Accessory (Table 21-2) */ + .bInterfaceProtocol = 0x01, + .iInterface = offsetof(StringDescTable_t, iAP_EANative_InterfaceStr)/sizeof(char *), + }, + + /* Alternative 1 */ + /* iAP EA Native Transport Interface descriptor */ + .iAP_EANativeTransport_Interface_Alt1 = + { + .bLength = sizeof(USB_Descriptor_Interface_t), + .bDescriptorType = USB_DESCTYPE_INTERFACE, + .bInterfaceNumber = INTERFACE_NUMBER_IAP_EA_NATIVE, + .bAlternateSetting = 0x01, + .bNumEndpoints = 0x02, + .bInterfaceClass = USB_CLASS_VENDOR_SPECIFIC, + .bInterfaceSubClass = 0xF0, /* MFI Accessory (Table 21-1) */ + .bInterfaceProtocol = 0x01, + .iInterface = offsetof(StringDescTable_t, iAP_EANative_InterfaceStr)/sizeof(char *), + }, + + /* iAP EA Native Transport Bulk OUT Endpoint Descriptor */ + .iAP_Out_Endpoint = + { + 0x07, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ + 0x05, /* 1 bDescriptorType : ENDPOINT descriptor. (field size 1 bytes) */ + ENDPOINT_ADDRESS_OUT_IAP_EA_NATIVE, /* 2 bEndpointAddress : OUT Endpoint 3. High bit isIn (field size 1 bytes) */ + 0x02, /* 3 bmAttributes : Bulk, not shared. (field size 1 bytes) */ + 0x0200, //TODO check this /* 4 wMaxPacketSize : Has to be 0x200 for compliance*/ + 0x00, /* 6 bInterval : Ignored for Bulk. Set to zero. (field size 1 bytes) */ + }, + + /* iAP EA Native Transport Bulk IN Endpoint Descriptor */ + .iAP_In_Endpoint = + { + 0x07, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ + 0x05, /* 1 bDescriptorType : ENDPOINT descriptor. (field size 1 bytes) */ + ENDPOINT_ADDRESS_IN_IAP_EA_NATIVE, /* 2 bEndpointAddress : OUT Endpoint 3. High bit isIn (field size 1 bytes) */ + 0x02, /* 3 bmAttributes : Bulk, not shared. (field size 1 bytes) */ + 0x0200, //TODO check this /* 4 wMaxPacketSize : Has to be 0x200 for compliance*/ + 0x00, /* 6 bInterval : Ignored for Bulk. Set to zero. (field size 1 bytes) */ + }, +#endif #endif /* IAP */ #ifdef HID_CONTROLS From 46a31e7475c68605353904504ef420403eba6255 Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Fri, 13 Jun 2014 18:35:43 +0100 Subject: [PATCH 04/48] Use correct struct names for iAP EA Native Transport EPs --- module_usb_audio/endpoint0/descriptors.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index f2f57a4f..3c1c035f 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -942,7 +942,7 @@ typedef struct #ifdef IAP_EA_NATIVE USB_Descriptor_Interface_t iAP_EANativeTransport_Interface_Alt0; USB_Descriptor_Interface_t iAP_EANativeTransport_Interface_Alt1; - USB_Descriptor_Endpoint_t iAP_EANatvieTransport_Out_Endpoint; + USB_Descriptor_Endpoint_t iAP_EANativeTransport_Out_Endpoint; USB_Descriptor_Endpoint_t iAP_EANativeTransport_In_Endpoint; #endif #endif @@ -1897,7 +1897,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= }, /* iAP EA Native Transport Bulk OUT Endpoint Descriptor */ - .iAP_Out_Endpoint = + .iAP_EANativeTransport_Out_Endpoint = { 0x07, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ 0x05, /* 1 bDescriptorType : ENDPOINT descriptor. (field size 1 bytes) */ @@ -1908,7 +1908,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= }, /* iAP EA Native Transport Bulk IN Endpoint Descriptor */ - .iAP_In_Endpoint = + .iAP_EANativeTransport_In_Endpoint = { 0x07, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ 0x05, /* 1 bDescriptorType : ENDPOINT descriptor. (field size 1 bytes) */ From 87641ac724635dd7cf31897a075abaab5580cf3d Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Fri, 13 Jun 2014 18:42:06 +0100 Subject: [PATCH 05/48] Improved consistency of iAP EA Native Transport interface string name --- module_usb_audio/endpoint0/descriptors.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index 3c1c035f..111a7673 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -185,7 +185,7 @@ typedef struct #error NUM_USB_CHAN > 18 #endif STR_TABLE_ENTRY(iAPInterfaceStr); - STR_TABLE_ENTRY(iAP_EANative_InterfaceStr); + STR_TABLE_ENTRY(iAP_EANativeTransport_InterfaceStr); } StringDescTable_t; StringDescTable_t g_strTable = @@ -601,7 +601,7 @@ StringDescTable_t g_strTable = #error NUM_USB_CHAN > 18 #endif .iAPInterfaceStr = "iAP Interface", - .iAP_EANative_InterfaceStr = IAP_EA_NATIVE_PROTOCOL_NAME, + .iAP_EANativeTransport_InterfaceStr = IAP_EA_NATIVE_PROTOCOL_NAME, }; @@ -1878,7 +1878,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .bInterfaceClass = USB_CLASS_VENDOR_SPECIFIC, .bInterfaceSubClass = 0xF0, /* MFI Accessory (Table 21-2) */ .bInterfaceProtocol = 0x01, - .iInterface = offsetof(StringDescTable_t, iAP_EANative_InterfaceStr)/sizeof(char *), + .iInterface = offsetof(StringDescTable_t, iAP_EANativeTransport_InterfaceStr)/sizeof(char *), }, /* Alternative 1 */ @@ -1893,7 +1893,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= .bInterfaceClass = USB_CLASS_VENDOR_SPECIFIC, .bInterfaceSubClass = 0xF0, /* MFI Accessory (Table 21-1) */ .bInterfaceProtocol = 0x01, - .iInterface = offsetof(StringDescTable_t, iAP_EANative_InterfaceStr)/sizeof(char *), + .iInterface = offsetof(StringDescTable_t, iAP_EANativeTransport_InterfaceStr)/sizeof(char *), }, /* iAP EA Native Transport Bulk OUT Endpoint Descriptor */ From 1bbee4b977b1c9519a1c0db07db9d34a0cc39e83 Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Fri, 13 Jun 2014 18:47:10 +0100 Subject: [PATCH 06/48] IAP_EA_NATIVE -> IAP_EA_NATIVE_TRANS --- module_usb_audio/devicedefines.h | 12 ++-- module_usb_audio/endpoint0/descriptors.h | 72 ++++++++++++------------ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/module_usb_audio/devicedefines.h b/module_usb_audio/devicedefines.h index c656db6f..ff82e572 100644 --- a/module_usb_audio/devicedefines.h +++ b/module_usb_audio/devicedefines.h @@ -903,8 +903,8 @@ #endif /* IAP EA Native Transport */ -#if defined(IAP_EA_NATIVE) && (IAP_EA_NATIVE == 0) -#undef IAP_EA_NATIVE +#if defined(IAP_EA_NATIVE_TRANS) && (IAP_EA_NATIVE_TRANS == 0) +#undef IAP_EA_NATIVE_TRANS #endif /* Endpoint addresses enums */ @@ -927,8 +927,8 @@ enum USBEndpointNumber_In ENDPOINT_NUMBER_IN_IAP_INT, #endif ENDPOINT_NUMBER_IN_IAP, -#ifdef IAP_EA_NATIVE - ENDPOINT_NUMBER_IN_IAP_EA_NATIVE, +#ifdef IAP_EA_NATIVE_TRANS + ENDPOINT_NUMBER_IN_IAP_EA_NATIVE_TRANS, #endif #endif ENDPOINT_COUNT_IN /* End marker */ @@ -943,8 +943,8 @@ enum USBEndpointNumber_Out #endif #ifdef IAP ENDPOINT_NUMBER_OUT_IAP, -#ifdef IAP_EA_NATIVE - ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE, +#ifdef IAP_EA_NATIVE_TRANS + ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS, #endif #endif ENDPOINT_COUNT_OUT /* End marker */ diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index 111a7673..6725a9db 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -12,9 +12,9 @@ #include "usbaudiocommon.h" #include "usb_std_descriptors.h" -#ifdef IAP_EA_NATIVE +#ifdef IAP_EA_NATIVE_TRANS /* - * FIXME currently this will not build if IAP_EA_NATIVE_PROTOCOL_NAME is not defined in iap_conf.h, + * FIXME currently this will not build if IAP_EA_NATIVE_TRANS_PROTOCOL_NAME is not defined in iap_conf.h, * would be nice if a default string was used instead, and a warning issued. * * Could get a default define by including the following line, but iap2.h cannot currently be included from C @@ -600,8 +600,8 @@ StringDescTable_t g_strTable = #if (NUM_USB_CHAN_IN > 18) #error NUM_USB_CHAN > 18 #endif - .iAPInterfaceStr = "iAP Interface", - .iAP_EANativeTransport_InterfaceStr = IAP_EA_NATIVE_PROTOCOL_NAME, + .iAPInterfaceStr = "iAP Interface", + .iAP_EANativeTransport_InterfaceStr = IAP_EA_NATIVE_TRANS_PROTOCOL_NAME, }; @@ -624,8 +624,8 @@ enum USBInterfaceNumber #endif #if defined(IAP) && (IAP != 0) INTERFACE_NUMBER_IAP, -#if defined(IAP_EA_NATIVE) && (IAP_EA_NATIVE != 0) - INTERFACE_NUMBER_IAP_EA_NATIVE, +#if defined(IAP_EA_NATIVE_TRANS) && (IAP_EA_NATIVE_TRANS != 0) + INTERFACE_NUMBER_IAP_EA_NATIVE_TRANS, #endif #endif #if defined(HID_CONTROLS) && (HID_CONTROLS != 0) @@ -643,21 +643,21 @@ enum USBInterfaceNumber #endif /* Endpoint address defines */ -#define ENDPOINT_ADDRESS_IN_CONTROL (ENDPOINT_NUMBER_IN_CONTROL | 0x80) -#define ENDPOINT_ADDRESS_IN_FEEDBACK (ENDPOINT_NUMBER_IN_FEEDBACK | 0x80) -#define ENDPOINT_ADDRESS_IN_AUDIO (ENDPOINT_NUMBER_IN_AUDIO | 0x80) -#define ENDPOINT_ADDRESS_IN_INTERRUPT (ENDPOINT_NUMBER_IN_INTERRUPT | 0x80) -#define ENDPOINT_ADDRESS_IN_MIDI (ENDPOINT_NUMBER_IN_MIDI | 0x80) -#define ENDPOINT_ADDRESS_IN_HID (ENDPOINT_NUMBER_IN_HID | 0x80) -#define ENDPOINT_ADDRESS_IN_IAP_INT (ENDPOINT_NUMBER_IN_IAP_INT | 0x80) -#define ENDPOINT_ADDRESS_IN_IAP (ENDPOINT_NUMBER_IN_IAP | 0x80) -#define ENDPOINT_ADDRESS_IN_IAP_EA_NATIVE (ENDPOINT_NUMBER_IN_IAP_EA_NATIVE | 0x80) +#define ENDPOINT_ADDRESS_IN_CONTROL (ENDPOINT_NUMBER_IN_CONTROL | 0x80) +#define ENDPOINT_ADDRESS_IN_FEEDBACK (ENDPOINT_NUMBER_IN_FEEDBACK | 0x80) +#define ENDPOINT_ADDRESS_IN_AUDIO (ENDPOINT_NUMBER_IN_AUDIO | 0x80) +#define ENDPOINT_ADDRESS_IN_INTERRUPT (ENDPOINT_NUMBER_IN_INTERRUPT | 0x80) +#define ENDPOINT_ADDRESS_IN_MIDI (ENDPOINT_NUMBER_IN_MIDI | 0x80) +#define ENDPOINT_ADDRESS_IN_HID (ENDPOINT_NUMBER_IN_HID | 0x80) +#define ENDPOINT_ADDRESS_IN_IAP_INT (ENDPOINT_NUMBER_IN_IAP_INT | 0x80) +#define ENDPOINT_ADDRESS_IN_IAP (ENDPOINT_NUMBER_IN_IAP | 0x80) +#define ENDPOINT_ADDRESS_IN_IAP_EA_NATIVE_TRANS (ENDPOINT_NUMBER_IN_IAP_EA_NATIVE_TRANS | 0x80) -#define ENDPOINT_ADDRESS_OUT_CONTROL (ENDPOINT_NUMBER_OUT_CONTROL) -#define ENDPOINT_ADDRESS_OUT_AUDIO (ENDPOINT_NUMBER_OUT_AUDIO) -#define ENDPOINT_ADDRESS_OUT_MIDI (ENDPOINT_NUMBER_OUT_MIDI) -#define ENDPOINT_ADDRESS_OUT_IAP (ENDPOINT_NUMBER_OUT_IAP) -#define ENDPOINT_ADDRESS_OUT_IAP_EA_NATIVE (ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE) +#define ENDPOINT_ADDRESS_OUT_CONTROL (ENDPOINT_NUMBER_OUT_CONTROL) +#define ENDPOINT_ADDRESS_OUT_AUDIO (ENDPOINT_NUMBER_OUT_AUDIO) +#define ENDPOINT_ADDRESS_OUT_MIDI (ENDPOINT_NUMBER_OUT_MIDI) +#define ENDPOINT_ADDRESS_OUT_IAP (ENDPOINT_NUMBER_OUT_IAP) +#define ENDPOINT_ADDRESS_OUT_IAP_EA_NATIVE_TRANS (ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS) /***** Device Descriptors *****/ @@ -939,7 +939,7 @@ typedef struct #ifdef IAP_INT_EP USB_Descriptor_Endpoint_t iAP_Interrupt_Endpoint; #endif -#ifdef IAP_EA_NATIVE +#ifdef IAP_EA_NATIVE_TRANS USB_Descriptor_Interface_t iAP_EANativeTransport_Interface_Alt0; USB_Descriptor_Interface_t iAP_EANativeTransport_Interface_Alt1; USB_Descriptor_Endpoint_t iAP_EANativeTransport_Out_Endpoint; @@ -1865,14 +1865,14 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= 0x08, /* 6 bInterval : (2^(bInterval-1))/8 ms. Must be between 4 and 32ms (field size 1 bytes) */ }, #endif -#ifdef IAP_EA_NATIVE +#ifdef IAP_EA_NATIVE_TRANS /* Zero bandwidth alternative 0 */ /* iAP EA Native Transport Interface descriptor */ .iAP_EANativeTransport_Interface_Alt0 = { .bLength = sizeof(USB_Descriptor_Interface_t), .bDescriptorType = USB_DESCTYPE_INTERFACE, - .bInterfaceNumber = INTERFACE_NUMBER_IAP_EA_NATIVE, + .bInterfaceNumber = INTERFACE_NUMBER_IAP_EA_NATIVE_TRANS, .bAlternateSetting = 0x00, .bNumEndpoints = 0x00, .bInterfaceClass = USB_CLASS_VENDOR_SPECIFIC, @@ -1887,7 +1887,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= { .bLength = sizeof(USB_Descriptor_Interface_t), .bDescriptorType = USB_DESCTYPE_INTERFACE, - .bInterfaceNumber = INTERFACE_NUMBER_IAP_EA_NATIVE, + .bInterfaceNumber = INTERFACE_NUMBER_IAP_EA_NATIVE_TRANS, .bAlternateSetting = 0x01, .bNumEndpoints = 0x02, .bInterfaceClass = USB_CLASS_VENDOR_SPECIFIC, @@ -1899,23 +1899,23 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= /* iAP EA Native Transport Bulk OUT Endpoint Descriptor */ .iAP_EANativeTransport_Out_Endpoint = { - 0x07, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ - 0x05, /* 1 bDescriptorType : ENDPOINT descriptor. (field size 1 bytes) */ - ENDPOINT_ADDRESS_OUT_IAP_EA_NATIVE, /* 2 bEndpointAddress : OUT Endpoint 3. High bit isIn (field size 1 bytes) */ - 0x02, /* 3 bmAttributes : Bulk, not shared. (field size 1 bytes) */ - 0x0200, //TODO check this /* 4 wMaxPacketSize : Has to be 0x200 for compliance*/ - 0x00, /* 6 bInterval : Ignored for Bulk. Set to zero. (field size 1 bytes) */ + 0x07, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ + 0x05, /* 1 bDescriptorType : ENDPOINT descriptor. (field size 1 bytes) */ + ENDPOINT_ADDRESS_OUT_IAP_EA_NATIVE_TRANS, /* 2 bEndpointAddress : OUT Endpoint 3. High bit isIn (field size 1 bytes) */ + 0x02, /* 3 bmAttributes : Bulk, not shared. (field size 1 bytes) */ + 0x0200, //TODO check this /* 4 wMaxPacketSize : Has to be 0x200 for compliance*/ + 0x00, /* 6 bInterval : Ignored for Bulk. Set to zero. (field size 1 bytes) */ }, /* iAP EA Native Transport Bulk IN Endpoint Descriptor */ .iAP_EANativeTransport_In_Endpoint = { - 0x07, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ - 0x05, /* 1 bDescriptorType : ENDPOINT descriptor. (field size 1 bytes) */ - ENDPOINT_ADDRESS_IN_IAP_EA_NATIVE, /* 2 bEndpointAddress : OUT Endpoint 3. High bit isIn (field size 1 bytes) */ - 0x02, /* 3 bmAttributes : Bulk, not shared. (field size 1 bytes) */ - 0x0200, //TODO check this /* 4 wMaxPacketSize : Has to be 0x200 for compliance*/ - 0x00, /* 6 bInterval : Ignored for Bulk. Set to zero. (field size 1 bytes) */ + 0x07, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ + 0x05, /* 1 bDescriptorType : ENDPOINT descriptor. (field size 1 bytes) */ + ENDPOINT_ADDRESS_IN_IAP_EA_NATIVE_TRANS, /* 2 bEndpointAddress : OUT Endpoint 3. High bit isIn (field size 1 bytes) */ + 0x02, /* 3 bmAttributes : Bulk, not shared. (field size 1 bytes) */ + 0x0200, //TODO check this /* 4 wMaxPacketSize : Has to be 0x200 for compliance*/ + 0x00, /* 6 bInterval : Ignored for Bulk. Set to zero. (field size 1 bytes) */ }, #endif #endif /* IAP */ From 012f4fbba3cd3d83c8b6641e478d7e36ea756a55 Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Wed, 18 Jun 2014 10:57:29 +0100 Subject: [PATCH 07/48] Avoid error on non iAP EAP builds --- module_usb_audio/endpoint0/descriptors.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index 6725a9db..ccb92a1d 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -601,8 +601,9 @@ StringDescTable_t g_strTable = #error NUM_USB_CHAN > 18 #endif .iAPInterfaceStr = "iAP Interface", +#ifdef IAP_EA_NATIVE_TRANS .iAP_EANativeTransport_InterfaceStr = IAP_EA_NATIVE_TRANS_PROTOCOL_NAME, - +#endif }; /* Interface numbers enum */ From 5f9c699be4b5aa98fe7c963c1e3caf3e2325bbf3 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 15 Jul 2014 12:05:29 +0100 Subject: [PATCH 08/48] Fixed mixer build and run-time issues --- module_usb_audio/endpoint0/audiorequests.xc | 43 ++++---- module_usb_audio/endpoint0/endpoint0.c | 4 - module_usb_audio/mixer/mixer.xc | 103 ++++++++++++-------- 3 files changed, 82 insertions(+), 68 deletions(-) diff --git a/module_usb_audio/endpoint0/audiorequests.xc b/module_usb_audio/endpoint0/audiorequests.xc index 6accd883..9eb8c7ba 100644 --- a/module_usb_audio/endpoint0/audiorequests.xc +++ b/module_usb_audio/endpoint0/audiorequests.xc @@ -36,12 +36,8 @@ extern unsigned char mixer1Crossbar[]; extern short mixer1Weights[]; /* Device channel mapping */ -#if NUM_USB_CHAN_OUT > 0 extern unsigned char channelMapAud[NUM_USB_CHAN_OUT]; -#endif -#if NUM_USB_CHAN_IN > 0 extern unsigned char channelMapUsb[NUM_USB_CHAN_IN]; -#endif /* Mixer input mapping */ extern unsigned char mixSel[MIX_INPUTS]; @@ -605,10 +601,11 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c unsigned volume = 0; int c = sp.wValue & 0xff; - loop = XUD_GetBuffer(ep0_out, buffer); - if(loop < 0) - return loop; + if((result = XUD_GetBuffer(ep0_out, buffer, datalength)) != XUD_RES_OKAY) + { + return result; + } channelMapAud[c] = buffer[0] | buffer[1] << 8; @@ -643,10 +640,10 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c unsigned volume = 0; int c = sp.wValue & 0xff; - loop = XUD_GetBuffer(ep0_out, buffer); - - if(loop < 0) - return loop; + if((result = XUD_GetBuffer(ep0_out, buffer, datalength)) != XUD_RES_OKAY) + { + return result; + } channelMapUsb[c] = buffer[0] | buffer[1] << 8; @@ -677,14 +674,13 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c int cn = sp.wValue & 0xff; /* Channel number */ /* Check for Get or Set */ - if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_OUT) + if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_H2D) { /* Direction: Host-to-device */ /* Host-to-device */ - datalength = XUD_GetBuffer(ep0_out, buffer); - - /* Check for reset */ - if(datalength < 0) - return datalength; + if((result = XUD_GetBuffer(ep0_out, buffer, datalength)) != XUD_RES_OKAY) + { + return result; + } if(datalength > 0) { @@ -734,14 +730,15 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c case ID_MIXER_1: - if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_OUT) /* Direction: Host-to-device */ + if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_H2D) /* Direction: Host-to-device */ { unsigned volume = 0; - /* Expect OUT here with mute */ - loop = XUD_GetBuffer(ep0_out, buffer); - if(loop < 0) - return loop; + /* Expect OUT here with mute */ + if((result = XUD_GetBuffer(ep0_out, buffer, datalength)) != XUD_RES_OKAY) + { + return result; + } mixer1Weights[sp.wValue & 0xff] = buffer[0] | buffer[1] << 8; @@ -906,7 +903,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c { case ID_MIXER_1: - if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_IN) + if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_D2H) { int length = 0; diff --git a/module_usb_audio/endpoint0/endpoint0.c b/module_usb_audio/endpoint0/endpoint0.c index cbc9d77c..33bc6298 100755 --- a/module_usb_audio/endpoint0/endpoint0.c +++ b/module_usb_audio/endpoint0/endpoint0.c @@ -76,12 +76,8 @@ unsigned char mixer1Crossbar[18]; short mixer1Weights[18*8]; unsigned char channelMap[NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + MAX_MIX_COUNT]; -#if (NUM_USB_CHAN_OUT > 0) unsigned char channelMapAud[NUM_USB_CHAN_OUT]; -#endif -#if (NUM_USB_CHAN_IN > 0) unsigned char channelMapUsb[NUM_USB_CHAN_IN]; -#endif unsigned char mixSel[MIX_INPUTS]; #endif diff --git a/module_usb_audio/mixer/mixer.xc b/module_usb_audio/mixer/mixer.xc index f85aefe9..2a517f0f 100644 --- a/module_usb_audio/mixer/mixer.xc +++ b/module_usb_audio/mixer/mixer.xc @@ -117,7 +117,7 @@ int doMix8(xc_ptr samples, xc_ptr mult); /* DO NOT inline, causes 10.4.2 tools to add extra loads in loop */ /* At 18 x 12dB we could get 64 x bigger */ #pragma unsafe arrays -static int doMix(xc_ptr samples, xc_ptr ptr, xc_ptr mult) +static inline int doMix(xc_ptr samples, xc_ptr ptr, xc_ptr mult) { int h=0; int l=0; @@ -153,7 +153,7 @@ static int doMix(xc_ptr samples, xc_ptr ptr, xc_ptr mult) #endif #pragma unsafe arrays -static void giveSamplesToHost(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr multIn) +static inline void giveSamplesToHost(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr multIn) { #if defined(IN_VOLUME_IN_MIXER) && defined(IN_VOLUME_AFTER_MIX) int mult; @@ -186,7 +186,7 @@ static void giveSamplesToHost(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr mult } #pragma unsafe arrays -static void getSamplesFromHost(chanend c, xc_ptr samples, int base, unsigned underflow) +static inline void getSamplesFromHost(chanend c, xc_ptr samples, int base, unsigned underflow) { if(!underflow) { @@ -227,7 +227,7 @@ static void getSamplesFromHost(chanend c, xc_ptr samples, int base, unsigned und } #pragma unsafe arrays -static void giveSamplesToDevice(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr multOut, unsigned underflow) +static inline void giveSamplesToDevice(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr multOut, unsigned underflow) { outuint(c, underflow); @@ -265,7 +265,7 @@ static void giveSamplesToDevice(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr mu } #pragma unsafe arrays -static void getSamplesFromDevice(chanend c, xc_ptr samples, int base) +static inline void getSamplesFromDevice(chanend c, xc_ptr samples, int base) { #if defined(IN_VOLUME_IN_MIXER) && !defined(IN_VOLUME_AFTER_MIX) int mult; @@ -475,12 +475,12 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2) { unsigned underflow = inuint(c_host); #if MAX_MIX_COUNT > 0 - outuint(c_mixer2, 0); + outuint(c_mixer2, underflow); giveSamplesToHost(c_host, samples, samples_to_host_map, multIn); outuint(c_mixer2, 0); inuint(c_mixer2); - getSamplesFromHost(c_host, samples, 0); + getSamplesFromHost(c_host, samples, 0, underflow); outuint(c_mixer2, 0); inuint(c_mixer2); #ifdef FAST_MIXER @@ -555,44 +555,65 @@ static int mixer2_mix2_flag = (DEFAULT_FREQ > 96000); #pragma unsafe arrays static void mixer2(chanend c_mixer1, chanend c_audio) { - int mixed; + int mixed; + unsigned underflow = 0; - while (1) { - outuint(c_mixer1, 0); -#pragma xta endpoint "mixer2_req" - inuint(c_audio); - if(testct(c_mixer1)) + while (1) { - int sampFreq; -#pragma xta endpoint "mixer2_rate_change" - inct(c_mixer1); - sampFreq = inuint(c_mixer1); - - - mixer2_mix2_flag = sampFreq > 96000; - - for (int i=0;i 96000; + + /* Inform mixer2 (or audio()) about freq change */ + outct(c_audio, command); + outuint(c_audio, sampFreq); + break; + + case SET_STREAM_FORMAT_OUT: + case SET_STREAM_FORMAT_IN: + /* Inform mixer2 (or audio()) about format change */ + outct(c_audio, command); + outuint(c_audio, inuint(c_mixer1)); + outuint(c_audio, inuint(c_mixer1)); + break; + + default: + break; + } + + for (int i=0;i 1 #ifdef FAST_MIXER mixed = doMix1(samples, mix_mult_slice(1)); From a84ed67cd50967ec35c0ae50c15b254549558b0a Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Tue, 29 Jul 2014 15:12:19 +0100 Subject: [PATCH 09/48] Added define for the number of alternative settings on the iAP EA Native Transport interface --- module_usb_audio/devicedefines.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/module_usb_audio/devicedefines.h b/module_usb_audio/devicedefines.h index ff82e572..bfaa908c 100644 --- a/module_usb_audio/devicedefines.h +++ b/module_usb_audio/devicedefines.h @@ -907,6 +907,22 @@ #undef IAP_EA_NATIVE_TRANS #endif +#if defined(IAP_EA_NATIVE_TRANS) || defined(__DOXYGEN__) +/** + * @brief Number of supported EA Native Interface Alternative settings. + * + * Only 1 supported + */ +#ifndef IAP_EA_NATIVE_TRANS_ALT_COUNT + #define IAP_EA_NATIVE_TRANS_ALT_COUNT 1 +#endif + +#if (IAP_EA_NATIVE_TRANS_ALT_COUNT > 1) + /* Only 1 supported */ + #error +#endif +#endif + /* Endpoint addresses enums */ enum USBEndpointNumber_In { From cbe78f355c6733f969dc0fa07be951f6110c48ee Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Tue, 29 Jul 2014 15:14:24 +0100 Subject: [PATCH 10/48] iAP EA Native Transport Eps added to epTypeTables --- module_usb_audio/main.xc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/module_usb_audio/main.xc b/module_usb_audio/main.xc index 5559f4ad..bac09ed6 100755 --- a/module_usb_audio/main.xc +++ b/module_usb_audio/main.xc @@ -180,7 +180,10 @@ XUD_EpType epTypeTableOut[ENDPOINT_COUNT_OUT] = { XUD_EPTYPE_CTL | XUD_STATUS_EN XUD_EPTYPE_BUL, /* MIDI */ #endif #ifdef IAP - XUD_EPTYPE_BUL /* iAP */ + XUD_EPTYPE_BUL, /* iAP */ +#ifdef IAP_EA_NATIVE_TRANS + XUD_EPTYPE_BUL, /* EA Native Transport */ +#endif #endif }; @@ -201,6 +204,9 @@ XUD_EpType epTypeTableIn[ENDPOINT_COUNT_IN] = { XUD_EPTYPE_CTL | XUD_STATUS_ENAB #ifdef IAP_INT_EP XUD_EPTYPE_BUL | XUD_STATUS_ENABLE, #endif +#ifdef IAP_EA_NATIVE_TRANS + XUD_EPTYPE_BUL | XUD_STATUS_ENABLE, +#endif #endif }; From 201c899f237c458120d65ce43bc50004e5fd7f30 Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Tue, 29 Jul 2014 15:22:51 +0100 Subject: [PATCH 11/48] EP0 changed to use switch statement when handling USB_SET_INTERFACE requests --- module_usb_audio/endpoint0/endpoint0.c | 182 +++++++++++++------------ 1 file changed, 96 insertions(+), 86 deletions(-) diff --git a/module_usb_audio/endpoint0/endpoint0.c b/module_usb_audio/endpoint0/endpoint0.c index cbc9d77c..ce16785b 100755 --- a/module_usb_audio/endpoint0/endpoint0.c +++ b/module_usb_audio/endpoint0/endpoint0.c @@ -268,102 +268,112 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, /* Over-riding USB_StandardRequests implementation */ if(sp.bRequest == USB_SET_INTERFACE) { - /* Check for audio stream from host start/stop */ - if(sp.wIndex == 1) /* Output interface */ + switch (sp.wIndex) { - /* Check the alt is in range */ - if(sp.wValue <= OUTPUT_FORMAT_COUNT) - { - /* Alt 0 is stream stop */ - /* Only send change if we need to */ - if((sp.wValue > 0) && (g_curStreamAlt_Out != sp.wValue)) + /* Check for audio stream from host start/stop */ + case INTERFACE_NUMBER_AUDIO_OUTPUT: + /* Check the alt is in range */ + if(sp.wValue <= OUTPUT_FORMAT_COUNT) { - g_curStreamAlt_Out = sp.wValue; - - /* Send format of data onto buffering */ - outuint(c_audioControl, SET_STREAM_FORMAT_OUT); - outuint(c_audioControl, g_dataFormat_Out[sp.wValue-1]); /* Data format (PCM/DSD) */ - - if(g_curUsbSpeed == XUD_SPEED_HS) + /* Alt 0 is stream stop */ + /* Only send change if we need to */ + if((sp.wValue > 0) && (g_curStreamAlt_Out != sp.wValue)) { - outuint(c_audioControl, NUM_USB_CHAN_OUT); /* Channel count */ - outuint(c_audioControl, g_subSlot_Out_HS[sp.wValue-1]); /* Subslot */ - outuint(c_audioControl, g_sampRes_Out_HS[sp.wValue-1]); /* Resolution */ - } - else - { - outuint(c_audioControl, NUM_USB_CHAN_OUT_FS); /* Channel count */ - outuint(c_audioControl, g_subSlot_Out_FS[sp.wValue-1]); /* Subslot */ - outuint(c_audioControl, g_sampRes_Out_FS[sp.wValue-1]); /* Resolution */ - } + g_curStreamAlt_Out = sp.wValue; - /* Handshake */ - chkct(c_audioControl, XS1_CT_END); + /* Send format of data onto buffering */ + outuint(c_audioControl, SET_STREAM_FORMAT_OUT); + outuint(c_audioControl, g_dataFormat_Out[sp.wValue-1]); /* Data format (PCM/DSD) */ + + if(g_curUsbSpeed == XUD_SPEED_HS) + { + outuint(c_audioControl, NUM_USB_CHAN_OUT); /* Channel count */ + outuint(c_audioControl, g_subSlot_Out_HS[sp.wValue-1]); /* Subslot */ + outuint(c_audioControl, g_sampRes_Out_HS[sp.wValue-1]); /* Resolution */ + } + else + { + outuint(c_audioControl, NUM_USB_CHAN_OUT_FS); /* Channel count */ + outuint(c_audioControl, g_subSlot_Out_FS[sp.wValue-1]); /* Subslot */ + outuint(c_audioControl, g_sampRes_Out_FS[sp.wValue-1]); /* Resolution */ + } + + /* Handshake */ + chkct(c_audioControl, XS1_CT_END); + } } - } + break; + case INTERFACE_NUMBER_AUDIO_INPUT: + /* Check the alt is in range */ + if(sp.wValue <= INPUT_FORMAT_COUNT) + { + /* Alt 0 is stream stop */ + /* Only send change if we need to */ + if((sp.wValue > 0) && (g_curStreamAlt_In != sp.wValue)) + { + g_curStreamAlt_In = sp.wValue; + + /* Send format of data onto buffering */ + outuint(c_audioControl, SET_STREAM_FORMAT_IN); + outuint(c_audioControl, g_dataFormat_In[sp.wValue-1]); /* Data format (PCM/DSD) */ + + if(g_curUsbSpeed == XUD_SPEED_HS) + { + outuint(c_audioControl, NUM_USB_CHAN_IN); /* Channel count */ + outuint(c_audioControl, g_subSlot_In_HS[sp.wValue-1]); /* Subslot */ + outuint(c_audioControl, g_sampRes_In_HS[sp.wValue-1]); /* Resolution */ + } + else + { + outuint(c_audioControl, NUM_USB_CHAN_IN_FS); /* Channel count */ + outuint(c_audioControl, g_subSlot_In_FS[sp.wValue-1]); /* Subslot */ + outuint(c_audioControl, g_sampRes_In_FS[sp.wValue-1]); /* Resolution */ + } + + /* Handshake */ + chkct(c_audioControl, XS1_CT_END); + } + } + break; + { + + default: + /* Unhandled interface */ + break; } - else if(sp.wIndex == 2) /* Input interface */ + + if ((sp.wIndex == INTERFACE_NUMBER_AUDIO_OUTPUT) || (sp.wIndex == INTERFACE_NUMBER_AUDIO_INPUT)) { - /* Check the alt is in range */ - if(sp.wValue <= INPUT_FORMAT_COUNT) - { - /* Alt 0 is stream stop */ - /* Only send change if we need to */ - if((sp.wValue > 0) && (g_curStreamAlt_In != sp.wValue)) - { - g_curStreamAlt_In = sp.wValue; - - /* Send format of data onto buffering */ - outuint(c_audioControl, SET_STREAM_FORMAT_IN); - outuint(c_audioControl, g_dataFormat_In[sp.wValue-1]); /* Data format (PCM/DSD) */ - - if(g_curUsbSpeed == XUD_SPEED_HS) - { - outuint(c_audioControl, NUM_USB_CHAN_IN); /* Channel count */ - outuint(c_audioControl, g_subSlot_In_HS[sp.wValue-1]); /* Subslot */ - outuint(c_audioControl, g_sampRes_In_HS[sp.wValue-1]); /* Resolution */ - } - else - { - outuint(c_audioControl, NUM_USB_CHAN_IN_FS); /* Channel count */ - outuint(c_audioControl, g_subSlot_In_FS[sp.wValue-1]); /* Subslot */ - outuint(c_audioControl, g_sampRes_In_FS[sp.wValue-1]); /* Resolution */ - } - - /* Handshake */ - chkct(c_audioControl, XS1_CT_END); - } - } - } #if (NUM_USB_CHAN_OUT > 0) && (NUM_USB_CHAN_IN > 0) - /* Check for stream start stop on output and input audio interfaces */ - if(sp.wValue && !g_interfaceAlt[1] && !g_interfaceAlt[2]) - { - /* If start and input AND output not currently running */ - UserAudioStreamStart(); - } - else if(((sp.wIndex == 1) && (!sp.wValue)) && g_interfaceAlt[1] && (!g_interfaceAlt[2])) - { - /* if output stop and output running and input not running */ - UserAudioStreamStop(); - } - else if(((sp.wIndex == 2) && (!sp.wValue)) && g_interfaceAlt[2] && (!g_interfaceAlt[1])) - { - /* if input stop and input running and output not running */ - UserAudioStreamStop(); - } + /* Check for stream start stop on output and input audio interfaces */ + if(sp.wValue && !g_interfaceAlt[1] && !g_interfaceAlt[2]) + { + /* If start and input AND output not currently running */ + UserAudioStreamStart(); + } + else if(((sp.wIndex == 1) && (!sp.wValue)) && g_interfaceAlt[1] && (!g_interfaceAlt[2])) + { + /* if output stop and output running and input not running */ + UserAudioStreamStop(); + } + else if(((sp.wIndex == 2) && (!sp.wValue)) && g_interfaceAlt[2] && (!g_interfaceAlt[1])) + { + /* if input stop and input running and output not running */ + UserAudioStreamStop(); + } #elif (NUM_USB_CHAN_OUT > 0) || (NUM_USB_CHAN_IN > 0) - if(sp.wValue && (!g_interfaceAlt[1])) - { - /* if start and not currently running */ - UserAudioStreamStart(); - } - else if (!sp.wValue && g_interfaceAlt[1]) - { - /* if stop and currently running */ - UserAudioStreamStop(); - } + if(sp.wValue && (!g_interfaceAlt[1])) + { + /* if start and not currently running */ + UserAudioStreamStart(); + } + else if (!sp.wValue && g_interfaceAlt[1]) + { + /* if stop and currently running */ + UserAudioStreamStop(); + } #endif + } } /* if(sp.bRequest == SET_INTERFACE) */ break; /* BMREQ_H2D_STANDARD_INT */ From 0870c3edc8b430eb22e01df6f69466cb2b928749 Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Tue, 29 Jul 2014 15:24:21 +0100 Subject: [PATCH 12/48] Additional chanend passed to Endpoint0 for iAP EA Native Transport support --- module_usb_audio/endpoint0/endpoint0.c | 2 +- module_usb_audio/endpoint0/endpoint0.h | 5 ++++- module_usb_audio/main.xc | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/module_usb_audio/endpoint0/endpoint0.c b/module_usb_audio/endpoint0/endpoint0.c index ce16785b..e1591a55 100755 --- a/module_usb_audio/endpoint0/endpoint0.c +++ b/module_usb_audio/endpoint0/endpoint0.c @@ -159,7 +159,7 @@ const unsigned g_dataFormat_In[INPUT_FORMAT_COUNT] = {STREAM_FORMAT_INPUT_1_DATA /* Endpoint 0 function. Handles all requests to the device */ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, - chanend c_mix_ctl, chanend c_clk_ctl) + chanend c_mix_ctl, chanend c_clk_ctl, chanend c_EANativeTransport_ctrl) { USB_SetupPacket_t sp; XUD_ep ep0_out = XUD_InitEp(c_ep0_out); diff --git a/module_usb_audio/endpoint0/endpoint0.h b/module_usb_audio/endpoint0/endpoint0.h index be2171fa..778d0937 100644 --- a/module_usb_audio/endpoint0/endpoint0.h +++ b/module_usb_audio/endpoint0/endpoint0.h @@ -14,8 +14,11 @@ * \param c_clk_ctl Optional chanend to be connected to the clockgen thread if * present. * \param c_usb_test Optional chanend to be connected to XUD if test modes required. + * + * \param c_EANativeTransport_ctrl Optional chanend to be connected to EA Native + * endpoint manager if present */ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCtrl, - chanend ?c_mix_ctl,chanend ?c_clk_ctl); + chanend ?c_mix_ctl,chanend ?c_clk_ctl, chanend ?c_EANativeTransport_ctrl); #endif diff --git a/module_usb_audio/main.xc b/module_usb_audio/main.xc index bac09ed6..57db3a29 100755 --- a/module_usb_audio/main.xc +++ b/module_usb_audio/main.xc @@ -260,6 +260,12 @@ void usb_audio_core(chanend c_mix_out #ifndef MIXER #define c_mix_ctl null +#endif + +#ifdef IAP_EA_NATIVE_TRANS + chan c_EANativeTransport_ctrl; +#else +#define c_EANativeTransport_ctrl null #endif par @@ -326,7 +332,7 @@ void usb_audio_core(chanend c_mix_out /* Endpoint 0 Core */ { thread_speed(); - Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, null); + Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, null, c_EANativeTransport_ctrl); } /* Decoupling core */ From 73b2e5f27e41534499fcfc7917d3a51d7eadfa9e Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Tue, 29 Jul 2014 15:25:32 +0100 Subject: [PATCH 13/48] Endpoint0 now sends notification that the EA Native Transport interface alternative setting has changed --- module_usb_audio/endpoint0/endpoint0.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/module_usb_audio/endpoint0/endpoint0.c b/module_usb_audio/endpoint0/endpoint0.c index e1591a55..cfd28db4 100755 --- a/module_usb_audio/endpoint0/endpoint0.c +++ b/module_usb_audio/endpoint0/endpoint0.c @@ -335,8 +335,24 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, } } break; +#ifdef IAP_EA_NATIVE_TRANS + case INTERFACE_NUMBER_IAP_EA_NATIVE_TRANS: + /* Check the alt is in range */ + if (sp.wValue <= IAP_EA_NATIVE_TRANS_ALT_COUNT) //FIXME is this check required? + /* Alt 0 is EA Protocol stop */ + /* Only send change if we need to */ + //TODO if ((sp.wValue > 0) && g_eaNativeTransportAlt != sp.wValue))? { + //TODO g_eaNativeTransportAlt = sp.wValue;? + /* Send selected Alt interface number onto EA Native EP manager */ + outuint(c_EANativeTransport_ctrl, sp.wValue); + + /* Handshake */ + chkct(c_EANativeTransport_ctrl, XS1_CT_END); + } + break; +#endif default: /* Unhandled interface */ break; From cff84f1786d78d19b177cecc15cbf82170f4c62f Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Tue, 29 Jul 2014 15:26:16 +0100 Subject: [PATCH 14/48] iAP EA Native Transport endpoint manager core added to tile 0 --- module_usb_audio/main.xc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/module_usb_audio/main.xc b/module_usb_audio/main.xc index 57db3a29..53ab6737 100755 --- a/module_usb_audio/main.xc +++ b/module_usb_audio/main.xc @@ -243,6 +243,9 @@ void usb_audio_core(chanend c_mix_out #endif #ifdef IAP , chanend c_iap +#ifdef IAP_EA_NATIVE_TRANS +, chanend c_ea_data +#endif #endif #ifdef MIXER , chanend c_mix_ctl @@ -344,6 +347,17 @@ void usb_audio_core(chanend c_mix_out #endif ); } + +#if defined(IAP_EA_NATIVE_TRANS) + /* EA Native Transport Endpoint manager */ + { + thread_speed(); + iAP2_EANativeTransport_EPManager( + c_xud_out[ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS], + c_xud_in[ENDPOINT_NUMBER_IN_IAP_EA_NATIVE_TRANS], + c_EANativeTransport_ctrl, c_ea_data); + } +#endif //: } } @@ -405,6 +419,9 @@ int main() #endif #ifdef IAP chan c_iap; +#ifdef IAP_EA_NATIVE_TRANS + chan c_ea_data; +#endif #endif #ifdef SU1_ADC_ENABLE chan c_adc; @@ -432,6 +449,9 @@ int main() #endif #ifdef IAP , c_iap +#ifdef IAP_EA_NATIVE_TRANS + , c_ea_data +#endif #endif #ifdef MIXER , c_mix_ctl From 2c9d4c239bcec2d738ead8e4b177e1e5c9dd42ac Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Wed, 30 Jul 2014 13:34:13 +0100 Subject: [PATCH 15/48] Updated define names in line with changes to sc_mfi --- module_usb_audio/endpoint0/descriptors.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index ccb92a1d..ef2ad025 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -602,7 +602,7 @@ StringDescTable_t g_strTable = #endif .iAPInterfaceStr = "iAP Interface", #ifdef IAP_EA_NATIVE_TRANS - .iAP_EANativeTransport_InterfaceStr = IAP_EA_NATIVE_TRANS_PROTOCOL_NAME, + .iAP_EANativeTransport_InterfaceStr = IAP2_EA_NATIVE_TRANS_PROTOCOL_NAME, #endif }; From 193ae6eaff2db5f0ee20a973206424b3dce132ca Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Wed, 30 Jul 2014 19:32:55 +0100 Subject: [PATCH 16/48] Mask Alt settings value before sending to iAP EA Native code (clean up short sent via channel) --- module_usb_audio/endpoint0/endpoint0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module_usb_audio/endpoint0/endpoint0.c b/module_usb_audio/endpoint0/endpoint0.c index cfd28db4..92840187 100755 --- a/module_usb_audio/endpoint0/endpoint0.c +++ b/module_usb_audio/endpoint0/endpoint0.c @@ -346,7 +346,8 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, //TODO g_eaNativeTransportAlt = sp.wValue;? /* Send selected Alt interface number onto EA Native EP manager */ - outuint(c_EANativeTransport_ctrl, sp.wValue); + unsigned int altSetting = (0x0000FFFF & sp.wValue); // sp.wValue is an unsigned short + outuint(c_EANativeTransport_ctrl, altSetting); /* Handshake */ chkct(c_EANativeTransport_ctrl, XS1_CT_END); From 3f4ba11f26a83e8295fa39c60cdf28e53474d86d Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Tue, 5 Aug 2014 17:06:56 +0100 Subject: [PATCH 17/48] Avoid declaring unneeded channel when digital rx is not enabled --- module_usb_audio/main.xc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module_usb_audio/main.xc b/module_usb_audio/main.xc index 4e271583..e4501c16 100755 --- a/module_usb_audio/main.xc +++ b/module_usb_audio/main.xc @@ -364,7 +364,11 @@ chanend ?c_clk_int chan c_mix_out; #endif +#if defined(SPDIF_RX) || defined(ADAT_RX) chan c_dig_rx; +#else + #define c_dig_rx null +#endif par { @@ -436,7 +440,6 @@ int main() chan c_clk_ctl; chan c_clk_int; #else -#define c_dig_rx null #define c_clk_int null #define c_clk_ctl null #define c_spdif_rx null From 074a58f6eb8f0beea202c9d54957ac4875e24b7a Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Fri, 15 Aug 2014 12:58:32 +0100 Subject: [PATCH 18/48] Removed "Input" and "Output" append on interface strings. --- module_usb_audio/endpoint0/descriptors.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index f054dc52..cea473f4 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -180,17 +180,17 @@ StringDescTable_t g_strTable = .vendorStr = VENDOR_STR, .serialStr = "", .productStr_Audio2 = PRODUCT_STR_A2, - .outputInterfaceStr_Audio2 = APPEND_PRODUCT_STR_A2(Output), - .inputInterfaceStr_Audio2 = APPEND_PRODUCT_STR_A2(Input), - .usbInputTermStr_Audio2 = APPEND_PRODUCT_STR_A2(Output), - .usbOutputTermStr_Audio2 = APPEND_PRODUCT_STR_A2(Input), + .outputInterfaceStr_Audio2 = APPEND_PRODUCT_STR_A2(), + .inputInterfaceStr_Audio2 = APPEND_PRODUCT_STR_A2(), + .usbInputTermStr_Audio2 = APPEND_PRODUCT_STR_A2(), + .usbOutputTermStr_Audio2 = APPEND_PRODUCT_STR_A2(), #if defined (AUDIO_CLASS_FALLBACK) || (AUDIO_CLASS == 1) .productStr_Audio1 = PRODUCT_STR_A1, - .outputInterfaceStr_Audio1 = APPEND_PRODUCT_STR_A1(Output), - .inputInterfaceStr_Audio1 = APPEND_PRODUCT_STR_A1(Input), - .usbInputTermStr_Audio1 = APPEND_PRODUCT_STR_A1(Output), - .usbOutputTermStr_Audio1 = APPEND_PRODUCT_STR_A1(Input), + .outputInterfaceStr_Audio1 = APPEND_PRODUCT_STR_A1(), + .inputInterfaceStr_Audio1 = APPEND_PRODUCT_STR_A1(), + .usbInputTermStr_Audio1 = APPEND_PRODUCT_STR_A1(), + .usbOutputTermStr_Audio1 = APPEND_PRODUCT_STR_A1(), #endif .clockSelectorStr = APPEND_VENDOR_STR(Clock Selector), .internalClockSourceStr = APPEND_VENDOR_STR(Internal Clock), From a9259412bd20febe6ea1d32b14930b5595f48a8c Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Fri, 15 Aug 2014 12:59:08 +0100 Subject: [PATCH 19/48] changelog 6.6.1 -> 6.6.2 --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 22ff07f2..c1959d91 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ sc_usb_audio Change Log ======================= -6.6.1 +6.6.2 ----- * see sw_usb_audio for changelog From f2b688b4cb1ff723c322ddea30ee4608bd1edb4e Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Fri, 15 Aug 2014 12:59:26 +0100 Subject: [PATCH 20/48] xpd: Patched version number --- module_dfu/.cproject | 18 +++--------------- module_usb_audio/devicedefines.h | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/module_dfu/.cproject b/module_dfu/.cproject index bb778c83..da068095 100644 --- a/module_dfu/.cproject +++ b/module_dfu/.cproject @@ -156,11 +156,7 @@