v5.6: codec2codec DAI links

commit 95cfc0a0aaf575207152dd7601e782702565a6f1
Author: Samuel Holland <samuel@sholland.org>
Date:   Wed Mar 4 23:11:43 2020 -0600

    ASoC: simple-card: Add support for codec2codec DAI links

    Following the example in cb2cf0de1174 ("ASoC: soc-core: care Codec <->
    Codec case by non_legacy_dai_naming"), determine if a DAI link contains
    only codec DAIs by examining the non_legacy_dai_naming flag in each
    DAI's component.

    For now, we assume there is only one or a small set of valid PCM stream
    parameters, so num_params == 1 is good enough. We also assume that the
    same params are valid for all supported streams. params is set to the
    subset of parameters common among all DAIs, and then the existing code
    automatically chooses the highest quality of the remaining values when
    the link is brought up.
This commit is contained in:
Hin-Tak Leung 2021-04-13 02:50:59 +01:00
parent d692927067
commit 47d09dba0e

View file

@ -335,6 +335,50 @@ static int asoc_simple_init_dai(struct snd_soc_dai *dai,
return 0; return 0;
} }
static int asoc_simple_init_dai_link_params(struct snd_soc_pcm_runtime *rtd,
struct simple_dai_props *dai_props)
{
struct snd_soc_dai_link *dai_link = rtd->dai_link;
struct snd_soc_component *component;
struct snd_soc_pcm_stream *params;
struct snd_pcm_hardware hw;
int i, ret, stream;
/* Only codecs should have non_legacy_dai_naming set. */
for_each_rtd_components(rtd, i, component) {
if (!component->driver->non_legacy_dai_naming)
return 0;
}
/* Assumes the capabilities are the same for all supported streams */
for (stream = 0; stream < 2; stream++) {
ret = snd_soc_runtime_calc_hw(rtd, &hw, stream);
if (ret == 0)
break;
}
if (ret < 0) {
dev_err(rtd->dev, "simple-card: no valid dai_link params\n");
return ret;
}
params = devm_kzalloc(rtd->dev, sizeof(*params), GFP_KERNEL);
if (!params)
return -ENOMEM;
params->formats = hw.formats;
params->rates = hw.rates;
params->rate_min = hw.rate_min;
params->rate_max = hw.rate_max;
params->channels_min = hw.channels_min;
params->channels_max = hw.channels_max;
dai_link->params = params;
dai_link->num_params = 1;
return 0;
}
static int seeed_voice_card_dai_init(struct snd_soc_pcm_runtime *rtd) static int seeed_voice_card_dai_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct seeed_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct seeed_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
@ -352,6 +396,10 @@ static int seeed_voice_card_dai_init(struct snd_soc_pcm_runtime *rtd)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = asoc_simple_init_dai_link_params(rtd, dai_props);
if (ret < 0)
return ret;
return 0; return 0;
} }