ASoC: q6asm-dai: add next track metadata support
[linux-2.6-microblaze.git] / sound / soc / qcom / qdsp6 / q6asm-dai.c
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
5 #include <linux/init.h>
6 #include <linux/err.h>
7 #include <linux/module.h>
8 #include <linux/platform_device.h>
9 #include <linux/slab.h>
10 #include <sound/soc.h>
11 #include <sound/soc-dapm.h>
12 #include <sound/pcm.h>
13 #include <linux/spinlock.h>
14 #include <sound/compress_driver.h>
15 #include <asm/dma.h>
16 #include <linux/dma-mapping.h>
17 #include <linux/of_device.h>
18 #include <sound/pcm_params.h>
19 #include "q6asm.h"
20 #include "q6routing.h"
21 #include "q6dsp-errno.h"
22
23 #define DRV_NAME        "q6asm-fe-dai"
24
25 #define PLAYBACK_MIN_NUM_PERIODS    2
26 #define PLAYBACK_MAX_NUM_PERIODS   8
27 #define PLAYBACK_MAX_PERIOD_SIZE    65536
28 #define PLAYBACK_MIN_PERIOD_SIZE    128
29 #define CAPTURE_MIN_NUM_PERIODS     2
30 #define CAPTURE_MAX_NUM_PERIODS     8
31 #define CAPTURE_MAX_PERIOD_SIZE     4096
32 #define CAPTURE_MIN_PERIOD_SIZE     320
33 #define SID_MASK_DEFAULT        0xF
34
35 /* Default values used if user space does not set */
36 #define COMPR_PLAYBACK_MIN_FRAGMENT_SIZE (8 * 1024)
37 #define COMPR_PLAYBACK_MAX_FRAGMENT_SIZE (128 * 1024)
38 #define COMPR_PLAYBACK_MIN_NUM_FRAGMENTS (4)
39 #define COMPR_PLAYBACK_MAX_NUM_FRAGMENTS (16 * 4)
40
41 #define ALAC_CH_LAYOUT_MONO   ((101 << 16) | 1)
42 #define ALAC_CH_LAYOUT_STEREO ((101 << 16) | 2)
43
44 enum stream_state {
45         Q6ASM_STREAM_IDLE = 0,
46         Q6ASM_STREAM_STOPPED,
47         Q6ASM_STREAM_RUNNING,
48 };
49
50 struct q6asm_dai_rtd {
51         struct snd_pcm_substream *substream;
52         struct snd_compr_stream *cstream;
53         struct snd_compr_params codec_param;
54         struct snd_dma_buffer dma_buffer;
55         spinlock_t lock;
56         phys_addr_t phys;
57         unsigned int pcm_size;
58         unsigned int pcm_count;
59         unsigned int pcm_irq_pos;       /* IRQ position */
60         unsigned int periods;
61         unsigned int bytes_sent;
62         unsigned int bytes_received;
63         unsigned int copied_total;
64         uint16_t bits_per_sample;
65         uint16_t source; /* Encoding source bit mask */
66         struct audio_client *audio_client;
67         uint32_t stream_id;
68         uint16_t session_id;
69         enum stream_state state;
70         uint32_t initial_samples_drop;
71         uint32_t trailing_samples_drop;
72 };
73
74 struct q6asm_dai_data {
75         struct snd_soc_dai_driver *dais;
76         int num_dais;
77         long long int sid;
78 };
79
80 static const struct snd_pcm_hardware q6asm_dai_hardware_capture = {
81         .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_BATCH |
82                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
83                                 SNDRV_PCM_INFO_MMAP_VALID |
84                                 SNDRV_PCM_INFO_INTERLEAVED |
85                                 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
86         .formats =              (SNDRV_PCM_FMTBIT_S16_LE |
87                                 SNDRV_PCM_FMTBIT_S24_LE),
88         .rates =                SNDRV_PCM_RATE_8000_48000,
89         .rate_min =             8000,
90         .rate_max =             48000,
91         .channels_min =         1,
92         .channels_max =         4,
93         .buffer_bytes_max =     CAPTURE_MAX_NUM_PERIODS *
94                                 CAPTURE_MAX_PERIOD_SIZE,
95         .period_bytes_min =     CAPTURE_MIN_PERIOD_SIZE,
96         .period_bytes_max =     CAPTURE_MAX_PERIOD_SIZE,
97         .periods_min =          CAPTURE_MIN_NUM_PERIODS,
98         .periods_max =          CAPTURE_MAX_NUM_PERIODS,
99         .fifo_size =            0,
100 };
101
102 static struct snd_pcm_hardware q6asm_dai_hardware_playback = {
103         .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_BATCH |
104                                 SNDRV_PCM_INFO_BLOCK_TRANSFER |
105                                 SNDRV_PCM_INFO_MMAP_VALID |
106                                 SNDRV_PCM_INFO_INTERLEAVED |
107                                 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
108         .formats =              (SNDRV_PCM_FMTBIT_S16_LE |
109                                 SNDRV_PCM_FMTBIT_S24_LE),
110         .rates =                SNDRV_PCM_RATE_8000_192000,
111         .rate_min =             8000,
112         .rate_max =             192000,
113         .channels_min =         1,
114         .channels_max =         8,
115         .buffer_bytes_max =     (PLAYBACK_MAX_NUM_PERIODS *
116                                 PLAYBACK_MAX_PERIOD_SIZE),
117         .period_bytes_min =     PLAYBACK_MIN_PERIOD_SIZE,
118         .period_bytes_max =     PLAYBACK_MAX_PERIOD_SIZE,
119         .periods_min =          PLAYBACK_MIN_NUM_PERIODS,
120         .periods_max =          PLAYBACK_MAX_NUM_PERIODS,
121         .fifo_size =            0,
122 };
123
124 #define Q6ASM_FEDAI_DRIVER(num) { \
125                 .playback = {                                           \
126                         .stream_name = "MultiMedia"#num" Playback",     \
127                         .rates = (SNDRV_PCM_RATE_8000_192000|           \
128                                         SNDRV_PCM_RATE_KNOT),           \
129                         .formats = (SNDRV_PCM_FMTBIT_S16_LE |           \
130                                         SNDRV_PCM_FMTBIT_S24_LE),       \
131                         .channels_min = 1,                              \
132                         .channels_max = 8,                              \
133                         .rate_min =     8000,                           \
134                         .rate_max =     192000,                         \
135                 },                                                      \
136                 .capture = {                                            \
137                         .stream_name = "MultiMedia"#num" Capture",      \
138                         .rates = (SNDRV_PCM_RATE_8000_48000|            \
139                                         SNDRV_PCM_RATE_KNOT),           \
140                         .formats = (SNDRV_PCM_FMTBIT_S16_LE |           \
141                                     SNDRV_PCM_FMTBIT_S24_LE),           \
142                         .channels_min = 1,                              \
143                         .channels_max = 4,                              \
144                         .rate_min =     8000,                           \
145                         .rate_max =     48000,                          \
146                 },                                                      \
147                 .name = "MultiMedia"#num,                               \
148                 .id = MSM_FRONTEND_DAI_MULTIMEDIA##num,                 \
149         }
150
151 /* Conventional and unconventional sample rate supported */
152 static unsigned int supported_sample_rates[] = {
153         8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
154         88200, 96000, 176400, 192000
155 };
156
157 static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
158         .count = ARRAY_SIZE(supported_sample_rates),
159         .list = supported_sample_rates,
160         .mask = 0,
161 };
162
163 static const struct snd_compr_codec_caps q6asm_compr_caps = {
164         .num_descriptors = 1,
165         .descriptor[0].max_ch = 2,
166         .descriptor[0].sample_rates = { 8000, 11025, 12000, 16000, 22050,
167                                         24000, 32000, 44100, 48000, 88200,
168                                         96000, 176400, 192000 },
169         .descriptor[0].num_sample_rates = 13,
170         .descriptor[0].bit_rate[0] = 320,
171         .descriptor[0].bit_rate[1] = 128,
172         .descriptor[0].num_bitrates = 2,
173         .descriptor[0].profiles = 0,
174         .descriptor[0].modes = SND_AUDIOCHANMODE_MP3_STEREO,
175         .descriptor[0].formats = 0,
176 };
177
178 static void event_handler(uint32_t opcode, uint32_t token,
179                           void *payload, void *priv)
180 {
181         struct q6asm_dai_rtd *prtd = priv;
182         struct snd_pcm_substream *substream = prtd->substream;
183
184         switch (opcode) {
185         case ASM_CLIENT_EVENT_CMD_RUN_DONE:
186                 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
187                         q6asm_write_async(prtd->audio_client, prtd->stream_id,
188                                    prtd->pcm_count, 0, 0, 0);
189                 break;
190         case ASM_CLIENT_EVENT_CMD_EOS_DONE:
191                 prtd->state = Q6ASM_STREAM_STOPPED;
192                 break;
193         case ASM_CLIENT_EVENT_DATA_WRITE_DONE: {
194                 prtd->pcm_irq_pos += prtd->pcm_count;
195                 snd_pcm_period_elapsed(substream);
196                 if (prtd->state == Q6ASM_STREAM_RUNNING)
197                         q6asm_write_async(prtd->audio_client, prtd->stream_id,
198                                            prtd->pcm_count, 0, 0, 0);
199
200                 break;
201                 }
202         case ASM_CLIENT_EVENT_DATA_READ_DONE:
203                 prtd->pcm_irq_pos += prtd->pcm_count;
204                 snd_pcm_period_elapsed(substream);
205                 if (prtd->state == Q6ASM_STREAM_RUNNING)
206                         q6asm_read(prtd->audio_client, prtd->stream_id);
207
208                 break;
209         default:
210                 break;
211         }
212 }
213
214 static int q6asm_dai_prepare(struct snd_soc_component *component,
215                              struct snd_pcm_substream *substream)
216 {
217         struct snd_pcm_runtime *runtime = substream->runtime;
218         struct snd_soc_pcm_runtime *soc_prtd = asoc_substream_to_rtd(substream);
219         struct q6asm_dai_rtd *prtd = runtime->private_data;
220         struct q6asm_dai_data *pdata;
221         struct device *dev = component->dev;
222         int ret, i;
223
224         pdata = snd_soc_component_get_drvdata(component);
225         if (!pdata)
226                 return -EINVAL;
227
228         if (!prtd || !prtd->audio_client) {
229                 dev_err(dev, "%s: private data null or audio client freed\n",
230                         __func__);
231                 return -EINVAL;
232         }
233
234         prtd->pcm_count = snd_pcm_lib_period_bytes(substream);
235         prtd->pcm_irq_pos = 0;
236         /* rate and channels are sent to audio driver */
237         if (prtd->state) {
238                 /* clear the previous setup if any  */
239                 q6asm_cmd(prtd->audio_client, prtd->stream_id, CMD_CLOSE);
240                 q6asm_unmap_memory_regions(substream->stream,
241                                            prtd->audio_client);
242                 q6routing_stream_close(soc_prtd->dai_link->id,
243                                          substream->stream);
244         }
245
246         ret = q6asm_map_memory_regions(substream->stream, prtd->audio_client,
247                                        prtd->phys,
248                                        (prtd->pcm_size / prtd->periods),
249                                        prtd->periods);
250
251         if (ret < 0) {
252                 dev_err(dev, "Audio Start: Buffer Allocation failed rc = %d\n",
253                                                         ret);
254                 return -ENOMEM;
255         }
256
257         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
258                 ret = q6asm_open_write(prtd->audio_client, prtd->stream_id,
259                                        FORMAT_LINEAR_PCM,
260                                        0, prtd->bits_per_sample, false);
261         } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
262                 ret = q6asm_open_read(prtd->audio_client, prtd->stream_id,
263                                       FORMAT_LINEAR_PCM,
264                                       prtd->bits_per_sample);
265         }
266
267         if (ret < 0) {
268                 dev_err(dev, "%s: q6asm_open_write failed\n", __func__);
269                 q6asm_audio_client_free(prtd->audio_client);
270                 prtd->audio_client = NULL;
271                 return -ENOMEM;
272         }
273
274         prtd->session_id = q6asm_get_session_id(prtd->audio_client);
275         ret = q6routing_stream_open(soc_prtd->dai_link->id, LEGACY_PCM_MODE,
276                               prtd->session_id, substream->stream);
277         if (ret) {
278                 dev_err(dev, "%s: stream reg failed ret:%d\n", __func__, ret);
279                 return ret;
280         }
281
282         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
283                 ret = q6asm_media_format_block_multi_ch_pcm(
284                                 prtd->audio_client, prtd->stream_id,
285                                 runtime->rate, runtime->channels, NULL,
286                                 prtd->bits_per_sample);
287         } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
288                 ret = q6asm_enc_cfg_blk_pcm_format_support(prtd->audio_client,
289                                                            prtd->stream_id,
290                                                            runtime->rate,
291                                                            runtime->channels,
292                                                            prtd->bits_per_sample);
293
294                 /* Queue the buffers */
295                 for (i = 0; i < runtime->periods; i++)
296                         q6asm_read(prtd->audio_client, prtd->stream_id);
297
298         }
299         if (ret < 0)
300                 dev_info(dev, "%s: CMD Format block failed\n", __func__);
301
302         prtd->state = Q6ASM_STREAM_RUNNING;
303
304         return 0;
305 }
306
307 static int q6asm_dai_trigger(struct snd_soc_component *component,
308                              struct snd_pcm_substream *substream, int cmd)
309 {
310         int ret = 0;
311         struct snd_pcm_runtime *runtime = substream->runtime;
312         struct q6asm_dai_rtd *prtd = runtime->private_data;
313
314         switch (cmd) {
315         case SNDRV_PCM_TRIGGER_START:
316         case SNDRV_PCM_TRIGGER_RESUME:
317         case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
318                 ret = q6asm_run_nowait(prtd->audio_client, prtd->stream_id,
319                                        0, 0, 0);
320                 break;
321         case SNDRV_PCM_TRIGGER_STOP:
322                 prtd->state = Q6ASM_STREAM_STOPPED;
323                 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
324                                        CMD_EOS);
325                 break;
326         case SNDRV_PCM_TRIGGER_SUSPEND:
327         case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
328                 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
329                                        CMD_PAUSE);
330                 break;
331         default:
332                 ret = -EINVAL;
333                 break;
334         }
335
336         return ret;
337 }
338
339 static int q6asm_dai_open(struct snd_soc_component *component,
340                           struct snd_pcm_substream *substream)
341 {
342         struct snd_pcm_runtime *runtime = substream->runtime;
343         struct snd_soc_pcm_runtime *soc_prtd = asoc_substream_to_rtd(substream);
344         struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(soc_prtd, 0);
345         struct q6asm_dai_rtd *prtd;
346         struct q6asm_dai_data *pdata;
347         struct device *dev = component->dev;
348         int ret = 0;
349         int stream_id;
350
351         stream_id = cpu_dai->driver->id;
352
353         pdata = snd_soc_component_get_drvdata(component);
354         if (!pdata) {
355                 dev_err(dev, "Drv data not found ..\n");
356                 return -EINVAL;
357         }
358
359         prtd = kzalloc(sizeof(struct q6asm_dai_rtd), GFP_KERNEL);
360         if (prtd == NULL)
361                 return -ENOMEM;
362
363         prtd->substream = substream;
364         prtd->audio_client = q6asm_audio_client_alloc(dev,
365                                 (q6asm_cb)event_handler, prtd, stream_id,
366                                 LEGACY_PCM_MODE);
367         if (IS_ERR(prtd->audio_client)) {
368                 dev_info(dev, "%s: Could not allocate memory\n", __func__);
369                 ret = PTR_ERR(prtd->audio_client);
370                 kfree(prtd);
371                 return ret;
372         }
373
374         /* DSP expects stream id from 1 */
375         prtd->stream_id = 1;
376
377         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
378                 runtime->hw = q6asm_dai_hardware_playback;
379         else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
380                 runtime->hw = q6asm_dai_hardware_capture;
381
382         ret = snd_pcm_hw_constraint_list(runtime, 0,
383                                 SNDRV_PCM_HW_PARAM_RATE,
384                                 &constraints_sample_rates);
385         if (ret < 0)
386                 dev_info(dev, "snd_pcm_hw_constraint_list failed\n");
387         /* Ensure that buffer size is a multiple of period size */
388         ret = snd_pcm_hw_constraint_integer(runtime,
389                                             SNDRV_PCM_HW_PARAM_PERIODS);
390         if (ret < 0)
391                 dev_info(dev, "snd_pcm_hw_constraint_integer failed\n");
392
393         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
394                 ret = snd_pcm_hw_constraint_minmax(runtime,
395                         SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
396                         PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE,
397                         PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE);
398                 if (ret < 0) {
399                         dev_err(dev, "constraint for buffer bytes min max ret = %d\n",
400                                 ret);
401                 }
402         }
403
404         ret = snd_pcm_hw_constraint_step(runtime, 0,
405                 SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
406         if (ret < 0) {
407                 dev_err(dev, "constraint for period bytes step ret = %d\n",
408                                                                 ret);
409         }
410         ret = snd_pcm_hw_constraint_step(runtime, 0,
411                 SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
412         if (ret < 0) {
413                 dev_err(dev, "constraint for buffer bytes step ret = %d\n",
414                                                                 ret);
415         }
416
417         runtime->private_data = prtd;
418
419         snd_soc_set_runtime_hwparams(substream, &q6asm_dai_hardware_playback);
420
421         runtime->dma_bytes = q6asm_dai_hardware_playback.buffer_bytes_max;
422
423
424         if (pdata->sid < 0)
425                 prtd->phys = substream->dma_buffer.addr;
426         else
427                 prtd->phys = substream->dma_buffer.addr | (pdata->sid << 32);
428
429         snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
430
431         return 0;
432 }
433
434 static int q6asm_dai_close(struct snd_soc_component *component,
435                            struct snd_pcm_substream *substream)
436 {
437         struct snd_pcm_runtime *runtime = substream->runtime;
438         struct snd_soc_pcm_runtime *soc_prtd = asoc_substream_to_rtd(substream);
439         struct q6asm_dai_rtd *prtd = runtime->private_data;
440
441         if (prtd->audio_client) {
442                 if (prtd->state)
443                         q6asm_cmd(prtd->audio_client, prtd->stream_id,
444                                   CMD_CLOSE);
445
446                 q6asm_unmap_memory_regions(substream->stream,
447                                            prtd->audio_client);
448                 q6asm_audio_client_free(prtd->audio_client);
449                 prtd->audio_client = NULL;
450         }
451         q6routing_stream_close(soc_prtd->dai_link->id,
452                                                 substream->stream);
453         kfree(prtd);
454         return 0;
455 }
456
457 static snd_pcm_uframes_t q6asm_dai_pointer(struct snd_soc_component *component,
458                                            struct snd_pcm_substream *substream)
459 {
460
461         struct snd_pcm_runtime *runtime = substream->runtime;
462         struct q6asm_dai_rtd *prtd = runtime->private_data;
463
464         if (prtd->pcm_irq_pos >= prtd->pcm_size)
465                 prtd->pcm_irq_pos = 0;
466
467         return bytes_to_frames(runtime, (prtd->pcm_irq_pos));
468 }
469
470 static int q6asm_dai_mmap(struct snd_soc_component *component,
471                           struct snd_pcm_substream *substream,
472                           struct vm_area_struct *vma)
473 {
474         struct snd_pcm_runtime *runtime = substream->runtime;
475         struct device *dev = component->dev;
476
477         return dma_mmap_coherent(dev, vma,
478                         runtime->dma_area, runtime->dma_addr,
479                         runtime->dma_bytes);
480 }
481
482 static int q6asm_dai_hw_params(struct snd_soc_component *component,
483                                struct snd_pcm_substream *substream,
484                                struct snd_pcm_hw_params *params)
485 {
486         struct snd_pcm_runtime *runtime = substream->runtime;
487         struct q6asm_dai_rtd *prtd = runtime->private_data;
488
489         prtd->pcm_size = params_buffer_bytes(params);
490         prtd->periods = params_periods(params);
491
492         switch (params_format(params)) {
493         case SNDRV_PCM_FORMAT_S16_LE:
494                 prtd->bits_per_sample = 16;
495                 break;
496         case SNDRV_PCM_FORMAT_S24_LE:
497                 prtd->bits_per_sample = 24;
498                 break;
499         }
500
501         return 0;
502 }
503
504 static void compress_event_handler(uint32_t opcode, uint32_t token,
505                                    void *payload, void *priv)
506 {
507         struct q6asm_dai_rtd *prtd = priv;
508         struct snd_compr_stream *substream = prtd->cstream;
509         unsigned long flags;
510         uint64_t avail;
511         uint32_t bytes_written;
512
513         switch (opcode) {
514         case ASM_CLIENT_EVENT_CMD_RUN_DONE:
515                 spin_lock_irqsave(&prtd->lock, flags);
516                 if (!prtd->bytes_sent) {
517                         q6asm_write_async(prtd->audio_client, prtd->stream_id,
518                                           prtd->pcm_count, 0, 0, 0);
519                         prtd->bytes_sent += prtd->pcm_count;
520                 }
521
522                 spin_unlock_irqrestore(&prtd->lock, flags);
523                 break;
524
525         case ASM_CLIENT_EVENT_CMD_EOS_DONE:
526                 prtd->state = Q6ASM_STREAM_STOPPED;
527                 break;
528
529         case ASM_CLIENT_EVENT_DATA_WRITE_DONE:
530                 spin_lock_irqsave(&prtd->lock, flags);
531
532                 bytes_written = token >> ASM_WRITE_TOKEN_LEN_SHIFT;
533                 prtd->copied_total += bytes_written;
534                 snd_compr_fragment_elapsed(substream);
535
536                 if (prtd->state != Q6ASM_STREAM_RUNNING) {
537                         spin_unlock_irqrestore(&prtd->lock, flags);
538                         break;
539                 }
540
541                 avail = prtd->bytes_received - prtd->bytes_sent;
542
543                 if (avail >= prtd->pcm_count) {
544                         q6asm_write_async(prtd->audio_client, prtd->stream_id,
545                                            prtd->pcm_count, 0, 0, 0);
546                         prtd->bytes_sent += prtd->pcm_count;
547                 }
548
549                 spin_unlock_irqrestore(&prtd->lock, flags);
550                 break;
551
552         default:
553                 break;
554         }
555 }
556
557 static int q6asm_dai_compr_open(struct snd_soc_component *component,
558                                 struct snd_compr_stream *stream)
559 {
560         struct snd_soc_pcm_runtime *rtd = stream->private_data;
561         struct snd_compr_runtime *runtime = stream->runtime;
562         struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
563         struct q6asm_dai_data *pdata;
564         struct device *dev = component->dev;
565         struct q6asm_dai_rtd *prtd;
566         int stream_id, size, ret;
567
568         stream_id = cpu_dai->driver->id;
569         pdata = snd_soc_component_get_drvdata(component);
570         if (!pdata) {
571                 dev_err(dev, "Drv data not found ..\n");
572                 return -EINVAL;
573         }
574
575         prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
576         if (!prtd)
577                 return -ENOMEM;
578
579         /* DSP expects stream id from 1 */
580         prtd->stream_id = 1;
581
582         prtd->cstream = stream;
583         prtd->audio_client = q6asm_audio_client_alloc(dev,
584                                         (q6asm_cb)compress_event_handler,
585                                         prtd, stream_id, LEGACY_PCM_MODE);
586         if (IS_ERR(prtd->audio_client)) {
587                 dev_err(dev, "Could not allocate memory\n");
588                 ret = PTR_ERR(prtd->audio_client);
589                 goto free_prtd;
590         }
591
592         size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE *
593                         COMPR_PLAYBACK_MAX_NUM_FRAGMENTS;
594         ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size,
595                                   &prtd->dma_buffer);
596         if (ret) {
597                 dev_err(dev, "Cannot allocate buffer(s)\n");
598                 goto free_client;
599         }
600
601         if (pdata->sid < 0)
602                 prtd->phys = prtd->dma_buffer.addr;
603         else
604                 prtd->phys = prtd->dma_buffer.addr | (pdata->sid << 32);
605
606         snd_compr_set_runtime_buffer(stream, &prtd->dma_buffer);
607         spin_lock_init(&prtd->lock);
608         runtime->private_data = prtd;
609
610         return 0;
611
612 free_client:
613         q6asm_audio_client_free(prtd->audio_client);
614 free_prtd:
615         kfree(prtd);
616
617         return ret;
618 }
619
620 static int q6asm_dai_compr_free(struct snd_soc_component *component,
621                                 struct snd_compr_stream *stream)
622 {
623         struct snd_compr_runtime *runtime = stream->runtime;
624         struct q6asm_dai_rtd *prtd = runtime->private_data;
625         struct snd_soc_pcm_runtime *rtd = stream->private_data;
626
627         if (prtd->audio_client) {
628                 if (prtd->state)
629                         q6asm_cmd(prtd->audio_client, prtd->stream_id,
630                                   CMD_CLOSE);
631
632                 snd_dma_free_pages(&prtd->dma_buffer);
633                 q6asm_unmap_memory_regions(stream->direction,
634                                            prtd->audio_client);
635                 q6asm_audio_client_free(prtd->audio_client);
636                 prtd->audio_client = NULL;
637         }
638         q6routing_stream_close(rtd->dai_link->id, stream->direction);
639         kfree(prtd);
640
641         return 0;
642 }
643
644 static int q6asm_dai_compr_set_params(struct snd_soc_component *component,
645                                       struct snd_compr_stream *stream,
646                                       struct snd_compr_params *params)
647 {
648         struct snd_compr_runtime *runtime = stream->runtime;
649         struct q6asm_dai_rtd *prtd = runtime->private_data;
650         struct snd_soc_pcm_runtime *rtd = stream->private_data;
651         int dir = stream->direction;
652         struct q6asm_dai_data *pdata;
653         struct q6asm_flac_cfg flac_cfg;
654         struct q6asm_wma_cfg wma_cfg;
655         struct q6asm_alac_cfg alac_cfg;
656         struct q6asm_ape_cfg ape_cfg;
657         unsigned int wma_v9 = 0;
658         struct device *dev = component->dev;
659         int ret;
660         union snd_codec_options *codec_options;
661         struct snd_dec_flac *flac;
662         struct snd_dec_wma *wma;
663         struct snd_dec_alac *alac;
664         struct snd_dec_ape *ape;
665
666         codec_options = &(prtd->codec_param.codec.options);
667
668
669         memcpy(&prtd->codec_param, params, sizeof(*params));
670
671         pdata = snd_soc_component_get_drvdata(component);
672         if (!pdata)
673                 return -EINVAL;
674
675         if (!prtd || !prtd->audio_client) {
676                 dev_err(dev, "private data null or audio client freed\n");
677                 return -EINVAL;
678         }
679
680         prtd->periods = runtime->fragments;
681         prtd->pcm_count = runtime->fragment_size;
682         prtd->pcm_size = runtime->fragments * runtime->fragment_size;
683         prtd->bits_per_sample = 16;
684         if (dir == SND_COMPRESS_PLAYBACK) {
685                 ret = q6asm_open_write(prtd->audio_client, prtd->stream_id,
686                                        params->codec.id, params->codec.profile,
687                                        prtd->bits_per_sample, true);
688
689                 if (ret < 0) {
690                         dev_err(dev, "q6asm_open_write failed\n");
691                         q6asm_audio_client_free(prtd->audio_client);
692                         prtd->audio_client = NULL;
693                         return ret;
694                 }
695         }
696
697         prtd->session_id = q6asm_get_session_id(prtd->audio_client);
698         ret = q6routing_stream_open(rtd->dai_link->id, LEGACY_PCM_MODE,
699                               prtd->session_id, dir);
700         if (ret) {
701                 dev_err(dev, "Stream reg failed ret:%d\n", ret);
702                 return ret;
703         }
704
705         switch (params->codec.id) {
706         case SND_AUDIOCODEC_FLAC:
707
708                 memset(&flac_cfg, 0x0, sizeof(struct q6asm_flac_cfg));
709                 flac = &codec_options->flac_d;
710
711                 flac_cfg.ch_cfg = params->codec.ch_in;
712                 flac_cfg.sample_rate =  params->codec.sample_rate;
713                 flac_cfg.stream_info_present = 1;
714                 flac_cfg.sample_size = flac->sample_size;
715                 flac_cfg.min_blk_size = flac->min_blk_size;
716                 flac_cfg.max_blk_size = flac->max_blk_size;
717                 flac_cfg.max_frame_size = flac->max_frame_size;
718                 flac_cfg.min_frame_size = flac->min_frame_size;
719
720                 ret = q6asm_stream_media_format_block_flac(prtd->audio_client,
721                                                            prtd->stream_id,
722                                                            &flac_cfg);
723                 if (ret < 0) {
724                         dev_err(dev, "FLAC CMD Format block failed:%d\n", ret);
725                         return -EIO;
726                 }
727                 break;
728
729         case SND_AUDIOCODEC_WMA:
730                 wma = &codec_options->wma_d;
731
732                 memset(&wma_cfg, 0x0, sizeof(struct q6asm_wma_cfg));
733
734                 wma_cfg.sample_rate =  params->codec.sample_rate;
735                 wma_cfg.num_channels = params->codec.ch_in;
736                 wma_cfg.bytes_per_sec = params->codec.bit_rate / 8;
737                 wma_cfg.block_align = params->codec.align;
738                 wma_cfg.bits_per_sample = prtd->bits_per_sample;
739                 wma_cfg.enc_options = wma->encoder_option;
740                 wma_cfg.adv_enc_options = wma->adv_encoder_option;
741                 wma_cfg.adv_enc_options2 = wma->adv_encoder_option2;
742
743                 if (wma_cfg.num_channels == 1)
744                         wma_cfg.channel_mask = 4; /* Mono Center */
745                 else if (wma_cfg.num_channels == 2)
746                         wma_cfg.channel_mask = 3; /* Stereo FL/FR */
747                 else
748                         return -EINVAL;
749
750                 /* check the codec profile */
751                 switch (params->codec.profile) {
752                 case SND_AUDIOPROFILE_WMA9:
753                         wma_cfg.fmtag = 0x161;
754                         wma_v9 = 1;
755                         break;
756
757                 case SND_AUDIOPROFILE_WMA10:
758                         wma_cfg.fmtag = 0x166;
759                         break;
760
761                 case SND_AUDIOPROFILE_WMA9_PRO:
762                         wma_cfg.fmtag = 0x162;
763                         break;
764
765                 case SND_AUDIOPROFILE_WMA9_LOSSLESS:
766                         wma_cfg.fmtag = 0x163;
767                         break;
768
769                 case SND_AUDIOPROFILE_WMA10_LOSSLESS:
770                         wma_cfg.fmtag = 0x167;
771                         break;
772
773                 default:
774                         dev_err(dev, "Unknown WMA profile:%x\n",
775                                 params->codec.profile);
776                         return -EIO;
777                 }
778
779                 if (wma_v9)
780                         ret = q6asm_stream_media_format_block_wma_v9(
781                                         prtd->audio_client, prtd->stream_id,
782                                         &wma_cfg);
783                 else
784                         ret = q6asm_stream_media_format_block_wma_v10(
785                                         prtd->audio_client, prtd->stream_id,
786                                         &wma_cfg);
787                 if (ret < 0) {
788                         dev_err(dev, "WMA9 CMD failed:%d\n", ret);
789                         return -EIO;
790                 }
791                 break;
792
793         case SND_AUDIOCODEC_ALAC:
794                 memset(&alac_cfg, 0x0, sizeof(alac_cfg));
795                 alac = &codec_options->alac_d;
796
797                 alac_cfg.sample_rate = params->codec.sample_rate;
798                 alac_cfg.avg_bit_rate = params->codec.bit_rate;
799                 alac_cfg.bit_depth = prtd->bits_per_sample;
800                 alac_cfg.num_channels = params->codec.ch_in;
801
802                 alac_cfg.frame_length = alac->frame_length;
803                 alac_cfg.pb = alac->pb;
804                 alac_cfg.mb = alac->mb;
805                 alac_cfg.kb = alac->kb;
806                 alac_cfg.max_run = alac->max_run;
807                 alac_cfg.compatible_version = alac->compatible_version;
808                 alac_cfg.max_frame_bytes = alac->max_frame_bytes;
809
810                 switch (params->codec.ch_in) {
811                 case 1:
812                         alac_cfg.channel_layout_tag = ALAC_CH_LAYOUT_MONO;
813                         break;
814                 case 2:
815                         alac_cfg.channel_layout_tag = ALAC_CH_LAYOUT_STEREO;
816                         break;
817                 }
818                 ret = q6asm_stream_media_format_block_alac(prtd->audio_client,
819                                                            prtd->stream_id,
820                                                            &alac_cfg);
821                 if (ret < 0) {
822                         dev_err(dev, "ALAC CMD Format block failed:%d\n", ret);
823                         return -EIO;
824                 }
825                 break;
826
827         case SND_AUDIOCODEC_APE:
828                 memset(&ape_cfg, 0x0, sizeof(ape_cfg));
829                 ape = &codec_options->ape_d;
830
831                 ape_cfg.sample_rate = params->codec.sample_rate;
832                 ape_cfg.num_channels = params->codec.ch_in;
833                 ape_cfg.bits_per_sample = prtd->bits_per_sample;
834
835                 ape_cfg.compatible_version = ape->compatible_version;
836                 ape_cfg.compression_level = ape->compression_level;
837                 ape_cfg.format_flags = ape->format_flags;
838                 ape_cfg.blocks_per_frame = ape->blocks_per_frame;
839                 ape_cfg.final_frame_blocks = ape->final_frame_blocks;
840                 ape_cfg.total_frames = ape->total_frames;
841                 ape_cfg.seek_table_present = ape->seek_table_present;
842
843                 ret = q6asm_stream_media_format_block_ape(prtd->audio_client,
844                                                           prtd->stream_id,
845                                                           &ape_cfg);
846                 if (ret < 0) {
847                         dev_err(dev, "APE CMD Format block failed:%d\n", ret);
848                         return -EIO;
849                 }
850                 break;
851
852         default:
853                 break;
854         }
855
856         ret = q6asm_map_memory_regions(dir, prtd->audio_client, prtd->phys,
857                                        (prtd->pcm_size / prtd->periods),
858                                        prtd->periods);
859
860         if (ret < 0) {
861                 dev_err(dev, "Buffer Mapping failed ret:%d\n", ret);
862                 return -ENOMEM;
863         }
864
865         prtd->state = Q6ASM_STREAM_RUNNING;
866
867         return 0;
868 }
869
870 static int q6asm_dai_compr_set_metadata(struct snd_soc_component *component,
871                                         struct snd_compr_stream *stream,
872                                         struct snd_compr_metadata *metadata)
873 {
874         struct snd_compr_runtime *runtime = stream->runtime;
875         struct q6asm_dai_rtd *prtd = runtime->private_data;
876         int ret = 0;
877
878         switch (metadata->key) {
879         case SNDRV_COMPRESS_ENCODER_PADDING:
880                 prtd->trailing_samples_drop = metadata->value[0];
881                 break;
882         case SNDRV_COMPRESS_ENCODER_DELAY:
883                 prtd->initial_samples_drop = metadata->value[0];
884                 break;
885         default:
886                 ret = -EINVAL;
887                 break;
888         }
889
890         return ret;
891 }
892
893 static int q6asm_dai_compr_trigger(struct snd_soc_component *component,
894                                    struct snd_compr_stream *stream, int cmd)
895 {
896         struct snd_compr_runtime *runtime = stream->runtime;
897         struct q6asm_dai_rtd *prtd = runtime->private_data;
898         int ret = 0;
899
900         switch (cmd) {
901         case SNDRV_PCM_TRIGGER_START:
902         case SNDRV_PCM_TRIGGER_RESUME:
903         case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
904                 ret = q6asm_run_nowait(prtd->audio_client, prtd->stream_id,
905                                        0, 0, 0);
906                 break;
907         case SNDRV_PCM_TRIGGER_STOP:
908                 prtd->state = Q6ASM_STREAM_STOPPED;
909                 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
910                                        CMD_EOS);
911                 break;
912         case SNDRV_PCM_TRIGGER_SUSPEND:
913         case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
914                 ret = q6asm_cmd_nowait(prtd->audio_client, prtd->stream_id,
915                                        CMD_PAUSE);
916                 break;
917         default:
918                 ret = -EINVAL;
919                 break;
920         }
921
922         return ret;
923 }
924
925 static int q6asm_dai_compr_pointer(struct snd_soc_component *component,
926                                    struct snd_compr_stream *stream,
927                                    struct snd_compr_tstamp *tstamp)
928 {
929         struct snd_compr_runtime *runtime = stream->runtime;
930         struct q6asm_dai_rtd *prtd = runtime->private_data;
931         unsigned long flags;
932
933         spin_lock_irqsave(&prtd->lock, flags);
934
935         tstamp->copied_total = prtd->copied_total;
936         tstamp->byte_offset = prtd->copied_total % prtd->pcm_size;
937
938         spin_unlock_irqrestore(&prtd->lock, flags);
939
940         return 0;
941 }
942
943 static int q6asm_dai_compr_ack(struct snd_soc_component *component,
944                                struct snd_compr_stream *stream,
945                                size_t count)
946 {
947         struct snd_compr_runtime *runtime = stream->runtime;
948         struct q6asm_dai_rtd *prtd = runtime->private_data;
949         unsigned long flags;
950
951         spin_lock_irqsave(&prtd->lock, flags);
952         prtd->bytes_received += count;
953         spin_unlock_irqrestore(&prtd->lock, flags);
954
955         return count;
956 }
957
958 static int q6asm_dai_compr_mmap(struct snd_soc_component *component,
959                                 struct snd_compr_stream *stream,
960                                 struct vm_area_struct *vma)
961 {
962         struct snd_compr_runtime *runtime = stream->runtime;
963         struct q6asm_dai_rtd *prtd = runtime->private_data;
964         struct device *dev = component->dev;
965
966         return dma_mmap_coherent(dev, vma,
967                         prtd->dma_buffer.area, prtd->dma_buffer.addr,
968                         prtd->dma_buffer.bytes);
969 }
970
971 static int q6asm_dai_compr_get_caps(struct snd_soc_component *component,
972                                     struct snd_compr_stream *stream,
973                                     struct snd_compr_caps *caps)
974 {
975         caps->direction = SND_COMPRESS_PLAYBACK;
976         caps->min_fragment_size = COMPR_PLAYBACK_MIN_FRAGMENT_SIZE;
977         caps->max_fragment_size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE;
978         caps->min_fragments = COMPR_PLAYBACK_MIN_NUM_FRAGMENTS;
979         caps->max_fragments = COMPR_PLAYBACK_MAX_NUM_FRAGMENTS;
980         caps->num_codecs = 5;
981         caps->codecs[0] = SND_AUDIOCODEC_MP3;
982         caps->codecs[1] = SND_AUDIOCODEC_FLAC;
983         caps->codecs[2] = SND_AUDIOCODEC_WMA;
984         caps->codecs[3] = SND_AUDIOCODEC_ALAC;
985         caps->codecs[4] = SND_AUDIOCODEC_APE;
986
987         return 0;
988 }
989
990 static int q6asm_dai_compr_get_codec_caps(struct snd_soc_component *component,
991                                           struct snd_compr_stream *stream,
992                                           struct snd_compr_codec_caps *codec)
993 {
994         switch (codec->codec) {
995         case SND_AUDIOCODEC_MP3:
996                 *codec = q6asm_compr_caps;
997                 break;
998         default:
999                 break;
1000         }
1001
1002         return 0;
1003 }
1004
1005 static struct snd_compress_ops q6asm_dai_compress_ops = {
1006         .open           = q6asm_dai_compr_open,
1007         .free           = q6asm_dai_compr_free,
1008         .set_params     = q6asm_dai_compr_set_params,
1009         .set_metadata   = q6asm_dai_compr_set_metadata,
1010         .pointer        = q6asm_dai_compr_pointer,
1011         .trigger        = q6asm_dai_compr_trigger,
1012         .get_caps       = q6asm_dai_compr_get_caps,
1013         .get_codec_caps = q6asm_dai_compr_get_codec_caps,
1014         .mmap           = q6asm_dai_compr_mmap,
1015         .ack            = q6asm_dai_compr_ack,
1016 };
1017
1018 static int q6asm_dai_pcm_new(struct snd_soc_component *component,
1019                              struct snd_soc_pcm_runtime *rtd)
1020 {
1021         struct snd_pcm_substream *psubstream, *csubstream;
1022         struct snd_pcm *pcm = rtd->pcm;
1023         struct device *dev;
1024         int size, ret;
1025
1026         dev = component->dev;
1027         size = q6asm_dai_hardware_playback.buffer_bytes_max;
1028         psubstream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
1029         if (psubstream) {
1030                 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size,
1031                                           &psubstream->dma_buffer);
1032                 if (ret) {
1033                         dev_err(dev, "Cannot allocate buffer(s)\n");
1034                         return ret;
1035                 }
1036         }
1037
1038         csubstream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
1039         if (csubstream) {
1040                 ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size,
1041                                           &csubstream->dma_buffer);
1042                 if (ret) {
1043                         dev_err(dev, "Cannot allocate buffer(s)\n");
1044                         if (psubstream)
1045                                 snd_dma_free_pages(&psubstream->dma_buffer);
1046                         return ret;
1047                 }
1048         }
1049
1050         return 0;
1051 }
1052
1053 static void q6asm_dai_pcm_free(struct snd_soc_component *component,
1054                                struct snd_pcm *pcm)
1055 {
1056         struct snd_pcm_substream *substream;
1057         int i;
1058
1059         for (i = 0; i < ARRAY_SIZE(pcm->streams); i++) {
1060                 substream = pcm->streams[i].substream;
1061                 if (substream) {
1062                         snd_dma_free_pages(&substream->dma_buffer);
1063                         substream->dma_buffer.area = NULL;
1064                         substream->dma_buffer.addr = 0;
1065                 }
1066         }
1067 }
1068
1069 static const struct snd_soc_component_driver q6asm_fe_dai_component = {
1070         .name           = DRV_NAME,
1071         .open           = q6asm_dai_open,
1072         .hw_params      = q6asm_dai_hw_params,
1073         .close          = q6asm_dai_close,
1074         .prepare        = q6asm_dai_prepare,
1075         .trigger        = q6asm_dai_trigger,
1076         .pointer        = q6asm_dai_pointer,
1077         .mmap           = q6asm_dai_mmap,
1078         .pcm_construct  = q6asm_dai_pcm_new,
1079         .pcm_destruct   = q6asm_dai_pcm_free,
1080         .compress_ops   = &q6asm_dai_compress_ops,
1081 };
1082
1083 static struct snd_soc_dai_driver q6asm_fe_dais_template[] = {
1084         Q6ASM_FEDAI_DRIVER(1),
1085         Q6ASM_FEDAI_DRIVER(2),
1086         Q6ASM_FEDAI_DRIVER(3),
1087         Q6ASM_FEDAI_DRIVER(4),
1088         Q6ASM_FEDAI_DRIVER(5),
1089         Q6ASM_FEDAI_DRIVER(6),
1090         Q6ASM_FEDAI_DRIVER(7),
1091         Q6ASM_FEDAI_DRIVER(8),
1092 };
1093
1094 static int of_q6asm_parse_dai_data(struct device *dev,
1095                                     struct q6asm_dai_data *pdata)
1096 {
1097         struct snd_soc_dai_driver *dai_drv;
1098         struct snd_soc_pcm_stream empty_stream;
1099         struct device_node *node;
1100         int ret, id, dir, idx = 0;
1101
1102
1103         pdata->num_dais = of_get_child_count(dev->of_node);
1104         if (!pdata->num_dais) {
1105                 dev_err(dev, "No dais found in DT\n");
1106                 return -EINVAL;
1107         }
1108
1109         pdata->dais = devm_kcalloc(dev, pdata->num_dais, sizeof(*dai_drv),
1110                                    GFP_KERNEL);
1111         if (!pdata->dais)
1112                 return -ENOMEM;
1113
1114         memset(&empty_stream, 0, sizeof(empty_stream));
1115
1116         for_each_child_of_node(dev->of_node, node) {
1117                 ret = of_property_read_u32(node, "reg", &id);
1118                 if (ret || id >= MAX_SESSIONS || id < 0) {
1119                         dev_err(dev, "valid dai id not found:%d\n", ret);
1120                         continue;
1121                 }
1122
1123                 dai_drv = &pdata->dais[idx++];
1124                 *dai_drv = q6asm_fe_dais_template[id];
1125
1126                 ret = of_property_read_u32(node, "direction", &dir);
1127                 if (ret)
1128                         continue;
1129
1130                 if (dir == Q6ASM_DAI_RX)
1131                         dai_drv->capture = empty_stream;
1132                 else if (dir == Q6ASM_DAI_TX)
1133                         dai_drv->playback = empty_stream;
1134
1135                 if (of_property_read_bool(node, "is-compress-dai"))
1136                         dai_drv->compress_new = snd_soc_new_compress;
1137         }
1138
1139         return 0;
1140 }
1141
1142 static int q6asm_dai_probe(struct platform_device *pdev)
1143 {
1144         struct device *dev = &pdev->dev;
1145         struct device_node *node = dev->of_node;
1146         struct of_phandle_args args;
1147         struct q6asm_dai_data *pdata;
1148         int rc;
1149
1150         pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
1151         if (!pdata)
1152                 return -ENOMEM;
1153
1154         rc = of_parse_phandle_with_fixed_args(node, "iommus", 1, 0, &args);
1155         if (rc < 0)
1156                 pdata->sid = -1;
1157         else
1158                 pdata->sid = args.args[0] & SID_MASK_DEFAULT;
1159
1160         dev_set_drvdata(dev, pdata);
1161
1162         rc = of_q6asm_parse_dai_data(dev, pdata);
1163         if (rc)
1164                 return rc;
1165
1166         return devm_snd_soc_register_component(dev, &q6asm_fe_dai_component,
1167                                                pdata->dais, pdata->num_dais);
1168 }
1169
1170 static const struct of_device_id q6asm_dai_device_id[] = {
1171         { .compatible = "qcom,q6asm-dais" },
1172         {},
1173 };
1174 MODULE_DEVICE_TABLE(of, q6asm_dai_device_id);
1175
1176 static struct platform_driver q6asm_dai_platform_driver = {
1177         .driver = {
1178                 .name = "q6asm-dai",
1179                 .of_match_table = of_match_ptr(q6asm_dai_device_id),
1180         },
1181         .probe = q6asm_dai_probe,
1182 };
1183 module_platform_driver(q6asm_dai_platform_driver);
1184
1185 MODULE_DESCRIPTION("Q6ASM dai driver");
1186 MODULE_LICENSE("GPL v2");