blob: 2c887855e7d8e422df3e721ba6b746c78f60a8da [file] [log] [blame]
Mark Browna4b12992014-03-12 23:04:35 +00001#ifndef __SST_MFLD_DSP_H__
2#define __SST_MFLD_DSP_H__
Vinod Koulc514a912012-08-16 17:10:42 +05303/*
Mark Browna4b12992014-03-12 23:04:35 +00004 * sst_mfld_dsp.h - Intel SST Driver for audio engine
Vinod Koulc514a912012-08-16 17:10:42 +05305 *
Vinod Koulaa9b0452014-06-13 18:03:54 +05306 * Copyright (C) 2008-14 Intel Corporation
Vinod Koulc514a912012-08-16 17:10:42 +05307 * Authors: Vinod Koul <vinod.koul@linux.intel.com>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2 of the License.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
Vinod Koulc514a912012-08-16 17:10:42 +053019 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 */
21
Vinod Koulaa9b0452014-06-13 18:03:54 +053022#define SST_MAX_BIN_BYTES 1024
23
24#define MAX_DBG_RW_BYTES 80
25#define MAX_NUM_SCATTER_BUFFERS 8
26#define MAX_LOOP_BACK_DWORDS 8
27/* IPC base address and mailbox, timestamp offsets */
28#define SST_MAILBOX_SIZE 0x0400
29#define SST_MAILBOX_SEND 0x0000
30#define SST_TIME_STAMP 0x1800
31#define SST_TIME_STAMP_MRFLD 0x800
32#define SST_RESERVED_OFFSET 0x1A00
33#define SST_SCU_LPE_MAILBOX 0x1000
34#define SST_LPE_SCU_MAILBOX 0x1400
35#define SST_SCU_LPE_LOG_BUF (SST_SCU_LPE_MAILBOX+16)
36#define PROCESS_MSG 0x80
37
38/* Message ID's for IPC messages */
39/* Bits B7: SST or IA/SC ; B6-B4: Msg Category; B3-B0: Msg Type */
40
41/* I2L Firmware/Codec Download msgs */
42#define IPC_IA_PREP_LIB_DNLD 0x01
43#define IPC_IA_LIB_DNLD_CMPLT 0x02
44#define IPC_IA_GET_FW_VERSION 0x04
45#define IPC_IA_GET_FW_BUILD_INF 0x05
46#define IPC_IA_GET_FW_INFO 0x06
47#define IPC_IA_GET_FW_CTXT 0x07
48#define IPC_IA_SET_FW_CTXT 0x08
49#define IPC_IA_PREPARE_SHUTDOWN 0x31
50/* I2L Codec Config/control msgs */
51#define IPC_PREP_D3 0x10
52#define IPC_IA_SET_CODEC_PARAMS 0x10
53#define IPC_IA_GET_CODEC_PARAMS 0x11
54#define IPC_IA_SET_PPP_PARAMS 0x12
55#define IPC_IA_GET_PPP_PARAMS 0x13
56#define IPC_SST_PERIOD_ELAPSED_MRFLD 0xA
57#define IPC_IA_ALG_PARAMS 0x1A
58#define IPC_IA_TUNING_PARAMS 0x1B
59#define IPC_IA_SET_RUNTIME_PARAMS 0x1C
60#define IPC_IA_SET_PARAMS 0x1
61#define IPC_IA_GET_PARAMS 0x2
62
63#define IPC_EFFECTS_CREATE 0xE
64#define IPC_EFFECTS_DESTROY 0xF
65
66/* I2L Stream config/control msgs */
67#define IPC_IA_ALLOC_STREAM_MRFLD 0x2
68#define IPC_IA_ALLOC_STREAM 0x20 /* Allocate a stream ID */
69#define IPC_IA_FREE_STREAM_MRFLD 0x03
70#define IPC_IA_FREE_STREAM 0x21 /* Free the stream ID */
71#define IPC_IA_SET_STREAM_PARAMS 0x22
72#define IPC_IA_SET_STREAM_PARAMS_MRFLD 0x12
73#define IPC_IA_GET_STREAM_PARAMS 0x23
74#define IPC_IA_PAUSE_STREAM 0x24
75#define IPC_IA_PAUSE_STREAM_MRFLD 0x4
76#define IPC_IA_RESUME_STREAM 0x25
77#define IPC_IA_RESUME_STREAM_MRFLD 0x5
78#define IPC_IA_DROP_STREAM 0x26
79#define IPC_IA_DROP_STREAM_MRFLD 0x07
80#define IPC_IA_DRAIN_STREAM 0x27 /* Short msg with str_id */
81#define IPC_IA_DRAIN_STREAM_MRFLD 0x8
82#define IPC_IA_CONTROL_ROUTING 0x29
83#define IPC_IA_VTSV_UPDATE_MODULES 0x20
84#define IPC_IA_VTSV_DETECTED 0x21
85
86#define IPC_IA_START_STREAM_MRFLD 0X06
87#define IPC_IA_START_STREAM 0x30 /* Short msg with str_id */
88
89#define IPC_IA_SET_GAIN_MRFLD 0x21
90/* Debug msgs */
91#define IPC_IA_DBG_MEM_READ 0x40
92#define IPC_IA_DBG_MEM_WRITE 0x41
93#define IPC_IA_DBG_LOOP_BACK 0x42
94#define IPC_IA_DBG_LOG_ENABLE 0x45
95#define IPC_IA_DBG_SET_PROBE_PARAMS 0x47
96
97/* L2I Firmware/Codec Download msgs */
98#define IPC_IA_FW_INIT_CMPLT 0x81
99#define IPC_IA_FW_INIT_CMPLT_MRFLD 0x01
100#define IPC_IA_FW_ASYNC_ERR_MRFLD 0x11
101
102/* L2I Codec Config/control msgs */
103#define IPC_SST_FRAGMENT_ELPASED 0x90 /* Request IA more data */
104
105#define IPC_SST_BUF_UNDER_RUN 0x92 /* PB Under run and stopped */
106#define IPC_SST_BUF_OVER_RUN 0x93 /* CAP Under run and stopped */
107#define IPC_SST_DRAIN_END 0x94 /* PB Drain complete and stopped */
108#define IPC_SST_CHNGE_SSP_PARAMS 0x95 /* PB SSP parameters changed */
109#define IPC_SST_STREAM_PROCESS_FATAL_ERR 0x96/* error in processing a stream */
110#define IPC_SST_PERIOD_ELAPSED 0x97 /* period elapsed */
111
112#define IPC_SST_ERROR_EVENT 0x99 /* Buffer over run occurred */
113/* L2S messages */
114#define IPC_SC_DDR_LINK_UP 0xC0
115#define IPC_SC_DDR_LINK_DOWN 0xC1
116#define IPC_SC_SET_LPECLK_REQ 0xC2
117#define IPC_SC_SSP_BIT_BANG 0xC3
118
119/* L2I Error reporting msgs */
120#define IPC_IA_MEM_ALLOC_FAIL 0xE0
121#define IPC_IA_PROC_ERR 0xE1 /* error in processing a
122 stream can be used by playback and
123 capture modules */
124
125/* L2I Debug msgs */
126#define IPC_IA_PRINT_STRING 0xF0
127
128/* Buffer under-run */
129#define IPC_IA_BUF_UNDER_RUN_MRFLD 0x0B
130
131/* Mrfld specific defines:
132 * For asynchronous messages(INIT_CMPLT, PERIOD_ELAPSED, ASYNC_ERROR)
133 * received from FW, the format is:
134 * - IPC High: pvt_id is set to zero. Always short message.
135 * - msg_id is in lower 16-bits of IPC low payload.
136 * - pipe_id is in higher 16-bits of IPC low payload for period_elapsed.
137 * - error id is in higher 16-bits of IPC low payload for async errors.
138 */
139#define SST_ASYNC_DRV_ID 0
140
141/* Command Response or Acknowledge message to any IPC message will have
142 * same message ID and stream ID information which is sent.
143 * There is no specific Ack message ID. The data field is used as response
144 * meaning.
145 */
146enum ackData {
147 IPC_ACK_SUCCESS = 0,
148 IPC_ACK_FAILURE,
149};
150
151enum ipc_ia_msg_id {
152 IPC_CMD = 1, /*!< Task Control message ID */
153 IPC_SET_PARAMS = 2,/*!< Task Set param message ID */
154 IPC_GET_PARAMS = 3, /*!< Task Get param message ID */
155 IPC_INVALID = 0xFF, /*!<Task Get param message ID */
156};
157
Vinod Koulc514a912012-08-16 17:10:42 +0530158enum sst_codec_types {
159 /* AUDIO/MUSIC CODEC Type Definitions */
160 SST_CODEC_TYPE_UNKNOWN = 0,
161 SST_CODEC_TYPE_PCM, /* Pass through Audio codec */
162 SST_CODEC_TYPE_MP3,
163 SST_CODEC_TYPE_MP24,
164 SST_CODEC_TYPE_AAC,
165 SST_CODEC_TYPE_AACP,
166 SST_CODEC_TYPE_eAACP,
167};
168
169enum stream_type {
170 SST_STREAM_TYPE_NONE = 0,
171 SST_STREAM_TYPE_MUSIC = 1,
172};
173
Vinod Koulaa9b0452014-06-13 18:03:54 +0530174struct ipc_dsp_hdr {
175 u16 mod_index_id:8; /*!< DSP Command ID specific to tasks */
176 u16 pipe_id:8; /*!< instance of the module in the pipeline */
177 u16 mod_id; /*!< Pipe_id */
178 u16 cmd_id; /*!< Module ID = lpe_algo_types_t */
179 u16 length; /*!< Length of the payload only */
180} __packed;
181
182union ipc_header_high {
183 struct {
184 u32 msg_id:8; /* Message ID - Max 256 Message Types */
185 u32 task_id:4; /* Task ID associated with this comand */
186 u32 drv_id:4; /* Identifier for the driver to track*/
187 u32 rsvd1:8; /* Reserved */
188 u32 result:4; /* Reserved */
189 u32 res_rqd:1; /* Response rqd */
190 u32 large:1; /* Large Message if large = 1 */
191 u32 done:1; /* bit 30 - Done bit */
192 u32 busy:1; /* bit 31 - busy bit*/
193 } part;
194 u32 full;
195} __packed;
196/* IPC header */
197union ipc_header_mrfld {
198 struct {
199 u32 header_low_payload;
200 union ipc_header_high header_high;
201 } p;
202 u64 full;
203} __packed;
204/* CAUTION NOTE: All IPC message body must be multiple of 32 bits.*/
205
206/* IPC Header */
207union ipc_header {
208 struct {
209 u32 msg_id:8; /* Message ID - Max 256 Message Types */
210 u32 str_id:5;
211 u32 large:1; /* Large Message if large = 1 */
212 u32 reserved:2; /* Reserved for future use */
213 u32 data:14; /* Ack/Info for msg, size of msg in Mailbox */
214 u32 done:1; /* bit 30 */
215 u32 busy:1; /* bit 31 */
216 } part;
217 u32 full;
218} __packed;
219
220/* Firmware build info */
221struct sst_fw_build_info {
222 unsigned char date[16]; /* Firmware build date */
223 unsigned char time[16]; /* Firmware build time */
224} __packed;
225
226/* Firmware Version info */
227struct snd_sst_fw_version {
228 u8 build; /* build number*/
229 u8 minor; /* minor number*/
230 u8 major; /* major number*/
231 u8 type; /* build type */
232};
233
234struct ipc_header_fw_init {
235 struct snd_sst_fw_version fw_version;/* Firmware version details */
236 struct sst_fw_build_info build_info;
237 u16 result; /* Fw init result */
238 u8 module_id; /* Module ID in case of error */
239 u8 debug_info; /* Debug info from Module ID in case of fail */
240} __packed;
241
242struct snd_sst_tstamp {
243 u64 ring_buffer_counter; /* PB/CP: Bytes copied from/to DDR. */
244 u64 hardware_counter; /* PB/CP: Bytes DMAed to/from SSP. */
245 u64 frames_decoded;
246 u64 bytes_decoded;
247 u64 bytes_copied;
248 u32 sampling_frequency;
249 u32 channel_peak[8];
250} __packed;
251
252/* Stream type params struture for Alloc stream */
253struct snd_sst_str_type {
254 u8 codec_type; /* Codec type */
255 u8 str_type; /* 1 = voice 2 = music */
256 u8 operation; /* Playback or Capture */
257 u8 protected_str; /* 0=Non DRM, 1=DRM */
258 u8 time_slots;
259 u8 reserved; /* Reserved */
260 u16 result; /* Result used for acknowledgment */
261} __packed;
262
263/* Library info structure */
264struct module_info {
265 u32 lib_version;
266 u32 lib_type;/*TBD- KLOCKWORK u8 lib_type;*/
267 u32 media_type;
268 u8 lib_name[12];
269 u32 lib_caps;
270 unsigned char b_date[16]; /* Lib build date */
271 unsigned char b_time[16]; /* Lib build time */
272} __packed;
273
274/* Library slot info */
275struct lib_slot_info {
276 u8 slot_num; /* 1 or 2 */
277 u8 reserved1;
278 u16 reserved2;
279 u32 iram_size; /* slot size in IRAM */
280 u32 dram_size; /* slot size in DRAM */
281 u32 iram_offset; /* starting offset of slot in IRAM */
282 u32 dram_offset; /* starting offset of slot in DRAM */
283} __packed;
284
285struct snd_ppp_mixer_params {
286 __u32 type; /*Type of the parameter */
287 __u32 size;
288 __u32 input_stream_bitmap; /*Input stream Bit Map*/
289} __packed;
290
291struct snd_sst_lib_download {
292 struct module_info lib_info; /* library info type, capabilities etc */
293 struct lib_slot_info slot_info; /* slot info to be downloaded */
294 u32 mod_entry_pt;
295};
296
297struct snd_sst_lib_download_info {
298 struct snd_sst_lib_download dload_lib;
299 u16 result; /* Result used for acknowledgment */
300 u8 pvt_id; /* Private ID */
301 u8 reserved; /* for alignment */
302};
Vinod Koulc514a912012-08-16 17:10:42 +0530303struct snd_pcm_params {
Vinod Koulc514a912012-08-16 17:10:42 +0530304 u8 num_chan; /* 1=Mono, 2=Stereo */
305 u8 pcm_wd_sz; /* 16/24 - bit*/
Vinod Koulaa9b0452014-06-13 18:03:54 +0530306 u8 use_offload_path; /* 0-PCM using period elpased & ALSA interfaces
307 1-PCM stream via compressed interface */
Vinod Koulc514a912012-08-16 17:10:42 +0530308 u8 reserved2;
Vinod Koulaa9b0452014-06-13 18:03:54 +0530309 u32 sfreq; /* Sampling rate in Hz */
Vinod Koulc514a912012-08-16 17:10:42 +0530310 u8 channel_map[8];
311} __packed;
312
313/* MP3 Music Parameters Message */
314struct snd_mp3_params {
Vinod Koulc514a912012-08-16 17:10:42 +0530315 u8 num_chan; /* 1=Mono, 2=Stereo */
316 u8 pcm_wd_sz; /* 16/24 - bit*/
317 u8 crc_check; /* crc_check - disable (0) or enable (1) */
318 u8 reserved1; /* unused*/
319 u16 reserved2; /* Unused */
320} __packed;
321
322#define AAC_BIT_STREAM_ADTS 0
323#define AAC_BIT_STREAM_ADIF 1
324#define AAC_BIT_STREAM_RAW 2
325
326/* AAC Music Parameters Message */
327struct snd_aac_params {
Vinod Koulc514a912012-08-16 17:10:42 +0530328 u8 num_chan; /* 1=Mono, 2=Stereo*/
329 u8 pcm_wd_sz; /* 16/24 - bit*/
330 u8 bdownsample; /*SBR downsampling 0 - disable 1 -enabled AAC+ only */
331 u8 bs_format; /* input bit stream format adts=0, adif=1, raw=2 */
332 u16 reser2;
333 u32 externalsr; /*sampling rate of basic AAC raw bit stream*/
334 u8 sbr_signalling;/*disable/enable/set automode the SBR tool.AAC+*/
335 u8 reser1;
336 u16 reser3;
337} __packed;
338
339/* WMA Music Parameters Message */
340struct snd_wma_params {
Vinod Koulc514a912012-08-16 17:10:42 +0530341 u8 num_chan; /* 1=Mono, 2=Stereo */
342 u8 pcm_wd_sz; /* 16/24 - bit*/
Vinod Koulaa9b0452014-06-13 18:03:54 +0530343 u16 reserved1;
Vinod Koulc514a912012-08-16 17:10:42 +0530344 u32 brate; /* Use the hard coded value. */
345 u32 sfreq; /* Sampling freq eg. 8000, 441000, 48000 */
346 u32 channel_mask; /* Channel Mask */
347 u16 format_tag; /* Format Tag */
348 u16 block_align; /* packet size */
349 u16 wma_encode_opt;/* Encoder option */
350 u8 op_align; /* op align 0- 16 bit, 1- MSB, 2 LSB */
351 u8 reserved; /* reserved */
352} __packed;
353
354/* Codec params struture */
355union snd_sst_codec_params {
356 struct snd_pcm_params pcm_params;
357 struct snd_mp3_params mp3_params;
358 struct snd_aac_params aac_params;
359 struct snd_wma_params wma_params;
360} __packed;
361
362/* Address and size info of a frame buffer */
363struct sst_address_info {
364 u32 addr; /* Address at IA */
365 u32 size; /* Size of the buffer */
366};
367
368struct snd_sst_alloc_params_ext {
Vinod Koulaa9b0452014-06-13 18:03:54 +0530369 __u16 sg_count;
370 __u16 reserved;
371 __u32 frag_size; /*Number of samples after which period elapsed
Vinod Koulc514a912012-08-16 17:10:42 +0530372 message is sent valid only if path = 0*/
Vinod Koulaa9b0452014-06-13 18:03:54 +0530373 struct sst_address_info ring_buf_info[8];
374};
Vinod Koulc514a912012-08-16 17:10:42 +0530375
376struct snd_sst_stream_params {
377 union snd_sst_codec_params uc;
378} __packed;
379
380struct snd_sst_params {
Vinod Koulaa9b0452014-06-13 18:03:54 +0530381 u32 result;
Vinod Koulc514a912012-08-16 17:10:42 +0530382 u32 stream_id;
383 u8 codec;
384 u8 ops;
385 u8 stream_type;
386 u8 device_type;
Vinod Koulaa9b0452014-06-13 18:03:54 +0530387 u8 task;
Vinod Koulc514a912012-08-16 17:10:42 +0530388 struct snd_sst_stream_params sparams;
389 struct snd_sst_alloc_params_ext aparams;
390};
391
Vinod Koulaa9b0452014-06-13 18:03:54 +0530392struct snd_sst_alloc_mrfld {
393 u16 codec_type;
394 u8 operation;
395 u8 sg_count;
396 struct sst_address_info ring_buf_info[8];
397 u32 frag_size;
398 u32 ts;
399 struct snd_sst_stream_params codec_params;
400} __packed;
401
402/* Alloc stream params structure */
403struct snd_sst_alloc_params {
404 struct snd_sst_str_type str_type;
405 struct snd_sst_stream_params stream_params;
406 struct snd_sst_alloc_params_ext alloc_params;
407} __packed;
408
409/* Alloc stream response message */
410struct snd_sst_alloc_response {
411 struct snd_sst_str_type str_type; /* Stream type for allocation */
412 struct snd_sst_lib_download lib_dnld; /* Valid only for codec dnld */
413};
414
415/* Drop response */
416struct snd_sst_drop_response {
417 u32 result;
418 u32 bytes;
419};
420
421struct snd_sst_async_msg {
422 u32 msg_id; /* Async msg id */
423 u32 payload[0];
424};
425
426struct snd_sst_async_err_msg {
427 u32 fw_resp; /* Firmware Result */
428 u32 lib_resp; /*Library result */
429} __packed;
430
431struct snd_sst_vol {
432 u32 stream_id;
433 s32 volume;
434 u32 ramp_duration;
435 u32 ramp_type; /* Ramp type, default=0 */
436};
437
438/* Gain library parameters for mrfld
439 * based on DSP command spec v0.82
440 */
441struct snd_sst_gain_v2 {
442 u16 gain_cell_num; /* num of gain cells to modify*/
443 u8 cell_nbr_idx; /* instance index*/
444 u8 cell_path_idx; /* pipe-id */
445 u16 module_id; /*module id */
446 u16 left_cell_gain; /* left gain value in dB*/
447 u16 right_cell_gain; /* right gain value in dB*/
448 u16 gain_time_const; /* gain time constant*/
449} __packed;
450
451struct snd_sst_mute {
452 u32 stream_id;
453 u32 mute;
454};
455
456struct snd_sst_runtime_params {
457 u8 type;
458 u8 str_id;
459 u8 size;
460 u8 rsvd;
461 void *addr;
462} __packed;
463
464enum stream_param_type {
465 SST_SET_TIME_SLOT = 0,
466 SST_SET_CHANNEL_INFO = 1,
467 OTHERS = 2, /*reserved for future params*/
468};
469
470/* CSV Voice call routing structure */
471struct snd_sst_control_routing {
472 u8 control; /* 0=start, 1=Stop */
473 u8 reserved[3]; /* Reserved- for 32 bit alignment */
474};
475
476struct ipc_post {
477 struct list_head node;
478 union ipc_header header; /* driver specific */
479 bool is_large;
480 bool is_process_reply;
481 union ipc_header_mrfld mrfld_header;
482 char *mailbox_data;
483};
484
485struct snd_sst_ctxt_params {
486 u32 address; /* Physical Address in DDR where the context is stored */
487 u32 size; /* size of the context */
488};
489
490struct snd_sst_lpe_log_params {
491 u8 dbg_type;
492 u8 module_id;
493 u8 log_level;
494 u8 reserved;
495} __packed;
496
497enum snd_sst_bytes_type {
498 SND_SST_BYTES_SET = 0x1,
499 SND_SST_BYTES_GET = 0x2,
500};
501
502struct snd_sst_bytes_v2 {
503 u8 type;
504 u8 ipc_msg;
505 u8 block;
506 u8 task_id;
507 u8 pipe_id;
508 u8 rsvd;
509 u16 len;
510 char bytes[0];
511};
512
513#define MAX_VTSV_FILES 2
514struct snd_sst_vtsv_info {
515 struct sst_address_info vfiles[MAX_VTSV_FILES];
516} __packed;
517
Mark Browna4b12992014-03-12 23:04:35 +0000518#endif /* __SST_MFLD_DSP_H__ */