1 #ifndef __SST_MFLD_DSP_H__
2 #define __SST_MFLD_DSP_H__
4 * sst_mfld_dsp.h - Intel SST Driver for audio engine
6 * Copyright (C) 2008-14 Intel Corporation
7 * Authors: Vinod Koul <vinod.koul@linux.intel.com>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
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.
19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 #define SST_MAX_BIN_BYTES 1024
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
38 /* Message ID's for IPC messages */
39 /* Bits B7: SST or IA/SC ; B6-B4: Msg Category; B3-B0: Msg Type */
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
63 #define IPC_EFFECTS_CREATE 0xE
64 #define IPC_EFFECTS_DESTROY 0xF
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
86 #define IPC_IA_START_STREAM_MRFLD 0X06
87 #define IPC_IA_START_STREAM 0x30 /* Short msg with str_id */
89 #define IPC_IA_SET_GAIN_MRFLD 0x21
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
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
102 /* L2I Codec Config/control msgs */
103 #define IPC_SST_FRAGMENT_ELPASED 0x90 /* Request IA more data */
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 */
112 #define IPC_SST_ERROR_EVENT 0x99 /* Buffer over run occurred */
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
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
126 #define IPC_IA_PRINT_STRING 0xF0
128 /* Buffer under-run */
129 #define IPC_IA_BUF_UNDER_RUN_MRFLD 0x0B
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.
139 #define SST_ASYNC_DRV_ID 0
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
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 */
158 enum sst_codec_types
{
159 /* AUDIO/MUSIC CODEC Type Definitions */
160 SST_CODEC_TYPE_UNKNOWN
= 0,
161 SST_CODEC_TYPE_PCM
, /* Pass through Audio codec */
166 SST_CODEC_TYPE_eAACP
,
170 SST_STREAM_TYPE_NONE
= 0,
171 SST_STREAM_TYPE_MUSIC
= 1,
174 enum sst_error_codes
{
175 /* Error code,response to msgId: Description */
176 /* Common error codes */
177 SST_SUCCESS
= 0, /* Success */
178 SST_ERR_INVALID_STREAM_ID
= 1,
179 SST_ERR_INVALID_MSG_ID
= 2,
180 SST_ERR_INVALID_STREAM_OP
= 3,
181 SST_ERR_INVALID_PARAMS
= 4,
182 SST_ERR_INVALID_CODEC
= 5,
183 SST_ERR_INVALID_MEDIA_TYPE
= 6,
184 SST_ERR_STREAM_ERR
= 7,
186 SST_ERR_STREAM_IN_USE
= 15,
190 u16 mod_index_id
:8; /*!< DSP Command ID specific to tasks */
191 u16 pipe_id
:8; /*!< instance of the module in the pipeline */
192 u16 mod_id
; /*!< Pipe_id */
193 u16 cmd_id
; /*!< Module ID = lpe_algo_types_t */
194 u16 length
; /*!< Length of the payload only */
197 union ipc_header_high
{
199 u32 msg_id
:8; /* Message ID - Max 256 Message Types */
200 u32 task_id
:4; /* Task ID associated with this comand */
201 u32 drv_id
:4; /* Identifier for the driver to track*/
202 u32 rsvd1
:8; /* Reserved */
203 u32 result
:4; /* Reserved */
204 u32 res_rqd
:1; /* Response rqd */
205 u32 large
:1; /* Large Message if large = 1 */
206 u32 done
:1; /* bit 30 - Done bit */
207 u32 busy
:1; /* bit 31 - busy bit*/
212 union ipc_header_mrfld
{
214 u32 header_low_payload
;
215 union ipc_header_high header_high
;
219 /* CAUTION NOTE: All IPC message body must be multiple of 32 bits.*/
224 u32 msg_id
:8; /* Message ID - Max 256 Message Types */
226 u32 large
:1; /* Large Message if large = 1 */
227 u32 reserved
:2; /* Reserved for future use */
228 u32 data
:14; /* Ack/Info for msg, size of msg in Mailbox */
229 u32 done
:1; /* bit 30 */
230 u32 busy
:1; /* bit 31 */
235 /* Firmware build info */
236 struct sst_fw_build_info
{
237 unsigned char date
[16]; /* Firmware build date */
238 unsigned char time
[16]; /* Firmware build time */
241 /* Firmware Version info */
242 struct snd_sst_fw_version
{
243 u8 build
; /* build number*/
244 u8 minor
; /* minor number*/
245 u8 major
; /* major number*/
246 u8 type
; /* build type */
249 struct ipc_header_fw_init
{
250 struct snd_sst_fw_version fw_version
;/* Firmware version details */
251 struct sst_fw_build_info build_info
;
252 u16 result
; /* Fw init result */
253 u8 module_id
; /* Module ID in case of error */
254 u8 debug_info
; /* Debug info from Module ID in case of fail */
257 struct snd_sst_tstamp
{
258 u64 ring_buffer_counter
; /* PB/CP: Bytes copied from/to DDR. */
259 u64 hardware_counter
; /* PB/CP: Bytes DMAed to/from SSP. */
263 u32 sampling_frequency
;
267 /* Stream type params struture for Alloc stream */
268 struct snd_sst_str_type
{
269 u8 codec_type
; /* Codec type */
270 u8 str_type
; /* 1 = voice 2 = music */
271 u8 operation
; /* Playback or Capture */
272 u8 protected_str
; /* 0=Non DRM, 1=DRM */
274 u8 reserved
; /* Reserved */
275 u16 result
; /* Result used for acknowledgment */
278 /* Library info structure */
281 u32 lib_type
;/*TBD- KLOCKWORK u8 lib_type;*/
285 unsigned char b_date
[16]; /* Lib build date */
286 unsigned char b_time
[16]; /* Lib build time */
289 /* Library slot info */
290 struct lib_slot_info
{
291 u8 slot_num
; /* 1 or 2 */
294 u32 iram_size
; /* slot size in IRAM */
295 u32 dram_size
; /* slot size in DRAM */
296 u32 iram_offset
; /* starting offset of slot in IRAM */
297 u32 dram_offset
; /* starting offset of slot in DRAM */
300 struct snd_ppp_mixer_params
{
301 __u32 type
; /*Type of the parameter */
303 __u32 input_stream_bitmap
; /*Input stream Bit Map*/
306 struct snd_sst_lib_download
{
307 struct module_info lib_info
; /* library info type, capabilities etc */
308 struct lib_slot_info slot_info
; /* slot info to be downloaded */
312 struct snd_sst_lib_download_info
{
313 struct snd_sst_lib_download dload_lib
;
314 u16 result
; /* Result used for acknowledgment */
315 u8 pvt_id
; /* Private ID */
316 u8 reserved
; /* for alignment */
318 struct snd_pcm_params
{
319 u8 num_chan
; /* 1=Mono, 2=Stereo */
320 u8 pcm_wd_sz
; /* 16/24 - bit*/
321 u8 use_offload_path
; /* 0-PCM using period elpased & ALSA interfaces
322 1-PCM stream via compressed interface */
324 u32 sfreq
; /* Sampling rate in Hz */
328 /* MP3 Music Parameters Message */
329 struct snd_mp3_params
{
330 u8 num_chan
; /* 1=Mono, 2=Stereo */
331 u8 pcm_wd_sz
; /* 16/24 - bit*/
332 u8 crc_check
; /* crc_check - disable (0) or enable (1) */
333 u8 reserved1
; /* unused*/
334 u16 reserved2
; /* Unused */
337 #define AAC_BIT_STREAM_ADTS 0
338 #define AAC_BIT_STREAM_ADIF 1
339 #define AAC_BIT_STREAM_RAW 2
341 /* AAC Music Parameters Message */
342 struct snd_aac_params
{
343 u8 num_chan
; /* 1=Mono, 2=Stereo*/
344 u8 pcm_wd_sz
; /* 16/24 - bit*/
345 u8 bdownsample
; /*SBR downsampling 0 - disable 1 -enabled AAC+ only */
346 u8 bs_format
; /* input bit stream format adts=0, adif=1, raw=2 */
348 u32 externalsr
; /*sampling rate of basic AAC raw bit stream*/
349 u8 sbr_signalling
;/*disable/enable/set automode the SBR tool.AAC+*/
354 /* WMA Music Parameters Message */
355 struct snd_wma_params
{
356 u8 num_chan
; /* 1=Mono, 2=Stereo */
357 u8 pcm_wd_sz
; /* 16/24 - bit*/
359 u32 brate
; /* Use the hard coded value. */
360 u32 sfreq
; /* Sampling freq eg. 8000, 441000, 48000 */
361 u32 channel_mask
; /* Channel Mask */
362 u16 format_tag
; /* Format Tag */
363 u16 block_align
; /* packet size */
364 u16 wma_encode_opt
;/* Encoder option */
365 u8 op_align
; /* op align 0- 16 bit, 1- MSB, 2 LSB */
366 u8 reserved
; /* reserved */
369 /* Codec params struture */
370 union snd_sst_codec_params
{
371 struct snd_pcm_params pcm_params
;
372 struct snd_mp3_params mp3_params
;
373 struct snd_aac_params aac_params
;
374 struct snd_wma_params wma_params
;
377 /* Address and size info of a frame buffer */
378 struct sst_address_info
{
379 u32 addr
; /* Address at IA */
380 u32 size
; /* Size of the buffer */
383 struct snd_sst_alloc_params_ext
{
386 __u32 frag_size
; /*Number of samples after which period elapsed
387 message is sent valid only if path = 0*/
388 struct sst_address_info ring_buf_info
[8];
391 struct snd_sst_stream_params
{
392 union snd_sst_codec_params uc
;
395 struct snd_sst_params
{
403 struct snd_sst_stream_params sparams
;
404 struct snd_sst_alloc_params_ext aparams
;
407 struct snd_sst_alloc_mrfld
{
411 struct sst_address_info ring_buf_info
[8];
414 struct snd_sst_stream_params codec_params
;
417 /* Alloc stream params structure */
418 struct snd_sst_alloc_params
{
419 struct snd_sst_str_type str_type
;
420 struct snd_sst_stream_params stream_params
;
421 struct snd_sst_alloc_params_ext alloc_params
;
424 /* Alloc stream response message */
425 struct snd_sst_alloc_response
{
426 struct snd_sst_str_type str_type
; /* Stream type for allocation */
427 struct snd_sst_lib_download lib_dnld
; /* Valid only for codec dnld */
431 struct snd_sst_drop_response
{
436 struct snd_sst_async_msg
{
437 u32 msg_id
; /* Async msg id */
441 struct snd_sst_async_err_msg
{
442 u32 fw_resp
; /* Firmware Result */
443 u32 lib_resp
; /*Library result */
450 u32 ramp_type
; /* Ramp type, default=0 */
453 /* Gain library parameters for mrfld
454 * based on DSP command spec v0.82
456 struct snd_sst_gain_v2
{
457 u16 gain_cell_num
; /* num of gain cells to modify*/
458 u8 cell_nbr_idx
; /* instance index*/
459 u8 cell_path_idx
; /* pipe-id */
460 u16 module_id
; /*module id */
461 u16 left_cell_gain
; /* left gain value in dB*/
462 u16 right_cell_gain
; /* right gain value in dB*/
463 u16 gain_time_const
; /* gain time constant*/
466 struct snd_sst_mute
{
471 struct snd_sst_runtime_params
{
479 enum stream_param_type
{
480 SST_SET_TIME_SLOT
= 0,
481 SST_SET_CHANNEL_INFO
= 1,
482 OTHERS
= 2, /*reserved for future params*/
485 /* CSV Voice call routing structure */
486 struct snd_sst_control_routing
{
487 u8 control
; /* 0=start, 1=Stop */
488 u8 reserved
[3]; /* Reserved- for 32 bit alignment */
492 struct list_head node
;
493 union ipc_header header
; /* driver specific */
495 bool is_process_reply
;
496 union ipc_header_mrfld mrfld_header
;
500 struct snd_sst_ctxt_params
{
501 u32 address
; /* Physical Address in DDR where the context is stored */
502 u32 size
; /* size of the context */
505 struct snd_sst_lpe_log_params
{
512 enum snd_sst_bytes_type
{
513 SND_SST_BYTES_SET
= 0x1,
514 SND_SST_BYTES_GET
= 0x2,
517 struct snd_sst_bytes_v2
{
528 #define MAX_VTSV_FILES 2
529 struct snd_sst_vtsv_info
{
530 struct sst_address_info vfiles
[MAX_VTSV_FILES
];
533 #endif /* __SST_MFLD_DSP_H__ */