skl-topology.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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 <uapi/sound/skl-tplg-interface.h>
  26. #include "skl.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 8
  33. #define MODULE_MAX_IN_PINS 8
  34. #define MODULE_MAX_OUT_PINS 8
  35. #define SKL_MIC_CH_SUPPORT 4
  36. #define SKL_MIC_MAX_CH_SUPPORT 8
  37. #define SKL_DEFAULT_MIC_SEL_GAIN 0x3FF
  38. #define SKL_MIC_SEL_SWITCH 0x3
  39. #define SKL_OUTPUT_PIN 0
  40. #define SKL_INPUT_PIN 1
  41. #define SKL_MAX_PATH_CONFIGS 8
  42. #define SKL_MAX_MODULES_IN_PIPE 8
  43. #define SKL_MAX_MODULE_FORMATS 32
  44. #define SKL_MAX_MODULE_RESOURCES 32
  45. enum skl_channel_index {
  46. SKL_CHANNEL_LEFT = 0,
  47. SKL_CHANNEL_RIGHT = 1,
  48. SKL_CHANNEL_CENTER = 2,
  49. SKL_CHANNEL_LEFT_SURROUND = 3,
  50. SKL_CHANNEL_CENTER_SURROUND = 3,
  51. SKL_CHANNEL_RIGHT_SURROUND = 4,
  52. SKL_CHANNEL_LFE = 7,
  53. SKL_CHANNEL_INVALID = 0xF,
  54. };
  55. enum skl_bitdepth {
  56. SKL_DEPTH_8BIT = 8,
  57. SKL_DEPTH_16BIT = 16,
  58. SKL_DEPTH_24BIT = 24,
  59. SKL_DEPTH_32BIT = 32,
  60. SKL_DEPTH_INVALID
  61. };
  62. enum skl_s_freq {
  63. SKL_FS_8000 = 8000,
  64. SKL_FS_11025 = 11025,
  65. SKL_FS_12000 = 12000,
  66. SKL_FS_16000 = 16000,
  67. SKL_FS_22050 = 22050,
  68. SKL_FS_24000 = 24000,
  69. SKL_FS_32000 = 32000,
  70. SKL_FS_44100 = 44100,
  71. SKL_FS_48000 = 48000,
  72. SKL_FS_64000 = 64000,
  73. SKL_FS_88200 = 88200,
  74. SKL_FS_96000 = 96000,
  75. SKL_FS_128000 = 128000,
  76. SKL_FS_176400 = 176400,
  77. SKL_FS_192000 = 192000,
  78. SKL_FS_INVALID
  79. };
  80. enum skl_widget_type {
  81. SKL_WIDGET_VMIXER = 1,
  82. SKL_WIDGET_MIXER = 2,
  83. SKL_WIDGET_PGA = 3,
  84. SKL_WIDGET_MUX = 4
  85. };
  86. struct skl_audio_data_format {
  87. enum skl_s_freq s_freq;
  88. enum skl_bitdepth bit_depth;
  89. u32 channel_map;
  90. enum skl_ch_cfg ch_cfg;
  91. enum skl_interleaving interleaving;
  92. u8 number_of_channels;
  93. u8 valid_bit_depth;
  94. u8 sample_type;
  95. u8 reserved[1];
  96. } __packed;
  97. struct skl_base_cfg {
  98. u32 cps;
  99. u32 ibs;
  100. u32 obs;
  101. u32 is_pages;
  102. struct skl_audio_data_format audio_fmt;
  103. };
  104. struct skl_cpr_gtw_cfg {
  105. u32 node_id;
  106. u32 dma_buffer_size;
  107. u32 config_length;
  108. /* not mandatory; required only for DMIC/I2S */
  109. u32 config_data[1];
  110. } __packed;
  111. struct skl_dma_control {
  112. u32 node_id;
  113. u32 config_length;
  114. u32 config_data[0];
  115. } __packed;
  116. struct skl_cpr_cfg {
  117. struct skl_base_cfg base_cfg;
  118. struct skl_audio_data_format out_fmt;
  119. u32 cpr_feature_mask;
  120. struct skl_cpr_gtw_cfg gtw_cfg;
  121. } __packed;
  122. struct skl_cpr_pin_fmt {
  123. u32 sink_id;
  124. struct skl_audio_data_format src_fmt;
  125. struct skl_audio_data_format dst_fmt;
  126. } __packed;
  127. struct skl_src_module_cfg {
  128. struct skl_base_cfg base_cfg;
  129. enum skl_s_freq src_cfg;
  130. } __packed;
  131. struct notification_mask {
  132. u32 notify;
  133. u32 enable;
  134. } __packed;
  135. struct skl_up_down_mixer_cfg {
  136. struct skl_base_cfg base_cfg;
  137. enum skl_ch_cfg out_ch_cfg;
  138. /* This should be set to 1 if user coefficients are required */
  139. u32 coeff_sel;
  140. /* Pass the user coeff in this array */
  141. s32 coeff[UP_DOWN_MIXER_MAX_COEFF];
  142. u32 ch_map;
  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_uuid_inst_map {
  194. u16 inst_id;
  195. u16 reserved;
  196. uuid_le mod_uuid;
  197. } __packed;
  198. struct skl_kpb_params {
  199. u32 num_modules;
  200. union {
  201. struct skl_mod_inst_map map[0];
  202. struct skl_uuid_inst_map map_uuid[0];
  203. } u;
  204. };
  205. struct skl_module_inst_id {
  206. uuid_le mod_uuid;
  207. int module_id;
  208. u32 instance_id;
  209. int pvt_id;
  210. };
  211. enum skl_module_pin_state {
  212. SKL_PIN_UNBIND = 0,
  213. SKL_PIN_BIND_DONE = 1,
  214. };
  215. struct skl_module_pin {
  216. struct skl_module_inst_id id;
  217. bool is_dynamic;
  218. bool in_use;
  219. enum skl_module_pin_state pin_state;
  220. struct skl_module_cfg *tgt_mcfg;
  221. };
  222. struct skl_specific_cfg {
  223. u32 set_params;
  224. u32 param_id;
  225. u32 caps_size;
  226. u32 *caps;
  227. };
  228. enum skl_pipe_state {
  229. SKL_PIPE_INVALID = 0,
  230. SKL_PIPE_CREATED = 1,
  231. SKL_PIPE_PAUSED = 2,
  232. SKL_PIPE_STARTED = 3,
  233. SKL_PIPE_RESET = 4
  234. };
  235. struct skl_pipe_module {
  236. struct snd_soc_dapm_widget *w;
  237. struct list_head node;
  238. };
  239. struct skl_pipe_params {
  240. u8 host_dma_id;
  241. u8 link_dma_id;
  242. u32 ch;
  243. u32 s_freq;
  244. u32 s_fmt;
  245. u8 linktype;
  246. snd_pcm_format_t format;
  247. int link_index;
  248. int stream;
  249. unsigned int host_bps;
  250. unsigned int link_bps;
  251. };
  252. struct skl_pipe_fmt {
  253. u32 freq;
  254. u8 channels;
  255. u8 bps;
  256. };
  257. struct skl_pipe_mcfg {
  258. u8 res_idx;
  259. u8 fmt_idx;
  260. };
  261. struct skl_path_config {
  262. u8 mem_pages;
  263. struct skl_pipe_fmt in_fmt;
  264. struct skl_pipe_fmt out_fmt;
  265. };
  266. struct skl_pipe {
  267. u8 ppl_id;
  268. u8 pipe_priority;
  269. u16 conn_type;
  270. u32 memory_pages;
  271. u8 lp_mode;
  272. struct skl_pipe_params *p_params;
  273. enum skl_pipe_state state;
  274. u8 direction;
  275. u8 cur_config_idx;
  276. u8 nr_cfgs;
  277. struct skl_path_config configs[SKL_MAX_PATH_CONFIGS];
  278. struct list_head w_list;
  279. bool passthru;
  280. };
  281. enum skl_module_state {
  282. SKL_MODULE_UNINIT = 0,
  283. SKL_MODULE_LOADED = 1,
  284. SKL_MODULE_INIT_DONE = 2,
  285. SKL_MODULE_BIND_DONE = 3,
  286. SKL_MODULE_UNLOADED = 4,
  287. };
  288. enum d0i3_capability {
  289. SKL_D0I3_NONE = 0,
  290. SKL_D0I3_STREAMING = 1,
  291. SKL_D0I3_NON_STREAMING = 2,
  292. };
  293. struct skl_module_pin_fmt {
  294. u8 id;
  295. struct skl_module_fmt fmt;
  296. };
  297. struct skl_module_iface {
  298. u8 fmt_idx;
  299. u8 nr_in_fmt;
  300. u8 nr_out_fmt;
  301. struct skl_module_pin_fmt inputs[MAX_IN_QUEUE];
  302. struct skl_module_pin_fmt outputs[MAX_OUT_QUEUE];
  303. };
  304. struct skl_module_pin_resources {
  305. u8 pin_index;
  306. u32 buf_size;
  307. };
  308. struct skl_module_res {
  309. u8 id;
  310. u32 is_pages;
  311. u32 cps;
  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. uuid_le 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. u8 domain;
  340. bool homogenous_inputs;
  341. bool homogenous_outputs;
  342. struct skl_module_fmt in_fmt[MODULE_MAX_IN_PINS];
  343. struct skl_module_fmt out_fmt[MODULE_MAX_OUT_PINS];
  344. u8 max_in_queue;
  345. u8 max_out_queue;
  346. u8 in_queue_mask;
  347. u8 out_queue_mask;
  348. u8 in_queue;
  349. u8 out_queue;
  350. u32 mcps;
  351. u32 ibs;
  352. u32 obs;
  353. u8 is_loadable;
  354. u8 core_id;
  355. u8 dev_type;
  356. u8 dma_id;
  357. u8 time_slot;
  358. u8 dmic_ch_combo_index;
  359. u32 dmic_ch_type;
  360. u32 params_fixup;
  361. u32 converter;
  362. u32 vbus_id;
  363. u32 mem_pages;
  364. enum d0i3_capability d0i3_caps;
  365. u32 dma_buffer_size; /* in milli seconds */
  366. struct skl_module_pin *m_in_pin;
  367. struct skl_module_pin *m_out_pin;
  368. enum skl_module_type m_type;
  369. enum skl_hw_conn_type hw_conn_type;
  370. enum skl_module_state m_state;
  371. struct skl_pipe *pipe;
  372. struct skl_specific_cfg formats_config;
  373. struct skl_pipe_mcfg mod_cfg[SKL_MAX_MODULES_IN_PIPE];
  374. };
  375. struct skl_algo_data {
  376. u32 param_id;
  377. u32 set_params;
  378. u32 max;
  379. u32 size;
  380. char *params;
  381. };
  382. struct skl_pipeline {
  383. struct skl_pipe *pipe;
  384. struct list_head node;
  385. };
  386. struct skl_module_deferred_bind {
  387. struct skl_module_cfg *src;
  388. struct skl_module_cfg *dst;
  389. struct list_head node;
  390. };
  391. struct skl_mic_sel_config {
  392. u16 mic_switch;
  393. u16 flags;
  394. u16 blob[SKL_MIC_MAX_CH_SUPPORT][SKL_MIC_MAX_CH_SUPPORT];
  395. } __packed;
  396. enum skl_channel {
  397. SKL_CH_MONO = 1,
  398. SKL_CH_STEREO = 2,
  399. SKL_CH_TRIO = 3,
  400. SKL_CH_QUATRO = 4,
  401. };
  402. static inline struct skl *get_skl_ctx(struct device *dev)
  403. {
  404. struct hdac_bus *bus = dev_get_drvdata(dev);
  405. return bus_to_skl(bus);
  406. }
  407. int skl_tplg_be_update_params(struct snd_soc_dai *dai,
  408. struct skl_pipe_params *params);
  409. int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps,
  410. u32 caps_size, u32 node_id);
  411. void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai,
  412. struct skl_pipe_params *params, int stream);
  413. int skl_tplg_init(struct snd_soc_component *component,
  414. struct hdac_bus *ebus);
  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 *skl, enum d0i3_capability caps);
  420. void skl_tplg_d0i3_put(struct skl *skl, enum d0i3_capability caps);
  421. int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe);
  422. int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  423. int skl_pause_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  424. int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  425. int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  426. int skl_reset_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  427. int skl_init_module(struct skl_sst *ctx, struct skl_module_cfg *module_config);
  428. int skl_bind_modules(struct skl_sst *ctx, struct skl_module_cfg
  429. *src_module, struct skl_module_cfg *dst_module);
  430. int skl_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
  431. *src_module, struct skl_module_cfg *dst_module);
  432. int skl_set_module_params(struct skl_sst *ctx, u32 *params, int size,
  433. u32 param_id, struct skl_module_cfg *mcfg);
  434. int skl_get_module_params(struct skl_sst *ctx, 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 *skl,
  447. struct snd_soc_dapm_widget *w);
  448. #endif