Fix for input sample alignment in TDM mde.

This commit is contained in:
Ross Owen
2015-05-22 11:17:29 +01:00
parent 91738ee2bc
commit 6840e9d95f

View File

@@ -622,7 +622,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
/* Input previous L sample into L in buffer */ /* Input previous L sample into L in buffer */
index = 0; index = 0;
/* First input (i.e. frameCount == 0) we read last ADC channel of previous frame.. */ /* First input (i.e. frameCount == 0) we read last ADC channel of previous frame.. */
unsigned buffIndex = frameCount ? !readBuffNo : readBuffNo; unsigned buffIndex = (frameCount < 3) ? !readBuffNo : readBuffNo;
#pragma loop unroll #pragma loop unroll
/* First time around we get channel 7 of TDM8 */ /* First time around we get channel 7 of TDM8 */
@@ -634,9 +634,9 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
/* Note the use of readBuffNo changes based on frameCount */ /* Note the use of readBuffNo changes based on frameCount */
if(buffIndex) if(buffIndex)
samplesIn_1[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i] = bitrev(sample); // channels 1, 3, 5.. on each line. samplesIn_1[((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i] = bitrev(sample); // channels 0, 2, 4.. on each line.
else else
samplesIn_0[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i] = bitrev(sample); // channels 1, 3, 5.. on each line. samplesIn_0[((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i] = bitrev(sample);
} }
#endif #endif
@@ -672,12 +672,6 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
doI2SClocks(divide); doI2SClocks(divide);
#endif #endif
#ifdef ADAT_TX #ifdef ADAT_TX
TransferAdatTxSamples(c_adat_out, samplesOut, adatSmuxMode, 1); TransferAdatTxSamples(c_adat_out, samplesOut, adatSmuxMode, 1);
#endif #endif
@@ -727,10 +721,11 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
{ {
/* Manual IN instruction since compiler generates an extra setc per IN (bug #15256) */ /* Manual IN instruction since compiler generates an extra setc per IN (bug #15256) */
asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index++])); asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index++]));
if(readBuffNo) if(buffIndex)
samplesIn_0[frameCount+i] = bitrev(sample); samplesIn_1[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i] = bitrev(sample); // channels 1, 3, 5.. on each line.
else else
samplesIn_1[frameCount+i] = bitrev(sample); samplesIn_0[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i] = bitrev(sample); // channels 1, 3, 5.. on each line.
} }
#ifdef SU1_ADC_ENABLE #ifdef SU1_ADC_ENABLE
@@ -743,9 +738,6 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out,
#endif #endif
#endif #endif
#ifndef CODEC_MASTER #ifndef CODEC_MASTER
#ifdef I2S_MODE_TDM #ifdef I2S_MODE_TDM
if(frameCount == (I2S_CHANS_PER_FRAME-2)) if(frameCount == (I2S_CHANS_PER_FRAME-2))