2 * soc-pcm.c -- ALSA SoC PCM
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Copyright 2005 Openedhand Ltd.
6 * Copyright (C) 2010 Slimlogic Ltd.
7 * Copyright (C) 2010 Texas Instruments Inc.
9 * Authors: Liam Girdwood <lrg@ti.com>
10 * Mark Brown <broonie@opensource.wolfsonmicro.com>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/delay.h>
22 #include <linux/pm_runtime.h>
23 #include <linux/slab.h>
24 #include <linux/workqueue.h>
25 #include <sound/core.h>
26 #include <sound/pcm.h>
27 #include <sound/pcm_params.h>
28 #include <sound/soc.h>
29 #include <sound/initval.h>
31 static int soc_pcm_apply_symmetry(struct snd_pcm_substream
*substream
,
32 struct snd_soc_dai
*soc_dai
)
34 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
37 if (!soc_dai
->driver
->symmetric_rates
&&
38 !rtd
->dai_link
->symmetric_rates
)
41 /* This can happen if multiple streams are starting simultaneously -
42 * the second can need to get its constraints before the first has
43 * picked a rate. Complain and allow the application to carry on.
46 dev_warn(soc_dai
->dev
,
47 "Not enforcing symmetric_rates due to race\n");
51 dev_dbg(soc_dai
->dev
, "Symmetry forces %dHz rate\n", soc_dai
->rate
);
53 ret
= snd_pcm_hw_constraint_minmax(substream
->runtime
,
54 SNDRV_PCM_HW_PARAM_RATE
,
55 soc_dai
->rate
, soc_dai
->rate
);
58 "Unable to apply rate symmetry constraint: %d\n", ret
);
66 * List of sample sizes that might go over the bus for parameter
67 * application. There ought to be a wildcard sample size for things
68 * like the DAC/ADC resolution to use but there isn't right now.
70 static int sample_sizes
[] = {
74 static void soc_pcm_apply_msb(struct snd_pcm_substream
*substream
,
75 struct snd_soc_dai
*dai
)
79 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
80 bits
= dai
->driver
->playback
.sig_bits
;
82 bits
= dai
->driver
->capture
.sig_bits
;
87 for (i
= 0; i
< ARRAY_SIZE(sample_sizes
); i
++) {
88 if (bits
>= sample_sizes
[i
])
91 ret
= snd_pcm_hw_constraint_msbits(substream
->runtime
, 0,
92 sample_sizes
[i
], bits
);
95 "Failed to set MSB %d/%d: %d\n",
96 bits
, sample_sizes
[i
], ret
);
101 * Called by ALSA when a PCM substream is opened, the runtime->hw record is
102 * then initialized and any private data can be allocated. This also calls
103 * startup for the cpu DAI, platform, machine and codec DAI.
105 static int soc_pcm_open(struct snd_pcm_substream
*substream
)
107 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
108 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
109 struct snd_soc_platform
*platform
= rtd
->platform
;
110 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
111 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
112 struct snd_soc_dai_driver
*cpu_dai_drv
= cpu_dai
->driver
;
113 struct snd_soc_dai_driver
*codec_dai_drv
= codec_dai
->driver
;
116 pm_runtime_get_sync(cpu_dai
->dev
);
117 pm_runtime_get_sync(codec_dai
->dev
);
118 pm_runtime_get_sync(platform
->dev
);
120 mutex_lock_nested(&rtd
->pcm_mutex
, rtd
->pcm_subclass
);
122 /* startup the audio subsystem */
123 if (cpu_dai
->driver
->ops
->startup
) {
124 ret
= cpu_dai
->driver
->ops
->startup(substream
, cpu_dai
);
126 dev_err(cpu_dai
->dev
, "can't open interface %s: %d\n",
132 if (platform
->driver
->ops
&& platform
->driver
->ops
->open
) {
133 ret
= platform
->driver
->ops
->open(substream
);
135 dev_err(platform
->dev
, "can't open platform %s: %d\n",
136 platform
->name
, ret
);
141 if (codec_dai
->driver
->ops
->startup
) {
142 ret
= codec_dai
->driver
->ops
->startup(substream
, codec_dai
);
144 dev_err(codec_dai
->dev
, "can't open codec %s: %d\n",
145 codec_dai
->name
, ret
);
150 if (rtd
->dai_link
->ops
&& rtd
->dai_link
->ops
->startup
) {
151 ret
= rtd
->dai_link
->ops
->startup(substream
);
153 pr_err("asoc: %s startup failed: %d\n",
154 rtd
->dai_link
->name
, ret
);
159 /* Check that the codec and cpu DAIs are compatible */
160 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
161 runtime
->hw
.rate_min
=
162 max(codec_dai_drv
->playback
.rate_min
,
163 cpu_dai_drv
->playback
.rate_min
);
164 runtime
->hw
.rate_max
=
165 min(codec_dai_drv
->playback
.rate_max
,
166 cpu_dai_drv
->playback
.rate_max
);
167 runtime
->hw
.channels_min
=
168 max(codec_dai_drv
->playback
.channels_min
,
169 cpu_dai_drv
->playback
.channels_min
);
170 runtime
->hw
.channels_max
=
171 min(codec_dai_drv
->playback
.channels_max
,
172 cpu_dai_drv
->playback
.channels_max
);
173 runtime
->hw
.formats
=
174 codec_dai_drv
->playback
.formats
& cpu_dai_drv
->playback
.formats
;
176 codec_dai_drv
->playback
.rates
& cpu_dai_drv
->playback
.rates
;
177 if (codec_dai_drv
->playback
.rates
178 & (SNDRV_PCM_RATE_KNOT
| SNDRV_PCM_RATE_CONTINUOUS
))
179 runtime
->hw
.rates
|= cpu_dai_drv
->playback
.rates
;
180 if (cpu_dai_drv
->playback
.rates
181 & (SNDRV_PCM_RATE_KNOT
| SNDRV_PCM_RATE_CONTINUOUS
))
182 runtime
->hw
.rates
|= codec_dai_drv
->playback
.rates
;
184 runtime
->hw
.rate_min
=
185 max(codec_dai_drv
->capture
.rate_min
,
186 cpu_dai_drv
->capture
.rate_min
);
187 runtime
->hw
.rate_max
=
188 min(codec_dai_drv
->capture
.rate_max
,
189 cpu_dai_drv
->capture
.rate_max
);
190 runtime
->hw
.channels_min
=
191 max(codec_dai_drv
->capture
.channels_min
,
192 cpu_dai_drv
->capture
.channels_min
);
193 runtime
->hw
.channels_max
=
194 min(codec_dai_drv
->capture
.channels_max
,
195 cpu_dai_drv
->capture
.channels_max
);
196 runtime
->hw
.formats
=
197 codec_dai_drv
->capture
.formats
& cpu_dai_drv
->capture
.formats
;
199 codec_dai_drv
->capture
.rates
& cpu_dai_drv
->capture
.rates
;
200 if (codec_dai_drv
->capture
.rates
201 & (SNDRV_PCM_RATE_KNOT
| SNDRV_PCM_RATE_CONTINUOUS
))
202 runtime
->hw
.rates
|= cpu_dai_drv
->capture
.rates
;
203 if (cpu_dai_drv
->capture
.rates
204 & (SNDRV_PCM_RATE_KNOT
| SNDRV_PCM_RATE_CONTINUOUS
))
205 runtime
->hw
.rates
|= codec_dai_drv
->capture
.rates
;
209 snd_pcm_limit_hw_rates(runtime
);
210 if (!runtime
->hw
.rates
) {
211 printk(KERN_ERR
"asoc: %s <-> %s No matching rates\n",
212 codec_dai
->name
, cpu_dai
->name
);
215 if (!runtime
->hw
.formats
) {
216 printk(KERN_ERR
"asoc: %s <-> %s No matching formats\n",
217 codec_dai
->name
, cpu_dai
->name
);
220 if (!runtime
->hw
.channels_min
|| !runtime
->hw
.channels_max
||
221 runtime
->hw
.channels_min
> runtime
->hw
.channels_max
) {
222 printk(KERN_ERR
"asoc: %s <-> %s No matching channels\n",
223 codec_dai
->name
, cpu_dai
->name
);
227 soc_pcm_apply_msb(substream
, codec_dai
);
228 soc_pcm_apply_msb(substream
, cpu_dai
);
230 /* Symmetry only applies if we've already got an active stream. */
231 if (cpu_dai
->active
) {
232 ret
= soc_pcm_apply_symmetry(substream
, cpu_dai
);
237 if (codec_dai
->active
) {
238 ret
= soc_pcm_apply_symmetry(substream
, codec_dai
);
243 pr_debug("asoc: %s <-> %s info:\n",
244 codec_dai
->name
, cpu_dai
->name
);
245 pr_debug("asoc: rate mask 0x%x\n", runtime
->hw
.rates
);
246 pr_debug("asoc: min ch %d max ch %d\n", runtime
->hw
.channels_min
,
247 runtime
->hw
.channels_max
);
248 pr_debug("asoc: min rate %d max rate %d\n", runtime
->hw
.rate_min
,
249 runtime
->hw
.rate_max
);
251 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
252 cpu_dai
->playback_active
++;
253 codec_dai
->playback_active
++;
255 cpu_dai
->capture_active
++;
256 codec_dai
->capture_active
++;
260 rtd
->codec
->active
++;
261 mutex_unlock(&rtd
->pcm_mutex
);
265 if (rtd
->dai_link
->ops
&& rtd
->dai_link
->ops
->shutdown
)
266 rtd
->dai_link
->ops
->shutdown(substream
);
269 if (codec_dai
->driver
->ops
->shutdown
)
270 codec_dai
->driver
->ops
->shutdown(substream
, codec_dai
);
273 if (platform
->driver
->ops
&& platform
->driver
->ops
->close
)
274 platform
->driver
->ops
->close(substream
);
277 if (cpu_dai
->driver
->ops
->shutdown
)
278 cpu_dai
->driver
->ops
->shutdown(substream
, cpu_dai
);
280 mutex_unlock(&rtd
->pcm_mutex
);
282 pm_runtime_put(platform
->dev
);
283 pm_runtime_put(codec_dai
->dev
);
284 pm_runtime_put(cpu_dai
->dev
);
290 * Power down the audio subsystem pmdown_time msecs after close is called.
291 * This is to ensure there are no pops or clicks in between any music tracks
292 * due to DAPM power cycling.
294 static void close_delayed_work(struct work_struct
*work
)
296 struct snd_soc_pcm_runtime
*rtd
=
297 container_of(work
, struct snd_soc_pcm_runtime
, delayed_work
.work
);
298 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
300 mutex_lock_nested(&rtd
->pcm_mutex
, rtd
->pcm_subclass
);
302 pr_debug("pop wq checking: %s status: %s waiting: %s\n",
303 codec_dai
->driver
->playback
.stream_name
,
304 codec_dai
->playback_active
? "active" : "inactive",
305 codec_dai
->pop_wait
? "yes" : "no");
307 /* are we waiting on this codec DAI stream */
308 if (codec_dai
->pop_wait
== 1) {
309 codec_dai
->pop_wait
= 0;
310 snd_soc_dapm_stream_event(rtd
, SNDRV_PCM_STREAM_PLAYBACK
,
311 codec_dai
, SND_SOC_DAPM_STREAM_STOP
);
314 mutex_unlock(&rtd
->pcm_mutex
);
318 * Called by ALSA when a PCM substream is closed. Private data can be
319 * freed here. The cpu DAI, codec DAI, machine and platform are also
322 static int soc_pcm_close(struct snd_pcm_substream
*substream
)
324 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
325 struct snd_soc_platform
*platform
= rtd
->platform
;
326 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
327 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
328 struct snd_soc_codec
*codec
= rtd
->codec
;
330 mutex_lock_nested(&rtd
->pcm_mutex
, rtd
->pcm_subclass
);
332 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
333 cpu_dai
->playback_active
--;
334 codec_dai
->playback_active
--;
336 cpu_dai
->capture_active
--;
337 codec_dai
->capture_active
--;
344 /* clear the corresponding DAIs rate when inactive */
345 if (!cpu_dai
->active
)
348 if (!codec_dai
->active
)
351 /* Muting the DAC suppresses artifacts caused during digital
352 * shutdown, for example from stopping clocks.
354 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
355 snd_soc_dai_digital_mute(codec_dai
, 1);
357 if (cpu_dai
->driver
->ops
->shutdown
)
358 cpu_dai
->driver
->ops
->shutdown(substream
, cpu_dai
);
360 if (codec_dai
->driver
->ops
->shutdown
)
361 codec_dai
->driver
->ops
->shutdown(substream
, codec_dai
);
363 if (rtd
->dai_link
->ops
&& rtd
->dai_link
->ops
->shutdown
)
364 rtd
->dai_link
->ops
->shutdown(substream
);
366 if (platform
->driver
->ops
&& platform
->driver
->ops
->close
)
367 platform
->driver
->ops
->close(substream
);
368 cpu_dai
->runtime
= NULL
;
370 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
) {
371 if (!rtd
->pmdown_time
|| codec
->ignore_pmdown_time
||
372 rtd
->dai_link
->ignore_pmdown_time
) {
373 /* powered down playback stream now */
374 snd_soc_dapm_stream_event(rtd
,
375 SNDRV_PCM_STREAM_PLAYBACK
,
377 SND_SOC_DAPM_STREAM_STOP
);
379 /* start delayed pop wq here for playback streams */
380 codec_dai
->pop_wait
= 1;
381 schedule_delayed_work(&rtd
->delayed_work
,
382 msecs_to_jiffies(rtd
->pmdown_time
));
385 /* capture streams can be powered down now */
386 snd_soc_dapm_stream_event(rtd
, SNDRV_PCM_STREAM_CAPTURE
,
387 codec_dai
, SND_SOC_DAPM_STREAM_STOP
);
390 mutex_unlock(&rtd
->pcm_mutex
);
392 pm_runtime_put(platform
->dev
);
393 pm_runtime_put(codec_dai
->dev
);
394 pm_runtime_put(cpu_dai
->dev
);
400 * Called by ALSA when the PCM substream is prepared, can set format, sample
401 * rate, etc. This function is non atomic and can be called multiple times,
402 * it can refer to the runtime info.
404 static int soc_pcm_prepare(struct snd_pcm_substream
*substream
)
406 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
407 struct snd_soc_platform
*platform
= rtd
->platform
;
408 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
409 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
412 mutex_lock_nested(&rtd
->pcm_mutex
, rtd
->pcm_subclass
);
414 if (rtd
->dai_link
->ops
&& rtd
->dai_link
->ops
->prepare
) {
415 ret
= rtd
->dai_link
->ops
->prepare(substream
);
417 pr_err("asoc: machine prepare error: %d\n", ret
);
422 if (platform
->driver
->ops
&& platform
->driver
->ops
->prepare
) {
423 ret
= platform
->driver
->ops
->prepare(substream
);
425 dev_err(platform
->dev
, "platform prepare error: %d\n",
431 if (codec_dai
->driver
->ops
->prepare
) {
432 ret
= codec_dai
->driver
->ops
->prepare(substream
, codec_dai
);
434 dev_err(codec_dai
->dev
, "DAI prepare error: %d\n",
440 if (cpu_dai
->driver
->ops
->prepare
) {
441 ret
= cpu_dai
->driver
->ops
->prepare(substream
, cpu_dai
);
443 dev_err(cpu_dai
->dev
, "DAI prepare error: %d\n",
449 /* cancel any delayed stream shutdown that is pending */
450 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
&&
451 codec_dai
->pop_wait
) {
452 codec_dai
->pop_wait
= 0;
453 cancel_delayed_work(&rtd
->delayed_work
);
456 snd_soc_dapm_stream_event(rtd
, substream
->stream
, codec_dai
,
457 SND_SOC_DAPM_STREAM_START
);
459 snd_soc_dai_digital_mute(codec_dai
, 0);
462 mutex_unlock(&rtd
->pcm_mutex
);
467 * Called by ALSA when the hardware params are set by application. This
468 * function can also be called multiple times and can allocate buffers
469 * (using snd_pcm_lib_* ). It's non-atomic.
471 static int soc_pcm_hw_params(struct snd_pcm_substream
*substream
,
472 struct snd_pcm_hw_params
*params
)
474 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
475 struct snd_soc_platform
*platform
= rtd
->platform
;
476 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
477 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
480 mutex_lock_nested(&rtd
->pcm_mutex
, rtd
->pcm_subclass
);
482 if (rtd
->dai_link
->ops
&& rtd
->dai_link
->ops
->hw_params
) {
483 ret
= rtd
->dai_link
->ops
->hw_params(substream
, params
);
485 pr_err("asoc: machine hw_params failed: %d\n", ret
);
490 if (codec_dai
->driver
->ops
->hw_params
) {
491 ret
= codec_dai
->driver
->ops
->hw_params(substream
, params
, codec_dai
);
493 dev_err(codec_dai
->dev
, "can't set %s hw params: %d\n",
494 codec_dai
->name
, ret
);
499 if (cpu_dai
->driver
->ops
->hw_params
) {
500 ret
= cpu_dai
->driver
->ops
->hw_params(substream
, params
, cpu_dai
);
502 dev_err(cpu_dai
->dev
, "%s hw params failed: %d\n",
508 if (platform
->driver
->ops
&& platform
->driver
->ops
->hw_params
) {
509 ret
= platform
->driver
->ops
->hw_params(substream
, params
);
511 dev_err(platform
->dev
, "%s hw params failed: %d\n",
512 platform
->name
, ret
);
517 /* store the rate for each DAIs */
518 cpu_dai
->rate
= params_rate(params
);
519 codec_dai
->rate
= params_rate(params
);
522 mutex_unlock(&rtd
->pcm_mutex
);
526 if (cpu_dai
->driver
->ops
->hw_free
)
527 cpu_dai
->driver
->ops
->hw_free(substream
, cpu_dai
);
530 if (codec_dai
->driver
->ops
->hw_free
)
531 codec_dai
->driver
->ops
->hw_free(substream
, codec_dai
);
534 if (rtd
->dai_link
->ops
&& rtd
->dai_link
->ops
->hw_free
)
535 rtd
->dai_link
->ops
->hw_free(substream
);
537 mutex_unlock(&rtd
->pcm_mutex
);
542 * Frees resources allocated by hw_params, can be called multiple times
544 static int soc_pcm_hw_free(struct snd_pcm_substream
*substream
)
546 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
547 struct snd_soc_platform
*platform
= rtd
->platform
;
548 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
549 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
550 struct snd_soc_codec
*codec
= rtd
->codec
;
552 mutex_lock_nested(&rtd
->pcm_mutex
, rtd
->pcm_subclass
);
554 /* apply codec digital mute */
556 snd_soc_dai_digital_mute(codec_dai
, 1);
558 /* free any machine hw params */
559 if (rtd
->dai_link
->ops
&& rtd
->dai_link
->ops
->hw_free
)
560 rtd
->dai_link
->ops
->hw_free(substream
);
562 /* free any DMA resources */
563 if (platform
->driver
->ops
&& platform
->driver
->ops
->hw_free
)
564 platform
->driver
->ops
->hw_free(substream
);
566 /* now free hw params for the DAIs */
567 if (codec_dai
->driver
->ops
->hw_free
)
568 codec_dai
->driver
->ops
->hw_free(substream
, codec_dai
);
570 if (cpu_dai
->driver
->ops
->hw_free
)
571 cpu_dai
->driver
->ops
->hw_free(substream
, cpu_dai
);
573 mutex_unlock(&rtd
->pcm_mutex
);
577 static int soc_pcm_trigger(struct snd_pcm_substream
*substream
, int cmd
)
579 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
580 struct snd_soc_platform
*platform
= rtd
->platform
;
581 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
582 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
585 if (codec_dai
->driver
->ops
->trigger
) {
586 ret
= codec_dai
->driver
->ops
->trigger(substream
, cmd
, codec_dai
);
591 if (platform
->driver
->ops
&& platform
->driver
->ops
->trigger
) {
592 ret
= platform
->driver
->ops
->trigger(substream
, cmd
);
597 if (cpu_dai
->driver
->ops
->trigger
) {
598 ret
= cpu_dai
->driver
->ops
->trigger(substream
, cmd
, cpu_dai
);
606 * soc level wrapper for pointer callback
607 * If cpu_dai, codec_dai, platform driver has the delay callback, than
608 * the runtime->delay will be updated accordingly.
610 static snd_pcm_uframes_t
soc_pcm_pointer(struct snd_pcm_substream
*substream
)
612 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
613 struct snd_soc_platform
*platform
= rtd
->platform
;
614 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
615 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
616 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
617 snd_pcm_uframes_t offset
= 0;
618 snd_pcm_sframes_t delay
= 0;
620 if (platform
->driver
->ops
&& platform
->driver
->ops
->pointer
)
621 offset
= platform
->driver
->ops
->pointer(substream
);
623 if (cpu_dai
->driver
->ops
->delay
)
624 delay
+= cpu_dai
->driver
->ops
->delay(substream
, cpu_dai
);
626 if (codec_dai
->driver
->ops
->delay
)
627 delay
+= codec_dai
->driver
->ops
->delay(substream
, codec_dai
);
629 if (platform
->driver
->delay
)
630 delay
+= platform
->driver
->delay(substream
, codec_dai
);
632 runtime
->delay
= delay
;
637 /* create a new pcm */
638 int soc_new_pcm(struct snd_soc_pcm_runtime
*rtd
, int num
)
640 struct snd_soc_codec
*codec
= rtd
->codec
;
641 struct snd_soc_platform
*platform
= rtd
->platform
;
642 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
643 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
644 struct snd_pcm_ops
*soc_pcm_ops
= &rtd
->ops
;
647 int ret
= 0, playback
= 0, capture
= 0;
649 soc_pcm_ops
->open
= soc_pcm_open
;
650 soc_pcm_ops
->close
= soc_pcm_close
;
651 soc_pcm_ops
->hw_params
= soc_pcm_hw_params
;
652 soc_pcm_ops
->hw_free
= soc_pcm_hw_free
;
653 soc_pcm_ops
->prepare
= soc_pcm_prepare
;
654 soc_pcm_ops
->trigger
= soc_pcm_trigger
;
655 soc_pcm_ops
->pointer
= soc_pcm_pointer
;
657 /* check client and interface hw capabilities */
658 snprintf(new_name
, sizeof(new_name
), "%s %s-%d",
659 rtd
->dai_link
->stream_name
, codec_dai
->name
, num
);
661 if (codec_dai
->driver
->playback
.channels_min
)
663 if (codec_dai
->driver
->capture
.channels_min
)
666 dev_dbg(rtd
->card
->dev
, "registered pcm #%d %s\n",num
,new_name
);
667 ret
= snd_pcm_new(rtd
->card
->snd_card
, new_name
,
668 num
, playback
, capture
, &pcm
);
670 printk(KERN_ERR
"asoc: can't create pcm for codec %s\n", codec
->name
);
674 /* DAPM dai link stream work */
675 INIT_DELAYED_WORK(&rtd
->delayed_work
, close_delayed_work
);
678 pcm
->private_data
= rtd
;
679 if (platform
->driver
->ops
) {
680 soc_pcm_ops
->mmap
= platform
->driver
->ops
->mmap
;
681 soc_pcm_ops
->pointer
= platform
->driver
->ops
->pointer
;
682 soc_pcm_ops
->ioctl
= platform
->driver
->ops
->ioctl
;
683 soc_pcm_ops
->copy
= platform
->driver
->ops
->copy
;
684 soc_pcm_ops
->silence
= platform
->driver
->ops
->silence
;
685 soc_pcm_ops
->ack
= platform
->driver
->ops
->ack
;
686 soc_pcm_ops
->page
= platform
->driver
->ops
->page
;
690 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
, soc_pcm_ops
);
693 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
, soc_pcm_ops
);
695 if (platform
->driver
->pcm_new
) {
696 ret
= platform
->driver
->pcm_new(rtd
);
698 pr_err("asoc: platform pcm constructor failed\n");
703 pcm
->private_free
= platform
->driver
->pcm_free
;
704 printk(KERN_INFO
"asoc: %s <-> %s mapping ok\n", codec_dai
->name
,