forked from PAWPAW-Mirror/lib_xua
added option USB_CMD_CFG_SAMP_FREQ that allows host to conifgure sampling rate by endpoint command
This commit is contained in:
@@ -231,13 +231,30 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef DEFAULT_AUDOUT_FREQ
|
#ifndef DEFAULT_AUDOUT_FREQ
|
||||||
#define DEFAULT_AUDOUT_FREQ (48000)
|
#define DEFAULT_AUDOUT_FREQ (48000)
|
||||||
|
|
||||||
#define USB_IN_DESCRIPTOR_FREQ_OVERRIDE //used if USB in frequency is not conifigurable by USB endpoint command
|
|
||||||
#ifdef USB_IN_DESCRIPTOR_FREQ_OVERRIDE
|
|
||||||
#define USB_IN_FREQ_DESCIPTOR_OFFSET 161 //161- (3 * 3) are the position of descriptor that needed to be modified for USB in frequency
|
|
||||||
#define CHARIFY_SR(x) (x & 0xff),((x & 0xff00)>> 8),((x & 0xff0000)>> 16)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define USB_CMD_CFG_SAMP_FREQ
|
||||||
|
// Not ready yet
|
||||||
|
// #define USB_IN_CONFIGURABLE_BIT_RES
|
||||||
|
// #ifdef USB_IN_CONFIGURABLE_BIT_RES
|
||||||
|
// #define USB_IN_BIT_RES_0 STREAM_FORMAT_INPUT_1_RESOLUTION_BITS
|
||||||
|
// #define USB_IN_BIT_RES_1 STREAM_FORMAT_INPUT_1_RESOLUTION_BITS//24
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
#ifdef USB_CMD_CFG_SAMP_FREQ
|
||||||
|
#define USB_IN_SAMP_FREQ_NUM 3
|
||||||
|
#define USB_IN_SAMP_FREQ_0 DEFAULT_AUDOUT_FREQ
|
||||||
|
#define USB_IN_SAMP_FREQ_1 16000
|
||||||
|
#define USB_IN_SAMP_FREQ_2 16000
|
||||||
|
|
||||||
|
#if (USB_IN_SAMP_FREQ_NUM < 3)
|
||||||
|
#error "USB_IN_SAMP_FREQ_NUM must be >=3"
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define USB_IN_DESCRIPTOR_FREQ_OVERRIDE //used if USB in frequency is not conifigurable by USB endpoint command
|
||||||
|
#ifdef USB_IN_DESCRIPTOR_FREQ_OVERRIDE
|
||||||
|
#define USB_IN_FREQ_DESCIPTOR_OFFSET 161 //161- (3 * 3) are the position of descriptor that needed to be modified for USB in frequency
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Audio Class Defines */
|
/* Audio Class Defines */
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "iap2.h" /* Defines iAP EA Native Transport protocol name */
|
#include "iap2.h" /* Defines iAP EA Native Transport protocol name */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "xua_conf_default.h"
|
||||||
|
|
||||||
#define APPEND_VENDOR_STR(x) VENDOR_STR" "#x
|
#define APPEND_VENDOR_STR(x) VENDOR_STR" "#x
|
||||||
|
|
||||||
#define APPEND_PRODUCT_STR_A2(x) PRODUCT_STR_A2 " "#x
|
#define APPEND_PRODUCT_STR_A2(x) PRODUCT_STR_A2 " "#x
|
||||||
@@ -2738,6 +2740,13 @@ unsigned char cfgDesc_Audio1[] =
|
|||||||
NUM_USB_CHAN_IN_FS, /* bNrChannels - Typically 2 */
|
NUM_USB_CHAN_IN_FS, /* bNrChannels - Typically 2 */
|
||||||
FS_STREAM_FORMAT_INPUT_1_SUBSLOT_BYTES, /* subFrameSize - Typically 4 bytes per slot */
|
FS_STREAM_FORMAT_INPUT_1_SUBSLOT_BYTES, /* subFrameSize - Typically 4 bytes per slot */
|
||||||
FS_STREAM_FORMAT_INPUT_1_RESOLUTION_BITS, /* bitResolution - Typically 24bit */
|
FS_STREAM_FORMAT_INPUT_1_RESOLUTION_BITS, /* bitResolution - Typically 24bit */
|
||||||
|
|
||||||
|
#ifdef USB_CMD_CFG_SAMP_FREQ
|
||||||
|
USB_IN_SAMP_FREQ_NUM,
|
||||||
|
CHARIFY_SR(USB_IN_SAMP_FREQ_0),
|
||||||
|
CHARIFY_SR(USB_IN_SAMP_FREQ_1),
|
||||||
|
CHARIFY_SR(USB_IN_SAMP_FREQ_2),
|
||||||
|
#else
|
||||||
num_freqs_a1, /* SamFreqType - sample freq count */
|
num_freqs_a1, /* SamFreqType - sample freq count */
|
||||||
|
|
||||||
/* Windows enum issue with <= two sample rates work around */
|
/* Windows enum issue with <= two sample rates work around */
|
||||||
@@ -2790,6 +2799,7 @@ unsigned char cfgDesc_Audio1[] =
|
|||||||
#if (MIN_FREQ <= 96000) && (MAX_FREQ_FS >= 96000)
|
#if (MIN_FREQ <= 96000) && (MAX_FREQ_FS >= 96000)
|
||||||
0x00, 0x77, 0x01, /* sampleFreq - 96KHz */
|
0x00, 0x77, 0x01, /* sampleFreq - 96KHz */
|
||||||
#endif
|
#endif
|
||||||
|
#endif //USB_CMD_CFG_SAMP_FREQ
|
||||||
|
|
||||||
/* Standard Endpoint Descriptor */
|
/* Standard Endpoint Descriptor */
|
||||||
0x09,
|
0x09,
|
||||||
|
|||||||
@@ -17,6 +17,12 @@
|
|||||||
#ifdef MIXER
|
#ifdef MIXER
|
||||||
#include "mixer.h"
|
#include "mixer.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "xua_conf_default.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define DEBUG_UNIT XUA_EP0_UACREQS
|
||||||
|
#define DEBUG_PRINT_ENABLE_XUA_EP0_UACREQS 0
|
||||||
|
#include "debug_print.h"
|
||||||
|
|
||||||
#define CS_XU_MIXSEL (0x06)
|
#define CS_XU_MIXSEL (0x06)
|
||||||
|
|
||||||
@@ -45,8 +51,17 @@ extern unsigned char channelMapUsb[NUM_USB_CHAN_IN];
|
|||||||
extern unsigned char mixSel[MAX_MIX_COUNT][MIX_INPUTS];
|
extern unsigned char mixSel[MAX_MIX_COUNT][MIX_INPUTS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USB_CMD_CFG_SAMP_FREQ
|
||||||
|
extern unsigned int g_curAudOut_SamFreq;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Global var for current frequency, set to default freq */
|
/* Global var for current frequency, set to default freq */
|
||||||
|
#ifdef DEFAULT_AUDOUT_FREQ
|
||||||
|
unsigned int g_curSamFreq = DEFAULT_AUDOUT_FREQ;
|
||||||
|
#else
|
||||||
unsigned int g_curSamFreq = DEFAULT_FREQ;
|
unsigned int g_curSamFreq = DEFAULT_FREQ;
|
||||||
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
unsigned int g_curSamFreq48000Family = DEFAULT_FREQ % 48000 == 0;
|
unsigned int g_curSamFreq48000Family = DEFAULT_FREQ % 48000 == 0;
|
||||||
|
|
||||||
@@ -325,6 +340,9 @@ 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);
|
||||||
@@ -1098,7 +1116,7 @@ int AudioEndpointRequests_1(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp
|
|||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#if (MAX_FREQ != MIN_FREQ)
|
#if ((MAX_FREQ != MIN_FREQ) || (defined USB_CMD_CFG_SAMP_FREQ)
|
||||||
if(controlSelector == SAMPLING_FREQ_CONTROL)
|
if(controlSelector == SAMPLING_FREQ_CONTROL)
|
||||||
{
|
{
|
||||||
/* Expect length 3 for sample rate */
|
/* Expect length 3 for sample rate */
|
||||||
@@ -1120,6 +1138,9 @@ int AudioEndpointRequests_1(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp
|
|||||||
if(curSamFreq48000Family || curSamFreq44100Family)
|
if(curSamFreq48000Family || curSamFreq44100Family)
|
||||||
{
|
{
|
||||||
g_curSamFreq = newSampleRate;
|
g_curSamFreq = newSampleRate;
|
||||||
|
#ifdef USB_CMD_CFG_SAMP_FREQ
|
||||||
|
g_curAudOut_SamFreq = newSampleRate;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Instruct audio thread to change sample freq */
|
/* Instruct audio thread to change sample freq */
|
||||||
outuint(c_audioControl, SET_SAMPLE_FREQ);
|
outuint(c_audioControl, SET_SAMPLE_FREQ);
|
||||||
|
|||||||
Reference in New Issue
Block a user