mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
ASoC: soc-core: move snd_soc_runtime_set_dai_fmt() to upside
This patch moves snd_soc_runtime_set_dai_fmt() to upside. This is prepare to support snd_soc_runtime_get_dai_fmt(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87im34nc9r.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
ffb2df66ba
commit
4d1a98b5f1
@ -1054,6 +1054,68 @@ _err_defer:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime);
|
||||
|
||||
/**
|
||||
* snd_soc_runtime_set_dai_fmt() - Change DAI link format for a ASoC runtime
|
||||
* @rtd: The runtime for which the DAI link format should be changed
|
||||
* @dai_fmt: The new DAI link format
|
||||
*
|
||||
* This function updates the DAI link format for all DAIs connected to the DAI
|
||||
* link for the specified runtime.
|
||||
*
|
||||
* Note: For setups with a static format set the dai_fmt field in the
|
||||
* corresponding snd_dai_link struct instead of using this function.
|
||||
*
|
||||
* Returns 0 on success, otherwise a negative error code.
|
||||
*/
|
||||
int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
|
||||
unsigned int dai_fmt)
|
||||
{
|
||||
struct snd_soc_dai *cpu_dai;
|
||||
struct snd_soc_dai *codec_dai;
|
||||
unsigned int inv_dai_fmt;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
||||
ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
|
||||
if (ret != 0 && ret != -ENOTSUPP)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flip the polarity for the "CPU" end of a CODEC<->CODEC link
|
||||
* the component which has non_legacy_dai_naming is Codec
|
||||
*/
|
||||
inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_MASTER_MASK;
|
||||
switch (dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
case SND_SOC_DAIFMT_CBM_CFM:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBM_CFS:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFM:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFS:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
|
||||
break;
|
||||
}
|
||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||
unsigned int fmt = dai_fmt;
|
||||
|
||||
if (cpu_dai->component->driver->non_legacy_dai_naming)
|
||||
fmt = inv_dai_fmt;
|
||||
|
||||
ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
|
||||
if (ret != 0 && ret != -ENOTSUPP)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
|
||||
|
||||
static int soc_init_pcm_runtime(struct snd_soc_card *card,
|
||||
struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
@ -1402,68 +1464,6 @@ static void soc_remove_aux_devices(struct snd_soc_card *card)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* snd_soc_runtime_set_dai_fmt() - Change DAI link format for a ASoC runtime
|
||||
* @rtd: The runtime for which the DAI link format should be changed
|
||||
* @dai_fmt: The new DAI link format
|
||||
*
|
||||
* This function updates the DAI link format for all DAIs connected to the DAI
|
||||
* link for the specified runtime.
|
||||
*
|
||||
* Note: For setups with a static format set the dai_fmt field in the
|
||||
* corresponding snd_dai_link struct instead of using this function.
|
||||
*
|
||||
* Returns 0 on success, otherwise a negative error code.
|
||||
*/
|
||||
int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
|
||||
unsigned int dai_fmt)
|
||||
{
|
||||
struct snd_soc_dai *cpu_dai;
|
||||
struct snd_soc_dai *codec_dai;
|
||||
unsigned int inv_dai_fmt;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
||||
ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
|
||||
if (ret != 0 && ret != -ENOTSUPP)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flip the polarity for the "CPU" end of a CODEC<->CODEC link
|
||||
* the component which has non_legacy_dai_naming is Codec
|
||||
*/
|
||||
inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_MASTER_MASK;
|
||||
switch (dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
case SND_SOC_DAIFMT_CBM_CFM:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBM_CFS:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFM:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
|
||||
break;
|
||||
case SND_SOC_DAIFMT_CBS_CFS:
|
||||
inv_dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
|
||||
break;
|
||||
}
|
||||
for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
|
||||
unsigned int fmt = dai_fmt;
|
||||
|
||||
if (cpu_dai->component->driver->non_legacy_dai_naming)
|
||||
fmt = inv_dai_fmt;
|
||||
|
||||
ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
|
||||
if (ret != 0 && ret != -ENOTSUPP)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_runtime_set_dai_fmt);
|
||||
|
||||
#ifdef CONFIG_DMI
|
||||
/*
|
||||
* If a DMI filed contain strings in this blacklist (e.g.
|
||||
|
Loading…
Reference in New Issue
Block a user