alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/21] ASoC: Use static DAI format setup
@ 2015-01-01 16:16 Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 01/21] ASoC: sam9g20_wm8731: " Lars-Peter Clausen
                   ` (21 more replies)
  0 siblings, 22 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

There is still a rather large amount of board driver which manually call
snd_soc_dai_set_fmt() for both the CPU and the CODEC DAI, while pretty much
all of them can use static DAI setup by setting the dai_fmt field in the
snd_soc_dai_link struct.

Using the later method results in shorter and cleaner code and will also
make it easier to eventually switch to a component type independent way to
specify the clock master/slave settings (Right now the meaning of the value
depends on whether a DAI belongs to a CODEC or not).

This series converts all the trivial cases of snd_soc_dai_set_fmt() users to
use the dai_fmt field instead.

- Lars

Lars-Peter Clausen (21):
  ASoC: sam9g20_wm8731: Use static DAI format setup
  ASoC: db1200: Use static DAI format setup
  ASoC: eureka-tlv320: Use static DAI format setup
  ASoC: mx27vis-aci32x4: Use static DAI format setup
  ASoC: wm1133-ev1: Use static DAI format setup
  ASoC: mxs-sgtl5000: Use static DAI format setup
  ASoC: ams-delta: Use static DAI format setup
  ASoC: raumfeld: Use static DAI format setup
  ASoC: zylonite: Use static DAI format setup
  ASoC: goni_wm8994: Use static DAI format setup
  ASoC: h1940_uda1380: Use static DAI format setup
  ASoC: jive_wm8750: Use static DAI format setup
  ASoC: neo1973_wm8753: Use static DAI format setup
  ASoC: rx1950_uda1380: Use static DAI format setup
  ASoC: s3c24xx_simtec: Use static DAI format setup
  ASoC: s3c24xx_uda134x: Use static DAI format setup
  ASoC: smartq_wm8987: Use static DAI format setup
  ASoC: smdk_wm8580: Use static DAI format setup
  ASoC: smdk_wm8570pcm: Use static DAI format setup
  ASoC: smdk_wm8994pcm: Use static DAI format setup
  ASoC: migor: Use static DAI format setup

 sound/soc/atmel/sam9g20_wm8731.c    | 30 ++----------------------------
 sound/soc/au1x/db1200.c             | 19 +++----------------
 sound/soc/fsl/eukrea-tlv320.c       | 21 ++-------------------
 sound/soc/fsl/mx27vis-aic32x4.c     | 12 ++----------
 sound/soc/fsl/wm1133-ev1.c          | 12 ++----------
 sound/soc/mxs/mxs-sgtl5000.c        | 27 ++++++---------------------
 sound/soc/omap/ams-delta.c          | 18 +++---------------
 sound/soc/pxa/raumfeld.c            | 35 ++++++++---------------------------
 sound/soc/pxa/zylonite.c            | 12 ++----------
 sound/soc/samsung/goni_wm8994.c     | 23 ++++-------------------
 sound/soc/samsung/h1940_uda1380.c   | 15 ++-------------
 sound/soc/samsung/jive_wm8750.c     | 16 ++--------------
 sound/soc/samsung/neo1973_wm8753.c  | 25 ++++---------------------
 sound/soc/samsung/rx1950_uda1380.c  | 15 ++-------------
 sound/soc/samsung/s3c24xx_simtec.c  | 20 ++------------------
 sound/soc/samsung/s3c24xx_uda134x.c | 12 ++----------
 sound/soc/samsung/smartq_wm8987.c   | 16 ++--------------
 sound/soc/samsung/smdk_wm8580.c     | 21 ++++++---------------
 sound/soc/samsung/smdk_wm8580pcm.c  | 19 +++++--------------
 sound/soc/samsung/smdk_wm8994pcm.c  | 16 ++--------------
 sound/soc/sh/migor.c                | 12 ++----------
 21 files changed, 65 insertions(+), 331 deletions(-)

-- 
1.8.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 01/21] ASoC: sam9g20_wm8731: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-04  1:11   ` Bo Shen
  2015-01-01 16:16 ` [PATCH 02/21] ASoC: db1200: " Lars-Peter Clausen
                   ` (20 subsequent siblings)
  21 siblings, 1 reply; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/atmel/sam9g20_wm8731.c | 30 ++----------------------------
 1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
index 66b66d0..98ca634 100644
--- a/sound/soc/atmel/sam9g20_wm8731.c
+++ b/sound/soc/atmel/sam9g20_wm8731.c
@@ -64,33 +64,6 @@
 
 static struct clk *mclk;
 
-static int at91sam9g20ek_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 *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret;
-
-	/* set codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		return ret;
-
-	/* set cpu DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		return ret;
-
-	return 0;
-}
-
-static struct snd_soc_ops at91sam9g20ek_ops = {
-	.hw_params = at91sam9g20ek_hw_params,
-};
-
 static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card,
 					struct snd_soc_dapm_context *dapm,
 					enum snd_soc_bias_level level)
@@ -173,7 +146,8 @@ static struct snd_soc_dai_link at91sam9g20ek_dai = {
 	.init = at91sam9g20ek_wm8731_init,
 	.platform_name = "at91rm9200_ssc.0",
 	.codec_name = "wm8731.0-001b",
-	.ops = &at91sam9g20ek_ops,
+	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+		   SND_SOC_DAIFMT_CBM_CFM,
 };
 
 static struct snd_soc_card snd_soc_at91sam9g20ek = {
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 02/21] ASoC: db1200: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 01/21] ASoC: sam9g20_wm8731: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 03/21] ASoC: eureka-tlv320: " Lars-Peter Clausen
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/au1x/db1200.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/sound/soc/au1x/db1200.c b/sound/soc/au1x/db1200.c
index a747ac0..c75995f 100644
--- a/sound/soc/au1x/db1200.c
+++ b/sound/soc/au1x/db1200.c
@@ -91,27 +91,12 @@ static int db1200_i2s_startup(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int ret;
 
 	/* WM8731 has its own 12MHz crystal */
 	snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
 				12000000, SND_SOC_CLOCK_IN);
 
