q6audio-v2.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936
  1. /* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/slab.h>
  13. #include <linux/wait.h>
  14. #include <linux/sched.h>
  15. #include <linux/jiffies.h>
  16. #include <linux/uaccess.h>
  17. #include <linux/atomic.h>
  18. #include <dsp/q6afe-v2.h>
  19. #include <dsp/q6audio-v2.h>
  20. int q6audio_get_port_index(u16 port_id)
  21. {
  22. switch (port_id) {
  23. case PRIMARY_I2S_RX: return IDX_PRIMARY_I2S_RX;
  24. case PRIMARY_I2S_TX: return IDX_PRIMARY_I2S_TX;
  25. case AFE_PORT_ID_PRIMARY_PCM_RX:
  26. return IDX_AFE_PORT_ID_PRIMARY_PCM_RX;
  27. case AFE_PORT_ID_PRIMARY_PCM_TX:
  28. return IDX_AFE_PORT_ID_PRIMARY_PCM_TX;
  29. case AFE_PORT_ID_SECONDARY_PCM_RX:
  30. return IDX_AFE_PORT_ID_SECONDARY_PCM_RX;
  31. case AFE_PORT_ID_SECONDARY_PCM_TX:
  32. return IDX_AFE_PORT_ID_SECONDARY_PCM_TX;
  33. case AFE_PORT_ID_TERTIARY_PCM_RX:
  34. return IDX_AFE_PORT_ID_TERTIARY_PCM_RX;
  35. case AFE_PORT_ID_TERTIARY_PCM_TX:
  36. return IDX_AFE_PORT_ID_TERTIARY_PCM_TX;
  37. case AFE_PORT_ID_QUATERNARY_PCM_RX:
  38. return IDX_AFE_PORT_ID_QUATERNARY_PCM_RX;
  39. case AFE_PORT_ID_QUATERNARY_PCM_TX:
  40. return IDX_AFE_PORT_ID_QUATERNARY_PCM_TX;
  41. case AFE_PORT_ID_QUINARY_PCM_RX:
  42. return IDX_AFE_PORT_ID_QUINARY_PCM_RX;
  43. case AFE_PORT_ID_QUINARY_PCM_TX:
  44. return IDX_AFE_PORT_ID_QUINARY_PCM_TX;
  45. case SECONDARY_I2S_RX: return IDX_SECONDARY_I2S_RX;
  46. case SECONDARY_I2S_TX: return IDX_SECONDARY_I2S_TX;
  47. case MI2S_RX: return IDX_MI2S_RX;
  48. case MI2S_TX: return IDX_MI2S_TX;
  49. case HDMI_RX: return IDX_HDMI_RX;
  50. case DISPLAY_PORT_RX: return IDX_DISPLAY_PORT_RX;
  51. case AFE_PORT_ID_SPDIF_RX: return IDX_SPDIF_RX;
  52. case RSVD_2: return IDX_RSVD_2;
  53. case RSVD_3: return IDX_RSVD_3;
  54. case DIGI_MIC_TX: return IDX_DIGI_MIC_TX;
  55. case VOICE_RECORD_RX: return IDX_VOICE_RECORD_RX;
  56. case VOICE_RECORD_TX: return IDX_VOICE_RECORD_TX;
  57. case VOICE_PLAYBACK_TX: return IDX_VOICE_PLAYBACK_TX;
  58. case VOICE2_PLAYBACK_TX: return IDX_VOICE2_PLAYBACK_TX;
  59. case SLIMBUS_0_RX: return IDX_SLIMBUS_0_RX;
  60. case SLIMBUS_0_TX: return IDX_SLIMBUS_0_TX;
  61. case SLIMBUS_1_RX: return IDX_SLIMBUS_1_RX;
  62. case SLIMBUS_1_TX: return IDX_SLIMBUS_1_TX;
  63. case SLIMBUS_2_RX: return IDX_SLIMBUS_2_RX;
  64. case SLIMBUS_2_TX: return IDX_SLIMBUS_2_TX;
  65. case SLIMBUS_3_RX: return IDX_SLIMBUS_3_RX;
  66. case SLIMBUS_3_TX: return IDX_SLIMBUS_3_TX;
  67. case SLIMBUS_4_RX: return IDX_SLIMBUS_4_RX;
  68. case SLIMBUS_4_TX: return IDX_SLIMBUS_4_TX;
  69. case SLIMBUS_5_RX: return IDX_SLIMBUS_5_RX;
  70. case SLIMBUS_5_TX: return IDX_SLIMBUS_5_TX;
  71. case SLIMBUS_6_RX: return IDX_SLIMBUS_6_RX;
  72. case SLIMBUS_6_TX: return IDX_SLIMBUS_6_TX;
  73. case SLIMBUS_7_RX: return IDX_SLIMBUS_7_RX;
  74. case SLIMBUS_7_TX: return IDX_SLIMBUS_7_TX;
  75. case SLIMBUS_8_RX: return IDX_SLIMBUS_8_RX;
  76. case SLIMBUS_8_TX: return IDX_SLIMBUS_8_TX;
  77. case INT_BT_SCO_RX: return IDX_INT_BT_SCO_RX;
  78. case INT_BT_SCO_TX: return IDX_INT_BT_SCO_TX;
  79. case INT_BT_A2DP_RX: return IDX_INT_BT_A2DP_RX;
  80. case INT_FM_RX: return IDX_INT_FM_RX;
  81. case INT_FM_TX: return IDX_INT_FM_TX;
  82. case RT_PROXY_PORT_001_RX: return IDX_RT_PROXY_PORT_001_RX;
  83. case RT_PROXY_PORT_001_TX: return IDX_RT_PROXY_PORT_001_TX;
  84. case AFE_PORT_ID_PRIMARY_MI2S_RX:
  85. return IDX_AFE_PORT_ID_PRIMARY_MI2S_RX;
  86. case AFE_PORT_ID_PRIMARY_MI2S_TX:
  87. return IDX_AFE_PORT_ID_PRIMARY_MI2S_TX;
  88. case AFE_PORT_ID_QUATERNARY_MI2S_RX:
  89. return IDX_AFE_PORT_ID_QUATERNARY_MI2S_RX;
  90. case AFE_PORT_ID_QUATERNARY_MI2S_TX:
  91. return IDX_AFE_PORT_ID_QUATERNARY_MI2S_TX;
  92. case AFE_PORT_ID_SECONDARY_MI2S_RX:
  93. return IDX_AFE_PORT_ID_SECONDARY_MI2S_RX;
  94. case AFE_PORT_ID_SECONDARY_MI2S_TX:
  95. return IDX_AFE_PORT_ID_SECONDARY_MI2S_TX;
  96. case AFE_PORT_ID_TERTIARY_MI2S_RX:
  97. return IDX_AFE_PORT_ID_TERTIARY_MI2S_RX;
  98. case AFE_PORT_ID_TERTIARY_MI2S_TX:
  99. return IDX_AFE_PORT_ID_TERTIARY_MI2S_TX;
  100. case AFE_PORT_ID_QUINARY_MI2S_RX:
  101. return IDX_AFE_PORT_ID_QUINARY_MI2S_RX;
  102. case AFE_PORT_ID_QUINARY_MI2S_TX:
  103. return IDX_AFE_PORT_ID_QUINARY_MI2S_TX;
  104. case AUDIO_PORT_ID_I2S_RX:
  105. return IDX_AUDIO_PORT_ID_I2S_RX;
  106. case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
  107. return IDX_AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  108. case AFE_PORT_ID_PRIMARY_TDM_RX:
  109. return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_0;
  110. case AFE_PORT_ID_PRIMARY_TDM_TX:
  111. return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_0;
  112. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  113. return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_1;
  114. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  115. return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_1;
  116. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  117. return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_2;
  118. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  119. return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_2;
  120. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  121. return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_3;
  122. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  123. return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_3;
  124. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  125. return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_4;
  126. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  127. return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_4;
  128. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  129. return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_5;
  130. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  131. return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_5;
  132. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  133. return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_6;
  134. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  135. return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_6;
  136. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  137. return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_7;
  138. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  139. return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_7;
  140. case AFE_PORT_ID_SECONDARY_TDM_RX:
  141. return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_0;
  142. case AFE_PORT_ID_SECONDARY_TDM_TX:
  143. return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_0;
  144. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  145. return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_1;
  146. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  147. return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_1;
  148. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  149. return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_2;
  150. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  151. return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_2;
  152. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  153. return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_3;
  154. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  155. return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_3;
  156. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  157. return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_4;
  158. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  159. return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_4;
  160. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  161. return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_5;
  162. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  163. return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_5;
  164. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  165. return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_6;
  166. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  167. return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_6;
  168. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  169. return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_7;
  170. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  171. return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_7;
  172. case AFE_PORT_ID_TERTIARY_TDM_RX:
  173. return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_0;
  174. case AFE_PORT_ID_TERTIARY_TDM_TX:
  175. return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_0;
  176. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  177. return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_1;
  178. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  179. return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_1;
  180. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  181. return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_2;
  182. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  183. return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_2;
  184. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  185. return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_3;
  186. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  187. return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_3;
  188. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  189. return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_4;
  190. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  191. return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_4;
  192. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  193. return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_5;
  194. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  195. return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_5;
  196. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  197. return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_6;
  198. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  199. return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_6;
  200. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  201. return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_7;
  202. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  203. return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_7;
  204. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  205. return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_0;
  206. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  207. return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_0;
  208. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  209. return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_1;
  210. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  211. return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_1;
  212. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  213. return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_2;
  214. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  215. return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_2;
  216. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  217. return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_3;
  218. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  219. return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_3;
  220. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  221. return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_4;
  222. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  223. return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_4;
  224. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  225. return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_5;
  226. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  227. return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_5;
  228. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  229. return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_6;
  230. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  231. return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_6;
  232. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  233. return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_7;
  234. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  235. return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_7;
  236. case AFE_PORT_ID_QUINARY_TDM_RX:
  237. return IDX_AFE_PORT_ID_QUINARY_TDM_RX_0;
  238. case AFE_PORT_ID_QUINARY_TDM_TX:
  239. return IDX_AFE_PORT_ID_QUINARY_TDM_TX_0;
  240. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  241. return IDX_AFE_PORT_ID_QUINARY_TDM_RX_1;
  242. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  243. return IDX_AFE_PORT_ID_QUINARY_TDM_TX_1;
  244. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  245. return IDX_AFE_PORT_ID_QUINARY_TDM_RX_2;
  246. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  247. return IDX_AFE_PORT_ID_QUINARY_TDM_TX_2;
  248. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  249. return IDX_AFE_PORT_ID_QUINARY_TDM_RX_3;
  250. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  251. return IDX_AFE_PORT_ID_QUINARY_TDM_TX_3;
  252. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  253. return IDX_AFE_PORT_ID_QUINARY_TDM_RX_4;
  254. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  255. return IDX_AFE_PORT_ID_QUINARY_TDM_TX_4;
  256. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  257. return IDX_AFE_PORT_ID_QUINARY_TDM_RX_5;
  258. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  259. return IDX_AFE_PORT_ID_QUINARY_TDM_TX_5;
  260. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  261. return IDX_AFE_PORT_ID_QUINARY_TDM_RX_6;
  262. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  263. return IDX_AFE_PORT_ID_QUINARY_TDM_TX_6;
  264. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  265. return IDX_AFE_PORT_ID_QUINARY_TDM_RX_7;
  266. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  267. return IDX_AFE_PORT_ID_QUINARY_TDM_TX_7;
  268. case AFE_PORT_ID_SENARY_MI2S_TX:
  269. return IDX_AFE_PORT_ID_SENARY_MI2S_TX;
  270. case AFE_PORT_ID_USB_RX:
  271. return IDX_AFE_PORT_ID_USB_RX;
  272. case AFE_PORT_ID_USB_TX:
  273. return IDX_AFE_PORT_ID_USB_TX;
  274. case AFE_PORT_ID_INT0_MI2S_RX:
  275. return IDX_AFE_PORT_ID_INT0_MI2S_RX;
  276. case AFE_PORT_ID_INT0_MI2S_TX:
  277. return IDX_AFE_PORT_ID_INT0_MI2S_TX;
  278. case AFE_PORT_ID_INT1_MI2S_RX:
  279. return IDX_AFE_PORT_ID_INT1_MI2S_RX;
  280. case AFE_PORT_ID_INT1_MI2S_TX:
  281. return IDX_AFE_PORT_ID_INT1_MI2S_TX;
  282. case AFE_PORT_ID_INT2_MI2S_RX:
  283. return IDX_AFE_PORT_ID_INT2_MI2S_RX;
  284. case AFE_PORT_ID_INT2_MI2S_TX:
  285. return IDX_AFE_PORT_ID_INT2_MI2S_TX;
  286. case AFE_PORT_ID_INT3_MI2S_RX:
  287. return IDX_AFE_PORT_ID_INT3_MI2S_RX;
  288. case AFE_PORT_ID_INT3_MI2S_TX:
  289. return IDX_AFE_PORT_ID_INT3_MI2S_TX;
  290. case AFE_PORT_ID_INT4_MI2S_RX:
  291. return IDX_AFE_PORT_ID_INT4_MI2S_RX;
  292. case AFE_PORT_ID_INT4_MI2S_TX:
  293. return IDX_AFE_PORT_ID_INT4_MI2S_TX;
  294. case AFE_PORT_ID_INT5_MI2S_RX:
  295. return IDX_AFE_PORT_ID_INT5_MI2S_RX;
  296. case AFE_PORT_ID_INT5_MI2S_TX:
  297. return IDX_AFE_PORT_ID_INT5_MI2S_TX;
  298. case AFE_PORT_ID_INT6_MI2S_RX:
  299. return IDX_AFE_PORT_ID_INT6_MI2S_RX;
  300. case AFE_PORT_ID_INT6_MI2S_TX:
  301. return IDX_AFE_PORT_ID_INT6_MI2S_TX;
  302. default: return -EINVAL;
  303. }
  304. }
  305. int q6audio_get_port_id(u16 port_id)
  306. {
  307. switch (port_id) {
  308. case PRIMARY_I2S_RX: return PRIMARY_I2S_RX;
  309. case PRIMARY_I2S_TX: return PRIMARY_I2S_TX;
  310. case AFE_PORT_ID_PRIMARY_PCM_RX:
  311. return AFE_PORT_ID_PRIMARY_PCM_RX;
  312. case AFE_PORT_ID_PRIMARY_PCM_TX:
  313. return AFE_PORT_ID_PRIMARY_PCM_TX;
  314. case AFE_PORT_ID_SECONDARY_PCM_RX:
  315. return AFE_PORT_ID_SECONDARY_PCM_RX;
  316. case AFE_PORT_ID_SECONDARY_PCM_TX:
  317. return AFE_PORT_ID_SECONDARY_PCM_TX;
  318. case AFE_PORT_ID_TERTIARY_PCM_RX:
  319. return AFE_PORT_ID_TERTIARY_PCM_RX;
  320. case AFE_PORT_ID_TERTIARY_PCM_TX:
  321. return AFE_PORT_ID_TERTIARY_PCM_TX;
  322. case AFE_PORT_ID_QUATERNARY_PCM_RX:
  323. return AFE_PORT_ID_QUATERNARY_PCM_RX;
  324. case AFE_PORT_ID_QUATERNARY_PCM_TX:
  325. return AFE_PORT_ID_QUATERNARY_PCM_TX;
  326. case AFE_PORT_ID_QUINARY_PCM_RX:
  327. return AFE_PORT_ID_QUINARY_PCM_RX;
  328. case AFE_PORT_ID_QUINARY_PCM_TX:
  329. return AFE_PORT_ID_QUINARY_PCM_TX;
  330. case SECONDARY_I2S_RX: return AFE_PORT_ID_SECONDARY_MI2S_RX;
  331. case SECONDARY_I2S_TX: return AFE_PORT_ID_SECONDARY_MI2S_TX;
  332. case MI2S_RX: return AFE_PORT_ID_PRIMARY_MI2S_RX;
  333. case MI2S_TX: return AFE_PORT_ID_PRIMARY_MI2S_TX;
  334. case HDMI_RX: return AFE_PORT_ID_MULTICHAN_HDMI_RX;
  335. case DISPLAY_PORT_RX:
  336. return AFE_PORT_ID_HDMI_OVER_DP_RX;
  337. case AFE_PORT_ID_SPDIF_RX: return AFE_PORT_ID_SPDIF_RX;
  338. case RSVD_2: return IDX_RSVD_2;
  339. case RSVD_3: return IDX_RSVD_3;
  340. case DIGI_MIC_TX: return AFE_PORT_ID_DIGITAL_MIC_TX;
  341. case VOICE_RECORD_RX: return AFE_PORT_ID_VOICE_RECORD_RX;
  342. case VOICE_RECORD_TX: return AFE_PORT_ID_VOICE_RECORD_TX;
  343. case VOICE_PLAYBACK_TX: return AFE_PORT_ID_VOICE_PLAYBACK_TX;
  344. case VOICE2_PLAYBACK_TX: return AFE_PORT_ID_VOICE2_PLAYBACK_TX;
  345. case SLIMBUS_0_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_RX;
  346. case SLIMBUS_0_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_TX;
  347. case SLIMBUS_1_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_RX;
  348. case SLIMBUS_1_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_TX;
  349. case SLIMBUS_2_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_RX;
  350. case SLIMBUS_2_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_TX;
  351. case SLIMBUS_3_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_RX;
  352. case SLIMBUS_3_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_TX;
  353. case SLIMBUS_4_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_RX;
  354. case SLIMBUS_4_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_TX;
  355. case SLIMBUS_5_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_RX;
  356. case SLIMBUS_5_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_TX;
  357. case SLIMBUS_6_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX;
  358. case SLIMBUS_6_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_TX;
  359. case SLIMBUS_7_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_7_RX;
  360. case SLIMBUS_7_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_7_TX;
  361. case SLIMBUS_8_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_8_RX;
  362. case SLIMBUS_8_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_8_TX;
  363. case INT_BT_SCO_RX: return AFE_PORT_ID_INTERNAL_BT_SCO_RX;
  364. case INT_BT_SCO_TX: return AFE_PORT_ID_INTERNAL_BT_SCO_TX;
  365. case INT_BT_A2DP_RX: return AFE_PORT_ID_INTERNAL_BT_A2DP_RX;
  366. case INT_FM_RX: return AFE_PORT_ID_INTERNAL_FM_RX;
  367. case INT_FM_TX: return AFE_PORT_ID_INTERNAL_FM_TX;
  368. case RT_PROXY_PORT_001_RX: return AFE_PORT_ID_RT_PROXY_PORT_001_RX;
  369. case RT_PROXY_PORT_001_TX: return AFE_PORT_ID_RT_PROXY_PORT_001_TX;
  370. case AFE_PORT_ID_PRIMARY_MI2S_RX:
  371. return AFE_PORT_ID_PRIMARY_MI2S_RX;
  372. case AFE_PORT_ID_PRIMARY_MI2S_TX:
  373. return AFE_PORT_ID_PRIMARY_MI2S_TX;
  374. case AFE_PORT_ID_QUATERNARY_MI2S_RX:
  375. return AFE_PORT_ID_QUATERNARY_MI2S_RX;
  376. case AFE_PORT_ID_QUATERNARY_MI2S_TX:
  377. return AFE_PORT_ID_QUATERNARY_MI2S_TX;
  378. case AFE_PORT_ID_SECONDARY_MI2S_RX:
  379. return AFE_PORT_ID_SECONDARY_MI2S_RX;
  380. case AFE_PORT_ID_SECONDARY_MI2S_TX:
  381. return AFE_PORT_ID_SECONDARY_MI2S_TX;
  382. case AFE_PORT_ID_TERTIARY_MI2S_RX:
  383. return AFE_PORT_ID_TERTIARY_MI2S_RX;
  384. case AFE_PORT_ID_TERTIARY_MI2S_TX:
  385. return AFE_PORT_ID_TERTIARY_MI2S_TX;
  386. case AFE_PORT_ID_QUINARY_MI2S_RX:
  387. return AFE_PORT_ID_QUINARY_MI2S_RX;
  388. case AFE_PORT_ID_QUINARY_MI2S_TX:
  389. return AFE_PORT_ID_QUINARY_MI2S_TX;
  390. case AUDIO_PORT_ID_I2S_RX:
  391. return AUDIO_PORT_ID_I2S_RX;
  392. case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
  393. return AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  394. case AFE_PORT_ID_PRIMARY_TDM_RX:
  395. return AFE_PORT_ID_PRIMARY_TDM_RX;
  396. case AFE_PORT_ID_PRIMARY_TDM_TX:
  397. return AFE_PORT_ID_PRIMARY_TDM_TX;
  398. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  399. return AFE_PORT_ID_PRIMARY_TDM_RX_1;
  400. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  401. return AFE_PORT_ID_PRIMARY_TDM_TX_1;
  402. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  403. return AFE_PORT_ID_PRIMARY_TDM_RX_2;
  404. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  405. return AFE_PORT_ID_PRIMARY_TDM_TX_2;
  406. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  407. return AFE_PORT_ID_PRIMARY_TDM_RX_3;
  408. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  409. return AFE_PORT_ID_PRIMARY_TDM_TX_3;
  410. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  411. return AFE_PORT_ID_PRIMARY_TDM_RX_4;
  412. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  413. return AFE_PORT_ID_PRIMARY_TDM_TX_4;
  414. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  415. return AFE_PORT_ID_PRIMARY_TDM_RX_5;
  416. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  417. return AFE_PORT_ID_PRIMARY_TDM_TX_5;
  418. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  419. return AFE_PORT_ID_PRIMARY_TDM_RX_6;
  420. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  421. return AFE_PORT_ID_PRIMARY_TDM_TX_6;
  422. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  423. return AFE_PORT_ID_PRIMARY_TDM_RX_7;
  424. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  425. return AFE_PORT_ID_PRIMARY_TDM_TX_7;
  426. case AFE_PORT_ID_SECONDARY_TDM_RX:
  427. return AFE_PORT_ID_SECONDARY_TDM_RX;
  428. case AFE_PORT_ID_SECONDARY_TDM_TX:
  429. return AFE_PORT_ID_SECONDARY_TDM_TX;
  430. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  431. return AFE_PORT_ID_SECONDARY_TDM_RX_1;
  432. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  433. return AFE_PORT_ID_SECONDARY_TDM_TX_1;
  434. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  435. return AFE_PORT_ID_SECONDARY_TDM_RX_2;
  436. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  437. return AFE_PORT_ID_SECONDARY_TDM_TX_2;
  438. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  439. return AFE_PORT_ID_SECONDARY_TDM_RX_3;
  440. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  441. return AFE_PORT_ID_SECONDARY_TDM_TX_3;
  442. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  443. return AFE_PORT_ID_SECONDARY_TDM_RX_4;
  444. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  445. return AFE_PORT_ID_SECONDARY_TDM_TX_4;
  446. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  447. return AFE_PORT_ID_SECONDARY_TDM_RX_5;
  448. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  449. return AFE_PORT_ID_SECONDARY_TDM_TX_5;
  450. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  451. return AFE_PORT_ID_SECONDARY_TDM_RX_6;
  452. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  453. return AFE_PORT_ID_SECONDARY_TDM_TX_6;
  454. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  455. return AFE_PORT_ID_SECONDARY_TDM_RX_7;
  456. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  457. return AFE_PORT_ID_SECONDARY_TDM_TX_7;
  458. case AFE_PORT_ID_TERTIARY_TDM_RX:
  459. return AFE_PORT_ID_TERTIARY_TDM_RX;
  460. case AFE_PORT_ID_TERTIARY_TDM_TX:
  461. return AFE_PORT_ID_TERTIARY_TDM_TX;
  462. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  463. return AFE_PORT_ID_TERTIARY_TDM_RX_1;
  464. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  465. return AFE_PORT_ID_TERTIARY_TDM_TX_1;
  466. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  467. return AFE_PORT_ID_TERTIARY_TDM_RX_2;
  468. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  469. return AFE_PORT_ID_TERTIARY_TDM_TX_2;
  470. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  471. return AFE_PORT_ID_TERTIARY_TDM_RX_3;
  472. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  473. return AFE_PORT_ID_TERTIARY_TDM_TX_3;
  474. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  475. return AFE_PORT_ID_TERTIARY_TDM_RX_4;
  476. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  477. return AFE_PORT_ID_TERTIARY_TDM_TX_4;
  478. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  479. return AFE_PORT_ID_TERTIARY_TDM_RX_5;
  480. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  481. return AFE_PORT_ID_TERTIARY_TDM_TX_5;
  482. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  483. return AFE_PORT_ID_TERTIARY_TDM_RX_6;
  484. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  485. return AFE_PORT_ID_TERTIARY_TDM_TX_6;
  486. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  487. return AFE_PORT_ID_TERTIARY_TDM_RX_7;
  488. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  489. return AFE_PORT_ID_TERTIARY_TDM_TX_7;
  490. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  491. return AFE_PORT_ID_QUATERNARY_TDM_RX;
  492. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  493. return AFE_PORT_ID_QUATERNARY_TDM_TX;
  494. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  495. return AFE_PORT_ID_QUATERNARY_TDM_RX_1;
  496. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  497. return AFE_PORT_ID_QUATERNARY_TDM_TX_1;
  498. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  499. return AFE_PORT_ID_QUATERNARY_TDM_RX_2;
  500. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  501. return AFE_PORT_ID_QUATERNARY_TDM_TX_2;
  502. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  503. return AFE_PORT_ID_QUATERNARY_TDM_RX_3;
  504. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  505. return AFE_PORT_ID_QUATERNARY_TDM_TX_3;
  506. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  507. return AFE_PORT_ID_QUATERNARY_TDM_RX_4;
  508. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  509. return AFE_PORT_ID_QUATERNARY_TDM_TX_4;
  510. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  511. return AFE_PORT_ID_QUATERNARY_TDM_RX_5;
  512. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  513. return AFE_PORT_ID_QUATERNARY_TDM_TX_5;
  514. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  515. return AFE_PORT_ID_QUATERNARY_TDM_RX_6;
  516. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  517. return AFE_PORT_ID_QUATERNARY_TDM_TX_6;
  518. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  519. return AFE_PORT_ID_QUATERNARY_TDM_RX_7;
  520. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  521. return AFE_PORT_ID_QUATERNARY_TDM_TX_7;
  522. case AFE_PORT_ID_QUINARY_TDM_RX:
  523. return AFE_PORT_ID_QUINARY_TDM_RX;
  524. case AFE_PORT_ID_QUINARY_TDM_TX:
  525. return AFE_PORT_ID_QUINARY_TDM_TX;
  526. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  527. return AFE_PORT_ID_QUINARY_TDM_RX_1;
  528. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  529. return AFE_PORT_ID_QUINARY_TDM_TX_1;
  530. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  531. return AFE_PORT_ID_QUINARY_TDM_RX_2;
  532. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  533. return AFE_PORT_ID_QUINARY_TDM_TX_2;
  534. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  535. return AFE_PORT_ID_QUINARY_TDM_RX_3;
  536. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  537. return AFE_PORT_ID_QUINARY_TDM_TX_3;
  538. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  539. return AFE_PORT_ID_QUINARY_TDM_RX_4;
  540. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  541. return AFE_PORT_ID_QUINARY_TDM_TX_4;
  542. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  543. return AFE_PORT_ID_QUINARY_TDM_RX_5;
  544. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  545. return AFE_PORT_ID_QUINARY_TDM_TX_5;
  546. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  547. return AFE_PORT_ID_QUINARY_TDM_RX_6;
  548. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  549. return AFE_PORT_ID_QUINARY_TDM_TX_6;
  550. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  551. return AFE_PORT_ID_QUINARY_TDM_RX_7;
  552. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  553. return AFE_PORT_ID_QUINARY_TDM_TX_7;
  554. case AFE_PORT_ID_SENARY_MI2S_TX:
  555. return AFE_PORT_ID_SENARY_MI2S_TX;
  556. case AFE_PORT_ID_USB_RX:
  557. return AFE_PORT_ID_USB_RX;
  558. case AFE_PORT_ID_USB_TX:
  559. return AFE_PORT_ID_USB_TX;
  560. case AFE_PORT_ID_INT0_MI2S_RX:
  561. return AFE_PORT_ID_INT0_MI2S_RX;
  562. case AFE_PORT_ID_INT0_MI2S_TX:
  563. return AFE_PORT_ID_INT0_MI2S_TX;
  564. case AFE_PORT_ID_INT1_MI2S_RX:
  565. return AFE_PORT_ID_INT1_MI2S_RX;
  566. case AFE_PORT_ID_INT1_MI2S_TX:
  567. return AFE_PORT_ID_INT1_MI2S_TX;
  568. case AFE_PORT_ID_INT2_MI2S_RX:
  569. return AFE_PORT_ID_INT2_MI2S_RX;
  570. case AFE_PORT_ID_INT2_MI2S_TX:
  571. return AFE_PORT_ID_INT2_MI2S_TX;
  572. case AFE_PORT_ID_INT3_MI2S_RX:
  573. return AFE_PORT_ID_INT3_MI2S_RX;
  574. case AFE_PORT_ID_INT3_MI2S_TX:
  575. return AFE_PORT_ID_INT3_MI2S_TX;
  576. case AFE_PORT_ID_INT4_MI2S_RX:
  577. return AFE_PORT_ID_INT4_MI2S_RX;
  578. case AFE_PORT_ID_INT4_MI2S_TX:
  579. return AFE_PORT_ID_INT4_MI2S_TX;
  580. case AFE_PORT_ID_INT5_MI2S_RX:
  581. return AFE_PORT_ID_INT5_MI2S_RX;
  582. case AFE_PORT_ID_INT5_MI2S_TX:
  583. return AFE_PORT_ID_INT5_MI2S_TX;
  584. case AFE_PORT_ID_INT6_MI2S_RX:
  585. return AFE_PORT_ID_INT6_MI2S_RX;
  586. case AFE_PORT_ID_INT6_MI2S_TX:
  587. return AFE_PORT_ID_INT6_MI2S_TX;
  588. default:
  589. pr_warn("%s: Invalid port_id %d\n", __func__, port_id);
  590. return -EINVAL;
  591. }
  592. }
  593. int q6audio_convert_virtual_to_portid(u16 port_id)
  594. {
  595. int ret;
  596. /* if port_id is virtual, convert to physical..
  597. * if port_id is already physical, return physical
  598. */
  599. if (q6audio_validate_port(port_id) < 0) {
  600. if (port_id == RT_PROXY_DAI_001_RX ||
  601. port_id == RT_PROXY_DAI_001_TX ||
  602. port_id == RT_PROXY_DAI_002_RX ||
  603. port_id == RT_PROXY_DAI_002_TX)
  604. ret = VIRTUAL_ID_TO_PORTID(port_id);
  605. else
  606. ret = -EINVAL;
  607. } else
  608. ret = port_id;
  609. return ret;
  610. }
  611. int q6audio_is_digital_pcm_interface(u16 port_id)
  612. {
  613. int ret = 0;
  614. switch (port_id) {
  615. case PRIMARY_I2S_RX:
  616. case PRIMARY_I2S_TX:
  617. case AFE_PORT_ID_PRIMARY_PCM_RX:
  618. case AFE_PORT_ID_PRIMARY_PCM_TX:
  619. case AFE_PORT_ID_SECONDARY_PCM_RX:
  620. case AFE_PORT_ID_SECONDARY_PCM_TX:
  621. case AFE_PORT_ID_TERTIARY_PCM_RX:
  622. case AFE_PORT_ID_TERTIARY_PCM_TX:
  623. case AFE_PORT_ID_QUATERNARY_PCM_RX:
  624. case AFE_PORT_ID_QUATERNARY_PCM_TX:
  625. case AFE_PORT_ID_QUINARY_PCM_RX:
  626. case AFE_PORT_ID_QUINARY_PCM_TX:
  627. case SECONDARY_I2S_RX:
  628. case SECONDARY_I2S_TX:
  629. case MI2S_RX:
  630. case MI2S_TX:
  631. case AFE_PORT_ID_TERTIARY_MI2S_TX:
  632. case AFE_PORT_ID_TERTIARY_MI2S_RX:
  633. case AFE_PORT_ID_QUINARY_MI2S_TX:
  634. case AFE_PORT_ID_QUINARY_MI2S_RX:
  635. case AFE_PORT_ID_QUATERNARY_MI2S_RX:
  636. case AFE_PORT_ID_QUATERNARY_MI2S_TX:
  637. case AFE_PORT_ID_PRIMARY_MI2S_RX:
  638. case AFE_PORT_ID_PRIMARY_MI2S_TX:
  639. case AFE_PORT_ID_SECONDARY_MI2S_RX:
  640. case AFE_PORT_ID_SECONDARY_MI2S_TX:
  641. case AUDIO_PORT_ID_I2S_RX:
  642. case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
  643. case AFE_PORT_ID_PRIMARY_TDM_RX:
  644. case AFE_PORT_ID_PRIMARY_TDM_TX:
  645. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  646. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  647. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  648. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  649. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  650. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  651. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  652. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  653. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  654. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  655. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  656. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  657. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  658. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  659. case AFE_PORT_ID_SECONDARY_TDM_RX:
  660. case AFE_PORT_ID_SECONDARY_TDM_TX:
  661. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  662. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  663. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  664. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  665. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  666. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  667. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  668. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  669. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  670. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  671. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  672. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  673. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  674. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  675. case AFE_PORT_ID_TERTIARY_TDM_RX:
  676. case AFE_PORT_ID_TERTIARY_TDM_TX:
  677. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  678. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  679. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  680. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  681. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  682. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  683. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  684. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  685. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  686. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  687. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  688. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  689. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  690. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  691. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  692. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  693. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  694. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  695. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  696. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  697. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  698. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  699. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  700. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  701. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  702. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  703. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  704. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  705. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  706. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  707. case AFE_PORT_ID_QUINARY_TDM_RX:
  708. case AFE_PORT_ID_QUINARY_TDM_TX:
  709. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  710. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  711. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  712. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  713. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  714. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  715. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  716. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  717. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  718. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  719. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  720. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  721. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  722. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  723. case AFE_PORT_ID_SENARY_MI2S_TX:
  724. case AFE_PORT_ID_INT0_MI2S_RX:
  725. case AFE_PORT_ID_INT0_MI2S_TX:
  726. case AFE_PORT_ID_INT1_MI2S_RX:
  727. case AFE_PORT_ID_INT1_MI2S_TX:
  728. case AFE_PORT_ID_INT2_MI2S_RX:
  729. case AFE_PORT_ID_INT2_MI2S_TX:
  730. case AFE_PORT_ID_INT3_MI2S_RX:
  731. case AFE_PORT_ID_INT3_MI2S_TX:
  732. case AFE_PORT_ID_INT4_MI2S_RX:
  733. case AFE_PORT_ID_INT4_MI2S_TX:
  734. case AFE_PORT_ID_INT5_MI2S_RX:
  735. case AFE_PORT_ID_INT5_MI2S_TX:
  736. case AFE_PORT_ID_INT6_MI2S_RX:
  737. case AFE_PORT_ID_INT6_MI2S_TX:
  738. break;
  739. default:
  740. ret = -EINVAL;
  741. }
  742. return ret;
  743. }
  744. /**
  745. * q6audio_validate_port -
  746. * validates port id
  747. *
  748. * @port_id: port id to validate
  749. *
  750. * Returns 0 on success or error on invalid port
  751. */
  752. int q6audio_validate_port(u16 port_id)
  753. {
  754. int ret;
  755. switch (port_id) {
  756. case PRIMARY_I2S_RX:
  757. case PRIMARY_I2S_TX:
  758. case AFE_PORT_ID_PRIMARY_PCM_RX:
  759. case AFE_PORT_ID_PRIMARY_PCM_TX:
  760. case AFE_PORT_ID_SECONDARY_PCM_RX:
  761. case AFE_PORT_ID_SECONDARY_PCM_TX:
  762. case AFE_PORT_ID_TERTIARY_PCM_RX:
  763. case AFE_PORT_ID_TERTIARY_PCM_TX:
  764. case AFE_PORT_ID_QUATERNARY_PCM_RX:
  765. case AFE_PORT_ID_QUATERNARY_PCM_TX:
  766. case AFE_PORT_ID_QUINARY_PCM_RX:
  767. case AFE_PORT_ID_QUINARY_PCM_TX:
  768. case SECONDARY_I2S_RX:
  769. case SECONDARY_I2S_TX:
  770. case MI2S_RX:
  771. case MI2S_TX:
  772. case HDMI_RX:
  773. case DISPLAY_PORT_RX:
  774. case RSVD_2:
  775. case RSVD_3:
  776. case DIGI_MIC_TX:
  777. case VOICE_RECORD_RX:
  778. case VOICE_RECORD_TX:
  779. case VOICE_PLAYBACK_TX:
  780. case VOICE2_PLAYBACK_TX:
  781. case SLIMBUS_0_RX:
  782. case SLIMBUS_0_TX:
  783. case SLIMBUS_1_RX:
  784. case SLIMBUS_1_TX:
  785. case SLIMBUS_2_RX:
  786. case SLIMBUS_2_TX:
  787. case SLIMBUS_3_RX:
  788. case SLIMBUS_3_TX:
  789. case SLIMBUS_4_RX:
  790. case SLIMBUS_4_TX:
  791. case SLIMBUS_5_RX:
  792. case SLIMBUS_5_TX:
  793. case SLIMBUS_6_RX:
  794. case SLIMBUS_6_TX:
  795. case SLIMBUS_7_RX:
  796. case SLIMBUS_7_TX:
  797. case SLIMBUS_8_RX:
  798. case SLIMBUS_8_TX:
  799. case INT_BT_SCO_RX:
  800. case INT_BT_SCO_TX:
  801. case INT_BT_A2DP_RX:
  802. case INT_FM_RX:
  803. case INT_FM_TX:
  804. case RT_PROXY_PORT_001_RX:
  805. case RT_PROXY_PORT_001_TX:
  806. case AFE_PORT_ID_PRIMARY_MI2S_RX:
  807. case AFE_PORT_ID_PRIMARY_MI2S_TX:
  808. case AFE_PORT_ID_QUATERNARY_MI2S_RX:
  809. case AFE_PORT_ID_QUATERNARY_MI2S_TX:
  810. case AFE_PORT_ID_SECONDARY_MI2S_RX:
  811. case AFE_PORT_ID_SECONDARY_MI2S_TX:
  812. case AFE_PORT_ID_SPDIF_RX:
  813. case AFE_PORT_ID_TERTIARY_MI2S_RX:
  814. case AFE_PORT_ID_TERTIARY_MI2S_TX:
  815. case AFE_PORT_ID_QUINARY_MI2S_RX:
  816. case AFE_PORT_ID_QUINARY_MI2S_TX:
  817. case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
  818. case AFE_PORT_ID_PRIMARY_TDM_RX:
  819. case AFE_PORT_ID_PRIMARY_TDM_TX:
  820. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  821. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  822. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  823. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  824. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  825. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  826. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  827. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  828. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  829. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  830. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  831. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  832. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  833. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  834. case AFE_PORT_ID_SECONDARY_TDM_RX:
  835. case AFE_PORT_ID_SECONDARY_TDM_TX:
  836. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  837. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  838. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  839. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  840. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  841. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  842. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  843. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  844. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  845. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  846. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  847. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  848. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  849. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  850. case AFE_PORT_ID_TERTIARY_TDM_RX:
  851. case AFE_PORT_ID_TERTIARY_TDM_TX:
  852. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  853. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  854. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  855. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  856. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  857. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  858. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  859. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  860. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  861. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  862. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  863. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  864. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  865. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  866. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  867. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  868. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  869. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  870. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  871. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  872. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  873. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  874. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  875. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  876. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  877. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  878. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  879. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  880. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  881. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  882. case AFE_PORT_ID_QUINARY_TDM_RX:
  883. case AFE_PORT_ID_QUINARY_TDM_TX:
  884. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  885. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  886. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  887. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  888. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  889. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  890. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  891. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  892. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  893. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  894. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  895. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  896. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  897. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  898. case AFE_PORT_ID_SENARY_MI2S_TX:
  899. case AFE_PORT_ID_USB_RX:
  900. case AFE_PORT_ID_USB_TX:
  901. case AFE_PORT_ID_INT0_MI2S_RX:
  902. case AFE_PORT_ID_INT0_MI2S_TX:
  903. case AFE_PORT_ID_INT1_MI2S_RX:
  904. case AFE_PORT_ID_INT1_MI2S_TX:
  905. case AFE_PORT_ID_INT2_MI2S_RX:
  906. case AFE_PORT_ID_INT2_MI2S_TX:
  907. case AFE_PORT_ID_INT3_MI2S_RX:
  908. case AFE_PORT_ID_INT3_MI2S_TX:
  909. case AFE_PORT_ID_INT4_MI2S_RX:
  910. case AFE_PORT_ID_INT4_MI2S_TX:
  911. case AFE_PORT_ID_INT5_MI2S_RX:
  912. case AFE_PORT_ID_INT5_MI2S_TX:
  913. case AFE_PORT_ID_INT6_MI2S_RX:
  914. case AFE_PORT_ID_INT6_MI2S_TX:
  915. {
  916. ret = 0;
  917. break;
  918. }
  919. default:
  920. ret = -EINVAL;
  921. }
  922. return ret;
  923. }
  924. EXPORT_SYMBOL(q6audio_validate_port);