summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/abe/abe_fw.h
blob: 33e29d4fe77df8be3eff1b7783bc9da83570de8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
/*
 * ==========================================================================
 *               Texas Instruments OMAP(TM) Platform Firmware
 * (c) Copyright 2009, Texas Instruments Incorporated.  All Rights Reserved.
 *
 *  Use of this firmware is controlled by the terms and conditions found
 *  in the license agreement under which this firmware has been supplied.
 * ==========================================================================
 */

#include "abe_cm_addr.h"
#include "abe_sm_addr.h"
#include "abe_dm_addr.h"
#include "abe_typedef.h"

/*
 * GLOBAL DEFINITION
 */
#define FW_SCHED_LOOP_FREQ		4000	/* one scheduler loop = 4kHz = 12 samples at 48kHz */
#define EVENT_FREQUENCY			96000
#define SLOTS_IN_SCHED_LOOP		(96000/FW_SCHED_LOOP_FREQ)

#define SCHED_LOOP_8kHz			( 8000/FW_SCHED_LOOP_FREQ)
#define SCHED_LOOP_16kHz		(16000/FW_SCHED_LOOP_FREQ)
#define SCHED_LOOP_24kHz		(24000/FW_SCHED_LOOP_FREQ)
#define SCHED_LOOP_48kHz		(48000/FW_SCHED_LOOP_FREQ)

#define TASKS_IN_SLOT			8
/*
 * DMEM AREA - SCHEDULER
 */
#define smem_mm_trace			0
#define dmem_mm_trace			D_debugATCptrs_ADDR
#define dmem_mm_trace_size		((D_debugATCptrs_ADDR_END-D_debugATCptrs_ADDR+1)/4)


#define ATC_SIZE			8   /* 8 bytes per descriptors */

typedef struct {
	unsigned rdpt:7;	/* first 32bits word of the descriptor */
	unsigned reserved0:1;
	unsigned cbsize:7;
	unsigned irqdest:1;
	unsigned cberr:1;
	unsigned reserved1:5;
	unsigned cbdir:1;
	unsigned nw:1;
	unsigned wrpt:7;
	unsigned reserved2:1;
	unsigned badd:12;	/* second 32bits word of the descriptor */
	unsigned iter:7;	/*  iteration field overlaps the 16 bits boundary */
	unsigned srcid:6;
	unsigned destid:6;
	unsigned desen:1;
} abe_satcdescriptor_aess;

/*
 *  table of scheduler tasks :
 *  char scheduler_table[24 x 4] : four bytes used at OPP100%
 */
#define dmem_scheduler_table		D_multiFrame_ADDR

#define dmem_eanc_task_pointer		D_pFastLoopBack_ADDR

/*
 *  OPP value :
 *  pointer increment steps in the scheduler table
 */
#define dmem_scheduler_table_step	D_taskStep_ADDR

/*
 *  table of scheduler tasks (max 64) :
 *  char task_descriptors[64 x 8] : eight bytes per task
 *     TASK INDEX, INITPTR 1,2,3, INITREG, Loop Counter, Reserved 1,2
 */
#define dmem_task_descriptor		D_tasksList_ADDR

/*
 *  table of task function addresses:
 *  short task_function_descriptors[32 x 1] : 16bits addresses to PMEM using TASK_INDEX above
 */

/*
 *  IDs of the micro tasks
 */

// from ABE_FunctionsId.h
/*#define id_		copyMultiFrame_TFID
#define id_		inplaceGain_TFID
#define id_		mixer_TFID
#define id_		IIR_TFID
#define id_		gainConverge_TFID
#define id_		sinGen_TFID
#define id_		OSR0Fill_TFID
#define id_		IOtask_TFID

#define id_mixer
#define id_eq
#define id_upsample_src
#define id_downsample_src
#define id_asrc
#define id_gain_update
#define id_aps_hs
#define id_aps_ihf
#define id_dither
#define id_eanc
#define id_io
#define id_router
#define id_dynamic_dl
#define id_dynamic_ul
#define id_sequence_reader
#define id_ ..
*/

