1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef __SST_MFLD_DSP_H__
3 #define __SST_MFLD_DSP_H__
5 * sst_mfld_dsp.h - Intel SST Driver for audio engine
7 * Copyright (C) 2008-14 Intel Corporation
8 * Authors: Vinod Koul <vinod.koul@linux.intel.com>
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14 #define SST_MAX_BIN_BYTES 1024
16 #define MAX_DBG_RW_BYTES 80
17 #define MAX_NUM_SCATTER_BUFFERS 8
18 #define MAX_LOOP_BACK_DWORDS 8
19 /* IPC base address and mailbox, timestamp offsets */
20 #define SST_MAILBOX_SIZE 0x0400
21 #define SST_MAILBOX_SEND 0x0000
22 #define SST_TIME_STAMP 0x1800
23 #define SST_TIME_STAMP_MRFLD 0x800
24 #define SST_RESERVED_OFFSET 0x1A00
25 #define SST_SCU_LPE_MAILBOX 0x1000
26 #define SST_LPE_SCU_MAILBOX 0x1400
27 #define SST_SCU_LPE_LOG_BUF (SST_SCU_LPE_MAILBOX+16)
28 #define PROCESS_MSG 0x80
30 /* Message ID's for IPC messages */
31 /* Bits B7: SST or IA/SC ; B6-B4: Msg Category; B3-B0: Msg Type */
33 /* I2L Firmware/Codec Download msgs */
34 #define IPC_IA_PREP_LIB_DNLD 0x01
35 #define IPC_IA_LIB_DNLD_CMPLT 0x02
36 #define IPC_IA_GET_FW_VERSION 0x04
37 #define IPC_IA_GET_FW_BUILD_INF 0x05
38 #define IPC_IA_GET_FW_INFO 0x06
39 #define IPC_IA_GET_FW_CTXT 0x07
40 #define IPC_IA_SET_FW_CTXT 0x08
41 #define IPC_IA_PREPARE_SHUTDOWN 0x31
42 /* I2L Codec Config/control msgs */
43 #define IPC_PREP_D3 0x10
44 #define IPC_IA_SET_CODEC_PARAMS 0x10
45 #define IPC_IA_GET_CODEC_PARAMS 0x11
46 #define IPC_IA_SET_PPP_PARAMS 0x12
47 #define IPC_IA_GET_PPP_PARAMS 0x13
48 #define IPC_SST_PERIOD_ELAPSED_MRFLD 0xA
49 #define IPC_IA_ALG_PARAMS 0x1A
50 #define IPC_IA_TUNING_PARAMS 0x1B
51 #define IPC_IA_SET_RUNTIME_PARAMS 0x1C
52 #define IPC_IA_SET_PARAMS 0x1
53 #define IPC_IA_GET_PARAMS 0x2
55 #define IPC_EFFECTS_CREATE 0xE
56 #define IPC_EFFECTS_DESTROY 0xF
58 /* I2L Stream config/control msgs */
59 #define IPC_IA_ALLOC_STREAM_MRFLD 0x2
60 #define IPC_IA_ALLOC_STREAM 0x20 /* Allocate a stream ID */
61 #define IPC_IA_FREE_STREAM_MRFLD 0x03
62 #define IPC_IA_FREE_STREAM 0x21 /* Free the stream ID */
63 #define IPC_IA_SET_STREAM_PARAMS 0x22
64 #define IPC_IA_SET_STREAM_PARAMS_MRFLD 0x12
65 #define IPC_IA_GET_STREAM_PARAMS 0x23
66 #define IPC_IA_PAUSE_STREAM 0x24
67 #define IPC_IA_PAUSE_STREAM_MRFLD 0x4
68 #define IPC_IA_RESUME_STREAM 0x25
69 #define IPC_IA_RESUME_STREAM_MRFLD 0x5
70 #define IPC_IA_DROP_STREAM 0x26
71 #define IPC_IA_DROP_STREAM_MRFLD 0x07
72 #define IPC_IA_DRAIN_STREAM 0x27 /* Short msg with str_id */
73 #define IPC_IA_DRAIN_STREAM_MRFLD 0x8
74 #define IPC_IA_CONTROL_ROUTING 0x29
75 #define IPC_IA_VTSV_UPDATE_MODULES 0x20
76 #define IPC_IA_VTSV_DETECTED 0x21
78 #define IPC_IA_START_STREAM_MRFLD 0X06
79 #define IPC_IA_START_STREAM 0x30 /* Short msg with str_id */
81 #define IPC_IA_SET_GAIN_MRFLD 0x21
83 #define IPC_IA_DBG_MEM_READ 0x40
84 #define IPC_IA_DBG_MEM_WRITE 0x41
85 #define IPC_IA_DBG_LOOP_BACK 0x42
86 #define IPC_IA_DBG_LOG_ENABLE 0x45
87 #define IPC_IA_DBG_SET_PROBE_PARAMS 0x47
89 /* L2I Firmware/Codec Download msgs */
90 #define IPC_IA_FW_INIT_CMPLT 0x81
91 #define IPC_IA_FW_INIT_CMPLT_MRFLD 0x01
92 #define IPC_IA_FW_ASYNC_ERR_MRFLD 0x11
94 /* L2I Codec Config/control msgs */
95 #define IPC_SST_FRAGMENT_ELPASED 0x90 /* Request IA more data */
97 #define IPC_SST_BUF_UNDER_RUN 0x92 /* PB Under run and stopped */
98 #define IPC_SST_BUF_OVER_RUN 0x93 /* CAP Under run and stopped */
99 #define IPC_SST_DRAIN_END 0x94 /* PB Drain complete and stopped */
100 #define IPC_SST_CHNGE_SSP_PARAMS 0x95 /* PB SSP parameters changed */
101 #define IPC_SST_STREAM_PROCESS_FATAL_ERR 0x96/* error in processing a stream */
102 #define IPC_SST_PERIOD_ELAPSED 0x97 /* period elapsed */
104 #define IPC_SST_ERROR_EVENT 0x99 /* Buffer over run occurred */
106 #define IPC_SC_DDR_LINK_UP 0xC0
107 #define IPC_SC_DDR_LINK_DOWN 0xC1
108 #define IPC_SC_SET_LPECLK_REQ 0xC2
109 #define IPC_SC_SSP_BIT_BANG 0xC3
111 /* L2I Error reporting msgs */
112 #define IPC_IA_MEM_ALLOC_FAIL 0xE0
113 #define IPC_IA_PROC_ERR 0xE1 /* error in processing a
114 stream can be used by playback and
118 #define IPC_IA_PRINT_STRING 0xF0
120 /* Buffer under-run */
121 #define IPC_IA_BUF_UNDER_RUN_MRFLD 0x0B
123 /* Mrfld specific defines:
124 * For asynchronous messages(INIT_CMPLT, PERIOD_ELAPSED, ASYNC_ERROR)
125 * received from FW, the format is:
126 * - IPC High: pvt_id is set to zero. Always short message.
127 * - msg_id is in lower 16-bits of IPC low payload.
128 * - pipe_id is in higher 16-bits of IPC low payload for period_elapsed.
129 * - error id is in higher 16-bits of IPC low payload for async errors.
131 #define SST_ASYNC_DRV_ID 0
133 /* Command Response or Acknowledge message to any IPC message will have
134 * same message ID and stream ID information which is sent.
135 * There is no specific Ack message ID. The data field is used as response
144 IPC_CMD = 1, /*!< Task Control message ID */
145 IPC_SET_PARAMS = 2,/*!< Task Set param message ID */
146 IPC_GET_PARAMS = 3, /*!< Task Get param message ID */
147 IPC_INVALID = 0xFF, /*!<Task Get param message ID */
150 enum sst_codec_types {
151 /* AUDIO/MUSIC CODEC Type Definitions */
152 SST_CODEC_TYPE_UNKNOWN = 0,
153 SST_CODEC_TYPE_PCM, /* Pass through Audio codec */
158 SST_CODEC_TYPE_eAACP,
162 SST_STREAM_TYPE_NONE = 0,
163 SST_STREAM_TYPE_MUSIC = 1,
166 enum sst_error_codes {
167 /* Error code,response to msgId: Description */
168 /* Common error codes */
169 SST_SUCCESS = 0, /* Success */
170 SST_ERR_INVALID_STREAM_ID = 1,
171 SST_ERR_INVALID_MSG_ID = 2,
172 SST_ERR_INVALID_STREAM_OP = 3,
173 SST_ERR_INVALID_PARAMS = 4,
174 SST_ERR_INVALID_CODEC = 5,
175 SST_ERR_INVALID_MEDIA_TYPE = 6,
176 SST_ERR_STREAM_ERR = 7,
178 SST_ERR_STREAM_IN_USE = 15,
182 u16 mod_index_id:8; /*!< DSP Command ID specific to tasks */
183 u16 pipe_id:8; /*!< instance of the module in the pipeline */
184 u16 mod_id; /*!< Pipe_id */
185 u16 cmd_id; /*!< Module ID = lpe_algo_types_t */
186 u16 length; /*!< Length of the payload only */
189 union ipc_header_high {
191 u32 msg_id:8; /* Message ID - Max 256 Message Types */
192 u32 task_id:4; /* Task ID associated with this comand */
193 u32 drv_id:4; /* Identifier for the driver to track*/
194 u32 rsvd1:8; /* Reserved */
195 u32 result:4; /* Reserved */
196 u32 res_rqd:1; /* Response rqd */
197 u32 large:1; /* Large Message if large = 1 */
198 u32 done:1; /* bit 30 - Done bit */
199 u32 busy:1; /* bit 31 - busy bit*/
204 union ipc_header_mrfld {
206 u32 header_low_payload;
207 union ipc_header_high header_high;
211 /* CAUTION NOTE: All IPC message body must be multiple of 32 bits.*/
216 u32 msg_id:8; /* Message ID - Max 256 Message Types */
218 u32 large:1; /* Large Message if large = 1 */
219 u32 reserved:2; /* Reserved for future use */
220 u32 data:14; /* Ack/Info for msg, size of msg in Mailbox */
221 u32 done:1; /* bit 30 */
222 u32 busy:1; /* bit 31 */
227 /* Firmware build info */
228 struct sst_fw_build_info {
229 unsigned char date[16]; /* Firmware build date */
230 unsigned char time[16]; /* Firmware build time */
233 /* Firmware Version info */
234 struct snd_sst_fw_version {
235 u8 build; /* build number*/
236 u8 minor; /* minor number*/
237 u8 major; /* major number*/
238 u8 type; /* build type */
241 struct ipc_header_fw_init {
242 struct snd_sst_fw_version fw_version;/* Firmware version details */
243 struct sst_fw_build_info build_info;
244 u16 result; /* Fw init result */
245 u8 module_id; /* Module ID in case of error */
246 u8 debug_info; /* Debug info from Module ID in case of fail */
249 struct snd_sst_tstamp {
250 u64 ring_buffer_counter; /* PB/CP: Bytes copied from/to DDR. */
251 u64 hardware_counter; /* PB/CP: Bytes DMAed to/from SSP. */
255 u32 sampling_frequency;
259 /* Stream type params structure for Alloc stream */
260 struct snd_sst_str_type {
261 u8 codec_type; /* Codec type */
262 u8 str_type; /* 1 = voice 2 = music */
263 u8 operation; /* Playback or Capture */
264 u8 protected_str; /* 0=Non DRM, 1=DRM */
266 u8 reserved; /* Reserved */
267 u16 result; /* Result used for acknowledgment */
270 /* Library info structure */
273 u32 lib_type;/*TBD- KLOCKWORK u8 lib_type;*/
277 unsigned char b_date[16]; /* Lib build date */
278 unsigned char b_time[16]; /* Lib build time */
281 /* Library slot info */
282 struct lib_slot_info {
283 u8 slot_num; /* 1 or 2 */
286 u32 iram_size; /* slot size in IRAM */
287 u32 dram_size; /* slot size in DRAM */
288 u32 iram_offset; /* starting offset of slot in IRAM */
289 u32 dram_offset; /* starting offset of slot in DRAM */
292 struct snd_ppp_mixer_params {
293 __u32 type; /*Type of the parameter */
295 __u32 input_stream_bitmap; /*Input stream Bit Map*/
298 struct snd_sst_lib_download {
299 struct module_info lib_info; /* library info type, capabilities etc */
300 struct lib_slot_info slot_info; /* slot info to be downloaded */
304 struct snd_sst_lib_download_info {
305 struct snd_sst_lib_download dload_lib;
306 u16 result; /* Result used for acknowledgment */
307 u8 pvt_id; /* Private ID */
308 u8 reserved; /* for alignment */
310 struct snd_pcm_params {
311 u8 num_chan; /* 1=Mono, 2=Stereo */
312 u8 pcm_wd_sz; /* 16/24 - bit*/
313 u8 use_offload_path; /* 0-PCM using period elpased & ALSA interfaces
314 1-PCM stream via compressed interface */
316 u32 sfreq; /* Sampling rate in Hz */
320 /* MP3 Music Parameters Message */
321 struct snd_mp3_params {
322 u8 num_chan; /* 1=Mono, 2=Stereo */
323 u8 pcm_wd_sz; /* 16/24 - bit*/
324 u8 crc_check; /* crc_check - disable (0) or enable (1) */
325 u8 reserved1; /* unused*/
326 u16 reserved2; /* Unused */
329 #define AAC_BIT_STREAM_ADTS 0
330 #define AAC_BIT_STREAM_ADIF 1
331 #define AAC_BIT_STREAM_RAW 2
333 /* AAC Music Parameters Message */
334 struct snd_aac_params {
335 u8 num_chan; /* 1=Mono, 2=Stereo*/
336 u8 pcm_wd_sz; /* 16/24 - bit*/
337 u8 bdownsample; /*SBR downsampling 0 - disable 1 -enabled AAC+ only */
338 u8 bs_format; /* input bit stream format adts=0, adif=1, raw=2 */
340 u32 externalsr; /*sampling rate of basic AAC raw bit stream*/
341 u8 sbr_signalling;/*disable/enable/set automode the SBR tool.AAC+*/
346 /* WMA Music Parameters Message */
347 struct snd_wma_params {
348 u8 num_chan; /* 1=Mono, 2=Stereo */
349 u8 pcm_wd_sz; /* 16/24 - bit*/
351 u32 brate; /* Use the hard coded value. */
352 u32 sfreq; /* Sampling freq eg. 8000, 441000, 48000 */
353 u32 channel_mask; /* Channel Mask */
354 u16 format_tag; /* Format Tag */
355 u16 block_align; /* packet size */
356 u16 wma_encode_opt;/* Encoder option */
357 u8 op_align; /* op align 0- 16 bit, 1- MSB, 2 LSB */
358 u8 reserved; /* reserved */
361 /* Codec params structure */
362 union snd_sst_codec_params {
363 struct snd_pcm_params pcm_params;
364 struct snd_mp3_params mp3_params;
365 struct snd_aac_params aac_params;
366 struct snd_wma_params wma_params;
369 /* Address and size info of a frame buffer */
370 struct sst_address_info {
371 u32 addr; /* Address at IA */
372 u32 size; /* Size of the buffer */
375 struct snd_sst_alloc_params_ext {
378 __u32 frag_size; /*Number of samples after which period elapsed
379 message is sent valid only if path = 0*/
380 struct sst_address_info ring_buf_info[8];
383 struct snd_sst_stream_params {
384 union snd_sst_codec_params uc;
387 struct snd_sst_params {
395 struct snd_sst_stream_params sparams;
396 struct snd_sst_alloc_params_ext aparams;
399 struct snd_sst_alloc_mrfld {
403 struct sst_address_info ring_buf_info[8];
406 struct snd_sst_stream_params codec_params;
409 /* Alloc stream params structure */
410 struct snd_sst_alloc_params {
411 struct snd_sst_str_type str_type;
412 struct snd_sst_stream_params stream_params;
413 struct snd_sst_alloc_params_ext alloc_params;
416 /* Alloc stream response message */
417 struct snd_sst_alloc_response {
418 struct snd_sst_str_type str_type; /* Stream type for allocation */
419 struct snd_sst_lib_download lib_dnld; /* Valid only for codec dnld */
423 struct snd_sst_drop_response {
428 struct snd_sst_async_msg {
429 u32 msg_id; /* Async msg id */
433 struct snd_sst_async_err_msg {
434 u32 fw_resp; /* Firmware Result */
435 u32 lib_resp; /*Library result */
442 u32 ramp_type; /* Ramp type, default=0 */
445 /* Gain library parameters for mrfld
446 * based on DSP command spec v0.82
448 struct snd_sst_gain_v2 {
449 u16 gain_cell_num; /* num of gain cells to modify*/
450 u8 cell_nbr_idx; /* instance index*/
451 u8 cell_path_idx; /* pipe-id */
452 u16 module_id; /*module id */
453 u16 left_cell_gain; /* left gain value in dB*/
454 u16 right_cell_gain; /* right gain value in dB*/
455 u16 gain_time_const; /* gain time constant*/
458 struct snd_sst_mute {
463 struct snd_sst_runtime_params {
471 enum stream_param_type {
472 SST_SET_TIME_SLOT = 0,
473 SST_SET_CHANNEL_INFO = 1,
474 OTHERS = 2, /*reserved for future params*/
477 /* CSV Voice call routing structure */
478 struct snd_sst_control_routing {
479 u8 control; /* 0=start, 1=Stop */
480 u8 reserved[3]; /* Reserved- for 32 bit alignment */
484 struct list_head node;
485 union ipc_header header; /* driver specific */
487 bool is_process_reply;
488 union ipc_header_mrfld mrfld_header;
492 struct snd_sst_ctxt_params {
493 u32 address; /* Physical Address in DDR where the context is stored */
494 u32 size; /* size of the context */
497 struct snd_sst_lpe_log_params {
504 enum snd_sst_bytes_type {
505 SND_SST_BYTES_SET = 0x1,
506 SND_SST_BYTES_GET = 0x2,
509 struct snd_sst_bytes_v2 {
520 #define MAX_VTSV_FILES 2
521 struct snd_sst_vtsv_info {
522 struct sst_address_info vfiles[MAX_VTSV_FILES];
525 #endif /* __SST_MFLD_DSP_H__ */