sst-mfld-dsp.h 14 KB

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