/*
 *  I/O DESCRIPTORS
 */
#define dmem_port_descriptors		D_IOdescr_ADDR

/* ping_pong_t descriptors table
 *   structure of 8 bytes:
 *       uint16 base_address1
 *       uint16 size1       (16bits address format)
 *       uint16 base_address2
 *       uint16 size2
 *   } ping_pong_t
 *  ping_pong_t dmem_ping_pong_t [8]
 */
#define dmem_ping_pong_buffer		D_PING_ADDR	/* U8 address */

/*
 *  IRQ mask used with ports with IRQ (DMA or host)
 *  uint32 dmem_irq_masks [8]
 */
#define dmem_irq_masks			D_IRQMask_ADDR

/*
 *  tables of to the 8 FIFO sequences (delayed commands) holding 12bytes tasks in the format
 *  structure {
 *       1) Down counter delay on 16bits, decremented on each scheduler period
 *       2) Code on 8 bits for the type of operation to execute : call or data move.
 *       3) Three 16bits parameters (for data move example example : source/destination/counter)
 *       4) Three bytes reserved
 *      } seq_fw_task_t
 *
 *  structure {
 *      uint32 : base address(MSB) + read pointer(LSB)
 *      uint32 : max address (MSB) + write pointer (LSB)
 *      } FIFO_generic;
 *      seq_fw_task_t FIFO_CONTENT [8]; 96 bytes
 *
 *   FIFO_SEQ dmem_fifo_sequences [8]; all FIFO sequences
 */
#define dmem_fifo_sequences		D_DCFifo_ADDR
#define dmem_fifo_sequences_descriptors	D_DCFifoDesc_ADDR

/*
 *  IRQ FIFOs
 *
 *  structure {
 *      uint32 : base address(MSB) + read pointer(LSB)
 *      uint32 : max address (MSB) + write pointer (LSB)
 *      uint32 IRQ_CODES [6];
 *      } dmem_fifo_irq_mcu;  32 bytes
 *      } dmem_fifo_irq_dsp;  32 bytes
 */
#define dmem_fifo_irq_mcu_descriptor	D_McuIrqFifoDesc_ADDR
#define dmem_fifo_irq_dsp_descriptor	D_DspIrqFifoDesc_ADDR
#define dmem_fifo_irq_mcu		D_McuIrqFifo_ADDR
#define dmem_fifo_irq_dsp		D_DspIrqFifo_ADDR

/*
 *  remote debugger exchange buffer
 *  uint32 dmem_debug_ae2hal [32]
 *  uint32 dmem_debug_hal2ae [32]
 */
#define dmem_debug_ae2hal		D_DebugAbe2hal_ADDR
#define dmem_debug_hal2ae		D_Debug_hal2abe_ADDR

/*
 *  DMEM address of the ASRC ppm drift parameter for ASRCs (voice and multimedia paths)
 *  uint32 smem_asrc(x)_drift
 */
#define dmem_asrc1_drift		D_ASRC1drift_ADDR
#define dmem_asrc2_drift		D_ASRC2drift_ADDR

/*
 *  DMEM indexes of the router uplink paths
 *  uint8 dmem_router_index [8]
 */
// OC: TBD ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//#define dmem_router_index

/*
 *  analog control circular buffer commands to Phoenix
 *  structure {
 *      uint32 : base address(MSB) + read pointer(LSB)
 *      uint32 : max address (MSB) + write pointer (LSB)
 *      uint32 FIFO_CONTENT [6];
 *      } dmem_commands_to_phoenix;     32 bytes
 */
#define dmem_commands_to_phoenix		D_Cmd2PhenixFifo_ADDR
#define dmem_commands_to_phoenix_descriptor	D_Cmd2PhenixFifoDesc_ADDR

