sst-atom-controls.h 27 KB

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