sst-atom-controls.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * sst-atom-controls.h - Intel MID Platform driver header file
  4. *
  5. * Copyright (C) 2013-14 Intel Corp
  6. * Author: Ramesh Babu <[email protected]>
  7. * Omair M Abdullah <[email protected]>
  8. * Samreen Nilofer <[email protected]>
  9. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10. *
  11. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. */
  13. #ifndef __SST_ATOM_CONTROLS_H__
  14. #define __SST_ATOM_CONTROLS_H__
  15. #include <sound/soc.h>
  16. #include <sound/tlv.h>
  17. enum {
  18. MERR_DPCM_AUDIO = 0,
  19. MERR_DPCM_DEEP_BUFFER,
  20. MERR_DPCM_COMPR,
  21. };
  22. /* define a bit for each mixer input */
  23. #define SST_MIX_IP(x) (x)
  24. #define SST_IP_MODEM SST_MIX_IP(0)
  25. #define SST_IP_BT SST_MIX_IP(1)
  26. #define SST_IP_CODEC0 SST_MIX_IP(2)
  27. #define SST_IP_CODEC1 SST_MIX_IP(3)
  28. #define SST_IP_LOOP0 SST_MIX_IP(4)
  29. #define SST_IP_LOOP1 SST_MIX_IP(5)
  30. #define SST_IP_LOOP2 SST_MIX_IP(6)
  31. #define SST_IP_PROBE SST_MIX_IP(7)
  32. #define SST_IP_VOIP SST_MIX_IP(12)
  33. #define SST_IP_PCM0 SST_MIX_IP(13)
  34. #define SST_IP_PCM1 SST_MIX_IP(14)
  35. #define SST_IP_MEDIA0 SST_MIX_IP(17)
  36. #define SST_IP_MEDIA1 SST_MIX_IP(18)
  37. #define SST_IP_MEDIA2 SST_MIX_IP(19)
  38. #define SST_IP_MEDIA3 SST_MIX_IP(20)
  39. #define SST_IP_LAST SST_IP_MEDIA3
  40. #define SST_SWM_INPUT_COUNT (SST_IP_LAST + 1)
  41. #define SST_CMD_SWM_MAX_INPUTS 6
  42. #define SST_PATH_ID_SHIFT 8
  43. #define SST_DEFAULT_LOCATION_ID 0xFFFF
  44. #define SST_DEFAULT_CELL_NBR 0xFF
  45. #define SST_DEFAULT_MODULE_ID 0xFFFF
  46. /*
  47. * Audio DSP Path Ids. Specified by the audio DSP FW
  48. */
  49. enum sst_path_index {
  50. SST_PATH_INDEX_MODEM_OUT = (0x00 << SST_PATH_ID_SHIFT),
  51. SST_PATH_INDEX_CODEC_OUT0 = (0x02 << SST_PATH_ID_SHIFT),
  52. SST_PATH_INDEX_CODEC_OUT1 = (0x03 << SST_PATH_ID_SHIFT),
  53. SST_PATH_INDEX_SPROT_LOOP_OUT = (0x04 << SST_PATH_ID_SHIFT),
  54. SST_PATH_INDEX_MEDIA_LOOP1_OUT = (0x05 << SST_PATH_ID_SHIFT),
  55. SST_PATH_INDEX_MEDIA_LOOP2_OUT = (0x06 << SST_PATH_ID_SHIFT),
  56. SST_PATH_INDEX_VOIP_OUT = (0x0C << SST_PATH_ID_SHIFT),
  57. SST_PATH_INDEX_PCM0_OUT = (0x0D << SST_PATH_ID_SHIFT),
  58. SST_PATH_INDEX_PCM1_OUT = (0x0E << SST_PATH_ID_SHIFT),
  59. SST_PATH_INDEX_PCM2_OUT = (0x0F << SST_PATH_ID_SHIFT),
  60. SST_PATH_INDEX_MEDIA0_OUT = (0x12 << SST_PATH_ID_SHIFT),
  61. SST_PATH_INDEX_MEDIA1_OUT = (0x13 << SST_PATH_ID_SHIFT),
  62. /* Start of input paths */
  63. SST_PATH_INDEX_MODEM_IN = (0x80 << SST_PATH_ID_SHIFT),
  64. SST_PATH_INDEX_CODEC_IN0 = (0x82 << SST_PATH_ID_SHIFT),
  65. SST_PATH_INDEX_CODEC_IN1 = (0x83 << SST_PATH_ID_SHIFT),
  66. SST_PATH_INDEX_SPROT_LOOP_IN = (0x84 << SST_PATH_ID_SHIFT),
  67. SST_PATH_INDEX_MEDIA_LOOP1_IN = (0x85 << SST_PATH_ID_SHIFT),
  68. SST_PATH_INDEX_MEDIA_LOOP2_IN = (0x86 << SST_PATH_ID_SHIFT),
  69. SST_PATH_INDEX_VOIP_IN = (0x8C << SST_PATH_ID_SHIFT),
  70. SST_PATH_INDEX_PCM0_IN = (0x8D << SST_PATH_ID_SHIFT),
  71. SST_PATH_INDEX_PCM1_IN = (0x8E << SST_PATH_ID_SHIFT),
  72. SST_PATH_INDEX_MEDIA0_IN = (0x8F << SST_PATH_ID_SHIFT),
  73. SST_PATH_INDEX_MEDIA1_IN = (0x90 << SST_PATH_ID_SHIFT),
  74. SST_PATH_INDEX_MEDIA2_IN = (0x91 << SST_PATH_ID_SHIFT),
  75. SST_PATH_INDEX_MEDIA3_IN = (0x9C << SST_PATH_ID_SHIFT),
  76. SST_PATH_INDEX_RESERVED = (0xFF << SST_PATH_ID_SHIFT),
  77. };
  78. /*
  79. * path IDs
  80. */
  81. enum sst_swm_inputs {
  82. SST_SWM_IN_MODEM = (SST_PATH_INDEX_MODEM_IN | SST_DEFAULT_CELL_NBR),
  83. SST_SWM_IN_CODEC0 = (SST_PATH_INDEX_CODEC_IN0 | SST_DEFAULT_CELL_NBR),
  84. SST_SWM_IN_CODEC1 = (SST_PATH_INDEX_CODEC_IN1 | SST_DEFAULT_CELL_NBR),
  85. SST_SWM_IN_SPROT_LOOP = (SST_PATH_INDEX_SPROT_LOOP_IN | SST_DEFAULT_CELL_NBR),
  86. SST_SWM_IN_MEDIA_LOOP1 = (SST_PATH_INDEX_MEDIA_LOOP1_IN | SST_DEFAULT_CELL_NBR),
  87. SST_SWM_IN_MEDIA_LOOP2 = (SST_PATH_INDEX_MEDIA_LOOP2_IN | SST_DEFAULT_CELL_NBR),
  88. SST_SWM_IN_VOIP = (SST_PATH_INDEX_VOIP_IN | SST_DEFAULT_CELL_NBR),
  89. SST_SWM_IN_PCM0 = (SST_PATH_INDEX_PCM0_IN | SST_DEFAULT_CELL_NBR),
  90. SST_SWM_IN_PCM1 = (SST_PATH_INDEX_PCM1_IN | SST_DEFAULT_CELL_NBR),
  91. SST_SWM_IN_MEDIA0 = (SST_PATH_INDEX_MEDIA0_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
  92. SST_SWM_IN_MEDIA1 = (SST_PATH_INDEX_MEDIA1_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
  93. SST_SWM_IN_MEDIA2 = (SST_PATH_INDEX_MEDIA2_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
  94. SST_SWM_IN_MEDIA3 = (SST_PATH_INDEX_MEDIA3_IN | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
  95. SST_SWM_IN_END = (SST_PATH_INDEX_RESERVED | SST_DEFAULT_CELL_NBR)
  96. };
  97. /*
  98. * path IDs
  99. */
  100. enum sst_swm_outputs {
  101. SST_SWM_OUT_MODEM = (SST_PATH_INDEX_MODEM_OUT | SST_DEFAULT_CELL_NBR),
  102. SST_SWM_OUT_CODEC0 = (SST_PATH_INDEX_CODEC_OUT0 | SST_DEFAULT_CELL_NBR),
  103. SST_SWM_OUT_CODEC1 = (SST_PATH_INDEX_CODEC_OUT1 | SST_DEFAULT_CELL_NBR),
  104. SST_SWM_OUT_SPROT_LOOP = (SST_PATH_INDEX_SPROT_LOOP_OUT | SST_DEFAULT_CELL_NBR),
  105. SST_SWM_OUT_MEDIA_LOOP1 = (SST_PATH_INDEX_MEDIA_LOOP1_OUT | SST_DEFAULT_CELL_NBR),
  106. SST_SWM_OUT_MEDIA_LOOP2 = (SST_PATH_INDEX_MEDIA_LOOP2_OUT | SST_DEFAULT_CELL_NBR),
  107. SST_SWM_OUT_VOIP = (SST_PATH_INDEX_VOIP_OUT | SST_DEFAULT_CELL_NBR),
  108. SST_SWM_OUT_PCM0 = (SST_PATH_INDEX_PCM0_OUT | SST_DEFAULT_CELL_NBR),
  109. SST_SWM_OUT_PCM1 = (SST_PATH_INDEX_PCM1_OUT | SST_DEFAULT_CELL_NBR),
  110. SST_SWM_OUT_PCM2 = (SST_PATH_INDEX_PCM2_OUT | SST_DEFAULT_CELL_NBR),
  111. SST_SWM_OUT_MEDIA0 = (SST_PATH_INDEX_MEDIA0_OUT | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
  112. SST_SWM_OUT_MEDIA1 = (SST_PATH_INDEX_MEDIA1_OUT | SST_DEFAULT_CELL_NBR), /* Part of Media Mixer */
  113. SST_SWM_OUT_END = (SST_PATH_INDEX_RESERVED | SST_DEFAULT_CELL_NBR),
  114. };
  115. enum sst_ipc_msg {
  116. SST_IPC_IA_CMD = 1,
  117. SST_IPC_IA_SET_PARAMS,
  118. SST_IPC_IA_GET_PARAMS,
  119. };
  120. enum sst_cmd_type {
  121. SST_CMD_BYTES_SET = 1,
  122. SST_CMD_BYTES_GET = 2,
  123. };
  124. enum sst_task {
  125. SST_TASK_SBA = 1,
  126. SST_TASK_MMX = 3,
  127. };
  128. enum sst_type {
  129. SST_TYPE_CMD = 1,
  130. SST_TYPE_PARAMS,
  131. };
  132. enum sst_flag {
  133. SST_FLAG_BLOCKED = 1,
  134. SST_FLAG_NONBLOCK,
  135. };
  136. /*
  137. * Enumeration for indexing the gain cells in VB_SET_GAIN DSP command
  138. */
  139. enum sst_gain_index {
  140. /* GAIN IDs for SB task start here */
  141. SST_GAIN_INDEX_CODEC_OUT0,
  142. SST_GAIN_INDEX_CODEC_OUT1,
  143. SST_GAIN_INDEX_CODEC_IN0,
  144. SST_GAIN_INDEX_CODEC_IN1,
  145. SST_GAIN_INDEX_SPROT_LOOP_OUT,
  146. SST_GAIN_INDEX_MEDIA_LOOP1_OUT,
  147. SST_GAIN_INDEX_MEDIA_LOOP2_OUT,
  148. SST_GAIN_INDEX_PCM0_IN_LEFT,
  149. SST_GAIN_INDEX_PCM0_IN_RIGHT,
  150. SST_GAIN_INDEX_PCM1_OUT_LEFT,
  151. SST_GAIN_INDEX_PCM1_OUT_RIGHT,
  152. SST_GAIN_INDEX_PCM1_IN_LEFT,
  153. SST_GAIN_INDEX_PCM1_IN_RIGHT,
  154. SST_GAIN_INDEX_PCM2_OUT_LEFT,
  155. SST_GAIN_INDEX_PCM2_OUT_RIGHT,
  156. SST_GAIN_INDEX_VOIP_OUT,
  157. SST_GAIN_INDEX_VOIP_IN,
  158. /* Gain IDs for MMX task start here */
  159. SST_GAIN_INDEX_MEDIA0_IN_LEFT,
  160. SST_GAIN_INDEX_MEDIA0_IN_RIGHT,
  161. SST_GAIN_INDEX_MEDIA1_IN_LEFT,
  162. SST_GAIN_INDEX_MEDIA1_IN_RIGHT,
  163. SST_GAIN_INDEX_MEDIA2_IN_LEFT,
  164. SST_GAIN_INDEX_MEDIA2_IN_RIGHT,
  165. SST_GAIN_INDEX_GAIN_END
  166. };
  167. /*
  168. * Audio DSP module IDs specified by FW spec
  169. * TODO: Update with all modules
  170. */
  171. enum sst_module_id {
  172. SST_MODULE_ID_PCM = 0x0001,
  173. SST_MODULE_ID_MP3 = 0x0002,
  174. SST_MODULE_ID_MP24 = 0x0003,
  175. SST_MODULE_ID_AAC = 0x0004,
  176. SST_MODULE_ID_AACP = 0x0005,
  177. SST_MODULE_ID_EAACP = 0x0006,
  178. SST_MODULE_ID_WMA9 = 0x0007,
  179. SST_MODULE_ID_WMA10 = 0x0008,
  180. SST_MODULE_ID_WMA10P = 0x0009,
  181. SST_MODULE_ID_RA = 0x000A,
  182. SST_MODULE_ID_DDAC3 = 0x000B,
  183. SST_MODULE_ID_TRUE_HD = 0x000C,
  184. SST_MODULE_ID_HD_PLUS = 0x000D,
  185. SST_MODULE_ID_SRC = 0x0064,
  186. SST_MODULE_ID_DOWNMIX = 0x0066,
  187. SST_MODULE_ID_GAIN_CELL = 0x0067,
  188. SST_MODULE_ID_SPROT = 0x006D,
  189. SST_MODULE_ID_BASS_BOOST = 0x006E,
  190. SST_MODULE_ID_STEREO_WDNG = 0x006F,
  191. SST_MODULE_ID_AV_REMOVAL = 0x0070,
  192. SST_MODULE_ID_MIC_EQ = 0x0071,
  193. SST_MODULE_ID_SPL = 0x0072,
  194. SST_MODULE_ID_ALGO_VTSV = 0x0073,
  195. SST_MODULE_ID_NR = 0x0076,
  196. SST_MODULE_ID_BWX = 0x0077,
  197. SST_MODULE_ID_DRP = 0x0078,
  198. SST_MODULE_ID_MDRP = 0x0079,
  199. SST_MODULE_ID_ANA = 0x007A,
  200. SST_MODULE_ID_AEC = 0x007B,
  201. SST_MODULE_ID_NR_SNS = 0x007C,
  202. SST_MODULE_ID_SER = 0x007D,
  203. SST_MODULE_ID_AGC = 0x007E,
  204. SST_MODULE_ID_CNI = 0x007F,
  205. SST_MODULE_ID_CONTEXT_ALGO_AWARE = 0x0080,
  206. SST_MODULE_ID_FIR_24 = 0x0081,
  207. SST_MODULE_ID_IIR_24 = 0x0082,
  208. SST_MODULE_ID_ASRC = 0x0083,
  209. SST_MODULE_ID_TONE_GEN = 0x0084,
  210. SST_MODULE_ID_BMF = 0x0086,
  211. SST_MODULE_ID_EDL = 0x0087,
  212. SST_MODULE_ID_GLC = 0x0088,
  213. SST_MODULE_ID_FIR_16 = 0x0089,
  214. SST_MODULE_ID_IIR_16 = 0x008A,
  215. SST_MODULE_ID_DNR = 0x008B,
  216. SST_MODULE_ID_VIRTUALIZER = 0x008C,
  217. SST_MODULE_ID_VISUALIZATION = 0x008D,
  218. SST_MODULE_ID_LOUDNESS_OPTIMIZER = 0x008E,
  219. SST_MODULE_ID_REVERBERATION = 0x008F,
  220. SST_MODULE_ID_CNI_TX = 0x0090,
  221. SST_MODULE_ID_REF_LINE = 0x0091,
  222. SST_MODULE_ID_VOLUME = 0x0092,
  223. SST_MODULE_ID_FILT_DCR = 0x0094,
  224. SST_MODULE_ID_SLV = 0x009A,
  225. SST_MODULE_ID_NLF = 0x009B,
  226. SST_MODULE_ID_TNR = 0x009C,
  227. SST_MODULE_ID_WNR = 0x009D,
  228. SST_MODULE_ID_LOG = 0xFF00,
  229. SST_MODULE_ID_TASK = 0xFFFF,
  230. };
  231. enum sst_cmd {
  232. SBA_IDLE = 14,
  233. SBA_VB_SET_SPEECH_PATH = 26,
  234. MMX_SET_GAIN = 33,
  235. SBA_VB_SET_GAIN = 33,
  236. FBA_VB_RX_CNI = 35,
  237. MMX_SET_GAIN_TIMECONST = 36,
  238. SBA_VB_SET_TIMECONST = 36,
  239. SBA_VB_START = 85,
  240. SBA_SET_SWM = 114,
  241. SBA_SET_MDRP = 116,
  242. SBA_HW_SET_SSP = 117,
  243. SBA_SET_MEDIA_LOOP_MAP = 118,
  244. SBA_SET_MEDIA_PATH = 119,
  245. MMX_SET_MEDIA_PATH = 119,
  246. SBA_VB_LPRO = 126,
  247. SBA_VB_SET_FIR = 128,
  248. SBA_VB_SET_IIR = 129,
  249. SBA_SET_SSP_SLOT_MAP = 130,
  250. };
  251. enum sst_dsp_switch {
  252. SST_SWITCH_OFF = 0,
  253. SST_SWITCH_ON = 3,
  254. };
  255. enum sst_path_switch {
  256. SST_PATH_OFF = 0,
  257. SST_PATH_ON = 1,
  258. };
  259. enum sst_swm_state {
  260. SST_SWM_OFF = 0,
  261. SST_SWM_ON = 3,
  262. };
  263. #define SST_FILL_LOCATION_IDS(dst, cell_idx, pipe_id) do { \
  264. dst.location_id.p.cell_nbr_idx = (cell_idx); \
  265. dst.location_id.p.path_id = (pipe_id); \
  266. } while (0)
  267. #define SST_FILL_LOCATION_ID(dst, loc_id) (\
  268. dst.location_id.f = (loc_id))
  269. #define SST_FILL_MODULE_ID(dst, mod_id) (\
  270. dst.module_id = (mod_id))
  271. #define SST_FILL_DESTINATION1(dst, id) do { \
  272. SST_FILL_LOCATION_ID(dst, (id) & 0xFFFF); \
  273. SST_FILL_MODULE_ID(dst, ((id) & 0xFFFF0000) >> 16); \
  274. } while (0)
  275. #define SST_FILL_DESTINATION2(dst, loc_id, mod_id) do { \
  276. SST_FILL_LOCATION_ID(dst, loc_id); \
  277. SST_FILL_MODULE_ID(dst, mod_id); \
  278. } while (0)
  279. #define SST_FILL_DESTINATION3(dst, cell_idx, path_id, mod_id) do { \
  280. SST_FILL_LOCATION_IDS(dst, cell_idx, path_id); \
  281. SST_FILL_MODULE_ID(dst, mod_id); \
  282. } while (0)
  283. #define SST_FILL_DESTINATION(level, dst, ...) \
  284. SST_FILL_DESTINATION##level(dst, __VA_ARGS__)
  285. #define SST_FILL_DEFAULT_DESTINATION(dst) \
  286. SST_FILL_DESTINATION(2, dst, SST_DEFAULT_LOCATION_ID, SST_DEFAULT_MODULE_ID)
  287. struct sst_destination_id {
  288. union sst_location_id {
  289. struct {
  290. u8 cell_nbr_idx; /* module index */
  291. u8 path_id; /* pipe_id */
  292. } __packed p; /* part */
  293. u16 f; /* full */
  294. } __packed location_id;
  295. u16 module_id;
  296. } __packed;
  297. struct sst_dsp_header {
  298. struct sst_destination_id dst;
  299. u16 command_id;
  300. u16 length;
  301. } __packed;
  302. /*
  303. *
  304. * Common Commands
  305. *
  306. */
  307. struct sst_cmd_generic {
  308. struct sst_dsp_header header;
  309. } __packed;
  310. struct swm_input_ids {
  311. struct sst_destination_id input_id;
  312. } __packed;
  313. struct sst_cmd_set_swm {
  314. struct sst_dsp_header header;
  315. struct sst_destination_id output_id;
  316. u16 switch_state;
  317. u16 nb_inputs;
  318. struct swm_input_ids input[SST_CMD_SWM_MAX_INPUTS];
  319. } __packed;
  320. struct sst_cmd_set_media_path {
  321. struct sst_dsp_header header;
  322. u16 switch_state;
  323. } __packed;
  324. struct pcm_cfg {
  325. u8 s_length:2;
  326. u8 rate:3;
  327. u8 format:3;
  328. } __packed;
  329. struct sst_cmd_set_speech_path {
  330. struct sst_dsp_header header;
  331. u16 switch_state;
  332. struct {
  333. u16 rsvd:8;
  334. struct pcm_cfg cfg;
  335. } config;
  336. } __packed;
  337. struct gain_cell {
  338. struct sst_destination_id dest;
  339. s16 cell_gain_left;
  340. s16 cell_gain_right;
  341. u16 gain_time_constant;
  342. } __packed;
  343. #define NUM_GAIN_CELLS 1
  344. struct sst_cmd_set_gain_dual {
  345. struct sst_dsp_header header;
  346. u16 gain_cell_num;
  347. struct gain_cell cell_gains[NUM_GAIN_CELLS];
  348. } __packed;
  349. struct sst_cmd_set_params {
  350. struct sst_destination_id dst;
  351. u16 command_id;
  352. char params[];
  353. } __packed;
  354. struct sst_cmd_sba_vb_start {
  355. struct sst_dsp_header header;
  356. } __packed;
  357. union sba_media_loop_params {
  358. struct {
  359. u16 rsvd:8;
  360. struct pcm_cfg cfg;
  361. } part;
  362. u16 full;
  363. } __packed;
  364. struct sst_cmd_sba_set_media_loop_map {
  365. struct sst_dsp_header header;
  366. u16 switch_state;
  367. union sba_media_loop_params param;
  368. u16 map;
  369. } __packed;
  370. struct sst_cmd_tone_stop {
  371. struct sst_dsp_header header;
  372. u16 switch_state;
  373. } __packed;
  374. enum sst_ssp_mode {
  375. SSP_MODE_PROVIDER = 0,
  376. SSP_MODE_CONSUMER = 1,
  377. };
  378. enum sst_ssp_pcm_mode {
  379. SSP_PCM_MODE_NORMAL = 0,
  380. SSP_PCM_MODE_NETWORK = 1,
  381. };
  382. enum sst_ssp_duplex {
  383. SSP_DUPLEX = 0,
  384. SSP_RX = 1,
  385. SSP_TX = 2,
  386. };
  387. enum sst_ssp_fs_frequency {
  388. SSP_FS_8_KHZ = 0,
  389. SSP_FS_16_KHZ = 1,
  390. SSP_FS_44_1_KHZ = 2,
  391. SSP_FS_48_KHZ = 3,
  392. };
  393. enum sst_ssp_fs_polarity {
  394. SSP_FS_ACTIVE_LOW = 0,
  395. SSP_FS_ACTIVE_HIGH = 1,
  396. };
  397. enum sst_ssp_protocol {
  398. SSP_MODE_PCM = 0,
  399. SSP_MODE_I2S = 1,
  400. };
  401. enum sst_ssp_port_id {
  402. SSP_MODEM = 0,
  403. SSP_BT = 1,
  404. SSP_FM = 2,
  405. SSP_CODEC = 3,
  406. };
  407. struct sst_cmd_sba_hw_set_ssp {
  408. struct sst_dsp_header header;
  409. u16 selection; /* 0:SSP0(def), 1:SSP1, 2:SSP2 */
  410. u16 switch_state;
  411. u16 nb_bits_per_slots:6; /* 0-32 bits, 24 (def) */
  412. u16 nb_slots:4; /* 0-8: slots per frame */
  413. u16 mode:3; /* 0:Master, 1: Slave */
  414. u16 duplex:3;
  415. u16 active_tx_slot_map:8; /* Bit map, 0:off, 1:on */
  416. u16 reserved1:8;
  417. u16 active_rx_slot_map:8; /* Bit map 0: Off, 1:On */
  418. u16 reserved2:8;
  419. u16 frame_sync_frequency;
  420. u16 frame_sync_polarity:8;
  421. u16 data_polarity:8;
  422. u16 frame_sync_width; /* 1 to N clocks */
  423. u16 ssp_protocol:8;
  424. u16 start_delay:8; /* Start delay in terms of clock ticks */
  425. } __packed;
  426. #define SST_MAX_TDM_SLOTS 8
  427. struct sst_param_sba_ssp_slot_map {
  428. struct sst_dsp_header header;
  429. u16 param_id;
  430. u16 param_len;
  431. u16 ssp_index;
  432. u8 rx_slot_map[SST_MAX_TDM_SLOTS];
  433. u8 tx_slot_map[SST_MAX_TDM_SLOTS];
  434. } __packed;
  435. enum {
  436. SST_PROBE_EXTRACTOR = 0,
  437. SST_PROBE_INJECTOR = 1,
  438. };
  439. /**** widget defines *****/
  440. #define SST_MODULE_GAIN 1
  441. #define SST_MODULE_ALGO 2
  442. #define SST_FMT_MONO 0
  443. #define SST_FMT_STEREO 3
  444. /* physical SSP numbers */
  445. enum {
  446. SST_SSP0 = 0,
  447. SST_SSP1,
  448. SST_SSP2,
  449. SST_SSP_LAST = SST_SSP2,
  450. };
  451. #define SST_NUM_SSPS (SST_SSP_LAST + 1) /* physical SSPs */
  452. #define SST_MAX_SSP_MUX 2 /* single SSP muxed between pipes */
  453. #define SST_MAX_SSP_DOMAINS 2 /* domains present in each pipe */
  454. struct sst_module {
  455. struct snd_kcontrol *kctl;
  456. struct list_head node;
  457. };
  458. struct sst_ssp_config {
  459. u8 ssp_id;
  460. u8 bits_per_slot;
  461. u8 slots;
  462. u8 ssp_mode;
  463. u8 pcm_mode;
  464. u8 duplex;
  465. u8 ssp_protocol;
  466. u8 fs_frequency;
  467. u8 active_slot_map;
  468. u8 start_delay;
  469. u16 fs_width;
  470. u8 frame_sync_polarity;
  471. u8 data_polarity;
  472. };
  473. struct sst_ssp_cfg {
  474. const u8 ssp_number;
  475. const int *mux_shift;
  476. const int (*domain_shift)[SST_MAX_SSP_MUX];
  477. const struct sst_ssp_config (*ssp_config)[SST_MAX_SSP_MUX][SST_MAX_SSP_DOMAINS];
  478. };
  479. struct sst_ids {
  480. u16 location_id;
  481. u16 module_id;
  482. u8 task_id;
  483. u8 format;
  484. u8 reg;
  485. const char *parent_wname;
  486. struct snd_soc_dapm_widget *parent_w;
  487. struct list_head algo_list;
  488. struct list_head gain_list;
  489. const struct sst_pcm_format *pcm_fmt;
  490. };
  491. #define SST_AIF_IN(wname, wevent) \
  492. { .id = snd_soc_dapm_aif_in, .name = wname, .sname = NULL, \
  493. .reg = SND_SOC_NOPM, .shift = 0, \
  494. .on_val = 1, .off_val = 0, \
  495. .event = wevent, .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD, \
  496. .priv = (void *)&(struct sst_ids) { .task_id = 0, .location_id = 0 } \
  497. }
  498. #define SST_AIF_OUT(wname, wevent) \
  499. { .id = snd_soc_dapm_aif_out, .name = wname, .sname = NULL, \
  500. .reg = SND_SOC_NOPM, .shift = 0, \
  501. .on_val = 1, .off_val = 0, \
  502. .event = wevent, .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD, \
  503. .priv = (void *)&(struct sst_ids) { .task_id = 0, .location_id = 0 } \
  504. }
  505. #define SST_INPUT(wname, wevent) \
  506. { .id = snd_soc_dapm_input, .name = wname, .sname = NULL, \
  507. .reg = SND_SOC_NOPM, .shift = 0, \
  508. .on_val = 1, .off_val = 0, \
  509. .event = wevent, .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD, \
  510. .priv = (void *)&(struct sst_ids) { .task_id = 0, .location_id = 0 } \
  511. }
  512. #define SST_OUTPUT(wname, wevent) \
  513. { .id = snd_soc_dapm_output, .name = wname, .sname = NULL, \
  514. .reg = SND_SOC_NOPM, .shift = 0, \
  515. .on_val = 1, .off_val = 0, \
  516. .event = wevent, .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD, \
  517. .priv = (void *)&(struct sst_ids) { .task_id = 0, .location_id = 0 } \
  518. }
  519. #define SST_DAPM_OUTPUT(wname, wloc_id, wtask_id, wformat, wevent) \
  520. { .id = snd_soc_dapm_output, .name = wname, .sname = NULL, \
  521. .reg = SND_SOC_NOPM, .shift = 0, \
  522. .on_val = 1, .off_val = 0, \
  523. .event = wevent, .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD, \
  524. .priv = (void *)&(struct sst_ids) { .location_id = wloc_id, .task_id = wtask_id,\
  525. .pcm_fmt = wformat, } \
  526. }
  527. #define SST_PATH(wname, wtask, wloc_id, wevent, wflags) \
  528. { .id = snd_soc_dapm_pga, .name = wname, .reg = SND_SOC_NOPM, .shift = 0, \
  529. .kcontrol_news = NULL, .num_kcontrols = 0, \
  530. .on_val = 1, .off_val = 0, \
  531. .event = wevent, .event_flags = wflags, \
  532. .priv = (void *)&(struct sst_ids) { .task_id = wtask, .location_id = wloc_id, } \
  533. }
  534. #define SST_LINKED_PATH(wname, wtask, wloc_id, linked_wname, wevent, wflags) \
  535. { .id = snd_soc_dapm_pga, .name = wname, .reg = SND_SOC_NOPM, .shift = 0, \
  536. .kcontrol_news = NULL, .num_kcontrols = 0, \
  537. .on_val = 1, .off_val = 0, \
  538. .event = wevent, .event_flags = wflags, \
  539. .priv = (void *)&(struct sst_ids) { .task_id = wtask, .location_id = wloc_id, \
  540. .parent_wname = linked_wname} \
  541. }
  542. #define SST_PATH_MEDIA_LOOP(wname, wtask, wloc_id, wformat, wevent, wflags) \
  543. { .id = snd_soc_dapm_pga, .name = wname, .reg = SND_SOC_NOPM, .shift = 0, \
  544. .kcontrol_news = NULL, .num_kcontrols = 0, \
  545. .event = wevent, .event_flags = wflags, \
  546. .priv = (void *)&(struct sst_ids) { .task_id = wtask, .location_id = wloc_id, \
  547. .format = wformat,} \
  548. }
  549. /* output is triggered before input */
  550. #define SST_PATH_INPUT(name, task_id, loc_id, event) \
  551. SST_PATH(name, task_id, loc_id, event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)
  552. #define SST_PATH_LINKED_INPUT(name, task_id, loc_id, linked_wname, event) \
  553. SST_LINKED_PATH(name, task_id, loc_id, linked_wname, event, \
  554. SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)
  555. #define SST_PATH_OUTPUT(name, task_id, loc_id, event) \
  556. SST_PATH(name, task_id, loc_id, event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD)
  557. #define SST_PATH_LINKED_OUTPUT(name, task_id, loc_id, linked_wname, event) \
  558. SST_LINKED_PATH(name, task_id, loc_id, linked_wname, event, \
  559. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD)
  560. #define SST_PATH_MEDIA_LOOP_OUTPUT(name, task_id, loc_id, format, event) \
  561. SST_PATH_MEDIA_LOOP(name, task_id, loc_id, format, event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD)
  562. #define SST_SWM_MIXER(wname, wreg, wtask, wloc_id, wcontrols, wevent) \
  563. { .id = snd_soc_dapm_mixer, .name = wname, .reg = SND_SOC_NOPM, .shift = 0, \
  564. .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols),\
  565. .event = wevent, .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD | \
  566. SND_SOC_DAPM_POST_REG, \
  567. .priv = (void *)&(struct sst_ids) { .task_id = wtask, .location_id = wloc_id, \
  568. .reg = wreg } \
  569. }
  570. enum sst_gain_kcontrol_type {
  571. SST_GAIN_TLV,
  572. SST_GAIN_MUTE,
  573. SST_GAIN_RAMP_DURATION,
  574. };
  575. struct sst_gain_mixer_control {
  576. bool stereo;
  577. enum sst_gain_kcontrol_type type;
  578. struct sst_gain_value *gain_val;
  579. int max;
  580. int min;
  581. u16 instance_id;
  582. u16 module_id;
  583. u16 pipe_id;
  584. u16 task_id;
  585. char pname[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
  586. struct snd_soc_dapm_widget *w;
  587. };
  588. struct sst_gain_value {
  589. u16 ramp_duration;
  590. s16 l_gain;
  591. s16 r_gain;
  592. bool mute;
  593. };
  594. #define SST_GAIN_VOLUME_DEFAULT (-1440)
  595. #define SST_GAIN_RAMP_DURATION_DEFAULT 5 /* timeconstant */
  596. #define SST_GAIN_MUTE_DEFAULT true
  597. #define SST_GAIN_KCONTROL_TLV(xname, xhandler_get, xhandler_put, \
  598. xmod, xpipe, xinstance, xtask, tlv_array, xgain_val, \
  599. xmin, xmax, xpname) \
  600. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  601. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  602. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  603. .tlv.p = (tlv_array), \
  604. .info = sst_gain_ctl_info,\
  605. .get = xhandler_get, .put = xhandler_put, \
  606. .private_value = (unsigned long)&(struct sst_gain_mixer_control) \
  607. { .stereo = true, .max = xmax, .min = xmin, .type = SST_GAIN_TLV, \
  608. .module_id = xmod, .pipe_id = xpipe, .task_id = xtask,\
  609. .instance_id = xinstance, .gain_val = xgain_val, .pname = xpname}
  610. #define SST_GAIN_KCONTROL_INT(xname, xhandler_get, xhandler_put, \
  611. xmod, xpipe, xinstance, xtask, xtype, xgain_val, \
  612. xmin, xmax, xpname) \
  613. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  614. .info = sst_gain_ctl_info, \
  615. .get = xhandler_get, .put = xhandler_put, \
  616. .private_value = (unsigned long)&(struct sst_gain_mixer_control) \
  617. { .stereo = false, .max = xmax, .min = xmin, .type = xtype, \
  618. .module_id = xmod, .pipe_id = xpipe, .task_id = xtask,\
  619. .instance_id = xinstance, .gain_val = xgain_val, .pname = xpname}
  620. #define SST_GAIN_KCONTROL_BOOL(xname, xhandler_get, xhandler_put,\
  621. xmod, xpipe, xinstance, xtask, xgain_val, xpname) \
  622. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  623. .info = snd_soc_info_bool_ext, \
  624. .get = xhandler_get, .put = xhandler_put, \
  625. .private_value = (unsigned long)&(struct sst_gain_mixer_control) \
  626. { .stereo = false, .type = SST_GAIN_MUTE, \
  627. .module_id = xmod, .pipe_id = xpipe, .task_id = xtask,\
  628. .instance_id = xinstance, .gain_val = xgain_val, .pname = xpname}
  629. #define SST_CONTROL_NAME(xpname, xmname, xinstance, xtype) \
  630. xpname " " xmname " " #xinstance " " xtype
  631. #define SST_COMBO_CONTROL_NAME(xpname, xmname, xinstance, xtype, xsubmodule) \
  632. xpname " " xmname " " #xinstance " " xtype " " xsubmodule
  633. /*
  634. * 3 Controls for each Gain module
  635. * e.g. - pcm0_in Gain 0 Volume
  636. * - pcm0_in Gain 0 Ramp Delay
  637. * - pcm0_in Gain 0 Switch
  638. */
  639. #define SST_GAIN_KCONTROLS(xpname, xmname, xmin_gain, xmax_gain, xmin_tc, xmax_tc, \
  640. xhandler_get, xhandler_put, \
  641. xmod, xpipe, xinstance, xtask, tlv_array, xgain_val) \
  642. { SST_GAIN_KCONTROL_INT(SST_CONTROL_NAME(xpname, xmname, xinstance, "Ramp Delay"), \
  643. xhandler_get, xhandler_put, xmod, xpipe, xinstance, xtask, SST_GAIN_RAMP_DURATION, \
  644. xgain_val, xmin_tc, xmax_tc, xpname) }, \
  645. { SST_GAIN_KCONTROL_BOOL(SST_CONTROL_NAME(xpname, xmname, xinstance, "Switch"), \
  646. xhandler_get, xhandler_put, xmod, xpipe, xinstance, xtask, \
  647. xgain_val, xpname) } ,\
  648. { SST_GAIN_KCONTROL_TLV(SST_CONTROL_NAME(xpname, xmname, xinstance, "Volume"), \
  649. xhandler_get, xhandler_put, xmod, xpipe, xinstance, xtask, tlv_array, \
  650. xgain_val, xmin_gain, xmax_gain, xpname) }
  651. #define SST_GAIN_TC_MIN 5
  652. #define SST_GAIN_TC_MAX 5000
  653. #define SST_GAIN_MIN_VALUE -1440 /* in 0.1 DB units */
  654. #define SST_GAIN_MAX_VALUE 360
  655. enum sst_algo_kcontrol_type {
  656. SST_ALGO_PARAMS,
  657. SST_ALGO_BYPASS,
  658. };
  659. struct sst_algo_control {
  660. enum sst_algo_kcontrol_type type;
  661. int max;
  662. u16 module_id;
  663. u16 pipe_id;
  664. u16 task_id;
  665. u16 cmd_id;
  666. bool bypass;
  667. unsigned char *params;
  668. struct snd_soc_dapm_widget *w;
  669. };
  670. /* size of the control = size of params + size of length field */
  671. #define SST_ALGO_CTL_VALUE(xcount, xtype, xpipe, xmod, xtask, xcmd) \
  672. (struct sst_algo_control){ \
  673. .max = xcount + sizeof(u16), .type = xtype, .module_id = xmod, \
  674. .pipe_id = xpipe, .task_id = xtask, .cmd_id = xcmd, \
  675. }
  676. #define SST_ALGO_KCONTROL(xname, xcount, xmod, xpipe, \
  677. xtask, xcmd, xtype, xinfo, xget, xput) \
  678. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  679. .name = xname, \
  680. .info = xinfo, .get = xget, .put = xput, \
  681. .private_value = (unsigned long)& \
  682. SST_ALGO_CTL_VALUE(xcount, xtype, xpipe, \
  683. xmod, xtask, xcmd), \
  684. }
  685. #define SST_ALGO_KCONTROL_BYTES(xpname, xmname, xcount, xmod, \
  686. xpipe, xinstance, xtask, xcmd) \
  687. SST_ALGO_KCONTROL(SST_CONTROL_NAME(xpname, xmname, xinstance, "params"), \
  688. xcount, xmod, xpipe, xtask, xcmd, SST_ALGO_PARAMS, \
  689. sst_algo_bytes_ctl_info, \
  690. sst_algo_control_get, sst_algo_control_set)
  691. #define SST_ALGO_KCONTROL_BOOL(xpname, xmname, xmod, xpipe, xinstance, xtask) \
  692. SST_ALGO_KCONTROL(SST_CONTROL_NAME(xpname, xmname, xinstance, "bypass"), \
  693. 0, xmod, xpipe, xtask, 0, SST_ALGO_BYPASS, \
  694. snd_soc_info_bool_ext, \
  695. sst_algo_control_get, sst_algo_control_set)
  696. #define SST_ALGO_BYPASS_PARAMS(xpname, xmname, xcount, xmod, xpipe, \
  697. xinstance, xtask, xcmd) \
  698. SST_ALGO_KCONTROL_BOOL(xpname, xmname, xmod, xpipe, xinstance, xtask), \
  699. SST_ALGO_KCONTROL_BYTES(xpname, xmname, xcount, xmod, xpipe, xinstance, xtask, xcmd)
  700. #define SST_COMBO_ALGO_KCONTROL_BYTES(xpname, xmname, xsubmod, xcount, xmod, \
  701. xpipe, xinstance, xtask, xcmd) \
  702. SST_ALGO_KCONTROL(SST_COMBO_CONTROL_NAME(xpname, xmname, xinstance, "params", \
  703. xsubmod), \
  704. xcount, xmod, xpipe, xtask, xcmd, SST_ALGO_PARAMS, \
  705. sst_algo_bytes_ctl_info, \
  706. sst_algo_control_get, sst_algo_control_set)
  707. struct sst_enum {
  708. bool tx;
  709. unsigned short reg;
  710. unsigned int max;
  711. const char * const *texts;
  712. struct snd_soc_dapm_widget *w;
  713. };
  714. /* only 4 slots/channels supported atm */
  715. #define SST_SSP_SLOT_ENUM(s_ch_no, is_tx, xtexts) \
  716. (struct sst_enum){ .reg = s_ch_no, .tx = is_tx, .max = 4+1, .texts = xtexts, }
  717. #define SST_SLOT_CTL_NAME(xpname, xmname, s_ch_name) \
  718. xpname " " xmname " " s_ch_name
  719. #define SST_SSP_SLOT_CTL(xpname, xmname, s_ch_name, s_ch_no, is_tx, xtexts, xget, xput) \
  720. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  721. .name = SST_SLOT_CTL_NAME(xpname, xmname, s_ch_name), \
  722. .info = sst_slot_enum_info, \
  723. .get = xget, .put = xput, \
  724. .private_value = (unsigned long)&SST_SSP_SLOT_ENUM(s_ch_no, is_tx, xtexts), \
  725. }
  726. #define SST_MUX_CTL_NAME(xpname, xinstance) \
  727. xpname " " #xinstance
  728. #define SST_SSP_MUX_ENUM(xreg, xshift, xtexts) \
  729. (struct soc_enum) SOC_ENUM_DOUBLE(xreg, xshift, xshift, ARRAY_SIZE(xtexts), xtexts)
  730. #define SST_SSP_MUX_CTL(xpname, xinstance, xreg, xshift, xtexts) \
  731. SOC_DAPM_ENUM(SST_MUX_CTL_NAME(xpname, xinstance), \
  732. SST_SSP_MUX_ENUM(xreg, xshift, xtexts))
  733. int sst_fill_ssp_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
  734. unsigned int rx_mask, int slots, int slot_width);
  735. int sst_fill_ssp_config(struct snd_soc_dai *dai, unsigned int fmt);
  736. void sst_fill_ssp_defaults(struct snd_soc_dai *dai);
  737. #endif