/*
 *  analog control circular buffer commands from Phoenix (status line)
 *  structure {
 *      uint32 : base address(MSB) + read pointer(LSB)
 *      uint32 : max address (MSB) + write pointer (LSB)
 *      uint32 FIFO_CONTENT [6];
 *      } dmem_commands_to_phoenix;     32 bytes
 */
#define dmem_commands_from_phoenix		D_StatusFromPhenixFifo_ADDR
#define dmem_commands_from_phoenix_descriptor	D_StatusFromPhenixFifoDesc_ADDR

/*
 *  DEBUG mask
 *  uint16 dmem_debug_trace_mask
 *  each bit of this word enables a type a trace in the debug circular buffer
 */

// OC: TBD ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//#define dmem_debug_trace_mask

/*
 *  DEBUG circular buffer
 *  structure {
 *      uint32 : base address(MSB) + read pointer(LSB)
 *      uint32 : max address (MSB) + write pointer (LSB)
 *      uint32 FIFO_CONTENT [14];  = TIMESTAMP + CODE
 *      } dmem_debug_trace_buffer;     64 bytes
 *  should be much larger (depends on the DMEM mapping...)
 */
#define dmem_debug_trace_buffer
#define dmem_debug_trace_fifo		D_debugFifo_ADDR
#define dmem_debug_trace_descriptor	D_debugFifoDesc_ADDR

/*
 *  Infinite counter incremented on each sheduler periods (~250 us)
 *  uint16 dmem_debug_time_stamp
 */
#define dmem_debug_time_stamp		D_loopCounter_ADDR

/*
 *  ATC BUFFERS + IO TASKS SMEM buffers
 */
#define dmem_dmic			D_DMIC_UL_FIFO_ADDR
#define dmem_dmic_size			((D_DMIC_UL_FIFO_ADDR_END-D_DMIC_UL_FIFO_ADDR+1)/4)
#define smem_dmic1			DMIC0_96_labelID
#define smem_dmic2			DMIC1_96_labelID
#define smem_dmic3			DMIC2_96_labelID

#define dmem_amic			D_McPDM_UL_FIFO_ADDR
#define dmem_amic_size			((D_McPDM_UL_FIFO_ADDR_END-D_McPDM_UL_FIFO_ADDR+1)/4)
#define smem_amic			AMIC_96_labelID

#define dmem_mcpdm			D_McPDM_DL_FIFO_ADDR
#define dmem_mcpdm_size			((D_McPDM_DL_FIFO_ADDR_END-D_McPDM_DL_FIFO_ADDR+1)/4)

#define dmem_mm_ul			D_MM_UL_FIFO_ADDR
#define dmem_mm_ul_size			((D_MM_UL_FIFO_ADDR_END-D_MM_UL_FIFO_ADDR+1)/4)
#define smem_mm_ul			MM_UL_labelID	/* managed directly by the router */

#define dmem_mm_ul2			D_MM_UL2_FIFO_ADDR
#define dmem_mm_ul2_size		((D_MM_UL2_FIFO_ADDR_END-D_MM_UL2_FIFO_ADDR+1)/4)
#define smem_mm_ul2			MM_UL2_labelID /* managed directly by the router */

#define dmem_mm_dl			D_MM_DL_FIFO_ADDR
#define dmem_mm_dl_size			((D_MM_DL_FIFO_ADDR_END-D_MM_DL_FIFO_ADDR+1)/4)
#define smem_mm_dl_opp100		MM_DL_labelID
#define smem_mm_dl_opp25			MM_DL_labelID		/* @@@ at OPP 25/50 or without ASRC */

#define dmem_vx_dl			D_VX_DL_FIFO_ADDR
#define dmem_vx_dl_size			((D_VX_DL_FIFO_ADDR_END-D_VX_DL_FIFO_ADDR+1)/4)
#define smem_vx_dl			Voice_16k_DL_labelID	/* ASRC input buffer, size 40 */

#define dmem_vx_ul			D_VX_UL_FIFO_ADDR
#define dmem_vx_ul_size			((D_VX_UL_FIFO_ADDR_END-D_VX_UL_FIFO_ADDR+1)/4)
#define smem_vx_ul			Voice_16k_UL_labelID

