MLK-10108-2: ASoC: imx-mqs: set tdm slot in hw_params() for sai master mode
authorZidan Wang <zidan.wang@freescale.com>
Thu, 2 Apr 2015 09:48:48 +0000 (17:48 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:48:09 +0000 (14:48 -0500)
Set tdm slot in hw_params() for sai master mode.

Signed-off-by: Zidan Wang <zidan.wang@freescale.com>
sound/soc/fsl/imx-mqs.c

index 7f52d31..155e76e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <sound/soc.h>
+#include <sound/pcm_params.h>
 
 #define SUPPORT_RATE_NUM    10
 
@@ -51,12 +52,27 @@ static int imx_mqs_startup(struct snd_pcm_substream *substream)
        return 0;
 }
 
+static int imx_mqs_hw_params(struct snd_pcm_substream *substream,
+                                    struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+       struct snd_soc_card *card = rtd->card;
+       int ret;
+
+       ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0, 2, params_width(params));
+       if (ret) {
+               dev_err(card->dev, "failed to set cpu dai tdm slot: %d\n", ret);
+               return ret;
+       }
+       return 0;
+}
+
 static struct snd_soc_ops imx_mqs_ops = {
        .startup = imx_mqs_startup,
+       .hw_params = imx_mqs_hw_params,
 };
 
-
-
 static struct snd_soc_dai_link imx_mqs_dai = {
        .name = "HiFi",
        .stream_name = "HiFi",