All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Pargmann <mpa@pengutronix.de>
To: Mark Brown <broonie@kernel.org>
Cc: Fabio Estevam <fabio.estevam@freescale.com>,
	alsa-devel@alsa-project.org, Timur Tabi <timur@tabi.org>,
	kernel@pengutronix.de, Nicolin Chen <Guangyu.Chen@freescale.com>,
	Markus Pargmann <mpa@pengutronix.de>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 13/15] ASoC: fsl-ssi: Set default dai-fmts
Date: Wed, 26 Feb 2014 17:02:16 +0100	[thread overview]
Message-ID: <1393430538-32333-14-git-send-email-mpa@pengutronix.de> (raw)
In-Reply-To: <1393430538-32333-1-git-send-email-mpa@pengutronix.de>

The old fsl_ssi_setup function was replaced by a set_dai_fmt function.
As the fsl-ssi driver has a 'fsl,mode' DT binding we should keep the
backward compatibility for the moment.

This patch sets default dai-fmt for backwards compatibility and
initializes the DAI using _fsl_ssi_set_dai_fmt().

The fsl,mode property parsing is moved, so it can directly set the
correct dai-fmt in ssi_private.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 sound/soc/fsl/fsl_ssi.c | 43 ++++++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 15 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index a524195..56dbd77 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -598,12 +598,9 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-/**
- * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format.
- */
-static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
+static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private,
+		unsigned int fmt)
 {
-	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
 	struct regmap *regs = ssi_private->regs;
 	u32 strcr = 0, stcr, srcr, scr, mask;
 	u8 wm;
@@ -746,6 +743,17 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
 		fsl_ssi_setup_ac97(ssi_private);
 
 	return 0;
+
+}
+
+/**
+ * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format.
+ */
+static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
+{
+	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
+
+	return _fsl_ssi_set_dai_fmt(ssi_private, fmt);
 }
 
 /**
@@ -1203,7 +1211,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 	struct resource res;
 	void __iomem *iomem;
 	char name[64];
-	bool ac97 = false;
 
 	/* SSIs that are not connected on the board should have a
 	 *      status = "disabled"
@@ -1217,14 +1224,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 		return -EINVAL;
 	hw_type = (enum fsl_ssi_type) of_id->data;
 
-	sprop = of_get_property(np, "fsl,mode", NULL);
-	if (!sprop) {
-		dev_err(&pdev->dev, "fsl,mode property is necessary\n");
-		return -EINVAL;
-	}
-	if (!strcmp(sprop, "ac97-slave"))
-		ac97 = true;
-
 	ssi_private = devm_kzalloc(&pdev->dev, sizeof(*ssi_private),
 			GFP_KERNEL);
 	if (!ssi_private) {
@@ -1232,11 +1231,22 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	sprop = of_get_property(np, "fsl,mode", NULL);
+	if (!sprop) {
+		dev_err(&pdev->dev, "fsl,mode property is necessary\n");
+		return -EINVAL;
+	}
+	if (!strcmp(sprop, "ac97-slave"))
+		ssi_private->dai_fmt = SND_SOC_DAIFMT_AC97;
+	else if (!strcmp(sprop, "i2s-slave"))
+		ssi_private->dai_fmt = SND_SOC_DAIFMT_I2S |
+			SND_SOC_DAIFMT_CBM_CFM;
+
 	ssi_private->use_dma = !of_property_read_bool(np,
 			"fsl,fiq-stream-filter");
 	ssi_private->hw_type = hw_type;
 
-	if (ac97) {
+	if (fsl_ssi_is_ac97(ssi_private)) {
 		memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai,
 				sizeof(fsl_ssi_ac97_dai));
 
@@ -1354,6 +1364,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 	}
 
 done:
+	if (ssi_private->dai_fmt)
+		_fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt);
+
 	return 0;
 
 error_sound_card:
-- 
1.8.5.3

WARNING: multiple messages have this Message-ID
From: mpa@pengutronix.de (Markus Pargmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 13/15] ASoC: fsl-ssi: Set default dai-fmts
Date: Wed, 26 Feb 2014 17:02:16 +0100	[thread overview]
Message-ID: <1393430538-32333-14-git-send-email-mpa@pengutronix.de> (raw)
In-Reply-To: <1393430538-32333-1-git-send-email-mpa@pengutronix.de>

The old fsl_ssi_setup function was replaced by a set_dai_fmt function.
As the fsl-ssi driver has a 'fsl,mode' DT binding we should keep the
backward compatibility for the moment.

This patch sets default dai-fmt for backwards compatibility and
initializes the DAI using _fsl_ssi_set_dai_fmt().

The fsl,mode property parsing is moved, so it can directly set the
correct dai-fmt in ssi_private.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 sound/soc/fsl/fsl_ssi.c | 43 ++++++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 15 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index a524195..56dbd77 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -598,12 +598,9 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-/**
- * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format.
- */
-static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
+static int _fsl_ssi_set_dai_fmt(struct fsl_ssi_private *ssi_private,
+		unsigned int fmt)
 {
-	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
 	struct regmap *regs = ssi_private->regs;
 	u32 strcr = 0, stcr, srcr, scr, mask;
 	u8 wm;
@@ -746,6 +743,17 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
 		fsl_ssi_setup_ac97(ssi_private);
 
 	return 0;
+
+}
+
+/**
+ * fsl_ssi_set_dai_fmt - configure Digital Audio Interface Format.
+ */
+static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
+{
+	struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
+
+	return _fsl_ssi_set_dai_fmt(ssi_private, fmt);
 }
 
 /**
@@ -1203,7 +1211,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 	struct resource res;
 	void __iomem *iomem;
 	char name[64];
-	bool ac97 = false;
 
 	/* SSIs that are not connected on the board should have a
 	 *      status = "disabled"
@@ -1217,14 +1224,6 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 		return -EINVAL;
 	hw_type = (enum fsl_ssi_type) of_id->data;
 
-	sprop = of_get_property(np, "fsl,mode", NULL);
-	if (!sprop) {
-		dev_err(&pdev->dev, "fsl,mode property is necessary\n");
-		return -EINVAL;
-	}
-	if (!strcmp(sprop, "ac97-slave"))
-		ac97 = true;
-
 	ssi_private = devm_kzalloc(&pdev->dev, sizeof(*ssi_private),
 			GFP_KERNEL);
 	if (!ssi_private) {
@@ -1232,11 +1231,22 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	sprop = of_get_property(np, "fsl,mode", NULL);
+	if (!sprop) {
+		dev_err(&pdev->dev, "fsl,mode property is necessary\n");
+		return -EINVAL;
+	}
+	if (!strcmp(sprop, "ac97-slave"))
+		ssi_private->dai_fmt = SND_SOC_DAIFMT_AC97;
+	else if (!strcmp(sprop, "i2s-slave"))
+		ssi_private->dai_fmt = SND_SOC_DAIFMT_I2S |
+			SND_SOC_DAIFMT_CBM_CFM;
+
 	ssi_private->use_dma = !of_property_read_bool(np,
 			"fsl,fiq-stream-filter");
 	ssi_private->hw_type = hw_type;
 
-	if (ac97) {
+	if (fsl_ssi_is_ac97(ssi_private)) {
 		memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai,
 				sizeof(fsl_ssi_ac97_dai));
 
@@ -1354,6 +1364,9 @@ static int fsl_ssi_probe(struct platform_device *pdev)
 	}
 
 done:
+	if (ssi_private->dai_fmt)
+		_fsl_ssi_set_dai_fmt(ssi_private, ssi_private->dai_fmt);
+
 	return 0;
 
 error_sound_card:
-- 
1.8.5.3

  parent reply	other threads:[~2014-02-26 16:02 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26 16:02 [PATCH 00/15] ASoC: fsl-ssi: Driver cleanup Markus Pargmann
2014-02-26 16:02 ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 01/15] ASoC: fsl-ssi: Use regmap Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-27  2:08   ` Li.Xiubo
2014-02-27  2:08     ` Li.Xiubo at freescale.com
2014-02-27 15:23     ` Markus Pargmann
2014-02-27 15:23       ` Markus Pargmann
2014-02-27 16:06       ` Timur Tabi
2014-02-27 16:06         ` Timur Tabi
2014-03-05  6:21     ` Mark Brown
2014-03-05  6:21       ` Mark Brown
2014-03-05  7:04       ` Li.Xiubo
2014-03-05  7:04         ` Li.Xiubo at freescale.com
2014-03-05  7:07       ` Li.Xiubo
2014-03-05  7:07         ` Li.Xiubo at freescale.com
2014-02-26 16:02 ` [PATCH 02/15] ASoC: fsl-ssi: Remove fsl_ssi_setup Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 03/15] ASoC: fsl-ssi: Move debugging to seperate file Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 04/15] ASoC: fsl-ssi: Use dev_name for DAI driver struct Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 05/15] ASoC: fsl-ssi: Move imx-specific probe to seperate function Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 06/15] ASoC: fsl-ssi: Remove useless DMA code Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 07/15] ASoC: fsl-ssi: baud clock error handling Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 08/15] ASoC: fsl-ssi: Cleanup probe function Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 09/15] ASoC: fsl-ssi: Remove unnecessary variables from ssi_private Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 10/15] ASoC: fsl-ssi: reorder and document fsl_ssi_private Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 11/15] ASoC: fsl-ssi: Fix register values when disabling Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 12/15] ASoC: fsl-ssi: Only enable baudclk when used Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` Markus Pargmann [this message]
2014-02-26 16:02   ` [PATCH 13/15] ASoC: fsl-ssi: Set default dai-fmts Markus Pargmann
2014-02-26 16:02 ` [PATCH 14/15] ASoC: fsl-ssi: Transmit enable synchronization Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann
2014-02-26 16:02 ` [PATCH 15/15] ASoC: fsl-ssi: Update binding documentation Markus Pargmann
2014-02-26 16:02   ` Markus Pargmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393430538-32333-14-git-send-email-mpa@pengutronix.de \
    --to=mpa@pengutronix.de \
    --cc=Guangyu.Chen@freescale.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=fabio.estevam@freescale.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=timur@tabi.org \
    --subject='Re: [PATCH 13/15] ASoC: fsl-ssi: Set default dai-fmts' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.