-	/* codec is bitclock and lrclk master */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
-			SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		goto out;
-
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J |
-			SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		goto out;
-
-	ret = 0;
-out:
-	return ret;
+	return 0;
 }
 
 static struct snd_soc_ops db1200_i2s_wm8731_ops = {
@@ -125,6 +110,8 @@ static struct snd_soc_dai_link db1200_i2s_dai = {
 	.cpu_dai_name	= "au1xpsc_i2s.1",
 	.platform_name	= "au1xpsc-pcm.1",
 	.codec_name	= "wm8731.0-001b",
+	.dai_fmt	= SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_NB_NF |
+			  SND_SOC_DAIFMT_CBM_CFM,
 	.ops		= &db1200_i2s_wm8731_ops,
 };
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 03/21] ASoC: eureka-tlv320: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 01/21] ASoC: sam9g20_wm8731: " Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 02/21] ASoC: db1200: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 04/21] ASoC: mx27vis-aci32x4: " Lars-Peter Clausen
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/fsl/eukrea-tlv320.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/sound/soc/fsl/eukrea-tlv320.c b/sound/soc/fsl/eukrea-tlv320.c
index 9ce70fc..8c9e900 100644
--- a/sound/soc/fsl/eukrea-tlv320.c
+++ b/sound/soc/fsl/eukrea-tlv320.c
@@ -42,25 +42,6 @@ static int eukrea_tlv320_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret;
 
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-				  SND_SOC_DAIFMT_NB_NF |
-				  SND_SOC_DAIFMT_CBM_CFM);
-	/* fsl_ssi lacks the set_fmt ops. */
-	if (ret && ret != -ENOTSUPP) {
-		dev_err(cpu_dai->dev,
-			"Failed to set the cpu dai format.\n");
-		return ret;
-	}
-
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-				  SND_SOC_DAIFMT_NB_NF |
-				  SND_SOC_DAIFMT_CBM_CFM);
-	if (ret) {
-		dev_err(cpu_dai->dev,
-			"Failed to set the codec format.\n");
-		return ret;
-	}
-
 	ret = snd_soc_dai_set_sysclk(codec_dai, 0,
 				     CODEC_CLOCK, SND_SOC_CLOCK_OUT);
 	if (ret) {
@@ -91,6 +72,8 @@ static struct snd_soc_dai_link eukrea_tlv320_dai = {
 	.name		= "tlv320aic23",
 	.stream_name	= "TLV320AIC23",
 	.codec_dai_name	= "tlv320aic23-hifi",
+	.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+			  SND_SOC_DAIFMT_CBM_CFM,
 	.ops		= &eukrea_tlv320_snd_ops,
 };
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 04/21] ASoC: mx27vis-aci32x4: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (2 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 03/21] ASoC: eureka-tlv320: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 05/21] ASoC: wm1133-ev1: " Lars-Peter Clausen
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/fsl/mx27vis-aic32x4.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/sound/soc/fsl/mx27vis-aic32x4.c b/sound/soc/fsl/mx27vis-aic32x4.c
index b1ced7b..198eeb3 100644
--- a/sound/soc/fsl/mx27vis-aic32x4.c
+++ b/sound/soc/fsl/mx27vis-aic32x4.c
@@ -55,16 +55,6 @@ static int mx27vis_aic32x4_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;
 	int ret;
-	u32 dai_format;
-
-	dai_format = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF |
-		SND_SOC_DAIFMT_CBM_CFM;
-
-	/* set codec DAI configuration */
-	snd_soc_dai_set_fmt(codec_dai, dai_format);
-
-	/* set cpu DAI configuration */
-	snd_soc_dai_set_fmt(cpu_dai, dai_format);
 
 	ret = snd_soc_dai_set_sysclk(codec_dai, 0,
 				     25000000, SND_SOC_CLOCK_OUT);
