Skip to content

Commit

Permalink
ASoC: soc-core: add snd_soc_daifmt_clock_provider_fliped()
Browse files Browse the repository at this point in the history
Sometimes we want to get CLOCK_PROVIDER fliped dai_fmt.
This patch adds new snd_soc_daifmt_clock_provider_fliped() for it.

Signed-off-by: Kuninori Morimoto <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
morimoto authored and broonie committed Jun 21, 2021
1 parent 91ae447 commit b44a67f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
2 changes: 2 additions & 0 deletions include/sound/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,8 @@ void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
const char *propname);
int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);

unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt);
unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
const char *prefix,
Expand Down
40 changes: 25 additions & 15 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,21 +1249,8 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
* 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;
}
inv_dai_fmt = snd_soc_daifmt_clock_provider_fliped(dai_fmt);

for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
unsigned int fmt = dai_fmt;

Expand Down Expand Up @@ -3017,6 +3004,29 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname)
}
EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs);

unsigned int snd_soc_daifmt_clock_provider_fliped(unsigned int dai_fmt)
{
unsigned int inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK;

switch (dai_fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
case SND_SOC_DAIFMT_CBP_CFP:
inv_dai_fmt |= SND_SOC_DAIFMT_CBC_CFC;
break;
case SND_SOC_DAIFMT_CBP_CFC:
inv_dai_fmt |= SND_SOC_DAIFMT_CBC_CFP;
break;
case SND_SOC_DAIFMT_CBC_CFP:
inv_dai_fmt |= SND_SOC_DAIFMT_CBP_CFC;
break;
case SND_SOC_DAIFMT_CBC_CFC:
inv_dai_fmt |= SND_SOC_DAIFMT_CBP_CFP;
break;
}

return inv_dai_fmt;
}
EXPORT_SYMBOL_GPL(snd_soc_daifmt_clock_provider_fliped);

unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame)
{
/* Codec base */
Expand Down

0 comments on commit b44a67f

Please sign in to comment.