#define dmem_tones_dl			D_TONES_DL_FIFO_ADDR
#define dmem_tones_dl_size		((D_TONES_DL_FIFO_ADDR_END-D_TONES_DL_FIFO_ADDR+1)/4)
#define smem_tones_dl			Tones_labelID

#define dmem_vib_dl			D_VIB_DL_FIFO_ADDR
#define dmem_vib_dl_size		((D_VIB_DL_FIFO_ADDR_END-D_VIB_DL_FIFO_ADDR+1)/4)
#define smem_vib			IO_VIBRA_DL_labelID

#define dmem_mm_ext_out			D_MM_EXT_OUT_FIFO_ADDR
#define dmem_mm_ext_out_size		((D_MM_EXT_OUT_FIFO_ADDR_END-D_MM_EXT_OUT_FIFO_ADDR+1)/4)
#define smem_mm_ext_out			DL1_M_labelID

#define dmem_mm_ext_in			D_MM_EXT_IN_FIFO_ADDR
#define dmem_mm_ext_in_size		((D_MM_EXT_IN_FIFO_ADDR_END-D_MM_EXT_IN_FIFO_ADDR+1)/4)
#define smem_mm_ext_in			AMIC_labelID

#define dmem_bt_vx_dl			D_BT_DL_FIFO_ADDR
#define dmem_bt_vx_dl_size		((D_BT_DL_FIFO_ADDR_END-D_BT_DL_FIFO_ADDR+1)/4)
#define smem_bt_vx_dl			AMIC_labelID

#define dmem_bt_vx_ul			D_BT_UL_FIFO_ADDR
#define dmem_bt_vx_ul_size		((D_BT_UL_FIFO_ADDR_END-D_BT_UL_FIFO_ADDR+1)/4)
#define smem_bt_vx_ul			DL1_M_labelID

/*
 * INITPTR / INITREG AREA
 */

/*
 *  POINTER - used for the port descriptor programming
 *  corresponds to 8bits addresses to the INITPTR area
 *
 * List  from ABE_INITxxx_labels.h
 */
#define ptr_ul_rec
#define ptr_vx_dl
#define ptr_mm_dl
#define ptr_mm_ext
#define ptr_tones
#define ptr_vibra2

/*
 * SMEM AREA
 */

/*
 *  PHOENIX OFFSET in SMEM
 *  used to subtract a DC offset on the headset path (power consumption optimization)
 */

/* OC: exact usage to be detailled */
#define smem_phoenix_offset		S_PhoenixOffset_ADDR

/*
 *  EQUALIZERS Z AREA
 *  used to reset the filter memory - IIR-8 (max)
 *  int24 stereo smem_equ(x) [8x2 + 1]
 */
#define smem_equ1		S_EQU1_data_ADDR
#define smem_equ2		S_EQU2_data_ADDR
#define smem_equ3		S_EQU3_data_ADDR
#define smem_equ4		S_EQU4_data_ADDR
#define smem_sdt		S_SDT_data_ADDR

/*
 *  GAIN SMEM on PORT
 *  int32 smem_G0 [18] : desired gain on the ports
 *  format of G0 = 6 bits left shifted desired gain in linear 24bits format
 *  int24 stereo G0 [18] = G0
 *  int24 stereo GI [18] current value of the gain in the same format of G0
 *  List of smoothed gains :
 *  6 DMIC 0 1 2 3 4 5
 *  2 AMIC L R
 *  4 PORT1/2_RX L R
 *  2 MM_EXT L R
 *  2 MM_VX_DL L R
 *  2 IHF L R
 * ---------------
 * 18 = TOTAL
 */
//#define smem_g0			S_GTarget_ADDR	/* [9] 2 gains in 1 SM address */
//#define smem_g1			S_GCurrent_ADDR	/* [9] 2 gains in 1 SM address */