@@ -164,6 +154,8 @@ static struct snd_soc_dai_link mx27vis_aic32x4_dai = {
 	.platform_name	= "imx-ssi.0",
 	.codec_name	= "tlv320aic32x4.0-0018",
 	.cpu_dai_name	= "imx-ssi.0",
+	.dai_fmt	= SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF |
+			  SND_SOC_DAIFMT_CBM_CFM,
 	.ops		= &mx27vis_aic32x4_snd_ops,
 };
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 05/21] ASoC: wm1133-ev1: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (3 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 04/21] ASoC: mx27vis-aci32x4: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 06/21] ASoC: mxs-sgtl5000: " Lars-Peter Clausen
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/fsl/wm1133-ev1.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/sound/soc/fsl/wm1133-ev1.c b/sound/soc/fsl/wm1133-ev1.c
index 804749a..d072bd1 100644
--- a/sound/soc/fsl/wm1133-ev1.c
+++ b/sound/soc/fsl/wm1133-ev1.c
@@ -87,7 +87,6 @@ static int wm1133_ev1_hw_params(struct snd_pcm_substream *substream,
 	snd_pcm_format_t format = params_format(params);
 	unsigned int rate = params_rate(params);
 	unsigned int channels = params_channels(params);
-	u32 dai_format;
 
 	/* find the correct audio parameters */
 	for (i = 0; i < ARRAY_SIZE(wm8350_audio); i++) {
@@ -104,15 +103,6 @@ static int wm1133_ev1_hw_params(struct snd_pcm_substream *substream,
 	/* codec FLL input is 14.75 MHz from MCLK */
 	snd_soc_dai_set_pll(codec_dai, 0, 0, 14750000, wm8350_audio[i].sysclk);
 
-	dai_format = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
-		SND_SOC_DAIFMT_CBM_CFM;
-
-	/* set codec DAI configuration */
-	snd_soc_dai_set_fmt(codec_dai, dai_format);
-
-	/* set cpu DAI configuration */
-	snd_soc_dai_set_fmt(cpu_dai, dai_format);
-
 	/* TODO: The SSI driver should figure this out for us */
 	switch (channels) {
 	case 2:
@@ -244,6 +234,8 @@ static struct snd_soc_dai_link wm1133_ev1_dai = {
 	.init = wm1133_ev1_init,
 	.ops = &wm1133_ev1_ops,
 	.symmetric_rates = 1,
+	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+		   SND_SOC_DAIFMT_CBM_CFM,
 };
 
 static struct snd_soc_card wm1133_ev1 = {
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 06/21] ASoC: mxs-sgtl5000: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (4 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 05/21] ASoC: wm1133-ev1: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 07/21] ASoC: ams-delta: " Lars-Peter Clausen
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/mxs/mxs-sgtl5000.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c
index 6f1916b..6e6fce6 100644
--- a/sound/soc/mxs/mxs-sgtl5000.c
+++ b/sound/soc/mxs/mxs-sgtl5000.c
@@ -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,
 	},
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 07/21] ASoC: ams-delta: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (5 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 06/21] ASoC: mxs-sgtl5000: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 08/21] ASoC: raumfeld: " Lars-Peter Clausen
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/omap/ams-delta.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index 4c6afb7..7066130 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -412,21 +412,7 @@ static struct tty_ldisc_ops cx81801_ops = {
  * over the modem port.
  */
 
-static int ams_delta_hw_params(struct snd_pcm_substream *substream,
-			 struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-
-	/* Set cpu DAI configuration */
-	return snd_soc_dai_set_fmt(rtd->cpu_dai,
-				   SND_SOC_DAIFMT_DSP_A |
-				   SND_SOC_DAIFMT_NB_NF |
-				   SND_SOC_DAIFMT_CBM_CFM);
-}
-
-static struct snd_soc_ops ams_delta_ops = {
-	.hw_params = ams_delta_hw_params,
-};
+static struct snd_soc_ops ams_delta_ops;
 
 
 /* Digital mute implemented using modem/CPU multiplexer.
@@ -546,6 +532,8 @@ static struct snd_soc_dai_link ams_delta_dai_link = {
 	.platform_name = "omap-mcbsp.1",
 	.codec_name = "cx20442-codec",
 	.ops = &ams_delta_ops,
+	.dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF |
+		   SND_SOC_DAIFMT_CBM_CFM,
 };
 
 /* Audio card driver */
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 08/21] ASoC: raumfeld: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (6 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 07/21] ASoC: ams-delta: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 09/21] ASoC: zylonite: " Lars-Peter Clausen
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/pxa/raumfeld.c | 35 ++++++++---------------------------
 1 file changed, 8 insertions(+), 27 deletions(-)

diff --git a/sound/soc/pxa/raumfeld.c b/sound/soc/pxa/raumfeld.c
index 0837065..552b763 100644
--- a/sound/soc/pxa/raumfeld.c
+++ b/sound/soc/pxa/raumfeld.c
@@ -88,7 +88,7 @@ static int raumfeld_cs4270_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	unsigned int fmt, clk = 0;
+	unsigned int clk = 0;
 	int ret = 0;
 
 	switch (params_rate(params)) {
@@ -112,15 +112,6 @@ static int raumfeld_cs4270_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	fmt = SND_SOC_DAIFMT_I2S |
-	      SND_SOC_DAIFMT_NB_NF |
-	      SND_SOC_DAIFMT_CBS_CFS;
-
-	/* setup the CODEC DAI */
-	ret = snd_soc_dai_set_fmt(codec_dai, fmt);
-	if (ret < 0)
-		return ret;
-
 	ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk, 0);
 	if (ret < 0)
 		return ret;
@@ -130,10 +121,6 @@ static int raumfeld_cs4270_hw_params(struct snd_pcm_substream *substream,
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
-	if (ret < 0)
-		return ret;
-
 	ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_DIV_SCR, 4);
 	if (ret < 0)
 		return ret;
