msm-pcm-voice.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /* Copyright (c) 2011-2013, 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/init.h>
  13. #include <linux/err.h>
  14. #include <linux/module.h>
  15. #include <linux/time.h>
  16. #include <linux/wait.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/slab.h>
  19. #include <sound/core.h>
  20. #include <sound/soc.h>
  21. #include <sound/soc-dapm.h>
  22. #include <sound/pcm.h>
  23. #include <sound/initval.h>
  24. #include <sound/control.h>
  25. #include <asm/dma.h>
  26. #include <linux/dma-mapping.h>
  27. #include "msm-pcm-voice.h"
  28. #include "qdsp6/q6voice.h"
  29. static struct msm_voice voice_info[VOICE_SESSION_INDEX_MAX];
  30. static struct snd_pcm_hardware msm_pcm_hardware = {
  31. .info = (SNDRV_PCM_INFO_INTERLEAVED|
  32. SNDRV_PCM_INFO_PAUSE |
  33. SNDRV_PCM_INFO_RESUME),
  34. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  35. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  36. .rate_min = 8000,
  37. .rate_max = 16000,
  38. .channels_min = 1,
  39. .channels_max = 1,
  40. .buffer_bytes_max = 4096 * 2,
  41. .period_bytes_min = 4096,
  42. .period_bytes_max = 4096,
  43. .periods_min = 2,
  44. .periods_max = 2,
  45. .fifo_size = 0,
  46. };
  47. static int is_volte(struct msm_voice *pvolte)
  48. {
  49. if (pvolte == &voice_info[VOLTE_SESSION_INDEX])
  50. return true;
  51. else
  52. return false;
  53. }
  54. static int is_voice2(struct msm_voice *pvoice2)
  55. {
  56. if (pvoice2 == &voice_info[VOICE2_SESSION_INDEX])
  57. return true;
  58. else
  59. return false;
  60. }
  61. static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream)
  62. {
  63. struct snd_pcm_runtime *runtime = substream->runtime;
  64. struct msm_voice *prtd = runtime->private_data;
  65. pr_debug("%s\n", __func__);
  66. if (!prtd->playback_start)
  67. prtd->playback_start = 1;
  68. return 0;
  69. }
  70. static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
  71. {
  72. struct snd_pcm_runtime *runtime = substream->runtime;
  73. struct msm_voice *prtd = runtime->private_data;
  74. pr_debug("%s\n", __func__);
  75. if (!prtd->capture_start)
  76. prtd->capture_start = 1;
  77. return 0;
  78. }
  79. static int msm_pcm_open(struct snd_pcm_substream *substream)
  80. {
  81. struct snd_pcm_runtime *runtime = substream->runtime;
  82. struct msm_voice *voice;
  83. if (!strncmp("VoLTE", substream->pcm->id, 5)) {
  84. voice = &voice_info[VOLTE_SESSION_INDEX];
  85. pr_debug("%s: Open VoLTE Substream Id=%s\n",
  86. __func__, substream->pcm->id);
  87. } else if (!strncmp("Voice2", substream->pcm->id, 6)) {
  88. voice = &voice_info[VOICE2_SESSION_INDEX];
  89. pr_debug("%s: Open Voice2 Substream Id=%s\n",
  90. __func__, substream->pcm->id);
  91. } else {
  92. voice = &voice_info[VOICE_SESSION_INDEX];
  93. pr_debug("%s: Open VOICE Substream Id=%s\n",
  94. __func__, substream->pcm->id);
  95. }
  96. mutex_lock(&voice->lock);
  97. runtime->hw = msm_pcm_hardware;
  98. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  99. voice->playback_substream = substream;
  100. else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  101. voice->capture_substream = substream;
  102. voice->instance++;
  103. pr_debug("%s: Instance = %d, Stream ID = %s\n",
  104. __func__ , voice->instance, substream->pcm->id);
  105. runtime->private_data = voice;
  106. mutex_unlock(&voice->lock);
  107. return 0;
  108. }
  109. static int msm_pcm_playback_close(struct snd_pcm_substream *substream)
  110. {
  111. struct snd_pcm_runtime *runtime = substream->runtime;
  112. struct msm_voice *prtd = runtime->private_data;
  113. pr_debug("%s\n", __func__);
  114. if (prtd->playback_start)
  115. prtd->playback_start = 0;
  116. prtd->playback_substream = NULL;
  117. return 0;
  118. }
  119. static int msm_pcm_capture_close(struct snd_pcm_substream *substream)
  120. {
  121. struct snd_pcm_runtime *runtime = substream->runtime;
  122. struct msm_voice *prtd = runtime->private_data;
  123. pr_debug("%s\n", __func__);
  124. if (prtd->capture_start)
  125. prtd->capture_start = 0;
  126. prtd->capture_substream = NULL;
  127. return 0;
  128. }
  129. static int msm_pcm_close(struct snd_pcm_substream *substream)
  130. {
  131. struct snd_pcm_runtime *runtime = substream->runtime;
  132. struct msm_voice *prtd = runtime->private_data;
  133. uint16_t session_id = 0;
  134. int ret = 0;
  135. mutex_lock(&prtd->lock);
  136. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  137. ret = msm_pcm_playback_close(substream);
  138. else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  139. ret = msm_pcm_capture_close(substream);
  140. prtd->instance--;
  141. if (!prtd->playback_start && !prtd->capture_start) {
  142. pr_debug("end voice call\n");
  143. if (is_volte(prtd))
  144. session_id = voc_get_session_id(VOLTE_SESSION_NAME);
  145. else if (is_voice2(prtd))
  146. session_id = voc_get_session_id(VOICE2_SESSION_NAME);
  147. else
  148. session_id = voc_get_session_id(VOICE_SESSION_NAME);
  149. voc_end_voice_call(session_id);
  150. }
  151. mutex_unlock(&prtd->lock);
  152. return ret;
  153. }
  154. static int msm_pcm_prepare(struct snd_pcm_substream *substream)
  155. {
  156. int ret = 0;
  157. struct snd_pcm_runtime *runtime = substream->runtime;
  158. struct msm_voice *prtd = runtime->private_data;
  159. uint16_t session_id = 0;
  160. mutex_lock(&prtd->lock);
  161. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  162. ret = msm_pcm_playback_prepare(substream);
  163. else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  164. ret = msm_pcm_capture_prepare(substream);
  165. if (prtd->playback_start && prtd->capture_start) {
  166. if (is_volte(prtd))
  167. session_id = voc_get_session_id(VOLTE_SESSION_NAME);
  168. else if (is_voice2(prtd))
  169. session_id = voc_get_session_id(VOICE2_SESSION_NAME);
  170. else
  171. session_id = voc_get_session_id(VOICE_SESSION_NAME);
  172. voc_start_voice_call(session_id);
  173. }
  174. mutex_unlock(&prtd->lock);
  175. return ret;
  176. }
  177. static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
  178. struct snd_pcm_hw_params *params)
  179. {
  180. pr_debug("%s: Voice\n", __func__);
  181. snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
  182. return 0;
  183. }
  184. static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
  185. {
  186. int ret = 0;
  187. struct snd_pcm_runtime *runtime = substream->runtime;
  188. struct msm_voice *prtd = runtime->private_data;
  189. uint16_t session_id = 0;
  190. pr_debug("%s: cmd = %d\n", __func__, cmd);
  191. if (is_volte(prtd))
  192. session_id = voc_get_session_id(VOLTE_SESSION_NAME);
  193. else if (is_voice2(prtd))
  194. session_id = voc_get_session_id(VOICE2_SESSION_NAME);
  195. else
  196. session_id = voc_get_session_id(VOICE_SESSION_NAME);
  197. switch (cmd) {
  198. case SNDRV_PCM_TRIGGER_START:
  199. case SNDRV_PCM_TRIGGER_STOP:
  200. pr_debug("Start & Stop Voice call not handled in Trigger.\n");
  201. break;
  202. case SNDRV_PCM_TRIGGER_RESUME:
  203. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  204. pr_debug("%s: resume call session_id = %d\n", __func__,
  205. session_id);
  206. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  207. ret = msm_pcm_playback_prepare(substream);
  208. else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  209. ret = msm_pcm_capture_prepare(substream);
  210. if (prtd->playback_start && prtd->capture_start)
  211. voc_resume_voice_call(session_id);
  212. break;
  213. case SNDRV_PCM_TRIGGER_SUSPEND:
  214. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  215. pr_debug("%s: pause call session_id=%d\n",
  216. __func__, session_id);
  217. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  218. if (prtd->playback_start)
  219. prtd->playback_start = 0;
  220. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  221. if (prtd->capture_start)
  222. prtd->capture_start = 0;
  223. }
  224. voc_standby_voice_call(session_id);
  225. break;
  226. default:
  227. ret = -EINVAL;
  228. break;
  229. }
  230. return ret;
  231. }
  232. static int msm_voice_volume_get(struct snd_kcontrol *kcontrol,
  233. struct snd_ctl_elem_value *ucontrol)
  234. {
  235. ucontrol->value.integer.value[0] = 0;
  236. return 0;
  237. }
  238. static int msm_voice_volume_put(struct snd_kcontrol *kcontrol,
  239. struct snd_ctl_elem_value *ucontrol)
  240. {
  241. int volume = ucontrol->value.integer.value[0];
  242. pr_debug("%s: volume: %d\n", __func__, volume);
  243. voc_set_rx_vol_index(voc_get_session_id(VOICE_SESSION_NAME),
  244. RX_PATH, volume);
  245. return 0;
  246. }
  247. static int msm_volte_volume_get(struct snd_kcontrol *kcontrol,
  248. struct snd_ctl_elem_value *ucontrol)
  249. {
  250. ucontrol->value.integer.value[0] = 0;
  251. return 0;
  252. }
  253. static int msm_volte_volume_put(struct snd_kcontrol *kcontrol,
  254. struct snd_ctl_elem_value *ucontrol)
  255. {
  256. int volume = ucontrol->value.integer.value[0];
  257. pr_debug("%s: volume: %d\n", __func__, volume);
  258. voc_set_rx_vol_index(voc_get_session_id(VOLTE_SESSION_NAME),
  259. RX_PATH, volume);
  260. return 0;
  261. }
  262. static int msm_voice2_volume_get(struct snd_kcontrol *kcontrol,
  263. struct snd_ctl_elem_value *ucontrol)
  264. {
  265. ucontrol->value.integer.value[0] = 0;
  266. return 0;
  267. }
  268. static int msm_voice2_volume_put(struct snd_kcontrol *kcontrol,
  269. struct snd_ctl_elem_value *ucontrol)
  270. {
  271. int volume = ucontrol->value.integer.value[0];
  272. pr_debug("%s: volume: %d\n", __func__, volume);
  273. voc_set_rx_vol_index(voc_get_session_id(VOICE2_SESSION_NAME),
  274. RX_PATH, volume);
  275. return 0;
  276. }
  277. static int msm_voice_topology_disable_get(struct snd_kcontrol *kcontrol,
  278. struct snd_ctl_elem_value *ucontrol)
  279. {
  280. ucontrol->value.integer.value[0] = 0;
  281. return 0;
  282. }
  283. static int msm_voice_topology_disable_put(struct snd_kcontrol *kcontrol,
  284. struct snd_ctl_elem_value *ucontrol)
  285. {
  286. int disable = ucontrol->value.integer.value[0];
  287. pr_debug("%s: disable = %d\n", __func__, disable);
  288. return voc_disable_topology(voc_get_session_id(VOICE_SESSION_NAME),
  289. disable);
  290. }
  291. static int msm_volte_topology_disable_get(struct snd_kcontrol *kcontrol,
  292. struct snd_ctl_elem_value *ucontrol)
  293. {
  294. ucontrol->value.integer.value[0] = 0;
  295. return 0;
  296. }
  297. static int msm_volte_topology_disable_put(struct snd_kcontrol *kcontrol,
  298. struct snd_ctl_elem_value *ucontrol)
  299. {
  300. int disable = ucontrol->value.integer.value[0];
  301. pr_debug("%s: disable = %d\n", __func__, disable);
  302. return voc_disable_topology(voc_get_session_id(VOLTE_SESSION_NAME),
  303. disable);
  304. }
  305. static int msm_voice_mute_get(struct snd_kcontrol *kcontrol,
  306. struct snd_ctl_elem_value *ucontrol)
  307. {
  308. ucontrol->value.integer.value[0] = 0;
  309. return 0;
  310. }
  311. static int msm_voice_mute_put(struct snd_kcontrol *kcontrol,
  312. struct snd_ctl_elem_value *ucontrol)
  313. {
  314. int mute = ucontrol->value.integer.value[0];
  315. pr_debug("%s: mute=%d\n", __func__, mute);
  316. voc_set_tx_mute(voc_get_session_id(VOICE_SESSION_NAME), TX_PATH, mute);
  317. return 0;
  318. }
  319. static int msm_volte_mute_get(struct snd_kcontrol *kcontrol,
  320. struct snd_ctl_elem_value *ucontrol)
  321. {
  322. ucontrol->value.integer.value[0] = 0;
  323. return 0;
  324. }
  325. static int msm_volte_mute_put(struct snd_kcontrol *kcontrol,
  326. struct snd_ctl_elem_value *ucontrol)
  327. {
  328. int mute = ucontrol->value.integer.value[0];
  329. pr_debug("%s: mute=%d\n", __func__, mute);
  330. voc_set_tx_mute(voc_get_session_id(VOLTE_SESSION_NAME), TX_PATH, mute);
  331. return 0;
  332. }
  333. static int msm_voice2_mute_get(struct snd_kcontrol *kcontrol,
  334. struct snd_ctl_elem_value *ucontrol)
  335. {
  336. ucontrol->value.integer.value[0] = 0;
  337. return 0;
  338. }
  339. static int msm_voice2_mute_put(struct snd_kcontrol *kcontrol,
  340. struct snd_ctl_elem_value *ucontrol)
  341. {
  342. int mute = ucontrol->value.integer.value[0];
  343. pr_debug("%s: mute=%d\n", __func__, mute);
  344. voc_set_tx_mute(voc_get_session_id(VOICE2_SESSION_NAME), TX_PATH, mute);
  345. return 0;
  346. }
  347. static int msm_voice_rx_device_mute_get(struct snd_kcontrol *kcontrol,
  348. struct snd_ctl_elem_value *ucontrol)
  349. {
  350. ucontrol->value.integer.value[0] =
  351. voc_get_rx_device_mute(voc_get_session_id(VOICE_SESSION_NAME));
  352. return 0;
  353. }
  354. static int msm_voice_rx_device_mute_put(struct snd_kcontrol *kcontrol,
  355. struct snd_ctl_elem_value *ucontrol)
  356. {
  357. int mute = ucontrol->value.integer.value[0];
  358. pr_debug("%s: mute=%d\n", __func__, mute);
  359. voc_set_rx_device_mute(voc_get_session_id(VOICE_SESSION_NAME), mute);
  360. return 0;
  361. }
  362. static int msm_volte_rx_device_mute_get(struct snd_kcontrol *kcontrol,
  363. struct snd_ctl_elem_value *ucontrol)
  364. {
  365. ucontrol->value.integer.value[0] =
  366. voc_get_rx_device_mute(voc_get_session_id(VOLTE_SESSION_NAME));
  367. return 0;
  368. }
  369. static int msm_volte_rx_device_mute_put(struct snd_kcontrol *kcontrol,
  370. struct snd_ctl_elem_value *ucontrol)
  371. {
  372. int mute = ucontrol->value.integer.value[0];
  373. pr_debug("%s: mute=%d\n", __func__, mute);
  374. voc_set_rx_device_mute(voc_get_session_id(VOLTE_SESSION_NAME), mute);
  375. return 0;
  376. }
  377. static int msm_voice2_rx_device_mute_get(struct snd_kcontrol *kcontrol,
  378. struct snd_ctl_elem_value *ucontrol)
  379. {
  380. ucontrol->value.integer.value[0] =
  381. voc_get_rx_device_mute(voc_get_session_id(VOICE2_SESSION_NAME));
  382. return 0;
  383. }
  384. static int msm_voice2_rx_device_mute_put(struct snd_kcontrol *kcontrol,
  385. struct snd_ctl_elem_value *ucontrol)
  386. {
  387. int mute = ucontrol->value.integer.value[0];
  388. pr_debug("%s: mute=%d\n", __func__, mute);
  389. voc_set_rx_device_mute(voc_get_session_id(VOICE2_SESSION_NAME), mute);
  390. return 0;
  391. }
  392. static const char const *tty_mode[] = {"OFF", "HCO", "VCO", "FULL"};
  393. static const struct soc_enum msm_tty_mode_enum[] = {
  394. SOC_ENUM_SINGLE_EXT(4, tty_mode),
  395. };
  396. static int msm_voice_tty_mode_get(struct snd_kcontrol *kcontrol,
  397. struct snd_ctl_elem_value *ucontrol)
  398. {
  399. ucontrol->value.integer.value[0] =
  400. voc_get_tty_mode(voc_get_session_id(VOICE_SESSION_NAME));
  401. return 0;
  402. }
  403. static int msm_voice_tty_mode_put(struct snd_kcontrol *kcontrol,
  404. struct snd_ctl_elem_value *ucontrol)
  405. {
  406. int tty_mode = ucontrol->value.integer.value[0];
  407. pr_debug("%s: tty_mode=%d\n", __func__, tty_mode);
  408. voc_set_tty_mode(voc_get_session_id(VOICE_SESSION_NAME), tty_mode);
  409. voc_set_tty_mode(voc_get_session_id(VOICE2_SESSION_NAME), tty_mode);
  410. voc_set_tty_mode(voc_get_session_id(VOLTE_SESSION_NAME), tty_mode);
  411. return 0;
  412. }
  413. static int msm_voice_widevoice_put(struct snd_kcontrol *kcontrol,
  414. struct snd_ctl_elem_value *ucontrol)
  415. {
  416. int wv_enable = ucontrol->value.integer.value[0];
  417. pr_debug("%s: wv enable=%d\n", __func__, wv_enable);
  418. voc_set_widevoice_enable(voc_get_session_id(VOICE_SESSION_NAME),
  419. wv_enable);
  420. voc_set_widevoice_enable(voc_get_session_id(VOICE2_SESSION_NAME),
  421. wv_enable);
  422. return 0;
  423. }
  424. static int msm_voice_widevoice_get(struct snd_kcontrol *kcontrol,
  425. struct snd_ctl_elem_value *ucontrol)
  426. {
  427. ucontrol->value.integer.value[0] =
  428. voc_get_widevoice_enable(voc_get_session_id(VOICE_SESSION_NAME));
  429. return 0;
  430. }
  431. static int msm_voice_slowtalk_put(struct snd_kcontrol *kcontrol,
  432. struct snd_ctl_elem_value *ucontrol)
  433. {
  434. int st_enable = ucontrol->value.integer.value[0];
  435. pr_debug("%s: st enable=%d\n", __func__, st_enable);
  436. voc_set_pp_enable(voc_get_session_id(VOICE_SESSION_NAME),
  437. MODULE_ID_VOICE_MODULE_ST, st_enable);
  438. voc_set_pp_enable(voc_get_session_id(VOICE2_SESSION_NAME),
  439. MODULE_ID_VOICE_MODULE_ST, st_enable);
  440. return 0;
  441. }
  442. static int msm_voice_slowtalk_get(struct snd_kcontrol *kcontrol,
  443. struct snd_ctl_elem_value *ucontrol)
  444. {
  445. ucontrol->value.integer.value[0] =
  446. voc_get_pp_enable(voc_get_session_id(VOICE_SESSION_NAME),
  447. MODULE_ID_VOICE_MODULE_ST);
  448. return 0;
  449. }
  450. static int msm_voice_fens_put(struct snd_kcontrol *kcontrol,
  451. struct snd_ctl_elem_value *ucontrol)
  452. {
  453. int fens_enable = ucontrol->value.integer.value[0];
  454. pr_debug("%s: fens enable=%d\n", __func__, fens_enable);
  455. voc_set_pp_enable(voc_get_session_id(VOICE_SESSION_NAME),
  456. MODULE_ID_VOICE_MODULE_FENS, fens_enable);
  457. voc_set_pp_enable(voc_get_session_id(VOICE2_SESSION_NAME),
  458. MODULE_ID_VOICE_MODULE_FENS, fens_enable);
  459. return 0;
  460. }
  461. static int msm_voice_fens_get(struct snd_kcontrol *kcontrol,
  462. struct snd_ctl_elem_value *ucontrol)
  463. {
  464. ucontrol->value.integer.value[0] =
  465. voc_get_pp_enable(voc_get_session_id(VOICE_SESSION_NAME),
  466. MODULE_ID_VOICE_MODULE_FENS);
  467. return 0;
  468. }
  469. static struct snd_kcontrol_new msm_voice_controls[] = {
  470. SOC_SINGLE_EXT("Voice Rx Device Mute", SND_SOC_NOPM, 0, 1, 0,
  471. msm_voice_rx_device_mute_get,
  472. msm_voice_rx_device_mute_put),
  473. SOC_SINGLE_EXT("Voice Tx Mute", SND_SOC_NOPM, 0, 1, 0,
  474. msm_voice_mute_get, msm_voice_mute_put),
  475. SOC_SINGLE_EXT("Voice Rx Volume", SND_SOC_NOPM, 0, 5, 0,
  476. msm_voice_volume_get, msm_voice_volume_put),
  477. SOC_SINGLE_EXT("Voice Topology Disable", SND_SOC_NOPM, 0, 1, 0,
  478. msm_voice_topology_disable_get,
  479. msm_voice_topology_disable_put),
  480. SOC_ENUM_EXT("TTY Mode", msm_tty_mode_enum[0], msm_voice_tty_mode_get,
  481. msm_voice_tty_mode_put),
  482. SOC_SINGLE_EXT("Widevoice Enable", SND_SOC_NOPM, 0, 1, 0,
  483. msm_voice_widevoice_get, msm_voice_widevoice_put),
  484. SOC_SINGLE_EXT("Slowtalk Enable", SND_SOC_NOPM, 0, 1, 0,
  485. msm_voice_slowtalk_get, msm_voice_slowtalk_put),
  486. SOC_SINGLE_EXT("FENS Enable", SND_SOC_NOPM, 0, 1, 0,
  487. msm_voice_fens_get, msm_voice_fens_put),
  488. SOC_SINGLE_EXT("VoLTE Rx Device Mute", SND_SOC_NOPM, 0, 1, 0,
  489. msm_volte_rx_device_mute_get,
  490. msm_volte_rx_device_mute_put),
  491. SOC_SINGLE_EXT("VoLTE Tx Mute", SND_SOC_NOPM, 0, 1, 0,
  492. msm_volte_mute_get, msm_volte_mute_put),
  493. SOC_SINGLE_EXT("VoLTE Rx Volume", SND_SOC_NOPM, 0, 5, 0,
  494. msm_volte_volume_get, msm_volte_volume_put),
  495. SOC_SINGLE_EXT("VoLTE Topology Disable", SND_SOC_NOPM, 0, 1, 0,
  496. msm_volte_topology_disable_get,
  497. msm_volte_topology_disable_put),
  498. SOC_SINGLE_EXT("Voice2 Rx Device Mute", SND_SOC_NOPM, 0, 1, 0,
  499. msm_voice2_rx_device_mute_get,
  500. msm_voice2_rx_device_mute_put),
  501. SOC_SINGLE_EXT("Voice2 Tx Mute", SND_SOC_NOPM, 0, 1, 0,
  502. msm_voice2_mute_get, msm_voice2_mute_put),
  503. SOC_SINGLE_EXT("Voice2 Rx Volume", SND_SOC_NOPM, 0, 5, 0,
  504. msm_voice2_volume_get, msm_voice2_volume_put),
  505. };
  506. static struct snd_pcm_ops msm_pcm_ops = {
  507. .open = msm_pcm_open,
  508. .hw_params = msm_pcm_hw_params,
  509. .close = msm_pcm_close,
  510. .prepare = msm_pcm_prepare,
  511. .trigger = msm_pcm_trigger,
  512. };
  513. static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
  514. {
  515. struct snd_card *card = rtd->card->snd_card;
  516. int ret = 0;
  517. if (!card->dev->coherent_dma_mask)
  518. card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
  519. return ret;
  520. }
  521. static int msm_pcm_voice_probe(struct snd_soc_platform *platform)
  522. {
  523. snd_soc_add_platform_controls(platform, msm_voice_controls,
  524. ARRAY_SIZE(msm_voice_controls));
  525. return 0;
  526. }
  527. static struct snd_soc_platform_driver msm_soc_platform = {
  528. .ops = &msm_pcm_ops,
  529. .pcm_new = msm_asoc_pcm_new,
  530. .probe = msm_pcm_voice_probe,
  531. };
  532. static __devinit int msm_pcm_probe(struct platform_device *pdev)
  533. {
  534. pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
  535. return snd_soc_register_platform(&pdev->dev,
  536. &msm_soc_platform);
  537. }
  538. static int msm_pcm_remove(struct platform_device *pdev)
  539. {
  540. snd_soc_unregister_platform(&pdev->dev);
  541. return 0;
  542. }
  543. static struct platform_driver msm_pcm_driver = {
  544. .driver = {
  545. .name = "msm-pcm-voice",
  546. .owner = THIS_MODULE,
  547. },
  548. .probe = msm_pcm_probe,
  549. .remove = __devexit_p(msm_pcm_remove),
  550. };
  551. static int __init msm_soc_platform_init(void)
  552. {
  553. memset(&voice_info, 0, sizeof(voice_info));
  554. mutex_init(&voice_info[VOICE_SESSION_INDEX].lock);
  555. mutex_init(&voice_info[VOLTE_SESSION_INDEX].lock);
  556. mutex_init(&voice_info[VOICE2_SESSION_INDEX].lock);
  557. return platform_driver_register(&msm_pcm_driver);
  558. }
  559. module_init(msm_soc_platform_init);
  560. static void __exit msm_soc_platform_exit(void)
  561. {
  562. platform_driver_unregister(&msm_pcm_driver);
  563. }
  564. module_exit(msm_soc_platform_exit);
  565. MODULE_DESCRIPTION("Voice PCM module platform driver");
  566. MODULE_LICENSE("GPL v2");