index 7e9d322574544d524dc872350b422f815fba6523..196692e3d014cf13a343740a51999e5ffbce49b9 100644 (file)
/*\r
- * Copyright (c) 2015, Texas Instruments Incorporated\r
+ * Copyright (c) 2017, Texas Instruments Incorporated\r
* All rights reserved.\r
*\r
* Redistribution and use in source and binary forms, with or without\r
*\r
*/\r
\r
+#include "fil.h" /* FILE I/O implementation */\r
+#include "sys.h" /* System API and structures */\r
+#include "sysbfflt.h" /* System support for BF filters */\r
+\r
#include "mcasp_cfg.h"\r
-#include "../include/cmbk2g.h"\r
+#include "cmb.h"\r
\r
\r
/* The infamous xdc/std.h must come before any header file which uses XDC symbols */\r
#include <ti/mas/aer/bf.h>\r
#include "../../../common/components/mss/mss.h" /* local version used */\r
#include <ti/mas/vpe/asnr.h>\r
+#if (SYS_USE_DRC)\r
+#include <ti/mas/vau/vau.h>\r
+#include <ti/mas/aer/drc.h>\r
+#endif\r
\r
/*----------------------------------------\r
* BIOS header files\r
\r
#include <ti/sysbios/knl/Semaphore.h> /* this looks obvious */\r
\r
-#include "fil.h" /* FILE I/O implementation */\r
-#include "sys.h" /* System API and structures */\r
-#include "sysbfflt.h" /* System support for BF filters */\r
-\r
#define Timestamp_get Timestamp_get32 /* use 32-bit time stamps */\r
\r
#define MIN(a,b) (((a)>(b))?(b):(a)) /* Min/Max macros */\r
Ptr wkBuf[NUM_BUFS];\r
Ptr outBuf[NUM_BUFS];\r
\r
-int chanToMicMapping[8] = {0, 1, 4, 5, 2, 3, 6, 7};\r
+/* channel 0 (serilizer 1 left) - mic1 */\r
+/* channel 1 (serilizer 1 right) - mic2 */\r
+/* channel 2 (serilizer 2 left) - mic5 */\r
+/* channel 3 (serilizer 2 right) - mic6 */\r
+/* channel 4 (serilizer 3 left) - mic3 */\r
+/* channel 5 (serilizer 3 right) - mic4 */\r
+/* channel 6 (serilizer 4 left) - mic8 */\r
+/* channel 7 (serilizer 4 right) - mic7 */\r
+int chanToMicMapping[8] = {0, 1, 4, 5, 3, 2, 7, 6};\r
\r
/* Error flag */\r
uint32_t gblErrFlag = 0;\r
};\r
\r
/* McASP HW setup for transmit */\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
Mcasp_HwSetupData mcaspXmtSetup = {\r
/* .xmask = */ 0xFFFFFFFF, /* 16 bits are to be used */\r
/* .xfmt = */ 0x000180F0, /*\r
TRUE\r
};\r
\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
/* McAsp channel parameters for transmit */\r
Mcasp_ChanParams mcaspTxChanParam =\r
{\r
};\r
#endif\r
\r
+#if (SYS_USE_DRC)\r
+/* Output frame for MSS, input for DRC */\r
+#pragma DATA_ALIGN(txOutFrame1,8)\r
+linSample txOutFrame1[SYS_FRAME_LENGTH];\r
+\r
+/* Output frame for DRC, input for VAU */\r
+#pragma DATA_ALIGN(txOutFrame2,8)\r
+linSample txOutFrame2[SYS_FRAME_LENGTH];\r
+#endif\r
+\r
typedef struct txBfDebug_stc {\r
tulong frmcnt; /* normal frames */\r
tulong silcnt; /* silence frames */\r
txTaskProfileData_t bf; /* Beamformer profile */\r
txTaskProfileData_t asnr; /* ASNR profile */\r
txTaskProfileData_t mss; /* MSS profile */\r
+ txTaskProfileData_t drc; /* DRC profile */\r
txTaskProfileData_t vau; /* VAU profile */\r
} txTaskProfile_t;\r
volatile txTaskProfile_t txTaskProfile = {\r
{~(0uL), 0, 0, 0.0f},\r
{~(0uL), 0, 0, 0.0f},\r
{~(0uL), 0, 0, 0.0f},\r
+ {~(0uL), 0, 0, 0.0f},\r
{~(0uL), 0, 0, 0.0f}\r
};\r
\r
/**\r
* \brief Initializes McASP data buffers and submits to McASP driver\r
*\r
- * \return Cmbk2g_EOK on Success or error code\r
+ * \return Cmb_EOK on Success or error code\r
*/\r
-Cmbk2g_STATUS initBuffers(void)\r
+Cmb_STATUS initBuffers(void)\r
{\r
Error_Block eb;\r
uint32_t count = 0;\r
BUFALIGN, &eb);\r
if(NULL == rxBuf[count])\r
{\r
- IFPRINT(cmbk2g_write("\r\nMEM_calloc failed for Rx\n"));\r
+ IFPRINT(cmb_write("\r\nMEM_calloc failed for Rx\n"));\r
}\r
}\r
\r
BUFALIGN, &eb);\r
if(NULL == wkBuf[count])\r
{\r
- IFPRINT(cmbk2g_write("\r\nMEM_calloc failed for Wk\n"));\r
+ IFPRINT(cmb_write("\r\nMEM_calloc failed for Wk\n"));\r
}\r
}\r
\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
/* Allocate buffers for the McASP data exchanges */\r
for(count = 0; count < NUM_BUFS; count++)\r
{\r
BUFALIGN, &eb);\r
if(NULL == txBuf[count])\r
{\r
- IFPRINT(cmbk2g_write("\r\nMEM_calloc failed for Tx\n"));\r
+ IFPRINT(cmb_write("\r\nMEM_calloc failed for Tx\n"));\r
}\r
}\r
\r
BUFALIGN, &eb);\r
if(NULL == outBuf[count])\r
{\r
- IFPRINT(cmbk2g_write("\r\nMEM_calloc failed for Out\n"));\r
+ IFPRINT(cmb_write("\r\nMEM_calloc failed for Out\n"));\r
}\r
}\r
#endif\r
status = mcaspSubmitChan(hMcaspRxChan, &rxFrame[count]);\r
if((status != MCASP_COMPLETED) && (status != MCASP_PENDING))\r
{\r
- IFPRINT(cmbk2g_write("mcaspSubmitChan for Rx Failed\n"));\r
- return (Cmbk2g_EFAIL);\r
+ IFPRINT(cmb_write("mcaspSubmitChan for Rx Failed\n"));\r
+ return (Cmb_EFAIL);\r
}\r
}\r
\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
for(count = 0; count < NUM_BUFS; count++)\r
{\r
memset((uint8_t *)txBuf[count], 0xCC, (BUFSIZE * TX_NUM_SERIALIZER));\r
status = mcaspSubmitChan(hMcaspTxChan, &txFrame[count]);\r
if((status != MCASP_COMPLETED) && (status != MCASP_PENDING))\r
{\r
- IFPRINT(cmbk2g_write("mcaspSubmitChan for Tx Failed\n"));\r
- return (Cmbk2g_EFAIL);\r
+ IFPRINT(cmb_write("mcaspSubmitChan for Tx Failed\n"));\r
+ return (Cmb_EFAIL);\r
}\r
}\r
#endif\r
- return (Cmbk2g_EOK);\r
+ return (Cmb_EOK);\r
}\r
\r
/**\r
* \brief Configures McASP module and creates the channel\r
* for audio Tx and Rx\r
*\r
- * \return Cmbk2g_EOK on Success or error code\r
+ * \return Cmb_EOK on Success or error code\r
*/\r
-Cmbk2g_STATUS mcaspAudioConfig(void)\r
+Cmb_STATUS mcaspAudioConfig(void)\r
{\r
Int status;\r
\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
hMcaspDevTx = NULL;\r
hMcaspTxChan = NULL;\r
#endif\r
hMcaspRxChan = NULL;\r
\r
/* Initialize McASP Tx and Rx parameters */\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
mcaspTxParams = Mcasp_PARAMS;\r
#endif\r
mcaspRxParams = Mcasp_PARAMS;\r
\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
mcaspTxParams.mcaspHwSetup.tx.clk.clkSetupClk = 0x63;\r
mcaspTxParams.mcaspHwSetup.rx.clk.clkSetupClk = 0x23;\r
#endif\r
mcaspRxParams.mcaspHwSetup.rx.clk.clkSetupClk = 0x23;\r
mcaspRxParams.mcaspHwSetup.tx.clk.clkSetupClk = 0x63;\r
\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
mcaspTxParams.mcaspHwSetup.glb.pdir |= 0x2000000; //Set Amute pin as output for Tx channel\r
#endif\r
\r
/* Set the HW interrupt number */\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
mcaspTxParams.hwiNumber = 8;\r
#endif\r
mcaspRxParams.hwiNumber = 8;\r
\r
/* Initialize eDMA handle */\r
mcaspRxChanParam.edmaHandle = hEdma1;\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
mcaspTxChanParam.edmaHandle = hEdma1;\r
\r
/* Bind McASP2 for Tx */\r
status = mcaspBindDev(&hMcaspDevTx, CSL_MCASP_2, &mcaspTxParams);\r
if((status != MCASP_COMPLETED) || (hMcaspDevTx == NULL))\r
{\r
- IFPRINT(cmbk2g_write("mcaspBindDev for Tx Failed\n"));\r
- return (Cmbk2g_EFAIL);\r
+ IFPRINT(cmb_write("mcaspBindDev for Tx Failed\n"));\r
+ return (Cmb_EFAIL);\r
}\r
#endif\r
/* Bind McASP1 for Rx */\r
status = mcaspBindDev(&hMcaspDevRx, CSL_MCASP_1, &mcaspRxParams);\r
if((status != MCASP_COMPLETED) || (hMcaspDevRx == NULL))\r
{\r
- IFPRINT(cmbk2g_write("mcaspBindDev for Rx Failed\n"));\r
- return (Cmbk2g_EFAIL);\r
+ IFPRINT(cmb_write("mcaspBindDev for Rx Failed\n"));\r
+ return (Cmb_EFAIL);\r
}\r
\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
/* Create McASP channel for Tx */\r
status = mcaspCreateChan(&hMcaspTxChan, hMcaspDevTx,\r
MCASP_OUTPUT,\r
mcaspAppCallback, &txChanMode);\r
if((status != MCASP_COMPLETED) || (hMcaspTxChan == NULL))\r
{\r
- IFPRINT(cmbk2g_write("mcaspCreateChan for Tx Failed\n"));\r
- return (Cmbk2g_EFAIL);\r
+ IFPRINT(cmb_write("mcaspCreateChan for Tx Failed\n"));\r
+ return (Cmb_EFAIL);\r
}\r
\r
configAudioDAC();\r
mcaspAppCallback, &rxChanMode);\r
if((status != MCASP_COMPLETED) || (hMcaspRxChan == NULL))\r
{\r
- IFPRINT(cmbk2g_write("mcaspCreateChan for Rx Failed\n"));\r
- return (Cmbk2g_EFAIL);\r
+ IFPRINT(cmb_write("mcaspCreateChan for Rx Failed\n"));\r
+ return (Cmb_EFAIL);\r
}\r
\r
/* Initialize the buffers and submit for McASP Tx/Rx */\r
- if(initBuffers() != Cmbk2g_EOK)\r
+ if(initBuffers() != Cmb_EOK)\r
{\r
- IFPRINT(cmbk2g_write("McASP Buffer Initialization Failed\n"));\r
- return (Cmbk2g_EFAIL);\r
+ IFPRINT(cmb_write("McASP Buffer Initialization Failed\n"));\r
+ return (Cmb_EFAIL);\r
}\r
\r
- return (Cmbk2g_EOK);\r
+ return (Cmb_EOK);\r
}\r
\r
/**\r
*/\r
void testRet(uint32_t status)\r
{\r
- cmbk2g_write("\n\nAudio DC Analog Interface Test Completed!\n");\r
+ cmb_write("\n\nAudio DC Analog Interface Test Completed!\n");\r
\r
testExit(status);\r
}\r
* Waits for the McASP data transfer completion and copies the\r
* Rx data to Tx buffers\r
*\r
- * \return Cmbk2g_EOK on Success or error code\r
+ * \return Cmb_EOK on Success or error code\r
*/\r
#define DUMP_SEC 5\r
#define FRAME_PER_SEC 100\r
void *inst_p;\r
linSample *in_r; /* pointer to current microphone input buffer */\r
linSample *frame_p; /* pointer to signal frame */\r
+ linSample *outframe_p; /* Output frame pointer for VAU */\r
linSample *mics_in[SYS_MICS_MAX+1]; /* pointers to microphone inputs */\r
\r
mssDebugStat_t mssDbg;\r
\r
/* Reclaim full buffer from the input stream */\r
Semaphore_pend(semR, BIOS_WAIT_FOREVER);\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
Semaphore_pend(semT, BIOS_WAIT_FOREVER);\r
#endif\r
/* Reclaim full buffer from the input stream */\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
gtxFrameIndexCount = txFrameIndex;\r
#endif\r
grxFrameIndexCount = rxFrameIndex;\r
\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
\r
#if 0 // Mcasp_BufferFormat_MULTISER_MULTISLOT_SEMI_INTERLEAVED_1\r
// copy RX mic 1 to TX left channel and RX mic 5 to right channel\r
/* Here comes a lot of work */\r
/* We start with beamformers */\r
\r
+ /* Start the beamformers */\r
// get the number of virtual mics\r
nvmics = sysContext.nvmics;\r
t1 = Timestamp_get();\r
* any protection to prevent the swiDataIn from stepping over while we were doing this.\r
* We could let this task to handle the read pointer and SWI to handle write pointer which\r
* could be used to detect if such overrun would happen. */\r
-\r
/* Done with the beamformers */\r
- /* Start ASNR's */\r
\r
+ /* Start ASNR's */\r
t1 = Timestamp_get();\r
for (k = 0; k < nvmics; k++) {\r
inst_p = sysContext.asnrInst_p[k]; /* fetch the bf instance pointer */\r
txTaskProfile.asnr.max = MAX(txTaskProfile.asnr.max,delta);\r
txTaskProfile.asnr.n++;\r
txTaskProfile.asnr.total += (float)delta;\r
-\r
/* Done with the ASNR's */\r
- /* Run MSS */\r
\r
+ /* Run MSS */\r
t1 = Timestamp_get();\r
inst_p = sysContext.mssInst_p; /* fetch the MSS instance pointer */\r
+#if (SYS_USE_DRC)\r
+ frame_p = txOutFrame1; /* point to the output frame buffer */\r
+#else\r
frame_p = outBuf[gtxFrameIndexCount]; /* point to the output frame buffer */\r
+#endif\r
\r
err = mssProcess(inst_p, /* instance */\r
(void*)frame_p, /* output frame pointers */\r
angle = sysBfFilterAngles[sysBfVMicAngles[mssDbgNewSrc.index]];\r
///Log_write6(UIAEvt_intWithKey, angle, 1, mssDbgNewSrc.index, (IArg)"MSS-N: %d, G:%d", 1, mssDbgNewSrc.group);\r
}\r
-\r
/* Done with MSS */\r
\r
+#if (SYS_USE_DRC)\r
+ /* Run DRC */\r
+ t1 = Timestamp_get();\r
+ inst_p = sysContext.drcInst_p; /* fetch the DRC instance pointer */\r
+ frame_p = txOutFrame1; /* point to the MSS output frame buffer and use it as input */\r
+ outframe_p = txOutFrame2; /* point to DRC output frame */\r
+ err = drcProcess(inst_p, frame_p, /* instance and input frame pointers */\r
+ outframe_p); /* pointer to output buffer pointer */\r
+ t2 = Timestamp_get();\r
+ delta = t2-t1;\r
+ txTaskProfile.drc.min = MIN(txTaskProfile.drc.min,delta);\r
+ txTaskProfile.drc.max = MAX(txTaskProfile.drc.max,delta);\r
+ txTaskProfile.drc.n++;\r
+ txTaskProfile.drc.total += (float)delta;\r
+ /* Done with DRC */\r
+#endif\r
+\r
/*---------------------------------*/\r
/* Save samples to the TX buffer */\r
/*---------------------------------*/\r
// copy MSS output to TX left channel and RX mic 5 to TX right channel\r
// set the tempOutPtr to MSS output\r
+#if (SYS_USE_DRC)\r
+ tempOutPtr = txOutFrame2;\r
+#else\r
tempOutPtr = outBuf[gtxFrameIndexCount];\r
- // set the tempMicPtr to mic_in[4]\r
- tempMicPtr = (unsigned char *)mics_in[4];\r
+#endif\r
+ // set the tempMicPtr to mic_in[7] (mic8)\r
+ tempMicPtr = (unsigned char *)mics_in[7];\r
// set the TX pointer to left cahhnel\r
tempTxPtr = txBuf[gtxFrameIndexCount];\r
// copy upsampled and Q15 to Q31 converted MSS output to TX left channel\r
}\r
#endif // Signal Processing Path\r
#endif // Mcasp_BufferFormat\r
-#endif // CMBK2G_AUDIO_DAC\r
+#endif // CMB_AUDIO_DAC\r
\r
// Audio debug dump\r
if (gAudDumpBufIdx<FRAME_PER_SEC*DUMP_SEC)\r
gAudDumpBufIdx++;\r
}\r
\r
-#if (CMBK2G_AUDIO_DAC)\r
+#if (CMB_AUDIO_DAC)\r
/* Issue full buffer to the output stream */\r
/* TX frame processing */\r
txFrame[gtxFrameIndexCount].cmd = MCASP_WRITE;\r