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;
|
mute[channelNum] = ((audio_control_cur_1_t*) pBuff)->bCur;
|
||||||
|
|
||||||
TU_LOG2(" Set Mute: %d of channel: %u\r\n", mute[channelNum], channelNum);
|
TU_LOG2(" Set Mute: %d of channel: %u\r\n", mute[channelNum], channelNum);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case AUDIO_FU_CTRL_VOLUME:
|
case AUDIO_FU_CTRL_VOLUME:
|
||||||
|
@ -217,8 +216,7 @@ bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
|
||||||
volume[channelNum] = ((audio_control_cur_2_t*) pBuff)->bCur;
|
volume[channelNum] = ((audio_control_cur_2_t*) pBuff)->bCur;
|
||||||
|
|
||||||
TU_LOG2(" Set Volume: %d dB of channel: %u\r\n", volume[channelNum], channelNum);
|
TU_LOG2(" Set Volume: %d dB of channel: %u\r\n", volume[channelNum], channelNum);
|
||||||
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
// Unknown/Unsupported control
|
// Unknown/Unsupported control
|
||||||
default:
|
default:
|
||||||
|
@ -275,96 +273,110 @@ bool tud_audio_get_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
|
||||||
// Input terminal (Microphone input)
|
// Input terminal (Microphone input)
|
||||||
if (entityID == 1)
|
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.
|
{
|
||||||
|
// The terminal connector control only has a get request with only the CUR attribute.
|
||||||
|
audio_desc_channel_cluster_t ret;
|
||||||
|
|
||||||
audio_desc_channel_cluster_t ret;
|
// Those are dummy values for now
|
||||||
|
ret.bNrChannels = 1;
|
||||||
|
ret.bmChannelConfig = 0;
|
||||||
|
ret.iChannelNames = 0;
|
||||||
|
|
||||||
// Those are dummy values for now
|
TU_LOG2(" Get terminal connector\r\n");
|
||||||
ret.bNrChannels = 1;
|
|
||||||
ret.bmChannelConfig = 0;
|
|
||||||
ret.iChannelNames = 0;
|
|
||||||
|
|
||||||
TU_LOG2(" Get terminal connector\r\n");
|
return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, (void*) &ret, sizeof(ret));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
return tud_audio_buffer_and_schedule_control_xfer(rhport, p_request, (void*)&ret, sizeof(ret));
|
// Unknown/Unsupported control selector
|
||||||
|
default:
|
||||||
// Unknown/Unsupported control selector
|
TU_BREAKPOINT();
|
||||||
default: TU_BREAKPOINT(); return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Feature unit
|
// Feature unit
|
||||||
if (entityID == 2)
|
if (entityID == 2)
|
||||||
{
|
{
|
||||||
switch (ctrlSel)
|
switch ( ctrlSel )
|
||||||
{
|
{
|
||||||
case AUDIO_FU_CTRL_MUTE:
|
case AUDIO_FU_CTRL_MUTE:
|
||||||
// Audio control mute cur parameter block consists of only one byte - we thus can send it right away
|
// Audio control mute cur parameter block consists of only one byte - we thus can send it right away
|
||||||
// There does not exist a range parameter block for mute
|
// There does not exist a range parameter block for mute
|
||||||
TU_LOG2(" Get Mute of channel: %u\r\n", channelNum);
|
TU_LOG2(" Get Mute of channel: %u\r\n", channelNum);
|
||||||
return tud_control_xfer(rhport, p_request, &mute[channelNum], 1);
|
return tud_control_xfer(rhport, p_request, &mute[channelNum], 1);
|
||||||
|
|
||||||
case AUDIO_FU_CTRL_VOLUME:
|
case AUDIO_FU_CTRL_VOLUME:
|
||||||
|
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]));
|
||||||
|
|
||||||
switch (p_request->bRequest)
|
case AUDIO_CS_REQ_RANGE:
|
||||||
{
|
TU_LOG2(" Get Volume range of channel: %u\r\n", channelNum);
|
||||||
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
|
// 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.wNumSubRanges = 1;
|
||||||
ret.subrange[0].bMin = -90; // -90 dB
|
ret.subrange[0].bMin = -90; // -90 dB
|
||||||
ret.subrange[0].bMax = 90; // +90 dB
|
ret.subrange[0].bMax = 90; // +90 dB
|
||||||
ret.subrange[0].bRes = 1; // 1 dB steps
|
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
|
// Unknown/Unsupported control
|
||||||
default: TU_BREAKPOINT(); return false;
|
default:
|
||||||
}
|
TU_BREAKPOINT();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// Unknown/Unsupported control
|
// Unknown/Unsupported control
|
||||||
default: TU_BREAKPOINT(); return false;
|
default:
|
||||||
|
TU_BREAKPOINT();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clock Source unit
|
// Clock Source unit
|
||||||
if (entityID == 4)
|
if ( entityID == 4 )
|
||||||
{
|
{
|
||||||
switch (ctrlSel)
|
switch ( ctrlSel )
|
||||||
{
|
{
|
||||||
case AUDIO_CS_CTRL_SAM_FREQ:
|
case AUDIO_CS_CTRL_SAM_FREQ:
|
||||||
|
// channelNum is always zero in this case
|
||||||
|
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));
|
||||||
|
|
||||||
// channelNum is always zero in this case
|
case AUDIO_CS_REQ_RANGE:
|
||||||
|
TU_LOG2(" Get Sample Freq. range\r\n");
|
||||||
|
return tud_control_xfer(rhport, p_request, &sampleFreqRng, sizeof(sampleFreqRng));
|
||||||
|
|
||||||
switch (p_request->bRequest)
|
// Unknown/Unsupported control
|
||||||
{
|
default:
|
||||||
case AUDIO_CS_REQ_CUR:
|
TU_BREAKPOINT();
|
||||||
TU_LOG2(" Get Sample Freq.\r\n");
|
return false;
|
||||||
return tud_control_xfer(rhport, p_request, &sampFreq, sizeof(sampFreq));
|
}
|
||||||
case AUDIO_CS_REQ_RANGE:
|
break;
|
||||||
TU_LOG2(" Get Sample Freq. range\r\n");
|
|
||||||
return tud_control_xfer(rhport, p_request, &sampleFreqRng, sizeof(sampleFreqRng));
|
|
||||||
|
|
||||||
// Unknown/Unsupported control
|
case AUDIO_CS_CTRL_CLK_VALID:
|
||||||
default: TU_BREAKPOINT(); return false;
|
// Only cur attribute exists for this request
|
||||||
}
|
TU_LOG2(" Get Sample Freq. valid\r\n");
|
||||||
|
return tud_control_xfer(rhport, p_request, &clkValid, sizeof(clkValid));
|
||||||
|
|
||||||
case AUDIO_CS_CTRL_CLK_VALID:
|
// Unknown/Unsupported control
|
||||||
// Only cur attribute exists for this request
|
default:
|
||||||
TU_LOG2(" Get Sample Freq. valid\r\n");
|
TU_BREAKPOINT();
|
||||||
return tud_control_xfer(rhport, p_request, &clkValid, sizeof(clkValid));
|
return false;
|
||||||
|
|
||||||
// Unknown/Unsupported control
|
|
||||||
default: TU_BREAKPOINT(); return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -481,15 +481,6 @@ typedef enum
|
||||||
AUDIO_EXT_FORMAT_TYPE_III = 0x83,
|
AUDIO_EXT_FORMAT_TYPE_III = 0x83,
|
||||||
} audio_format_type_t;
|
} 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
|
// A.2.1 - Audio Class-Audio Data Format Type I UAC2
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -501,13 +492,6 @@ typedef enum
|
||||||
AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x100000000,
|
AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x100000000,
|
||||||
} audio_data_format_type_I_t;
|
} 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
|
/// All remaining definitions are taken from the descriptor descriptions in the UAC2 main specification
|
||||||
|
|
||||||
/// Isochronous End Point Attributes
|
/// Isochronous End Point Attributes
|
||||||
|
|
Loading…
Reference in New Issue