sst-mfld-dsp.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. #ifndef __SST_MFLD_DSP_H__
  2. #define __SST_MFLD_DSP_H__
  3. /*
  4. * sst_mfld_dsp.h - Intel SST Driver for audio engine
  5. *
  6. * Copyright (C) 2008-14 Intel Corporation
  7. * Authors: Vinod Koul <vinod.koul@linux.intel.com>
  8. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. *
  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.
  13. *
  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.
  18. *
  19. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20. */
  21. #define SST_MAX_BIN_BYTES 1024
  22. #define MAX_DBG_RW_BYTES 80
  23. #define MAX_NUM_SCATTER_BUFFERS 8
  24. #define MAX_LOOP_BACK_DWORDS 8
  25. /* IPC base address and mailbox, timestamp offsets */
  26. #define SST_MAILBOX_SIZE 0x0400
  27. #define SST_MAILBOX_SEND 0x0000
  28. #define SST_TIME_STAMP 0x1800
  29. #define SST_TIME_STAMP_MRFLD 0x800
  30. #define SST_RESERVED_OFFSET 0x1A00
  31. #define SST_SCU_LPE_MAILBOX 0x1000
  32. #define SST_LPE_SCU_MAILBOX 0x1400
  33. #define SST_SCU_LPE_LOG_BUF (SST_SCU_LPE_MAILBOX+16)
  34. #define PROCESS_MSG 0x80
  35. /* Message ID's for IPC messages */
  36. /* Bits B7: SST or IA/SC ; B6-B4: Msg Category; B3-B0: Msg Type */
  37. /* I2L Firmware/Codec Download msgs */
  38. #define IPC_IA_PREP_LIB_DNLD 0x01
  39. #define IPC_IA_LIB_DNLD_CMPLT 0x02
  40. #define IPC_IA_GET_FW_VERSION 0x04
  41. #define IPC_IA_GET_FW_BUILD_INF 0x05
  42. #define IPC_IA_GET_FW_INFO 0x06
  43. #define IPC_IA_GET_FW_CTXT 0x07
  44. #define IPC_IA_SET_FW_CTXT 0x08
  45. #define IPC_IA_PREPARE_SHUTDOWN 0x31
  46. /* I2L Codec Config/control msgs */
  47. #define IPC_PREP_D3 0x10
  48. #define IPC_IA_SET_CODEC_PARAMS 0x10
  49. #define IPC_IA_GET_CODEC_PARAMS 0x11
  50. #define IPC_IA_SET_PPP_PARAMS 0x12
  51. #define IPC_IA_GET_PPP_PARAMS 0x13
  52. #define IPC_SST_PERIOD_ELAPSED_MRFLD 0xA
  53. #define IPC_IA_ALG_PARAMS 0x1A
  54. #define IPC_IA_TUNING_PARAMS 0x1B
  55. #define IPC_IA_SET_RUNTIME_PARAMS 0x1C
  56. #define IPC_IA_SET_PARAMS 0x1
  57. #define IPC_IA_GET_PARAMS 0x2
  58. #define IPC_EFFECTS_CREATE 0xE
  59. #define IPC_EFFECTS_DESTROY 0xF
  60. /* I2L Stream config/control msgs */
  61. #define IPC_IA_ALLOC_STREAM_MRFLD 0x2
  62. #define IPC_IA_ALLOC_STREAM 0x20 /* Allocate a stream ID */
  63. #define IPC_IA_FREE_STREAM_MRFLD 0x03
  64. #define IPC_IA_FREE_STREAM 0x21 /* Free the stream ID */
  65. #define IPC_IA_SET_STREAM_PARAMS 0x22
  66. #define IPC_IA_SET_STREAM_PARAMS_MRFLD 0x12
  67. #define IPC_IA_GET_STREAM_PARAMS 0x23
  68. #define IPC_IA_PAUSE_STREAM 0x24
  69. #define IPC_IA_PAUSE_STREAM_MRFLD 0x4
  70. #define IPC_IA_RESUME_STREAM 0x25
  71. #define IPC_IA_RESUME_STREAM_MRFLD 0x5
  72. #define IPC_IA_DROP_STREAM 0x26
  73. #define IPC_IA_DROP_STREAM_MRFLD 0x07
  74. #define IPC_IA_DRAIN_STREAM 0x27 /* Short msg with str_id */
  75. #define IPC_IA_DRAIN_STREAM_MRFLD 0x8
  76. #define IPC_IA_CONTROL_ROUTING 0x29
  77. #define IPC_IA_VTSV_UPDATE_MODULES 0x20
  78. #define IPC_IA_VTSV_DETECTED 0x21
  79. #define IPC_IA_START_STREAM_MRFLD 0X06
  80. #define IPC_IA_START_STREAM 0x30 /* Short msg with str_id */
  81. #define IPC_IA_SET_GAIN_MRFLD 0x21
  82. /* Debug msgs */
  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
  88. /* L2I Firmware/Codec Download msgs */
  89. #define IPC_IA_FW_INIT_CMPLT 0x81
  90. #define IPC_IA_FW_INIT_CMPLT_MRFLD 0x01
  91. #define IPC_IA_FW_ASYNC_ERR_MRFLD 0x11
  92. /* L2I Codec Config/control msgs */
  93. #define IPC_SST_FRAGMENT_ELPASED 0x90 /* Request IA more data */
  94. #define IPC_SST_BUF_UNDER_RUN 0x92 /* PB Under run and stopped */
  95. #define IPC_SST_BUF_OVER_RUN 0x93 /* CAP Under run and stopped */
  96. #define IPC_SST_DRAIN_END 0x94 /* PB Drain complete and stopped */
  97. #define IPC_SST_CHNGE_SSP_PARAMS 0x95 /* PB SSP parameters changed */
  98. #define IPC_SST_STREAM_PROCESS_FATAL_ERR 0x96/* error in processing a stream */
  99. #define IPC_SST_PERIOD_ELAPSED 0x97 /* period elapsed */
  100. #define IPC_SST_ERROR_EVENT 0x99 /* Buffer over run occurred */
  101. /* L2S messages */
  102. #define IPC_SC_DDR_LINK_UP 0xC0
  103. #define IPC_SC_DDR_LINK_DOWN 0xC1
  104. #define IPC_SC_SET_LPECLK_REQ 0xC2
  105. #define IPC_SC_SSP_BIT_BANG 0xC3
  106. /* L2I Error reporting msgs */
  107. #define IPC_IA_MEM_ALLOC_FAIL 0xE0
  108. #define IPC_IA_PROC_ERR 0xE1 /* error in processing a
  109. stream can be used by playback and
  110. capture modules */
  111. /* L2I Debug msgs */
  112. #define IPC_IA_PRINT_STRING 0xF0
  113. /* Buffer under-run */
  114. #define IPC_IA_BUF_UNDER_RUN_MRFLD 0x0B
  115. /* Mrfld specific defines:
  116. * For asynchronous messages(INIT_CMPLT, PERIOD_ELAPSED, ASYNC_ERROR)
  117. * received from FW, the format is:
  118. * - IPC High: pvt_id is set to zero. Always short message.
  119. * - msg_id is in lower 16-bits of IPC low payload.
  120. * - pipe_id is in higher 16-bits of IPC low payload for period_elapsed.
  121. * - error id is in higher 16-bits of IPC low payload for async errors.
  122. */
  123. #define SST_ASYNC_DRV_ID 0
  124. /* Command Response or Acknowledge message to any IPC message will have
  125. * same message ID and stream ID information which is sent.
  126. * There is no specific Ack message ID. The data field is used as response
  127. * meaning.
  128. */
  129. enum ackData {
  130. IPC_ACK_SUCCESS = 0,
  131. IPC_ACK_FAILURE,
  132. };
  133. enum ipc_ia_msg_id {
  134. IPC_CMD = 1, /*!< Task Control message ID */
  135. IPC_SET_PARAMS = 2,/*!< Task Set param message ID */
  136. IPC_GET_PARAMS = 3, /*!< Task Get param message ID */
  137. IPC_INVALID = 0xFF, /*!<Task Get param message ID */
  138. };
  139. enum sst_codec_types {
  140. /* AUDIO/MUSIC CODEC Type Definitions */
  141. SST_CODEC_TYPE_UNKNOWN = 0,
  142. SST_CODEC_TYPE_PCM, /* Pass through Audio codec */
  143. SST_CODEC_TYPE_MP3,
  144. SST_CODEC_TYPE_MP24,
  145. SST_CODEC_TYPE_AAC,
  146. SST_CODEC_TYPE_AACP,
  147. SST_CODEC_TYPE_eAACP,
  148. };
  149. enum stream_type {
  150. SST_STREAM_TYPE_NONE = 0,
  151. SST_STREAM_TYPE_MUSIC = 1,
  152. };
  153. enum sst_error_codes {
  154. /* Error code,response to msgId: Description */
  155. /* Common error codes */
  156. SST_SUCCESS = 0, /* Success */
  157. SST_ERR_INVALID_STREAM_ID = 1,
  158. SST_ERR_INVALID_MSG_ID = 2,
  159. SST_ERR_INVALID_STREAM_OP = 3,
  160. SST_ERR_INVALID_PARAMS = 4,
  161. SST_ERR_INVALID_CODEC = 5,
  162. SST_ERR_INVALID_MEDIA_TYPE = 6,
  163. SST_ERR_STREAM_ERR = 7,
  164. SST_ERR_STREAM_IN_USE = 15,
  165. };
  166. struct ipc_dsp_hdr {
  167. u16 mod_index_id:8; /*!< DSP Command ID specific to tasks */
  168. u16 pipe_id:8; /*!< instance of the module in the pipeline */
  169. u16 mod_id; /*!< Pipe_id */
  170. u16 cmd_id; /*!< Module ID = lpe_algo_types_t */
  171. u16 length; /*!< Length of the payload only */
  172. } __packed;
  173. union ipc_header_high {
  174. struct {
  175. u32 msg_id:8; /* Message ID - Max 256 Message Types */
  176. u32 task_id:4; /* Task ID associated with this comand */
  177. u32 drv_id:4; /* Identifier for the driver to track*/
  178. u32 rsvd1:8; /* Reserved */
  179. u32 result:4; /* Reserved */
  180. u32 res_rqd:1; /* Response rqd */
  181. u32 large:1; /* Large Message if large = 1 */
  182. u32 done:1; /* bit 30 - Done bit */
  183. u32 busy:1; /* bit 31 - busy bit*/
  184. } part;
  185. u32 full;
  186. } __packed;
  187. /* IPC header */
  188. union ipc_header_mrfld {
  189. struct {
  190. u32 header_low_payload;
  191. union ipc_header_high header_high;
  192. } p;
  193. u64 full;
  194. } __packed;
  195. /* CAUTION NOTE: All IPC message body must be multiple of 32 bits.*/
  196. /* IPC Header */
  197. union ipc_header {
  198. struct {
  199. u32 msg_id:8; /* Message ID - Max 256 Message Types */
  200. u32 str_id:5;
  201. u32 large:1; /* Large Message if large = 1 */
  202. u32 reserved:2; /* Reserved for future use */
  203. u32 data:14; /* Ack/Info for msg, size of msg in Mailbox */
  204. u32 done:1; /* bit 30 */
  205. u32 busy:1; /* bit 31 */
  206. } part;
  207. u32 full;
  208. } __packed;
  209. /* Firmware build info */
  210. struct sst_fw_build_info {
  211. unsigned char date[16]; /* Firmware build date */
  212. unsigned char time[16]; /* Firmware build time */
  213. } __packed;
  214. /* Firmware Version info */
  215. struct snd_sst_fw_version {
  216. u8 build; /* build number*/
  217. u8 minor; /* minor number*/
  218. u8 major; /* major number*/
  219. u8 type; /* build type */
  220. };
  221. struct ipc_header_fw_init {
  222. struct snd_sst_fw_version fw_version;/* Firmware version details */
  223. struct sst_fw_build_info build_info;
  224. u16 result; /* Fw init result */
  225. u8 module_id; /* Module ID in case of error */
  226. u8 debug_info; /* Debug info from Module ID in case of fail */
  227. } __packed;
  228. struct snd_sst_tstamp {
  229. u64 ring_buffer_counter; /* PB/CP: Bytes copied from/to DDR. */
  230. u64 hardware_counter; /* PB/CP: Bytes DMAed to/from SSP. */
  231. u64 frames_decoded;
  232. u64 bytes_decoded;
  233. u64 bytes_copied;
  234. u32 sampling_frequency;
  235. u32 channel_peak[8];
  236. } __packed;
  237. /* Stream type params struture for Alloc stream */
  238. struct snd_sst_str_type {
  239. u8 codec_type; /* Codec type */
  240. u8 str_type; /* 1 = voice 2 = music */
  241. u8 operation; /* Playback or Capture */
  242. u8 protected_str; /* 0=Non DRM, 1=DRM */
  243. u8 time_slots;
  244. u8 reserved; /* Reserved */
  245. u16 result; /* Result used for acknowledgment */
  246. } __packed;
  247. /* Library info structure */
  248. struct module_info {
  249. u32 lib_version;
  250. u32 lib_type;/*TBD- KLOCKWORK u8 lib_type;*/
  251. u32 media_type;
  252. u8 lib_name[12];
  253. u32 lib_caps;
  254. unsigned char b_date[16]; /* Lib build date */
  255. unsigned char b_time[16]; /* Lib build time */
  256. } __packed;
  257. /* Library slot info */
  258. struct lib_slot_info {
  259. u8 slot_num; /* 1 or 2 */
  260. u8 reserved1;
  261. u16 reserved2;
  262. u32 iram_size; /* slot size in IRAM */
  263. u32 dram_size; /* slot size in DRAM */
  264. u32 iram_offset; /* starting offset of slot in IRAM */
  265. u32 dram_offset; /* starting offset of slot in DRAM */
  266. } __packed;
  267. struct snd_ppp_mixer_params {
  268. __u32 type; /*Type of the parameter */
  269. __u32 size;
  270. __u32 input_stream_bitmap; /*Input stream Bit Map*/
  271. } __packed;
  272. struct snd_sst_lib_download {
  273. struct module_info lib_info; /* library info type, capabilities etc */
  274. struct lib_slot_info slot_info; /* slot info to be downloaded */
  275. u32 mod_entry_pt;
  276. };
  277. struct snd_sst_lib_download_info {
  278. struct snd_sst_lib_download dload_lib;
  279. u16 result; /* Result used for acknowledgment */
  280. u8 pvt_id; /* Private ID */
  281. u8 reserved; /* for alignment */
  282. };
  283. struct snd_pcm_params {
  284. u8 num_chan; /* 1=Mono, 2=Stereo */
  285. u8 pcm_wd_sz; /* 16/24 - bit*/
  286. u8 use_offload_path; /* 0-PCM using period elpased & ALSA interfaces
  287. 1-PCM stream via compressed interface */
  288. u8 reserved2;
  289. u32 sfreq; /* Sampling rate in Hz */
  290. u8 channel_map[8];
  291. } __packed;
  292. /* MP3 Music Parameters Message */
  293. struct snd_mp3_params {
  294. u8 num_chan; /* 1=Mono, 2=Stereo */
  295. u8 pcm_wd_sz; /* 16/24 - bit*/
  296. u8 crc_check; /* crc_check - disable (0) or enable (1) */
  297. u8 reserved1; /* unused*/
  298. u16 reserved2; /* Unused */
  299. } __packed;
  300. #define AAC_BIT_STREAM_ADTS 0
  301. #define AAC_BIT_STREAM_ADIF 1
  302. #define AAC_BIT_STREAM_RAW 2
  303. /* AAC Music Parameters Message */
  304. struct snd_aac_params {
  305. u8 num_chan; /* 1=Mono, 2=Stereo*/
  306. u8 pcm_wd_sz; /* 16/24 - bit*/
  307. u8 bdownsample; /*SBR downsampling 0 - disable 1 -enabled AAC+ only */
  308. u8 bs_format; /* input bit stream format adts=0, adif=1, raw=2 */
  309. u16 reser2;
  310. u32 externalsr; /*sampling rate of basic AAC raw bit stream*/
  311. u8 sbr_signalling;/*disable/enable/set automode the SBR tool.AAC+*/
  312. u8 reser1;
  313. u16 reser3;
  314. } __packed;
  315. /* WMA Music Parameters Message */
  316. struct snd_wma_params {
  317. u8 num_chan; /* 1=Mono, 2=Stereo */
  318. u8 pcm_wd_sz; /* 16/24 - bit*/
  319. u16 reserved1;
  320. u32 brate; /* Use the hard coded value. */
  321. u32 sfreq; /* Sampling freq eg. 8000, 441000, 48000 */
  322. u32 channel_mask; /* Channel Mask */
  323. u16 format_tag; /* Format Tag */
  324. u16 block_align; /* packet size */
  325. u16 wma_encode_opt;/* Encoder option */
  326. u8 op_align; /* op align 0- 16 bit, 1- MSB, 2 LSB */
  327. u8 reserved; /* reserved */
  328. } __packed;
  329. /* Codec params struture */
  330. union snd_sst_codec_params {
  331. struct snd_pcm_params pcm_params;
  332. struct snd_mp3_params mp3_params;
  333. struct snd_aac_params aac_params;
  334. struct snd_wma_params wma_params;
  335. } __packed;
  336. /* Address and size info of a frame buffer */
  337. struct sst_address_info {
  338. u32 addr; /* Address at IA */
  339. u32 size; /* Size of the buffer */
  340. };
  341. struct snd_sst_alloc_params_ext {
  342. __u16 sg_count;
  343. __u16 reserved;
  344. __u32 frag_size; /*Number of samples after which period elapsed
  345. message is sent valid only if path = 0*/
  346. struct sst_address_info ring_buf_info[8];
  347. };
  348. struct snd_sst_stream_params {
  349. union snd_sst_codec_params uc;
  350. } __packed;
  351. struct snd_sst_params {
  352. u32 result;
  353. u32 stream_id;
  354. u8 codec;
  355. u8 ops;
  356. u8 stream_type;
  357. u8 device_type;
  358. u8 task;
  359. struct snd_sst_stream_params sparams;
  360. struct snd_sst_alloc_params_ext aparams;
  361. };
  362. struct snd_sst_alloc_mrfld {
  363. u16 codec_type;
  364. u8 operation;
  365. u8 sg_count;
  366. struct sst_address_info ring_buf_info[8];
  367. u32 frag_size;
  368. u32 ts;
  369. struct snd_sst_stream_params codec_params;
  370. } __packed;
  371. /* Alloc stream params structure */
  372. struct snd_sst_alloc_params {
  373. struct snd_sst_str_type str_type;
  374. struct snd_sst_stream_params stream_params;
  375. struct snd_sst_alloc_params_ext alloc_params;
  376. } __packed;
  377. /* Alloc stream response message */
  378. struct snd_sst_alloc_response {
  379. struct snd_sst_str_type str_type; /* Stream type for allocation */
  380. struct snd_sst_lib_download lib_dnld; /* Valid only for codec dnld */
  381. };
  382. /* Drop response */
  383. struct snd_sst_drop_response {
  384. u32 result;
  385. u32 bytes;
  386. };
  387. struct snd_sst_async_msg {
  388. u32 msg_id; /* Async msg id */
  389. u32 payload[0];
  390. };
  391. struct snd_sst_async_err_msg {
  392. u32 fw_resp; /* Firmware Result */
  393. u32 lib_resp; /*Library result */
  394. } __packed;
  395. struct snd_sst_vol {
  396. u32 stream_id;
  397. s32 volume;
  398. u32 ramp_duration;
  399. u32 ramp_type; /* Ramp type, default=0 */
  400. };
  401. /* Gain library parameters for mrfld
  402. * based on DSP command spec v0.82
  403. */
  404. struct snd_sst_gain_v2 {
  405. u16 gain_cell_num; /* num of gain cells to modify*/
  406. u8 cell_nbr_idx; /* instance index*/
  407. u8 cell_path_idx; /* pipe-id */
  408. u16 module_id; /*module id */
  409. u16 left_cell_gain; /* left gain value in dB*/
  410. u16 right_cell_gain; /* right gain value in dB*/
  411. u16 gain_time_const; /* gain time constant*/
  412. } __packed;
  413. struct snd_sst_mute {
  414. u32 stream_id;
  415. u32 mute;
  416. };
  417. struct snd_sst_runtime_params {
  418. u8 type;
  419. u8 str_id;
  420. u8 size;
  421. u8 rsvd;
  422. void *addr;
  423. } __packed;
  424. enum stream_param_type {
  425. SST_SET_TIME_SLOT = 0,
  426. SST_SET_CHANNEL_INFO = 1,
  427. OTHERS = 2, /*reserved for future params*/
  428. };
  429. /* CSV Voice call routing structure */
  430. struct snd_sst_control_routing {
  431. u8 control; /* 0=start, 1=Stop */
  432. u8 reserved[3]; /* Reserved- for 32 bit alignment */
  433. };
  434. struct ipc_post {
  435. struct list_head node;
  436. union ipc_header header; /* driver specific */
  437. bool is_large;
  438. bool is_process_reply;
  439. union ipc_header_mrfld mrfld_header;
  440. char *mailbox_data;
  441. };
  442. struct snd_sst_ctxt_params {
  443. u32 address; /* Physical Address in DDR where the context is stored */
  444. u32 size; /* size of the context */
  445. };
  446. struct snd_sst_lpe_log_params {
  447. u8 dbg_type;
  448. u8 module_id;
  449. u8 log_level;
  450. u8 reserved;
  451. } __packed;
  452. enum snd_sst_bytes_type {
  453. SND_SST_BYTES_SET = 0x1,
  454. SND_SST_BYTES_GET = 0x2,
  455. };
  456. struct snd_sst_bytes_v2 {
  457. u8 type;
  458. u8 ipc_msg;
  459. u8 block;
  460. u8 task_id;
  461. u8 pipe_id;
  462. u8 rsvd;
  463. u16 len;
  464. char bytes[0];
  465. };
  466. #define MAX_VTSV_FILES 2
  467. struct snd_sst_vtsv_info {
  468. struct sst_address_info vfiles[MAX_VTSV_FILES];
  469. } __packed;
  470. #endif /* __SST_MFLD_DSP_H__ */