mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
code format
This commit is contained in:
parent
68687ed0f4
commit
8b79040c38
@ -207,7 +207,6 @@ bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
|
||||
mute[channelNum] = ((audio_control_cur_1_t*) pBuff)->bCur;
|
||||
|
||||
TU_LOG2(" Set Mute: %d of channel: %u\r\n", mute[channelNum], channelNum);
|
||||
|
||||
return true;
|
||||
|
||||
case AUDIO_FU_CTRL_VOLUME:
|
||||
@ -217,7 +216,6 @@ bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
|
||||
volume[channelNum] = ((audio_control_cur_2_t*) pBuff)->bCur;
|
||||
|
||||
TU_LOG2(" Set Volume: %d dB of channel: %u\r\n", volume[channelNum], channelNum);
|
||||
|
||||
return true;
|
||||
|
||||
// Unknown/Unsupported control
|
||||
@ -275,11 +273,11 @@ bool tud_audio_get_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
|
||||
// Input terminal (Microphone input)
|
||||
if (entityID == 1)
|
||||
{
|
||||
switch (ctrlSel)
|
||||
switch ( ctrlSel )
|
||||
{
|
||||
case AUDIO_TE_CTRL_CONNECTOR:
|
||||
{
|
||||
case AUDIO_TE_CTRL_CONNECTOR:;
|
||||
// The terminal connector control only has a get request with only the CUR attribute.
|
||||
|
||||
audio_desc_channel_cluster_t ret;
|
||||
|
||||
// Those are dummy values for now
|
||||
@ -289,17 +287,21 @@ bool tud_audio_get_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
|
||||
|
||||
TU_LOG2(" Get terminal connector\r\n");
|
||||
|
||||
return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, (void*)&ret, sizeof(ret));
|
||||
return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, (void*) &ret, sizeof(ret));
|
||||
}
|
||||
break;
|
||||
|
||||
// Unknown/Unsupported control selector
|
||||
default: TU_BREAKPOINT(); return false;
|
||||
default:
|
||||
TU_BREAKPOINT();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Feature unit
|
||||
if (entityID == 2)
|
||||
{
|
||||
switch (ctrlSel)
|
||||
switch ( ctrlSel )
|
||||
{
|
||||
case AUDIO_FU_CTRL_MUTE:
|
||||
// Audio control mute cur parameter block consists of only one byte - we thus can send it right away
|
||||
@ -308,55 +310,63 @@ bool tud_audio_get_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
|
||||
return tud_control_xfer(rhport, p_request, &mute[channelNum], 1);
|
||||
|
||||
case AUDIO_FU_CTRL_VOLUME:
|
||||
|
||||
switch (p_request->bRequest)
|
||||
switch ( p_request->bRequest )
|
||||
{
|
||||
case AUDIO_CS_REQ_CUR:
|
||||
TU_LOG2(" Get Volume of channel: %u\r\n", channelNum);
|
||||
return tud_control_xfer(rhport, p_request, &volume[channelNum], sizeof(volume[channelNum]));
|
||||
|
||||
case AUDIO_CS_REQ_RANGE:
|
||||
TU_LOG2(" Get Volume range of channel: %u\r\n", channelNum);
|
||||
|
||||
// Copy values - only for testing - better is version below
|
||||
audio_control_range_2_n_t(1) ret;
|
||||
audio_control_range_2_n_t(1)
|
||||
ret;
|
||||
|
||||
ret.wNumSubRanges = 1;
|
||||
ret.subrange[0].bMin = -90; // -90 dB
|
||||
ret.subrange[0].bMax = 90; // +90 dB
|
||||
ret.subrange[0].bRes = 1; // 1 dB steps
|
||||
|
||||
return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, (void*)&ret, sizeof(ret));
|
||||
return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, (void*) &ret, sizeof(ret));
|
||||
|
||||
// Unknown/Unsupported control
|
||||
default: TU_BREAKPOINT(); return false;
|
||||
default:
|
||||
TU_BREAKPOINT();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
// Unknown/Unsupported control
|
||||
default: TU_BREAKPOINT(); return false;
|
||||
default:
|
||||
TU_BREAKPOINT();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clock Source unit
|
||||
if (entityID == 4)
|
||||
if ( entityID == 4 )
|
||||
{
|
||||
switch (ctrlSel)
|
||||
switch ( ctrlSel )
|
||||
{
|
||||
case AUDIO_CS_CTRL_SAM_FREQ:
|
||||
|
||||
// channelNum is always zero in this case
|
||||
|
||||
switch (p_request->bRequest)
|
||||
switch ( p_request->bRequest )
|
||||
{
|
||||
case AUDIO_CS_REQ_CUR:
|
||||
TU_LOG2(" Get Sample Freq.\r\n");
|
||||
return tud_control_xfer(rhport, p_request, &sampFreq, sizeof(sampFreq));
|
||||
|
||||
case AUDIO_CS_REQ_RANGE:
|
||||
TU_LOG2(" Get Sample Freq. range\r\n");
|
||||
return tud_control_xfer(rhport, p_request, &sampleFreqRng, sizeof(sampleFreqRng));
|
||||
|
||||
// Unknown/Unsupported control
|
||||
default: TU_BREAKPOINT(); return false;
|
||||
default:
|
||||
TU_BREAKPOINT();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_CS_CTRL_CLK_VALID:
|
||||
// Only cur attribute exists for this request
|
||||
@ -364,7 +374,9 @@ bool tud_audio_get_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
|
||||
return tud_control_xfer(rhport, p_request, &clkValid, sizeof(clkValid));
|
||||
|
||||
// Unknown/Unsupported control
|
||||
default: TU_BREAKPOINT(); return false;
|
||||
default:
|
||||
TU_BREAKPOINT();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,15 +481,6 @@ typedef enum
|
||||
AUDIO_EXT_FORMAT_TYPE_III = 0x83,
|
||||
} audio_format_type_t;
|
||||
|
||||
//#define AUDIO_FORMAT_TYPE_UNDEFINED 0x00
|
||||
//#define AUDIO_FORMAT_TYPE_I 0x01
|
||||
//#define AUDIO_FORMAT_TYPE_II 0x02
|
||||
//#define AUDIO_FORMAT_TYPE_III 0x03
|
||||
//#define AUDIO_FORMAT_TYPE_IV 0x04
|
||||
//#define AUDIO_EXT_FORMAT_TYPE_I 0x81
|
||||
//#define AUDIO_EXT_FORMAT_TYPE_II 0x82
|
||||
//#define AUDIO_EXT_FORMAT_TYPE_III 0x83
|
||||
|
||||
// A.2.1 - Audio Class-Audio Data Format Type I UAC2
|
||||
typedef enum
|
||||
{
|
||||
@ -501,13 +492,6 @@ typedef enum
|
||||
AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x100000000,
|
||||
} audio_data_format_type_I_t;
|
||||
|
||||
//#define AUDIO_DATA_FORMAT_TYPE_I_PCM ((uint32_t) (1 << 0))
|
||||
//#define AUDIO_DATA_FORMAT_TYPE_I_PCM8 ((uint32_t) (1 << 1))
|
||||
//#define AUDIO_DATA_FORMAT_TYPE_I_IEEE_FLOAT ((uint32_t) (1 << 2))
|
||||
//#define AUDIO_DATA_FORMAT_TYPE_I_ALAW ((uint32_t) (1 << 3))
|
||||
//#define AUDIO_DATA_FORMAT_TYPE_I_MULAW ((uint32_t) (1 << 4))
|
||||
//#define AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA 0x100000000
|
||||
|
||||
/// All remaining definitions are taken from the descriptor descriptions in the UAC2 main specification
|
||||
|
||||
/// Isochronous End Point Attributes
|
||||
|
Loading…
x
Reference in New Issue
Block a user