forked from PAWPAW-Mirror/lib_xua
Updates for new S/PDIF receiver
This commit is contained in:
@@ -219,18 +219,6 @@ static inline int validSamples(Counter &counter, int clockIndex)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (XUA_SPDIF_RX_EN)
|
|
||||||
//:badParity
|
|
||||||
/* Returns 1 for bad parity, else 0 */
|
|
||||||
static inline int badParity(unsigned x)
|
|
||||||
{
|
|
||||||
unsigned X = (x>>4);
|
|
||||||
crc32(X, 0, 1);
|
|
||||||
return X & 1;
|
|
||||||
}
|
|
||||||
//:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LEVEL_METER_LEDS
|
#ifdef LEVEL_METER_LEDS
|
||||||
void VendorLedRefresh(unsigned levelData[]);
|
void VendorLedRefresh(unsigned levelData[]);
|
||||||
unsigned g_inputLevelData[NUM_USB_CHAN_IN];
|
unsigned g_inputLevelData[NUM_USB_CHAN_IN];
|
||||||
@@ -269,9 +257,10 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
|||||||
int spdifUnderflow = 1;
|
int spdifUnderflow = 1;
|
||||||
int spdifSamps = 0; /* Number of samples in buffer */
|
int spdifSamps = 0; /* Number of samples in buffer */
|
||||||
Counter spdifCounters;
|
Counter spdifCounters;
|
||||||
int spdifReceivedTime;
|
int spdifRxTime;
|
||||||
unsigned tmp2;
|
unsigned tmp2;
|
||||||
unsigned spdifLeft = 0;
|
unsigned spdifLeft = 0;
|
||||||
|
unsigned spdifRxData;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (XUA_ADAT_RX_EN)
|
#if (XUA_ADAT_RX_EN)
|
||||||
@@ -330,7 +319,6 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
|||||||
adatCounters.samplesPerTick = 0;
|
adatCounters.samplesPerTick = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
t_local :> timeNextEdge;
|
t_local :> timeNextEdge;
|
||||||
timeLastEdge = timeNextEdge;
|
timeLastEdge = timeNextEdge;
|
||||||
timeNextClockDetection = timeNextEdge + (LOCAL_CLOCK_INCREMENT / 2);
|
timeNextClockDetection = timeNextEdge + (LOCAL_CLOCK_INCREMENT / 2);
|
||||||
@@ -521,25 +509,24 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (XUA_SPDIF_RX_EN)
|
#if (XUA_SPDIF_RX_EN)
|
||||||
/* Receive sample from S/PDIF RX thread (steaming chan) */
|
/* Receive sample from S/PDIF RX thread (streaming chan) */
|
||||||
case c_spdif_rx :> tmp:
|
case c_spdif_rx :> spdifRxData:
|
||||||
|
|
||||||
/* Record time of sample */
|
/* Record time of sample */
|
||||||
t_local :> spdifReceivedTime;
|
t_local :> spdifRxTime;
|
||||||
|
|
||||||
/* Check parity and ignore if bad */
|
/* Check parity and ignore if bad */
|
||||||
if(badParity(tmp))
|
if(spdif_check_parity(tmp))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Get pre-amble */
|
/* Get preamble */
|
||||||
tmp2 = tmp & 0xF;
|
unsigned preamble = spdifRxData & SPDIF_RX_PREAMBLE_MASK;
|
||||||
switch(tmp2)
|
switch(preamble)
|
||||||
{
|
{
|
||||||
/* LEFT */
|
/* LEFT */
|
||||||
case SPDIF_FRAME_X:
|
case SPDIF_FRAME_X:
|
||||||
case SPDIF_FRAME_Z:
|
case SPDIF_FRAME_Z:
|
||||||
|
spdifLeft = SPDIF_RX_EXTRACT_SAMPLE(spdifRxData);
|
||||||
spdifLeft = tmp << 4;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* RIGHT */
|
/* RIGHT */
|
||||||
@@ -550,7 +537,7 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
|||||||
{
|
{
|
||||||
/* Store left and right sample pair to buffer */
|
/* Store left and right sample pair to buffer */
|
||||||
spdifSamples[spdifWr] = spdifLeft;
|
spdifSamples[spdifWr] = spdifLeft;
|
||||||
spdifSamples[spdifWr+1] = tmp << 4;
|
spdifSamples[spdifWr+1] = SPDIF_RX_EXTRACT_SAMPLE(spdifRxData);
|
||||||
|
|
||||||
spdifWr = (spdifWr + 2) & (MAX_SPDIF_SAMPLES - 1);
|
spdifWr = (spdifWr + 2) & (MAX_SPDIF_SAMPLES - 1);
|
||||||
|
|
||||||
@@ -586,13 +573,13 @@ void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, client interfa
|
|||||||
if((spdifCounters.receivedSamples >= spdifCounters.samplesPerTick))
|
if((spdifCounters.receivedSamples >= spdifCounters.samplesPerTick))
|
||||||
{
|
{
|
||||||
/* Check edge is about right... S/PDIF may have changed freq... */
|
/* Check edge is about right... S/PDIF may have changed freq... */
|
||||||
if(timeafter(spdifReceivedTime, (timeLastEdge + LOCAL_CLOCK_INCREMENT - LOCAL_CLOCK_MARGIN)))
|
if(timeafter(spdifRxTime, (timeLastEdge + LOCAL_CLOCK_INCREMENT - LOCAL_CLOCK_MARGIN)))
|
||||||
{
|
{
|
||||||
/* Record edge time */
|
/* Record edge time */
|
||||||
timeLastEdge = spdifReceivedTime;
|
timeLastEdge = spdifRxTime;
|
||||||
|
|
||||||
/* Setup for next edge */
|
/* Setup for next edge */
|
||||||
timeNextEdge = spdifReceivedTime + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
|
timeNextEdge = spdifRxTime + LOCAL_CLOCK_INCREMENT + LOCAL_CLOCK_MARGIN;
|
||||||
|
|
||||||
/* Toggle edge */
|
/* Toggle edge */
|
||||||
i_pll_ref.toggle_timed(1);
|
i_pll_ref.toggle_timed(1);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
#include "iap.h"
|
#include "iap.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (XUA_SPDIF_RX_EN)
|
#if (XUA_SPDIF_RX_EN || XUA_SPDIF_TX_EN)
|
||||||
#include "spdif.h"
|
#include "spdif.h" /* From lib_spdif */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (XUA_ADAT_RX_EN)
|
#if (XUA_ADAT_RX_EN)
|
||||||
@@ -42,10 +42,6 @@
|
|||||||
#include "xua_pdm_mic.h"
|
#include "xua_pdm_mic.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (XUA_SPDIF_TX_EN)
|
|
||||||
#include "spdif.h" /* From lib_spdif */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (XUA_DFU_EN == 1)
|
#if (XUA_DFU_EN == 1)
|
||||||
[[distributable]]
|
[[distributable]]
|
||||||
void DFUHandler(server interface i_dfu i, chanend ?c_user_cmd);
|
void DFUHandler(server interface i_dfu i, chanend ?c_user_cmd);
|
||||||
@@ -142,7 +138,11 @@ on stdcore[XUD_TILE] : buffered in port:32 p_adat_rx = PORT_ADAT_IN;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (XUA_SPDIF_RX_EN)
|
#if (XUA_SPDIF_RX_EN)
|
||||||
|
#if (LEGACY_SPDIF_RECEIVER)
|
||||||
on tile[XUD_TILE] : in port p_spdif_rx = PORT_SPDIF_IN;
|
on tile[XUD_TILE] : in port p_spdif_rx = PORT_SPDIF_IN;
|
||||||
|
#else
|
||||||
|
on tile[XUD_TILE] : buffered in port:32 p_spdif_rx = PORT_SPDIF_IN;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (XUA_SPDIF_RX_EN) || (XUA_ADAT_RX_EN) || (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
#if (XUA_SPDIF_RX_EN) || (XUA_ADAT_RX_EN) || (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
|
||||||
|
|||||||
Reference in New Issue
Block a user