/drivers/staging/intel_sst/intel_sst_fw_ipc.h

https://bitbucket.org/wisechild/galaxy-nexus · C++ Header · 416 lines · 279 code · 58 blank · 79 comment · 0 complexity · 2259a930caefd14f10832f403aa21cea MD5 · raw file

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