Merge branch 'master' into refactor_i2s

* master:
  Fixes #12
  Patches up #11
  Buffer file arrangement tidy
  Resolved build issue related to XS2 DSD fix
  Chnagelog update
  Manually applied XS2 DSD fix - could not easily cherry pick due to conflicts
  CHANGELOG tidy
  Added basic PDM mic delay (based on MIC_BUFFER_DEPTH). Default, 1 sample.
  Added XUA_ENDPOINT_COUNT_CUSTOM_IN/OUT define
  ADAT related build fixes
  Syntax error in main with digital RX
  Build fixes relating to SPDIF
  SPDIF_TX and XUA_DFU_EN changes for build
  Fixed BCD_DEVICE_N def
  Extra comment
  Use a define for USB class of control interface (from sc_usb_audio vf_spk_1.1.2 branch)

# Conflicts:
#	lib_xua/src/core/audiohub/xua_audiohub.xc
This commit is contained in:
Ed Clarke
2018-01-10 09:18:05 +00:00
16 changed files with 114 additions and 65 deletions

View File

@@ -7,18 +7,19 @@ lib_xua Change Log
- ADDED: Linux Makefile for xmosdfu host application - ADDED: Linux Makefile for xmosdfu host application
- ADDED: Raspberry Pi Makefile for xmosdfu host application - ADDED: Raspberry Pi Makefile for xmosdfu host application
- ADDED: Documentation of PID argument to xmosdfu - ADDED: Documentation of PID argument to xmosdfu
- ADDED: Optional build time microphone delay line (MIC_BUFFER_DEPTH)
- CHANGE: Removal of audManage_if, users should define their own interfaces as required - CHANGE: Removal of audManage_if, users should define their own interfaces as required
- CHANGE: Vendor specific control interface in UAC1 descriptor now has a string descriptor
so it shows up with a descriptive name in Windows Device Manager
- CHANGE: DFU_BCD_DEVICE removed (now uses BCD_DEVICE)
- CHANGE: Renaming in descriptors.h to avoid clashes with application
- RESOLVED: FIR gain compensation for PDM mics set incorrectly for divide of 8 - RESOLVED: FIR gain compensation for PDM mics set incorrectly for divide of 8
- RESOLVED: Incorrect xmosdfu DYLD path in test script code - RESOLVED: Incorrect xmosdfu DYLD path in test script code
- RESOLVED: xmosdfu cannot find XMOS device on modern MacBook Pro (#17897) - RESOLVED: xmosdfu cannot find XMOS device on modern MacBook Pro (#17897)
- RESOLVED: Issue when feedback is initially incorrect when two SOF's are not yet received - RESOLVED: Issue when feedback is initially incorrect when two SOF's are not yet received
- RESOLVED: AUDIO_TILE and PDM_TILE may now share the same value/tile - RESOLVED: AUDIO_TILE and PDM_TILE may now share the same value/tile
- RESOLVED: Cope with out of order interface numbers in xmosdfu - RESOLVED: Cope with out of order interface numbers in xmosdfu
- CHANGE: Renaming in descriptors.h to avoid clashes with application - RESOLVED: DSD playback not functional on xCORE-200 (introduced in sc_usb_audio 6.14)
- CHANGE: Vendor specific control interface in UAC1 descriptor now has a string descriptor
so it shows up with a descriptive name in Windows Device Manager
- CHANGE: DFU_BCD_DEVICE removed (used BCD_DEVICE)
- CHANGE: Fork from sc_usb_audio to lib_xua
Legacy release history Legacy release history
---------------------- ----------------------

View File

@@ -22,7 +22,7 @@
* CODEC configuration functions. * CODEC configuration functions.
*/ */
void XUA_AudioHub(chanend ?c_aud void XUA_AudioHub(chanend ?c_aud
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
, chanend c_spdif_tx , chanend c_spdif_tx
#endif #endif
#if(defined(SPDIF_RX) || defined(ADAT_RX)) #if(defined(SPDIF_RX) || defined(ADAT_RX))

View File

@@ -299,13 +299,8 @@
/** /**
* @brief Enables SPDIF Tx. Default: 0 (Disabled) * @brief Enables SPDIF Tx. Default: 0 (Disabled)
*/ */
#ifndef SPDIF_TX #ifndef XUA_SPDIF_TX_EN
#define SPDIF_TX (0) #define XUA_SPDIF_TX_EN (0)
#endif
/* Tidy up old SPDIF usage */
#if defined(SPDIF_TX) && (SPDIF_TX == 0)
#undef SPDIF_TX
#endif #endif
/** /**
@@ -521,21 +516,21 @@
* @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. * @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number.
*/ */
#ifndef BCD_DEVICE_J #ifndef BCD_DEVICE_J
#define BCD_DEVICE_J 1 #define BCD_DEVICE_J (1)
#endif #endif
/** /**
* @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. * @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number.
*/ */
#ifndef BCD_DEVICE_M #ifndef BCD_DEVICE_M
#define BCD_DEVICE_M 0 #define BCD_DEVICE_M (0)
#endif #endif
/** /**
* @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. * @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number.
*/ */
#ifndef BCD_DEVICE_N #ifndef BCD_DEVICE_N
#define BCD_DEVICE_N #define BCD_DEVICE_N (0)
#endif #endif
/** /**
@@ -1193,7 +1188,7 @@ enum USBEndpointNumber_In
ENDPOINT_NUMBER_IN_IAP_EA_NATIVE_TRANS, ENDPOINT_NUMBER_IN_IAP_EA_NATIVE_TRANS,
#endif #endif
#endif #endif
ENDPOINT_COUNT_IN /* End marker */ XUA_ENDPOINT_COUNT_IN /* End marker */
}; };
enum USBEndpointNumber_Out enum USBEndpointNumber_Out
@@ -1209,9 +1204,21 @@ enum USBEndpointNumber_Out
ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS, ENDPOINT_NUMBER_OUT_IAP_EA_NATIVE_TRANS,
#endif #endif
#endif #endif
ENDPOINT_COUNT_OUT /* End marker */ XUA_ENDPOINT_COUNT_OUT /* End marker */
}; };
#ifndef XUA_ENDPOINT_COUNT_CUSTOM_OUT
#define XUA_ENDPOINT_COUNT_CUSTOM_OUT 0
#endif
#ifndef XUA_ENDPOINT_COUNT_CUSTOM_IN
#define XUA_ENDPOINT_COUNT_CUSTOM_IN 0
#endif
#define ENDPOINT_COUNT_IN (XUA_ENDPOINT_COUNT_IN + XUA_ENDPOINT_COUNT_CUSTOM_IN)
#define ENDPOINT_COUNT_OUT (XUA_ENDPOINT_COUNT_OUT + XUA_ENDPOINT_COUNT_CUSTOM_OUT)
#endif #endif
/*** Internal defines below here. NOT FOR MODIFICATION ***/ /*** Internal defines below here. NOT FOR MODIFICATION ***/

