forked from PAWPAW-Mirror/lib_xua
modified AudioEndpointRequests_1 to distinguish between ep0 request for USB in and out
This commit is contained in:
@@ -2656,7 +2656,7 @@ unsigned char cfgDesc_Audio1[] =
|
|||||||
/* Standard AS Isochronous Audio Data Endpoint Descriptor 4.6.1.1 */
|
/* Standard AS Isochronous Audio Data Endpoint Descriptor 4.6.1.1 */
|
||||||
0x09,
|
0x09,
|
||||||
0x05, /* ENDPOINT */
|
0x05, /* ENDPOINT */
|
||||||
0x01, /* endpointAddress - D7, direction (0 OUT, 1 IN). D6..4 reserved (0). D3..0 endpoint no. */
|
ENDPOINT_ADDRESS_OUT_AUDIO, /* endpointAddress - D7, direction (0 OUT, 1 IN). D6..4 reserved (0). D3..0 endpoint no. */
|
||||||
#ifdef XUA_ADAPTIVE
|
#ifdef XUA_ADAPTIVE
|
||||||
ISO_EP_ATTRIBUTES_ADAPTIVE,
|
ISO_EP_ATTRIBUTES_ADAPTIVE,
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "mixer.h"
|
#include "mixer.h"
|
||||||
#endif
|
#endif
|
||||||
#include "xua_conf_default.h"
|
#include "xua_conf_default.h"
|
||||||
|
#include "descriptor_defs.h"
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG_UNIT XUA_EP0_UACREQS
|
#define DEBUG_UNIT XUA_EP0_UACREQS
|
||||||
@@ -58,10 +59,13 @@ extern unsigned int g_curAudOut_SamFreq;
|
|||||||
|
|
||||||
/* Global var for current frequency, set to default freq */
|
/* Global var for current frequency, set to default freq */
|
||||||
#ifdef USB_CMD_CFG_SAMP_FREQ
|
#ifdef USB_CMD_CFG_SAMP_FREQ
|
||||||
#define g_curSamFreq g_curAudOut_SamFreq
|
#define g_curUSBin_SamFreq g_curAudOut_SamFreq
|
||||||
//unsigned int g_curSamFreq = DEFAULT_AUDOUT_FREQ;
|
unsigned int g_curUSBout_SamFreq = DEFAULT_FREQ;
|
||||||
|
unsigned int g_curSamFreq = DEFAULT_FREQ; // should no longer be used
|
||||||
#else
|
#else
|
||||||
unsigned int g_curSamFreq = DEFAULT_FREQ;
|
unsigned int g_curUSBin_SamFreq = DEFAULT_FREQ;
|
||||||
|
unsigned int g_curUSBout_SamFreq = DEFAULT_FREQ;
|
||||||
|
unsigned int g_curSamFreq = DEFAULT_FREQ; // should no longer be used
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
unsigned int g_curSamFreq48000Family = DEFAULT_FREQ % 48000 == 0;
|
unsigned int g_curSamFreq48000Family = DEFAULT_FREQ % 48000 == 0;
|
||||||
@@ -341,9 +345,6 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
|
|||||||
int newMasterClock;
|
int newMasterClock;
|
||||||
|
|
||||||
g_curSamFreq = newSampleRate;
|
g_curSamFreq = newSampleRate;
|
||||||
#ifdef USB_CMD_CFG_SAMP_FREQ
|
|
||||||
g_curAudOut_SamFreq = newSampleRate;
|
|
||||||
#endif
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Original feedback implementation */
|
/* Original feedback implementation */
|
||||||
g_curSamFreq48000Family = ((MCLK_48 % g_curSamFreq) == 0);
|
g_curSamFreq48000Family = ((MCLK_48 % g_curSamFreq) == 0);
|
||||||
@@ -1096,6 +1097,7 @@ int AudioEndpointRequests_1(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp
|
|||||||
* bmRequestType.Recipient = Endpoint
|
* bmRequestType.Recipient = Endpoint
|
||||||
* bmRequestType.Type = Class
|
* bmRequestType.Type = Class
|
||||||
* endpoint (wIndex & 0xff) is 0x01 or 0x82
|
* endpoint (wIndex & 0xff) is 0x01 or 0x82
|
||||||
|
* wIndex is endpoint address for distinguishing input and output
|
||||||
*/
|
*/
|
||||||
|
|
||||||
XUD_Result_t result;
|
XUD_Result_t result;
|
||||||
@@ -1126,7 +1128,8 @@ int AudioEndpointRequests_1(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp
|
|||||||
/* Recontruct sample-freq */
|
/* Recontruct sample-freq */
|
||||||
int newSampleRate = (buffer, unsigned char[])[0] | ((buffer, unsigned char[])[1] << 8) | ((buffer, unsigned char[])[2] << 16);
|
int newSampleRate = (buffer, unsigned char[])[0] | ((buffer, unsigned char[])[1] << 8) | ((buffer, unsigned char[])[2] << 16);
|
||||||
|
|
||||||
if(newSampleRate != g_curSamFreq)
|
if(((sp.wIndex == ENDPOINT_ADDRESS_IN_AUDIO) && (newSampleRate != g_curUSBin_SamFreq)) || \
|
||||||
|
((sp.wIndex == ENDPOINT_ADDRESS_OUT_AUDIO) && (newSampleRate != g_curUSBout_SamFreq)))
|
||||||
{
|
{
|
||||||
int curSamFreq44100Family;
|
int curSamFreq44100Family;
|
||||||
int curSamFreq48000Family;
|
int curSamFreq48000Family;
|
||||||
@@ -1138,21 +1141,25 @@ int AudioEndpointRequests_1(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp
|
|||||||
|
|
||||||
if(curSamFreq48000Family || curSamFreq44100Family)
|
if(curSamFreq48000Family || curSamFreq44100Family)
|
||||||
{
|
{
|
||||||
g_curSamFreq = newSampleRate;
|
if(sp.wIndex == ENDPOINT_ADDRESS_IN_AUDIO){
|
||||||
#ifdef USB_CMD_CFG_SAMP_FREQ
|
g_curUSBin_SamFreq = newSampleRate;
|
||||||
g_curAudOut_SamFreq = newSampleRate;
|
/* Instruct audio thread to change sample freq */
|
||||||
#endif
|
outuint(c_audioControl, SET_SAMPLE_FREQ);
|
||||||
|
outuint(c_audioControl, g_curUSBin_SamFreq);
|
||||||
/* Instruct audio thread to change sample freq */
|
}
|
||||||
outuint(c_audioControl, SET_SAMPLE_FREQ);
|
else{ //if sp.wIndex == ENDPOINT_ADDRESS_OUT_AUDIO
|
||||||
outuint(c_audioControl, g_curSamFreq);
|
g_curUSBout_SamFreq = newSampleRate;
|
||||||
|
/* Instruct audio thread to change sample freq */
|
||||||
|
//outuint(c_audioControl, SET_SAMPLE_FREQ);
|
||||||
|
//outuint(c_audioControl, g_curUSBout_SamFreq); // FIXME: not implemented yet
|
||||||
|
}
|
||||||
|
|
||||||
/* Wait for handshake back - i.e. pll locked and clocks okay */
|
/* Wait for handshake back - i.e. pll locked and clocks okay */
|
||||||
chkct(c_audioControl, XS1_CT_END);
|
chkct(c_audioControl, XS1_CT_END);
|
||||||
|
|
||||||
/* Allow time for the change - feedback to stabilise */
|
/* Allow time for the change - feedback to stabilise */
|
||||||
FeedbackStabilityDelay();
|
FeedbackStabilityDelay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return XUD_SetBuffer(ep0_in, (buffer, unsigned char[]), 0);
|
return XUD_SetBuffer(ep0_in, (buffer, unsigned char[]), 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user