Lines Matching +full:fe +full:- +full:dai +full:- +full:link

1 // SPDX-License-Identifier: GPL-2.0+
3 // soc-compress.c -- ALSA SoC Compress
21 #include <sound/soc-dpcm.h>
22 #include <sound/soc-link.h>
26 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in snd_soc_compr_components_open()
47 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in snd_soc_compr_components_free()
59 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in soc_compr_clean()
62 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ in soc_compr_clean()
72 cpu_dai->rate = 0; in soc_compr_clean()
75 codec_dai->rate = 0; in soc_compr_clean()
100 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in soc_compr_open()
102 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ in soc_compr_open()
135 struct snd_soc_pcm_runtime *fe = cstream->private_data; in soc_compr_open_fe() local
136 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0); in soc_compr_open_fe()
139 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ in soc_compr_open_fe()
142 snd_soc_card_mutex_lock(fe->card); in soc_compr_open_fe()
144 ret = dpcm_path_get(fe, stream, &list); in soc_compr_open_fe()
148 snd_soc_dpcm_mutex_lock(fe); in soc_compr_open_fe()
150 /* calculate valid and active FE <-> BE dpcms */ in soc_compr_open_fe()
151 dpcm_process_paths(fe, stream, &list, 1); in soc_compr_open_fe()
153 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in soc_compr_open_fe()
155 ret = dpcm_be_dai_startup(fe, stream); in soc_compr_open_fe()
158 for_each_dpcm_be(fe, stream, dpcm) in soc_compr_open_fe()
159 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in soc_compr_open_fe()
161 dpcm_be_disconnect(fe, stream); in soc_compr_open_fe()
177 dpcm_clear_pending_state(fe, stream); in soc_compr_open_fe()
180 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN; in soc_compr_open_fe()
181 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in soc_compr_open_fe()
183 snd_soc_runtime_activate(fe, stream); in soc_compr_open_fe()
184 snd_soc_dpcm_mutex_unlock(fe); in soc_compr_open_fe()
186 snd_soc_card_mutex_unlock(fe->card); in soc_compr_open_fe()
196 snd_soc_dpcm_mutex_unlock(fe); in soc_compr_open_fe()
198 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in soc_compr_open_fe()
199 snd_soc_card_mutex_unlock(fe->card); in soc_compr_open_fe()
205 struct snd_soc_pcm_runtime *fe = cstream->private_data; in soc_compr_free_fe() local
206 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0); in soc_compr_free_fe()
208 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ in soc_compr_free_fe()
210 snd_soc_card_mutex_lock(fe->card); in soc_compr_free_fe()
212 snd_soc_dpcm_mutex_lock(fe); in soc_compr_free_fe()
213 snd_soc_runtime_deactivate(fe, stream); in soc_compr_free_fe()
215 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in soc_compr_free_fe()
217 dpcm_be_dai_hw_free(fe, stream); in soc_compr_free_fe()
219 dpcm_be_dai_shutdown(fe, stream); in soc_compr_free_fe()
221 /* mark FE's links ready to prune */ in soc_compr_free_fe()
222 for_each_dpcm_be(fe, stream, dpcm) in soc_compr_free_fe()
223 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; in soc_compr_free_fe()
225 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); in soc_compr_free_fe()
227 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; in soc_compr_free_fe()
228 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in soc_compr_free_fe()
230 dpcm_be_disconnect(fe, stream); in soc_compr_free_fe()
232 snd_soc_dpcm_mutex_unlock(fe); in soc_compr_free_fe()
240 snd_soc_card_mutex_unlock(fe->card); in soc_compr_free_fe()
246 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in soc_compr_trigger()
249 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ in soc_compr_trigger()
278 struct snd_soc_pcm_runtime *fe = cstream->private_data; in soc_compr_trigger_fe() local
279 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0); in soc_compr_trigger_fe()
280 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ in soc_compr_trigger_fe()
287 snd_soc_card_mutex_lock(fe->card); in soc_compr_trigger_fe()
297 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in soc_compr_trigger_fe()
299 ret = dpcm_be_dai_trigger(fe, stream, cmd); in soc_compr_trigger_fe()
305 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START; in soc_compr_trigger_fe()
309 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP; in soc_compr_trigger_fe()
312 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED; in soc_compr_trigger_fe()
317 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in soc_compr_trigger_fe()
318 snd_soc_card_mutex_unlock(fe->card); in soc_compr_trigger_fe()
325 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in soc_compr_set_params()
327 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ in soc_compr_set_params()
333 * First we call set_params for the CPU DAI, then the component in soc_compr_set_params()
354 rtd->pop_wait = 0; in soc_compr_set_params()
357 cancel_delayed_work_sync(&rtd->delayed_work); in soc_compr_set_params()
369 struct snd_soc_pcm_runtime *fe = cstream->private_data; in soc_compr_set_params_fe() local
371 fe->pcm->streams[cstream->direction].substream; in soc_compr_set_params_fe()
372 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0); in soc_compr_set_params_fe()
373 int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */ in soc_compr_set_params_fe()
376 snd_soc_card_mutex_lock(fe->card); in soc_compr_set_params_fe()
383 memset(&fe->dpcm[fe_substream->stream].hw_params, 0, in soc_compr_set_params_fe()
386 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in soc_compr_set_params_fe()
388 snd_soc_dpcm_mutex_lock(fe); in soc_compr_set_params_fe()
389 ret = dpcm_be_dai_hw_params(fe, stream); in soc_compr_set_params_fe()
390 snd_soc_dpcm_mutex_unlock(fe); in soc_compr_set_params_fe()
394 snd_soc_dpcm_mutex_lock(fe); in soc_compr_set_params_fe()
395 ret = dpcm_be_dai_prepare(fe, stream); in soc_compr_set_params_fe()
396 snd_soc_dpcm_mutex_unlock(fe); in soc_compr_set_params_fe()
411 snd_soc_dpcm_mutex_lock(fe); in soc_compr_set_params_fe()
412 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START); in soc_compr_set_params_fe()
413 snd_soc_dpcm_mutex_unlock(fe); in soc_compr_set_params_fe()
414 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; in soc_compr_set_params_fe()
417 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; in soc_compr_set_params_fe()
418 snd_soc_card_mutex_unlock(fe->card); in soc_compr_set_params_fe()
425 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in soc_compr_get_params()
443 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in soc_compr_ack()
462 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in soc_compr_pointer()
481 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in soc_compr_set_metadata()
495 struct snd_soc_pcm_runtime *rtd = cstream->private_data; in soc_compr_get_metadata()
537 * snd_soc_new_compress - create a new compress.
540 * @num: the device index number (zero based - shared with normal PCMs)
563 if (rtd->dai_link->num_cpus > 1 || in snd_soc_new_compress()
564 rtd->dai_link->num_codecs > 1) { in snd_soc_new_compress()
565 dev_err(rtd->card->dev, in snd_soc_new_compress()
567 return -EINVAL; in snd_soc_new_compress()
571 dev_err(rtd->card->dev, "Missing codec\n"); in snd_soc_new_compress()
572 return -EINVAL; in snd_soc_new_compress()
588 dev_err(rtd->card->dev, in snd_soc_new_compress()
591 return -EINVAL; in snd_soc_new_compress()
599 compr = devm_kzalloc(rtd->card->dev, sizeof(*compr), GFP_KERNEL); in snd_soc_new_compress()
601 return -ENOMEM; in snd_soc_new_compress()
603 compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops), in snd_soc_new_compress()
605 if (!compr->ops) in snd_soc_new_compress()
606 return -ENOMEM; in snd_soc_new_compress()
608 if (rtd->dai_link->dynamic) { in snd_soc_new_compress()
610 rtd->dai_link->stream_name); in snd_soc_new_compress()
612 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, in snd_soc_new_compress()
613 rtd->dai_link->dpcm_playback, in snd_soc_new_compress()
614 rtd->dai_link->dpcm_capture, &be_pcm); in snd_soc_new_compress()
616 dev_err(rtd->card->dev, in snd_soc_new_compress()
618 rtd->dai_link->name, ret); in snd_soc_new_compress()
622 /* inherit atomicity from DAI link */ in snd_soc_new_compress()
623 be_pcm->nonatomic = rtd->dai_link->nonatomic; in snd_soc_new_compress()
625 rtd->pcm = be_pcm; in snd_soc_new_compress()
626 rtd->fe_compr = 1; in snd_soc_new_compress()
627 if (rtd->dai_link->dpcm_playback) in snd_soc_new_compress()
628 be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd; in snd_soc_new_compress()
629 if (rtd->dai_link->dpcm_capture) in snd_soc_new_compress()
630 be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd; in snd_soc_new_compress()
631 memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops)); in snd_soc_new_compress()
633 snprintf(new_name, sizeof(new_name), "%s %s-%d", in snd_soc_new_compress()
634 rtd->dai_link->stream_name, codec_dai->name, num); in snd_soc_new_compress()
636 memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); in snd_soc_new_compress()
640 if (!component->driver->compress_ops || in snd_soc_new_compress()
641 !component->driver->compress_ops->copy) in snd_soc_new_compress()
644 compr->ops->copy = snd_soc_component_compr_copy; in snd_soc_new_compress()
648 ret = snd_compress_new(rtd->card->snd_card, num, direction, in snd_soc_new_compress()
651 component = snd_soc_rtd_to_codec(rtd, 0)->component; in snd_soc_new_compress()
652 dev_err(component->dev, in snd_soc_new_compress()
654 component->name, ret); in snd_soc_new_compress()
658 /* DAPM dai link stream work */ in snd_soc_new_compress()
659 rtd->close_delayed_work_func = snd_soc_close_delayed_work; in snd_soc_new_compress()
661 rtd->compr = compr; in snd_soc_new_compress()
662 compr->private_data = rtd; in snd_soc_new_compress()
664 dev_dbg(rtd->card->dev, "Compress ASoC: %s <-> %s mapping ok\n", in snd_soc_new_compress()
665 codec_dai->name, cpu_dai->name); in snd_soc_new_compress()