ASoC: rsnd: add .auto_selectable_formats support
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 27 May 2021 02:27:31 +0000 (11:27 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 7 Jun 2021 14:55:15 +0000 (15:55 +0100)
By this patch, DAI format might be automatically selected
(Depends on paired DAI).

Link: https://lore.kernel.org/r/871rb3hypy.wl-kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/871racbx0w.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87cztcnc6k.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/core.c

index a4ed9d8f022adff1f133c0448f0af53ab83394d4..5e382b5c9d45735e88d79b5557b83512e0847239 100644 (file)
@@ -756,10 +756,10 @@ static int rsnd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 
        /* set clock master for audio interface */
        switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-       case SND_SOC_DAIFMT_CBM_CFM:
+       case SND_SOC_DAIFMT_CBP_CFP:
                rdai->clk_master = 0;
                break;
-       case SND_SOC_DAIFMT_CBS_CFS:
+       case SND_SOC_DAIFMT_CBC_CFC:
                rdai->clk_master = 1; /* cpu is master */
                break;
        default:
@@ -1039,6 +1039,31 @@ static int rsnd_soc_dai_prepare(struct snd_pcm_substream *substream,
        return rsnd_dai_call(prepare, io, priv);
 }
 
+static u64 rsnd_soc_dai_formats[] = {
+       /*
+        * 1st Priority
+        *
+        * Well tested formats.
+        * Select below from Sound Card, not auto
+        *      SND_SOC_DAIFMT_CBC_CFC
+        *      SND_SOC_DAIFMT_CBP_CFP
+        */
+       SND_SOC_POSSIBLE_DAIFMT_I2S     |
+       SND_SOC_POSSIBLE_DAIFMT_RIGHT_J |
+       SND_SOC_POSSIBLE_DAIFMT_LEFT_J  |
+       SND_SOC_POSSIBLE_DAIFMT_NB_NF   |
+       SND_SOC_POSSIBLE_DAIFMT_NB_IF   |
+       SND_SOC_POSSIBLE_DAIFMT_IB_NF   |
+       SND_SOC_POSSIBLE_DAIFMT_IB_IF,
+       /*
+        * 2nd Priority
+        *
+        * Supported, but not well tested
+        */
+       SND_SOC_POSSIBLE_DAIFMT_DSP_A   |
+       SND_SOC_POSSIBLE_DAIFMT_DSP_B,
+};
+
 static const struct snd_soc_dai_ops rsnd_soc_dai_ops = {
        .startup        = rsnd_soc_dai_startup,
        .shutdown       = rsnd_soc_dai_shutdown,
@@ -1046,6 +1071,8 @@ static const struct snd_soc_dai_ops rsnd_soc_dai_ops = {
        .set_fmt        = rsnd_soc_dai_set_fmt,
        .set_tdm_slot   = rsnd_soc_set_dai_tdm_slot,
        .prepare        = rsnd_soc_dai_prepare,
+       .auto_selectable_formats        = rsnd_soc_dai_formats,
+       .num_auto_selectable_formats    = ARRAY_SIZE(rsnd_soc_dai_formats),
 };
 
 static void rsnd_parse_tdm_split_mode(struct rsnd_priv *priv,