sst-atom-controls.h 26 KB

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