skl-topology.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * skl_topology.h - Intel HDA Platform topology header file
  4. *
  5. * Copyright (C) 2014-15 Intel Corp
  6. * Author: Jeeja KP <[email protected]>
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10. */
  11. #ifndef __SKL_TOPOLOGY_H__
  12. #define __SKL_TOPOLOGY_H__
  13. #include <linux/types.h>
  14. #include <sound/hdaudio_ext.h>
  15. #include <sound/soc.h>
  16. #include <uapi/sound/skl-tplg-interface.h>
  17. #include "skl.h"
  18. #define BITS_PER_BYTE 8
  19. #define MAX_TS_GROUPS 8
  20. #define MAX_DMIC_TS_GROUPS 4
  21. #define MAX_FIXED_DMIC_PARAMS_SIZE 727
  22. /* Maximum number of coefficients up down mixer module */
  23. #define UP_DOWN_MIXER_MAX_COEFF 8
  24. #define MODULE_MAX_IN_PINS 8
  25. #define MODULE_MAX_OUT_PINS 8
  26. #define SKL_MIC_CH_SUPPORT 4
  27. #define SKL_MIC_MAX_CH_SUPPORT 8
  28. #define SKL_DEFAULT_MIC_SEL_GAIN 0x3FF
  29. #define SKL_MIC_SEL_SWITCH 0x3
  30. #define SKL_OUTPUT_PIN 0
  31. #define SKL_INPUT_PIN 1
  32. #define SKL_MAX_PATH_CONFIGS 8
  33. #define SKL_MAX_MODULES_IN_PIPE 8
  34. #define SKL_MAX_MODULE_FORMATS 32
  35. #define SKL_MAX_MODULE_RESOURCES 32
  36. enum skl_channel_index {
  37. SKL_CHANNEL_LEFT = 0,
  38. SKL_CHANNEL_RIGHT = 1,
  39. SKL_CHANNEL_CENTER = 2,
  40. SKL_CHANNEL_LEFT_SURROUND = 3,
  41. SKL_CHANNEL_CENTER_SURROUND = 3,
  42. SKL_CHANNEL_RIGHT_SURROUND = 4,
  43. SKL_CHANNEL_LFE = 7,
  44. SKL_CHANNEL_INVALID = 0xF,
  45. };
  46. enum skl_bitdepth {
  47. SKL_DEPTH_8BIT = 8,
  48. SKL_DEPTH_16BIT = 16,
  49. SKL_DEPTH_24BIT = 24,
  50. SKL_DEPTH_32BIT = 32,
  51. SKL_DEPTH_INVALID
  52. };
  53. enum skl_s_freq {
  54. SKL_FS_8000 = 8000,
  55. SKL_FS_11025 = 11025,
  56. SKL_FS_12000 = 12000,
  57. SKL_FS_16000 = 16000,
  58. SKL_FS_22050 = 22050,
  59. SKL_FS_24000 = 24000,
  60. SKL_FS_32000 = 32000,
  61. SKL_FS_44100 = 44100,
  62. SKL_FS_48000 = 48000,
  63. SKL_FS_64000 = 64000,
  64. SKL_FS_88200 = 88200,
  65. SKL_FS_96000 = 96000,
  66. SKL_FS_128000 = 128000,
  67. SKL_FS_176400 = 176400,
  68. SKL_FS_192000 = 192000,
  69. SKL_FS_INVALID
  70. };
  71. #define SKL_MAX_PARAMS_TYPES 4
  72. enum skl_widget_type {
  73. SKL_WIDGET_VMIXER = 1,
  74. SKL_WIDGET_MIXER = 2,
  75. SKL_WIDGET_PGA = 3,
  76. SKL_WIDGET_MUX = 4
  77. };
  78. struct skl_audio_data_format {
  79. enum skl_s_freq s_freq;
  80. enum skl_bitdepth bit_depth;
  81. u32 channel_map;
  82. enum skl_ch_cfg ch_cfg;
  83. enum skl_interleaving interleaving;
  84. u8 number_of_channels;
  85. u8 valid_bit_depth;
  86. u8 sample_type;
  87. u8 reserved;
  88. } __packed;
  89. struct skl_base_cfg {
  90. u32 cpc;
  91. u32 ibs;
  92. u32 obs;
  93. u32 is_pages;
  94. struct skl_audio_data_format audio_fmt;
  95. };
  96. struct skl_cpr_gtw_cfg {
  97. u32 node_id;
  98. u32 dma_buffer_size;
  99. u32 config_length;
  100. /* not mandatory; required only for DMIC/I2S */
  101. u32 config_data[1];
  102. } __packed;
  103. struct skl_dma_control {
  104. u32 node_id;
  105. u32 config_length;
  106. u32 config_data[];
  107. } __packed;
  108. struct skl_cpr_cfg {
  109. struct skl_base_cfg base_cfg;
  110. struct skl_audio_data_format out_fmt;
  111. u32 cpr_feature_mask;
  112. struct skl_cpr_gtw_cfg gtw_cfg;
  113. } __packed;
  114. struct skl_cpr_pin_fmt {
  115. u32 sink_id;
  116. struct skl_audio_data_format src_fmt;
  117. struct skl_audio_data_format dst_fmt;
  118. } __packed;
  119. struct skl_src_module_cfg {
  120. struct skl_base_cfg base_cfg;
  121. enum skl_s_freq src_cfg;
  122. } __packed;
  123. struct skl_up_down_mixer_cfg {
  124. struct skl_base_cfg base_cfg;
  125. enum skl_ch_cfg out_ch_cfg;
  126. /* This should be set to 1 if user coefficients are required */
  127. u32 coeff_sel;
  128. /* Pass the user coeff in this array */
  129. s32 coeff[UP_DOWN_MIXER_MAX_COEFF];
  130. u32 ch_map;
  131. } __packed;
  132. struct skl_pin_format {
  133. u32 pin_idx;
  134. u32 buf_size;
  135. struct skl_audio_data_format audio_fmt;
  136. } __packed;
  137. struct skl_base_cfg_ext {
  138. u16 nr_input_pins;
  139. u16 nr_output_pins;
  140. u8 reserved[8];
  141. u32 priv_param_length;
  142. /* Input pin formats followed by output ones. */
  143. struct skl_pin_format pins_fmt[];
  144. } __packed;
  145. struct skl_algo_cfg {
  146. struct skl_base_cfg base_cfg;
  147. char params[];
  148. } __packed;
  149. struct skl_base_outfmt_cfg {
  150. struct skl_base_cfg base_cfg;
  151. struct skl_audio_data_format out_fmt;
  152. } __packed;
  153. enum skl_dma_type {
  154. SKL_DMA_HDA_HOST_OUTPUT_CLASS = 0,
  155. SKL_DMA_HDA_HOST_INPUT_CLASS = 1,
  156. SKL_DMA_HDA_HOST_INOUT_CLASS = 2,
  157. SKL_DMA_HDA_LINK_OUTPUT_CLASS = 8,
  158. SKL_DMA_HDA_LINK_INPUT_CLASS = 9,
  159. SKL_DMA_HDA_LINK_INOUT_CLASS = 0xA,
  160. SKL_DMA_DMIC_LINK_INPUT_CLASS = 0xB,
  161. SKL_DMA_I2S_LINK_OUTPUT_CLASS = 0xC,
  162. SKL_DMA_I2S_LINK_INPUT_CLASS = 0xD,
  163. };
  164. union skl_ssp_dma_node {
  165. u8 val;
  166. struct {
  167. u8 time_slot_index:4;
  168. u8 i2s_instance:4;
  169. } dma_node;
  170. };
  171. union skl_connector_node_id {
  172. u32 val;
  173. struct {
  174. u32 vindex:8;
  175. u32 dma_type:4;
  176. u32 rsvd:20;
  177. } node;
  178. };
  179. struct skl_module_fmt {
  180. u32 channels;
  181. u32 s_freq;
  182. u32 bit_depth;
  183. u32 valid_bit_depth;
  184. u32 ch_cfg;
  185. u32 interleaving_style;
  186. u32 sample_type;
  187. u32 ch_map;
  188. };
  189. struct skl_module_cfg;
  190. struct skl_mod_inst_map {
  191. u16 mod_id;
  192. u16 inst_id;
  193. };
  194. struct skl_uuid_inst_map {
  195. u16 inst_id;
  196. u16 reserved;
  197. guid_t mod_uuid;
  198. } __packed;
  199. struct skl_kpb_params {
  200. u32 num_modules;
  201. union {
  202. DECLARE_FLEX_ARRAY(struct skl_mod_inst_map, map);
  203. DECLARE_FLEX_ARRAY(struct skl_uuid_inst_map, map_uuid);
  204. } u;
  205. };
  206. struct skl_module_inst_id {
  207. guid_t mod_uuid;
  208. int module_id;
  209. u32 instance_id;
  210. int pvt_id;
  211. };
  212. enum skl_module_pin_state {
  213. SKL_PIN_UNBIND = 0,
  214. SKL_PIN_BIND_DONE = 1,
  215. };
  216. struct skl_module_pin {
  217. struct skl_module_inst_id id;
  218. bool is_dynamic;
  219. bool in_use;
  220. enum skl_module_pin_state pin_state;
  221. struct skl_module_cfg *tgt_mcfg;
  222. };
  223. struct skl_specific_cfg {
  224. u32 set_params;
  225. u32 param_id;
  226. u32 caps_size;
  227. u32 *caps;
  228. };
  229. enum skl_pipe_state {
  230. SKL_PIPE_INVALID = 0,
  231. SKL_PIPE_CREATED = 1,
  232. SKL_PIPE_PAUSED = 2,
  233. SKL_PIPE_STARTED = 3,
  234. SKL_PIPE_RESET = 4
  235. };
  236. struct skl_pipe_module {
  237. struct snd_soc_dapm_widget *w;
  238. struct list_head node;
  239. };
  240. struct skl_pipe_params {
  241. u8 host_dma_id;
  242. u8 link_dma_id;
  243. u32 ch;
  244. u32 s_freq;
  245. u32 s_fmt;
  246. u32 s_cont;
  247. u8 linktype;
  248. snd_pcm_format_t format;
  249. int link_index;
  250. int stream;
  251. unsigned int host_bps;
  252. unsigned int link_bps;
  253. };
  254. struct skl_pipe_fmt {
  255. u32 freq;
  256. u8 channels;
  257. u8 bps;
  258. };
  259. struct skl_pipe_mcfg {
  260. u8 res_idx;
  261. u8 fmt_idx;
  262. };
  263. struct skl_path_config {
  264. u8 mem_pages;
  265. struct skl_pipe_fmt in_fmt;
  266. struct skl_pipe_fmt out_fmt;
  267. };
  268. struct skl_pipe {
  269. u8 ppl_id;
  270. u8 pipe_priority;
  271. u16 conn_type;
  272. u32 memory_pages;
  273. u8 lp_mode;
  274. struct skl_pipe_params *p_params;
  275. enum skl_pipe_state state;
  276. u8 direction;
  277. u8 cur_config_idx;
  278. u8 nr_cfgs;
  279. struct skl_path_config configs[SKL_MAX_PATH_CONFIGS];
  280. struct list_head w_list;
  281. bool passthru;
  282. u32 pipe_config_idx;
  283. };
  284. enum skl_module_state {
  285. SKL_MODULE_UNINIT = 0,
  286. SKL_MODULE_INIT_DONE = 1,
  287. SKL_MODULE_BIND_DONE = 2,
  288. };
  289. enum d0i3_capability {
  290. SKL_D0I3_NONE = 0,
  291. SKL_D0I3_STREAMING = 1,
  292. SKL_D0I3_NON_STREAMING = 2,
  293. };
  294. struct skl_module_pin_fmt {
  295. u8 id;
  296. struct skl_module_fmt fmt;
  297. };
  298. struct skl_module_iface {
  299. u8 fmt_idx;
  300. u8 nr_in_fmt;
  301. u8 nr_out_fmt;
  302. struct skl_module_pin_fmt inputs[MAX_IN_QUEUE];
  303. struct skl_module_pin_fmt outputs[MAX_OUT_QUEUE];
  304. };
  305. struct skl_module_pin_resources {
  306. u8 pin_index;
  307. u32 buf_size;
  308. };
  309. struct skl_module_res {
  310. u8 id;
  311. u32 is_pages;
  312. u32 ibs;
  313. u32 obs;
  314. u32 dma_buffer_size;
  315. u32 cpc;
  316. u8 nr_input_pins;
  317. u8 nr_output_pins;
  318. struct skl_module_pin_resources input[MAX_IN_QUEUE];
  319. struct skl_module_pin_resources output[MAX_OUT_QUEUE];
  320. };
  321. struct skl_module {
  322. guid_t uuid;
  323. u8 loadable;
  324. u8 input_pin_type;
  325. u8 output_pin_type;
  326. u8 max_input_pins;
  327. u8 max_output_pins;
  328. u8 nr_resources;
  329. u8 nr_interfaces;
  330. struct skl_module_res resources[SKL_MAX_MODULE_RESOURCES];
  331. struct skl_module_iface formats[SKL_MAX_MODULE_FORMATS];
  332. };
  333. struct skl_module_cfg {
  334. u8 guid[16];
  335. struct skl_module_inst_id id;
  336. struct skl_module *module;
  337. int res_idx;
  338. int fmt_idx;
  339. int fmt_cfg_idx;
  340. u8 domain;
  341. bool homogenous_inputs;
  342. bool homogenous_outputs;
  343. struct skl_module_fmt in_fmt[MODULE_MAX_IN_PINS];
  344. struct skl_module_fmt out_fmt[MODULE_MAX_OUT_PINS];
  345. u8 max_in_queue;
  346. u8 max_out_queue;
  347. u8 in_queue_mask;
  348. u8 out_queue_mask;
  349. u8 in_queue;
  350. u8 out_queue;
  351. u8 is_loadable;
  352. u8 core_id;
  353. u8 dev_type;
  354. u8 dma_id;
  355. u8 time_slot;
  356. u8 dmic_ch_combo_index;
  357. u32 dmic_ch_type;
  358. u32 params_fixup;
  359. u32 converter;
  360. u32 vbus_id;
  361. u32 mem_pages;
  362. enum d0i3_capability d0i3_caps;
  363. u32 dma_buffer_size; /* in milli seconds */
  364. struct skl_module_pin *m_in_pin;
  365. struct skl_module_pin *m_out_pin;
  366. enum skl_module_type m_type;
  367. enum skl_hw_conn_type hw_conn_type;
  368. enum skl_module_state m_state;
  369. struct skl_pipe *pipe;
  370. struct skl_specific_cfg formats_config[SKL_MAX_PARAMS_TYPES];
  371. struct skl_pipe_mcfg mod_cfg[SKL_MAX_MODULES_IN_PIPE];
  372. };
  373. struct skl_algo_data {
  374. u32 param_id;
  375. u32 set_params;
  376. u32 max;
  377. u32 size;
  378. char *params;
  379. };
  380. struct skl_pipeline {
  381. struct skl_pipe *pipe;
  382. struct list_head node;
  383. };
  384. struct skl_module_deferred_bind {
  385. struct skl_module_cfg *src;
  386. struct skl_module_cfg *dst;
  387. struct list_head node;
  388. };
  389. struct skl_mic_sel_config {
  390. u16 mic_switch;
  391. u16 flags;
  392. u16 blob[SKL_MIC_MAX_CH_SUPPORT][SKL_MIC_MAX_CH_SUPPORT];
  393. } __packed;
  394. enum skl_channel {
  395. SKL_CH_MONO = 1,
  396. SKL_CH_STEREO = 2,
  397. SKL_CH_TRIO = 3,
  398. SKL_CH_QUATRO = 4,
  399. };
  400. static inline struct skl_dev *get_skl_ctx(struct device *dev)
  401. {
  402. struct hdac_bus *bus = dev_get_drvdata(dev);
  403. return bus_to_skl(bus);
  404. }
  405. int skl_tplg_be_update_params(struct snd_soc_dai *dai,
  406. struct skl_pipe_params *params);
  407. int skl_dsp_set_dma_control(struct skl_dev *skl, u32 *caps,
  408. u32 caps_size, u32 node_id);
  409. void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai,
  410. struct skl_pipe_params *params, int stream);
  411. int skl_tplg_init(struct snd_soc_component *component,
  412. struct hdac_bus *bus);
  413. void skl_tplg_exit(struct snd_soc_component *component,
  414. struct hdac_bus *bus);
  415. struct skl_module_cfg *skl_tplg_fe_get_cpr_module(
  416. struct snd_soc_dai *dai, int stream);
  417. int skl_tplg_update_pipe_params(struct device *dev,
  418. struct skl_module_cfg *mconfig, struct skl_pipe_params *params);
  419. void skl_tplg_d0i3_get(struct skl_dev *skl, enum d0i3_capability caps);
  420. void skl_tplg_d0i3_put(struct skl_dev *skl, enum d0i3_capability caps);
  421. int skl_create_pipeline(struct skl_dev *skl, struct skl_pipe *pipe);
  422. int skl_run_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
  423. int skl_pause_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
  424. int skl_delete_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
  425. int skl_stop_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
  426. int skl_reset_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
  427. int skl_init_module(struct skl_dev *skl, struct skl_module_cfg *mconfig);
  428. int skl_bind_modules(struct skl_dev *skl, struct skl_module_cfg
  429. *src_mcfg, struct skl_module_cfg *dst_mcfg);
  430. int skl_unbind_modules(struct skl_dev *skl, struct skl_module_cfg
  431. *src_mcfg, struct skl_module_cfg *dst_mcfg);
  432. int skl_set_module_params(struct skl_dev *skl, u32 *params, int size,
  433. u32 param_id, struct skl_module_cfg *mcfg);
  434. int skl_get_module_params(struct skl_dev *skl, u32 *params, int size,
  435. u32 param_id, struct skl_module_cfg *mcfg);
  436. struct skl_module_cfg *skl_tplg_be_get_cpr_module(struct snd_soc_dai *dai,
  437. int stream);
  438. enum skl_bitdepth skl_get_bit_depth(int params);
  439. int skl_pcm_host_dma_prepare(struct device *dev,
  440. struct skl_pipe_params *params);
  441. int skl_pcm_link_dma_prepare(struct device *dev,
  442. struct skl_pipe_params *params);
  443. int skl_dai_load(struct snd_soc_component *cmp, int index,
  444. struct snd_soc_dai_driver *dai_drv,
  445. struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai);
  446. void skl_tplg_add_moduleid_in_bind_params(struct skl_dev *skl,
  447. struct snd_soc_dapm_widget *w);
  448. #endif