@@ -169,9 +156,8 @@ static int raumfeld_ak4104_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 *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	int fmt, ret = 0, clk = 0;
+	int ret = 0, clk = 0;
 
 	switch (params_rate(params)) {
 	case 44100:
@@ -194,22 +180,11 @@ static int raumfeld_ak4104_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF;
-
-	/* setup the CODEC DAI */
-	ret = snd_soc_dai_set_fmt(codec_dai, fmt | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	/* setup the CPU DAI */
 	ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, 0, clk);
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_dai_set_fmt(cpu_dai, fmt | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_DIV_SCR, 4);
 	if (ret < 0)
 		return ret;
@@ -233,6 +208,9 @@ static struct snd_soc_ops raumfeld_ak4104_ops = {
 	.platform_name	= "pxa-pcm-audio",		\
 	.codec_dai_name	= "cs4270-hifi",		\
 	.codec_name	= "cs4270.0-0048",	\
+	.dai_fmt	= SND_SOC_DAIFMT_I2S |		\
+			  SND_SOC_DAIFMT_NB_NF |        \
+			  SND_SOC_DAIFMT_CBS_CFS,       \
 	.ops		= &raumfeld_cs4270_ops,		\
 }
 
@@ -243,6 +221,9 @@ static struct snd_soc_ops raumfeld_ak4104_ops = {
 	.cpu_dai_name	= "pxa-ssp-dai.1",		\
 	.codec_dai_name	= "ak4104-hifi",		\
 	.platform_name	= "pxa-pcm-audio",		\
+	.dai_fmt	= SND_SOC_DAIFMT_I2S |		\
+			  SND_SOC_DAIFMT_NB_NF |	\
+			  SND_SOC_DAIFMT_CBS_CFS,       \
 	.ops		= &raumfeld_ak4104_ops,		\
 	.codec_name	= "spi0.0",			\
 }
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 09/21] ASoC: zylonite: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (7 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 08/21] ASoC: raumfeld: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 10/21] ASoC: goni_wm8994: " Lars-Peter Clausen
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/pxa/zylonite.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/sound/soc/pxa/zylonite.c b/sound/soc/pxa/zylonite.c
index 23bf991..8f301c7 100644
--- a/sound/soc/pxa/zylonite.c
+++ b/sound/soc/pxa/zylonite.c
@@ -130,16 +130,6 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream,
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	return 0;
 }
 
@@ -172,6 +162,8 @@ static struct snd_soc_dai_link zylonite_dai[] = {
 	.platform_name = "pxa-pcm-audio",
 	.cpu_dai_name = "pxa-ssp-dai.2",
 	.codec_dai_name = "wm9713-voice",
+	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+		   SND_SOC_DAIFMT_CBS_CFS,
 	.ops = &zylonite_voice_ops,
 },
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 10/21] ASoC: goni_wm8994: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (8 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 09/21] ASoC: zylonite: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 11/21] ASoC: h1940_uda1380: " Lars-Peter Clausen
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/goni_wm8994.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/sound/soc/samsung/goni_wm8994.c b/sound/soc/samsung/goni_wm8994.c
index 3b527dc..fad56b9 100644
--- a/sound/soc/samsung/goni_wm8994.c
+++ b/sound/soc/samsung/goni_wm8994.c
@@ -136,22 +136,9 @@ static int goni_hifi_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	unsigned int pll_out = 24000000;
 	int ret = 0;
 
-	/* set the cpu DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-			SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		return ret;
-
-	/* set codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-			SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		return ret;
-
 	/* set the codec FLL */
 	ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, 0, pll_out,
 			params_rate(params) * 256);
@@ -182,12 +169,6 @@ static int goni_voice_hw_params(struct snd_pcm_substream *substream,
 	if (params_rate(params) != 8000)
 		return -EINVAL;
 
-	/* set codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
-			SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		return ret;
-
 	/* set the codec FLL */
 	ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL2, 0, pll_out,
 			params_rate(params) * 256);
@@ -234,6 +215,8 @@ static struct snd_soc_dai_link goni_dai[] = {
 	.codec_dai_name = "wm8994-aif1",
 	.platform_name = "samsung-i2s.0",
 	.codec_name = "wm8994-codec.0-001a",
+	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+		   SND_SOC_DAIFMT_CBM_CFM,
 	.init = goni_wm8994_init,
 	.ops = &goni_hifi_ops,
 }, {
@@ -242,6 +225,8 @@ static struct snd_soc_dai_link goni_dai[] = {
 	.cpu_dai_name = "goni-voice-dai",
 	.codec_dai_name = "wm8994-aif2",
 	.codec_name = "wm8994-codec.0-001a",
+	.dai_fmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_IB_IF |
+		   SND_SOC_DAIFMT_CBM_CFM,
 	.ops = &goni_voice_ops,
 },
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 11/21] ASoC: h1940_uda1380: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (9 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 10/21] ASoC: goni_wm8994: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 12/21] ASoC: jive_wm8750: " Lars-Peter Clausen
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/h1940_uda1380.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c
index f2d7980..59b0442 100644
--- a/sound/soc/samsung/h1940_uda1380.c
+++ b/sound/soc/samsung/h1940_uda1380.c
@@ -76,7 +76,6 @@ static int h1940_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	int div;
 	int ret;
 	unsigned int rate = params_rate(params);
@@ -95,18 +94,6 @@ static int h1940_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	/* set codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
-	/* set cpu DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	/* select clock source */
 	ret = snd_soc_dai_set_sysclk(cpu_dai, S3C24XX_CLKSRC_PCLK, rate,
 			SND_SOC_CLOCK_OUT);
@@ -207,6 +194,8 @@ static struct snd_soc_dai_link h1940_uda1380_dai[] = {
 		.init		= h1940_uda1380_init,
 		.platform_name	= "s3c24xx-iis",
 		.codec_name	= "uda1380-codec.0-001a",
+		.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBS_CFS,
 		.ops		= &h1940_ops,
 	},
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 12/21] ASoC: jive_wm8750: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (10 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 11/21] ASoC: h1940_uda1380: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 13/21] ASoC: neo1973_wm8753: " Lars-Peter Clausen
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/jive_wm8750.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/sound/soc/samsung/jive_wm8750.c b/sound/soc/samsung/jive_wm8750.c
index b5f6abd..6c3b359 100644
--- a/sound/soc/samsung/jive_wm8750.c
+++ b/sound/soc/samsung/jive_wm8750.c
@@ -61,20 +61,6 @@ static int jive_hw_params(struct snd_pcm_substream *substream,
 	s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params),
 				s3c_i2sv2_get_clock(cpu_dai));
 
