Lines Matching +full:is +full:- +full:compress +full:- +full:dai

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->symmetric_rate = 0; in soc_compr_clean()
75 codec_dai->symmetric_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()
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()
150 /* calculate valid and active FE <-> BE dpcms */ in soc_compr_open_fe()
153 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in soc_compr_open_fe()
159 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; 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()
186 snd_soc_card_mutex_unlock(fe->card); 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()
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()
215 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; in soc_compr_free_fe()
223 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; 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()
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()
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()
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()
335 * compressed ops then we call that as well. The expectation is in soc_compr_set_params()
336 * that these callbacks will configure everything for this compress in soc_compr_set_params()
353 /* cancel any delayed stream shutdown that is pending */ 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()
371 fe->pcm->streams[cstream->direction].substream; 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()
381 * I.e. machine driver fixup for compressed BE is mandatory. 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()
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()
506 /* ASoC Compress operations */
521 /* ASoC Dynamic Compress operations */
537 * snd_soc_new_compress - create a new compress.
539 * @rtd: The runtime for which we will create compress
562 if (rtd->dai_link->num_cpus > 1 || in snd_soc_new_compress()
563 rtd->dai_link->num_codecs > 1) { in snd_soc_new_compress()
564 dev_err(rtd->card->dev, in snd_soc_new_compress()
565 "Compress ASoC: Multi CPU/Codec not supported\n"); in snd_soc_new_compress()
566 return -EINVAL; in snd_soc_new_compress()
570 dev_err(rtd->card->dev, "Missing codec\n"); in snd_soc_new_compress()
571 return -EINVAL; in snd_soc_new_compress()
583 * Compress devices are unidirectional so only one of the directions in snd_soc_new_compress()
587 dev_err(rtd->card->dev, in snd_soc_new_compress()
588 "Compress ASoC: Invalid direction for P %d, C %d\n", in snd_soc_new_compress()
590 return -EINVAL; in snd_soc_new_compress()
598 compr = devm_kzalloc(rtd->card->dev, sizeof(*compr), GFP_KERNEL); in snd_soc_new_compress()
600 return -ENOMEM; in snd_soc_new_compress()
602 compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops), in snd_soc_new_compress()
604 if (!compr->ops) in snd_soc_new_compress()
605 return -ENOMEM; in snd_soc_new_compress()
607 if (rtd->dai_link->dynamic) { in snd_soc_new_compress()
611 if (rtd->dai_link->capture_only) in snd_soc_new_compress()
613 if (rtd->dai_link->playback_only) in snd_soc_new_compress()
617 rtd->dai_link->stream_name); in snd_soc_new_compress()
619 ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, rtd->id, in snd_soc_new_compress()
622 dev_err(rtd->card->dev, in snd_soc_new_compress()
623 "Compress ASoC: can't create compressed for %s: %d\n", in snd_soc_new_compress()
624 rtd->dai_link->name, ret); in snd_soc_new_compress()
628 /* inherit atomicity from DAI link */ in snd_soc_new_compress()
629 be_pcm->nonatomic = rtd->dai_link->nonatomic; in snd_soc_new_compress()
631 rtd->pcm = be_pcm; in snd_soc_new_compress()
632 rtd->fe_compr = 1; in snd_soc_new_compress()
634 be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd; in snd_soc_new_compress()
636 be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd; in snd_soc_new_compress()
637 memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops)); in snd_soc_new_compress()
639 snprintf(new_name, sizeof(new_name), "%s %s-%d", in snd_soc_new_compress()
640 rtd->dai_link->stream_name, codec_dai->name, rtd->id); in snd_soc_new_compress()
642 memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); in snd_soc_new_compress()
646 if (!component->driver->compress_ops || in snd_soc_new_compress()
647 !component->driver->compress_ops->copy) in snd_soc_new_compress()
650 compr->ops->copy = snd_soc_component_compr_copy; in snd_soc_new_compress()
654 ret = snd_compress_new(rtd->card->snd_card, rtd->id, direction, in snd_soc_new_compress()
657 component = snd_soc_rtd_to_codec(rtd, 0)->component; in snd_soc_new_compress()
658 dev_err(component->dev, in snd_soc_new_compress()
659 "Compress ASoC: can't create compress for codec %s: %d\n", in snd_soc_new_compress()
660 component->name, ret); in snd_soc_new_compress()
664 /* DAPM dai link stream work */ in snd_soc_new_compress()
665 rtd->close_delayed_work_func = snd_soc_close_delayed_work; in snd_soc_new_compress()
667 rtd->compr = compr; in snd_soc_new_compress()
668 compr->private_data = rtd; in snd_soc_new_compress()
670 dev_dbg(rtd->card->dev, "Compress ASoC: %s <-> %s mapping ok\n", in snd_soc_new_compress()
671 codec_dai->name, cpu_dai->name); in snd_soc_new_compress()