mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-25 10:43:44 +00:00
Fix formatting, get rid of all tabs.
This commit is contained in:
parent
c14f68e2c1
commit
37be0ca732
@ -883,7 +883,7 @@ typedef struct TU_ATTR_PACKED {
|
||||
} subrange[numSubRanges] ; \
|
||||
}
|
||||
|
||||
// 5.2.3.2 2-byte Control RANGE Parameter Block
|
||||
/// 5.2.3.2 2-byte Control RANGE Parameter Block
|
||||
#define audio_control_range_2_n_t(numSubRanges) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint16_t wNumSubRanges; \
|
||||
|
@ -125,20 +125,6 @@ typedef struct
|
||||
|
||||
#define ITF_MEM_RESET_SIZE offsetof(audiod_interface_t, ctrl_buf)
|
||||
|
||||
//#if CFG_TUD_AUDIO_EPSIZE_IN && CFG_TUD_AUDIO_TX_FIFO_SIZE
|
||||
//#define ITF_MEM_RESET_SIZE offsetof(audiod_interface_t, tx_ff)
|
||||
//#elif CFG_TUD_AUDIO_EPSIZE_OUT && CFG_TUD_AUDIO_RX_FIFO_SIZE
|
||||
//#define ITF_MEM_RESET_SIZE offsetof(audiod_interface_t, rx_ff)
|
||||
//#elif CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
|
||||
//#define ITF_MEM_RESET_SIZE offsetof(audiod_interface_t, int_ctr_ff)
|
||||
//#elif CFG_TUD_AUDIO_EPSIZE_OUT
|
||||
//#define ITF_MEM_RESET_SIZE offsetof(audiod_interface_t, epout_buf)
|
||||
//#elif CFG_TUD_AUDIO_EPSIZE_IN
|
||||
//#define ITF_MEM_RESET_SIZE offsetof(audiod_interface_t, epin_buf)
|
||||
//#elif CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
|
||||
//#define ITF_MEM_RESET_SIZE offsetof(audiod_interface_t, ep_int_ctr_buf)
|
||||
//#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
@ -253,7 +239,8 @@ static bool audio_rx_done_cb(uint8_t rhport, audiod_interface_t* audio, uint8_t*
|
||||
{
|
||||
case AUDIO_FORMAT_TYPE_UNDEFINED:
|
||||
// INDIVIDUAL DECODING PROCEDURE REQUIRED HERE!
|
||||
asm("nop");
|
||||
TU_LOG2(" Desired CFG_TUD_AUDIO_FORMAT encoding not implemented!\r\n");
|
||||
TU_BREAKPOINT();
|
||||
break;
|
||||
|
||||
case AUDIO_FORMAT_TYPE_I:
|
||||
@ -271,19 +258,22 @@ static bool audio_rx_done_cb(uint8_t rhport, audiod_interface_t* audio, uint8_t*
|
||||
|
||||
default:
|
||||
// DESIRED CFG_TUD_AUDIO_FORMAT_TYPE_I_RX NOT IMPLEMENTED!
|
||||
asm("nop");
|
||||
TU_LOG2(" Desired CFG_TUD_AUDIO_FORMAT_TYPE_I_RX encoding not implemented!\r\n");
|
||||
TU_BREAKPOINT();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Desired CFG_TUD_AUDIO_FORMAT_TYPE_RX not implemented!
|
||||
asm("nop");
|
||||
TU_LOG2(" Desired CFG_TUD_AUDIO_FORMAT_TYPE_RX not implemented!\r\n");
|
||||
TU_BREAKPOINT();
|
||||
break;
|
||||
}
|
||||
|
||||
// Call a weak callback here - a possibility for user to get informed RX was completed
|
||||
TTU_VERIFY(tud_audio_rx_done_cb(rhport, buffer, bufsize));
|
||||
if (tud_audio_rx_done_cb) TU_VERIFY(tud_audio_rx_done_cb(rhport, buffer, bufsize));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -328,22 +318,6 @@ static bool audio_rx_done_type_I_pcm_ff_cb(uint8_t rhport, audiod_interface_t* a
|
||||
} }
|
||||
#endif //CFG_TUD_AUDIO_RX_FIFO_SIZE
|
||||
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_OUT
|
||||
TU_ATTR_WEAK bool tud_audio_rx_done_cb(uint8_t rhport, uint8_t * buffer, uint16_t bufsize)
|
||||
{
|
||||
(void) rhport;
|
||||
(void) buffer;
|
||||
(void) bufsize;
|
||||
|
||||
/* NOTE: This function should not be modified, when the callback is needed,
|
||||
the tud_audio_rx_done_cb could be implemented in the user file
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// WRITE API
|
||||
//--------------------------------------------------------------------+
|
||||
@ -631,9 +605,6 @@ uint16_t audiod_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uin
|
||||
TU_ASSERT( i < CFG_TUD_AUDIO );
|
||||
|
||||
// This is all we need so far - the EPs are setup by a later set_interface request (as per UAC2 specification)
|
||||
|
||||
// Notify caller we read complete descriptor
|
||||
// (*p_length) += tud_audio_desc_lengths[i];
|
||||
// TODO: Find a way to find end of current audio function and avoid necessity of tud_audio_desc_lengths - since now max_length is available we could do this surely somehow
|
||||
uint16_t drv_len = tud_audio_desc_lengths[i] - TUD_AUDIO_DESC_IAD_LEN; // - TUD_AUDIO_DESC_IAD_LEN since tinyUSB already handles the IAD descriptor
|
||||
|
||||
@ -1252,222 +1223,3 @@ static bool audiod_verify_ep_exists(uint8_t ep, uint8_t *idxDriver)
|
||||
}
|
||||
|
||||
#endif //TUSB_OPT_DEVICE_ENABLED && CFG_TUD_AUDIO
|
||||
|
||||
// OLD
|
||||
//// In order that this function works the following is mandatory:
|
||||
// // - An IAD descriptor is required and has to be placed directly before the Standard AC Interface Descriptor (4.7.1) ALSO if no Audio Streaming interfaces are used!
|
||||
// // - The Standard AC Interface Descriptor (4.7.1) has to be the first interface listed (required by UAC2 specification)
|
||||
// // - The alternate interfaces of the Standard AS Interface Descriptor(4.9.1) must be listed in increasing order and alternate 0 must have zero EPs
|
||||
//
|
||||
// TU_VERIFY ( TUSB_CLASS_AUDIO == itf_desc->bInterfaceClass &&
|
||||
// AUDIO_SUBCLASS_CONTROL == itf_desc->bInterfaceSubClass);
|
||||
//
|
||||
// // Verify version is correct - this check can be omitted
|
||||
// TU_VERIFY(itf_desc->bInterfaceProtocol == AUDIO_PROTOCOL_V2);
|
||||
//
|
||||
// // Verify interrupt control EP is enabled if demanded by descriptor - this should be best some static check however - this check can be omitted
|
||||
// if (itf_desc->bNumEndpoints == 1) // 0 or 1 EPs are allowed
|
||||
// {
|
||||
// TU_VERIFY(CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN > 0);
|
||||
// }
|
||||
//
|
||||
// // Alternate setting MUST be zero - this check can be omitted
|
||||
// TU_VERIFY(itf_desc->bAlternateSetting == 0);
|
||||
//
|
||||
// // Since checks are successful we get the number of interfaces we have to process by exploiting the fact that an IAD descriptor has to be provided directly before this AC descriptor
|
||||
// // We do not get this value delivered by the stack so we need to hack a little bit - the number of interfaces to be processed is listed in the IAD descriptor with an offset of exactly 5
|
||||
// uint8_t nItfs = *(((uint8_t const *) itf_desc) - 5) - 1; // -1 since we already process the (included) AC interface
|
||||
//
|
||||
// // Notify caller we have read Standard AC Interface Descriptor (4.7.1)
|
||||
// (*p_length) = sizeof(tusb_desc_interface_t);
|
||||
//
|
||||
// // Go to next descriptor which has to be a Class-Specific AC Interface Header Descriptor(4.7.2) - always present
|
||||
// audio_desc_cs_ac_interface_t const * p_desc_cs_ac = (audio_desc_cs_ac_interface_t const *) tu_desc_next ( (uint8_t const *) itf_desc );
|
||||
//
|
||||
// // Verify its the correct descriptor - this check can be omitted
|
||||
// TU_VERIFY(p_desc_cs_ac->bDescriptorType == TUSB_DESC_CS_INTERFACE
|
||||
// && p_desc_cs_ac->bDescriptorSubType == AUDIO_CS_AC_INTERFACE_HEADER
|
||||
// && p_desc_cs_ac->bcdADC == 0x0200);
|
||||
//
|
||||
// // We do not check the Audio Function Category Codes
|
||||
//
|
||||
// // We do not check all the following Clock Source, Unit and Terminal descriptors
|
||||
//
|
||||
// // We do not check the latency control
|
||||
//
|
||||
// // We jump over all the following descriptor to the next following interface (which should be a Standard AS Interface Descriptor(4.9.1) if nItfs > 0)
|
||||
// (*p_length) += p_desc_cs_ac->wTotalLength; // Notify caller of read bytes
|
||||
// itf_desc = (tusb_desc_interface_t const * )(((uint8_t const *)p_desc_cs_ac ) + p_desc_cs_ac->wTotalLength); // Move pointer
|
||||
//
|
||||
// // From this point on we have nItfs packs of audio streaming interfaces (consisting of multiple descriptors always starting with a Standard AS Interface Descriptor(4.9.1))
|
||||
//
|
||||
// uint8_t cnt;
|
||||
// uint8_t nEPs;
|
||||
// audio_format_type_t formatType;
|
||||
// uint8_t intNum;
|
||||
// uint8_t altInt;
|
||||
//
|
||||
// for (cnt = 0; cnt < nItfs; cnt++)
|
||||
// {
|
||||
//
|
||||
// // Here starts an unknown number of alternate interfaces - the art here is to find the end of this interface pack. We do not have the total number of descriptor bytes available (not provided by tinyUSB stack for .open() function) so we try to find the end of this interface pack by deducing it from the order and content of the descriptor pack
|
||||
// while(1)
|
||||
// {
|
||||
// // At first this should be a Standard AS Interface Descriptor(4.9.1) - this check can be omitted
|
||||
// TU_VERIFY(itf_desc->bDescriptorType == TUSB_DESC_INTERFACE &&
|
||||
// itf_desc->bInterfaceClass == TUSB_CLASS_AUDIO &&
|
||||
// itf_desc->bInterfaceSubClass == AUDIO_SUBCLASS_STREAMING &&
|
||||
// itf_desc->bInterfaceProtocol == AUDIO_PROTOCOL_V2);
|
||||
//
|
||||
// // Remember number of EPs this interface has - required for later
|
||||
// nEPs = itf_desc->bNumEndpoints;
|
||||
// intNum = itf_desc->bInterfaceNumber;
|
||||
// altInt = itf_desc->bAlternateSetting;
|
||||
//
|
||||
// // Notify caller we have read bytes
|
||||
// (*p_length) += tu_desc_len((uint8_t const *) itf_desc);
|
||||
//
|
||||
// // Advance pointer
|
||||
// itf_desc = (tusb_desc_interface_t const * )(tu_desc_next((uint8_t const *)itf_desc));
|
||||
//
|
||||
// // It is possible now that the following interface is again a Standard AS Interface Descriptor(4.9.1) (in case the related terminal has more than zero EPs at all and this is the following alternative interface > 0 - the alternative (that this is not a Standard AS Interface Descriptor(4.9.1) but a Class-Specific AS Interface Descriptor(4.9.2)) could be in case the related terminal has no EPs at all e.g. SPDIF connector
|
||||
// if (tu_desc_type((uint8_t const *) itf_desc) == TUSB_DESC_INTERFACE)
|
||||
// {
|
||||
// // It is not possible, that a Standard AS Interface Descriptor(4.9.1) ends without a Class-Specific AS Interface Descriptor(4.9.2)
|
||||
// // hence the next interface has to be an alternative interface with regard to the one we started above - continue
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // Second, this interface has to be a Class-Specific AS Interface Descriptor(4.9.2) - this check can be omitted
|
||||
// TU_VERIFY(tu_desc_type((uint8_t const *) itf_desc) == TUSB_DESC_CS_INTERFACE &&
|
||||
// ((audio_desc_cs_as_interface_t *) itf_desc)->bDescriptorSubType == AUDIO_CS_AS_INTERFACE_AS_GENERAL);
|
||||
//
|
||||
// // Remember format type of this interface - required for later
|
||||
// formatType = ((audio_desc_cs_as_interface_t *) itf_desc)->bFormatType;
|
||||
//
|
||||
// // Notify caller we have read bytes
|
||||
// (*p_length) += tu_desc_len((uint8_t const *) itf_desc);
|
||||
//
|
||||
// // Advance pointer
|
||||
// itf_desc = (tusb_desc_interface_t const * )(tu_desc_next((uint8_t const *)itf_desc));
|
||||
//
|
||||
// // Every Class-Specific AS Interface Descriptor(4.9.2) defines a format type and thus a format type descriptor e.g. Type I Format Type Descriptor(2.3.1.6 - Audio Formats) should follow - only if the format type is undefined no format type descriptor follows
|
||||
// if (formatType != AUDIO_FORMAT_TYPE_UNDEFINED)
|
||||
// {
|
||||
// // We do not need any information from this descriptor - we simply advance
|
||||
// // Notify caller we have read bytes
|
||||
// (*p_length) += tu_desc_len((uint8_t const *) itf_desc);
|
||||
//
|
||||
// // Advance pointer
|
||||
// itf_desc = (tusb_desc_interface_t const * )(tu_desc_next((uint8_t const *)itf_desc));
|
||||
// }
|
||||
//
|
||||
// // Now there might be an encoder/decoder interface - i found no clue if this interface is mandatory (although examples found by google never use this descriptor) or if there is any way to determine if this descriptor is reliably present or not. Problem here: Since we need to find the end of this interface pack and we do not have the total amount of descriptor bytes available here (not given by the tinyUSB stack for the .open() function), we have to make a speculative check if the following is an encoder/decoder interface or not.
|
||||
// // It could be possible that we ready over the total length of all descriptor bytes here - we simply hope that the combination of descriptor length, type, and sub type does not occur randomly in memory here. The only way to make this check waterproof is to know how many bytes we can read at all but this would be an information we need to be given by tinyUSB!
|
||||
// if (tu_desc_len((uint8_t const *) itf_desc) == 21 && tu_desc_type((uint8_t const *) itf_desc) == TUSB_DESC_CS_INTERFACE && (((audio_desc_cs_as_interface_t *) itf_desc)->bDescriptorSubType == AUDIO_CS_AS_INTERFACE_ENCODER || ((audio_desc_cs_as_interface_t *) itf_desc)->bDescriptorSubType == AUDIO_CS_AS_INTERFACE_DECODER))
|
||||
// {
|
||||
// // We do not need any information from this descriptor - we simply advance
|
||||
// // Notify caller we have read bytes
|
||||
// (*p_length) += tu_desc_len((uint8_t const *) itf_desc);
|
||||
//
|
||||
// // Advance pointer
|
||||
// itf_desc = (tusb_desc_interface_t const * )(tu_desc_next((uint8_t const *)itf_desc));
|
||||
// }
|
||||
//
|
||||
// // Here may be some EP descriptors
|
||||
// for (uint8_t cntEP = 0; cntEP < nEPs; cntEP++)
|
||||
// {
|
||||
// // This check can be omitted
|
||||
// TU_VERIFY(tu_desc_type((uint8_t const *) itf_desc) == TUSB_DESC_ENDPOINT);
|
||||
//
|
||||
// // Here we can find information about our EPs address etc. but in the initialization process we do not set anything, we have to wait for the host to send a setInterface request where the EPs etc. are set up according
|
||||
//
|
||||
// // Notify caller we have read bytes
|
||||
// (*p_length) += tu_desc_len((uint8_t const *) itf_desc);
|
||||
//
|
||||
// // If the usage type is something else than feedback there is a Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) following up
|
||||
// if (((tusb_desc_endpoint_t *) itf_desc)->bmAttributes.usage != 0x10)
|
||||
// {
|
||||
// // Advance pointer
|
||||
// itf_desc = (tusb_desc_interface_t const * )(tu_desc_next((uint8_t const *)itf_desc));
|
||||
//
|
||||
// // We do not need any information from this descriptor - we simply advance
|
||||
// // Notify caller we have read bytes
|
||||
// (*p_length) += tu_desc_len((uint8_t const *) itf_desc);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // Advance pointer
|
||||
// itf_desc = (tusb_desc_interface_t const * )(tu_desc_next((uint8_t const *)itf_desc));
|
||||
// }
|
||||
//
|
||||
// // Okay we processed a complete pack - now we have to make a speculative check if the next interface is an alternate interface belonging to the ones processed before - since it is speculative we check a lot to reduce the chances we go wrong and hope for the best
|
||||
// if (!(tu_desc_len((uint8_t const *) itf_desc) == 9 && tu_desc_type((uint8_t const *) itf_desc) == TUSB_DESC_INTERFACE && itf_desc->bInterfaceNumber == intNum && itf_desc->bAlternateSetting == altInt + 1))
|
||||
// {
|
||||
// // The current interface is not a consecutive alternate interface to the one processed above
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// Here follow the encoding steps
|
||||
|
||||
//#if CFG_TUD_AUDIO_FORMAT_TYPE_TX == AUDIO_FORMAT_TYPE_UNDEFINED
|
||||
//
|
||||
//#error Individual encoding procedure required!
|
||||
//
|
||||
//#elif CFG_TUD_AUDIO_FORMAT_TYPE_TX == AUDIO_FORMAT_TYPE_I
|
||||
//
|
||||
//#if CFG_TUD_AUDIO_FORMAT_TYPE_I_TX == AUDIO_DATA_FORMAT_TYPE_I_PCM
|
||||
//
|
||||
//#if CFG_TUD_AUDIO_TX_FIFO_SIZE
|
||||
// TU_VERIFY(audio_tx_done_type_I_pcm_cb(rhport, audio, n_bytes_copied));
|
||||
//#else
|
||||
//#error YOUR ENCODING AND SENDING IS REQUIRED HERE!
|
||||
//#endif
|
||||
//
|
||||
//#else
|
||||
//#error Desired CFG_TUD_AUDIO_FORMAT_TYPE_I_TX not implemented!
|
||||
//#endif
|
||||
//
|
||||
//#else
|
||||
//#error Desired CFG_TUD_AUDIO_FORMAT_TYPE_TX not implemented!
|
||||
//#endif
|
||||
//
|
||||
// // Call a weak callback here - a possibility for user to get informed TX was completed
|
||||
// TU_VERIFY(tud_audio_tx_done_cb(rhport, n_bytes_copied));
|
||||
// return true;
|
||||
|
||||
//#if CFG_TUD_AUDIO_EPSIZE_OUT
|
||||
//static bool audio_rx_done_cb(uint8_t rhport, audiod_interface_t* audio, uint8_t* buffer, uint16_t bufsize) {
|
||||
//
|
||||
// // Here follow the decoding steps
|
||||
//
|
||||
//#if CFG_TUD_AUDIO_FORMAT_TYPE_RX == AUDIO_FORMAT_TYPE_UNDEFINED
|
||||
//
|
||||
//#error Individual decoding procedure required!
|
||||
//
|
||||
//#elif CFG_TUD_AUDIO_FORMAT_TYPE_RX == AUDIO_FORMAT_TYPE_I
|
||||
//
|
||||
//#if CFG_TUD_AUDIO_FORMAT_TYPE_I_RX == AUDIO_DATA_FORMAT_TYPE_I_PCM
|
||||
//
|
||||
//#if CFG_TUD_AUDIO_RX_FIFO_SIZE
|
||||
// TU_VERIFY(audio_rx_done_type_I_pcm_ff_cb(rhport, audio, buffer, bufsize));
|
||||
//#else
|
||||
//#error YOUR DECODING AND BUFFERING IS REQUIRED HERE!
|
||||
//#endif
|
||||
//
|
||||
//#else
|
||||
//#error Desired CFG_TUD_AUDIO_FORMAT_TYPE_I_RX not implemented!
|
||||
//#endif
|
||||
//
|
||||
//#else
|
||||
//#error Desired CFG_TUD_AUDIO_FORMAT_TYPE_RX not implemented!
|
||||
//#endif
|
||||
//
|
||||
// TU_VERIFY(tud_audio_rx_done_cb(rhport, buffer, bufsize));
|
||||
// return true;
|
||||
//}
|
||||
//#endif
|
||||
|
@ -375,7 +375,6 @@ static void set_speed(uint8_t rhport, tusb_speed_t speed)
|
||||
dev->DCFG |= (bitvalue << USB_OTG_DCFG_DSPD_Pos);
|
||||
}
|
||||
|
||||
|
||||
#if defined(USB_HS_PHYC)
|
||||
static bool USB_HS_PHYCInit(void)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user