-	/* set codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-				  SND_SOC_DAIFMT_NB_NF |
-				  SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
-	/* set cpu DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-				  SND_SOC_DAIFMT_NB_NF |
-				  SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	/* set the codec system clock for DAC and ADC */
 	ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk,
 				     SND_SOC_CLOCK_IN);
@@ -121,6 +107,8 @@ static struct snd_soc_dai_link jive_dai = {
 	.platform_name	= "s3c2412-i2s",
 	.codec_name	= "wm8750.0-001a",
 	.init		= jive_wm8750_init,
+	.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+			  SND_SOC_DAIFMT_CBS_CFS,
 	.ops		= &jive_ops,
 };
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 13/21] ASoC: neo1973_wm8753: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (11 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 12/21] ASoC: jive_wm8750: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 14/21] ASoC: rx1950_uda1380: " Lars-Peter Clausen
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/neo1973_wm8753.c | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/sound/soc/samsung/neo1973_wm8753.c b/sound/soc/samsung/neo1973_wm8753.c
index 9b4a09f..65602b9 100644
--- a/sound/soc/samsung/neo1973_wm8753.c
+++ b/sound/soc/samsung/neo1973_wm8753.c
@@ -70,20 +70,6 @@ static int neo1973_hifi_hw_params(struct snd_pcm_substream *substream,
 		break;
 	}
 
-	/* set codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai,
-		SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
-		SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		return ret;
-
-	/* set cpu DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai,
-		SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
-		SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		return ret;
-
 	/* set the codec system clock for DAC and ADC */
 	ret = snd_soc_dai_set_sysclk(codec_dai, WM8753_MCLK, pll_out,
 		SND_SOC_CLOCK_IN);
@@ -151,13 +137,6 @@ static int neo1973_voice_hw_params(struct snd_pcm_substream *substream,
 
 	pcmdiv = WM8753_PCM_DIV_6; /* 2.048 MHz */
 
-	/* todo: gg check mode (DSP_B) against CSR datasheet */
-	/* set codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B |
-		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	/* set the codec system clock for DAC and ADC */
 	ret = snd_soc_dai_set_sysclk(codec_dai, WM8753_PCMCLK, 12288000,
 		SND_SOC_CLOCK_IN);
@@ -300,6 +279,8 @@ static struct snd_soc_dai_link neo1973_dai[] = {
 	.cpu_dai_name = "s3c24xx-iis",
 	.codec_dai_name = "wm8753-hifi",
 	.codec_name = "wm8753.0-001a",
+	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+		   SND_SOC_DAIFMT_CBM_CFM,
 	.init = neo1973_wm8753_init,
 	.ops = &neo1973_hifi_ops,
 },
@@ -309,6 +290,8 @@ static struct snd_soc_dai_link neo1973_dai[] = {
 	.cpu_dai_name = "bt-sco-pcm",
 	.codec_dai_name = "wm8753-voice",
 	.codec_name = "wm8753.0-001a",
+	.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF |
+		   SND_SOC_DAIFMT_CBS_CFS,
 	.ops = &neo1973_voice_ops,
 },
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 14/21] ASoC: rx1950_uda1380: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (12 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 13/21] ASoC: neo1973_wm8753: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 15/21] ASoC: s3c24xx_simtec: " Lars-Peter Clausen
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/rx1950_uda1380.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c
index 37688eb..873f2cb 100644
--- a/sound/soc/samsung/rx1950_uda1380.c
+++ b/sound/soc/samsung/rx1950_uda1380.c
@@ -89,6 +89,8 @@ static struct snd_soc_dai_link rx1950_uda1380_dai[] = {
 		.init		= rx1950_uda1380_init,
 		.platform_name	= "s3c24xx-iis",
 		.codec_name	= "uda1380-codec.0-001a",
+		.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBS_CFS,
 		.ops		= &rx1950_ops,
 	},
 };
@@ -154,7 +156,6 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	int div;
 	int ret;
 	unsigned int rate = params_rate(params);
@@ -181,18 +182,6 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	/* set codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
-	/* set cpu DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	/* select clock source */
 	ret = snd_soc_dai_set_sysclk(cpu_dai, clk_source, rate,
 			SND_SOC_CLOCK_OUT);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 15/21] ASoC: s3c24xx_simtec: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (13 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 14/21] ASoC: rx1950_uda1380: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 16/21] ASoC: s3c24xx_uda134x: " Lars-Peter Clausen
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/s3c24xx_simtec.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/sound/soc/samsung/s3c24xx_simtec.c b/sound/soc/samsung/s3c24xx_simtec.c
index 2c015f6..dcc008d 100644
--- a/sound/soc/samsung/s3c24xx_simtec.c
+++ b/sound/soc/samsung/s3c24xx_simtec.c
@@ -169,24 +169,6 @@ static int simtec_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	int ret;
 
