1 #ifndef __INTEL_SST_FW_IPC_H__
2 #define __INTEL_SST_FW_IPC_H__
4 * intel_sst_fw_ipc.h - Intel SST Driver for audio engine
6 * Copyright (C) 2008-10 Intel Corporation
7 * Author: Vinod Koul <vinod.koul@intel.com>
8 * Harsha Priya <priya.harsha@intel.com>
9 * Dharageswari R <dharageswari.r@intel.com>
10 * KP Jeeja <jeeja.kp@intel.com>
11 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; version 2 of the License.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 * This driver exposes the audio engine functionalities to the ALSA
30 * This file has definitions shared between the firmware and driver
33 #define MAX_NUM_STREAMS_MRST 3
34 #define MAX_NUM_STREAMS 6
35 #define MAX_DBG_RW_BYTES 80
36 #define MAX_NUM_SCATTER_BUFFERS 8
37 #define MAX_LOOP_BACK_DWORDS 8
38 /* IPC base address and mailbox, timestamp offsets */
39 #define SST_MAILBOX_SIZE 0x0400
40 #define SST_MAILBOX_SEND 0x0000
41 #define SST_MAILBOX_RCV 0x0804
42 #define SST_TIME_STAMP 0x1800
43 #define SST_RESERVED_OFFSET 0x1A00
44 #define SST_CHEKPOINT_OFFSET 0x1C00
45 #define REPLY_MSG 0x80
47 /* Message ID's for IPC messages */
48 /* Bits B7: SST or IA/SC ; B6-B4: Msg Category; B3-B0: Msg Type */
50 /* I2L Firmware/Codec Download msgs */
51 #define IPC_IA_PREP_LIB_DNLD 0x01
52 #define IPC_IA_LIB_DNLD_CMPLT 0x02
54 #define IPC_IA_SET_PMIC_TYPE 0x03
55 #define IPC_IA_GET_FW_VERSION 0x04
56 #define IPC_IA_GET_FW_BUILD_INF 0x05
57 #define IPC_IA_GET_FW_INFO 0x06
59 /* I2L Codec Config/control msgs */
60 #define IPC_IA_SET_CODEC_PARAMS 0x10
61 #define IPC_IA_GET_CODEC_PARAMS 0x11
62 #define IPC_IA_SET_PPP_PARAMS 0x12
63 #define IPC_IA_GET_PPP_PARAMS 0x13
64 #define IPC_IA_PLAY_FRAMES 0x14
65 #define IPC_IA_CAPT_FRAMES 0x15
66 #define IPC_IA_PLAY_VOICE 0x16
67 #define IPC_IA_CAPT_VOICE 0x17
68 #define IPC_IA_DECODE_FRAMES 0x18
70 /* I2L Stream config/control msgs */
71 #define IPC_IA_ALLOC_STREAM 0x20 /* Allocate a stream ID */
72 #define IPC_IA_FREE_STREAM 0x21 /* Free the stream ID */
73 #define IPC_IA_SET_STREAM_PARAMS 0x22
74 #define IPC_IA_GET_STREAM_PARAMS 0x23
75 #define IPC_IA_PAUSE_STREAM 0x24
76 #define IPC_IA_RESUME_STREAM 0x25
77 #define IPC_IA_DROP_STREAM 0x26
78 #define IPC_IA_DRAIN_STREAM 0x27 /* Short msg with str_id */
79 #define IPC_IA_TARGET_DEV_SELECT 0x28
80 #define IPC_IA_CONTROL_ROUTING 0x29
82 #define IPC_IA_SET_STREAM_VOL 0x2A /*Vol for stream, pre mixer */
83 #define IPC_IA_GET_STREAM_VOL 0x2B
84 #define IPC_IA_SET_STREAM_MUTE 0x2C
85 #define IPC_IA_GET_STREAM_MUTE 0x2D
86 #define IPC_IA_ENABLE_RX_TIME_SLOT 0x2E /* Enable Rx time slot 0 or 1 */
88 #define IPC_IA_START_STREAM 0x30 /* Short msg with str_id */
91 #define IPC_IA_DBG_MEM_READ 0x40
92 #define IPC_IA_DBG_MEM_WRITE 0x41
93 #define IPC_IA_DBG_LOOP_BACK 0x42
95 /* L2I Firmware/Codec Download msgs */
96 #define IPC_IA_FW_INIT_CMPLT 0x81
97 #define IPC_IA_LPE_GETTING_STALLED 0x82
98 #define IPC_IA_LPE_UNSTALLED 0x83
100 /* L2I Codec Config/control msgs */
101 #define IPC_SST_GET_PLAY_FRAMES 0x90 /* Request IA more data */
102 #define IPC_SST_GET_CAPT_FRAMES 0x91 /* Request IA more data */
103 #define IPC_SST_BUF_UNDER_RUN 0x92 /* PB Under run and stopped */
104 #define IPC_SST_BUF_OVER_RUN 0x93 /* CAP Under run and stopped */
105 #define IPC_SST_DRAIN_END 0x94 /* PB Drain complete and stopped */
106 #define IPC_SST_CHNGE_SSP_PARAMS 0x95 /* PB SSP parameters changed */
107 #define IPC_SST_STREAM_PROCESS_FATAL_ERR 0x96/* error in processing a stream */
108 #define IPC_SST_PERIOD_ELAPSED 0x97 /* period elapsed */
109 #define IPC_IA_TARGET_DEV_CHNGD 0x98 /* error in processing a stream */
111 #define IPC_SST_ERROR_EVENT 0x99 /* Buffer over run occured */
113 #define IPC_SC_DDR_LINK_UP 0xC0
114 #define IPC_SC_DDR_LINK_DOWN 0xC1
115 #define IPC_SC_SET_LPECLK_REQ 0xC2
116 #define IPC_SC_SSP_BIT_BANG 0xC3
118 /* L2I Error reporting msgs */
119 #define IPC_IA_MEM_ALLOC_FAIL 0xE0
120 #define IPC_IA_PROC_ERR 0xE1 /* error in processing a
121 stream can be used by playback and
125 #define IPC_IA_PRINT_STRING 0xF0
129 /* Command Response or Acknowledge message to any IPC message will have
130 * same message ID and stream ID information which is sent.
131 * There is no specific Ack message ID. The data field is used as response
140 enum sst_error_codes
{
141 /* Error code,response to msgId: Description */
142 /* Common error codes */
143 SST_SUCCESS
= 0, /* Success */
144 SST_ERR_INVALID_STREAM_ID
, /* Invalid stream ID */
145 SST_ERR_INVALID_MSG_ID
, /* Invalid message ID */
146 SST_ERR_INVALID_STREAM_OP
, /* Invalid stream operation request */
147 SST_ERR_INVALID_PARAMS
, /* Invalid params */
148 SST_ERR_INVALID_CODEC
, /* Invalid codec type */
149 SST_ERR_INVALID_MEDIA_TYPE
, /* Invalid media type */
150 SST_ERR_STREAM_ERR
, /* ANY: Stream control or config or
153 /* IPC specific error codes */
154 SST_IPC_ERR_CALL_BACK_NOT_REGD
, /* Call back for msg not regd */
155 SST_IPC_ERR_STREAM_NOT_ALLOCATED
, /* Stream is not allocated */
156 SST_IPC_ERR_STREAM_ALLOC_FAILED
, /* ALLOC:Stream alloc failed */
157 SST_IPC_ERR_GET_STREAM_FAILED
, /* ALLOC:Get stream id failed*/
158 SST_ERR_MOD_NOT_AVAIL
, /* SET/GET: Mod(AEC/AGC/ALC) not available */
159 SST_ERR_MOD_DNLD_RQD
, /* SET/GET: Mod(AEC/AGC/ALC) download required */
160 SST_ERR_STREAM_STOPPED
, /* ANY: Stream is in stopped state */
161 SST_ERR_STREAM_IN_USE
, /* ANY: Stream is already in use */
163 /* Capture specific error codes */
164 SST_CAP_ERR_INCMPLTE_CAPTURE_MSG
,/* ANY:Incomplete message */
165 SST_CAP_ERR_CAPTURE_FAIL
, /* ANY:Capture op failed */
166 SST_CAP_ERR_GET_DDR_NEW_SGLIST
,
167 SST_CAP_ERR_UNDER_RUN
, /* lack of input data */
168 SST_CAP_ERR_OVERFLOW
, /* lack of output space */
170 /* Playback specific error codes*/
171 SST_PB_ERR_INCMPLTE_PLAY_MSG
, /* ANY: Incomplete message */
172 SST_PB_ERR_PLAY_FAIL
, /* ANY: Playback operation failed */
173 SST_PB_ERR_GET_DDR_NEW_SGLIST
,
175 /* Codec manager specific error codes */
176 SST_LIB_ERR_LIB_DNLD_REQUIRED
, /* ALLOC: Codec download required */
177 SST_LIB_ERR_LIB_NOT_SUPPORTED
, /* Library is not supported */
179 /* Library manager specific error codes */
180 SST_SCC_ERR_PREP_DNLD_FAILED
, /* Failed to prepare for codec download */
181 SST_SCC_ERR_LIB_DNLD_RES_FAILED
, /* Lib download resume failed */
182 /* Scheduler specific error codes */
183 SST_SCH_ERR_FAIL
, /* REPORT: */
185 /* DMA specific error codes */
186 SST_DMA_ERR_NO_CHNL_AVAILABLE
, /* DMA Ch not available */
187 SST_DMA_ERR_INVALID_INPUT_PARAMS
, /* Invalid input params */
188 SST_DMA_ERR_CHNL_ALREADY_SUSPENDED
, /* Ch is suspended */
189 SST_DMA_ERR_CHNL_ALREADY_STARTED
, /* Ch already started */
190 SST_DMA_ERR_CHNL_NOT_ENABLED
, /* Ch not enabled */
191 SST_DMA_ERR_TRANSFER_FAILED
, /* Transfer failed */
192 SST_SSP_ERR_ALREADY_ENABLED
, /* REPORT: SSP already enabled */
193 SST_SSP_ERR_ALREADY_DISABLED
, /* REPORT: SSP already disabled */
194 SST_SSP_ERR_NOT_INITIALIZED
,
196 /* Other error codes */
197 SST_ERR_MOD_INIT_FAIL
, /* Firmware Module init failed */
199 /* FW init error codes */
200 SST_RDR_ERR_IO_DEV_SEL_NOT_ALLOWED
,
201 SST_RDR_ERR_ROUTE_ALREADY_STARTED
,
202 SST_RDR_PREP_CODEC_DNLD_FAILED
,
204 /* Memory debug error codes */
205 SST_ERR_DBG_MEM_READ_FAIL
,
206 SST_ERR_DBG_MEM_WRITE_FAIL
,
208 /* Decode error codes */
209 SST_ERR_DEC_NEED_INPUT_BUF
,
213 enum dbg_mem_data_type
{
214 /* Data type of debug read/write */
220 /* CAUTION NOTE: All IPC message body must be multiple of 32 bits.*/
225 u32 msg_id
:8; /* Message ID - Max 256 Message Types */
227 u32 large
:1; /* Large Message if large = 1 */
228 u32 reserved
:2; /* Reserved for future use */
229 u32 data
:14; /* Ack/Info for msg, size of msg in Mailbox */
230 u32 done
:1; /* bit 30 */
231 u32 busy
:1; /* bit 31 */
234 } __attribute__ ((packed
));
236 /* Firmware build info */
237 struct sst_fw_build_info
{
238 unsigned char date
[16]; /* Firmware build date */
239 unsigned char time
[16]; /* Firmware build time */
240 } __attribute__ ((packed
));
242 struct ipc_header_fw_init
{
243 struct snd_sst_fw_version fw_version
;/* Firmware version details */
244 struct sst_fw_build_info build_info
;
245 u16 result
; /* Fw init result */
246 u8 module_id
; /* Module ID in case of error */
247 u8 debug_info
; /* Debug info from Module ID in case of fail */
248 } __attribute__ ((packed
));
250 /* Address and size info of a frame buffer in DDR */
251 struct sst_address_info
{
252 u32 addr
; /* Address at IA */
253 u32 size
; /* Size of the buffer */
254 } __attribute__ ((packed
));
257 struct snd_sst_tstamp
{
258 u64 samples_processed
;/* capture - data in DDR */
259 u64 samples_rendered
;/* playback - data rendered */
260 u64 bytes_processed
;/* bytes decoded or encoded */
261 u32 sampling_frequency
;/* eg: 48000, 44100 */
262 u32 dma_base_address
;/* DMA base address */
263 u16 dma_channel_no
;/* DMA Channel used for the data transfer*/
264 u16 reserved
;/* 32 bit alignment */
267 /* Frame info to play or capture */
268 struct sst_frame_info
{
269 u16 num_entries
; /* number of entries to follow */
271 struct sst_address_info addr
[MAX_NUM_SCATTER_BUFFERS
];
272 } __attribute__ ((packed
));
274 /* Frames info for decode */
275 struct snd_sst_decode_info
{
276 unsigned long long input_bytes_consumed
;
277 unsigned long long output_bytes_produced
;
278 struct sst_frame_info frames_in
;
279 struct sst_frame_info frames_out
;
280 } __attribute__ ((packed
));
282 /* SST to IA print debug message*/
283 struct ipc_sst_ia_print_params
{
284 u32 string_size
;/* Max value is 160 */
285 u8 prt_string
[160];/* Null terminated Char string */
286 } __attribute__ ((packed
));
288 /* Voice data message */
289 struct snd_sst_voice_data
{
290 u16 num_bytes
;/* Number of valid voice data bytes */
291 u8 pcm_wd_size
;/* 0=8 bit, 1=16 bit 2=32 bit */
292 u8 reserved
;/* Reserved */
293 u8 voice_data_buf
[0];/* Voice data buffer in bytes, little endian */
294 } __attribute__ ((packed
));
296 /* SST to IA memory read debug message */
297 struct ipc_sst_ia_dbg_mem_rw
{
298 u16 num_bytes
;/* Maximum of MAX_DBG_RW_BYTES */
299 u16 data_type
;/* enum: dbg_mem_data_type */
300 u32 address
; /* Memory address of data memory of data_type */
301 u8 rw_bytes
[MAX_DBG_RW_BYTES
];/* Maximum of 64 bytes can be RW */
302 } __attribute__ ((packed
));
304 struct ipc_sst_ia_dbg_loop_back
{
305 u16 num_dwords
; /* Maximum of MAX_DBG_RW_BYTES */
306 u16 increment_val
;/* Increments dwords by this value, 0- no increment */
307 u32 lpbk_dwords
[MAX_LOOP_BACK_DWORDS
];/* Maximum of 8 dwords loopback */
308 } __attribute__ ((packed
));
310 /* Stream type params struture for Alloc stream */
311 struct snd_sst_str_type
{
312 u8 codec_type
; /* Codec type */
313 u8 str_type
; /* 1 = voice 2 = music */
314 u8 operation
; /* Playback or Capture */
315 u8 protected_str
; /* 0=Non DRM, 1=DRM */
317 u8 reserved
; /* Reserved */
318 u16 result
; /* Result used for acknowledgment */
319 } __attribute__ ((packed
));
321 /* Library info structure */
324 u32 lib_type
;/*TBD- KLOCKWORK u8 lib_type;*/
328 unsigned char b_date
[16]; /* Lib build date */
329 unsigned char b_time
[16]; /* Lib build time */
330 } __attribute__ ((packed
));
332 /* Library slot info */
333 struct lib_slot_info
{
334 u8 slot_num
; /* 1 or 2 */
337 u32 iram_size
; /* slot size in IRAM */
338 u32 dram_size
; /* slot size in DRAM */
339 u32 iram_offset
; /* starting offset of slot in IRAM */
340 u32 dram_offset
; /* starting offset of slot in DRAM */
341 } __attribute__ ((packed
));
343 struct snd_sst_lib_download
{
344 struct module_info lib_info
; /* library info type, capabilities etc */
345 struct lib_slot_info slot_info
; /* slot info to be downloaded */
349 struct snd_sst_lib_download_info
{
350 struct snd_sst_lib_download dload_lib
;
351 u16 result
; /* Result used for acknowledgment */
352 u8 pvt_id
; /* Private ID */
353 u8 reserved
; /* for alignment */
356 /* Alloc stream params structure */
357 struct snd_sst_alloc_params
{
358 struct snd_sst_str_type str_type
;
359 struct snd_sst_stream_params stream_params
;
362 struct snd_sst_fw_get_stream_params
{
363 struct snd_sst_stream_params codec_params
;
364 struct snd_sst_pmic_config pcm_params
;
367 /* Alloc stream response message */
368 struct snd_sst_alloc_response
{
369 struct snd_sst_str_type str_type
; /* Stream type for allocation */
370 struct snd_sst_lib_download lib_dnld
; /* Valid only for codec dnld */
374 struct snd_sst_drop_response
{
379 /* CSV Voice call routing structure */
380 struct snd_sst_control_routing
{
381 u8 control
; /* 0=start, 1=Stop */
382 u8 reserved
[3]; /* Reserved- for 32 bit alignment */
387 struct list_head node
;
388 union ipc_header header
; /* driver specific */
392 #endif /* __INTEL_SST_FW_IPC_H__ */