9cf06b713f76590e5eed012c6beb169132fdda84
2 /*
3 Copyright (c) 2017, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 /*
37 * ======== audioStreamOutProc.h ========
38 */
40 #ifndef _ASOP_H_
41 #define _ASOP_H_
43 #include <xdc/std.h>
44 #include <ti/sysbios/knl/Event.h>
45 #include <ti/sysbios/knl/Task.h>
47 #include "mcasp_cfg.h"
48 #include "ioPhy.h"
49 #include "ioBuff.h"
51 #include "audioStreamProc_params.h"
52 #include "audioStreamProc_patchs.h"
53 #include "audioStreamProc_config.h"
54 #include "audioStreamProc_master.h"
56 #define TRACE_TIME(a)
58 /* !!!!!!!!! Revisit !!!!!!!!!!!!!!
59 * Purpose : Temporary ASOT frame length sizes.
60 * Deprecate PAF_SYS_FRAMELENGTH in phases.*/
61 #define PAF_ASOT_FRAMELENGTH 256
62 #define PAF_ASOT_MAX_FRAMELENGTH 1024
64 // ASOT event IDs
65 #define Evt_Id_AsotWakeTimer Event_Id_00 // ASOT Wake Timer event
66 #define Evt_Id_AsotRxMsgAsit Event_Id_01 // ASOT Rx ASIT message event
67 #define Evt_Id_AsotRxMsgAsdt Event_Id_02 // ASOT Rx ASDT message event
68 #define Evt_Id_AsotTxMcaspEdma Event_Id_03 // ASOT Tx McASP EDMA event
70 // ASOT event handle - to put in structure
71 extern Event_Handle gAsotEvtHandle;
73 struct PAF_ASOT_Params;
74 struct PAF_ASOT_Patchs;
75 struct PAF_ASOT_Config;
77 // Audio Stream Output Task (ASOT) parameters, functions
78 typedef struct PAF_ASOT_Fxns {
79 Int (*initPhase[8]) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
80 Int (*initFrame0) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
81 Int (*initFrame1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int);
82 Int (*decodeProcessing) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
83 Int (*encodeCommand) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
84 Int (*decodeInit) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
85 Int (*decodeInfo1) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
86 Int (*decodeInfo2) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
87 Int (*decodeStream) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
88 Int (*decodeEncode) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
89 Int (*decodeFinalTest) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
90 Int (*decodeComplete) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
91 Int (*selectDevices) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Bool *);
92 Int (*startOutput) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
93 Int (*stopOutput) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *);
94 Int (*setCheckRateX) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int);
95 Int (*streamChainFunction) (const struct PAF_ASOT_Params *, const struct PAF_ASOT_Patchs *, struct PAF_ASOT_Config *, Int, Int, Int);
96 Int (*deviceAllocate) (SIO_Handle *, int, int, int, Ptr);
97 Int (*deviceSelect) (SIO_Handle *, int, int, Ptr);
99 // For RAM_report
100 Void (*headerPrint)();
101 Int (*allocPrint)(const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p);
102 Void (*commonPrint)(IALG_MemRec common[], PAF_IALG_Config *p);
103 Void (*bufMemPrint)(Int z, Int size, Int heapId, Int bufType);
104 Void (*memStatusPrint)(
105 CString header,
106 HeapMem_Handle hInternalHeap,
107 HeapMem_Handle hInternal1Heap,
108 HeapMem_Handle hExternalHeap,
109 HeapMem_Handle hInternal1HeapShm,
110 HeapMem_Handle hExternalHeapShm,
111 HeapMem_Handle hExternalNoncachedHeapShm);
112 } PAF_ASOT_Fxns;
114 // Audio Stream Output Task (ASOT) parameters
115 typedef struct PAF_ASOT_Params {
116 const PAF_ASOT_Fxns *fxns;
117 struct {
118 SmInt master;
119 SmInt inputs;
120 SmInt input1;
121 SmInt inputN;
122 SmInt decodes;
123 SmInt decode1;
124 SmInt decodeN;
125 SmInt streams;
126 SmInt stream1; /* unused */
127 SmInt streamN; /* unused */
128 SmInt encodes;
129 SmInt encode1;
130 SmInt encodeN;
131 SmInt outputs;
132 SmInt output1;
133 SmInt outputN;
134 } zone;
135 const SmInt *inputsFromDecodes;
136 const SmInt *outputsFromEncodes;
137 struct {
138 int *pHeapIdIntern; // INT memory heap ID
139 int *pHeapIdExtern; // EXT memory heap ID
140 int *pHeapIdInpbuf; // IB buffer heap ID
141 int *pHeapIdOutbuf; // OB buffer heap ID
142 int *pHeapIdFrmbuf; // Frame buffer heap ID
143 int *pHeapIdIntern1; // INT1 memory heap ID
144 int *pHeapIdInt1Shm; // INT1 SHared Memory heap ID
145 int *pHeapIdExtShm; // EXT SHared Memory heap ID
146 int *pHeapIdExtNonCachedShm; // EXT Non-Cached SHared Memory heap ID
147 int clear;
148 } heap;
149 struct {
150 const IALG_MemSpace *space;
151 } common;
152 const LgInt *z_rx_bufsiz;
153 const LgInt *z_tx_bufsiz;
154 const SmInt *z_numchan;
155 MdInt framelength;
156 const PAF_AudioFunctions *pAudioFrameFunctions;
157 const struct PAF_ASP_ChainFxns *pChainFxns;
158 const PAF_InpBufStatus *pInpBufStatus;
159 const PAF_DecodeStatus * const *z_pDecodeStatus;
160 const PAF_OutBufStatus *pOutBufStatus;
161 const PAF_EncodeStatus * const *z_pEncodeStatus;
162 const PAF_VolumeStatus *pVolumeStatus;
163 const PAF_ASP_AlgKey *pDecAlgKey;
164 const PAF_ASP_AlgKey *pEncAlgKey;
165 const PAF_ASP_SioMap *pDecSioMap;
166 const SmInt *streamsFromDecodes;
167 const SmInt *streamsFromEncodes;
168 const MdInt maxFramelength;
169 const SmInt *streamOrder;
170 const PAF_ASP_LinkInit * const (*i_inpLinkInit);
171 const PAF_ASP_LinkInit * const (*i_outLinkInit);
172 const PAF_ASP_outNumBufMap * const (*poutNumBufMap);
173 const PAF_MetadataBufStatus *pMetadataBufStatus;
174 const PAF_AudioFrameBufStatus *pAudioFrameBufStatus;
175 } PAF_ASOT_Params;
177 // Audio Stream Output Task (ASOT) patchs
178 typedef struct PAF_ASOT_Patchs {
179 const PAF_SIO_ParamsN * devout;
180 const PAF_ASP_LinkInit * const (*i_aspLinkInit)[GEARS];
181 const PAF_ASP_LinkInit * const (*i_encLinkInit);
182 } PAF_ASOT_Patchs;
184 typedef struct PAF_AST_OutIO {
185 ioPhyHandle_t hIoPhy; // handle to I/O physical layer
186 ioBuffHandle_t hIoBuff; // handle to I/O buffer management
187 Ptr hMcaspChan; // handle to McASP LLD channel for output
188 mcaspLLDconfig *pLldCfg; // pointer to McASP LLD configuration
190 uint32_t phyXferSize;
191 uint32_t stride;
193 void *mcaspTxBuf1;
194 void *mcaspTxBuf2;
195 uint32_t mcaspTxSize1;
196 uint32_t mcaspTxSize2;
197 int mcaspTxtwoXfers;
199 int numPrimeXfers;
201 uint32_t mcaspXferErr;
203 void *buff1; // pointer to 1st buffer in output memory pool
204 void *buff2; // pointer to 2nd buffer in output memory pool in case of buffer wrap
205 size_t size1; // size of 1st buffer in output memory pool
206 size_t size2; // size of 2nd buffer in output memory pool
208 uint32_t ioBuffBuf2AllocCnt; // Output buffer2 allocation (split buffer on buffer wrap) count
209 uint32_t errIoBuffOvrCnt; // Output IO overflow count
210 uint32_t errIoBuffUndCnt; // Output IO underflow count
212 float rateX; // Input/Output clock ratio
214 // debugging counters
215 uint32_t num_xfers;
217 } PAF_AST_IoOut;
219 // Audio Stream Input Task (ASOT) configuration
220 typedef struct PAF_ASOT_Config {
221 Task_Handle taskHandle; // ASOT task handle
222 uint_least16_t state; // ASOT state
223 ACP_Handle acp; // ASOT ACP handle
224 Int8 cbDrainedFlag[DECODEN_MAX]; // CB drained flags
225 PAF_ASPM_Config *pAspmCfg; // ASIT/ASOT shared configuration
226 PAF_AST_Config *pAstCfg; // ASIT/ASOT/ASDT shared configuration
227 PAF_AST_IoOut *pIoOut; // ASOT IO configuration
228 } PAF_ASOT_Config;
230 // ASOT configuration
231 extern PAF_ASOT_Config gPAF_ASOT_config;
233 #endif /* _ASOP_H_ */