-	/* Set the CODEC as the bus clock master, I2S */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-				  SND_SOC_DAIFMT_NB_NF |
-				  SND_SOC_DAIFMT_CBM_CFM);
-	if (ret) {
-		pr_err("%s: failed set cpu dai format\n", __func__);
-		return ret;
-	}
-
-	/* Set the CODEC as the bus clock master */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-				  SND_SOC_DAIFMT_NB_NF |
-				  SND_SOC_DAIFMT_CBM_CFM);
-	if (ret) {
-		pr_err("%s: failed set codec dai format\n", __func__);
-		return ret;
-	}
-
 	ret = snd_soc_dai_set_sysclk(codec_dai, 0,
 				     CODEC_CLOCK, SND_SOC_CLOCK_IN);
 	if (ret) {
@@ -320,6 +302,8 @@ int simtec_audio_core_probe(struct platform_device *pdev,
 	int ret;
 
 	card->dai_link->ops = &simtec_snd_ops;
+	card->dai_link->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBM_CFM;
 
 	pdata = pdev->dev.platform_data;
 	if (!pdata) {
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 16/21] ASoC: s3c24xx_uda134x: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (14 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 15/21] ASoC: s3c24xx_simtec: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 17/21] ASoC: smartq_wm8987: " Lars-Peter Clausen
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/s3c24xx_uda134x.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/sound/soc/samsung/s3c24xx_uda134x.c b/sound/soc/samsung/s3c24xx_uda134x.c
index 9c6f7db..50849e1 100644
--- a/sound/soc/samsung/s3c24xx_uda134x.c
+++ b/sound/soc/samsung/s3c24xx_uda134x.c
@@ -173,16 +173,6 @@ static int s3c24xx_uda134x_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-			SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-			SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	ret = snd_soc_dai_set_sysclk(cpu_dai, clk_source , clk,
 			SND_SOC_CLOCK_IN);
 	if (ret < 0)
@@ -223,6 +213,8 @@ static struct snd_soc_dai_link s3c24xx_uda134x_dai_link = {
 	.codec_name = "uda134x-codec",
 	.codec_dai_name = "uda134x-hifi",
 	.cpu_dai_name = "s3c24xx-iis",
+	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+		   SND_SOC_DAIFMT_CBS_CFS,
 	.ops = &s3c24xx_uda134x_ops,
 	.platform_name	= "s3c24xx-iis",
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 17/21] ASoC: smartq_wm8987: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (15 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 16/21] ASoC: s3c24xx_uda134x: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 18/21] ASoC: smdk_wm8580: " Lars-Peter Clausen
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/smartq_wm8987.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c
index 9b0ffac..8291d2a 100644
--- a/sound/soc/samsung/smartq_wm8987.c
+++ b/sound/soc/samsung/smartq_wm8987.c
@@ -56,20 +56,6 @@ static int smartq_hifi_hw_params(struct snd_pcm_substream *substream,
 		break;
 	}
 
-	/* set codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-					     SND_SOC_DAIFMT_NB_NF |
-					     SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
-	/* set cpu DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-					   SND_SOC_DAIFMT_NB_NF |
-					   SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	/* Use PCLK for I2S signal generation */
 	ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_RCLKSRC_0,
 					0, SND_SOC_CLOCK_IN);
@@ -199,6 +185,8 @@ static struct snd_soc_dai_link smartq_dai[] = {
 		.platform_name	= "samsung-i2s.0",
 		.codec_name	= "wm8750.0-0x1a",
 		.init		= smartq_wm8987_init,
+		.dai_fmt	= SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBS_CFS,
 		.ops		= &smartq_hifi_ops,
 	},
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 18/21] ASoC: smdk_wm8580: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (16 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 17/21] ASoC: smartq_wm8987: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 19/21] ASoC: smdk_wm8570pcm: " Lars-Peter Clausen
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/smdk_wm8580.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/sound/soc/samsung/smdk_wm8580.c b/sound/soc/samsung/smdk_wm8580.c
index b1a519f..17a2f71 100644
--- a/sound/soc/samsung/smdk_wm8580.c
+++ b/sound/soc/samsung/smdk_wm8580.c
@@ -32,7 +32,6 @@ static int smdk_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_dai *codec_dai = rtd->codec_dai;
 	unsigned int pll_out;
 	int bfs, rfs, ret;
@@ -77,20 +76,6 @@ static int smdk_hw_params(struct snd_pcm_substream *substream,
 	}
 	pll_out = params_rate(params) * rfs;
 
-	/* Set the Codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S
-					 | SND_SOC_DAIFMT_NB_NF
-					 | SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		return ret;
-
-	/* Set the AP DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S
-					 | SND_SOC_DAIFMT_NB_NF
-					 | SND_SOC_DAIFMT_CBM_CFM);
-	if (ret < 0)
-		return ret;
-
 	/* Set WM8580 to drive MCLK from its PLLA */
 	ret = snd_soc_dai_set_clkdiv(codec_dai, WM8580_MCLK,
 					WM8580_CLKSRC_PLLA);
@@ -168,6 +153,9 @@ enum {
 	SEC_PLAYBACK,
 };
 
