ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
PATCH v2 1/1 ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
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 alsa-lib.
--- include/uapi/sound/asoc.h | 16 ++++++++++++++-- sound/soc/soc-topology.c | 12 +++++++----- 2 files changed, 21 insertions(+), 7 deletions(-)
include/uapi/sound/asoc.h +14 -2
@@ -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 */
sound/soc/soc-topology.c +7 -5
@@ -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 ;
Signature · 1 line
2.13.6
PATCH v2 1/1 ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
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.
--- 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(-)
include/sound/asoc.h +14 -2
@@ -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 */
include/topology.h +2 -2
@@ -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 */
src/conf/topology/broadwell/broadwell.conf +2 -2
@@ -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" {
src/topology/pcm.c +26 -4
@@ -1137,8 +1137,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 ; }
@@ -1163,8 +1174,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 ; }
Signature · 1 line
2.13.6
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 135 lines · 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.confThis 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 <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>--- 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(-)include/sound/asoc.h +14
-2@@ -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 */ include/topology.h +2
-2@@ -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 */ src/conf/topology/broadwell/broadwell.conf +2
-2@@ -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" {src/topology/pcm.c +26
-4@@ -1137,8 +1137,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 ; }@@ -1163,8 +1174,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 ; }
Quoted 35 lines · Kirill Marinushkin
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 31 lines · 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.confThis 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 <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>--- 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(-)include/sound/asoc.h +0
-0@@ -156,6 +156,18 @@#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2)#define SND_SOC_TPLG_LNK_FLGBIT_VOICE_WAKEUP (1 << 3)
Quoted 13 lines
include/sound/asoc.h line 171
Quoted 13 lines
include/sound/asoc.h +12
-0+/* 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 */ +/*
Could we keep this align with the old values.
1 for master of BCLK, 0 for slave
1 for master of FSYNC, 0 for slave
This will save some change for SOF topology load parse to DSP. Now we need to modify a few codes too fit this changing.
And to make things more easier. We can just keep the old values and only modify alsa-lib to let "master" == "codec_slave". Here we only need to change how we write tplg and no more kernel patches are need.
Quoted 60 lines
Quoted 60 lines
include/sound/asoc.h +2
-2* 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 */ include/topology.h +2
-2@@ -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 */ src/conf/topology/broadwell/broadwell.conf +2
-2@@ -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" {src/topology/pcm.c +7
-2@@ -1137,8 +1137,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); +
Quoted 8 lines
src/topology/pcm.c int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, · line 1154
Quoted 8 lines
src/topology/pcm.c +6
-0+ 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 ; }
What if some old tplg used "slave"? What should we do to those values.
Quoted 15 lines
Quoted 15 lines
src/topology/pcm.c +8
-2@@ -1163,8 +1174,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 ;
Quoted 8 lines
src/topology/pcm.c int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, · line 1192
Quoted 8 lines
src/topology/pcm.c +5
-0+ }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 ; }
Test with our SOF topology and found a missing part mclk.
We also use mclk now, and I think these KEY WORDS should align with the new changes, too.
Thanks
Xiuli
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 53 lines · Xiuli
Quoted 39 lines · Kirill Marinushkin
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 35 lines · 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.confThis 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 <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>---
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(-)include/sound/asoc.h +0
-0@@ -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
+ */include/sound/asoc.h +2
-0+#define SND_SOC_TPLG_BCLK_CM 0/* codec is bclk master */ +#define SND_SOC_TPLG_BCLK_CS 1/* codec is bclk slave */ Quoted 8 lines
Quoted 8 lines
include/sound/asoc.h +7
-0+ +/* 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 */ +/*
Could we keep this align with the old values.
Quoted 2 lines
1 for master of BCLK, 0 for slave
1 for master of FSYNC, 0 for slave
We cannot keep it aligned with the old *comment descriptions*, because we keep it aligned with the old *implementation*. As you remember, the whole issue was with the reverted values.
We exactly keep our new solution aligned to the old solution by doing this:
~~~~
#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */ #define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
~~~~
Quoted 4 lines
This will save some change for SOF topology load parse to DSP. Now we need to modify a few codes too fit this changing.
See above why we can't follow this proposal.
Quoted 62 lines
And to make things more easier. We can just keep the old values and only modify alsa-lib to let "master" == "
codec_slave". Here we only need to change how we write tplg and no more kernel patches are need.Quoted 59 lines
Quoted 59 lines
* Block Header.
* This header precedes all object and object arrays below.include/sound/asoc.h +0
-0@@ -311,8 +323,8 @@ struct snd_soc_tplg_hw_config {
__u8clock_gated; /* 1 if clock can be gated to save power */__u8invert_bclk; /* 1 for inverted BCLK, 0 for normal */__u8invert_fsync; /* 1 for inverted frame clock, 0 for normal */ -__u8bclk_master; /* 1 for master of BCLK, 0 for slave */ -__u8fsync_master; /* 1 for master of FSYNC, 0 for slave */ +__u8bclk_master; /*SND_SOC_TPLG_BCLK_value */
+__u8fsync_master; /*SND_SOC_TPLG_FSYNC_value */__u8mclk_direction; /* 0 for input, 1 for output */__le16reserved; /* for 32bit alignment */
__le32mclk_rate; /* MCLK or SYSCLK freqency in Hz */include/topology.h +0
-0@@ -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 */src/conf/topology/broadwell/broadwell.conf +0
-0@@ -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" {src/topology/pcm.c +8
-1@@ -1137,8 +1137,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;
Quoted 9 lines
Quoted 7 lines
src/topology/pcm.c int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, · line 1154
Quoted 7 lines
src/topology/pcm.c +5
-0+ } 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; }What if some old tplg used "slave"? What should we do to those values.
Old behavior: "slave" => not modified (hw_cfg->bclk_master = 0) New behavior: "slave" => not modified (hw_cfg->bclk_master = 0)
So, we keep this use-case unchanged.
Quoted 21 lines
Quoted 13 lines
Quoted 13 lines
src/topology/pcm.c +0
-0@@ -1163,8 +1174,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;Quoted 8 lines
Quoted 8 lines
+ } 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;
}
Quoted 3 lines
Test with our SOF topology and found a missing part mclk.
We also use mclk now, and I think these KEY WORDS should align with the new changes, too.
mclk is not related to this patch series. Feel free to add it in a separate patch.
Best Regards,
Kirill
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 52 lines · Kirill Marinushkin
Quoted 51 lines · Xiuli
Quoted 39 lines · Kirill Marinushkin
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 35 lines · 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.confThis 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 <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>--- 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(-)include/sound/asoc.h +4
-0@@ -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 */ Quoted 8 lines
include/sound/asoc.h line 171
Quoted 8 lines
include/sound/asoc.h +7
-0+ +/* 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 */ + /*Could we keep this align with the old values.
Quoted 5 lines
Quoted 2 lines
1 for master of BCLK, 0 for slave
1 for master of FSYNC, 0 for slaveWe cannot keep it aligned with the old *comment descriptions*, because we keep it aligned with the old *implementation*. As you remember, the whole issue was with the reverted values.
We exactly keep our new solution aligned to the old solution by doing this:
Yes, but what I suggest is that if we can not modify the kernel part. But just use the value in alsatplg to fix this problem. We actually not passed any string in the tplg file, but only some parsed value. Could we align the string & value mapping to make this more easier.
Though I know that the value for bclk_master ans fsync_master is very confusing.
Quoted 81 lines
~~~~
#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */ #define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
~~~~Quoted 3 lines
This will save some change for SOF topology load parse to DSP. Now we need to modify a few codes too fit this changing.
See above why we can't follow this proposal.
Quoted 62 lines
And to make things more easier. We can just keep the old values and only modify alsa-lib to let "master" == "
codec_slave". Here we only need to change how we write tplg and no more kernel patches are need.Quoted 59 lines
Quoted 59 lines
include/sound/asoc.h +2
-2* 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 */include/topology.h +2
-2@@ -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 */src/conf/topology/broadwell/broadwell.conf +2
-2@@ -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" {src/topology/pcm.c +8
-1@@ -1137,8 +1137,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;Quoted 9 lines
Quoted 7 lines
src/topology/pcm.c int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, · line 1154
Quoted 7 lines
src/topology/pcm.c +5
-0+ } 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; }What if some old tplg used "slave"? What should we do to those values.
Quoted 4 lines
Old behavior: "slave" => not modified (
hw_cfg->bclk_master= 0) New behavior: "slave" => not modified (hw_cfg->bclk_master= 0)So, we keep this use-case unchanged.
What I worry about is that we have make hw_cfg->bclk_master usage different in kernel part. I think we should keep this the same now, the same 0 have different meanings. Otherwise, why should we check codec_master?
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
src/topology/pcm.c +13
-1@@ -1163,8 +1174,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; }
Quoted 4 lines
Quoted 3 lines
Test with our SOF topology and found a missing part mclk.
We also use mclk now, and I think these KEY WORDS should align with the new changes, too.mclk is not related to this patch series. Feel free to add it in a separate patch.
OK, we may add this support later.
Thanks
Xiuli
Quoted 6 lines
Best Regards,
Kirill
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 58 lines · Xiuli
Quoted 55 lines · Kirill Marinushkin
Quoted 54 lines · Xiuli
Quoted 40 lines · Kirill Marinushkin
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 36 lines · 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.confThis 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 <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>---
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(-)include/sound/asoc.h +0
-0@@ -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
+ */include/sound/asoc.h +2
-0+#define SND_SOC_TPLG_BCLK_CM 0/* codec is bclk master */ +#define SND_SOC_TPLG_BCLK_CS 1/* codec is bclk slave */ Quoted 8 lines
Quoted 8 lines
include/sound/asoc.h +7
-0+ +/* 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 */ +/*
Could we keep this align with the old values.
1 for master of BCLK, 0 for slave
1 for master of FSYNC, 0 for slave
Quoted 8 lines
Quoted 3 lines
We cannot keep it aligned with the old *comment descriptions*, because we keep it aligned with the old *implementation*. As you remember, the whole issue was with the reverted values.
We exactly keep our new solution aligned to the old solution by doing this:Yes, but what I suggest is that if we can not modify the kernel part. But just use the value in alsatplg to fix this problem. We actually not passed any string in the tplg file, but only some parsed value. Could we align the string & value mapping to make this more easier.
Though I know that the value for
bclk_masteransfsync_masteris very confusing.
Xiuli, I was not able to understand any of your points...
Rule #1 is we don't break userspace. If people generated a .tplg file with an old version of alsatplg or an inversion in the .conf file, then we have to provide a backwards-compatible solution.
Quoted 118 lines
Quoted 87 lines
~~~~
#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */ #define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
~~~~Quoted 3 lines
This will save some change for SOF topology load parse to DSP. Now we need to modify a few codes too fit this changing.
See above why we can't follow this proposal.
Quoted 67 lines
And to make things more easier. We can just keep the old values and only modify alsa-lib to let "master" == "
codec_slave". Here we only need to change how we write tplg and no more kernel patches are need.Quoted 64 lines
Quoted 64 lines
* Block Header.
* This header precedes all object and object arrays below.include/sound/asoc.h +0
-0@@ -311,8 +323,8 @@ struct snd_soc_tplg_hw_config {
__u8clock_gated; /* 1 if clock can be gated to save power */__u8invert_bclk; /* 1 for inverted BCLK, 0 for normal */__u8invert_fsync; /* 1 for inverted frame clock, 0 for normal */ -__u8bclk_master; /* 1 for master of BCLK, 0 for slave */ -__u8fsync_master; /* 1 for master of FSYNC, 0 for slave */ +__u8bclk_master; /*SND_SOC_TPLG_BCLK_value */
+__u8fsync_master; /*SND_SOC_TPLG_FSYNC_value */
__u8mclk_direction; /* 0 for input, 1 for output */__le16reserved; /* for 32bit alignment */
__le32mclk_rate; /* MCLK or SYSCLK freqency in Hz */include/topology.h +0
-0@@ -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 */src/conf/topology/broadwell/broadwell.conf +0
-0@@ -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" {src/topology/pcm.c +8
-1@@ -1137,8 +1137,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;Quoted 9 lines
Quoted 7 lines
src/topology/pcm.c int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, · line 1154
Quoted 7 lines
src/topology/pcm.c +5
-0+ } 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; }What if some old tplg used "slave"? What should we do to those values.
Quoted 4 lines
Old behavior: "slave" => not modified (
hw_cfg->bclk_master= 0) New behavior: "slave" => not modified (hw_cfg->bclk_master= 0)So, we keep this use-case unchanged.
What I worry about is that we have make
hw_cfg->bclk_masterusage different in kernel part. I think we should keep this the same now, the same 0 have different meanings. Otherwise, why should we checkcodec_master?Quoted 23 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
@@ -1163,8 +1174,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);
+Quoted 8 lines
Quoted 8 lines
+
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;
}Test with our SOF topology and found a missing part mclk.
We also use mclk now, and I think these KEY WORDS should align with the new changes, too.
Quoted 14 lines
Quoted 1 line
mclk is not related to this patch series. Feel free to add it in a separate patch.
OK, we may add this support later.
Thanks
XiuliQuoted 6 lines
Best Regards,
Kirill
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 65 lines · Pierre-Louis Bossart
Quoted 62 lines · Xiuli
Quoted 58 lines · Kirill Marinushkin
Quoted 52 lines · Xiuli
Quoted 40 lines · Kirill Marinushkin
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 36 lines · 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.confThis 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 <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>---
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(-)include/sound/asoc.h +0
-0@@ -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
+ */include/sound/asoc.h +2
-0+#define SND_SOC_TPLG_BCLK_CM 0/* codec is bclk master */ +#define SND_SOC_TPLG_BCLK_CS 1/* codec is bclk slave */ Quoted 8 lines
Quoted 8 lines
include/sound/asoc.h +7
-0+ +/* 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 */ +/*
Could we keep this align with the old values.
Quoted 2 lines
1 for master of BCLK, 0 for slave
1 for master of FSYNC, 0 for slaveWe cannot keep it aligned with the old *comment descriptions*, because we keep it aligned with the old *implementation*. As you remember, the whole issue was with the reverted values.
We exactly keep our new solution aligned to the old solution by doing this:
Quoted 8 lines
Quoted 4 lines
Yes, but what I suggest is that if we can not modify the kernel part. But just use the value in alsatplg to fix this problem. We actually not passed any string in the tplg file, but only some parsed value. Could we align the string & value mapping to make this more easier.
Though I know that the value for
bclk_masteransfsync_masteris very confusing.Xiuli, I was not able to understand any of your points...
Rule #1 is we don't break userspace. If people generated a .tplg file with an old version of alsatplg or an inversion in the .conf file, then we have to provide a backwards-compatible solution.
OK, I got the point. We must make enough changes for the old version files to be accepted. The SOF need some patches to work with these patches. I will send them once these are merged in.
Thanks
Xiuli
Quoted 125 lines
Quoted 125 lines
Quoted 87 lines
~~~~
#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */ #define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
~~~~Quoted 3 lines
This will save some change for SOF topology load parse to DSP. Now we need to modify a few codes too fit this changing.
See above why we can't follow this proposal.
Quoted 67 lines
And to make things more easier. We can just keep the old values and only modify alsa-lib to let "master" == "
codec_slave". Here we only need to change how we write tplg and no more kernel patches are need.Quoted 64 lines
Quoted 64 lines
* Block Header.
* This header precedes all object and object arrays below.include/sound/asoc.h +0
-0@@ -311,8 +323,8 @@ struct snd_soc_tplg_hw_config {
__u8clock_gated; /* 1 if clock can be gated to save power */__u8invert_bclk; /* 1 for inverted BCLK, 0 for normal */__u8invert_fsync; /* 1 for inverted frame clock, 0 for normal */ -__u8bclk_master; /* 1 for master of BCLK, 0 for slave */ -__u8fsync_master; /* 1 for master of FSYNC, 0 for slave */ +__u8bclk_master; /*SND_SOC_TPLG_BCLK_value */
+__u8fsync_master; /*SND_SOC_TPLG_FSYNC_value */
__u8mclk_direction; /* 0 for input, 1 for output */__le16reserved; /* for 32bit alignment */
__le32mclk_rate; /* MCLK or SYSCLK freqency in Hz */include/topology.h +0
-0@@ -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 */src/conf/topology/broadwell/broadwell.conf +0
-0@@ -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" {src/topology/pcm.c +8
-1@@ -1137,8 +1137,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;Quoted 9 lines
Quoted 7 lines
src/topology/pcm.c int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, · line 1154
Quoted 7 lines
src/topology/pcm.c +5
-0+ } 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; }What if some old tplg used "slave"? What should we do to those values.
Quoted 4 lines
Old behavior: "slave" => not modified (
hw_cfg->bclk_master= 0) New behavior: "slave" => not modified (hw_cfg->bclk_master= 0)So, we keep this use-case unchanged.
What I worry about is that we have make
hw_cfg->bclk_masterusage different in kernel part. I think we should keep this the same now, the same 0 have different meanings. Otherwise, why should we checkcodec_master?Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
@@ -1163,8 +1174,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;
}Quoted 4 lines
Quoted 3 lines
Test with our SOF topology and found a missing part mclk.
We also use mclk now, and I think these KEY WORDS should align with the new changes, too.mclk is not related to this patch series. Feel free to add it in a separate patch.
OK, we may add this support later.
Thanks
Xiuli
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Best Regards,
Kirill
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Hello Mark, Takashi.
This patch series fixes an issue which causes troubles at Sound Open Firmware.
It is already reviewed and agreed by the SOF engineers
Pan, Xiuli <[email protected]> and Pierre-Louis Bossart <[email protected]>
Please have a look.
Notice: this patch series includes 1 patch for linux + 1 patch for alsa-lib.
Best Regards,
Kirill
Quoted 76 lines · Xiuli
Quoted 64 lines · Pierre-Louis Bossart
Quoted 61 lines · Xiuli
Quoted 57 lines · Kirill Marinushkin
Quoted 51 lines · Xiuli
Quoted 39 lines · Kirill Marinushkin
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 35 lines · 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.confThis 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 <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>---
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(-)include/sound/asoc.h +0
-0@@ -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
+ */include/sound/asoc.h +2
-0+#define SND_SOC_TPLG_BCLK_CM 0/* codec is bclk master */ +#define SND_SOC_TPLG_BCLK_CS 1/* codec is bclk slave */ Quoted 8 lines
Quoted 8 lines
include/sound/asoc.h +7
-0+ +/* 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 */ +/*
Could we keep this align with the old values.
Quoted 2 lines
1 for master of BCLK, 0 for slave
1 for master of FSYNC, 0 for slaveWe cannot keep it aligned with the old *comment descriptions*, because we keep it aligned with the old *implementation*. As you remember, the whole issue was with the reverted values.
We exactly keep our new solution aligned to the old solution by doing this:Quoted 8 lines
Quoted 4 lines
Yes, but what I suggest is that if we can not modify the kernel part. But just use the value in alsatplg to fix this problem. We actually not passed any string in the tplg file, but only some parsed value. Could we align the string & value mapping to make this more easier.
Though I know that the value for
bclk_masteransfsync_masteris very confusing.Xiuli, I was not able to understand any of your points...
Rule #1 is we don't break userspace. If people generated a .tplg file with an old version of alsatplg or an inversion in the .conf file, then we have to provide a backwards-compatible solution.
Quoted 135 lines
OK, I got the point. We must make enough changes for the old version files to be accepted. The SOF need some patches to work with these patches. I will send them once these are merged in.
Thanks
XiuliQuoted 128 lines
Quoted 127 lines
Quoted 82 lines
~~~~
#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */ #define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
~~~~Quoted 3 lines
This will save some change for SOF topology load parse to DSP. Now we need to modify a few codes too fit this changing.
See above why we can't follow this proposal.
Quoted 62 lines
And to make things more easier. We can just keep the old values and only modify alsa-lib to let "master" == "
codec_slave". Here we only need to change how we write tplg and no more kernel patches are need.Quoted 59 lines
Quoted 59 lines
* Block Header.
* This header precedes all object and object arrays below.include/sound/asoc.h +0
-0@@ -311,8 +323,8 @@ struct snd_soc_tplg_hw_config {
__u8clock_gated; /* 1 if clock can be gated to save power */__u8invert_bclk; /* 1 for inverted BCLK, 0 for normal */__u8invert_fsync; /* 1 for inverted frame clock, 0 for normal */ -__u8bclk_master; /* 1 for master of BCLK, 0 for slave */ -__u8fsync_master; /* 1 for master of FSYNC, 0 for slave */ +__u8bclk_master; /*SND_SOC_TPLG_BCLK_value */
+__u8fsync_master; /*SND_SOC_TPLG_FSYNC_value */
__u8mclk_direction; /* 0 for input, 1 for output */__le16reserved; /* for 32bit alignment */
__le32mclk_rate; /* MCLK or SYSCLK freqency in Hz */include/topology.h +0
-0@@ -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 */src/conf/topology/broadwell/broadwell.conf +0
-0@@ -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" {src/topology/pcm.c +8
-1@@ -1137,8 +1137,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;Quoted 9 lines
Quoted 7 lines
src/topology/pcm.c int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, · line 1154
Quoted 7 lines
src/topology/pcm.c +5
-0+ } 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; }What if some old tplg used "slave"? What should we do to those values.
Quoted 4 lines
Old behavior: "slave" => not modified (
hw_cfg->bclk_master= 0) New behavior: "slave" => not modified (hw_cfg->bclk_master= 0)So, we keep this use-case unchanged.
What I worry about is that we have make
hw_cfg->bclk_masterusage different in kernel part. I think we should keep this the same now, the same 0 have different meanings. Otherwise, why should we checkcodec_master?Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
src/topology/pcm.c +0
-0@@ -1163,8 +1174,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;
}Quoted 4 lines
Quoted 3 lines
Test with our SOF topology and found a missing part mclk.
We also use mclk now, and I think these KEY WORDS should align with the new changes, too.mclk is not related to this patch series. Feel free to add it in a separate patch.
OK, we may add this support later.
Thanks
XiuliQuoted 6 lines
Best Regards,
Kirill
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Hello Xiuli, Pierre-Louis,
I want to resend this patch series. May I add "Reviewed-by:" tags with your names?
I think it will help us to have this patch series into upstream.
Best Regards,
Kirill
Quoted 6 lines · Kirill Marinushkin
Hello Mark, Takashi.
This patch series fixes an issue which causes troubles at Sound Open Firmware.
It is already reviewed and agreed by the SOF engineers
Pan, Xiuli <[email protected]> and Pierre-Louis Bossart <[email protected]>
Quoted 206 lines
Please have a look.
Notice: this patch series includes 1 patch for linux + 1 patch for alsa-lib.
Best Regards,
KirillQuoted 198 lines · Xiuli
Quoted 60 lines · Pierre-Louis Bossart
Quoted 58 lines · Xiuli
Quoted 56 lines · Kirill Marinushkin
Quoted 50 lines · Xiuli
Quoted 39 lines · Kirill Marinushkin
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 35 lines · 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.confThis 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 <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>---
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(-)include/sound/asoc.h +0
-0@@ -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
+ */include/sound/asoc.h +2
-0+#define SND_SOC_TPLG_BCLK_CM 0/* codec is bclk master */ +#define SND_SOC_TPLG_BCLK_CS 1/* codec is bclk slave */ Quoted 8 lines
Quoted 8 lines
include/sound/asoc.h +7
-0+ +/* 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 */ +/*
Could we keep this align with the old values.
Quoted 2 lines
1 for master of BCLK, 0 for slave
1 for master of FSYNC, 0 for slaveWe cannot keep it aligned with the old *comment descriptions*, because we keep it aligned with the old *implementation*. As you remember, the whole issue was with the reverted values.
We exactly keep our new solution aligned to the old solution by doing this:Quoted 7 lines
Quoted 4 lines
Yes, but what I suggest is that if we can not modify the kernel part. But just use the value in alsatplg to fix this problem. We actually not passed any string in the tplg file, but only some parsed value. Could we align the string & value mapping to make this more easier.
Though I know that the value for
bclk_masteransfsync_masteris very confusing.Xiuli, I was not able to understand any of your points...
Rule #1 is we don't break userspace. If people generated a .tplg file with an old version of alsatplg or an inversion in the .conf file, then we have to provide a backwards-compatible solution.OK, I got the point. We must make enough changes for the old version files to be accepted. The SOF need some patches to work with these patches. I will send them once these are merged in.
Thanks
XiuliQuoted 123 lines
Quoted 123 lines
Quoted 81 lines
~~~~
#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */ #define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
~~~~Quoted 3 lines
This will save some change for SOF topology load parse to DSP. Now we need to modify a few codes too fit this changing.
See above why we can't follow this proposal.
Quoted 62 lines
And to make things more easier. We can just keep the old values and only modify alsa-lib to let "master" == "
codec_slave". Here we only need to change how we write tplg and no more kernel patches are need.Quoted 59 lines
Quoted 59 lines
* Block Header.
* This header precedes all object and object arrays below.include/sound/asoc.h +0
-0@@ -311,8 +323,8 @@ struct snd_soc_tplg_hw_config {
__u8clock_gated; /* 1 if clock can be gated to save power */__u8invert_bclk; /* 1 for inverted BCLK, 0 for normal */__u8invert_fsync; /* 1 for inverted frame clock, 0 for normal */ -__u8bclk_master; /* 1 for master of BCLK, 0 for slave */ -__u8fsync_master; /* 1 for master of FSYNC, 0 for slave */ +__u8bclk_master; /*SND_SOC_TPLG_BCLK_value */
+__u8fsync_master; /*SND_SOC_TPLG_FSYNC_value */
__u8mclk_direction; /* 0 for input, 1 for output */__le16reserved; /* for 32bit alignment */
__le32mclk_rate; /* MCLK or SYSCLK freqency in Hz */include/topology.h +0
-0@@ -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 */src/conf/topology/broadwell/broadwell.conf +0
-0@@ -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" {src/topology/pcm.c +8
-1@@ -1137,8 +1137,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;Quoted 9 lines
Quoted 7 lines
src/topology/pcm.c int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, · line 1154
Quoted 7 lines
src/topology/pcm.c +5
-0+ } 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; }What if some old tplg used "slave"? What should we do to those values.
Quoted 4 lines
Old behavior: "slave" => not modified (
hw_cfg->bclk_master= 0) New behavior: "slave" => not modified (hw_cfg->bclk_master= 0)So, we keep this use-case unchanged.
What I worry about is that we have make
hw_cfg->bclk_masterusage different in kernel part. I think we should keep this the same now, the same 0 have different meanings. Otherwise, why should we checkcodec_master?Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
src/topology/pcm.c +0
-0@@ -1163,8 +1174,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;
}Quoted 4 lines
Quoted 3 lines
Test with our SOF topology and found a missing part mclk.
We also use mclk now, and I think these KEY WORDS should align with the new changes, too.mclk is not related to this patch series. Feel free to add it in a separate patch.
OK, we may add this support later.
Thanks
XiuliQuoted 6 lines
Best Regards,
Kirill
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 3 lines · Kirill Marinushkin
Hello Xiuli, Pierre-Louis,
I want to resend this patch series. May I add "Reviewed-by:" tags with your names?
I am going to test it this week, was traveling on business and Xiuli is busy with a release. Thanks for your patience.
Quoted 218 lines
I think it will help us to have this patch series into upstream.
Best Regards,
Kirill
Quoted 6 lines · Kirill Marinushkin
Hello Mark, Takashi.
This patch series fixes an issue which causes troubles at Sound Open Firmware.
It is already reviewed and agreed by the SOF engineers
Pan, Xiuli <[email protected]> and Pierre-Louis Bossart <[email protected]>Quoted 203 lines
Please have a look.
Notice: this patch series includes 1 patch for linux + 1 patch for alsa-lib.
Best Regards,
KirillQuoted 195 lines · Xiuli
Quoted 58 lines · Pierre-Louis Bossart
Quoted 57 lines · Xiuli
Quoted 56 lines · Kirill Marinushkin
Quoted 50 lines · Xiuli
Quoted 39 lines · Kirill Marinushkin
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 35 lines · 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.confThis 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 <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>--- 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(-)include/sound/asoc.h +4
-0@@ -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 */ Quoted 8 lines
include/sound/asoc.h line 170
Quoted 8 lines
include/sound/asoc.h +7
-0+ +/* 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 */ + /*Could we keep this align with the old values.
Quoted 2 lines
1 for master of BCLK, 0 for slave
1 for master of FSYNC, 0 for slaveWe cannot keep it aligned with the old *comment descriptions*, because we keep it aligned with the old *implementation*. As you remember, the whole issue was with the reverted values.
We exactly keep our new solution aligned to the old solution by doing this:Quoted 7 lines
Quoted 4 lines
Yes, but what I suggest is that if we can not modify the kernel part. But just use the value in alsatplg to fix this problem. We actually not passed any string in the tplg file, but only some parsed value. Could we align the string & value mapping to make this more easier.
Though I know that the value for
bclk_masteransfsync_masteris very confusing.Xiuli, I was not able to understand any of your points...
Rule #1 is we don't break userspace. If people generated a .tplg file with an old version of alsatplg or an inversion in the .conf file, then we have to provide a backwards-compatible solution.OK, I got the point. We must make enough changes for the old version files to be accepted. The SOF need some patches to work with these patches. I will send them once these are merged in.
Thanks
XiuliQuoted 123 lines
Quoted 123 lines
Quoted 81 lines
~~~~
#define SND_SOC_TPLG_FSYNC_CM 0 /* codec is fsync master */ #define SND_SOC_TPLG_FSYNC_CS 1 /* codec is fsync slave */
~~~~Quoted 3 lines
This will save some change for SOF topology load parse to DSP. Now we need to modify a few codes too fit this changing.
See above why we can't follow this proposal.
Quoted 62 lines
And to make things more easier. We can just keep the old values and only modify alsa-lib to let "master" == "
codec_slave". Here we only need to change how we write tplg and no more kernel patches are need.Quoted 59 lines
Quoted 59 lines
include/sound/asoc.h +2
-2* 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 */include/topology.h +2
-2@@ -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 */src/conf/topology/broadwell/broadwell.conf +2
-2@@ -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" {src/topology/pcm.c +8
-1@@ -1137,8 +1137,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;Quoted 9 lines
Quoted 7 lines
src/topology/pcm.c int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, · line 1154
Quoted 7 lines
src/topology/pcm.c +5
-0+ } 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; }What if some old tplg used "slave"? What should we do to those values.
Quoted 4 lines
Old behavior: "slave" => not modified (
hw_cfg->bclk_master= 0) New behavior: "slave" => not modified (hw_cfg->bclk_master= 0)So, we keep this use-case unchanged.
What I worry about is that we have make
hw_cfg->bclk_masterusage different in kernel part. I think we should keep this the same now, the same 0 have different meanings. Otherwise, why should we checkcodec_master?Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
src/topology/pcm.c +13
-1@@ -1163,8 +1174,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; }Quoted 4 lines
Quoted 3 lines
Test with our SOF topology and found a missing part mclk.
We also use mclk now, and I think these KEY WORDS should align with the new changes, too.mclk is not related to this patch series. Feel free to add it in a separate patch.
OK, we may add this support later.
Thanks
XiuliQuoted 6 lines
Best Regards,
Kirill
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 4 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 8 lines · Pierre-Louis Bossart
Quoted 3 lines · Kirill Marinushkin
Hello Xiuli, Pierre-Louis,
I want to resend this patch series. May I add "Reviewed-by:" tags with your names?
I am going to test it this week, was traveling on business and Xiuli is busy with a release. Thanks for your patience.
Sure, we also have some tests with your patches in SOF now.
I did a test and make some changes in SOF about 2 weeks ago, and raised some comments to make sure my changes on SOF is necessary. Now Pierre got the similar changes to SOF and test with your patches on one platform.
I just helped him to do testes on our other platforms.
You can also add "Test-by: " now.
Thanks
Xiuli
Quoted 8 lines
Quoted 8 lines
I think it will help us to have this patch series into upstream.
Best Regards,
Kirill
Pierre-Louis Bossart
Tested-byQuoted 11 lines · Kirill Marinushkin
This patch is for alsa-lib. I forgot to mention it in the subject.
Quoted 7 lines · 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.confThis commit provides the backwards-compatible solution to fix this misuse. This commit goes in pair with the corresponding patch for linux.
alsa-lib patch:
Quoted 128 lines
Quoted 128 lines
Signed-off-by Kirill Marinushkin <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>--- 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(-)include/sound/asoc.h +14
-2@@ -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 */ include/topology.h +2
-2@@ -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 */ src/conf/topology/broadwell/broadwell.conf +2
-2@@ -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" {src/topology/pcm.c +26
-4@@ -1137,8 +1137,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 ; }@@ -1163,8 +1174,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 ; }
Quoted 7 lines · 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.confThis commit provides the backwards-compatible solution to fix this misuse. This commit goes in pair with the corresponding patch for alsa-lib.
kernel/ASoC patch:
Quoted 74 lines
Signed-off-by Kirill Marinushkin <[email protected]>Cc Mark Brown <[email protected]>Cc Takashi Iwai <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Pan Xiuli <[email protected]>Cc Liam Girdwood <[email protected]>--- include/uapi/sound/asoc.h | 16 ++++++++++++++-- sound/soc/soc-topology.c | 12 +++++++----- 2 files changed, 21 insertions(+), 7 deletions(-)include/uapi/sound/asoc.h +14
-2@@ -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 */ sound/soc/soc-topology.c +7
-5@@ -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 ;