q6asm-dai.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
  3. // Copyright (c) 2018, Linaro Limited
  4. #include <linux/init.h>
  5. #include <linux/err.h>
  6. #include <linux/module.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/slab.h>
  9. #include <sound/soc.h>
  10. #include <sound/soc.h>
  11. #include <sound/soc-dapm.h>
  12. #include <sound/pcm.h>
  13. #include <asm/dma.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/of_device.h>
  16. #include <sound/pcm_params.h>
  17. #include "q6asm.h"
  18. #include "q6routing.h"
  19. #include "q6dsp-errno.h"
  20. #define DRV_NAME "q6asm-fe-dai"
  21. #define PLAYBACK_MIN_NUM_PERIODS 2
  22. #define PLAYBACK_MAX_NUM_PERIODS 8
  23. #define PLAYBACK_MAX_PERIOD_SIZE 65536
  24. #define PLAYBACK_MIN_PERIOD_SIZE 128
  25. #define CAPTURE_MIN_NUM_PERIODS 2
  26. #define CAPTURE_MAX_NUM_PERIODS 8
  27. #define CAPTURE_MAX_PERIOD_SIZE 4096
  28. #define CAPTURE_MIN_PERIOD_SIZE 320
  29. #define SID_MASK_DEFAULT 0xF
  30. enum stream_state {
  31. Q6ASM_STREAM_IDLE = 0,
  32. Q6ASM_STREAM_STOPPED,
  33. Q6ASM_STREAM_RUNNING,
  34. };
  35. struct q6asm_dai_rtd {
  36. struct snd_pcm_substream *substream;
  37. phys_addr_t phys;
  38. unsigned int pcm_size;
  39. unsigned int pcm_count;
  40. unsigned int pcm_irq_pos; /* IRQ position */
  41. unsigned int periods;
  42. uint16_t bits_per_sample;
  43. uint16_t source; /* Encoding source bit mask */
  44. struct audio_client *audio_client;
  45. uint16_t session_id;
  46. enum stream_state state;
  47. };
  48. struct q6asm_dai_data {
  49. long long int sid;
  50. };
  51. static struct snd_pcm_hardware q6asm_dai_hardware_capture = {
  52. .info = (SNDRV_PCM_INFO_MMAP |
  53. SNDRV_PCM_INFO_BLOCK_TRANSFER |
  54. SNDRV_PCM_INFO_MMAP_VALID |
  55. SNDRV_PCM_INFO_INTERLEAVED |
  56. SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
  57. .formats = (SNDRV_PCM_FMTBIT_S16_LE |
  58. SNDRV_PCM_FMTBIT_S24_LE),
  59. .rates = SNDRV_PCM_RATE_8000_48000,
  60. .rate_min = 8000,
  61. .rate_max = 48000,
  62. .channels_min = 1,
  63. .channels_max = 4,
  64. .buffer_bytes_max = CAPTURE_MAX_NUM_PERIODS *
  65. CAPTURE_MAX_PERIOD_SIZE,
  66. .period_bytes_min = CAPTURE_MIN_PERIOD_SIZE,
  67. .period_bytes_max = CAPTURE_MAX_PERIOD_SIZE,
  68. .periods_min = CAPTURE_MIN_NUM_PERIODS,
  69. .periods_max = CAPTURE_MAX_NUM_PERIODS,
  70. .fifo_size = 0,
  71. };
  72. static struct snd_pcm_hardware q6asm_dai_hardware_playback = {
  73. .info = (SNDRV_PCM_INFO_MMAP |
  74. SNDRV_PCM_INFO_BLOCK_TRANSFER |
  75. SNDRV_PCM_INFO_MMAP_VALID |
  76. SNDRV_PCM_INFO_INTERLEAVED |
  77. SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
  78. .formats = (SNDRV_PCM_FMTBIT_S16_LE |
  79. SNDRV_PCM_FMTBIT_S24_LE),
  80. .rates = SNDRV_PCM_RATE_8000_192000,
  81. .rate_min = 8000,
  82. .rate_max = 192000,
  83. .channels_min = 1,
  84. .channels_max = 8,
  85. .buffer_bytes_max = (PLAYBACK_MAX_NUM_PERIODS *
  86. PLAYBACK_MAX_PERIOD_SIZE),
  87. .period_bytes_min = PLAYBACK_MIN_PERIOD_SIZE,
  88. .period_bytes_max = PLAYBACK_MAX_PERIOD_SIZE,
  89. .periods_min = PLAYBACK_MIN_NUM_PERIODS,
  90. .periods_max = PLAYBACK_MAX_NUM_PERIODS,
  91. .fifo_size = 0,
  92. };
  93. #define Q6ASM_FEDAI_DRIVER(num) { \
  94. .playback = { \
  95. .stream_name = "MultiMedia"#num" Playback", \
  96. .rates = (SNDRV_PCM_RATE_8000_192000| \
  97. SNDRV_PCM_RATE_KNOT), \
  98. .formats = (SNDRV_PCM_FMTBIT_S16_LE | \
  99. SNDRV_PCM_FMTBIT_S24_LE), \
  100. .channels_min = 1, \
  101. .channels_max = 8, \
  102. .rate_min = 8000, \
  103. .rate_max = 192000, \
  104. }, \
  105. .capture = { \
  106. .stream_name = "MultiMedia"#num" Capture", \
  107. .rates = (SNDRV_PCM_RATE_8000_48000| \
  108. SNDRV_PCM_RATE_KNOT), \
  109. .formats = (SNDRV_PCM_FMTBIT_S16_LE | \
  110. SNDRV_PCM_FMTBIT_S24_LE), \
  111. .channels_min = 1, \
  112. .channels_max = 4, \
  113. .rate_min = 8000, \
  114. .rate_max = 48000, \
  115. }, \
  116. .name = "MultiMedia"#num, \
  117. .probe = fe_dai_probe, \
  118. .id = MSM_FRONTEND_DAI_MULTIMEDIA##num, \
  119. }
  120. /* Conventional and unconventional sample rate supported */
  121. static unsigned int supported_sample_rates[] = {
  122. 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
  123. 88200, 96000, 176400, 192000
  124. };
  125. static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
  126. .count = ARRAY_SIZE(supported_sample_rates),
  127. .list = supported_sample_rates,
  128. .mask = 0,
  129. };
  130. static void event_handler(uint32_t opcode, uint32_t token,
  131. uint32_t *payload, void *priv)
  132. {
  133. struct q6asm_dai_rtd *prtd = priv;
  134. struct snd_pcm_substream *substream = prtd->substream;
  135. switch (opcode) {
  136. case ASM_CLIENT_EVENT_CMD_RUN_DONE:
  137. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  138. q6asm_write_async(prtd->audio_client,
  139. prtd->pcm_count, 0, 0, NO_TIMESTAMP);
  140. break;
  141. case ASM_CLIENT_EVENT_CMD_EOS_DONE:
  142. prtd->state = Q6ASM_STREAM_STOPPED;
  143. break;
  144. case ASM_CLIENT_EVENT_DATA_WRITE_DONE: {
  145. prtd->pcm_irq_pos += prtd->pcm_count;
  146. snd_pcm_period_elapsed(substream);
  147. if (prtd->state == Q6ASM_STREAM_RUNNING)
  148. q6asm_write_async(prtd->audio_client,
  149. prtd->pcm_count, 0, 0, NO_TIMESTAMP);
  150. break;
  151. }
  152. case ASM_CLIENT_EVENT_DATA_READ_DONE:
  153. prtd->pcm_irq_pos += prtd->pcm_count;
  154. snd_pcm_period_elapsed(substream);
  155. if (prtd->state == Q6ASM_STREAM_RUNNING)
  156. q6asm_read(prtd->audio_client);
  157. break;
  158. default:
  159. break;
  160. }
  161. }
  162. static int q6asm_dai_prepare(struct snd_pcm_substream *substream)
  163. {
  164. struct snd_pcm_runtime *runtime = substream->runtime;
  165. struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
  166. struct q6asm_dai_rtd *prtd = runtime->private_data;
  167. struct snd_soc_component *c = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
  168. struct q6asm_dai_data *pdata;
  169. int ret, i;
  170. pdata = snd_soc_component_get_drvdata(c);
  171. if (!pdata)
  172. return -EINVAL;
  173. if (!prtd || !prtd->audio_client) {
  174. pr_err("%s: private data null or audio client freed\n",
  175. __func__);
  176. return -EINVAL;
  177. }
  178. prtd->pcm_count = snd_pcm_lib_period_bytes(substream);
  179. prtd->pcm_irq_pos = 0;
  180. /* rate and channels are sent to audio driver */
  181. if (prtd->state) {
  182. /* clear the previous setup if any */
  183. q6asm_cmd(prtd->audio_client, CMD_CLOSE);
  184. q6asm_unmap_memory_regions(substream->stream,
  185. prtd->audio_client);
  186. q6routing_stream_close(soc_prtd->dai_link->id,
  187. substream->stream);
  188. }
  189. ret = q6asm_map_memory_regions(substream->stream, prtd->audio_client,
  190. prtd->phys,
  191. (prtd->pcm_size / prtd->periods),
  192. prtd->periods);
  193. if (ret < 0) {
  194. pr_err("Audio Start: Buffer Allocation failed rc = %d\n",
  195. ret);
  196. return -ENOMEM;
  197. }
  198. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  199. ret = q6asm_open_write(prtd->audio_client, FORMAT_LINEAR_PCM,
  200. prtd->bits_per_sample);
  201. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  202. ret = q6asm_open_read(prtd->audio_client, FORMAT_LINEAR_PCM,
  203. prtd->bits_per_sample);
  204. }
  205. if (ret < 0) {
  206. pr_err("%s: q6asm_open_write failed\n", __func__);
  207. q6asm_audio_client_free(prtd->audio_client);
  208. prtd->audio_client = NULL;
  209. return -ENOMEM;
  210. }
  211. prtd->session_id = q6asm_get_session_id(prtd->audio_client);
  212. ret = q6routing_stream_open(soc_prtd->dai_link->id, LEGACY_PCM_MODE,
  213. prtd->session_id, substream->stream);
  214. if (ret) {
  215. pr_err("%s: stream reg failed ret:%d\n", __func__, ret);
  216. return ret;
  217. }
  218. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  219. ret = q6asm_media_format_block_multi_ch_pcm(
  220. prtd->audio_client, runtime->rate,
  221. runtime->channels, NULL,
  222. prtd->bits_per_sample);
  223. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  224. ret = q6asm_enc_cfg_blk_pcm_format_support(prtd->audio_client,
  225. runtime->rate, runtime->channels,
  226. prtd->bits_per_sample);
  227. /* Queue the buffers */
  228. for (i = 0; i < runtime->periods; i++)
  229. q6asm_read(prtd->audio_client);
  230. }
  231. if (ret < 0)
  232. pr_info("%s: CMD Format block failed\n", __func__);
  233. prtd->state = Q6ASM_STREAM_RUNNING;
  234. return 0;
  235. }
  236. static int q6asm_dai_trigger(struct snd_pcm_substream *substream, int cmd)
  237. {
  238. int ret = 0;
  239. struct snd_pcm_runtime *runtime = substream->runtime;
  240. struct q6asm_dai_rtd *prtd = runtime->private_data;
  241. switch (cmd) {
  242. case SNDRV_PCM_TRIGGER_START:
  243. case SNDRV_PCM_TRIGGER_RESUME:
  244. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  245. ret = q6asm_run_nowait(prtd->audio_client, 0, 0, 0);
  246. break;
  247. case SNDRV_PCM_TRIGGER_STOP:
  248. prtd->state = Q6ASM_STREAM_STOPPED;
  249. ret = q6asm_cmd_nowait(prtd->audio_client, CMD_EOS);
  250. break;
  251. case SNDRV_PCM_TRIGGER_SUSPEND:
  252. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  253. ret = q6asm_cmd_nowait(prtd->audio_client, CMD_PAUSE);
  254. break;
  255. default:
  256. ret = -EINVAL;
  257. break;
  258. }
  259. return ret;
  260. }
  261. static int q6asm_dai_open(struct snd_pcm_substream *substream)
  262. {
  263. struct snd_pcm_runtime *runtime = substream->runtime;
  264. struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
  265. struct snd_soc_dai *cpu_dai = soc_prtd->cpu_dai;
  266. struct snd_soc_component *c = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
  267. struct q6asm_dai_rtd *prtd;
  268. struct q6asm_dai_data *pdata;
  269. struct device *dev = c->dev;
  270. int ret = 0;
  271. int stream_id;
  272. stream_id = cpu_dai->driver->id;
  273. pdata = snd_soc_component_get_drvdata(c);
  274. if (!pdata) {
  275. pr_err("Drv data not found ..\n");
  276. return -EINVAL;
  277. }
  278. prtd = kzalloc(sizeof(struct q6asm_dai_rtd), GFP_KERNEL);
  279. if (prtd == NULL)
  280. return -ENOMEM;
  281. prtd->substream = substream;
  282. prtd->audio_client = q6asm_audio_client_alloc(dev,
  283. (q6asm_cb)event_handler, prtd, stream_id,
  284. LEGACY_PCM_MODE);
  285. if (IS_ERR(prtd->audio_client)) {
  286. pr_info("%s: Could not allocate memory\n", __func__);
  287. ret = PTR_ERR(prtd->audio_client);
  288. kfree(prtd);
  289. return ret;
  290. }
  291. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  292. runtime->hw = q6asm_dai_hardware_playback;
  293. else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  294. runtime->hw = q6asm_dai_hardware_capture;
  295. ret = snd_pcm_hw_constraint_list(runtime, 0,
  296. SNDRV_PCM_HW_PARAM_RATE,
  297. &constraints_sample_rates);
  298. if (ret < 0)
  299. pr_info("snd_pcm_hw_constraint_list failed\n");
  300. /* Ensure that buffer size is a multiple of period size */
  301. ret = snd_pcm_hw_constraint_integer(runtime,
  302. SNDRV_PCM_HW_PARAM_PERIODS);
  303. if (ret < 0)
  304. pr_info("snd_pcm_hw_constraint_integer failed\n");
  305. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  306. ret = snd_pcm_hw_constraint_minmax(runtime,
  307. SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
  308. PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE,
  309. PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE);
  310. if (ret < 0) {
  311. pr_err("constraint for buffer bytes min max ret = %d\n",
  312. ret);
  313. }
  314. }
  315. ret = snd_pcm_hw_constraint_step(runtime, 0,
  316. SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
  317. if (ret < 0) {
  318. pr_err("constraint for period bytes step ret = %d\n",
  319. ret);
  320. }
  321. ret = snd_pcm_hw_constraint_step(runtime, 0,
  322. SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
  323. if (ret < 0) {
  324. pr_err("constraint for buffer bytes step ret = %d\n",
  325. ret);
  326. }
  327. runtime->private_data = prtd;
  328. snd_soc_set_runtime_hwparams(substream, &q6asm_dai_hardware_playback);
  329. runtime->dma_bytes = q6asm_dai_hardware_playback.buffer_bytes_max;
  330. if (pdata->sid < 0)
  331. prtd->phys = substream->dma_buffer.addr;
  332. else
  333. prtd->phys = substream->dma_buffer.addr | (pdata->sid << 32);
  334. snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
  335. return 0;
  336. }
  337. static int q6asm_dai_close(struct snd_pcm_substream *substream)
  338. {
  339. struct snd_pcm_runtime *runtime = substream->runtime;
  340. struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
  341. struct q6asm_dai_rtd *prtd = runtime->private_data;
  342. if (prtd->audio_client) {
  343. if (prtd->state)
  344. q6asm_cmd(prtd->audio_client, CMD_CLOSE);
  345. q6asm_unmap_memory_regions(substream->stream,
  346. prtd->audio_client);
  347. q6asm_audio_client_free(prtd->audio_client);
  348. prtd->audio_client = NULL;
  349. }
  350. q6routing_stream_close(soc_prtd->dai_link->id,
  351. substream->stream);
  352. kfree(prtd);
  353. return 0;
  354. }
  355. static snd_pcm_uframes_t q6asm_dai_pointer(struct snd_pcm_substream *substream)
  356. {
  357. struct snd_pcm_runtime *runtime = substream->runtime;
  358. struct q6asm_dai_rtd *prtd = runtime->private_data;
  359. if (prtd->pcm_irq_pos >= prtd->pcm_size)
  360. prtd->pcm_irq_pos = 0;
  361. return bytes_to_frames(runtime, (prtd->pcm_irq_pos));
  362. }
  363. static int q6asm_dai_mmap(struct snd_pcm_substream *substream,
  364. struct vm_area_struct *vma)
  365. {
  366. struct snd_pcm_runtime *runtime = substream->runtime;
  367. struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
  368. struct snd_soc_component *c = snd_soc_rtdcom_lookup(soc_prtd, DRV_NAME);
  369. struct device *dev = c->dev;
  370. return dma_mmap_coherent(dev, vma,
  371. runtime->dma_area, runtime->dma_addr,
  372. runtime->dma_bytes);
  373. }
  374. static int q6asm_dai_hw_params(struct snd_pcm_substream *substream,
  375. struct snd_pcm_hw_params *params)
  376. {
  377. struct snd_pcm_runtime *runtime = substream->runtime;
  378. struct q6asm_dai_rtd *prtd = runtime->private_data;
  379. prtd->pcm_size = params_buffer_bytes(params);
  380. prtd->periods = params_periods(params);
  381. switch (params_format(params)) {
  382. case SNDRV_PCM_FORMAT_S16_LE:
  383. prtd->bits_per_sample = 16;
  384. break;
  385. case SNDRV_PCM_FORMAT_S24_LE:
  386. prtd->bits_per_sample = 24;
  387. break;
  388. }
  389. return 0;
  390. }
  391. static struct snd_pcm_ops q6asm_dai_ops = {
  392. .open = q6asm_dai_open,
  393. .hw_params = q6asm_dai_hw_params,
  394. .close = q6asm_dai_close,
  395. .ioctl = snd_pcm_lib_ioctl,
  396. .prepare = q6asm_dai_prepare,
  397. .trigger = q6asm_dai_trigger,
  398. .pointer = q6asm_dai_pointer,
  399. .mmap = q6asm_dai_mmap,
  400. };
  401. static int q6asm_dai_pcm_new(struct snd_soc_pcm_runtime *rtd)
  402. {
  403. struct snd_pcm_substream *psubstream, *csubstream;
  404. struct snd_soc_component *c = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
  405. struct snd_pcm *pcm = rtd->pcm;
  406. struct device *dev;
  407. int size, ret;
  408. dev = c->dev;
  409. size = q6asm_dai_hardware_playback.buffer_bytes_max;
  410. psubstream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
  411. if (psubstream) {
  412. ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size,
  413. &psubstream->dma_buffer);
  414. if (ret) {
  415. dev_err(dev, "Cannot allocate buffer(s)\n");
  416. return ret;
  417. }
  418. }
  419. csubstream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
  420. if (csubstream) {
  421. ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size,
  422. &csubstream->dma_buffer);
  423. if (ret) {
  424. dev_err(dev, "Cannot allocate buffer(s)\n");
  425. if (psubstream)
  426. snd_dma_free_pages(&psubstream->dma_buffer);
  427. return ret;
  428. }
  429. }
  430. return ret;
  431. }
  432. static void q6asm_dai_pcm_free(struct snd_pcm *pcm)
  433. {
  434. struct snd_pcm_substream *substream;
  435. int i;
  436. for (i = 0; i < ARRAY_SIZE(pcm->streams); i++) {
  437. substream = pcm->streams[i].substream;
  438. if (substream) {
  439. snd_dma_free_pages(&substream->dma_buffer);
  440. substream->dma_buffer.area = NULL;
  441. substream->dma_buffer.addr = 0;
  442. }
  443. }
  444. }
  445. static const struct snd_soc_dapm_route afe_pcm_routes[] = {
  446. {"MM_DL1", NULL, "MultiMedia1 Playback" },
  447. {"MM_DL2", NULL, "MultiMedia2 Playback" },
  448. {"MM_DL3", NULL, "MultiMedia3 Playback" },
  449. {"MM_DL4", NULL, "MultiMedia4 Playback" },
  450. {"MM_DL5", NULL, "MultiMedia5 Playback" },
  451. {"MM_DL6", NULL, "MultiMedia6 Playback" },
  452. {"MM_DL7", NULL, "MultiMedia7 Playback" },
  453. {"MM_DL7", NULL, "MultiMedia8 Playback" },
  454. {"MultiMedia1 Capture", NULL, "MM_UL1"},
  455. {"MultiMedia2 Capture", NULL, "MM_UL2"},
  456. {"MultiMedia3 Capture", NULL, "MM_UL3"},
  457. {"MultiMedia4 Capture", NULL, "MM_UL4"},
  458. {"MultiMedia5 Capture", NULL, "MM_UL5"},
  459. {"MultiMedia6 Capture", NULL, "MM_UL6"},
  460. {"MultiMedia7 Capture", NULL, "MM_UL7"},
  461. {"MultiMedia8 Capture", NULL, "MM_UL8"},
  462. };
  463. static int fe_dai_probe(struct snd_soc_dai *dai)
  464. {
  465. struct snd_soc_dapm_context *dapm;
  466. dapm = snd_soc_component_get_dapm(dai->component);
  467. snd_soc_dapm_add_routes(dapm, afe_pcm_routes,
  468. ARRAY_SIZE(afe_pcm_routes));
  469. return 0;
  470. }
  471. static const struct snd_soc_component_driver q6asm_fe_dai_component = {
  472. .name = DRV_NAME,
  473. .ops = &q6asm_dai_ops,
  474. .pcm_new = q6asm_dai_pcm_new,
  475. .pcm_free = q6asm_dai_pcm_free,
  476. };
  477. static struct snd_soc_dai_driver q6asm_fe_dais[] = {
  478. Q6ASM_FEDAI_DRIVER(1),
  479. Q6ASM_FEDAI_DRIVER(2),
  480. Q6ASM_FEDAI_DRIVER(3),
  481. Q6ASM_FEDAI_DRIVER(4),
  482. Q6ASM_FEDAI_DRIVER(5),
  483. Q6ASM_FEDAI_DRIVER(6),
  484. Q6ASM_FEDAI_DRIVER(7),
  485. Q6ASM_FEDAI_DRIVER(8),
  486. };
  487. static int q6asm_dai_probe(struct platform_device *pdev)
  488. {
  489. struct device *dev = &pdev->dev;
  490. struct device_node *node = dev->of_node;
  491. struct of_phandle_args args;
  492. struct q6asm_dai_data *pdata;
  493. int rc;
  494. pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
  495. if (!pdata)
  496. return -ENOMEM;
  497. rc = of_parse_phandle_with_fixed_args(node, "iommus", 1, 0, &args);
  498. if (rc < 0)
  499. pdata->sid = -1;
  500. else
  501. pdata->sid = args.args[0] & SID_MASK_DEFAULT;
  502. dev_set_drvdata(dev, pdata);
  503. return devm_snd_soc_register_component(dev, &q6asm_fe_dai_component,
  504. q6asm_fe_dais,
  505. ARRAY_SIZE(q6asm_fe_dais));
  506. }
  507. static const struct of_device_id q6asm_dai_device_id[] = {
  508. { .compatible = "qcom,q6asm-dais" },
  509. {},
  510. };
  511. MODULE_DEVICE_TABLE(of, q6asm_dai_device_id);
  512. static struct platform_driver q6asm_dai_platform_driver = {
  513. .driver = {
  514. .name = "q6asm-dai",
  515. .of_match_table = of_match_ptr(q6asm_dai_device_id),
  516. },
  517. .probe = q6asm_dai_probe,
  518. };
  519. module_platform_driver(q6asm_dai_platform_driver);
  520. MODULE_DESCRIPTION("Q6ASM dai driver");
  521. MODULE_LICENSE("GPL v2");