+#define SMDK_DAI_FMT (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | \
+	SND_SOC_DAIFMT_CBM_CFM)
+
 static struct snd_soc_dai_link smdk_dai[] = {
 	[PRI_PLAYBACK] = { /* Primary Playback i/f */
 		.name = "WM8580 PAIF RX",
@@ -176,6 +164,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
 		.codec_dai_name = "wm8580-hifi-playback",
 		.platform_name = "samsung-i2s.0",
 		.codec_name = "wm8580.0-001b",
+		.dai_fmt = SMDK_DAI_FMT,
 		.ops = &smdk_ops,
 	},
 	[PRI_CAPTURE] = { /* Primary Capture i/f */
@@ -185,6 +174,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
 		.codec_dai_name = "wm8580-hifi-capture",
 		.platform_name = "samsung-i2s.0",
 		.codec_name = "wm8580.0-001b",
+		.dai_fmt = SMDK_DAI_FMT,
 		.init = smdk_wm8580_init_paiftx,
 		.ops = &smdk_ops,
 	},
@@ -195,6 +185,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
 		.codec_dai_name = "wm8580-hifi-playback",
 		.platform_name = "samsung-i2s-sec",
 		.codec_name = "wm8580.0-001b",
+		.dai_fmt = SMDK_DAI_FMT,
 		.ops = &smdk_ops,
 	},
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 19/21] ASoC: smdk_wm8570pcm: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (17 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 18/21] ASoC: smdk_wm8580: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 20/21] ASoC: smdk_wm8994pcm: " Lars-Peter Clausen
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/smdk_wm8580pcm.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/sound/soc/samsung/smdk_wm8580pcm.c b/sound/soc/samsung/smdk_wm8580pcm.c
index 05c609c..6deec52 100644
--- a/sound/soc/samsung/smdk_wm8580pcm.c
+++ b/sound/soc/samsung/smdk_wm8580pcm.c
@@ -62,20 +62,6 @@ static int smdk_wm8580_pcm_hw_params(struct snd_pcm_substream *substream,
 
 	rfs = mclk_freq / params_rate(params) / 2;
 
-	/* Set the codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B
-				| SND_SOC_DAIFMT_IB_NF
-				| SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
-	/* Set the cpu DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_B
-				| SND_SOC_DAIFMT_IB_NF
-				| SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	if (mclk_freq == xtal_freq) {
 		ret = snd_soc_dai_set_sysclk(codec_dai, WM8580_CLKSRC_MCLK,
 						mclk_freq, SND_SOC_CLOCK_IN);
@@ -121,6 +107,9 @@ static struct snd_soc_ops smdk_wm8580_pcm_ops = {
 	.hw_params = smdk_wm8580_pcm_hw_params,
 };
 
+#define SMDK_DAI_FMT (SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF | \
+	SND_SOC_DAIFMT_CBS_CFS)
+
 static struct snd_soc_dai_link smdk_dai[] = {
 	{
 		.name = "WM8580 PAIF PCM RX",
@@ -129,6 +118,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
 		.codec_dai_name = "wm8580-hifi-playback",
 		.platform_name = "samsung-audio",
 		.codec_name = "wm8580.0-001b",
+		.dai_fmt = SMDK_DAI_FMT,
 		.ops = &smdk_wm8580_pcm_ops,
 	}, {
 		.name = "WM8580 PAIF PCM TX",
@@ -137,6 +127,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
 		.codec_dai_name = "wm8580-hifi-capture",
 		.platform_name = "samsung-pcm.0",
 		.codec_name = "wm8580.0-001b",
+		.dai_fmt = SMDK_DAI_FMT,
 		.ops = &smdk_wm8580_pcm_ops,
 	},
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 20/21] ASoC: smdk_wm8994pcm: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (18 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 19/21] ASoC: smdk_wm8570pcm: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-01 16:16 ` [PATCH 21/21] ASoC: migor: " Lars-Peter Clausen
  2015-01-06 17:34 ` [PATCH 00/21] ASoC: " Mark Brown
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/samsung/smdk_wm8994pcm.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/sound/soc/samsung/smdk_wm8994pcm.c b/sound/soc/samsung/smdk_wm8994pcm.c
index c470e8e..b1c89ec 100644
--- a/sound/soc/samsung/smdk_wm8994pcm.c
+++ b/sound/soc/samsung/smdk_wm8994pcm.c
@@ -68,20 +68,6 @@ static int smdk_wm8994_pcm_hw_params(struct snd_pcm_substream *substream,
 
 	mclk_freq = params_rate(params) * rfs;
 
-	/* Set the codec DAI configuration */
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_B
-				| SND_SOC_DAIFMT_IB_NF
-				| SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
-	/* Set the cpu DAI configuration */
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_B
-				| SND_SOC_DAIFMT_IB_NF
-				| SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1,
 					mclk_freq, SND_SOC_CLOCK_IN);
 	if (ret < 0)
@@ -118,6 +104,8 @@ static struct snd_soc_dai_link smdk_dai[] = {
 		.codec_dai_name = "wm8994-aif1",
 		.platform_name = "samsung-pcm.0",
 		.codec_name = "wm8994-codec",
+		.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF |
+			   SND_SOC_DAIFMT_CBS_CFS,
 		.ops = &smdk_wm8994_pcm_ops,
 	},
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 21/21] ASoC: migor: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (19 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 20/21] ASoC: smdk_wm8994pcm: " Lars-Peter Clausen
@ 2015-01-01 16:16 ` Lars-Peter Clausen
  2015-01-06 17:34 ` [PATCH 00/21] ASoC: " Mark Brown
  21 siblings, 0 replies; 24+ messages in thread
From: Lars-Peter Clausen @ 2015-01-01 16:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Lars-Peter Clausen, Janusz Krzysztofik,
	Sangbeom Kim, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack

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>
---
 sound/soc/sh/migor.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/sound/soc/sh/migor.c b/sound/soc/sh/migor.c