View File

@@ -1,6 +1,6 @@
/** /**
* @file audio.xc * @file xua_audiohub.xc
* @brief XMOS L1/L2 USB 2,0 Audio Reference Design. Audio Functions. * @brief XMOS USB 2.0 Audio Reference Design. Audio Functions.
* @author Ross Owen, XMOS Semiconductor Ltd * @author Ross Owen, XMOS Semiconductor Ltd
* *
* This thread handles I2S and pars an additional SPDIF Tx thread. It forwards samples to the SPDIF Tx thread. * This thread handles I2S and pars an additional SPDIF Tx thread. It forwards samples to the SPDIF Tx thread.
@@ -19,7 +19,7 @@
#include "audioports.h" #include "audioports.h"
#include "audiohw.h" #include "audiohw.h"
#include "mic_array_conf.h" #include "mic_array_conf.h"
#ifdef SPDIF_TX #if (XUA_SPDIF_TX_EN)
#include "SpdifTransmit.h" #include "SpdifTransmit.h"
#endif #endif
#ifdef ADAT_TX #ifdef ADAT_TX
@@ -103,7 +103,7 @@ unsigned dsdMode = DSD_MODE_OFF;
extern unsafe port p_mclk_in; extern unsafe port p_mclk_in;
extern in port p_mclk_in2; extern in port p_mclk_in2;
#ifdef SPDIF_TX #if (XUA_SPDIF_TX_EN)
extern buffered out port:32 p_spdif_tx; extern buffered out port:32 p_spdif_tx;
#endif #endif
@@ -113,9 +113,12 @@ extern buffered out port:32 p_adat_tx;
extern clock clk_audio_mclk; extern clock clk_audio_mclk;
extern clock clk_audio_bclk; extern clock clk_audio_bclk;
extern clock clk_mst_spd;
extern void device_reboot(void); #if XUA_SPDIF_TX_EN || defined(ADAT_TX)
extern clock clk_mst_spd;
#endif
//extern void device_reboot(void);
#define MAX_DIVIDE_48 (MCLK_48/MIN_FREQ_48/64) #define MAX_DIVIDE_48 (MCLK_48/MIN_FREQ_48/64)
#define MAX_DIVIDE_44 (MCLK_44/MIN_FREQ_44/64) #define MAX_DIVIDE_44 (MCLK_44/MIN_FREQ_44/64)
@@ -812,7 +815,7 @@ unsigned static deliver_master(chanend ?c_out, chanend ?c_spd_out
/* Request digital data (with prefill) */ /* Request digital data (with prefill) */
outuint(c_dig_rx, 0); outuint(c_dig_rx, 0);
#endif #endif
#if defined(SPDIF_TX) && (NUM_USB_CHAN_OUT > 0) #if (XUA_SPDIF_TX_EN) && (NUM_USB_CHAN_OUT > 0)
outuint(c_spd_out, samplesOut[SPDIF_TX_INDEX]); /* Forward sample to S/PDIF Tx thread */ outuint(c_spd_out, samplesOut[SPDIF_TX_INDEX]); /* Forward sample to S/PDIF Tx thread */
unsigned sample = samplesOut[SPDIF_TX_INDEX + 1]; unsigned sample = samplesOut[SPDIF_TX_INDEX + 1];
outuint(c_spd_out, sample); /* Forward sample to S/PDIF Tx thread */ outuint(c_spd_out, sample); /* Forward sample to S/PDIF Tx thread */
@@ -1380,8 +1383,7 @@ unsigned static deliver_slave(chanend ?c_out, chanend ?c_spd_out
} }
#endif //CODEC_MASTER #endif //CODEC_MASTER
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
void SpdifTxWrapper(chanend c_spdif_tx) void SpdifTxWrapper(chanend c_spdif_tx)
{ {
unsigned portId; unsigned portId;
@@ -1465,11 +1467,11 @@ static void dummy_deliver(chanend ?c_out, unsigned &command)
} }
void XUA_AudioHub(chanend ?c_mix_out void XUA_AudioHub(chanend ?c_mix_out
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
chanend c_spdif_out, , chanend c_spdif_out
#endif #endif
#if (defined(ADAT_RX) || defined(SPDIF_RX)) #if (defined(ADAT_RX) || defined(SPDIF_RX))
chanend c_dig_rx, , chanend c_dig_rx
#endif #endif
#if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1)
, server interface i_dfu ?dfuInterface , server interface i_dfu ?dfuInterface
@@ -1479,7 +1481,7 @@ chanend c_dig_rx,
#endif #endif
) )
{ {
#if defined (SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
chan c_spdif_out; chan c_spdif_out;
#endif #endif
#ifdef ADAT_TX #ifdef ADAT_TX
@@ -1515,16 +1517,22 @@ chanend c_dig_rx,
#endif #endif
#ifdef ADAT_TX #ifdef ADAT_TX
/* Share SPDIF clk blk */ /* Share SPDIF clk blk */
configure_clock_src(clk_mst_spd, p_mclk_in); unsafe
{
configure_clock_src(clk_mst_spd, (port)p_mclk_in);
}
configure_out_port_no_ready(p_adat_tx, clk_mst_spd, 0); configure_out_port_no_ready(p_adat_tx, clk_mst_spd, 0);
set_clock_fall_delay(clk_mst_spd, 7); set_clock_fall_delay(clk_mst_spd, 7);
#ifndef SPDIF_TX #if (XUA_SPDIF_TX_EN == 0)
start_clock(clk_mst_spd); start_clock(clk_mst_spd);
#endif #endif
#endif #endif
/* Configure ADAT/SPDIF tx ports */ /* Configure ADAT/SPDIF tx ports */
#if defined(SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
SpdifTransmitPortConfig(p_spdif_tx, clk_mst_spd, p_mclk_in); unsafe
{
SpdifTransmitPortConfig(p_spdif_tx, clk_mst_spd, (port)p_mclk_in);
}
#endif #endif
/* Perform required CODEC/ADC/DAC initialisation */ /* Perform required CODEC/ADC/DAC initialisation */
@@ -1670,7 +1678,7 @@ chanend c_dig_rx,
par par
{ {
#if defined(SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
{ {
set_thread_fast_mode_on(); set_thread_fast_mode_on();
SpdifTransmit(p_spdif_tx, c_spdif_out); SpdifTransmit(p_spdif_tx, c_spdif_out);
@@ -1684,7 +1692,7 @@ chanend c_dig_rx,
} }
#endif #endif
{ {
#ifdef SPDIF_TX #if (XUA_SPDIF_TX_EN)
/* Communicate master clock and sample freq to S/PDIF thread */ /* Communicate master clock and sample freq to S/PDIF thread */
outuint(c_spdif_out, curSamFreq); outuint(c_spdif_out, curSamFreq);
outuint(c_spdif_out, mClk); outuint(c_spdif_out, mClk);
@@ -1713,7 +1721,7 @@ chanend c_dig_rx,
#else #else
command = deliver_master(c_mix_out command = deliver_master(c_mix_out
#endif #endif
#ifdef SPDIF_TX #ifdef XUA_SPDIF_TX_EN
, c_spdif_out , c_spdif_out
#else #else
, null , null
@@ -1779,7 +1787,7 @@ chanend c_dig_rx,
#endif /* NO_USB */ #endif /* NO_USB */
#ifdef SPDIF_TX #if (XUA_SPDIF_TX_EN)
/* Notify S/PDIF task of impending new freq... */ /* Notify S/PDIF task of impending new freq... */
outct(c_spdif_out, XS1_CT_END); outct(c_spdif_out, XS1_CT_END);
#endif #endif

View File

@@ -61,8 +61,13 @@ static xc_ptr p_multIn;
#endif #endif
/* Number of channels to/from the USB bus - initialised to HS Audio 2.0 */ /* Number of channels to/from the USB bus - initialised to HS Audio 2.0 */
unsigned g_numUsbChan_Out = NUM_USB_CHAN_OUT; #if (AUDIO_CLASS == 1)
unsigned g_numUsbChan_In = NUM_USB_CHAN_IN_FS;
unsigned g_numUsbChan_Out = NUM_USB_CHAN_OUT_FS;
#else
unsigned g_numUsbChan_In = NUM_USB_CHAN_IN; unsigned g_numUsbChan_In = NUM_USB_CHAN_IN;
unsigned g_numUsbChan_Out = NUM_USB_CHAN_OUT;
#endif
/* Circular audio buffers */ /* Circular audio buffers */
unsigned outAudioBuff[(BUFF_SIZE_OUT >> 2)+ (MAX_DEVICE_AUD_PACKET_SIZE_OUT >> 2)]; unsigned outAudioBuff[(BUFF_SIZE_OUT >> 2)+ (MAX_DEVICE_AUD_PACKET_SIZE_OUT >> 2)];
@@ -588,6 +593,15 @@ static inline void SetupZerosSendBuffer(XUD_ep aud_to_host_usb_ep, unsigned samp
asm volatile("stw %0, %1[0]"::"r"(mid),"r"(g_aud_to_host_zeros)); asm volatile("stw %0, %1[0]"::"r"(mid),"r"(g_aud_to_host_zeros));
#if XUA_DEBUG_BUFFER
printstr("slotSize: ");
printintln(slotSize);
printstr("g_numUsbChan_In: ");
printintln(g_numUsbChan_In);
printstr("mid: ");
printintln(mid);
#endif
/* Mark EP ready with the zero buffer. Note this will simply update the packet size /* Mark EP ready with the zero buffer. Note this will simply update the packet size
* if it is already ready */ * if it is already ready */
@@ -693,7 +707,7 @@ void XUA_Buffer_Decouple(chanend c_mix_out
/* NOTE: For UAC2 IN EP not marked ready at this point - Initial size of zero buffer not known /* NOTE: For UAC2 IN EP not marked ready at this point - Initial size of zero buffer not known
* since we don't know the USB bus-speed yet. * since we don't know the USB bus-speed yet.
* The host will send a SetAltInterface before streaming which will lead to this core * The host will send a SetAltInterface before streaming which will lead to this core
* getting a SET_CHANNEL_COUNT_IN. This will setup the EP for the first packet */ * getting a SET_STREAM_FORMAT_IN. This will setup the EP for the first packet */
#if (AUDIO_CLASS == 1) #if (AUDIO_CLASS == 1)
/* For UAC1 we know we only run at FS */ /* For UAC1 we know we only run at FS */
/* Set buffer back to zeros buffer */ /* Set buffer back to zeros buffer */

View File

@@ -1,5 +1,5 @@
#ifndef NO_USB #ifndef NO_USB
#include <interrupt.h> #include "interrupt.h"
register_interrupt_handler(handle_audio_request, 1, 200) register_interrupt_handler(handle_audio_request, 1, 200)
#endif #endif

View File

@@ -137,7 +137,7 @@ unsafe
on tile[XUD_TILE] : in port p_for_mclk_count = PORT_MCLK_COUNT; on tile[XUD_TILE] : in port p_for_mclk_count = PORT_MCLK_COUNT;
#endif #endif
#ifdef SPDIF_TX #if (XUA_SPDIF_TX_EN == 1)
on tile[SPDIF_TX_TILE] : buffered out port:32 p_spdif_tx = PORT_SPDIF_OUT; on tile[SPDIF_TX_TILE] : buffered out port:32 p_spdif_tx = PORT_SPDIF_OUT;
#endif #endif
@@ -177,7 +177,7 @@ clock clk_pdm = on tile[PDM_TILE]:
on tile[MIDI_TILE] : clock clk_midi = CLKBLK_MIDI; on tile[MIDI_TILE] : clock clk_midi = CLKBLK_MIDI;
#endif #endif
#if defined(SPDIF_TX) || defined(ADAT_TX) #if XUA_SPDIF_TX_EN || defined(ADAT_TX)
on tile[SPDIF_TX_TILE] : clock clk_mst_spd = CLKBLK_SPDIF_TX; on tile[SPDIF_TX_TILE] : clock clk_mst_spd = CLKBLK_SPDIF_TX;
#endif #endif
@@ -371,7 +371,10 @@ VENDOR_REQUESTS_PARAMS_DEC_
#endif #endif
//:buffer //:buffer
XUA_Buffer(c_xud_out[ENDPOINT_NUMBER_OUT_AUDIO],/* Audio Out*/ XUA_Buffer(c_xud_out[ENDPOINT_NUMBER_OUT_AUDIO],/* Audio Out*/
#if (NUM_USB_CHAN_IN > 0)
c_xud_in[ENDPOINT_NUMBER_IN_AUDIO], /* Audio In */ c_xud_in[ENDPOINT_NUMBER_IN_AUDIO], /* Audio In */
#endif
#if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) #if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP)
c_xud_in[ENDPOINT_NUMBER_IN_FEEDBACK], /* Audio FB */ c_xud_in[ENDPOINT_NUMBER_IN_FEEDBACK], /* Audio FB */
#endif #endif
@@ -423,7 +426,7 @@ VENDOR_REQUESTS_PARAMS_DEC_
#endif /* NO_USB */ #endif /* NO_USB */
void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc, void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
chanend c_spdif_tx, chanend c_spdif_tx,
#endif #endif
#ifdef MIXER #ifdef MIXER
@@ -433,7 +436,7 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
chanend ?c_adat_rx, chanend ?c_adat_rx,
chanend ?c_clk_ctl, chanend ?c_clk_ctl,
chanend ?c_clk_int chanend ?c_clk_int
#if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1)
, server interface i_dfu ?dfuInterface , server interface i_dfu ?dfuInterface
#endif #endif
#if (NUM_PDM_MICS > 0) #if (NUM_PDM_MICS > 0)
@@ -469,11 +472,11 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
#define AUDIO_CHANNEL c_aud_in #define AUDIO_CHANNEL c_aud_in
#endif #endif
XUA_AudioHub(AUDIO_CHANNEL XUA_AudioHub(AUDIO_CHANNEL
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
c_spdif_tx, , c_spdif_tx
#endif #endif
#if defined(SPDIF_RX) || defined(ADAT_RX) #if defined(SPDIF_RX) || defined(ADAT_RX)
c_dig_rx, , c_dig_rx
#endif #endif
#if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1)
, dfuInterface , dfuInterface
@@ -545,7 +548,7 @@ int main()
#define c_adat_rx null #define c_adat_rx null
#endif #endif
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
chan c_spdif_tx; chan c_spdif_tx;
#endif #endif
@@ -617,7 +620,7 @@ int main()
p_mclk_in = p_mclk_in_; p_mclk_in = p_mclk_in_;
} }
usb_audio_io(c_mix_out, c_adc usb_audio_io(c_mix_out, c_adc
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
, c_spdif_tx , c_spdif_tx
#endif #endif
#ifdef MIXER #ifdef MIXER
@@ -633,7 +636,7 @@ int main()
); );
} }
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
on tile[SPDIF_TX_TILE]: on tile[SPDIF_TX_TILE]:
{ {
thread_speed(); thread_speed();

View File

@@ -34,6 +34,10 @@ extern unsafe port p_mclk_in;
/* Delcared in main.xc */ /* Delcared in main.xc */
extern clock clk_pdm; extern clock clk_pdm;
#ifndef MIC_BUFFER_DEPTH
#define MIC_BUFFER_DEPTH 1
#endif
int mic_decimator_fir_data[8][THIRD_STAGE_COEFS_PER_STAGE * MAX_DECIMATION_FACTOR] = {{0}}; int mic_decimator_fir_data[8][THIRD_STAGE_COEFS_PER_STAGE * MAX_DECIMATION_FACTOR] = {{0}};
mic_array_frame_time_domain mic_audio[2]; mic_array_frame_time_domain mic_audio[2];
@@ -50,7 +54,7 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
{ {
unsigned buffer; unsigned buffer;
unsigned samplerate; unsigned samplerate;
int output[NUM_PDM_MICS]; int output[MIC_BUFFER_DEPTH][NUM_PDM_MICS];
#ifdef MIC_PROCESSING_USE_INTERFACE #ifdef MIC_PROCESSING_USE_INTERFACE
i_mic_process.init(); i_mic_process.init();
@@ -64,12 +68,15 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
unsigned decimatorCount = 1; unsigned decimatorCount = 1;
#endif #endif
unsigned micBufferWrite = (MIC_BUFFER_DEPTH -1);
unsigned micBufferRead = 0;
mic_array_decimator_conf_common_t dcc; mic_array_decimator_conf_common_t dcc;
const int * unsafe fir_coefs[7]; const int * unsafe fir_coefs[7];
mic_array_frame_time_domain * unsafe current; mic_array_frame_time_domain * unsafe current;
mic_array_decimator_config_t dc[2]; mic_array_decimator_config_t dc[2];
/* Get initial sample-rate and compute decimation factor */ /* Get initial sample-rate to run this thread at and compute decimation factor */
c_audio :> samplerate; c_audio :> samplerate;
unsigned decimationfactor = 96000/samplerate; unsigned decimationfactor = 96000/samplerate;
@@ -154,8 +161,11 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
#pragma loop unroll #pragma loop unroll
for(int i = 0; i < NUM_PDM_MICS; i++) for(int i = 0; i < NUM_PDM_MICS; i++)
{ {
c_audio <: output[i]; c_audio <: output[micBufferRead][i];
} }
micBufferRead++;
if(micBufferRead == MIC_BUFFER_DEPTH)
micBufferRead = 0;
} }
/* Get a new frame of mic data */ /* Get a new frame of mic data */
@@ -171,8 +181,11 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
#pragma loop unroll #pragma loop unroll
for(int i = 0; i < NUM_PDM_MICS; i++) for(int i = 0; i < NUM_PDM_MICS; i++)
{ {
output[i] = current->data[i][0]; output[micBufferWrite][i] = current->data[i][0];
} }
micBufferWrite++;
if(micBufferWrite == MIC_BUFFER_DEPTH)
micBufferWrite = 0;
} }
else else
unsafe{ unsafe{
@@ -199,8 +212,11 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
#pragma loop unroll #pragma loop unroll
for(int i = 0; i < NUM_PDM_MICS; i++) for(int i = 0; i < NUM_PDM_MICS; i++)
{ {
output[i] = current->data[i][0]; output[micBufferWrite][i] = current->data[i][0];
} }
micBufferWrite++;
if(micBufferWrite == MIC_BUFFER_DEPTH)
micBufferWrite = 0;
} }
break; break;
} /* select */ } /* select */

View File

@@ -1985,7 +1985,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2=
INTERFACE_NUMBER_DFU, /* 2 bInterfaceNumber : Index of this interface. (field size 1 bytes) */ INTERFACE_NUMBER_DFU, /* 2 bInterfaceNumber : Index of this interface. (field size 1 bytes) */
0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */ 0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */
0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */ 0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */
0xFE, /* 5 bInterfaceClass : DFU. (field size 1 bytes) */ 0xFE, /* 5 bInterfaceClass : DFU. (Application Specific) (field size 1 bytes) */
0x01, /* 6 bInterfaceSubclass : (field size 1 bytes) */ 0x01, /* 6 bInterfaceSubclass : (field size 1 bytes) */
0x01, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */ 0x01, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */
offsetof(StringDescTable_t, dfuStr)/sizeof(char *), /* 8 iInterface */ offsetof(StringDescTable_t, dfuStr)/sizeof(char *), /* 8 iInterface */
@@ -2751,7 +2751,7 @@ unsigned char cfgDesc_Audio1[] =
(OUTPUT_INTERFACES_A1 + INPUT_INTERFACES_A1 + NUM_CONTROL_USB_INTERFACES + 1), /* 2 bInterfaceNumber : Index of this interface. (field size 1 bytes) */ (OUTPUT_INTERFACES_A1 + INPUT_INTERFACES_A1 + NUM_CONTROL_USB_INTERFACES + 1), /* 2 bInterfaceNumber : Index of this interface. (field size 1 bytes) */
0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */ 0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */
0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */ 0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */
0xFE, /* 5 bInterfaceClass : DFU. (field size 1 bytes) */ 0xFE, /* 5 bInterfaceClass : DFU. (Application Specific) (field size 1 bytes) */
0x01, /* 6 bInterfaceSubclass : (field size 1 bytes) */ 0x01, /* 6 bInterfaceSubclass : (field size 1 bytes) */
0x01, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */ 0x01, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */
offsetof(StringDescTable_t, dfuStr)/sizeof(char *), /* 8 iInterface */ offsetof(StringDescTable_t, dfuStr)/sizeof(char *), /* 8 iInterface */
@@ -2775,7 +2775,7 @@ unsigned char cfgDesc_Audio1[] =
(OUTPUT_INTERFACES_A1 + INPUT_INTERFACES_A1 + 1), /* 2 bInterfaceNumber */ (OUTPUT_INTERFACES_A1 + INPUT_INTERFACES_A1 + 1), /* 2 bInterfaceNumber */
0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */ 0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */
0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */ 0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */
0xFF, /* 5 bInterfaceClass : DFU. (field size 1 bytes) */ USB_CLASS_VENDOR_SPECIFIC, /* 5 bInterfaceClass : Vendor specific. (field size 1 bytes) */
0xFF, /* 6 bInterfaceSubclass : (field size 1 bytes) */ 0xFF, /* 6 bInterfaceSubclass : (field size 1 bytes) */
0xFF, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */ 0xFF, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */
offsetof(StringDescTable_t, ctrlStr)/sizeof(char *), /* 8 iInterface */ offsetof(StringDescTable_t, ctrlStr)/sizeof(char *), /* 8 iInterface */