All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
@ 2018-03-27 20:56 Kirill Marinushkin
  2018-03-27 20:56 ` [PATCH v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-03-27 20:56 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Mark Brown
  Cc: Pan Xiuli, Pierre-Louis Bossart, Liam Girdwood, linux-kernel,
	alsa-devel, Kirill Marinushkin

Hello Jaroslav, Takashi, Mark,

This patch series is a resend of [1] and [2], rebased on top of the latest
head. It was logical to resend them together.

It includes 2 patches for linux + 2 patches for alsa-lib.

Please have a look.

Best Regards,
Kirill

[1] https://patchwork.kernel.org/patch/10250485/
[2] https://patchwork.kernel.org/patch/10230611/

Kirill Marinushkin (2):
  ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  ASoC: topology: Add missing clock gating parameter when parsing
    hw_configs

 include/uapi/sound/asoc.h | 23 ++++++++++++++++++++---
 sound/soc/soc-topology.c  | 19 ++++++++++++++-----
 2 files changed, 34 insertions(+), 8 deletions(-)

-- 
2.13.6

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

* [PATCH v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-03-27 20:56 [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
@ 2018-03-27 20:56 ` Kirill Marinushkin
  2018-03-27 20:56 ` [PATCH v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs Kirill Marinushkin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-03-27 20:56 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Mark Brown
  Cc: Pan Xiuli, Pierre-Louis Bossart, Liam Girdwood, linux-kernel,
	alsa-devel, Kirill Marinushkin

The values of bclk and fsync are inverted WRT the codec. But the existing
solution already works for Broadwell, see the alsa-lib config:

`alsa-lib/src/conf/topology/broadwell/broadwell.conf`

This commit provides the backwards-compatible solution to fix this misuse.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Tested-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org
---
 include/uapi/sound/asoc.h | 16 ++++++++++++++--
 sound/soc/soc-topology.c  | 12 +++++++-----
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index 69c37ecbff7e..f0e5e21efa54 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -160,6 +160,18 @@
 #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS    (1 << 2)
 #define SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP            (1 << 3)
 
+/* DAI topology BCLK parameter
+ * For the backwards capability, by default codec is bclk master
+ */
+#define SND_SOC_TPLG_BCLK_CM         0 /* codec is bclk master */
+#define SND_SOC_TPLG_BCLK_CS         1 /* codec is bclk slave */
+
+/* DAI topology FSYNC parameter
+ * For the backwards capability, by default codec is fsync master
+ */
+#define SND_SOC_TPLG_FSYNC_CM         0 /* codec is fsync master */
+#define SND_SOC_TPLG_FSYNC_CS         1 /* codec is fsync slave */
+
 /*
  * Block Header.
  * This header precedes all object and object arrays below.
@@ -315,8 +327,8 @@ struct snd_soc_tplg_hw_config {
 	__u8 clock_gated;	/* 1 if clock can be gated to save power */
 	__u8 invert_bclk;	/* 1 for inverted BCLK, 0 for normal */
 	__u8 invert_fsync;	/* 1 for inverted frame clock, 0 for normal */
-	__u8 bclk_master;	/* 1 for master of BCLK, 0 for slave */
-	__u8 fsync_master;	/* 1 for master of FSYNC, 0 for slave */
+	__u8 bclk_master;	/* SND_SOC_TPLG_BCLK_ value */
+	__u8 fsync_master;	/* SND_SOC_TPLG_FSYNC_ value */
 	__u8 mclk_direction;    /* 0 for input, 1 for output */
 	__le16 reserved;	/* for 32bit alignment */
 	__le32 mclk_rate;	/* MCLK or SYSCLK freqency in Hz */
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 01a50413c66f..c5bdc673b195 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1994,13 +1994,15 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
 			link->dai_fmt |= SND_SOC_DAIFMT_IB_IF;
 
 		/* clock masters */
-		bclk_master = hw_config->bclk_master;
-		fsync_master = hw_config->fsync_master;
-		if (!bclk_master && !fsync_master)
+		bclk_master = (hw_config->bclk_master ==
+			       SND_SOC_TPLG_BCLK_CM);
+		fsync_master = (hw_config->fsync_master ==
+				SND_SOC_TPLG_FSYNC_CM);
+		if (bclk_master && fsync_master)
 			link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
-		else if (bclk_master && !fsync_master)
-			link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
 		else if (!bclk_master && fsync_master)
+			link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFM;
+		else if (bclk_master && !fsync_master)
 			link->dai_fmt |= SND_SOC_DAIFMT_CBM_CFS;
 		else
 			link->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
-- 
2.13.6

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

* [PATCH v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs
  2018-03-27 20:56 [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
  2018-03-27 20:56 ` [PATCH v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
@ 2018-03-27 20:56 ` Kirill Marinushkin
  2018-04-16 17:15     ` Mark Brown
  2018-03-27 21:00 ` [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
  2018-04-02 21:17 ` [PATCH v3 0/2] ASoC: topology: Improve " Kirill Marinushkin
  3 siblings, 1 reply; 23+ messages in thread
From: Kirill Marinushkin @ 2018-03-27 20:56 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Mark Brown
  Cc: Pan Xiuli, Pierre-Louis Bossart, Liam Girdwood, linux-kernel,
	alsa-devel, Kirill Marinushkin

Clock gating parameter is a part of `dai_fmt`. It is supported by
`alsa-lib` when creating a topology binary file, but ignored by kernel
when loading this topology file.

After applying this commit, the clock gating parameter is not ignored any
more. This solution is backwards compatible. The existing behaviour is
not broken, because by default the parameter value is 0 and is ignored.

snd_soc_tplg_hw_config.clock_gated = 0 => no effect
snd_soc_tplg_hw_config.clock_gated = 1 => SND_SOC_DAIFMT_GATED
snd_soc_tplg_hw_config.clock_gated = 2 => SND_SOC_DAIFMT_CONT

For example, the following config, based on
alsa-lib/src/conf/topology/broadwell/broadwell.conf, is now supported:

~~~~
SectionHWConfig."CodecHWConfig" {
        id "1"
        format "I2S"            # physical audio format.
        pm_gate_clocks "true"   # clock can be gated
}

SectionLink."Codec" {

        # used for binding to the physical link
        id "0"

        hw_configs [
                "CodecHWConfig"
        ]

        default_hw_conf_id "1"
}
~~~~

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pan Xiuli <xiuli.pan@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org
---
 include/uapi/sound/asoc.h | 7 ++++++-
 sound/soc/soc-topology.c  | 7 +++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index f0e5e21efa54..f3c4b46e39d8 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -139,6 +139,11 @@
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS      (1 << 1)
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS    (1 << 2)
 
+/* DAI clock gating */
+#define SND_SOC_TPLG_DAI_CLK_GATE_UNDEFINED	0
+#define SND_SOC_TPLG_DAI_CLK_GATE_GATED	1
+#define SND_SOC_TPLG_DAI_CLK_GATE_CONT		2
+
 /* DAI physical PCM data formats.
  * Add new formats to the end of the list.
  */
@@ -324,7 +329,7 @@ struct snd_soc_tplg_hw_config {
 	__le32 size;            /* in bytes of this structure */
 	__le32 id;		/* unique ID - - used to match */
 	__le32 fmt;		/* SND_SOC_DAI_FORMAT_ format value */
-	__u8 clock_gated;	/* 1 if clock can be gated to save power */
+	__u8 clock_gated;	/* SND_SOC_TPLG_DAI_CLK_GATE_ value */
 	__u8 invert_bclk;	/* 1 for inverted BCLK, 0 for normal */
 	__u8 invert_fsync;	/* 1 for inverted frame clock, 0 for normal */
 	__u8 bclk_master;	/* SND_SOC_TPLG_BCLK_ value */
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index c5bdc673b195..04f834e6a6b5 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1981,6 +1981,13 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
 
 		link->dai_fmt = hw_config->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
 
+		/* clock gating */
+		if (hw_config->clock_gated == SND_SOC_TPLG_DAI_CLK_GATE_GATED)
+			link->dai_fmt |= SND_SOC_DAIFMT_GATED;
+		else if (hw_config->clock_gated ==
+			 SND_SOC_TPLG_DAI_CLK_GATE_CONT)
+			link->dai_fmt |= SND_SOC_DAIFMT_CONT;
+
 		/* clock signal polarity */
 		invert_bclk = hw_config->invert_bclk;
 		invert_fsync = hw_config->invert_fsync;
-- 
2.13.6

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

* [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing hw_configs
  2018-03-27 20:56 [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
  2018-03-27 20:56 ` [PATCH v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
  2018-03-27 20:56 ` [PATCH v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs Kirill Marinushkin
@ 2018-03-27 21:00 ` Kirill Marinushkin
  2018-03-27 21:00     ` Kirill Marinushkin
  2018-03-27 21:00   ` [PATCH, alsa-lib, v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs Kirill Marinushkin
  2018-04-02 21:17 ` [PATCH v3 0/2] ASoC: topology: Improve " Kirill Marinushkin
  3 siblings, 2 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-03-27 21:00 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Mark Brown
  Cc: Pan Xiuli, Pierre-Louis Bossart, Liam Girdwood, linux-kernel,
	alsa-devel, Kirill Marinushkin

Below is the alsa-lib part of the patch-series
"ASoC: topology: Improve parsing hw_configs"

Kirill Marinushkin (2):
  ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  ASoC: topology: Add missing clock gating parameter when parsing
    hw_configs

 include/sound/asoc.h                       | 23 ++++++++++++++++---
 include/topology.h                         |  6 ++---
 src/conf/topology/broadwell/broadwell.conf |  4 ++--
 src/topology/pcm.c                         | 36 +++++++++++++++++++++++++-----
 4 files changed, 56 insertions(+), 13 deletions(-)

-- 
2.13.6

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

* [PATCH, alsa-lib, v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-03-27 21:00 ` [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
@ 2018-03-27 21:00     ` Kirill Marinushkin
  2018-03-27 21:00   ` [PATCH, alsa-lib, v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs Kirill Marinushkin
  1 sibling, 0 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-03-27 21:00 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Mark Brown
  Cc: Pan Xiuli, Pierre-Louis Bossart, Liam Girdwood, linux-kernel,
	alsa-devel, Kirill Marinushkin

The values of bclk and fsync are inverted WRT the codec. But the existing
solution already works for Broadwell, see the alsa-lib config:

`alsa-lib/src/conf/topology/broadwell/broadwell.conf`

This commit provides the backwards-compatible solution to fix this misuse.
This commit goes in pair with the corresponding patch for linux.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Tested-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org
---
 include/sound/asoc.h                       | 16 ++++++++++++++--
 include/topology.h                         |  4 ++--
 src/conf/topology/broadwell/broadwell.conf |  4 ++--
 src/topology/pcm.c                         | 30 ++++++++++++++++++++++++++----
 4 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/include/sound/asoc.h b/include/sound/asoc.h
index 0f5d9f9a..89b00703 100644
--- a/include/sound/asoc.h
+++ b/include/sound/asoc.h
@@ -156,6 +156,18 @@
 #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS    (1 << 2)
 #define SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP            (1 << 3)
 
+/* DAI topology BCLK parameter
+ * For the backwards capability, by default codec is bclk master
+ */
+#define SND_SOC_TPLG_BCLK_CM         0 /* codec is bclk master */
+#define SND_SOC_TPLG_BCLK_CS         1 /* codec is bclk slave */
+
+/* DAI topology FSYNC parameter
+ * For the backwards capability, by default codec is fsync master
+ */
+#define SND_SOC_TPLG_FSYNC_CM         0 /* codec is fsync master */
+#define SND_SOC_TPLG_FSYNC_CS         1 /* codec is fsync slave */
+
 /*
  * Block Header.
  * This header precedes all object and object arrays below.
@@ -311,8 +323,8 @@ struct snd_soc_tplg_hw_config {
 	__u8 clock_gated;	/* 1 if clock can be gated to save power */
 	__u8 invert_bclk;	/* 1 for inverted BCLK, 0 for normal */
 	__u8 invert_fsync;	/* 1 for inverted frame clock, 0 for normal */
-	__u8 bclk_master;	/* 1 for master of BCLK, 0 for slave */
-	__u8 fsync_master;	/* 1 for master of FSYNC, 0 for slave */
+	__u8 bclk_master;	/* SND_SOC_TPLG_BCLK_ value */
+	__u8 fsync_master;	/* SND_SOC_TPLG_FSYNC_ value */
 	__u8 mclk_direction;    /* 0 for input, 1 for output */
 	__le16 reserved;	/* for 32bit alignment */
 	__le32 mclk_rate;	/* MCLK or SYSCLK freqency in Hz */
diff --git a/include/topology.h b/include/topology.h
index 8779da4d..5d7b46df 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -1000,8 +1000,8 @@ struct snd_tplg_hw_config_template {
 	unsigned char clock_gated;      /* 1 if clock can be gated to save power */
 	unsigned char  invert_bclk;     /* 1 for inverted BCLK, 0 for normal */
 	unsigned char  invert_fsync;    /* 1 for inverted frame clock, 0 for normal */
-	unsigned char  bclk_master;     /* 1 for master of BCLK, 0 for slave */
-	unsigned char  fsync_master;    /* 1 for master of FSYNC, 0 for slave */
+	unsigned char  bclk_master;     /* SND_SOC_TPLG_BCLK_ value */
+	unsigned char  fsync_master;    /* SND_SOC_TPLG_FSYNC_ value */
 	unsigned char  mclk_direction;  /* 0 for input, 1 for output */
 	unsigned short reserved;        /* for 32bit alignment */
 	unsigned int mclk_rate;	        /* MCLK or SYSCLK freqency in Hz */
diff --git a/src/conf/topology/broadwell/broadwell.conf b/src/conf/topology/broadwell/broadwell.conf
index b8405d93..09fc4daa 100644
--- a/src/conf/topology/broadwell/broadwell.conf
+++ b/src/conf/topology/broadwell/broadwell.conf
@@ -393,8 +393,8 @@ SectionGraph."dsp" {
 SectionHWConfig."CodecHWConfig" {
 	id "1"
 	format "I2S"		# physical audio format.
-	bclk   "master"		# Platform is master of bit clock
-	fsync  "master"		# platform is master of fsync
+	bclk   "codec_slave"	# platform is master of bit clock (codec is slave)
+	fsync  "codec_slave"	# platform is master of fsync (codec is slave)
 }
 
 SectionLink."Codec" {
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index bb47b9af..d0395182 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -1141,8 +1141,19 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
 			if (snd_config_get_string(n, &val) < 0)
 				return -EINVAL;
 
-			if (!strcmp(val, "master"))
-				hw_cfg->bclk_master = true;
+			if (!strcmp(val, "master")) {
+				/* For backwards capability,
+				 * "master" == "codec is slave"
+				 */
+				SNDERR("warning: deprecated bclk value '%s'\n",
+				       val);
+
+				hw_cfg->bclk_master = SND_SOC_TPLG_BCLK_CS;
+			} else if (!strcmp(val, "codec_slave")) {
+				hw_cfg->bclk_master = SND_SOC_TPLG_BCLK_CS;
+			} else if (!strcmp(val, "codec_master")) {
+				hw_cfg->bclk_master = SND_SOC_TPLG_BCLK_CM;
+			}
 			continue;
 		}
 
@@ -1167,8 +1178,19 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
 			if (snd_config_get_string(n, &val) < 0)
 				return -EINVAL;
 
-			if (!strcmp(val, "master"))
-				hw_cfg->fsync_master = true;
+			if (!strcmp(val, "master")) {
+				/* For backwards capability,
+				 * "master" == "codec is slave"
+				 */
+				SNDERR("warning: deprecated fsync value '%s'\n",
+				       val);
+
+				hw_cfg->fsync_master = SND_SOC_TPLG_FSYNC_CS;
+			} else if (!strcmp(val, "codec_slave")) {
+				hw_cfg->fsync_master = SND_SOC_TPLG_FSYNC_CS;
+			} else if (!strcmp(val, "codec_master")) {
+				hw_cfg->fsync_master = SND_SOC_TPLG_FSYNC_CM;
+			}
 			continue;
 		}
 
-- 
2.13.6

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

* [PATCH, alsa-lib, v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
@ 2018-03-27 21:00     ` Kirill Marinushkin
  0 siblings, 0 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-03-27 21:00 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Mark Brown
  Cc: alsa-devel, Pan Xiuli, Pierre-Louis Bossart, linux-kernel,
	Liam Girdwood, Kirill Marinushkin

The values of bclk and fsync are inverted WRT the codec. But the existing
solution already works for Broadwell, see the alsa-lib config:

`alsa-lib/src/conf/topology/broadwell/broadwell.conf`

This commit provides the backwards-compatible solution to fix this misuse.
This commit goes in pair with the corresponding patch for linux.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Tested-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org
---
 include/sound/asoc.h                       | 16 ++++++++++++++--
 include/topology.h                         |  4 ++--
 src/conf/topology/broadwell/broadwell.conf |  4 ++--
 src/topology/pcm.c                         | 30 ++++++++++++++++++++++++++----
 4 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/include/sound/asoc.h b/include/sound/asoc.h
index 0f5d9f9a..89b00703 100644
--- a/include/sound/asoc.h
+++ b/include/sound/asoc.h
@@ -156,6 +156,18 @@
 #define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS    (1 << 2)
 #define SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP            (1 << 3)
 
+/* DAI topology BCLK parameter
+ * For the backwards capability, by default codec is bclk master
+ */
+#define SND_SOC_TPLG_BCLK_CM         0 /* codec is bclk master */
+#define SND_SOC_TPLG_BCLK_CS         1 /* codec is bclk slave */
+
+/* DAI topology FSYNC parameter
+ * For the backwards capability, by default codec is fsync master
+ */
+#define SND_SOC_TPLG_FSYNC_CM         0 /* codec is fsync master */
+#define SND_SOC_TPLG_FSYNC_CS         1 /* codec is fsync slave */
+
 /*
  * Block Header.
  * This header precedes all object and object arrays below.
@@ -311,8 +323,8 @@ struct snd_soc_tplg_hw_config {
 	__u8 clock_gated;	/* 1 if clock can be gated to save power */
 	__u8 invert_bclk;	/* 1 for inverted BCLK, 0 for normal */
 	__u8 invert_fsync;	/* 1 for inverted frame clock, 0 for normal */
-	__u8 bclk_master;	/* 1 for master of BCLK, 0 for slave */
-	__u8 fsync_master;	/* 1 for master of FSYNC, 0 for slave */
+	__u8 bclk_master;	/* SND_SOC_TPLG_BCLK_ value */
+	__u8 fsync_master;	/* SND_SOC_TPLG_FSYNC_ value */
 	__u8 mclk_direction;    /* 0 for input, 1 for output */
 	__le16 reserved;	/* for 32bit alignment */
 	__le32 mclk_rate;	/* MCLK or SYSCLK freqency in Hz */
diff --git a/include/topology.h b/include/topology.h
index 8779da4d..5d7b46df 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -1000,8 +1000,8 @@ struct snd_tplg_hw_config_template {
 	unsigned char clock_gated;      /* 1 if clock can be gated to save power */
 	unsigned char  invert_bclk;     /* 1 for inverted BCLK, 0 for normal */
 	unsigned char  invert_fsync;    /* 1 for inverted frame clock, 0 for normal */
-	unsigned char  bclk_master;     /* 1 for master of BCLK, 0 for slave */
-	unsigned char  fsync_master;    /* 1 for master of FSYNC, 0 for slave */
+	unsigned char  bclk_master;     /* SND_SOC_TPLG_BCLK_ value */
+	unsigned char  fsync_master;    /* SND_SOC_TPLG_FSYNC_ value */
 	unsigned char  mclk_direction;  /* 0 for input, 1 for output */
 	unsigned short reserved;        /* for 32bit alignment */
 	unsigned int mclk_rate;	        /* MCLK or SYSCLK freqency in Hz */
diff --git a/src/conf/topology/broadwell/broadwell.conf b/src/conf/topology/broadwell/broadwell.conf
index b8405d93..09fc4daa 100644
--- a/src/conf/topology/broadwell/broadwell.conf
+++ b/src/conf/topology/broadwell/broadwell.conf
@@ -393,8 +393,8 @@ SectionGraph."dsp" {
 SectionHWConfig."CodecHWConfig" {
 	id "1"
 	format "I2S"		# physical audio format.
-	bclk   "master"		# Platform is master of bit clock
-	fsync  "master"		# platform is master of fsync
+	bclk   "codec_slave"	# platform is master of bit clock (codec is slave)
+	fsync  "codec_slave"	# platform is master of fsync (codec is slave)
 }
 
 SectionLink."Codec" {
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index bb47b9af..d0395182 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -1141,8 +1141,19 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
 			if (snd_config_get_string(n, &val) < 0)
 				return -EINVAL;
 
-			if (!strcmp(val, "master"))
-				hw_cfg->bclk_master = true;
+			if (!strcmp(val, "master")) {
+				/* For backwards capability,
+				 * "master" == "codec is slave"
+				 */
+				SNDERR("warning: deprecated bclk value '%s'\n",
+				       val);
+
+				hw_cfg->bclk_master = SND_SOC_TPLG_BCLK_CS;
+			} else if (!strcmp(val, "codec_slave")) {
+				hw_cfg->bclk_master = SND_SOC_TPLG_BCLK_CS;
+			} else if (!strcmp(val, "codec_master")) {
+				hw_cfg->bclk_master = SND_SOC_TPLG_BCLK_CM;
+			}
 			continue;
 		}
 
@@ -1167,8 +1178,19 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
 			if (snd_config_get_string(n, &val) < 0)
 				return -EINVAL;
 
-			if (!strcmp(val, "master"))
-				hw_cfg->fsync_master = true;
+			if (!strcmp(val, "master")) {
+				/* For backwards capability,
+				 * "master" == "codec is slave"
+				 */
+				SNDERR("warning: deprecated fsync value '%s'\n",
+				       val);
+
+				hw_cfg->fsync_master = SND_SOC_TPLG_FSYNC_CS;
+			} else if (!strcmp(val, "codec_slave")) {
+				hw_cfg->fsync_master = SND_SOC_TPLG_FSYNC_CS;
+			} else if (!strcmp(val, "codec_master")) {
+				hw_cfg->fsync_master = SND_SOC_TPLG_FSYNC_CM;
+			}
 			continue;
 		}
 
-- 
2.13.6

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

* [PATCH, alsa-lib, v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs
  2018-03-27 21:00 ` [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
  2018-03-27 21:00     ` Kirill Marinushkin
@ 2018-03-27 21:00   ` Kirill Marinushkin
  1 sibling, 0 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-03-27 21:00 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Mark Brown
  Cc: Pan Xiuli, Pierre-Louis Bossart, Liam Girdwood, linux-kernel,
	alsa-devel, Kirill Marinushkin

Clock gating parameter is a part of `dai_fmt`. It is supported by
`alsa-lib` when creating a topology binary file, but ignored by kernel
when loading this topology file.

After applying this commit, the clock gating parameter is not ignored any
more. This solution is backwards compatible. The existing behaviour is
not broken, because by default the parameter value is 0 and is ignored.

snd_soc_tplg_hw_config.clock_gated = 0 => no effect
snd_soc_tplg_hw_config.clock_gated = 1 => SND_SOC_DAIFMT_GATED
snd_soc_tplg_hw_config.clock_gated = 2 => SND_SOC_DAIFMT_CONT

For example, the following config, based on
alsa-lib/src/conf/topology/broadwell/broadwell.conf, is now supported:

~~~~
SectionHWConfig."CodecHWConfig" {
        id "1"
        format "I2S"            # physical audio format.
        pm_gate_clocks "true"   # clock can be gated
}

SectionLink."Codec" {

        # used for binding to the physical link
        id "0"

        hw_configs [
                "CodecHWConfig"
        ]

        default_hw_conf_id "1"
}
~~~~

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pan Xiuli <xiuli.pan@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org
---
 include/sound/asoc.h | 7 ++++++-
 include/topology.h   | 2 +-
 src/topology/pcm.c   | 6 +++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/sound/asoc.h b/include/sound/asoc.h
index 89b00703..297e837c 100644
--- a/include/sound/asoc.h
+++ b/include/sound/asoc.h
@@ -135,6 +135,11 @@
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS      (1 << 1)
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS    (1 << 2)
 
+/* DAI clock gating */
+#define SND_SOC_TPLG_DAI_CLK_GATE_UNDEFINED	0
+#define SND_SOC_TPLG_DAI_CLK_GATE_GATED	1
+#define SND_SOC_TPLG_DAI_CLK_GATE_CONT		2
+
 /* DAI physical PCM data formats.
  * Add new formats to the end of the list.
  */
@@ -320,7 +325,7 @@ struct snd_soc_tplg_hw_config {
 	__le32 size;            /* in bytes of this structure */
 	__le32 id;		/* unique ID - - used to match */
 	__le32 fmt;		/* SND_SOC_DAI_FORMAT_ format value */
-	__u8 clock_gated;	/* 1 if clock can be gated to save power */
+	__u8 clock_gated;	/* SND_SOC_TPLG_DAI_CLK_GATE_ value */
 	__u8 invert_bclk;	/* 1 for inverted BCLK, 0 for normal */
 	__u8 invert_fsync;	/* 1 for inverted frame clock, 0 for normal */
 	__u8 bclk_master;	/* SND_SOC_TPLG_BCLK_ value */
diff --git a/include/topology.h b/include/topology.h
index 5d7b46df..3793115c 100644
--- a/include/topology.h
+++ b/include/topology.h
@@ -997,7 +997,7 @@ struct snd_tplg_pcm_template {
 struct snd_tplg_hw_config_template {
 	int id;                         /* unique ID - - used to match */
 	unsigned int fmt;               /* SND_SOC_DAI_FORMAT_ format value */
-	unsigned char clock_gated;      /* 1 if clock can be gated to save power */
+	unsigned char clock_gated;      /* SND_SOC_TPLG_DAI_CLK_GATE_ value */
 	unsigned char  invert_bclk;     /* 1 for inverted BCLK, 0 for normal */
 	unsigned char  invert_fsync;    /* 1 for inverted frame clock, 0 for normal */
 	unsigned char  bclk_master;     /* SND_SOC_TPLG_BCLK_ value */
diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index d0395182..b53f6b03 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -1233,7 +1233,11 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg,
 				return -EINVAL;
 
 			if (!strcmp(val, "true"))
-				hw_cfg->clock_gated = true;
+				hw_cfg->clock_gated =
+					SND_SOC_TPLG_DAI_CLK_GATE_GATED;
+			else
+				hw_cfg->clock_gated =
+					SND_SOC_TPLG_DAI_CLK_GATE_CONT;
 			continue;
 		}
 
-- 
2.13.6

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

* Re: [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
  2018-03-27 20:56 [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
                   ` (2 preceding siblings ...)
  2018-03-27 21:00 ` [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
@ 2018-04-02 21:17 ` Kirill Marinushkin
  2018-04-03  0:57   ` Pierre-Louis Bossart
  3 siblings, 1 reply; 23+ messages in thread
From: Kirill Marinushkin @ 2018-04-02 21:17 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Jaroslav Kysela, Takashi Iwai, Mark Brown, Pan Xiuli,
	Liam Girdwood, linux-kernel, alsa-devel

Hello Pierre-Louis,

I explicitly clarified with Takashi: to have this patch series merged, we need a
tag "Reviewed-by" from you.

Patches [2] and [5]:
You already tested them. May I put a tag "Reviewed-by" with your name into them?

Patches [3] and [6]:
Those are new for you; I added them to this patch series, because they are
logically similar to [2] and [5].
Could you please review these patches?

Best Regards,
Kirill

[1] [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
[2] [PATCH v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
[3] [PATCH v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs
[4] [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing hw_configs
[5] [PATCH, alsa-lib, v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
[6] [PATCH, alsa-lib, v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs


On 03/27/18 22:56, Kirill Marinushkin wrote:
> Hello Jaroslav, Takashi, Mark,
>
> This patch series is a resend of [1] and [2], rebased on top of the latest
> head. It was logical to resend them together.
>
> It includes 2 patches for linux + 2 patches for alsa-lib.
>
> Please have a look.
>
> Best Regards,
> Kirill
>
> [1] https://patchwork.kernel.org/patch/10250485/
> [2] https://patchwork.kernel.org/patch/10230611/
>
> Kirill Marinushkin (2):
>   ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
>   ASoC: topology: Add missing clock gating parameter when parsing
>     hw_configs
>
>  include/uapi/sound/asoc.h | 23 ++++++++++++++++++++---
>  sound/soc/soc-topology.c  | 19 ++++++++++++++-----
>  2 files changed, 34 insertions(+), 8 deletions(-)
>

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

* Re: [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
  2018-04-02 21:17 ` [PATCH v3 0/2] ASoC: topology: Improve " Kirill Marinushkin
@ 2018-04-03  0:57   ` Pierre-Louis Bossart
  2018-04-03  5:15       ` Kirill Marinushkin
  0 siblings, 1 reply; 23+ messages in thread
From: Pierre-Louis Bossart @ 2018-04-03  0:57 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: Jaroslav Kysela, Takashi Iwai, Mark Brown, Pan Xiuli,
	Liam Girdwood, linux-kernel, alsa-devel



On 04/02/2018 04:17 PM, Kirill Marinushkin wrote:
> Hello Pierre-Louis,
>
> I explicitly clarified with Takashi: to have this patch series merged, we need a
> tag "Reviewed-by" from you.
I am fine with the changes, but maybe while we are at it, we should 
clarify what mclk_direction means?

     __u8 mclk_direction;    /* 0 for input, 1 for output */

This is really awful and might benefit for additional clarity using 
codec-centric conventions.

We also had a discussion internally and can't figure out why the strings 
are different from the fields in the structure, I feel it'd be simpler 
to align config and code to avoid issues but keep existing notation for 
backwards compatibility, e.g.

if (strcmp(id, "mclk_freq") == 0) || strcmp(id, "mclk_rate") == 0) {
         if (snd_config_get_string(n, &val) < 0)
                 return -EINVAL;

             hw_cfg->mclk_rate = atoi(val);
             continue;
}
>
> Patches [2] and [5]:
> You already tested them. May I put a tag "Reviewed-by" with your name into them?
>
> Patches [3] and [6]:
> Those are new for you; I added them to this patch series, because they are
> logically similar to [2] and [5].
> Could you please review these patches?
>
> Best Regards,
> Kirill
>
> [1] [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
> [2] [PATCH v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
> [3] [PATCH v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs
> [4] [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing hw_configs
> [5] [PATCH, alsa-lib, v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
> [6] [PATCH, alsa-lib, v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs
>
>
> On 03/27/18 22:56, Kirill Marinushkin wrote:
>> Hello Jaroslav, Takashi, Mark,
>>
>> This patch series is a resend of [1] and [2], rebased on top of the latest
>> head. It was logical to resend them together.
>>
>> It includes 2 patches for linux + 2 patches for alsa-lib.
>>
>> Please have a look.
>>
>> Best Regards,
>> Kirill
>>
>> [1] https://patchwork.kernel.org/patch/10250485/
>> [2] https://patchwork.kernel.org/patch/10230611/
>>
>> Kirill Marinushkin (2):
>>    ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
>>    ASoC: topology: Add missing clock gating parameter when parsing
>>      hw_configs
>>
>>   include/uapi/sound/asoc.h | 23 ++++++++++++++++++++---
>>   sound/soc/soc-topology.c  | 19 ++++++++++++++-----
>>   2 files changed, 34 insertions(+), 8 deletions(-)
>>

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

* Re: [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
  2018-04-03  0:57   ` Pierre-Louis Bossart
@ 2018-04-03  5:15       ` Kirill Marinushkin
  0 siblings, 0 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-04-03  5:15 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Jaroslav Kysela, Takashi Iwai, Mark Brown, Pan Xiuli,
	Liam Girdwood, linux-kernel, alsa-devel

On 04/03/18 02:57, Pierre-Louis Bossart wrote:
>
>
> On 04/02/2018 04:17 PM, Kirill Marinushkin wrote:
>> Hello Pierre-Louis,
>>
>> I explicitly clarified with Takashi: to have this patch series merged, we need a
>> tag "Reviewed-by" from you.
> I am fine with the changes, but maybe while we are at it, we should clarify
> what mclk_direction means?

That's a good idea to have it solved within this patch series.

>
>     __u8 mclk_direction;    /* 0 for input, 1 for output */
>
> This is really awful and might benefit for additional clarity using
> codec-centric conventions.
>

I agree that having a clear naming will avoid confusion for future usage.
I see from the code, that this variable is ignored. So we have no technical
restriction on how to interpret this.
I suggest to do similar to what we did for bclk_master:

/* DAI mclk_direction */
#define SND_SOC_TPLG_MCLK_CO        0 /* for codec, mclk is output */
#define SND_SOC_TPLG_MCLK_CI          1 /* for codec, mclk is input */

> We also had a discussion internally and can't figure out why the strings are
> different from the fields in the structure, I feel it'd be simpler to align
> config and code to avoid issues but keep existing notation for backwards
> compatibility, e.g.
>
> if (strcmp(id, "mclk_freq") == 0) || strcmp(id, "mclk_rate") == 0) {
>         if (snd_config_get_string(n, &val) < 0)
>                 return -EINVAL;
>
>             hw_cfg->mclk_rate = atoi(val);
>             continue;
> }

I agree with this. I will also do the same (keeping backwards-compatibility) for:

"format" => "fmt"
"bclk" => "bclk_master"
"bclk_freq" => "bclk_rate"
"bclk_invert" => "invert_bclk"
"fsync" => "fsync_master"
"fsync_invert" => "invert_fsync"
"fsync_freq" => "fsync_rate"
"mclk_freq" => "mclk_rate"
"mclk" => "mclk_direction"
"pm_gate_clocks" => "clock_gated"

If you agree with both proposals, I will add patches to this patch series, and
re-send as patch v4.
Or can we handle it in a better way?

>>
>> Patches [2] and [5]:
>> You already tested them. May I put a tag "Reviewed-by" with your name into them?
>>
>> Patches [3] and [6]:
>> Those are new for you; I added them to this patch series, because they are
>> logically similar to [2] and [5].
>> Could you please review these patches?
>>
>> Best Regards,
>> Kirill
>>
>> [1] [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
>> [2] [PATCH v3 1/2] ASoC: topology: Fix bclk and fsync inversion in
>> set_link_hw_format()
>> [3] [PATCH v3 2/2] ASoC: topology: Add missing clock gating parameter when
>> parsing hw_configs
>> [4] [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing
>> hw_configs
>> [5] [PATCH, alsa-lib, v3 1/2] ASoC: topology: Fix bclk and fsync inversion in
>> set_link_hw_format()
>> [6] [PATCH, alsa-lib, v3 2/2] ASoC: topology: Add missing clock gating
>> parameter when parsing hw_configs
>>
>>
>> On 03/27/18 22:56, Kirill Marinushkin wrote:
>>> Hello Jaroslav, Takashi, Mark,
>>>
>>> This patch series is a resend of [1] and [2], rebased on top of the latest
>>> head. It was logical to resend them together.
>>>
>>> It includes 2 patches for linux + 2 patches for alsa-lib.
>>>
>>> Please have a look.
>>>
>>> Best Regards,
>>> Kirill
>>>
>>> [1] https://patchwork.kernel.org/patch/10250485/
>>> [2] https://patchwork.kernel.org/patch/10230611/
>>>
>>> Kirill Marinushkin (2):
>>>    ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
>>>    ASoC: topology: Add missing clock gating parameter when parsing
>>>      hw_configs
>>>
>>>   include/uapi/sound/asoc.h | 23 ++++++++++++++++++++---
>>>   sound/soc/soc-topology.c  | 19 ++++++++++++++-----
>>>   2 files changed, 34 insertions(+), 8 deletions(-)
>>>
>

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

* Re: [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
@ 2018-04-03  5:15       ` Kirill Marinushkin
  0 siblings, 0 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-04-03  5:15 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: alsa-devel, Takashi Iwai, Pan Xiuli, linux-kernel, Liam Girdwood,
	Mark Brown

On 04/03/18 02:57, Pierre-Louis Bossart wrote:
>
>
> On 04/02/2018 04:17 PM, Kirill Marinushkin wrote:
>> Hello Pierre-Louis,
>>
>> I explicitly clarified with Takashi: to have this patch series merged, we need a
>> tag "Reviewed-by" from you.
> I am fine with the changes, but maybe while we are at it, we should clarify
> what mclk_direction means?

That's a good idea to have it solved within this patch series.

>
>     __u8 mclk_direction;    /* 0 for input, 1 for output */
>
> This is really awful and might benefit for additional clarity using
> codec-centric conventions.
>

I agree that having a clear naming will avoid confusion for future usage.
I see from the code, that this variable is ignored. So we have no technical
restriction on how to interpret this.
I suggest to do similar to what we did for bclk_master:

/* DAI mclk_direction */
#define SND_SOC_TPLG_MCLK_CO        0 /* for codec, mclk is output */
#define SND_SOC_TPLG_MCLK_CI          1 /* for codec, mclk is input */

> We also had a discussion internally and can't figure out why the strings are
> different from the fields in the structure, I feel it'd be simpler to align
> config and code to avoid issues but keep existing notation for backwards
> compatibility, e.g.
>
> if (strcmp(id, "mclk_freq") == 0) || strcmp(id, "mclk_rate") == 0) {
>         if (snd_config_get_string(n, &val) < 0)
>                 return -EINVAL;
>
>             hw_cfg->mclk_rate = atoi(val);
>             continue;
> }

I agree with this. I will also do the same (keeping backwards-compatibility) for:

"format" => "fmt"
"bclk" => "bclk_master"
"bclk_freq" => "bclk_rate"
"bclk_invert" => "invert_bclk"
"fsync" => "fsync_master"
"fsync_invert" => "invert_fsync"
"fsync_freq" => "fsync_rate"
"mclk_freq" => "mclk_rate"
"mclk" => "mclk_direction"
"pm_gate_clocks" => "clock_gated"

If you agree with both proposals, I will add patches to this patch series, and
re-send as patch v4.
Or can we handle it in a better way?

>>
>> Patches [2] and [5]:
>> You already tested them. May I put a tag "Reviewed-by" with your name into them?
>>
>> Patches [3] and [6]:
>> Those are new for you; I added them to this patch series, because they are
>> logically similar to [2] and [5].
>> Could you please review these patches?
>>
>> Best Regards,
>> Kirill
>>
>> [1] [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
>> [2] [PATCH v3 1/2] ASoC: topology: Fix bclk and fsync inversion in
>> set_link_hw_format()
>> [3] [PATCH v3 2/2] ASoC: topology: Add missing clock gating parameter when
>> parsing hw_configs
>> [4] [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing
>> hw_configs
>> [5] [PATCH, alsa-lib, v3 1/2] ASoC: topology: Fix bclk and fsync inversion in
>> set_link_hw_format()
>> [6] [PATCH, alsa-lib, v3 2/2] ASoC: topology: Add missing clock gating
>> parameter when parsing hw_configs
>>
>>
>> On 03/27/18 22:56, Kirill Marinushkin wrote:
>>> Hello Jaroslav, Takashi, Mark,
>>>
>>> This patch series is a resend of [1] and [2], rebased on top of the latest
>>> head. It was logical to resend them together.
>>>
>>> It includes 2 patches for linux + 2 patches for alsa-lib.
>>>
>>> Please have a look.
>>>
>>> Best Regards,
>>> Kirill
>>>
>>> [1] https://patchwork.kernel.org/patch/10250485/
>>> [2] https://patchwork.kernel.org/patch/10230611/
>>>
>>> Kirill Marinushkin (2):
>>>    ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
>>>    ASoC: topology: Add missing clock gating parameter when parsing
>>>      hw_configs
>>>
>>>   include/uapi/sound/asoc.h | 23 ++++++++++++++++++++---
>>>   sound/soc/soc-topology.c  | 19 ++++++++++++++-----
>>>   2 files changed, 34 insertions(+), 8 deletions(-)
>>>
>

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [alsa-devel] [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
  2018-04-03  5:15       ` Kirill Marinushkin
  (?)
@ 2018-04-03 17:21       ` Pierre-Louis Bossart
  2018-04-03 18:16         ` Kirill Marinushkin
  -1 siblings, 1 reply; 23+ messages in thread
From: Pierre-Louis Bossart @ 2018-04-03 17:21 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: alsa-devel, Takashi Iwai, Pan Xiuli, linux-kernel, Liam Girdwood,
	Mark Brown



On 04/03/2018 12:15 AM, Kirill Marinushkin wrote:
> On 04/03/18 02:57, Pierre-Louis Bossart wrote:
>>
>> On 04/02/2018 04:17 PM, Kirill Marinushkin wrote:
>>> Hello Pierre-Louis,
>>>
>>> I explicitly clarified with Takashi: to have this patch series merged, we need a
>>> tag "Reviewed-by" from you.
>> I am fine with the changes, but maybe while we are at it, we should clarify
>> what mclk_direction means?
> That's a good idea to have it solved within this patch series.
>
>>      __u8 mclk_direction;    /* 0 for input, 1 for output */
>>
>> This is really awful and might benefit for additional clarity using
>> codec-centric conventions.
>>
> I agree that having a clear naming will avoid confusion for future usage.
> I see from the code, that this variable is ignored. So we have no technical
> restriction on how to interpret this.
> I suggest to do similar to what we did for bclk_master:
>
> /* DAI mclk_direction */
> #define SND_SOC_TPLG_MCLK_CO        0 /* for codec, mclk is output */
> #define SND_SOC_TPLG_MCLK_CI          1 /* for codec, mclk is input */
>
>> We also had a discussion internally and can't figure out why the strings are
>> different from the fields in the structure, I feel it'd be simpler to align
>> config and code to avoid issues but keep existing notation for backwards
>> compatibility, e.g.
>>
>> if (strcmp(id, "mclk_freq") == 0) || strcmp(id, "mclk_rate") == 0) {
>>          if (snd_config_get_string(n, &val) < 0)
>>                  return -EINVAL;
>>
>>              hw_cfg->mclk_rate = atoi(val);
>>              continue;
>> }
> I agree with this. I will also do the same (keeping backwards-compatibility) for:
>
> "format" => "fmt"
> "bclk" => "bclk_master"
> "bclk_freq" => "bclk_rate"
> "bclk_invert" => "invert_bclk"
> "fsync" => "fsync_master"
> "fsync_invert" => "invert_fsync"
> "fsync_freq" => "fsync_rate"
> "mclk_freq" => "mclk_rate"
> "mclk" => "mclk_direction"
> "pm_gate_clocks" => "clock_gated"
>
> If you agree with both proposals, I will add patches to this patch series, and
> re-send as patch v4.
> Or can we handle it in a better way?
A v4 is fine with me.

These topology definitions appear in hindsight quite problematic, there 
are missing definitions and capabilities, e.g we have the ability to 
'gate the clock' but without knowing which clock, and we have no ability 
to force the mclk/bclk/fsync on (be it on demand from a codec driver or 
on startup as a system requirement). And there is no real extension 
capability with a protocol version. The net effect is that people will 
have to create custom tokens and parsing for things that should be common...

Thanks
-Pierre

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

* Re: [alsa-devel] [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
  2018-04-03 17:21       ` [alsa-devel] " Pierre-Louis Bossart
@ 2018-04-03 18:16         ` Kirill Marinushkin
  2018-04-03 19:19             ` Pierre-Louis Bossart
  0 siblings, 1 reply; 23+ messages in thread
From: Kirill Marinushkin @ 2018-04-03 18:16 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: alsa-devel, Takashi Iwai, Pan Xiuli, linux-kernel, Liam Girdwood,
	Mark Brown

On 04/03/18 19:21, Pierre-Louis Bossart wrote:
>
>
> On 04/03/2018 12:15 AM, Kirill Marinushkin wrote:
>> On 04/03/18 02:57, Pierre-Louis Bossart wrote:
>>>
>>> On 04/02/2018 04:17 PM, Kirill Marinushkin wrote:
>>>> Hello Pierre-Louis,
>>>>
>>>> I explicitly clarified with Takashi: to have this patch series merged, we
>>>> need a
>>>> tag "Reviewed-by" from you.
>>> I am fine with the changes, but maybe while we are at it, we should clarify
>>> what mclk_direction means?
>> That's a good idea to have it solved within this patch series.
>>
>>>      __u8 mclk_direction;    /* 0 for input, 1 for output */
>>>
>>> This is really awful and might benefit for additional clarity using
>>> codec-centric conventions.
>>>
>> I agree that having a clear naming will avoid confusion for future usage.
>> I see from the code, that this variable is ignored. So we have no technical
>> restriction on how to interpret this.
>> I suggest to do similar to what we did for bclk_master:
>>
>> /* DAI mclk_direction */
>> #define SND_SOC_TPLG_MCLK_CO        0 /* for codec, mclk is output */
>> #define SND_SOC_TPLG_MCLK_CI          1 /* for codec, mclk is input */
>>
>>> We also had a discussion internally and can't figure out why the strings are
>>> different from the fields in the structure, I feel it'd be simpler to align
>>> config and code to avoid issues but keep existing notation for backwards
>>> compatibility, e.g.
>>>
>>> if (strcmp(id, "mclk_freq") == 0) || strcmp(id, "mclk_rate") == 0) {
>>>          if (snd_config_get_string(n, &val) < 0)
>>>                  return -EINVAL;
>>>
>>>              hw_cfg->mclk_rate = atoi(val);
>>>              continue;
>>> }
>> I agree with this. I will also do the same (keeping backwards-compatibility)
>> for:
>>
>> "format" => "fmt"
>> "bclk" => "bclk_master"
>> "bclk_freq" => "bclk_rate"
>> "bclk_invert" => "invert_bclk"
>> "fsync" => "fsync_master"
>> "fsync_invert" => "invert_fsync"
>> "fsync_freq" => "fsync_rate"
>> "mclk_freq" => "mclk_rate"
>> "mclk" => "mclk_direction"
>> "pm_gate_clocks" => "clock_gated"
>>
>> If you agree with both proposals, I will add patches to this patch series, and
>> re-send as patch v4.
>> Or can we handle it in a better way?
> A v4 is fine with me.
>
> These topology definitions appear in hindsight quite problematic, there are
> missing definitions and capabilities, e.g we have the ability to 'gate the
> clock' but without knowing which clock, and we have no ability to force the
> mclk/bclk/fsync on (be it on demand from a codec driver or on startup as a
> system requirement). And there is no real extension capability with a protocol
> version. The net effect is that people will have to create custom tokens and
> parsing for things that should be common...
>

Yes, definitions which you mentioned really can become a problem.
But, I see from the header that topology files support versioning:

~~~~
#define SND_SOC_TPLG_ABI_VERSION    0x5    /* current version */
~~~~

So, in future such problems can be solved by incrementing the version, if no
backwards capabilities are available.




Before I continue with the patch v4, I want to clarify with you, so that we
avoid the misunderstanding:

* in the existing 4 patches, I will add a tag
  "Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>"
* in the new 2 patches, which we recently discussed, I will add a tag
  "Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>"

Do you agree with that?

Best Regards,
Kirill

> Thanks
> -Pierre

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

* Re: [alsa-devel] [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
  2018-04-03 18:16         ` Kirill Marinushkin
@ 2018-04-03 19:19             ` Pierre-Louis Bossart
  0 siblings, 0 replies; 23+ messages in thread
From: Pierre-Louis Bossart @ 2018-04-03 19:19 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: alsa-devel, Takashi Iwai, Pan Xiuli, linux-kernel, Liam Girdwood,
	Mark Brown

On 4/3/18 1:16 PM, Kirill Marinushkin wrote:
> On 04/03/18 19:21, Pierre-Louis Bossart wrote:
>>
>>
>> On 04/03/2018 12:15 AM, Kirill Marinushkin wrote:
>>> On 04/03/18 02:57, Pierre-Louis Bossart wrote:
>>>>
>>>> On 04/02/2018 04:17 PM, Kirill Marinushkin wrote:
>>>>> Hello Pierre-Louis,
>>>>>
>>>>> I explicitly clarified with Takashi: to have this patch series merged, we
>>>>> need a
>>>>> tag "Reviewed-by" from you.
>>>> I am fine with the changes, but maybe while we are at it, we should clarify
>>>> what mclk_direction means?
>>> That's a good idea to have it solved within this patch series.
>>>
>>>>       __u8 mclk_direction;    /* 0 for input, 1 for output */
>>>>
>>>> This is really awful and might benefit for additional clarity using
>>>> codec-centric conventions.
>>>>
>>> I agree that having a clear naming will avoid confusion for future usage.
>>> I see from the code, that this variable is ignored. So we have no technical
>>> restriction on how to interpret this.
>>> I suggest to do similar to what we did for bclk_master:
>>>
>>> /* DAI mclk_direction */
>>> #define SND_SOC_TPLG_MCLK_CO        0 /* for codec, mclk is output */
>>> #define SND_SOC_TPLG_MCLK_CI          1 /* for codec, mclk is input */
>>>
>>>> We also had a discussion internally and can't figure out why the strings are
>>>> different from the fields in the structure, I feel it'd be simpler to align
>>>> config and code to avoid issues but keep existing notation for backwards
>>>> compatibility, e.g.
>>>>
>>>> if (strcmp(id, "mclk_freq") == 0) || strcmp(id, "mclk_rate") == 0) {
>>>>           if (snd_config_get_string(n, &val) < 0)
>>>>                   return -EINVAL;
>>>>
>>>>               hw_cfg->mclk_rate = atoi(val);
>>>>               continue;
>>>> }
>>> I agree with this. I will also do the same (keeping backwards-compatibility)
>>> for:
>>>
>>> "format" => "fmt"
>>> "bclk" => "bclk_master"
>>> "bclk_freq" => "bclk_rate"
>>> "bclk_invert" => "invert_bclk"
>>> "fsync" => "fsync_master"
>>> "fsync_invert" => "invert_fsync"
>>> "fsync_freq" => "fsync_rate"
>>> "mclk_freq" => "mclk_rate"
>>> "mclk" => "mclk_direction"
>>> "pm_gate_clocks" => "clock_gated"
>>>
>>> If you agree with both proposals, I will add patches to this patch series, and
>>> re-send as patch v4.
>>> Or can we handle it in a better way?
>> A v4 is fine with me.
>>
>> These topology definitions appear in hindsight quite problematic, there are
>> missing definitions and capabilities, e.g we have the ability to 'gate the
>> clock' but without knowing which clock, and we have no ability to force the
>> mclk/bclk/fsync on (be it on demand from a codec driver or on startup as a
>> system requirement). And there is no real extension capability with a protocol
>> version. The net effect is that people will have to create custom tokens and
>> parsing for things that should be common...
>>
> 
> Yes, definitions which you mentioned really can become a problem.
> But, I see from the header that topology files support versioning:
> 
> ~~~~
> #define SND_SOC_TPLG_ABI_VERSION    0x5    /* current version */
> ~~~~
> 
> So, in future such problems can be solved by incrementing the version, if no
> backwards capabilities are available.

Maybe I misunderstood this version number, I thought this was only for 
the initial stages where there was quite a few evolutions in a couple of 
months. If this can be upgraded then we might want to add new 
definitions that we came up with during the SOF work but are of interest 
to others.

> 
> 
> 
> 
> Before I continue with the patch v4, I want to clarify with you, so that we
> avoid the misunderstanding:
> 
> * in the existing 4 patches, I will add a tag
>    "Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>"
> * in the new 2 patches, which we recently discussed, I will add a tag
>    "Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>"
> 
> Do you agree with that?

Yes, that's fine.

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

* Re: [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs
@ 2018-04-03 19:19             ` Pierre-Louis Bossart
  0 siblings, 0 replies; 23+ messages in thread
From: Pierre-Louis Bossart @ 2018-04-03 19:19 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: alsa-devel, Takashi Iwai, Pan Xiuli, linux-kernel, Liam Girdwood,
	Mark Brown

On 4/3/18 1:16 PM, Kirill Marinushkin wrote:
> On 04/03/18 19:21, Pierre-Louis Bossart wrote:
>>
>>
>> On 04/03/2018 12:15 AM, Kirill Marinushkin wrote:
>>> On 04/03/18 02:57, Pierre-Louis Bossart wrote:
>>>>
>>>> On 04/02/2018 04:17 PM, Kirill Marinushkin wrote:
>>>>> Hello Pierre-Louis,
>>>>>
>>>>> I explicitly clarified with Takashi: to have this patch series merged, we
>>>>> need a
>>>>> tag "Reviewed-by" from you.
>>>> I am fine with the changes, but maybe while we are at it, we should clarify
>>>> what mclk_direction means?
>>> That's a good idea to have it solved within this patch series.
>>>
>>>>       __u8 mclk_direction;    /* 0 for input, 1 for output */
>>>>
>>>> This is really awful and might benefit for additional clarity using
>>>> codec-centric conventions.
>>>>
>>> I agree that having a clear naming will avoid confusion for future usage.
>>> I see from the code, that this variable is ignored. So we have no technical
>>> restriction on how to interpret this.
>>> I suggest to do similar to what we did for bclk_master:
>>>
>>> /* DAI mclk_direction */
>>> #define SND_SOC_TPLG_MCLK_CO        0 /* for codec, mclk is output */
>>> #define SND_SOC_TPLG_MCLK_CI          1 /* for codec, mclk is input */
>>>
>>>> We also had a discussion internally and can't figure out why the strings are
>>>> different from the fields in the structure, I feel it'd be simpler to align
>>>> config and code to avoid issues but keep existing notation for backwards
>>>> compatibility, e.g.
>>>>
>>>> if (strcmp(id, "mclk_freq") == 0) || strcmp(id, "mclk_rate") == 0) {
>>>>           if (snd_config_get_string(n, &val) < 0)
>>>>                   return -EINVAL;
>>>>
>>>>               hw_cfg->mclk_rate = atoi(val);
>>>>               continue;
>>>> }
>>> I agree with this. I will also do the same (keeping backwards-compatibility)
>>> for:
>>>
>>> "format" => "fmt"
>>> "bclk" => "bclk_master"
>>> "bclk_freq" => "bclk_rate"
>>> "bclk_invert" => "invert_bclk"
>>> "fsync" => "fsync_master"
>>> "fsync_invert" => "invert_fsync"
>>> "fsync_freq" => "fsync_rate"
>>> "mclk_freq" => "mclk_rate"
>>> "mclk" => "mclk_direction"
>>> "pm_gate_clocks" => "clock_gated"
>>>
>>> If you agree with both proposals, I will add patches to this patch series, and
>>> re-send as patch v4.
>>> Or can we handle it in a better way?
>> A v4 is fine with me.
>>
>> These topology definitions appear in hindsight quite problematic, there are
>> missing definitions and capabilities, e.g we have the ability to 'gate the
>> clock' but without knowing which clock, and we have no ability to force the
>> mclk/bclk/fsync on (be it on demand from a codec driver or on startup as a
>> system requirement). And there is no real extension capability with a protocol
>> version. The net effect is that people will have to create custom tokens and
>> parsing for things that should be common...
>>
> 
> Yes, definitions which you mentioned really can become a problem.
> But, I see from the header that topology files support versioning:
> 
> ~~~~
> #define SND_SOC_TPLG_ABI_VERSION    0x5    /* current version */
> ~~~~
> 
> So, in future such problems can be solved by incrementing the version, if no
> backwards capabilities are available.

Maybe I misunderstood this version number, I thought this was only for 
the initial stages where there was quite a few evolutions in a couple of 
months. If this can be upgraded then we might want to add new 
definitions that we came up with during the SOF work but are of interest 
to others.

> 
> 
> 
> 
> Before I continue with the patch v4, I want to clarify with you, so that we
> avoid the misunderstanding:
> 
> * in the existing 4 patches, I will add a tag
>    "Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>"
> * in the new 2 patches, which we recently discussed, I will add a tag
>    "Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>"
> 
> Do you agree with that?

Yes, that's fine.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree
  2018-03-27 20:56 ` [PATCH v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs Kirill Marinushkin
@ 2018-04-16 17:15     ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2018-04-16 17:15 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: Jaroslav Kysela, Takashi Iwai, Mark Brown, Pan Xiuli,
	Liam Girdwood, linux-kernel, alsa-devel, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Mark Brown, alsa-devel, Pan Xiuli,
	Pierre-Louis Bossart, linux-kernel, Liam Girdwood, alsa-devel

The patch

   ASoC: topology: Add missing clock gating parameter when parsing hw_configs

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 933e1c4a667103c4d10ebdc9505a0a6abd8c3fbd Mon Sep 17 00:00:00 2001
From: Kirill Marinushkin <k.marinushkin@gmail.com>
Date: Wed, 4 Apr 2018 06:19:38 +0200
Subject: [PATCH] ASoC: topology: Add missing clock gating parameter when
 parsing hw_configs

Clock gating parameter is a part of `dai_fmt`. It is supported by
`alsa-lib` when creating a topology binary file, but ignored by kernel
when loading this topology file.

After applying this commit, the clock gating parameter is not ignored any
more. This solution is backwards compatible. The existing behaviour is
not broken, because by default the parameter value is 0 and is ignored.

snd_soc_tplg_hw_config.clock_gated = 0 => no effect
snd_soc_tplg_hw_config.clock_gated = 1 => SND_SOC_DAIFMT_GATED
snd_soc_tplg_hw_config.clock_gated = 2 => SND_SOC_DAIFMT_CONT

For example, the following config, based on
alsa-lib/src/conf/topology/broadwell/broadwell.conf, is now supported:

~~~~
SectionHWConfig."CodecHWConfig" {
        id "1"
        format "I2S"            # physical audio format.
        pm_gate_clocks "true"   # clock can be gated
}

SectionLink."Codec" {

        # used for binding to the physical link
        id "0"

        hw_configs [
                "CodecHWConfig"
        ]

        default_hw_conf_id "1"
}
~~~~

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pan Xiuli <xiuli.pan@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/uapi/sound/asoc.h | 7 ++++++-
 sound/soc/soc-topology.c  | 7 +++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index f0e5e21efa54..f3c4b46e39d8 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -139,6 +139,11 @@
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS      (1 << 1)
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS    (1 << 2)
 
+/* DAI clock gating */
+#define SND_SOC_TPLG_DAI_CLK_GATE_UNDEFINED	0
+#define SND_SOC_TPLG_DAI_CLK_GATE_GATED	1
+#define SND_SOC_TPLG_DAI_CLK_GATE_CONT		2
+
 /* DAI physical PCM data formats.
  * Add new formats to the end of the list.
  */
@@ -324,7 +329,7 @@ struct snd_soc_tplg_hw_config {
 	__le32 size;            /* in bytes of this structure */
 	__le32 id;		/* unique ID - - used to match */
 	__le32 fmt;		/* SND_SOC_DAI_FORMAT_ format value */
-	__u8 clock_gated;	/* 1 if clock can be gated to save power */
+	__u8 clock_gated;	/* SND_SOC_TPLG_DAI_CLK_GATE_ value */
 	__u8 invert_bclk;	/* 1 for inverted BCLK, 0 for normal */
 	__u8 invert_fsync;	/* 1 for inverted frame clock, 0 for normal */
 	__u8 bclk_master;	/* SND_SOC_TPLG_BCLK_ value */
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 1c55252641f3..aab31144f683 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -2006,6 +2006,13 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
 
 		link->dai_fmt = hw_config->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
 
+		/* clock gating */
+		if (hw_config->clock_gated == SND_SOC_TPLG_DAI_CLK_GATE_GATED)
+			link->dai_fmt |= SND_SOC_DAIFMT_GATED;
+		else if (hw_config->clock_gated ==
+			 SND_SOC_TPLG_DAI_CLK_GATE_CONT)
+			link->dai_fmt |= SND_SOC_DAIFMT_CONT;
+
 		/* clock signal polarity */
 		invert_bclk = hw_config->invert_bclk;
 		invert_fsync = hw_config->invert_fsync;
-- 
2.17.0

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

* Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree
@ 2018-04-16 17:15     ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2018-04-16 17:15 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: Jaroslav Kysela, Takashi Iwai, Mark Brown, Pan Xiuli,
	Liam Girdwood, linux-kernel, alsa-devel

The patch

   ASoC: topology: Add missing clock gating parameter when parsing hw_configs

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 933e1c4a667103c4d10ebdc9505a0a6abd8c3fbd Mon Sep 17 00:00:00 2001
From: Kirill Marinushkin <k.marinushkin@gmail.com>
Date: Wed, 4 Apr 2018 06:19:38 +0200
Subject: [PATCH] ASoC: topology: Add missing clock gating parameter when
 parsing hw_configs

Clock gating parameter is a part of `dai_fmt`. It is supported by
`alsa-lib` when creating a topology binary file, but ignored by kernel
when loading this topology file.

After applying this commit, the clock gating parameter is not ignored any
more. This solution is backwards compatible. The existing behaviour is
not broken, because by default the parameter value is 0 and is ignored.

snd_soc_tplg_hw_config.clock_gated = 0 => no effect
snd_soc_tplg_hw_config.clock_gated = 1 => SND_SOC_DAIFMT_GATED
snd_soc_tplg_hw_config.clock_gated = 2 => SND_SOC_DAIFMT_CONT

For example, the following config, based on
alsa-lib/src/conf/topology/broadwell/broadwell.conf, is now supported:

~~~~
SectionHWConfig."CodecHWConfig" {
        id "1"
        format "I2S"            # physical audio format.
        pm_gate_clocks "true"   # clock can be gated
}

SectionLink."Codec" {

        # used for binding to the physical link
        id "0"

        hw_configs [
                "CodecHWConfig"
        ]

        default_hw_conf_id "1"
}
~~~~

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pan Xiuli <xiuli.pan@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/uapi/sound/asoc.h | 7 ++++++-
 sound/soc/soc-topology.c  | 7 +++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index f0e5e21efa54..f3c4b46e39d8 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -139,6 +139,11 @@
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_CHANNELS      (1 << 1)
 #define SND_SOC_TPLG_DAI_FLGBIT_SYMMETRIC_SAMPLEBITS    (1 << 2)
 
+/* DAI clock gating */
+#define SND_SOC_TPLG_DAI_CLK_GATE_UNDEFINED	0
+#define SND_SOC_TPLG_DAI_CLK_GATE_GATED	1
+#define SND_SOC_TPLG_DAI_CLK_GATE_CONT		2
+
 /* DAI physical PCM data formats.
  * Add new formats to the end of the list.
  */
@@ -324,7 +329,7 @@ struct snd_soc_tplg_hw_config {
 	__le32 size;            /* in bytes of this structure */
 	__le32 id;		/* unique ID - - used to match */
 	__le32 fmt;		/* SND_SOC_DAI_FORMAT_ format value */
-	__u8 clock_gated;	/* 1 if clock can be gated to save power */
+	__u8 clock_gated;	/* SND_SOC_TPLG_DAI_CLK_GATE_ value */
 	__u8 invert_bclk;	/* 1 for inverted BCLK, 0 for normal */
 	__u8 invert_fsync;	/* 1 for inverted frame clock, 0 for normal */
 	__u8 bclk_master;	/* SND_SOC_TPLG_BCLK_ value */
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 1c55252641f3..aab31144f683 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -2006,6 +2006,13 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
 
 		link->dai_fmt = hw_config->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
 
+		/* clock gating */
+		if (hw_config->clock_gated == SND_SOC_TPLG_DAI_CLK_GATE_GATED)
+			link->dai_fmt |= SND_SOC_DAIFMT_GATED;
+		else if (hw_config->clock_gated ==
+			 SND_SOC_TPLG_DAI_CLK_GATE_CONT)
+			link->dai_fmt |= SND_SOC_DAIFMT_CONT;
+
 		/* clock signal polarity */
 		invert_bclk = hw_config->invert_bclk;
 		invert_fsync = hw_config->invert_fsync;
-- 
2.17.0

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

* Re: Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree
  2018-02-20 13:45     ` Mark Brown
@ 2018-02-20 16:56       ` Kirill Marinushkin
  -1 siblings, 0 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-02-20 16:56 UTC (permalink / raw)
  To: Mark Brown
  Cc: Takashi Sakamoto, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-kernel

On 02/20/18 14:45, Mark Brown wrote:
> On Tue, Feb 20, 2018 at 12:09:18PM +0000, Mark Brown wrote:
>> The patch
>>
>>    ASoC: topology: Add missing clock gating parameter when parsing hw_configs
>>
>> has been applied to the asoc tree at
>>
>>    https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 
> This broke the build so I dropped it.

This patch is part 2 of 2. I failed to send both of them as a single patch series.
I will resend them properly in a new thread.

Best Regards,
Kirill

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

* Re: Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree
@ 2018-02-20 16:56       ` Kirill Marinushkin
  0 siblings, 0 replies; 23+ messages in thread
From: Kirill Marinushkin @ 2018-02-20 16:56 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Takashi Sakamoto, Liam Girdwood, linux-kernel, Takashi Iwai

On 02/20/18 14:45, Mark Brown wrote:
> On Tue, Feb 20, 2018 at 12:09:18PM +0000, Mark Brown wrote:
>> The patch
>>
>>    ASoC: topology: Add missing clock gating parameter when parsing hw_configs
>>
>> has been applied to the asoc tree at
>>
>>    https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 
> This broke the build so I dropped it.

This patch is part 2 of 2. I failed to send both of them as a single patch series.
I will resend them properly in a new thread.

Best Regards,
Kirill

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

* Re: Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree
  2018-02-20 12:09   ` Mark Brown
@ 2018-02-20 13:45     ` Mark Brown
  -1 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2018-02-20 13:45 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: Takashi Sakamoto, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 321 bytes --]

On Tue, Feb 20, 2018 at 12:09:18PM +0000, Mark Brown wrote:
> The patch
> 
>    ASoC: topology: Add missing clock gating parameter when parsing hw_configs
> 
> has been applied to the asoc tree at
> 
>    https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

This broke the build so I dropped it.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree
@ 2018-02-20 13:45     ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2018-02-20 13:45 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: alsa-devel, Takashi Sakamoto, Liam Girdwood, linux-kernel, Takashi Iwai


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

On Tue, Feb 20, 2018 at 12:09:18PM +0000, Mark Brown wrote:
> The patch
> 
>    ASoC: topology: Add missing clock gating parameter when parsing hw_configs
> 
> has been applied to the asoc tree at
> 
>    https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

This broke the build so I dropped it.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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



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

* Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree
  2018-02-19 20:36 [PATCH v2 2/2] ASoC: topology: Add missing clock gating parameter when " Kirill Marinushkin
@ 2018-02-20 12:09   ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2018-02-20 12:09 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: Takashi Sakamoto, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel, Mark Brown,
	Takashi Sakamoto, alsa-devel, linux-kernel, Takashi Iwai,
	Liam Girdwood, Mark Brown, alsa-devel

The patch

   ASoC: topology: Add missing clock gating parameter when parsing hw_configs

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From bdb86c40e8c5d2abe2ec7be964d621c1b7c27081 Mon Sep 17 00:00:00 2001
From: Kirill Marinushkin <k.marinushkin@gmail.com>
Date: Mon, 19 Feb 2018 21:36:35 +0100
Subject: [PATCH] ASoC: topology: Add missing clock gating parameter when
 parsing hw_configs

Clock gating parameter is a part of `dai_fmt`. It is supported by
`alsa-lib` when creating a topology binary file, but ignored by kernel
when loading this topology file.

After applying this commit, the clock gating parameter is not ignored any
more. The old behaviour is not broken, as by default the parameter value
is 0.

For example, the following config, based on
alsa-lib/src/conf/topology/broadwell/broadwell.conf, is now supported:

~~~~
SectionHWConfig."CodecHWConfig" {
        id "1"
        format "I2S"            # physical audio format.
        bclk   "master"         # Platform is master of bit clock
        fsync  "master"         # platform is master of fsync
        pm_gate_clocks "true"   # clock can be gated
}

SectionLink."Codec" {

        # used for binding to the physical link
        id "0"

        hw_configs [
                "CodecHWConfig"
        ]

        default_hw_conf_id "1"
}
~~~~

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-topology.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 01a50413c66f..bac70676a6b4 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1981,6 +1981,13 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
 
 		link->dai_fmt = hw_config->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
 
+		/* clock gating */
+		if (hw_config->clock_gated == SND_SOC_TPLG_DAI_CLK_GATE_GATED)
+			link->dai_fmt |= SND_SOC_DAIFMT_GATED;
+		else if (hw_config->clock_gated ==
+			 SND_SOC_TPLG_DAI_CLK_GATE_CONT)
+			link->dai_fmt |= SND_SOC_DAIFMT_CONT;
+
 		/* clock signal polarity */
 		invert_bclk = hw_config->invert_bclk;
 		invert_fsync = hw_config->invert_fsync;
-- 
2.16.1

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

* Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree
@ 2018-02-20 12:09   ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2018-02-20 12:09 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: alsa-devel, Liam Girdwood, linux-kernel, Takashi Iwai,
	Mark Brown, Takashi Sakamoto

The patch

   ASoC: topology: Add missing clock gating parameter when parsing hw_configs

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From bdb86c40e8c5d2abe2ec7be964d621c1b7c27081 Mon Sep 17 00:00:00 2001
From: Kirill Marinushkin <k.marinushkin@gmail.com>
Date: Mon, 19 Feb 2018 21:36:35 +0100
Subject: [PATCH] ASoC: topology: Add missing clock gating parameter when
 parsing hw_configs

Clock gating parameter is a part of `dai_fmt`. It is supported by
`alsa-lib` when creating a topology binary file, but ignored by kernel
when loading this topology file.

After applying this commit, the clock gating parameter is not ignored any
more. The old behaviour is not broken, as by default the parameter value
is 0.

For example, the following config, based on
alsa-lib/src/conf/topology/broadwell/broadwell.conf, is now supported:

~~~~
SectionHWConfig."CodecHWConfig" {
        id "1"
        format "I2S"            # physical audio format.
        bclk   "master"         # Platform is master of bit clock
        fsync  "master"         # platform is master of fsync
        pm_gate_clocks "true"   # clock can be gated
}

SectionLink."Codec" {

        # used for binding to the physical link
        id "0"

        hw_configs [
                "CodecHWConfig"
        ]

        default_hw_conf_id "1"
}
~~~~

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-topology.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 01a50413c66f..bac70676a6b4 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1981,6 +1981,13 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
 
 		link->dai_fmt = hw_config->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
 
+		/* clock gating */
+		if (hw_config->clock_gated == SND_SOC_TPLG_DAI_CLK_GATE_GATED)
+			link->dai_fmt |= SND_SOC_DAIFMT_GATED;
+		else if (hw_config->clock_gated ==
+			 SND_SOC_TPLG_DAI_CLK_GATE_CONT)
+			link->dai_fmt |= SND_SOC_DAIFMT_CONT;
+
 		/* clock signal polarity */
 		invert_bclk = hw_config->invert_bclk;
 		invert_fsync = hw_config->invert_fsync;
-- 
2.16.1

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

end of thread, other threads:[~2018-04-16 17:15 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 20:56 [PATCH v3 0/2] ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
2018-03-27 20:56 ` [PATCH v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
2018-03-27 20:56 ` [PATCH v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs Kirill Marinushkin
2018-04-16 17:15   ` Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree Mark Brown
2018-04-16 17:15     ` Mark Brown
2018-03-27 21:00 ` [PATCH, alsa-lib, v3 0/2] alsa-lib: ASoC: topology: Improve parsing hw_configs Kirill Marinushkin
2018-03-27 21:00   ` [PATCH, alsa-lib, v3 1/2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
2018-03-27 21:00     ` Kirill Marinushkin
2018-03-27 21:00   ` [PATCH, alsa-lib, v3 2/2] ASoC: topology: Add missing clock gating parameter when parsing hw_configs Kirill Marinushkin
2018-04-02 21:17 ` [PATCH v3 0/2] ASoC: topology: Improve " Kirill Marinushkin
2018-04-03  0:57   ` Pierre-Louis Bossart
2018-04-03  5:15     ` Kirill Marinushkin
2018-04-03  5:15       ` Kirill Marinushkin
2018-04-03 17:21       ` [alsa-devel] " Pierre-Louis Bossart
2018-04-03 18:16         ` Kirill Marinushkin
2018-04-03 19:19           ` Pierre-Louis Bossart
2018-04-03 19:19             ` Pierre-Louis Bossart
  -- strict thread matches above, loose matches on Subject: below --
2018-02-19 20:36 [PATCH v2 2/2] ASoC: topology: Add missing clock gating parameter when " Kirill Marinushkin
2018-02-20 12:09 ` Applied "ASoC: topology: Add missing clock gating parameter when parsing hw_configs" to the asoc tree Mark Brown
2018-02-20 12:09   ` Mark Brown
2018-02-20 13:45   ` Mark Brown
2018-02-20 13:45     ` Mark Brown
2018-02-20 16:56     ` Kirill Marinushkin
2018-02-20 16:56       ` Kirill Marinushkin

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.