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 // PAF_DEVICE_VERSION Symbol Definitions
39 #define PAF_DEVICE_VERSION (PAF_DEVICE & 0xffff)
41 #include <xdc/cfg/global.h>
42 //#include <ti/procsdk_audio/procsdk_audio_typ.h>
43 #include <procsdk_audio_typ.h>
45 #include "paftyp.h"
46 #include <stdasp.h>
47 #include <pafsio_ialg.h>
49 #include "paf_heapMgr.h"
51 #include "asp1.h"
52 #include "audioStreamProc_params.h"
53 #include "audioStreamDecodeProc.h"
55 #include "dbgBenchmark.h" // PCM high-sampling rate + SRC + CAR benchmarking
57 //
58 // Framework Declarations
59 //
61 //#define PAF_AST_params_fxnsPA PAF_AST_params_fxnsPA17
63 //
64 // Audio Data Representation Definitions
65 //
66 // External declarations to patched IROM provide standard functionality.
67 //
69 #if 1
70 // FL: extern this, making it look like shared information between ARM/DSP.
71 // FL: Note could just define the same thing in separate file for ARM application (i.e. add "Slave" at end of identifier).
72 /* audio frame "width" in channels */
73 const SmInt PAF_AST_params_numchan[1] =
74 {
75 32,
76 };
77 #else
78 extern const SmInt PAF_AST_params_numchan[];
79 #endif
81 ///
82 // Audio Stream Processing Function Table Definition
83 //
85 const PAF_AudioFunctions PAF_ASDT_params_audioFrameFunctions =
86 {
87 &PAF_ASP_dB2ToLinear,
88 &PAF_ASP_channelMask,
89 &PAF_ASP_programFormat,
90 &PAF_ASP_sampleRateHz,
91 &PAF_ASP_delay,
92 };
94 //
95 // Source Select Array Declarations -- algorithm keys & sio map
96 //
97 // External declarations to patched IROM provide standard functionality.
98 //
100 #if 1
101 // FL: extern this, making it look like shared information between ARM/DSP.
102 // FL: Note could just define the same thing in separate file for ARM application (i.e. add "Slave" at end of identifier).
103 const PAF_ASP_AlgKey PAF_ASP_params_decAlgKey =
104 {
105 PAF_SOURCE_N, // length
106 /* Relies on the fact that ACP_SERIES_* != 0 here */
107 0, // PAF_SOURCE_UNKNOWN
108 0, // PAF_SOURCE_NONE
109 0, // PAF_SOURCE_PASS
110 PAF_ASP_ALPHACODE (STD, SNG), // PAF_SOURCE_SNG
111 0, // PAF_SOURCE_AUTO
112 0, // PAF_SOURCE_BITSTREAM
113 PAF_ASP_ALPHACODE (STD, DTSUHDA), // PAF_SOURCE_DTSALL
114 PAF_ASP_ALPHACODE (STD, PCM), // PAF_SOURCE_PCMAUTO
115 PAF_ASP_ALPHACODE (STD, PCM), // PAF_SOURCE_PCM
116 PAF_ASP_ALPHACODE (STD, PCN), // PAF_SOURCE_PC8 /* unused */
117 PAF_ASP_ALPHACODE (STD, DDP), // PAF_SOURCE_AC3
118 PAF_ASP_ALPHACODE (STD, DTSUHDA), // PAF_SOURCE_DTS
119 PAF_ASP_ALPHACODE (STD, AAC), // PAF_SOURCE_AAC
120 PAF_ASP_ALPHACODE (STD, MPG), // PAF_SOURCE_MPEG /* unused */
121 PAF_ASP_ALPHACODE (STD, DTSUHDA), // PAF_SOURCE_DTS12
122 PAF_ASP_ALPHACODE (STD, DTSUHDA), // PAF_SOURCE_DTS13
123 PAF_ASP_ALPHACODE (STD, DTSUHDA), // PAF_SOURCE_DTS14
124 PAF_ASP_ALPHACODE (STD, DTSUHDA), // PAF_SOURCE_DTS16
125 0, // PAF_SOURCE_WMA9PRO
126 0, // PAF_SOURCE_MP3
127 PAF_ASP_ALPHACODE (STD, DSD), // PAF_SOURCE_DSD1
128 PAF_ASP_ALPHACODE (STD, DSD), // PAF_SOURCE_DSD2
129 PAF_ASP_ALPHACODE (STD, DSD), // PAF_SOURCE_DSD3
130 PAF_ASP_ALPHACODE (STD, DDP), // PAF_SOURCE_DDP
131 PAF_ASP_ALPHACODE (STD, DTSUHDA), // PAF_SOURCE_DTSHD
132 PAF_ASP_ALPHACODE (STD, THD), // PAF_SOURCE_THD
133 PAF_ASP_ALPHACODE (STD, DXP), // PAF_SOURCE_DXP
134 };
135 #else
136 extern const PAF_ASP_AlgKey PAF_ASP_params_decAlgKey;
137 #endif
139 #if 1
140 // FL: This MUST be shared between ARM/DSP.
141 // FL: extern this, making it look like shared information between ARM/DSP.
142 //
143 // Mapping Declarations -- from *coders to *puts
144 //
145 // External declarations to patched IROM provide standard functionality.
146 //
147 const SmInt PAF_AST_streamsFromDecodes_std[DECODEN_MAX] =
148 {
149 0, 1, 2,
150 };
151 #else
152 extern const SmInt PAF_AST_streamsFromDecodes_std[DECODEN_MAX];
153 #endif
155 const SmInt PAF_AST_inputsFromDecodes_std[DECODEN_MAX] =
156 {
157 0, 1, 2,
158 };
160 //
161 // Audio Framework Initialization Function Table Declarations
162 //
163 // External declarations to patched IROM provide standard functionality.
164 //
166 extern const PAF_ASDT_Fxns PAF_ASDT_params_fxns;
168 #if 1
169 // FL: This MUST be shared between ARM/DSP.
170 // FL: extern this, making it look like shared information between ARM/DSP.
171 const PAF_DecodeStatus PAF_AST_params_decodeStatus_primary =
172 {
173 sizeof (PAF_DecodeStatus), // size
174 1, // mode
175 0, // unused1
176 0, // command.action
177 0, // command.result
178 PAF_SAMPLERATE_UNKNOWN, // sampleRate
179 PAF_SOURCE_NONE, // sourceSelect
180 PAF_SOURCE_UNKNOWN, // sourceProgram
181 PAF_SOURCE_UNKNOWN, // sourceDecode
182 PAF_SOURCE_DUAL_STEREO, // sourceDual
183 4, // sourceKaraoke: both
184 0, // aspGearControl: unused
185 0, // aspGearStatus: unused
186 0, 0, 0, 0, // Unused
187 0, 0, 0, 0, // Unused
188 0, 0, 0, 0, // Unused
189 0, 0, 0, 0, // Unused
190 0, 0, 0, 0, // Unused
191 0, // frameCount
192 0x40, // karaoka: Vocal 1 Level
193 0x40, // karaoka: Vocal 1 Pan
194 0x40, // karaoka: Vocal 2 Level
195 0xc0, // karaoka: Vocal 2 Pan
196 0x40, // karaoka: Melody Level
197 0x00, // karaoka: Melody Pan
198 0, // decBypass
199 0, // unused
200 0, // frameLength: reset later
201 1, // bufferRatio: unity
202 PAF_IEC_PREEMPHASIS_UNKNOWN, // emphasis
203 0, // bufferDrift
204 0, 0,
205 PAF_CC_SAT_SURROUND4, PAF_CC_SUB_ONE, PAF_CC_AUX_SURROUND4_UNKNOWN, 0, 0, 0, 0, 0,
206 // channelConfigurationRequest.full
207 PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,
208 // channelConfigurationProgram.full
209 PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,
210 // channelConfigurationDecode.full
211 PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,
212 // channelConfigurationDownmix.full
213 PAF_CC_SAT_UNKNOWN, PAF_CC_SUB_ZERO, 0, 0, 0, 0, 0, 0,
214 // channelConfigurationOverride.full
215 -3, // channelMap.from[0]
216 -3, // channelMap.from[1]
217 -3, // channelMap.from[2]
218 -3, // channelMap.from[3]
219 -3, // channelMap.from[4]
220 -3, // channelMap.from[5]
221 -3, // channelMap.from[6]
222 -3, // channelMap.from[7]
223 -3, // channelMap.from[8]
224 -3, // channelMap.from[9]
225 -3, // channelMap.from[10]
226 -3, // channelMap.from[11]
227 -3, // channelMap.from[12]
228 -3, // channelMap.from[13]
229 -3, // channelMap.from[14]
230 -3, // channelMap.from[15]
231 -3, // channelMap.from[16]
232 -3, // channelMap.from[17]
233 -3, // channelMap.from[18]
234 -3, // channelMap.from[19]
235 -3, // channelMap.from[20]
236 -3, // channelMap.from[21]
237 -3, // channelMap.from[22]
238 -3, // channelMap.from[23]
239 -3, // channelMap.from[24]
240 -3, // channelMap.from[25]
241 -3, // channelMap.from[26]
242 -3, // channelMap.from[27]
243 -3, // channelMap.from[28]
244 -3, // channelMap.from[29]
245 -3, // channelMap.from[30]
246 -3, // channelMap.from[31]
247 -3, // channelMap.to[0]
248 -3, // channelMap.to[1]
249 -3, // channelMap.to[2]
250 -3, // channelMap.to[3]
251 -3, // channelMap.to[4]
252 -3, // channelMap.to[5]
253 -3, // channelMap.to[6]
254 -3, // channelMap.to[7]
255 -3, // channelMap.to[8]
256 -3, // channelMap.to[9]
257 -3, // channelMap.to[10]
258 -3, // channelMap.to[11]
259 -3, // channelMap.to[12]
260 -3, // channelMap.to[13]
261 -3, // channelMap.to[14]
262 -3, // channelMap.to[15]
263 -3, // channelMap.to[16]
264 -3, // channelMap.to[17]
265 -3, // channelMap.to[18]
266 -3, // channelMap.to[19]
267 -3, // channelMap.to[20]
268 -3, // channelMap.to[21]
269 -3, // channelMap.to[22]
270 -3, // channelMap.to[23]
271 -3, // channelMap.to[24]
272 -3, // channelMap.to[25]
273 -3, // channelMap.to[26]
274 -3, // channelMap.to[27]
275 -3, // channelMap.to[28]
276 -3, // channelMap.to[29]
277 -3, // channelMap.to[30]
278 -3, // channelMap.to[31]
279 0, // programFormat.mask
280 0, // programFormat.form
282 };
283 #else
284 //extern const PAF_DecodeStatus PAF_AST_params_decodeStatus_primary;
285 #endif
287 #if 1
288 // FL: extern this, making it look like shared information between ARM/DSP.
289 // FL: Note could just define the same thing in separate file for ARM application (i.e. add "Slave" at end of identifier).
290 /* audio frame "width" in channels */
291 const PAF_DecodeStatus *const PAF_ASDT_params_decodeStatus[] =
292 {
293 &PAF_AST_params_decodeStatus_primary,
294 };
295 #else
296 //extern const PAF_DecodeStatus *const PAF_AST_params_decodeStatus[];
297 #endif // FL: #if 0
299 //
300 // Common Space Parameter Declarations and Definitions
301 //
302 // Local definitions in RAM provide non-standard functionality.
303 // The NULL pointer provides standard functionality.
304 //
306 /* baseline definition - NULL equivalent */
307 /* May be used for overrides of IALG_MemSpace */
309 static const IALG_MemSpace params_memspace_PAi_Slave[] = {
310 PAF_IALG_NONE, // Scratch
311 PAF_IALG_NONE, // Persistant
312 PAF_IALG_NONE, // Write once
313 PAF_IALG_NONE, // Common 1
314 PAF_IALG_NONE, // Common 2
315 PAF_IALG_NONE, // Common 3
316 PAF_IALG_NONE, // Common 4
317 PAF_IALG_NONE, // Common 5
318 PAF_IALG_NONE, // Common 6
319 PAF_IALG_NONE, // Common 7
320 IALG_EXTERNAL, // Common 8
321 PAF_IALG_NONE, // Common 9
322 PAF_IALG_NONE, // Common 10
323 PAF_IALG_NONE, // Common 11
324 PAF_IALG_NONE, // Common 12
325 PAF_IALG_NONE, // Common 13
326 PAF_IALG_NONE, // Common 14
327 PAF_IALG_NONE, // Common 15
328 };
330 //
331 // Heap Declarations
332 //
334 //#include <pafhjt.h>
336 // .............................................................................
337 const PAF_MetadataBufStatus PAF_ASDT_params_MetadataBufStatus[] =
338 {
339 PAF_MAX_PRIVATE_MD_SZ, // bufSize
340 PAF_MAX_NUM_PRIVATE_MD, // NumBuf
341 128, // alignment
342 &gPafHeapIdExt // pHeapIdMdbuf
343 };
345 #if 0 // FL: maybe needed on ARM if there's an audio frame buffer defined for decode (and possible stream)
346 // .............................................................................
347 //
348 // This structure defines the memory allocation of audio frame buffers (channel buffers). Users can customize this structure based
349 // on their requirement. IALG_SARAM specifies the audio frame buffer is allocated in IRAM and IALG_EXTERNAL
350 // specifies the audio frame buffer is allocated in SDRAM. By allocating few channel buffers in SDRAM, users can save internal memory
351 // but trading performance
352 // This structure defined for PAF_MAXNUMCHAN number of channels. But channel buffers will be allocated for "PAF_AST_params_numchan"
353 // number of channels only.
354 //
356 const PAF_AudioFrameBufStatus PAF_AST_params_AudioFrameBufStatus[PAF_MAXNUMCHAN] =
357 {
358 IALG_SARAM, // 0
359 IALG_SARAM,
360 IALG_SARAM,
361 IALG_SARAM,
362 IALG_SARAM,
363 IALG_SARAM,
364 IALG_SARAM,
365 IALG_SARAM,
366 IALG_SARAM,
367 IALG_SARAM,
368 IALG_SARAM,
369 IALG_SARAM,
370 IALG_SARAM,
371 IALG_SARAM,
372 IALG_SARAM,
373 IALG_SARAM,
374 IALG_SARAM, // 16
375 IALG_SARAM,
376 IALG_SARAM,
377 IALG_SARAM,
378 IALG_SARAM,
379 IALG_SARAM,
380 IALG_SARAM,
381 IALG_SARAM,
382 IALG_SARAM,
383 IALG_SARAM,
384 IALG_SARAM,
385 IALG_SARAM,
386 IALG_SARAM,
387 IALG_SARAM,
388 IALG_SARAM,
389 IALG_SARAM, // 31
390 //IALG_EXTERNAL, // 16
391 //IALG_EXTERNAL,
392 //IALG_EXTERNAL,
393 //IALG_EXTERNAL,
394 //IALG_EXTERNAL,
395 //IALG_EXTERNAL,
396 //IALG_EXTERNAL,
397 //IALG_EXTERNAL,
398 //IALG_EXTERNAL,
399 //IALG_EXTERNAL,
400 //IALG_EXTERNAL,
401 //IALG_EXTERNAL,
402 //IALG_EXTERNAL,
403 //IALG_EXTERNAL,
404 //IALG_EXTERNAL,
405 //IALG_EXTERNAL // 31
406 };
407 #endif // FL: #if 0
409 // .............................................................................
410 //
411 // Audio Stream Parameter Definitions
412 //
413 // Global definition in RAM provides standard & non-standard functionality.
414 //
416 const PAF_ASDT_Params asdp_params_PAi =
417 {
418 &PAF_ASDT_params_fxns, // fxns
419 { // zone
420 0, // zone.master
421 1, // zone.decodes
422 0, // zone.decode1
423 1, // zone.decodeN
424 1, // zone.streams
425 },
426 PAF_AST_inputsFromDecodes_std,
427 { // heap
428 &gPafHeapIdInt1, // heap.pHeapIdIntern
429 &gPafHeapIdExt, // heap.pHeapIdExtern
430 &gPafHeapIdExt, // heap.pHeapIdFrmbuf
431 &gPafHeapIdInt1, // heap.pHeapIdIntern1
432 &gPafHeapIdInt1Shm, // heap.pHeapIdInt1Shm
433 &gPafHeapIdExtShm, // heap.pHeapIdExtShm
434 &gPafHeapIdExtNonCachedShm, // heap.pHeapIdExtNonCachedShm
435 1, // heap.clear
436 },
437 { // common
438 params_memspace_PAi_Slave, // common.space
439 },
440 PAF_AST_params_numchan, // z_numchan
441 PAF_SYS_FRAMELENGTH, // framelength
442 &PAF_ASDT_params_audioFrameFunctions, // pAudioFrameFunctions
443 &PAF_ASP_chainFxns, // pChainFxns
444 PAF_ASDT_params_decodeStatus, // z_pDecodeStatus
445 &PAF_ASP_params_decAlgKey, // pDecAlgKey
446 PAF_AST_streamsFromDecodes_std, // streamsFromDecodes
447 14592, // maxFramelength set to match maximum value possible for a stream,
448 // max for 192k THD:
449 // 14592 = ((nearest 256 mutiple of (90AUs/frame * 160sample/AU))
450 // + 256 samples remaining in wrapper from previous deccode)
451 PAF_ASDT_params_MetadataBufStatus, //metadata buffer status
452 NULL //PAF_AST_params_AudioFrameBufStatus //Audio frame buffer status
453 };
455 // EOF