/*
 * COEFFICIENTS AREA
 */

/*
 *  delay coefficients used in the IIR-1 filters
 *  int24 cmem_gain_delay_iir1[9 x 2]  (a, (1-a))
 *
 *  3 for 6 DMIC 0 1 2 3 4 5
 *  1 for 2 AMIC L R
 *  2 for 4 PORT1/2_RX L R
 *  1 for 2 MM_EXT L R
 *  1 for 2 MM_VX_DL L R
 *  1 for 2 IHF L R
 */

#define cmem_gain_alpha		C_Alpha_ADDR	/* [9] */
#define cmem_gain_1_alpha	C_1_Alpha_ADDR

/*
 * gain controls
 */
#define GAIN_LEFT_OFFSET	(abe_port_id)0
#define GAIN_RIGHT_OFFSET	(abe_port_id)1

#define cmem_gains_base		C_GainsWRamp_ADDR
#define smem_target_gain_base	S_GTarget1_ADDR
#define cmem_1_Alpha_base	C_1_Alpha_ADDR
#define cmem_Alpha_base		C_Alpha_ADDR

#define dmic1_gains_offset	0	/* stereo gains */
#define dmic2_gains_offset	2	/* stereo gains */
#define dmic3_gains_offset	4	/* stereo gains */
#define amic_gains_offset	6	/* stereo gains */
#define dl1_gains_offset	8	/* stereo gains */
#define dl2_gains_offset	10	/* stereo gains */
#define splitters_gains_offset	12	/* stereo gains */

#define mixer_dl1_offset	14
#define mixer_dl2_offset	18
#define mixer_echo_offset	22
#define mixer_sdt_offset	24
#define mixer_vxrec_offset	26
#define mixer_audul_offset	30
#define gain_unused_offset	34

/*
 *  DMIC SRC 96->48
 *  the filter is changed depending on the decimatio ratio used (16/25/32/40)
 *  int32 cmem_src2_dmic [6]   IIR with 2 coefs in the recursive part and 4 coefs in the direct part
 */
#define cmem_src2_dmic

/*
 *  EANC coefficients
 *  structure of :
 *      20 Q6.26 coef for the FIR
 *      16 Q6.26 coef for the IIR
 *      1 Q6.26 coef for Lambda
 */
#define cmem_eanc_coef_fir
#define cmem_eanc_coef_iir
#define cmem_eanc_coef_lambda

/*
 *  EQUALIZERS - SDT - COEF AREA
 *  int24  cmem_equ(x) [8x2+1]
 */
#define cmem_equ1		C_EQU1_data_ADDR
#define cmem_equ2		C_EQU2_data_ADDR
#define cmem_equ3		C_EQU3_data_ADDR
#define cmem_equ4		C_EQU4_data_ADDR
#define cmem_sdt		C_SDT_data_ADDR

/*
 *  APS - COEF AREA
 *  int24  cmem_aps(x) [16]
 */
#define cmem_aps1
#define cmem_aps2
#define cmem_aps3

/*
 *  DITHER - COEF AREA
 *  int24  cmem_dither(x) [4]
 */
#define cmem_dither

/*
 * PMEM AREA
 */
#define sub_null_copy		NULL_COPY_CFPID
#define sub_copy_dmic		COPY_DMIC_CFPID
#define sub_copy_mm_ul		COPY_MM_UL_CFPID
#define sub_copy_mcpdm_dl	COPY_MCPDM_DL_CFPID
#define sub_copy_d2s_1616	COPY_D2S_LR_CFPID	/* data move in IO tasks */
#define sub_copy_d2s		COPY_D2S_2_CFPID
#define sub_copy_d2s_mono	COPY_D2S_MONO_CFPID
#define sub_copy_s2d_left	COPY_S1D_MONO_CFPID
#define sub_copy_s2d_mono	COPY_S2D_MONO_CFPID
#define sub_copy_s2d		COPY_S2D_2_CFPID

//#ifdef __cplusplus
//}
//#endif