ASoC: mxs-sgtl5000: Use static DAI format setup
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 1 Jan 2015 16:16:15 +0000 (17:16 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 6 Jan 2015 17:34:27 +0000 (17:34 +0000)
Set the dai_fmt field in the dai_link struct instead of manually calling
snd_soc_dai_fmt(). This makes the code cleaner and shorter.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/mxs/mxs-sgtl5000.c

index 6f1916b71815f3d5e509e2abbee69d1ccfdc8df4..6e6fce6a14ba6dc1c2ab14d054df8f5b07b2caea 100644 (file)
@@ -36,7 +36,7 @@ static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        unsigned int rate = params_rate(params);
-       u32 dai_format, mclk;
+       u32 mclk;
        int ret;
 
        /* sgtl5000 does not support 512*rate when in 96000 fs */
@@ -65,26 +65,6 @@ static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream,
                return ret;
        }
 
-       /* set codec to slave mode */
-       dai_format = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
-                       SND_SOC_DAIFMT_CBS_CFS;
-
-       /* set codec DAI configuration */
-       ret = snd_soc_dai_set_fmt(codec_dai, dai_format);
-       if (ret) {
-               dev_err(codec_dai->dev, "Failed to set dai format to %08x\n",
-                       dai_format);
-               return ret;
-       }
-
-       /* set cpu DAI configuration */
-       ret = snd_soc_dai_set_fmt(cpu_dai, dai_format);
-       if (ret) {
-               dev_err(cpu_dai->dev, "Failed to set dai format to %08x\n",
-                       dai_format);
-               return ret;
-       }
-
        return 0;
 }
 
@@ -92,17 +72,22 @@ static struct snd_soc_ops mxs_sgtl5000_hifi_ops = {
        .hw_params = mxs_sgtl5000_hw_params,
 };
 
+#define MXS_SGTL5000_DAI_FMT (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | \
+       SND_SOC_DAIFMT_CBS_CFS)
+
 static struct snd_soc_dai_link mxs_sgtl5000_dai[] = {
        {
                .name           = "HiFi Tx",
                .stream_name    = "HiFi Playback",
                .codec_dai_name = "sgtl5000",
+               .dai_fmt        = MXS_SGTL5000_DAI_FMT,
                .ops            = &mxs_sgtl5000_hifi_ops,
                .playback_only  = true,
        }, {
                .name           = "HiFi Rx",
                .stream_name    = "HiFi Capture",
                .codec_dai_name = "sgtl5000",
+               .dai_fmt        = MXS_SGTL5000_DAI_FMT,
                .ops            = &mxs_sgtl5000_hifi_ops,
                .capture_only   = true,
        },