EP0 changed to use switch statement when handling USB_SET_INTERFACE requests
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user