diff mbox

[5/7] ASoC: davinci-mcasp: Add support for I2S format

Message ID 1396611107-30765-6-git-send-email-peter.ujfalusi@ti.com (mailing list archive)
State Accepted
Commit ffd950f75dd71f13194b5d5c8ec67926a1996102
Headers show

Commit Message

Peter Ujfalusi April 4, 2014, 11:31 a.m. UTC
The FS needs to be inverted in McASP compared to other supported formats.
Use a flag to indicate if the FS needs to be inverted.
At the same time fail when non supported format is asked since the default
case was anyways configuring McASP to a not valid format.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/davinci/davinci-mcasp.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 3f67e374829e..af6cca3e61e4 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -266,6 +266,7 @@  static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 	int ret = 0;
 	u32 data_delay;
 	bool fs_pol_rising;
+	bool inv_fs = false;
 
 	pm_runtime_get_sync(mcasp->dev);
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
@@ -284,14 +285,19 @@  static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 		/* No delay after FS */
 		data_delay = 0;
 		break;
-	default:
+	case SND_SOC_DAIFMT_I2S:
 		/* configure a full-word SYNC pulse (LRCLK) */
 		mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
 		mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
 
 		/* 1st data bit occur one ACLK cycle after the frame sync */
 		data_delay = 1;
+		/* FS need to be inverted */
+		inv_fs = true;
 		break;
+	default:
+		ret = -EINVAL;
+		goto out;
 	}
 
 	mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, FSXDLY(data_delay),
@@ -372,6 +378,9 @@  static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
 		goto out;
 	}
 
+	if (inv_fs)
+		fs_pol_rising = !fs_pol_rising;
+
 	if (fs_pol_rising) {
 		mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
 		mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);