- Added AudioHwConfig_Mute() and AudioHwConfig_UnMute()

- Added default (empty) implementations of AudioHW.. functions
This commit is contained in:
Ross Owen
2023-07-13 14:12:41 +01:00
parent 1574137dda
commit 2f11eda7d8
3 changed files with 62 additions and 11 deletions

View File

@@ -63,16 +63,32 @@ void XUA_AudioHub(chanend ?c_aud,
void SpdifTxWrapper(chanend c_spdif_tx);
/* These functions must be implemented for the CODEC/ADC/DAC arrangement of a specific design */
/* The 4 functions below should implemented for the external audio haardware arrangement of a specific design.
* Note, default (empty) implementations of these are provided in audiohub_user.c
*/
/* Any required clocking and CODEC initialisation - run once at start up */
/* TODO Provide default implementation of this */
void AudioHwInit();
/** User code for any required audio hardwarte initialisation - run once at start up */
void AudioHwInit(void);
/* Configure audio hardware (clocking, CODECs etc) for a specific mClk/Sample frquency - run on every sample frequency change */
/* TODO Provide default implementation of this */
void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode,
unsigned sampRes_DAC, unsigned sampRes_ADC);
/** User code to mute audio hardware before a sample rate change - run every sample frequency change */
void AudioHwConfig_Mute(void);
/** User code to un-mute audio hardware after a sample rate change - run every sample frequency change */
void AudioHwConfig_UnMute(void);
/** User code Configure audio hardware (clocking, CODECs etc) for a specific mClk/Sample frquency - run on every sample frequency change
*
* \param samFreq The new sample frequency (in Hz)
*
* \param mclk The new master clock frequency (in Hz)
*
* \param dsdMode DSD mode, DSD_MODE_NATIVE, DSD_MODE_DOP or DSD_MODE_OFF
*
* \param sampReq_DAC Playback sample resolution (in bits)
*
* \param sampReq_ADC Record sample resolution (in bits)
*/
void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode, unsigned sampRes_DAC, unsigned sampRes_ADC);
#endif // __XC__

View File

@@ -0,0 +1,29 @@
// Copyright 2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
/* Default implementations of AudioHwInit(), AudioHwConfig(), AudioHwConfig_Mute() and AudioHwConfig_UnMute() */
void AudioHwInit() __attribute__ ((weak));
void AudioHwInit()
{
return;
}
void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode, unsigned sampRes_DAC, unsigned sampRes_ADC) __attribute__ ((weak));
void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode, unsigned sampRes_DAC, unsigned sampRes_ADC)
{
return;
}
void AudioHwConfig_Mute() __attribute__ ((weak));
void AudioHwConfig_Mute()
{
return;
}
void AudioHwConfig_UnMute() __attribute__ ((weak));
void AudioHwConfig_UnMute()
{
return;
}

View File

@@ -86,7 +86,7 @@ static inline int HandleSampleClock(int frameCount, buffered _XUA_CLK_DIR port:3
unsigned syncError = 0;
unsigned lrval = 0;
const unsigned lrval_mask = (0xffffffff << (32 - XUA_I2S_N_BITS));
if(XUA_I2S_N_BITS != 32)
{
asm volatile("in %0, res[%1]":"=r"(lrval):"r"(p_lrclk):"memory");
@@ -306,7 +306,7 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out
// Manual IN instruction since compiler generates an extra setc per IN (bug #15256)
unsigned sample;
asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index]));
sample = bitrev(sample);
if(XUA_I2S_N_BITS != 32)
{
@@ -805,12 +805,18 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk,
}
#endif
/* User should mute audio hardware */
AudioHwConfig_Mute();
#if (XUA_USE_APP_PLL)
AppPllEnable(tile[AUDIO_IO_TILE], mClk);
#endif
/* Configure Clocking/CODEC/DAC/ADC for SampleFreq/MClk */
/* User code should configure audio harware for SampleFreq/MClk etc */
AudioHwConfig(curFreq, mClk, dsdMode, curSamRes_DAC, curSamRes_ADC);
/* User should unmute audio hardware */
AudioHwConfig_UnMute();
}
if(!firstRun)