ASoC: Intel: bytcr_rt5640: set SSP to I2S mode 2ch
authorSebastien Guiriec <sebastien.guiriec@intel.com>
Fri, 18 Dec 2015 02:35:39 +0000 (20:35 -0600)
committerMark Brown <broonie@kernel.org>
Sat, 19 Dec 2015 11:49:56 +0000 (11:49 +0000)
Using the hw_fixup function in order to overwrite the default SSP
setting for Audio DSP port connected to the codec. Instead of
TDM 4ch use I2S 2ch 24 bits.

Signed-off-by: Sebastien Guiriec <sebastien.guiriec@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/boards/bytcr_rt5640.c

index 7a5c9a3..66d37b0 100644 (file)
@@ -107,6 +107,7 @@ static int byt_codec_fixup(struct snd_soc_pcm_runtime *rtd,
                        SNDRV_PCM_HW_PARAM_RATE);
        struct snd_interval *channels = hw_param_interval(params,
                                                SNDRV_PCM_HW_PARAM_CHANNELS);
+       int ret;
 
        /* The DSP will covert the FE rate to 48k, stereo, 24bits */
        rate->min = rate->max = 48000;
@@ -114,6 +115,28 @@ static int byt_codec_fixup(struct snd_soc_pcm_runtime *rtd,
 
        /* set SSP2 to 24-bit */
        params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
+
+       /*
+        * Default mode for SSP configuration is TDM 4 slot, override config
+        * with explicit setting to I2S 2ch 24-bit. The word length is set with
+        * dai_set_tdm_slot() since there is no other API exposed
+        */
+       ret = snd_soc_dai_set_fmt(rtd->cpu_dai,
+                                 SND_SOC_DAIFMT_I2S     |
+                                 SND_SOC_DAIFMT_NB_IF   |
+                                 SND_SOC_DAIFMT_CBS_CFS
+                                 );
+       if (ret < 0) {
+               dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
+               return ret;
+       }
+
+       ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24);
+       if (ret < 0) {
+               dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
+               return ret;
+       }
+
        return 0;
 }