index c58c252..82f5823 100644
--- a/sound/soc/sh/migor.c
+++ b/sound/soc/sh/migor.c
@@ -63,16 +63,6 @@ static int migor_hw_params(struct snd_pcm_substream *substream,
 	if (ret < 0)
 		return ret;
 
-	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_NB_IF |
-				  SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
-	ret = snd_soc_dai_set_fmt(rtd->cpu_dai, SND_SOC_DAIFMT_NB_IF |
-				  SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS);
-	if (ret < 0)
-		return ret;
-
 	codec_freq = rate * 512;
 	/*
 	 * This propagates the parent frequency change to children and
@@ -144,6 +134,8 @@ static struct snd_soc_dai_link migor_dai = {
 	.codec_dai_name = "wm8978-hifi",
 	.platform_name = "siu-pcm-audio",
 	.codec_name = "wm8978.0-001a",
+	.dai_fmt = SND_SOC_DAIFMT_NB_IF | SND_SOC_DAIFMT_I2S |
+		   SND_SOC_DAIFMT_CBS_CFS,
 	.ops = &migor_dai_ops,
 };
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 01/21] ASoC: sam9g20_wm8731: Use static DAI format setup
  2015-01-01 16:16 ` [PATCH 01/21] ASoC: sam9g20_wm8731: " Lars-Peter Clausen
@ 2015-01-04  1:11   ` Bo Shen
  0 siblings, 0 replies; 24+ messages in thread
From: Bo Shen @ 2015-01-04  1:11 UTC (permalink / raw)
  To: Lars-Peter Clausen, Mark Brown, Liam Girdwood
  Cc: Fabio Estevam, alsa-devel, Janusz Krzysztofik, Sangbeom Kim,
	Denis Carikli, Manuel Lauss, Shawn Guo, Guennadi Liakhovetski,
	Daniel Mack

Hi Lars-Peter Clausen,

On 01/02/2015 12:16 AM, Lars-Peter Clausen wrote:
> 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>

Thanks.
Acked-by: Bo Shen <voice.shen@atmel.com>

> ---
>   sound/soc/atmel/sam9g20_wm8731.c | 30 ++----------------------------
>   1 file changed, 2 insertions(+), 28 deletions(-)
>
> diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
> index 66b66d0..98ca634 100644
> --- a/sound/soc/atmel/sam9g20_wm8731.c
> +++ b/sound/soc/atmel/sam9g20_wm8731.c
> @@ -64,33 +64,6 @@
>
>   static struct clk *mclk;
>
> -static int at91sam9g20ek_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 *codec_dai = rtd->codec_dai;
> -	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
> -	int ret;
> -
> -	/* set codec DAI configuration */
> -	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
> -		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
> -	if (ret < 0)
> -		return ret;
> -
> -	/* set cpu DAI configuration */
> -	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
> -		SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
> -	if (ret < 0)
> -		return ret;
> -
> -	return 0;
> -}
> -
> -static struct snd_soc_ops at91sam9g20ek_ops = {
> -	.hw_params = at91sam9g20ek_hw_params,
> -};
> -
>   static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card,
>   					struct snd_soc_dapm_context *dapm,
>   					enum snd_soc_bias_level level)
> @@ -173,7 +146,8 @@ static struct snd_soc_dai_link at91sam9g20ek_dai = {
>   	.init = at91sam9g20ek_wm8731_init,
>   	.platform_name = "at91rm9200_ssc.0",
>   	.codec_name = "wm8731.0-001b",
> -	.ops = &at91sam9g20ek_ops,
> +	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
> +		   SND_SOC_DAIFMT_CBM_CFM,
>   };
>
>   static struct snd_soc_card snd_soc_at91sam9g20ek = {
>

Best Regards,
Bo Shen

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 00/21] ASoC: Use static DAI format setup
  2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
                   ` (20 preceding siblings ...)
  2015-01-01 16:16 ` [PATCH 21/21] ASoC: migor: " Lars-Peter Clausen
@ 2015-01-06 17:34 ` Mark Brown
  21 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2015-01-06 17:34 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Fabio Estevam, alsa-devel, Janusz Krzysztofik, Sangbeom Kim,
	Liam Girdwood, Denis Carikli, Manuel Lauss, Bo Shen, Shawn Guo,
	Guennadi Liakhovetski, Daniel Mack


[-- Attachment #1.1: Type: text/plain, Size: 345 bytes --]

On Thu, Jan 01, 2015 at 05:16:09PM +0100, Lars-Peter Clausen wrote:
> There is still a rather large amount of board driver which manually call
> snd_soc_dai_set_fmt() for both the CPU and the CODEC DAI, while pretty much
> all of them can use static DAI setup by setting the dai_fmt field in the
> snd_soc_dai_link struct.

Applied all, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2015-01-06 17:35 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-01 16:16 [PATCH 00/21] ASoC: Use static DAI format setup Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 01/21] ASoC: sam9g20_wm8731: " Lars-Peter Clausen
2015-01-04  1:11   ` Bo Shen
2015-01-01 16:16 ` [PATCH 02/21] ASoC: db1200: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 03/21] ASoC: eureka-tlv320: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 04/21] ASoC: mx27vis-aci32x4: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 05/21] ASoC: wm1133-ev1: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 06/21] ASoC: mxs-sgtl5000: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 07/21] ASoC: ams-delta: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 08/21] ASoC: raumfeld: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 09/21] ASoC: zylonite: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 10/21] ASoC: goni_wm8994: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 11/21] ASoC: h1940_uda1380: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 12/21] ASoC: jive_wm8750: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 13/21] ASoC: neo1973_wm8753: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 14/21] ASoC: rx1950_uda1380: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 15/21] ASoC: s3c24xx_simtec: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 16/21] ASoC: s3c24xx_uda134x: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 17/21] ASoC: smartq_wm8987: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 18/21] ASoC: smdk_wm8580: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 19/21] ASoC: smdk_wm8570pcm: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 20/21] ASoC: smdk_wm8994pcm: " Lars-Peter Clausen
2015-01-01 16:16 ` [PATCH 21/21] ASoC: migor: " Lars-Peter Clausen
2015-01-06 17:34 ` [PATCH 00/21] ASoC: " Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).