skl-topology.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. enum skl_channel_index {
  34. SKL_CHANNEL_LEFT = 0,
  35. SKL_CHANNEL_RIGHT = 1,
  36. SKL_CHANNEL_CENTER = 2,
  37. SKL_CHANNEL_LEFT_SURROUND = 3,
  38. SKL_CHANNEL_CENTER_SURROUND = 3,
  39. SKL_CHANNEL_RIGHT_SURROUND = 4,
  40. SKL_CHANNEL_LFE = 7,
  41. SKL_CHANNEL_INVALID = 0xF,
  42. };
  43. enum skl_bitdepth {
  44. SKL_DEPTH_8BIT = 8,
  45. SKL_DEPTH_16BIT = 16,
  46. SKL_DEPTH_24BIT = 24,
  47. SKL_DEPTH_32BIT = 32,
  48. SKL_DEPTH_INVALID
  49. };
  50. enum skl_interleaving {
  51. /* [s1_ch1...s1_chN,...,sM_ch1...sM_chN] */
  52. SKL_INTERLEAVING_PER_CHANNEL = 0,
  53. /* [s1_ch1...sM_ch1,...,s1_chN...sM_chN] */
  54. SKL_INTERLEAVING_PER_SAMPLE = 1,
  55. };
  56. enum skl_s_freq {
  57. SKL_FS_8000 = 8000,
  58. SKL_FS_11025 = 11025,
  59. SKL_FS_12000 = 12000,
  60. SKL_FS_16000 = 16000,
  61. SKL_FS_22050 = 22050,
  62. SKL_FS_24000 = 24000,
  63. SKL_FS_32000 = 32000,
  64. SKL_FS_44100 = 44100,
  65. SKL_FS_48000 = 48000,
  66. SKL_FS_64000 = 64000,
  67. SKL_FS_88200 = 88200,
  68. SKL_FS_96000 = 96000,
  69. SKL_FS_128000 = 128000,
  70. SKL_FS_176400 = 176400,
  71. SKL_FS_192000 = 192000,
  72. SKL_FS_INVALID
  73. };
  74. enum skl_widget_type {
  75. SKL_WIDGET_VMIXER = 1,
  76. SKL_WIDGET_MIXER = 2,
  77. SKL_WIDGET_PGA = 3,
  78. SKL_WIDGET_MUX = 4
  79. };
  80. struct skl_audio_data_format {
  81. enum skl_s_freq s_freq;
  82. enum skl_bitdepth bit_depth;
  83. u32 channel_map;
  84. enum skl_ch_cfg ch_cfg;
  85. enum skl_interleaving interleaving;
  86. u8 number_of_channels;
  87. u8 valid_bit_depth;
  88. u8 sample_type;
  89. u8 reserved[1];
  90. } __packed;
  91. struct skl_base_cfg {
  92. u32 cps;
  93. u32 ibs;
  94. u32 obs;
  95. u32 is_pages;
  96. struct skl_audio_data_format audio_fmt;
  97. };
  98. struct skl_cpr_gtw_cfg {
  99. u32 node_id;
  100. u32 dma_buffer_size;
  101. u32 config_length;
  102. /* not mandatory; required only for DMIC/I2S */
  103. u32 config_data[1];
  104. } __packed;
  105. struct skl_cpr_cfg {
  106. struct skl_base_cfg base_cfg;
  107. struct skl_audio_data_format out_fmt;
  108. u32 cpr_feature_mask;
  109. struct skl_cpr_gtw_cfg gtw_cfg;
  110. } __packed;
  111. struct skl_src_module_cfg {
  112. struct skl_base_cfg base_cfg;
  113. enum skl_s_freq src_cfg;
  114. } __packed;
  115. struct notification_mask {
  116. u32 notify;
  117. u32 enable;
  118. } __packed;
  119. struct skl_up_down_mixer_cfg {
  120. struct skl_base_cfg base_cfg;
  121. enum skl_ch_cfg out_ch_cfg;
  122. /* This should be set to 1 if user coefficients are required */
  123. u32 coeff_sel;
  124. /* Pass the user coeff in this array */
  125. s32 coeff[UP_DOWN_MIXER_MAX_COEFF];
  126. } __packed;
  127. enum skl_dma_type {
  128. SKL_DMA_HDA_HOST_OUTPUT_CLASS = 0,
  129. SKL_DMA_HDA_HOST_INPUT_CLASS = 1,
  130. SKL_DMA_HDA_HOST_INOUT_CLASS = 2,
  131. SKL_DMA_HDA_LINK_OUTPUT_CLASS = 8,
  132. SKL_DMA_HDA_LINK_INPUT_CLASS = 9,
  133. SKL_DMA_HDA_LINK_INOUT_CLASS = 0xA,
  134. SKL_DMA_DMIC_LINK_INPUT_CLASS = 0xB,
  135. SKL_DMA_I2S_LINK_OUTPUT_CLASS = 0xC,
  136. SKL_DMA_I2S_LINK_INPUT_CLASS = 0xD,
  137. };
  138. union skl_ssp_dma_node {
  139. u8 val;
  140. struct {
  141. u8 time_slot_index:4;
  142. u8 i2s_instance:4;
  143. } dma_node;
  144. };
  145. union skl_connector_node_id {
  146. u32 val;
  147. struct {
  148. u32 vindex:8;
  149. u32 dma_type:4;
  150. u32 rsvd:20;
  151. } node;
  152. };
  153. struct skl_module_fmt {
  154. u32 channels;
  155. u32 s_freq;
  156. u32 bit_depth;
  157. u32 valid_bit_depth;
  158. u32 ch_cfg;
  159. };
  160. struct skl_module_inst_id {
  161. u32 module_id;
  162. u32 instance_id;
  163. };
  164. struct skl_module_pin {
  165. struct skl_module_inst_id id;
  166. u8 pin_index;
  167. bool is_dynamic;
  168. bool in_use;
  169. };
  170. struct skl_specific_cfg {
  171. u32 caps_size;
  172. u32 *caps;
  173. };
  174. enum skl_pipe_state {
  175. SKL_PIPE_INVALID = 0,
  176. SKL_PIPE_CREATED = 1,
  177. SKL_PIPE_PAUSED = 2,
  178. SKL_PIPE_STARTED = 3
  179. };
  180. struct skl_pipe_module {
  181. struct snd_soc_dapm_widget *w;
  182. struct list_head node;
  183. };
  184. struct skl_pipe_params {
  185. u8 host_dma_id;
  186. u8 link_dma_id;
  187. u32 ch;
  188. u32 s_freq;
  189. u32 s_fmt;
  190. u8 linktype;
  191. int stream;
  192. };
  193. struct skl_pipe {
  194. u8 ppl_id;
  195. u8 pipe_priority;
  196. u16 conn_type;
  197. u32 memory_pages;
  198. struct skl_pipe_params *p_params;
  199. enum skl_pipe_state state;
  200. struct list_head w_list;
  201. };
  202. enum skl_module_state {
  203. SKL_MODULE_UNINIT = 0,
  204. SKL_MODULE_INIT_DONE = 1,
  205. SKL_MODULE_LOADED = 2,
  206. SKL_MODULE_UNLOADED = 3,
  207. SKL_MODULE_BIND_DONE = 4
  208. };
  209. struct skl_module_cfg {
  210. struct skl_module_inst_id id;
  211. struct skl_module_fmt in_fmt;
  212. struct skl_module_fmt out_fmt;
  213. u8 max_in_queue;
  214. u8 max_out_queue;
  215. u8 in_queue_mask;
  216. u8 out_queue_mask;
  217. u8 in_queue;
  218. u8 out_queue;
  219. u32 mcps;
  220. u32 ibs;
  221. u32 obs;
  222. u8 is_loadable;
  223. u8 core_id;
  224. u8 dev_type;
  225. u8 dma_id;
  226. u8 time_slot;
  227. u32 params_fixup;
  228. u32 converter;
  229. u32 vbus_id;
  230. struct skl_module_pin *m_in_pin;
  231. struct skl_module_pin *m_out_pin;
  232. enum skl_module_type m_type;
  233. enum skl_hw_conn_type hw_conn_type;
  234. enum skl_module_state m_state;
  235. struct skl_pipe *pipe;
  236. struct skl_specific_cfg formats_config;
  237. };
  238. struct skl_pipeline {
  239. struct skl_pipe *pipe;
  240. struct list_head node;
  241. };
  242. struct skl_dapm_path_list {
  243. struct snd_soc_dapm_path *dapm_path;
  244. struct list_head node;
  245. };
  246. static inline struct skl *get_skl_ctx(struct device *dev)
  247. {
  248. struct hdac_ext_bus *ebus = dev_get_drvdata(dev);
  249. return ebus_to_skl(ebus);
  250. }
  251. int skl_tplg_be_update_params(struct snd_soc_dai *dai,
  252. struct skl_pipe_params *params);
  253. void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai,
  254. struct skl_pipe_params *params, int stream);
  255. int skl_tplg_init(struct snd_soc_platform *platform,
  256. struct hdac_ext_bus *ebus);
  257. struct skl_module_cfg *skl_tplg_fe_get_cpr_module(
  258. struct snd_soc_dai *dai, int stream);
  259. int skl_tplg_update_pipe_params(struct device *dev,
  260. struct skl_module_cfg *mconfig, struct skl_pipe_params *params);
  261. int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe);
  262. int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  263. int skl_pause_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  264. int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  265. int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe);
  266. int skl_init_module(struct skl_sst *ctx, struct skl_module_cfg *module_config,
  267. char *param);
  268. int skl_bind_modules(struct skl_sst *ctx, struct skl_module_cfg
  269. *src_module, struct skl_module_cfg *dst_module);
  270. int skl_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg
  271. *src_module, struct skl_module_cfg *dst_module);
  272. enum skl_bitdepth skl_get_bit_depth(int params);
  273. #endif