summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 82d0776)
raw | patch | inline | side by side (parent: 82d0776)
author | Frank Livingston <frank-livingston@ti.com> | |
Mon, 14 May 2018 22:58:51 +0000 (17:58 -0500) | ||
committer | Frank Livingston <frank-livingston@ti.com> | |
Mon, 14 May 2018 22:58:51 +0000 (17:58 -0500) |
Dynamically size IO Buff buffer from which to allocate.
Size is multiple of:
Stream AF sample count x stride x size of element.
- Stream AF sample count is computed from ASP chain reset.
- Stride is from Output shortcut (select devices, McASP LLD config).
- Size of element is hard-coded in some place to 4. This need to be checked.
It should be possible to obtain size of element from the Output shortcut.
Size is multiple of:
Stream AF sample count x stride x size of element.
- Stream AF sample count is computed from ASP chain reset.
- Stride is from Output shortcut (select devices, McASP LLD config).
- Size of element is hard-coded in some place to 4. This need to be checked.
It should be possible to obtain size of element from the Output shortcut.
diff --git a/pasdk/common/asp0.c b/pasdk/common/asp0.c
index ffd178bb34814fcca9d1dd34dbf8c9ee5af209df..ed07f41e47a8809a904c36f37cbffffce4de5a60 100644 (file)
--- a/pasdk/common/asp0.c
+++ b/pasdk/common/asp0.c
return errno;
}
#endif /* PAF_ASP_FINAL */
-#if 1
/* ASP Algorithms are self-deactivating and framework-deactivated */
if (((ALG_Handle )alg)->fxns->algDeactivate)
((ALG_Handle )alg)->fxns->algDeactivate (((ALG_Handle )alg));
-#endif
}
return 0;
diff --git a/pasdk/test_dsp/framework/audioStreamOutDec.c b/pasdk/test_dsp/framework/audioStreamOutDec.c
index 989e9923ad01d0af2f900980cfb19492c048041f..4eb50bf68d7096bdbf951bc22fea5d428813a68f 100644 (file)
return status;
}
-// Purpose: Reset ASP chain, execute ENC info, and initiate Output
+// Purpose: Dec Info1 stub function
Int asopDecOutProcInfo1(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
PAF_ASOT_Config *pAsotCfg,
Int frame
)
+{
+ return ASOP_DOP_SOK;
+}
+
+// Purpose: Reset ASP chain, execute ENC info, and initiate Output
+Int asopDecOutProcDec1(
+ const PAF_ASOT_Params *pP,
+ const PAF_ASOT_Patchs *pQ,
+ PAF_ASOT_Config *pAsotCfg,
+ Int frame
+)
{
PAF_AST_Config *pAstCfg; // ASIT/ASOT/ASDT shared configuration
PAF_AST_IoOut *pOut; // ASOT IO configuration
if (errno)
{
TRACE_TERSE1("asopDecOutProcInfo1: streamChainFunction returns errno 0x%x ", errno);
- status = ASOP_DOP_ERR_INFO1_ASPCHAINRESET;
+ status = ASOP_DOP_ERR_DEC1_ASPCHAINRESET;
return status;
}
if (errno)
{
TRACE_TERSE1("asopDecOutProcInfo1: info returns errno 0x%x ", errno);
- status = ASOP_DOP_ERR_INFO1_ENCINFO;
+ status = ASOP_DOP_ERR_DEC1_ENCINFO;
return status;
}
}
if (errno)
{
TRACE_TERSE1("asopDecOutProcInfo1: info returns errno 0x%x ", errno);
- status = ASOP_DOP_ERR_INFO1_SETRATEX;
+ status = ASOP_DOP_ERR_DEC1_SETRATEX;
return status;
}
if (errno)
{
TRACE_TERSE1("asopDecOutProcInfo1: asopStartOutput returns errno 0x%x ", errno);
- status = ASOP_DOP_ERR_INFO1_STARTOUTPUT;
+ status = ASOP_DOP_ERR_DEC1_STARTOUTPUT;
return status;
}
+#if 0
// Find first Output associated with Master Stream
zO = OUTPUT1;
for (z=ENCODE1; z < ENCODEN; z++)
if (errno)
{
TRACE_TERSE1("asopDecOutProcInfo1: asopInitOutBufConfig returns errno 0x%x ", errno);
- status = ASOP_DOP_ERR_INFO1_STARTOUTPUT;
+ status = ASOP_DOP_ERR_DEC1_INITOUTBUFCFG;
return status;
}
+#endif
return status;
} //asopDecOutProcInfo1
diff --git a/pasdk/test_dsp/framework/audioStreamOutDec.h b/pasdk/test_dsp/framework/audioStreamOutDec.h
index cf4a2bc9e5b64cc2f18c3c9717cb40558baaa9c4..eda649f44bdad16219b773071cacd7b97c073f61 100644 (file)
// status codes
#define ASOP_DOP_SOK ( 0 ) // ok
#define ASOP_DOP_ERR_RESET_ENCRESET ( -1 ) // error - reset, enc reset
-#define ASOP_DOP_ERR_INFO1_ASPCHAINRESET ( -2 ) // error - info1, ASP chain reset
-#define ASOP_DOP_ERR_INFO1_ENCINFO ( -3 ) // error - info1, enc info
-#define ASOP_DOP_ERR_INFO1_SETRATEX ( -4 ) // error - info1, set rate X
-#define ASOP_DOP_ERR_INFO1_STARTOUTPUT ( -5 ) // error - info1, start output
-#define ASOP_DOP_ERR_INFO1_INITOUTBUFCFG ( -6 ) // error - info1, init out buf config
-#define ASOP_DOP_ERR_INFO2_SETRATEX ( -7 ) // error - info2, set rate X
-#define ASOP_DOP_ERR_INIT_CBINITREAD ( -8 ) // error - init, CB init read
-#define ASOP_DOP_ERR_INIT_CBREADSTART ( -9 ) // error - init, CB read start
-#define ASOP_DOP_ERR_STREAM_CBREAD ( -10 ) // error - stream, CB read
-#define ASOP_DOP_ERR_STREAM_CBREADUNDTHR ( -11 ) // error - stream, CB read underflow threshold reached
-#define ASOP_DOP_ERR_STREAM_ASPCHAINAPPLY ( -12 ) // error - stream, ASP chain apply
-#define ASOP_DOP_ERR_ENCODE_ENCSELECT ( -13 ) // error - encode, encoder (re-)select
-#define ASOP_DOP_ERR_ENCODE_ENC ( -14 ) // error - encode, encoder
-#define ASOP_DOP_ERR_ENCODE_WRTOPBUFS ( -15 ) // error - encode, write output buffers
-#define ASOP_DOP_ERR_FINALTEST_CBCHKDRAIN ( -16 ) // error - final test, CB check drained
-#define ASOP_DOP_ERR_FINALTEST_CBDRAINED ( -17 ) // error - final test, CB drained
-#define ASOP_DOP_ERR_COMPLETE_CBREADSTOP ( -18 ) // error - complete, CB read stop
-#define ASOP_DOP_ERR_COMPLETE_STOPOUTPUT ( -19 ) // error - complete, stop output
+#define ASOP_DOP_ERR_DEC1_ASPCHAINRESET ( -2 ) // error - dec1, ASP chain reset
+#define ASOP_DOP_ERR_DEC1_ENCINFO ( -3 ) // error - dec1, enc info
+#define ASOP_DOP_ERR_DEC1_SETRATEX ( -4 ) // error - dec1, set rate X
+#define ASOP_DOP_ERR_DEC1_STARTOUTPUT ( -5 ) // error - dec1, start output
+#define ASOP_DOP_ERR_INFO2_SETRATEX ( -6 ) // error - info2, set rate X
+#define ASOP_DOP_ERR_INIT_CBINITREAD ( -7 ) // error - init, CB init read
+#define ASOP_DOP_ERR_INIT_CBREADSTART ( -8 ) // error - init, CB read start
+#define ASOP_DOP_ERR_STREAM_CBREAD ( -9 ) // error - stream, CB read
+#define ASOP_DOP_ERR_STREAM_CBREADUNDTHR ( -10 ) // error - stream, CB read underflow threshold reached
+#define ASOP_DOP_ERR_STREAM_ASPCHAINAPPLY ( -11 ) // error - stream, ASP chain apply
+#define ASOP_DOP_ERR_ENCODE_ENCSELECT ( -12 ) // error - encode, encoder (re-)select
+#define ASOP_DOP_ERR_ENCODE_ENC ( -13 ) // error - encode, encoder
+#define ASOP_DOP_ERR_ENCODE_WRTOPBUFS ( -14 ) // error - encode, write output buffers
+#define ASOP_DOP_ERR_FINALTEST_CBCHKDRAIN ( -15 ) // error - final test, CB check drained
+#define ASOP_DOP_ERR_FINALTEST_CBDRAINED ( -16 ) // error - final test, CB drained
+#define ASOP_DOP_ERR_COMPLETE_CBREADSTOP ( -17 ) // error - complete, CB read stop
+#define ASOP_DOP_ERR_COMPLETE_STOPOUTPUT ( -18 ) // error - complete, stop output
// Purpose: ASOT Function for Output reset
Int frame
);
-// Purpose: Reset ASP chain, execute ENC info, and initiate Output
+// Purpose: Dec Info1 stub function
Int asopDecOutProcInfo1(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
Int frame
);
+// Purpose: Reset ASP chain, execute ENC info, and initiate Output
+Int asopDecOutProcDec1(
+ const PAF_ASOT_Params *pP,
+ const PAF_ASOT_Patchs *pQ,
+ PAF_ASOT_Config *pAsotCfg,
+ Int frame
+);
+
// Purpose: Re-initiate Output
Int asopDecOutProcInfo2(
const PAF_ASOT_Params *pP,
diff --git a/pasdk/test_dsp/framework/audioStreamOutIo.c b/pasdk/test_dsp/framework/audioStreamOutIo.c
index 8b2b37f85bf7f45c8ca8892e4fd6d3f201cf948d..ee4064e004ae27f0e7eca695a9b156b0a2b88ca6 100644 (file)
#define DEC_OUTNUMBUF_MAP(X) \
pP->poutNumBufMap[z]->map[(X) >= pP->poutNumBufMap[z]->length ? 0 : (X)]
-#define STRIDE_WORST_CASE 32 // 4-byte (32-bit) word, 2 slots, 4 serializers
+//#define STRIDE_WORST_CASE 32 // 4-byte (32-bit) word, 2 slots, 4 serializers
extern Ptr hMcaspTxChan;
extern Int d10Initialized;
* Initialize I/O components for output processing
============================================================================*/
Int asopIoCompsInit(
- PAF_AST_OutBuf *pOutBuf,
- PAF_AST_IoOut *pOutIo
+ Int16 strAfSampleCount, // stream audio frame sample count
+ PAF_AST_OutBuf *pOutBuf, // pointer to Output Buffer
+ PAF_AST_IoOut *pOutIo // pointer to Output IO
)
{
ioBuffParams_t ioBuffParams;
{
// Initialize I/O BUFF and I/O PHY components for output task
ioBuffParams.base = pOutBuf->outBufConfig.base.pVoid;
- ioBuffParams.size = pOutBuf->outBufConfig.allocation/STRIDE_WORST_CASE*STRIDE_WORST_CASE;
+ // Set IO buffer size to multiple of audio frame sample count x stride x size of element.
+ // This ensures no split buffers will be allocated on Output buffer wrap.
+ ioBuffParams.size = pOutBuf->outBufConfig.allocation/(strAfSampleCount * pOutIo->stride * WORD_SIZE_PCM)*
+ (strAfSampleCount * pOutIo->stride * WORD_SIZE_PCM);
ioBuffParams.sync = IOBUff_READ_SYNC;
- ioBuffParams.nominalDelay = NUM_CYCLE_PER_OUTPUT_FRAME_DEF * pOutIo->stride * WORD_SIZE_PCM * (NUM_PRIME_XFERS+1);
- if(ioBuffInit(pOutIo->hIoBuff, &ioBuffParams) != IOBUFF_NOERR)
+ ioBuffParams.nominalDelay = strAfSampleCount * pOutIo->stride * WORD_SIZE_PCM * (NUM_PRIME_XFERS+1);
+ if (ioBuffInit(pOutIo->hIoBuff, &ioBuffParams) != IOBUFF_NOERR)
{
return ASOP_IO_ERR_IOBUFF_INIT; // to remove magic number
}
ioPhyParams.ioBuffHandle = pOutIo->hIoBuff;
- ioPhyParams.xferFrameSize = NUM_CYCLE_PER_FRAME_DEF * pOutIo->stride * WORD_SIZE_PCM;
+ ioPhyParams.xferFrameSize = strAfSampleCount * pOutIo->stride * WORD_SIZE_PCM;
ioPhyParams.mcaspChanHandle = pOutIo->hMcaspChan;
ioPhyParams.ioBuffOp = IOPHY_IOBUFFOP_READ;
- if(ioPhyInit(pOutIo->hIoPhy, &ioPhyParams) != IOPHY_NOERR)
+ if (ioPhyInit(pOutIo->hIoPhy, &ioPhyParams) != IOPHY_NOERR)
{
return ASOP_IO_ERR_IOPHY_INIT; // to remove magic number
}
pOutIo->phyXferSize = ioPhyParams.xferFrameSize;
pOutIo->ioBuffBuf2AllocCnt = 0; // initialize buffer2 alloc count (indicates Output buffer wrap)
- pOutIo->errIoBuffOvrCnt = 0; // initialize IO buff overflow count
- pOutIo->errIoBuffUndCnt = 0; // initialize IO buff underflow count
+ pOutIo->errIoBuffOvrCnt = 0; // initialize IO buff overflow count
+ pOutIo->errIoBuffUndCnt = 0; // initialize IO buff underflow count
}
return ASOP_IO_SOK;
// already underflows and remain in underflow
}
+
+ if ((buff2 != NULL) || (size2 != 0))
+ {
+ // Two buffers allocated indicates split buffer allocation on buffer wrap.
+ pOutIo->ioBuffBuf2AllocCnt++; // increment count of allocated buffer2
+ }
// save buffer pointers & sizes for later write complete
pOutIo->buff1 = buff1;
diff --git a/pasdk/test_dsp/framework/audioStreamOutIo.h b/pasdk/test_dsp/framework/audioStreamOutIo.h
index df1afe1325cdba9a3168c96b64bc402baa1b53b6..cfd00dfe72874a508a7f476b617c2c0adf399edc 100644 (file)
// Initialize I/O components for output processing
Int asopIoCompsInit(
- PAF_AST_OutBuf *pOutBuf,
- PAF_AST_IoOut *pOutIo
+ Int16 strAfSampleCount, // stream audio frame sample count
+ PAF_AST_OutBuf *pOutBuf, // pointer to Output Buffer
+ PAF_AST_IoOut *pOutIo // pointer to Output IO
);
// Check I/O physical layer initialized
diff --git a/pasdk/test_dsp/framework/audioStreamOutProc.c b/pasdk/test_dsp/framework/audioStreamOutProc.c
index d9503c0af43e5c959e1ed31a2bcae4db04db61ff..d25f1e476b42a766ae0aef7f2f2160f15b1c626f 100644 (file)
Int frame
);
+// Encode function which handles encoding to two output buffers
static Int asopDecOutProcEncodeWrap(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
// FL: debug, allow modification of Output frame length via JTAG.
-Int16 gOutFrameLen=PAF_ASOT_FRAMELENGTH; // output frame length (PCM samples)
+//Int16 gOutFrameLen=PAF_ASOT_FRAMELENGTH; // output frame length (PCM samples)
// ASOT configuration
#pragma DATA_SECTION(gPAF_ASOT_config, ".globalSectionPafAsotConfig")
// check for valid index into device array
if (device >= pQ->devout->n) // DEVOUT_N
{
- device = 0; // treat as device None
+ device = 0; // treat as device OutNone
}
// Select Output Devices
*pOutDevSel = FALSE;
return status;
}
-
+
+#if 0
// Reset IO Buff & IO Phy
// FL, New IO: API for single Output
status = asopIoCompsInit(&pAstCfg->xOut[zO], &pAsotCfg->pIoOut[zO]);
*pOutDevSel = FALSE;
return status;
}
+#endif
+ // indicate SIO update request processed
pAstCfg->xOut[zO].outBufStatus.sioSelect = device | 0x80;
}
}
else
{
-// FL: moved to PAF_ASOT_initSyncDecDecode1()
+// FL: moved to PAF_ASOT_initSyncDecDecode1(), content of asopDecOutProcInfo1() moved to asopDecOutProcDec1().
// Decode parameters necessary for CB stream FL auto config are known at that time.
// CB stream FL used to configure Stream AF sample count.
// ASP chain reset can adjust Stream AF sample count, depending on whether SRC enabled & decimation factor.
// Wake Timer + *POLLING* version.
// No explicit Rx ASDT message event from ASDT.
// ASOT wakes on Wake Timer event and polls for flag set.
-//static Int PAF_ASOT_initSyncDecDecode1(
static Int PAF_ASOT_initSyncDecDecode1(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
}
else
{
+// FL: moved from PAF_ASOT_initSyncDecInfo1()
#if 1
// Get pointer to circular buffer control
pCbCtl = &pAsotCfg->pAspmCfg->decOpCircBufCtl;
// - ASP chain reset,
// - Enc Info,
// - Start Output
- status = asopDecOutProcInfo1(pP, pQ, pAsotCfg, frame);
+ status = asopDecOutProcDec1(pP, pQ, pAsotCfg, frame);
if (status < 0)
{
return status;
}
}
+ // FL, New IO: API for single Output
+ // Reset IO Buff & IO Phy
+ status = asopIoCompsInit(pStrAf->sampleCount, &pAstCfg->xOut[zO], &pAsotCfg->pIoOut[zO]);
+ if (status < 0)
+ {
+ return status;
+ }
+
+ // Initialize Output buffer configuration
+ status = asopInitOutBufConfig(&pAstCfg->xOut[zO], &pAsotCfg->pIoOut[zO]);
+ if (status)
+ {
+ TRACE_TERSE1("PAF_ASOT_initSyncDecDecode1: asopInitOutBufConfig returns errno 0x%x ", status);
+ return status;
+ }
+
// FL, New IO: assumption here is Tx McASP clock dividers &
// Output frame size are set correctly before IO prime,
// i.e. IO prime is not using defaults
-
// FL, New IO: API for single Output
-
// I/O physical layer prime operation required by McASP LLD
asopIoPhyPrime(&pAsotCfg->pIoOut[zO]);
TRACE_VERBOSE0("PAF_ASOT_initSyncDecDecode1: ASOP McASP LLD primed.");
status = ASOP_SOK;
pAstCfg = pAsotCfg->pAstCfg;
-
+
if (*pFirstTime == TRUE)
{
// Initialize Decoder output processing
return status;
}
+// Encode function which handles encoding to two output buffers
static Int asopDecOutProcEncodeWrap(
const PAF_ASOT_Params *pP,
const PAF_ASOT_Patchs *pQ,
pOutBufCfg = &(pAstCfg->xOut[zO].outBufConfig);
pAf = pAstCfg->xEnc[zO].encodeInStruct.pAudioFrame;
- if(pAsotCfg->pIoOut[zO].buff2 == NULL)
+ if (pAsotCfg->pIoOut[zO].buff2 == NULL)
{
// Output buffer won't wrap around - to invoke the encoder once
pOutBufCfg->lengthofFrame = pAf->sampleCount;
}
else
{
+ //
+ // Not expected to occur since output buffer is allocated
+ // to be a multiple of Stream AF sample count x stride x size of element.
+ // See asopIoCompsInit().
+ //
+ SW_BREAKPOINT;
+
+#if 0
// Output buffer will wrap around - to invoke the encoder twice
XDAS_Int16 sampleCountSave;
- PAF_AudioData *afDataAddrSave[16];
+ PAF_AudioData *afDataAddrSave[PAF_MAXNUMCHAN_AF];
PAF_AudioData **afDataAddr;
int i, ch;
for(i=0; i<pOutBufCfg->stride; i++)
{
ch = pAstCfg->xEnc[zO].encodeStatus.channelMap.from[i];
- afDataAddrSave[i] = afDataAddr[ch]; // save audio frame buffer addresses
- afDataAddr[ch] = &afDataAddr[ch][pOutBufCfg->lengthofFrame];
+ if (ch >= 0)
+ {
+ afDataAddrSave[i] = afDataAddr[ch]; // save audio frame buffer addresses
+ afDataAddr[ch] = &afDataAddr[ch][pOutBufCfg->lengthofFrame];
+ }
}
// Invoke the encoder to write data to the beginning of output buffer (wrapping around)
for(i=0; i<pOutBufCfg->stride; i++)
{
ch = pAstCfg->xEnc[zO].encodeStatus.channelMap.from[i];
- afDataAddr[ch] = afDataAddrSave[i];
+ if (ch >= 0)
+ {
+ afDataAddr[ch] = afDataAddrSave[i];
+ }
}
pAsotCfg->pIoOut[zO].ioBuffBuf2AllocCnt++; // debug
+#endif
}
return status;
diff --git a/pasdk/test_dsp/framework/audioStreamOutProc.h b/pasdk/test_dsp/framework/audioStreamOutProc.h
index 5aff6c71094aa204cb25f3adf29eb8b8af580f53..f30c85dfb680f4df14b63e6c30d374e0eee07043 100644 (file)
} PAF_ASOT_Patchs;
typedef struct PAF_AST_OutIO {
- ioPhyHandle_t hIoPhy; /* handle to I/O physical layer */
- ioBuffHandle_t hIoBuff; /* handle to I/O buffer management */
- Ptr hMcaspChan; /* handle to McASP LLD channel for output */
- mcaspLLDconfig *pLldCfg; /* pointer to McASP LLD configuration */
+ ioPhyHandle_t hIoPhy; // handle to I/O physical layer
+ ioBuffHandle_t hIoBuff; // handle to I/O buffer management
+ Ptr hMcaspChan; // handle to McASP LLD channel for output
+ mcaspLLDconfig *pLldCfg; // pointer to McASP LLD configuration
+
uint32_t phyXferSize;
uint32_t stride;
uint32_t mcaspXferErr;
- void *buff1; // pointer to 1st buffer in output memory pool
- void *buff2; // pointer to 2nd buffer in output memory pool in case of buffer wrap
- size_t size1; // size of 1st buffer in output memory pool
- size_t size2; // size of 2nd buffer in output memory pool
+ void *buff1; // pointer to 1st buffer in output memory pool
+ void *buff2; // pointer to 2nd buffer in output memory pool in case of buffer wrap
+ size_t size1; // size of 1st buffer in output memory pool
+ size_t size2; // size of 2nd buffer in output memory pool
- uint32_t ioBuffBuf2AllocCnt;
- uint32_t errIoBuffOvrCnt;
- uint32_t errIoBuffUndCnt;
+ uint32_t ioBuffBuf2AllocCnt; // Output buffer2 allocation (split buffer on buffer wrap) count
+ uint32_t errIoBuffOvrCnt; // Output IO overflow count
+ uint32_t errIoBuffUndCnt; // Output IO underflow count
// debugging counters
uint32_t num_xfers;
index 84ad3792fabce370422f92845a2cebf79f532a17..1242232e1496edb9eedf40c97a82914ec8201bbd 100644 (file)
PAF_ASOT_params_fxns.memStatusPrint = PAF_ALG_memStatusPrint;
#endif
-#if 1 // debug
+#if 1 // debug, GPIO ports
// Any of these can be used on ARM, but DSP must configure the GPIO since pinMuxSetMode() is only available on DSP
aud_pinMuxSetMode(101,AUD_PADCONFIG_MUX_MODE_QUATERNARY); // PAD101 to QUATERNARY, GPIO (B5 on AudioDaughterCard J12)
GPIOSetDirection(GPIO_PORT_0, GPIO_PIN_99, GPIO_OUT); // GPIO0,pin99 output