Merge branch 'linux_next' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[pandora-kernel.git] / drivers / staging / intel_sst / intel_sst_fw_ipc.h
1 #ifndef __INTEL_SST_FW_IPC_H__
2 #define __INTEL_SST_FW_IPC_H__
3 /*
4 *  intel_sst_fw_ipc.h - Intel SST Driver for audio engine
5 *
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 *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 *
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.
16 *
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.
21 *
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.
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 *
28 *  This driver exposes the audio engine functionalities to the ALSA
29 *       and middleware.
30 *  This file has definitions shared between the firmware and driver
31 */
32
33 #define MAX_NUM_STREAMS_MRST 3
34 #define MAX_NUM_STREAMS_MFLD 6
35 #define MAX_NUM_STREAMS 6
36 #define MAX_DBG_RW_BYTES 80
37 #define MAX_NUM_SCATTER_BUFFERS 8
38 #define MAX_LOOP_BACK_DWORDS 8
39 /* IPC base address and mailbox, timestamp offsets */
40 #define SST_MAILBOX_SIZE 0x0400
41 #define SST_MAILBOX_SEND 0x0000
42 #define SST_MAILBOX_RCV 0x0804
43 #define SST_TIME_STAMP 0x1800
44 #define SST_RESERVED_OFFSET 0x1A00
45 #define SST_CHEKPOINT_OFFSET 0x1C00
46 #define REPLY_MSG 0x80
47
48 /* Message ID's for IPC messages */
49 /* Bits B7: SST or IA/SC ; B6-B4: Msg Category; B3-B0: Msg Type */
50
51 /* I2L Firmware/Codec Download msgs */
52 #define IPC_IA_PREP_LIB_DNLD 0x01
53 #define IPC_IA_LIB_DNLD_CMPLT 0x02
54
55 #define IPC_IA_SET_PMIC_TYPE 0x03
56 #define IPC_IA_GET_FW_VERSION 0x04
57 #define IPC_IA_GET_FW_BUILD_INF 0x05
58 #define IPC_IA_GET_FW_INFO 0x06
59 #define IPC_IA_GET_FW_CTXT 0x07
60 #define IPC_IA_SET_FW_CTXT 0x08
61
62 /* I2L Codec Config/control msgs */
63 #define IPC_IA_SET_CODEC_PARAMS 0x10
64 #define IPC_IA_GET_CODEC_PARAMS 0x11
65 #define IPC_IA_SET_PPP_PARAMS 0x12
66 #define IPC_IA_GET_PPP_PARAMS 0x13
67 #define IPC_IA_PLAY_FRAMES 0x14
68 #define IPC_IA_CAPT_FRAMES 0x15
69 #define IPC_IA_PLAY_VOICE 0x16
70 #define IPC_IA_CAPT_VOICE 0x17
71 #define IPC_IA_DECODE_FRAMES 0x18
72
73 #define IPC_IA_ALG_PARAMS 0x1A
74 #define IPC_IA_TUNING_PARAMS 0x1B
75
76 /* I2L Stream config/control msgs */
77 #define IPC_IA_ALLOC_STREAM 0x20 /* Allocate a stream ID */
78 #define IPC_IA_FREE_STREAM 0x21 /* Free the stream ID */
79 #define IPC_IA_SET_STREAM_PARAMS 0x22
80 #define IPC_IA_GET_STREAM_PARAMS 0x23
81 #define IPC_IA_PAUSE_STREAM 0x24
82 #define IPC_IA_RESUME_STREAM 0x25
83 #define IPC_IA_DROP_STREAM 0x26
84 #define IPC_IA_DRAIN_STREAM 0x27 /* Short msg with str_id */
85 #define IPC_IA_TARGET_DEV_SELECT 0x28
86 #define IPC_IA_CONTROL_ROUTING 0x29
87
88 #define IPC_IA_SET_STREAM_VOL 0x2A /*Vol for stream, pre mixer */
89 #define IPC_IA_GET_STREAM_VOL 0x2B
90 #define IPC_IA_SET_STREAM_MUTE 0x2C
91 #define IPC_IA_GET_STREAM_MUTE 0x2D
92 #define IPC_IA_ENABLE_RX_TIME_SLOT 0x2E /* Enable Rx time slot 0 or 1 */
93
94 #define IPC_IA_START_STREAM 0x30 /* Short msg with str_id */
95
96 /* Debug msgs */
97 #define IPC_IA_DBG_MEM_READ 0x40
98 #define IPC_IA_DBG_MEM_WRITE 0x41
99 #define IPC_IA_DBG_LOOP_BACK 0x42
100
101 /* L2I Firmware/Codec Download msgs */
102 #define IPC_IA_FW_INIT_CMPLT 0x81
103 #define IPC_IA_LPE_GETTING_STALLED 0x82
104 #define IPC_IA_LPE_UNSTALLED 0x83
105
106 /* L2I Codec Config/control msgs */
107 #define IPC_SST_GET_PLAY_FRAMES 0x90 /* Request IA more data */
108 #define IPC_SST_GET_CAPT_FRAMES 0x91 /* Request IA more data */
109 #define IPC_SST_BUF_UNDER_RUN 0x92 /* PB Under run and stopped */
110 #define IPC_SST_BUF_OVER_RUN 0x93 /* CAP Under run and stopped */
111 #define IPC_SST_DRAIN_END 0x94 /* PB Drain complete and stopped */
112 #define IPC_SST_CHNGE_SSP_PARAMS 0x95 /* PB SSP parameters changed */
113 #define IPC_SST_STREAM_PROCESS_FATAL_ERR 0x96/* error in processing a stream */
114 #define IPC_SST_PERIOD_ELAPSED 0x97 /* period elapsed */
115 #define IPC_IA_TARGET_DEV_CHNGD 0x98 /* error in processing a stream */
116
117 #define IPC_SST_ERROR_EVENT 0x99 /* Buffer over run occurred */
118 /* L2S messages */
119 #define IPC_SC_DDR_LINK_UP 0xC0
120 #define IPC_SC_DDR_LINK_DOWN 0xC1
121 #define IPC_SC_SET_LPECLK_REQ 0xC2
122 #define IPC_SC_SSP_BIT_BANG 0xC3
123
124 /* L2I Error reporting msgs */
125 #define IPC_IA_MEM_ALLOC_FAIL 0xE0
126 #define IPC_IA_PROC_ERR 0xE1 /* error in processing a
127                                         stream can be used by playback and
128                                         capture modules */
129
130 /* L2I Debug msgs */
131 #define IPC_IA_PRINT_STRING 0xF0
132
133
134
135 /* Command Response or Acknowledge message to any IPC message will have
136  * same message ID and stream ID information which is sent.
137  * There is no specific Ack message ID. The data field is used as response
138  * meaning.
139  */
140 enum ackData {
141         IPC_ACK_SUCCESS = 0,
142         IPC_ACK_FAILURE
143 };
144
145
146 enum sst_error_codes {
147         /* Error code,response to msgId: Description */
148         /* Common error codes */
149         SST_SUCCESS = 0,        /* Success */
150         SST_ERR_INVALID_STREAM_ID = 1,
151         SST_ERR_INVALID_MSG_ID = 2,
152         SST_ERR_INVALID_STREAM_OP = 3,
153         SST_ERR_INVALID_PARAMS = 4,
154         SST_ERR_INVALID_CODEC = 5,
155         SST_ERR_INVALID_MEDIA_TYPE = 6,
156         SST_ERR_STREAM_ERR = 7,
157
158         /* IPC specific error codes */
159         SST_IPC_ERR_CALL_BACK_NOT_REGD = 8,
160         SST_IPC_ERR_STREAM_NOT_ALLOCATED = 9,
161         SST_IPC_ERR_STREAM_ALLOC_FAILED = 10,
162         SST_IPC_ERR_GET_STREAM_FAILED = 11,
163         SST_ERR_MOD_NOT_AVAIL = 12,
164         SST_ERR_MOD_DNLD_RQD = 13,
165         SST_ERR_STREAM_STOPPED = 14,
166         SST_ERR_STREAM_IN_USE = 15,
167
168         /* Capture specific error codes */
169         SST_CAP_ERR_INCMPLTE_CAPTURE_MSG = 16,
170         SST_CAP_ERR_CAPTURE_FAIL = 17,
171         SST_CAP_ERR_GET_DDR_NEW_SGLIST = 18,
172         SST_CAP_ERR_UNDER_RUN = 19,
173         SST_CAP_ERR_OVERFLOW = 20,
174
175         /* Playback specific error codes*/
176         SST_PB_ERR_INCMPLTE_PLAY_MSG = 21,
177         SST_PB_ERR_PLAY_FAIL = 22,
178         SST_PB_ERR_GET_DDR_NEW_SGLIST = 23,
179
180         /* Codec manager specific error codes */
181         SST_LIB_ERR_LIB_DNLD_REQUIRED = 24,
182         SST_LIB_ERR_LIB_NOT_SUPPORTED = 25,
183
184         /* Library manager specific error codes */
185         SST_SCC_ERR_PREP_DNLD_FAILED = 26,
186         SST_SCC_ERR_LIB_DNLD_RES_FAILED = 27,
187         /* Scheduler specific error codes */
188         SST_SCH_ERR_FAIL = 28,
189
190         /* DMA specific error codes */
191         SST_DMA_ERR_NO_CHNL_AVAILABLE = 29,
192         SST_DMA_ERR_INVALID_INPUT_PARAMS = 30,
193         SST_DMA_ERR_CHNL_ALREADY_SUSPENDED = 31,
194         SST_DMA_ERR_CHNL_ALREADY_STARTED = 32,
195         SST_DMA_ERR_CHNL_NOT_ENABLED = 33,
196         SST_DMA_ERR_TRANSFER_FAILED = 34,
197
198         SST_SSP_ERR_ALREADY_ENABLED = 35,
199         SST_SSP_ERR_ALREADY_DISABLED = 36,
200         SST_SSP_ERR_NOT_INITIALIZED = 37,
201         SST_SSP_ERR_SRAM_NO_DMA_DATA = 38,
202
203         /* Other error codes */
204         SST_ERR_MOD_INIT_FAIL = 39,
205
206         /* FW init error codes */
207         SST_RDR_ERR_IO_DEV_SEL_NOT_ALLOWED = 40,
208         SST_RDR_ERR_ROUTE_ALREADY_STARTED = 41,
209         SST_RDR_ERR_IO_DEV_SEL_FAILED = 42,
210         SST_RDR_PREP_CODEC_DNLD_FAILED = 43,
211
212         /* Memory debug error codes */
213         SST_ERR_DBG_MEM_READ_FAIL = 44,
214         SST_ERR_DBG_MEM_WRITE_FAIL = 45,
215         SST_ERR_INSUFFICIENT_INPUT_SG_LIST = 46,
216         SST_ERR_INSUFFICIENT_OUTPUT_SG_LIST = 47,
217
218         SST_ERR_BUFFER_NOT_AVAILABLE = 48,
219         SST_ERR_BUFFER_NOT_ALLOCATED = 49,
220         SST_ERR_INVALID_REGION_TYPE = 50,
221         SST_ERR_NULL_PTR = 51,
222         SST_ERR_INVALID_BUFFER_SIZE = 52,
223         SST_ERR_INVALID_BUFFER_INDEX = 53,
224
225         /*IIPC specific error codes */
226         SST_IIPC_QUEUE_FULL = 54,
227         SST_IIPC_ERR_MSG_SND_FAILED = 55,
228         SST_PB_ERR_UNDERRUN_OCCURED = 56,
229         SST_RDR_INSUFFICIENT_MIXER_BUFFER = 57,
230         SST_INVALID_TIME_SLOTS = 58,
231 };
232
233 enum dbg_mem_data_type {
234         /* Data type of debug read/write */
235         DATA_TYPE_U32,
236         DATA_TYPE_U16,
237         DATA_TYPE_U8,
238 };
239
240 /* CAUTION NOTE: All IPC message body must be multiple of 32 bits.*/
241
242 /* IPC Header */
243 union ipc_header {
244         struct {
245                 u32  msg_id:8; /* Message ID - Max 256 Message Types */
246                 u32  str_id:5;
247                 u32  large:1;   /* Large Message if large = 1 */
248                 u32  reserved:2;        /* Reserved for future use */
249                 u32  data:14;   /* Ack/Info for msg, size of msg in Mailbox */
250                 u32  done:1; /* bit 30 */
251                 u32  busy:1; /* bit 31 */
252         } part;
253         u32 full;
254 } __attribute__ ((packed));
255
256 /* Firmware build info */
257 struct sst_fw_build_info {
258         unsigned char  date[16]; /* Firmware build date */
259         unsigned char  time[16]; /* Firmware build time */
260 } __attribute__ ((packed));
261
262 struct ipc_header_fw_init {
263         struct snd_sst_fw_version fw_version;/* Firmware version details */
264         struct sst_fw_build_info build_info;
265         u16 result;     /* Fw init result */
266         u8 module_id; /* Module ID in case of error */
267         u8 debug_info; /* Debug info from Module ID in case of fail */
268 } __attribute__ ((packed));
269
270 /* Address and size info of a frame buffer in DDR */
271 struct sst_address_info {
272         u32 addr; /* Address at IA */
273         u32 size; /* Size of the buffer */
274 } __attribute__ ((packed));
275
276 /* Time stamp */
277 struct snd_sst_tstamp {
278         u64 samples_processed;/* capture - data in DDR */
279         u64 samples_rendered;/* playback - data rendered */
280         u64 bytes_processed;/* bytes decoded or encoded */
281         u32 sampling_frequency;/* eg: 48000, 44100 */
282         u32 dma_base_address;/* DMA base address */
283         u16     dma_channel_no;/* DMA Channel used for the data transfer*/
284         u16     reserved;/* 32 bit alignment */
285 };
286
287 /* Frame info to play or capture */
288 struct sst_frame_info {
289         u16  num_entries; /* number of entries to follow */
290         u16  rsrvd;
291         struct sst_address_info  addr[MAX_NUM_SCATTER_BUFFERS];
292 } __attribute__ ((packed));
293
294 /* Frames info for decode */
295 struct snd_sst_decode_info {
296         unsigned long long input_bytes_consumed;
297         unsigned long long output_bytes_produced;
298         struct sst_frame_info frames_in;
299         struct sst_frame_info frames_out;
300 } __attribute__ ((packed));
301
302 /* SST to IA print debug message*/
303 struct ipc_sst_ia_print_params {
304         u32 string_size;/* Max value is 160 */
305         u8 prt_string[160];/* Null terminated Char string */
306 } __attribute__ ((packed));
307
308 /* Voice data message  */
309 struct snd_sst_voice_data {
310         u16 num_bytes;/* Number of valid voice data bytes */
311         u8  pcm_wd_size;/* 0=8 bit, 1=16 bit 2=32 bit */
312         u8  reserved;/* Reserved */
313         u8  voice_data_buf[0];/* Voice data buffer in bytes, little endian */
314 } __attribute__ ((packed));
315
316 /* SST to IA memory read debug message  */
317 struct ipc_sst_ia_dbg_mem_rw  {
318         u16  num_bytes;/* Maximum of MAX_DBG_RW_BYTES */
319         u16  data_type;/* enum: dbg_mem_data_type */
320         u32  address;   /* Memory address of data memory of data_type */
321         u8      rw_bytes[MAX_DBG_RW_BYTES];/* Maximum of 64 bytes can be RW */
322 } __attribute__ ((packed));
323
324 struct ipc_sst_ia_dbg_loop_back {
325         u16 num_dwords; /* Maximum of MAX_DBG_RW_BYTES */
326         u16 increment_val;/* Increments dwords by this value, 0- no increment */
327         u32 lpbk_dwords[MAX_LOOP_BACK_DWORDS];/* Maximum of 8 dwords loopback */
328 } __attribute__ ((packed));
329
330 /* Stream type params struture for Alloc stream */
331 struct snd_sst_str_type {
332         u8 codec_type;          /* Codec type */
333         u8 str_type;            /* 1 = voice 2 = music */
334         u8 operation;           /* Playback or Capture */
335         u8 protected_str;       /* 0=Non DRM, 1=DRM */
336         u8 time_slots;
337         u8 reserved;            /* Reserved */
338         u16 result;             /* Result used for acknowledgment */
339 } __attribute__ ((packed));
340
341 /* Library info structure */
342 struct module_info {
343         u32 lib_version;
344         u32 lib_type;/*TBD- KLOCKWORK u8 lib_type;*/
345         u32 media_type;
346         u8  lib_name[12];
347         u32 lib_caps;
348         unsigned char  b_date[16]; /* Lib build date */
349         unsigned char  b_time[16]; /* Lib build time */
350 } __attribute__ ((packed));
351
352 /* Library slot info */
353 struct lib_slot_info {
354         u8  slot_num; /* 1 or 2 */
355         u8  reserved1;
356         u16 reserved2;
357         u32 iram_size; /* slot size in IRAM */
358         u32 dram_size; /* slot size in DRAM */
359         u32 iram_offset; /* starting offset of slot in IRAM */
360         u32 dram_offset; /* starting offset of slot in DRAM */
361 } __attribute__ ((packed));
362
363 struct snd_sst_lib_download {
364         struct module_info lib_info; /* library info type, capabilities etc */
365         struct lib_slot_info slot_info; /* slot info to be downloaded */
366         u32 mod_entry_pt;
367 };
368
369 struct snd_sst_lib_download_info {
370         struct snd_sst_lib_download dload_lib;
371         u16 result;     /* Result used for acknowledgment */
372         u8 pvt_id; /* Private ID */
373         u8 reserved;  /* for alignment */
374 };
375
376 /* Alloc stream params structure */
377 struct snd_sst_alloc_params {
378         struct snd_sst_str_type str_type;
379         struct snd_sst_stream_params stream_params;
380 };
381
382 struct snd_sst_fw_get_stream_params {
383         struct snd_sst_stream_params codec_params;
384         struct snd_sst_pmic_config pcm_params;
385 };
386
387 /* Alloc stream response message */
388 struct snd_sst_alloc_response {
389         struct snd_sst_str_type str_type; /* Stream type for allocation */
390         struct snd_sst_lib_download lib_dnld; /* Valid only for codec dnld */
391 };
392
393 /* Drop response */
394 struct snd_sst_drop_response {
395         u32 result;
396         u32 bytes;
397 };
398
399 /* CSV Voice call routing structure */
400 struct snd_sst_control_routing {
401         u8 control; /* 0=start, 1=Stop */
402         u8 reserved[3]; /* Reserved- for 32 bit alignment */
403 };
404
405
406 struct ipc_post {
407         struct list_head node;
408         union ipc_header header; /* driver specific */
409         char *mailbox_data;
410 };
411
412 struct snd_sst_ctxt_params {
413         u32 address; /* Physical Address in DDR where the context is stored */
414         u32 size; /* size of the context */
415 };
416 #endif /* __INTEL_SST_FW_IPC_H__ */