1 // SPDX-License-Identifier: GPL-2.0+
3 // soc-compress.c -- ALSA SoC Compress
5 // Copyright (C) 2012 Intel Corp.
7 // Authors: Namarta Kohli <namartax.kohli@intel.com>
8 // Ramesh Babu K V <ramesh.babu@linux.intel.com>
9 // Vinod Koul <vinod.koul@linux.intel.com>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
14 #include <linux/slab.h>
15 #include <linux/workqueue.h>
16 #include <sound/core.h>
17 #include <sound/compress_params.h>
18 #include <sound/compress_driver.h>
19 #include <sound/soc.h>
20 #include <sound/initval.h>
21 #include <sound/soc-dpcm.h>
22 #include <sound/soc-link.h>
23 #include <linux/pm_runtime.h>
25 static int soc_compr_components_open(struct snd_compr_stream *cstream,
26 struct snd_soc_component **last)
28 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
29 struct snd_soc_component *component;
32 for_each_rtd_components(rtd, i, component) {
33 if (!component->driver->compress_ops ||
34 !component->driver->compress_ops->open)
37 ret = component->driver->compress_ops->open(component, cstream);
39 dev_err(component->dev,
40 "Compress ASoC: can't open platform %s: %d\n",
41 component->name, ret);
52 static int soc_compr_components_free(struct snd_compr_stream *cstream,
53 struct snd_soc_component *last)
55 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
56 struct snd_soc_component *component;
59 for_each_rtd_components(rtd, i, component) {
60 if (component == last)
63 if (!component->driver->compress_ops ||
64 !component->driver->compress_ops->free)
67 component->driver->compress_ops->free(component, cstream);
73 static int soc_compr_open(struct snd_compr_stream *cstream)
75 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
76 struct snd_soc_component *component = NULL;
77 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
80 ret = snd_soc_pcm_component_pm_runtime_get(rtd, cstream);
84 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
86 ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
90 ret = soc_compr_components_open(cstream, &component);
94 ret = snd_soc_link_compr_startup(cstream);
98 snd_soc_runtime_activate(rtd, cstream->direction);
100 mutex_unlock(&rtd->card->pcm_mutex);
105 soc_compr_components_free(cstream, component);
107 snd_soc_dai_compr_shutdown(cpu_dai, cstream);
109 mutex_unlock(&rtd->card->pcm_mutex);
111 snd_soc_pcm_component_pm_runtime_put(rtd, cstream, 1);
116 static int soc_compr_open_fe(struct snd_compr_stream *cstream)
118 struct snd_soc_pcm_runtime *fe = cstream->private_data;
119 struct snd_pcm_substream *fe_substream =
120 fe->pcm->streams[cstream->direction].substream;
121 struct snd_soc_component *component;
122 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
123 struct snd_soc_dpcm *dpcm;
124 struct snd_soc_dapm_widget_list *list;
128 if (cstream->direction == SND_COMPRESS_PLAYBACK)
129 stream = SNDRV_PCM_STREAM_PLAYBACK;
131 stream = SNDRV_PCM_STREAM_CAPTURE;
133 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
134 fe->dpcm[stream].runtime = fe_substream->runtime;
136 ret = dpcm_path_get(fe, stream, &list);
140 dev_dbg(fe->dev, "Compress ASoC: %s no valid %s route\n",
141 fe->dai_link->name, stream ? "capture" : "playback");
142 /* calculate valid and active FE <-> BE dpcms */
143 dpcm_process_paths(fe, stream, &list, 1);
144 fe->dpcm[stream].runtime = fe_substream->runtime;
146 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
148 ret = dpcm_be_dai_startup(fe, stream);
150 /* clean up all links */
151 for_each_dpcm_be(fe, stream, dpcm)
152 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
154 dpcm_be_disconnect(fe, stream);
155 fe->dpcm[stream].runtime = NULL;
159 ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
163 ret = soc_compr_components_open(cstream, &component);
167 ret = snd_soc_link_compr_startup(cstream);
171 dpcm_clear_pending_state(fe, stream);
172 dpcm_path_put(&list);
174 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN;
175 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
177 snd_soc_runtime_activate(fe, stream);
179 mutex_unlock(&fe->card->mutex);
184 soc_compr_components_free(cstream, component);
186 snd_soc_dai_compr_shutdown(cpu_dai, cstream);
188 dpcm_path_put(&list);
190 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
191 mutex_unlock(&fe->card->mutex);
195 static int soc_compr_free(struct snd_compr_stream *cstream)
197 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
198 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
199 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
202 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
204 if (cstream->direction == SND_COMPRESS_PLAYBACK)
205 stream = SNDRV_PCM_STREAM_PLAYBACK;
207 stream = SNDRV_PCM_STREAM_CAPTURE;
209 snd_soc_runtime_deactivate(rtd, stream);
211 snd_soc_dai_digital_mute(codec_dai, 1, cstream->direction);
213 if (!snd_soc_dai_active(cpu_dai))
216 if (!snd_soc_dai_active(codec_dai))
219 snd_soc_link_compr_shutdown(cstream);
221 soc_compr_components_free(cstream, NULL);
223 snd_soc_dai_compr_shutdown(cpu_dai, cstream);
225 snd_soc_dapm_stream_stop(rtd, stream);
227 mutex_unlock(&rtd->card->pcm_mutex);
229 snd_soc_pcm_component_pm_runtime_put(rtd, cstream, 0);
234 static int soc_compr_free_fe(struct snd_compr_stream *cstream)
236 struct snd_soc_pcm_runtime *fe = cstream->private_data;
237 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
238 struct snd_soc_dpcm *dpcm;
241 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
243 if (cstream->direction == SND_COMPRESS_PLAYBACK)
244 stream = SNDRV_PCM_STREAM_PLAYBACK;
246 stream = SNDRV_PCM_STREAM_CAPTURE;
248 snd_soc_runtime_deactivate(fe, stream);
250 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
252 ret = dpcm_be_dai_hw_free(fe, stream);
254 dev_err(fe->dev, "Compressed ASoC: hw_free failed: %d\n", ret);
256 ret = dpcm_be_dai_shutdown(fe, stream);
258 /* mark FE's links ready to prune */
259 for_each_dpcm_be(fe, stream, dpcm)
260 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
262 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP);
264 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE;
265 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
267 dpcm_be_disconnect(fe, stream);
269 fe->dpcm[stream].runtime = NULL;
271 snd_soc_link_compr_shutdown(cstream);
273 soc_compr_components_free(cstream, NULL);
275 snd_soc_dai_compr_shutdown(cpu_dai, cstream);
277 mutex_unlock(&fe->card->mutex);
281 static int soc_compr_components_trigger(struct snd_compr_stream *cstream,
284 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
285 struct snd_soc_component *component;
288 for_each_rtd_components(rtd, i, component) {
289 if (!component->driver->compress_ops ||
290 !component->driver->compress_ops->trigger)
293 ret = component->driver->compress_ops->trigger(
294 component, cstream, cmd);
302 static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
304 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
305 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
306 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
309 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
311 ret = soc_compr_components_trigger(cstream, cmd);
315 ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
320 case SNDRV_PCM_TRIGGER_START:
321 snd_soc_dai_digital_mute(codec_dai, 0, cstream->direction);
323 case SNDRV_PCM_TRIGGER_STOP:
324 snd_soc_dai_digital_mute(codec_dai, 1, cstream->direction);
329 mutex_unlock(&rtd->card->pcm_mutex);
333 static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
335 struct snd_soc_pcm_runtime *fe = cstream->private_data;
336 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
339 if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
340 cmd == SND_COMPR_TRIGGER_DRAIN)
341 return soc_compr_components_trigger(cstream, cmd);
343 if (cstream->direction == SND_COMPRESS_PLAYBACK)
344 stream = SNDRV_PCM_STREAM_PLAYBACK;
346 stream = SNDRV_PCM_STREAM_CAPTURE;
348 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
350 ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
354 ret = soc_compr_components_trigger(cstream, cmd);
358 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
360 ret = dpcm_be_dai_trigger(fe, stream, cmd);
363 case SNDRV_PCM_TRIGGER_START:
364 case SNDRV_PCM_TRIGGER_RESUME:
365 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
366 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
368 case SNDRV_PCM_TRIGGER_STOP:
369 case SNDRV_PCM_TRIGGER_SUSPEND:
370 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
372 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
373 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
378 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
379 mutex_unlock(&fe->card->mutex);
383 static int soc_compr_components_set_params(struct snd_compr_stream *cstream,
384 struct snd_compr_params *params)
386 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
387 struct snd_soc_component *component;
390 for_each_rtd_components(rtd, i, component) {
391 if (!component->driver->compress_ops ||
392 !component->driver->compress_ops->set_params)
395 ret = component->driver->compress_ops->set_params(
396 component, cstream, params);
404 static int soc_compr_set_params(struct snd_compr_stream *cstream,
405 struct snd_compr_params *params)
407 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
408 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
411 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
414 * First we call set_params for the CPU DAI, then the component
415 * driver this should configure the SoC side. If the machine has
416 * compressed ops then we call that as well. The expectation is
417 * that these callbacks will configure everything for this compress
418 * path, like configuring a PCM port for a CODEC.
420 ret = snd_soc_dai_compr_set_params(cpu_dai, cstream, params);
424 ret = soc_compr_components_set_params(cstream, params);
428 ret = snd_soc_link_compr_set_params(cstream);
432 if (cstream->direction == SND_COMPRESS_PLAYBACK)
433 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
434 SND_SOC_DAPM_STREAM_START);
436 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
437 SND_SOC_DAPM_STREAM_START);
439 /* cancel any delayed stream shutdown that is pending */
441 mutex_unlock(&rtd->card->pcm_mutex);
443 cancel_delayed_work_sync(&rtd->delayed_work);
448 mutex_unlock(&rtd->card->pcm_mutex);
452 static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
453 struct snd_compr_params *params)
455 struct snd_soc_pcm_runtime *fe = cstream->private_data;
456 struct snd_pcm_substream *fe_substream =
457 fe->pcm->streams[cstream->direction].substream;
458 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
461 if (cstream->direction == SND_COMPRESS_PLAYBACK)
462 stream = SNDRV_PCM_STREAM_PLAYBACK;
464 stream = SNDRV_PCM_STREAM_CAPTURE;
466 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
469 * Create an empty hw_params for the BE as the machine driver must
470 * fix this up to match DSP decoder and ASRC configuration.
471 * I.e. machine driver fixup for compressed BE is mandatory.
473 memset(&fe->dpcm[fe_substream->stream].hw_params, 0,
474 sizeof(struct snd_pcm_hw_params));
476 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
478 ret = dpcm_be_dai_hw_params(fe, stream);
482 ret = dpcm_be_dai_prepare(fe, stream);
486 ret = snd_soc_dai_compr_set_params(cpu_dai, cstream, params);
490 ret = soc_compr_components_set_params(cstream, params);
494 ret = snd_soc_link_compr_set_params(cstream);
498 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START);
499 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE;
502 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
503 mutex_unlock(&fe->card->mutex);
507 static int soc_compr_get_params(struct snd_compr_stream *cstream,
508 struct snd_codec *params)
510 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
511 struct snd_soc_component *component;
512 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
515 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
517 ret = snd_soc_dai_compr_get_params(cpu_dai, cstream, params);
521 for_each_rtd_components(rtd, i, component) {
522 if (!component->driver->compress_ops ||
523 !component->driver->compress_ops->get_params)
526 ret = component->driver->compress_ops->get_params(
527 component, cstream, params);
532 mutex_unlock(&rtd->card->pcm_mutex);
536 static int soc_compr_get_caps(struct snd_compr_stream *cstream,
537 struct snd_compr_caps *caps)
539 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
540 struct snd_soc_component *component;
543 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
545 for_each_rtd_components(rtd, i, component) {
546 if (!component->driver->compress_ops ||
547 !component->driver->compress_ops->get_caps)
550 ret = component->driver->compress_ops->get_caps(
551 component, cstream, caps);
555 mutex_unlock(&rtd->card->pcm_mutex);
559 static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
560 struct snd_compr_codec_caps *codec)
562 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
563 struct snd_soc_component *component;
566 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
568 for_each_rtd_components(rtd, i, component) {
569 if (!component->driver->compress_ops ||
570 !component->driver->compress_ops->get_codec_caps)
573 ret = component->driver->compress_ops->get_codec_caps(
574 component, cstream, codec);
578 mutex_unlock(&rtd->card->pcm_mutex);
582 static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
584 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
585 struct snd_soc_component *component;
586 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
589 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
591 ret = snd_soc_dai_compr_ack(cpu_dai, cstream, bytes);
595 for_each_rtd_components(rtd, i, component) {
596 if (!component->driver->compress_ops ||
597 !component->driver->compress_ops->ack)
600 ret = component->driver->compress_ops->ack(
601 component, cstream, bytes);
607 mutex_unlock(&rtd->card->pcm_mutex);
611 static int soc_compr_pointer(struct snd_compr_stream *cstream,
612 struct snd_compr_tstamp *tstamp)
614 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
615 struct snd_soc_component *component;
617 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
619 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
621 ret = snd_soc_dai_compr_pointer(cpu_dai, cstream, tstamp);
625 for_each_rtd_components(rtd, i, component) {
626 if (!component->driver->compress_ops ||
627 !component->driver->compress_ops->pointer)
630 ret = component->driver->compress_ops->pointer(
631 component, cstream, tstamp);
635 mutex_unlock(&rtd->card->pcm_mutex);
639 static int soc_compr_copy(struct snd_compr_stream *cstream,
640 char __user *buf, size_t count)
642 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
643 struct snd_soc_component *component;
646 mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
648 for_each_rtd_components(rtd, i, component) {
649 if (!component->driver->compress_ops ||
650 !component->driver->compress_ops->copy)
653 ret = component->driver->compress_ops->copy(
654 component, cstream, buf, count);
658 mutex_unlock(&rtd->card->pcm_mutex);
662 static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
663 struct snd_compr_metadata *metadata)
665 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
666 struct snd_soc_component *component;
667 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
670 ret = snd_soc_dai_compr_set_metadata(cpu_dai, cstream, metadata);
674 for_each_rtd_components(rtd, i, component) {
675 if (!component->driver->compress_ops ||
676 !component->driver->compress_ops->set_metadata)
679 ret = component->driver->compress_ops->set_metadata(
680 component, cstream, metadata);
688 static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
689 struct snd_compr_metadata *metadata)
691 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
692 struct snd_soc_component *component;
693 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
696 ret = snd_soc_dai_compr_get_metadata(cpu_dai, cstream, metadata);
700 for_each_rtd_components(rtd, i, component) {
701 if (!component->driver->compress_ops ||
702 !component->driver->compress_ops->get_metadata)
705 return component->driver->compress_ops->get_metadata(
706 component, cstream, metadata);
712 /* ASoC Compress operations */
713 static struct snd_compr_ops soc_compr_ops = {
714 .open = soc_compr_open,
715 .free = soc_compr_free,
716 .set_params = soc_compr_set_params,
717 .set_metadata = soc_compr_set_metadata,
718 .get_metadata = soc_compr_get_metadata,
719 .get_params = soc_compr_get_params,
720 .trigger = soc_compr_trigger,
721 .pointer = soc_compr_pointer,
722 .ack = soc_compr_ack,
723 .get_caps = soc_compr_get_caps,
724 .get_codec_caps = soc_compr_get_codec_caps
727 /* ASoC Dynamic Compress operations */
728 static struct snd_compr_ops soc_compr_dyn_ops = {
729 .open = soc_compr_open_fe,
730 .free = soc_compr_free_fe,
731 .set_params = soc_compr_set_params_fe,
732 .get_params = soc_compr_get_params,
733 .set_metadata = soc_compr_set_metadata,
734 .get_metadata = soc_compr_get_metadata,
735 .trigger = soc_compr_trigger_fe,
736 .pointer = soc_compr_pointer,
737 .ack = soc_compr_ack,
738 .get_caps = soc_compr_get_caps,
739 .get_codec_caps = soc_compr_get_codec_caps
743 * snd_soc_new_compress - create a new compress.
745 * @rtd: The runtime for which we will create compress
746 * @num: the device index number (zero based - shared with normal PCMs)
748 * Return: 0 for success, else error.
750 int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
752 struct snd_soc_component *component;
753 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
754 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
755 struct snd_compr *compr;
756 struct snd_pcm *be_pcm;
758 int ret = 0, direction = 0;
759 int playback = 0, capture = 0;
762 if (rtd->num_cpus > 1 ||
763 rtd->num_codecs > 1) {
764 dev_err(rtd->card->dev,
765 "Compress ASoC: Multi CPU/Codec not supported\n");
770 dev_err(rtd->card->dev, "Missing codec\n");
774 /* check client and interface hw capabilities */
775 if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
776 snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK))
778 if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
779 snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE))
783 * Compress devices are unidirectional so only one of the directions
784 * should be set, check for that (xor)
786 if (playback + capture != 1) {
787 dev_err(rtd->card->dev,
788 "Compress ASoC: Invalid direction for P %d, C %d\n",
794 direction = SND_COMPRESS_PLAYBACK;
796 direction = SND_COMPRESS_CAPTURE;
798 compr = devm_kzalloc(rtd->card->dev, sizeof(*compr), GFP_KERNEL);
802 compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops),
807 if (rtd->dai_link->dynamic) {
808 snprintf(new_name, sizeof(new_name), "(%s)",
809 rtd->dai_link->stream_name);
811 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
812 rtd->dai_link->dpcm_playback,
813 rtd->dai_link->dpcm_capture, &be_pcm);
815 dev_err(rtd->card->dev,
816 "Compress ASoC: can't create compressed for %s: %d\n",
817 rtd->dai_link->name, ret);
823 if (rtd->dai_link->dpcm_playback)
824 be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
825 if (rtd->dai_link->dpcm_capture)
826 be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
827 memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops));
829 snprintf(new_name, sizeof(new_name), "%s %s-%d",
830 rtd->dai_link->stream_name, codec_dai->name, num);
832 memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
835 for_each_rtd_components(rtd, i, component) {
836 if (!component->driver->compress_ops ||
837 !component->driver->compress_ops->copy)
840 compr->ops->copy = soc_compr_copy;
844 mutex_init(&compr->lock);
845 ret = snd_compress_new(rtd->card->snd_card, num, direction,
848 component = asoc_rtd_to_codec(rtd, 0)->component;
849 dev_err(component->dev,
850 "Compress ASoC: can't create compress for codec %s: %d\n",
851 component->name, ret);
855 /* DAPM dai link stream work */
856 rtd->close_delayed_work_func = snd_soc_close_delayed_work;
859 compr->private_data = rtd;
861 dev_dbg(rtd->card->dev, "Compress ASoC: %s <-> %s mapping ok\n",
862 codec_dai->name, cpu_dai->name);
866 EXPORT_SYMBOL_GPL(snd_soc_new_compress);