skl-topology.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. /*
  2. * skl_topology.h - Intel HDA Platform topology header file
  3. *
  4. * Copyright (C) 2014-15 Intel Corp
  5. * Author: Jeeja KP <jeeja.kp@intel.com>
  6. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. *
  19. */
  20. #ifndef __SKL_TOPOLOGY_H__
  21. #define __SKL_TOPOLOGY_H__
  22. #include <linux/types.h>
  23. #include <sound/hdaudio_ext.h>
  24. #include <sound/soc.h>
  25. #include "skl.h"
  26. #include "skl-tplg-interface.h"
  27. #define BITS_PER_BYTE 8
  28. #define MAX_TS_GROUPS 8
  29. #define MAX_DMIC_TS_GROUPS 4
  30. #define MAX_FIXED_DMIC_PARAMS_SIZE 727
  31. /* Maximum number of coefficients up down mixer module */
  32. #define UP_DOWN_MIXER_MAX_COEFF 6
  33. #define MODULE_MAX_IN_PINS 8
  34. #define MODULE_MAX_OUT_PINS 8
  35. enum skl_channel_index {
  36. SKL_CHANNEL_LEFT = 0,
  37. SKL_CHANNEL_RIGHT = 1,
  38. SKL_CHANNEL_CENTER = 2,
  39. SKL_CHANNEL_LEFT_SURROUND = 3,
  40. SKL_CHANNEL_CENTER_SURROUND = 3,
  41. SKL_CHANNEL_RIGHT_SURROUND = 4,
  42. SKL_CHANNEL_LFE = 7,
  43. SKL_CHANNEL_INVALID = 0xF,
  44. };
  45. enum skl_bitdepth {
  46. SKL_DEPTH_8BIT = 8,
  47. SKL_DEPTH_16BIT = 16,
  48. SKL_DEPTH_24BIT = 24,
  49. SKL_DEPTH_32BIT = 32,
  50. SKL_DEPTH_INVALID
  51. };
  52. enum skl_s_freq {
  53. SKL_FS_8000 = 8000,
  54. SKL_FS_11025 = 11025,
  55. SKL_FS_12000 = 12000,
  56. SKL_FS_16000 = 16000,
  57. SKL_FS_22050 = 22050,
  58. SKL_FS_24000 = 24000,
  59. SKL_FS_32000 = 32000,
  60. SKL_FS_44100 = 44100,
  61. SKL_FS_48000 = 48000,
  62. SKL_FS_64000 = 64000,
  63. SKL_FS_88200 = 88200,
  64. SKL_FS_96000 = 96000,
  65. SKL_FS_128000 = 128000,
  66. SKL_FS_176400 = 176400,
  67. SKL_FS_192000 = 192000,
  68. SKL_FS_INVALID
  69. };
  70. enum skl_widget_type {
  71. SKL_WIDGET_VMIXER = 1,
  72. SKL_WIDGET_MIXER = 2,
  73. SKL_WIDGET_PGA = 3,
  74. SKL_WIDGET_MUX = 4
  75. };
  76. struct skl_audio_data_format {
  77. enum skl_s_freq s_freq;
  78. enum skl_bitdepth bit_depth;
  79. u32 channel_map;
  80. enum skl_ch_cfg ch_cfg;
  81. enum skl_interleaving interleaving;
  82. u8 number_of_channels;
  83. u8 valid_bit_depth;
  84. u8 sample_type;
  85. u8 reserved[1];
  86. } __packed;
  87. struct skl_base_cfg {
  88. u32 cps;
  89. u32 ibs;
  90. u32 obs;
  91. u32 is_pages;
  92. struct skl_audio_data_format audio_fmt;
  93. };
  94. struct skl_cpr_gtw_cfg {
  95. u32 node_id;
  96. u32 dma_buffer_size;
  97. u32 config_length;
  98. /* not mandatory; required only for DMIC/I2S */
  99. u32 config_data[1];
  100. } __packed;
  101. struct skl_i2s_config_blob {
  102. u32 gateway_attrib;
  103. u32 tdm_ts_group[8];
  104. u32 ssc0;
  105. u32 ssc1;
  106. u32 sscto;
  107. u32 sspsp;
  108. u32 sstsa;
  109. u32 ssrsa;
  110. u32 ssc2;
  111. u32 sspsp2;
  112. u32 ssc3;
  113. u32 ssioc;
  114. u32 mdivc;
  115. u32 mdivr;
  116. } __packed;
  117. struct skl_dma_control {
  118. u32 node_id;
  119. u32 config_length;
  120. u32 config_data[0];
  121. } __packed;
  122. struct skl_cpr_cfg {
  123. struct skl_base_cfg base_cfg;
  124. struct skl_audio_data_format out_fmt;
  125. u32 cpr_feature_mask;
  126. struct skl_cpr_gtw_cfg gtw_cfg;
  127. } __packed;
  128. struct skl_src_module_cfg {
  129. struct skl_base_cfg base_cfg;
  130. enum skl_s_freq src_cfg;
  131. } __packed;
  132. struct notification_mask {
  133. u32 notify;
  134. u32 enable;
  135. } __packed;
  136. struct skl_up_down_mixer_cfg {
  137. struct skl_base_cfg base_cfg;
  138. enum skl_ch_cfg out_ch_cfg;
  139. /* This should be set to 1 if user coefficients are required */
  140. u32 coeff_sel;
  141. /* Pass the user coeff in this array */
  142. s32 coeff[UP_DOWN_MIXER_MAX_COEFF];
  143. } __packed;
  144. struct skl_algo_cfg {
  145. struct skl_base_cfg base_cfg;
  146. char params[0];
  147. } __packed;
  148. struct skl_base_outfmt_cfg {
  149. struct skl_base_cfg base_cfg;
  150. struct skl_audio_data_format out_fmt;
  151. } __packed;
  152. enum skl_dma_type {
  153. SKL_DMA_HDA_HOST_OUTPUT_CLASS = 0,
  154. SKL_DMA_HDA_HOST_INPUT_CLASS = 1,
  155. SKL_DMA_HDA_HOST_INOUT_CLASS = 2,
  156. SKL_DMA_HDA_LINK_OUTPUT_CLASS = 8,
  157. SKL_DMA_HDA_LINK_INPUT_CLASS = 9,
  158. SKL_DMA_HDA_LINK_INOUT_CLASS = 0xA,
  159. SKL_DMA_DMIC_LINK_INPUT_CLASS = 0xB,
  160. SKL_DMA_I2S_LINK_OUTPUT_CLASS = 0xC,
  161. SKL_DMA_I2S_LINK_INPUT_CLASS = 0xD,
  162. };
  163. union skl_ssp_dma_node {
  164. u8 val;
  165. struct {
  166. u8 time_slot_index:4;
  167. u8 i2s_instance:4;
  168. } dma_node;
  169. };
  170. union skl_connector_node_id {
  171. u32 val;
  172. struct {
  173. u32 vindex:8;
  174. u32 dma_type:4;
  175. u32 rsvd:20;
  176. } node;
  177. };
  178. struct skl_module_fmt {
  179. u32 channels;
  180. u32 s_freq;
  181. u32 bit_depth;
  182. u32 valid_bit_depth;
  183. u32 ch_cfg;
  184. u32 interleaving_style;
  185. u32 sample_type;
  186. u32 ch_map;
  187. };
  188. struct skl_module_cfg;
  189. struct skl_mod_inst_map {
  190. u16 mod_id;
  191. u16 inst_id;
  192. };
  193. struct skl_kpb_params {
  194. u32 num_modules;
  195. struct skl_mod_inst_map map[0];
  196. };
  197. struct skl_module_inst_id {
  198. int module_id;
  199. u32 instance_id;
  200. int pvt_id;
  201. };
  202. enum skl_module_pin_state {
  203. SKL_PIN_UNBIND = 0,
  204. SKL_PIN_BIND_DONE = 1,
  205. };
  206. struct skl_module_pin {
  207. struct skl_module_inst_id id;
  208. bool is_dynamic;
  209. bool in_use;
  210. enum skl_module_pin_state pin_state;
  211. struct skl_module_cfg *tgt_mcfg;
  212. };
  213. struct skl_specific_cfg {
  214. u32 set_params;
  215. u32 param_id;
  216. u32 caps_size;
  217. u32 *caps;
  218. };
  219. enum skl_pipe_state {
  220. SKL_PIPE_INVALID = 0,
  221. SKL_PIPE_CREATED = 1,
  222. SKL_PIPE_PAUSED = 2,
  223. SKL_PIPE_STARTED = 3,
  224. SKL_PIPE_RESET = 4
  225. };
  226. struct skl_pipe_module {
  227. struct snd_soc_dapm_widget *w;
  228. struct list_head node;
  229. };
  230. struct skl_pipe_params {
  231. u8 host_dma_id;
  232. u8 link_dma_id;
  233. u32 ch;
  234. u32 s_freq;
  235. u32 s_fmt;
  236. u8 linktype;
  237. int stream;
  238. };
  239. struct skl_pipe {
  240. u8 ppl_id;
  241. u8 pipe_priority;
  242. u16 conn_type;
  243. u32 memory_pages;
  244. struct skl_pipe_params *p_params;
  245. enum skl_pipe_state state;
  246. struct list_head w_list;
  247. bool passthru;
  248. };
  249. enum skl_module_state {
  250. SKL_MODULE_UNINIT = 0,
  251. SKL_MODULE_LOADED = 1,
  252. SKL_MODULE_INIT_DONE = 2,
  253. SKL_MODULE_BIND_DONE = 3,
  254. SKL_MODULE_UNLOADED = 4,
  255. };
  256. struct skl_module_cfg {
  257. u8 guid[16];
  258. struct skl_module_inst_id id;
  259. u8 domain;
  260. bool homogenous_inputs;
  261. bool homogenous_outputs;
  262. struct skl_module_fmt in_fmt[MODULE_MAX_IN_PINS];
  263. struct skl_module_fmt out_fmt[MODULE_MAX_OUT_PINS];
  264. u8 max_in_queue;
  265. u8 max_out_queue;
  266. u8 in_queue_mask;
  267. u8 out_queue_mask;
  268. u8 in_queue;
  269. u8 out_queue;
  270. u32 mcps;
  271. u32 ibs;
  272. u32 obs;
  273. u8 is_loadable;
  274. u8 core_id;
  275. u8 dev_type;
  276. u8 dma_id;
  277. u8 time_slot;
  278. u32 params_fixup;
  279. u32 converter;
  280. u32 vbus_id;
  281. u32 mem_pages;
  282. struct skl_module_pin *m_in_pin;
  283. struct skl_module_pin *m_out_pin;
  284. enum skl_module_type m_type;
  285. enum skl_hw_conn_type hw_conn_type;
  286. enum skl_module_state m_state;
  287. struct skl_pipe *pipe;
  288. struct skl_specific_cfg formats_config;
  289. };
  290. struct skl_algo_data {
  291. u32 param_id;
  292. u32 set_params;
  293. u32 max;
  294. u32 size;
  295. char *params;
  296. };
  297. struct skl_pipeline {
  298. struct skl_pipe *pipe;
  299. struct list_head node;
  300. };
  301. static inline struct skl *get_skl_ctx(struct device *dev)
  302. {
  303. struct hdac_ext_bus *ebus = dev_get_drvdata(dev);
  304. return ebus_to_skl(ebus);
  305. }
  306. int skl_tplg_be_update_params(struct snd_soc_dai *dai,
  307. struct skl_pipe_params *params);
  308. int skl_dsp_set_dma_control(struct skl_sst *ctx,
  309. struct skl_module_cfg *mconfig);
  310. void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai,
  311. struct skl_pipe_params *params, int stream);
  312. int skl_tplg_init(struct snd_soc_platform *platform,
  313. struct hdac_ext_bus *ebus);
  314. struct skl_module_cfg *skl_tplg_fe_get_cpr_module(
  315. struct snd_soc_dai *dai, int stream);
  316. int skl_tplg_update_pipe_params(struct device *dev,
  317. struct skl_module_cfg *mconfig, struct skl_pipe_params *params);
  318. int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe);
  319. int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  320. int skl_pause_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  321. int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  322. int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  323. int skl_reset_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  324. int skl_init_module(struct skl_sst *ctx, struct skl_module_cfg *module_config);
  325. int skl_bind_modules(struct skl_sst *ctx, struct skl_module_cfg
  326. *src_module, struct skl_module_cfg *dst_module);
  327. int skl_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
  328. *src_module, struct skl_module_cfg *dst_module);
  329. int skl_set_module_params(struct skl_sst *ctx, u32 *params, int size,
  330. u32 param_id, struct skl_module_cfg *mcfg);
  331. int skl_get_module_params(struct skl_sst *ctx, u32 *params, int size,
  332. u32 param_id, struct skl_module_cfg *mcfg);
  333. struct skl_module_cfg *skl_tplg_be_get_cpr_module(struct snd_soc_dai *dai,
  334. int stream);
  335. enum skl_bitdepth skl_get_bit_depth(int params);
  336. #endif