All of lore.kernel.org
 help / color / mirror / Atom feed
* [FIX][PATCH] ASoC: topology: Fix logical inversion in set_link_hw_format()
@ 2018-02-22 22:01 Xiuli Pan
  2018-02-26 11:17   ` Mark Brown
  0 siblings, 1 reply; 28+ messages in thread
From: Xiuli Pan @ 2018-02-22 22:01 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, Pan Xiuli, xiuli.pan

From: Pan Xiuli <xiuli.pan@linux.intel.com>

The master/slave conventions are wrt. the codec. The topology code
contains a logical inversion, fix to follow ASoC usage.

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
---
 sound/soc/soc-topology.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 561f74d..2931248 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -2030,11 +2030,11 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
 		/* clock masters */
 		bclk_master = hw_config->bclk_master;
 		fsync_master = hw_config->fsync_master;
-		if (!bclk_master && !fsync_master)
+		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.7.4

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

* Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-22 22:01 [FIX][PATCH] ASoC: topology: Fix logical inversion in set_link_hw_format() Xiuli Pan
@ 2018-02-26 11:17   ` Mark Brown
  0 siblings, 0 replies; 28+ messages in thread
From: Mark Brown @ 2018-02-26 11:17 UTC (permalink / raw)
  To: Pan Xiuli
  Cc: Mark Brown, stable, alsa-devel, Mark Brown, xiuli.pan, alsa-devel

The patch

   ASoC: topology: Fix logical inversion in set_link_hw_format()

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 7f34c3f38e9666216fda155b6ebededd1073f5aa Mon Sep 17 00:00:00 2001
From: Pan Xiuli <xiuli.pan@linux.intel.com>
Date: Fri, 23 Feb 2018 06:01:28 +0800
Subject: [PATCH] ASoC: topology: Fix logical inversion in set_link_hw_format()

The master/slave conventions are wrt. the codec. The topology code
contains a logical inversion, fix to follow ASoC usage.

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
 sound/soc/soc-topology.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 01a50413c66f..5f507993c43e 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1996,11 +1996,11 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
 		/* clock masters */
 		bclk_master = hw_config->bclk_master;
 		fsync_master = hw_config->fsync_master;
-		if (!bclk_master && !fsync_master)
+		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.16.1

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

* Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
@ 2018-02-26 11:17   ` Mark Brown
  0 siblings, 0 replies; 28+ messages in thread
From: Mark Brown @ 2018-02-26 11:17 UTC (permalink / raw)
  To: Pan Xiuli; +Cc: Mark Brown, stable, alsa-devel

The patch

   ASoC: topology: Fix logical inversion in set_link_hw_format()

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 7f34c3f38e9666216fda155b6ebededd1073f5aa Mon Sep 17 00:00:00 2001
From: Pan Xiuli <xiuli.pan@linux.intel.com>
Date: Fri, 23 Feb 2018 06:01:28 +0800
Subject: [PATCH] ASoC: topology: Fix logical inversion in set_link_hw_format()

The master/slave conventions are wrt. the codec. The topology code
contains a logical inversion, fix to follow ASoC usage.

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
 sound/soc/soc-topology.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 01a50413c66f..5f507993c43e 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1996,11 +1996,11 @@ static void set_link_hw_format(struct snd_soc_dai_link *link,
 		/* clock masters */
 		bclk_master = hw_config->bclk_master;
 		fsync_master = hw_config->fsync_master;
-		if (!bclk_master && !fsync_master)
+		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.16.1

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

* Re: Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-26 11:17   ` Mark Brown
  (?)
@ 2018-02-26 18:34   ` Kirill Marinushkin
  2018-02-26 19:47     ` Mark Brown
                       ` (2 more replies)
  -1 siblings, 3 replies; 28+ messages in thread
From: Kirill Marinushkin @ 2018-02-26 18:34 UTC (permalink / raw)
  To: Mark Brown; +Cc: Pan Xiuli, alsa-devel, stable

Hello Mark Brown, Pan Xiuli,

As far as I understand, the suggested commit *breaks* the functionality instead
of fixing it, and should not be applied. Please correct me if I am wrong.


1. The existing functionality works correctly, nothing to fix here.

Below is a comment from include/sound/soc-dai.h:77

~~~~
/*
 * DAI hardware clock masters.
 *
 * This is wrt the codec, the inverse is true for the interface
 * i.e. if the codec is clk and FRM master then the interface is
 * clk and frame slave.
 */
#define SND_SOC_DAIFMT_CBM_CFM		(1 << 12) /* codec clk & FRM master */
#define SND_SOC_DAIFMT_CBS_CFM		(2 << 12) /* codec clk slave & FRM master */
#define SND_SOC_DAIFMT_CBM_CFS		(3 << 12) /* codec clk master & frame slave */
#define SND_SOC_DAIFMT_CBS_CFS		(4 << 12) /* codec clk & FRM slave */
~~~~

According to the comment, the existing functionality works correctly "WRT the
interface". The suggested commit doesn't fix the behaviour: instead, it reverts
the logic to "WRT the codec". But the existing implementation is also valid.


2. The suggested commit breaks the existing ASoC.

The existing functionality already works with several existing ASoC by
Intel. The suggested commit will break it for the following reason:

The ALSA topology mechanism loads the binary topology file into ASoC. The
suggested commit modifies the parser, but the binaries are already created for
the existing functionality. As a result, all existing binaries will be parsed
incorrectly.


3. The suggested commit should not go into stable.

For the reasons explained earlier, applying the suggested commit into stable
kernel will break the stable kernel.

As I am not in the mailing list, I will not be able to stop Greg K-H
<gregkh@linuxfoundation.org> when he will ask "If you, or anyone else, feels it
should not be added to the stable tree, please let <stable@vger.kernel.org> know
about it."

@Mark Brown could you please add me to the thread if such situation happens, so
that I could share my point for the stable patches.

Best Regards,
Kirill

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

* Re: Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-26 18:34   ` Kirill Marinushkin
@ 2018-02-26 19:47     ` Mark Brown
  2018-02-27  4:38       ` Kirill Marinushkin
  2018-02-27  2:30     ` [alsa-devel] " Pierre-Louis Bossart
  2018-03-12 16:14     ` Mark Brown
  2 siblings, 1 reply; 28+ messages in thread
From: Mark Brown @ 2018-02-26 19:47 UTC (permalink / raw)
  To: Kirill Marinushkin; +Cc: Pan Xiuli, alsa-devel, stable

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

On Mon, Feb 26, 2018 at 07:34:07PM +0100, Kirill Marinushkin wrote:

> 2. The suggested commit breaks the existing ASoC.

> The existing functionality already works with several existing ASoC by
> Intel. The suggested commit will break it for the following reason:

> The ALSA topology mechanism loads the binary topology file into ASoC. The
> suggested commit modifies the parser, but the binaries are already created for
> the existing functionality. As a result, all existing binaries will be parsed
> incorrectly.

Are there actual binaries using the existing code or is that just
theoretical?  My impression was that this was fixing things for existing
binaries which were shipped for non-mainline kernels, is that not the
case?

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

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

* Re: [alsa-devel] Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-26 18:34   ` Kirill Marinushkin
  2018-02-26 19:47     ` Mark Brown
@ 2018-02-27  2:30     ` Pierre-Louis Bossart
  2018-02-27  4:50       ` Kirill Marinushkin
  2018-02-27 10:38       ` Mark Brown
  2018-03-12 16:14     ` Mark Brown
  2 siblings, 2 replies; 28+ messages in thread
From: Pierre-Louis Bossart @ 2018-02-27  2:30 UTC (permalink / raw)
  To: Kirill Marinushkin, Mark Brown
  Cc: alsa-devel, Pan Xiuli, stable, Liam Girdwood

On 2/26/18 10:34 AM, Kirill Marinushkin wrote:
> Hello Mark Brown, Pan Xiuli,
> 
> As far as I understand, the suggested commit *breaks* the functionality instead
> of fixing it, and should not be applied. Please correct me if I am wrong.
> 
> 
> 1. The existing functionality works correctly, nothing to fix here.
> 
> Below is a comment from include/sound/soc-dai.h:77
> 
> ~~~~
> /*
>   * DAI hardware clock masters.
>   *
>   * This is wrt the codec, the inverse is true for the interface
>   * i.e. if the codec is clk and FRM master then the interface is
>   * clk and frame slave.
>   */
> #define SND_SOC_DAIFMT_CBM_CFM		(1 << 12) /* codec clk & FRM master */
> #define SND_SOC_DAIFMT_CBS_CFM		(2 << 12) /* codec clk slave & FRM master */
> #define SND_SOC_DAIFMT_CBM_CFS		(3 << 12) /* codec clk master & frame slave */
> #define SND_SOC_DAIFMT_CBS_CFS		(4 << 12) /* codec clk & FRM slave */
> ~~~~
> 
> According to the comment, the existing functionality works correctly "WRT the
> interface". The suggested commit doesn't fix the behaviour: instead, it reverts
> the logic to "WRT the codec". But the existing implementation is also valid.

Look at all the machine drivers, they always use the mask by looking at 
the codec side. The comment on top means that the SOC side ('the 
interface') is the dual of the codec side.

This issue was found during the development of SOF (Sound Open Firmware) 
where we get the reverse of the intended behavior when using the same 
conventions in topology files as in machine drivers.

> 
> 
> 2. The suggested commit breaks the existing ASoC.
> 
> The existing functionality already works with several existing ASoC by
> Intel. The suggested commit will break it for the following reason:
> 
> The ALSA topology mechanism loads the binary topology file into ASoC. The
> suggested commit modifies the parser, but the binaries are already created for
> the existing functionality. As a result, all existing binaries will be parsed
> incorrectly.

I know there is a similar inversion in the alsa-lib topology files for 
Broadwell, the codec is marked as master when it really is slave. I 
don't know how Intel handled this on SKL.

But you have a point that if people used this inversion in the past it'd 
break functionality on existing devices which retrieve topology 
information from ACPI tables and binary files.

Gah. Maybe we should keep this inversion then, document it and 
compensate for it in topology creating tools. Liam, what do you think?

> 
> 
> 3. The suggested commit should not go into stable.
> 
> For the reasons explained earlier, applying the suggested commit into stable
> kernel will break the stable kernel.
> 
> As I am not in the mailing list, I will not be able to stop Greg K-H
> <gregkh@linuxfoundation.org> when he will ask "If you, or anyone else, feels it
> should not be added to the stable tree, please let <stable@vger.kernel.org> know
> about it."
> 
> @Mark Brown could you please add me to the thread if such situation happens, so
> that I could share my point for the stable patches.
> 
> Best Regards,
> Kirill
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

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

* Re: Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-26 19:47     ` Mark Brown
@ 2018-02-27  4:38       ` Kirill Marinushkin
  0 siblings, 0 replies; 28+ messages in thread
From: Kirill Marinushkin @ 2018-02-27  4:38 UTC (permalink / raw)
  To: Mark Brown; +Cc: Pan Xiuli, alsa-devel, stable

On 02/26/18 20:47, Mark Brown wrote:
> On Mon, Feb 26, 2018 at 07:34:07PM +0100, Kirill Marinushkin wrote:
>
>> 2. The suggested commit breaks the existing ASoC.
>> The existing functionality already works with several existing ASoC by
>> Intel. The suggested commit will break it for the following reason:
>> The ALSA topology mechanism loads the binary topology file into ASoC. The
>> suggested commit modifies the parser, but the binaries are already created for
>> the existing functionality. As a result, all existing binaries will be parsed
>> incorrectly.
> Are there actual binaries using the existing code or is that just
> theoretical?  My impression was that this was fixing things for existing
> binaries which were shipped for non-mainline kernels, is that not the
> case?

There is an actual conf, which can be converted into an actual binary:
`alsa-lib/src/conf/topology/broadwell/broadwell.conf`

Theoretically, there can be an unknown number of the binaries, not available publicly.

Broadwell exists for a long time, and there is no way to be sure that all the theoretically
existing binaries are modified together with this kernel patch.

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

* Re: [alsa-devel] Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-27  2:30     ` [alsa-devel] " Pierre-Louis Bossart
@ 2018-02-27  4:50       ` Kirill Marinushkin
  2018-02-27 10:38       ` Mark Brown
  1 sibling, 0 replies; 28+ messages in thread
From: Kirill Marinushkin @ 2018-02-27  4:50 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Mark Brown
  Cc: alsa-devel, Pan Xiuli, stable, Liam Girdwood

On 02/27/18 03:30, Pierre-Louis Bossart wrote:
> On 2/26/18 10:34 AM, Kirill Marinushkin wrote:
>> Hello Mark Brown, Pan Xiuli,
>>
>> As far as I understand, the suggested commit *breaks* the functionality instead
>> of fixing it, and should not be applied. Please correct me if I am wrong.
>>
>>
>> 1. The existing functionality works correctly, nothing to fix here.
>>
>> Below is a comment from include/sound/soc-dai.h:77
>>
>> ~~~~
>> /*
>>   * DAI hardware clock masters.
>>   *
>>   * This is wrt the codec, the inverse is true for the interface
>>   * i.e. if the codec is clk and FRM master then the interface is
>>   * clk and frame slave.
>>   */
>> #define SND_SOC_DAIFMT_CBM_CFM        (1 << 12) /* codec clk & FRM master */
>> #define SND_SOC_DAIFMT_CBS_CFM        (2 << 12) /* codec clk slave & FRM master */
>> #define SND_SOC_DAIFMT_CBM_CFS        (3 << 12) /* codec clk master & frame slave */
>> #define SND_SOC_DAIFMT_CBS_CFS        (4 << 12) /* codec clk & FRM slave */
>> ~~~~
>>
>> According to the comment, the existing functionality works correctly "WRT the
>> interface". The suggested commit doesn't fix the behaviour: instead, it reverts
>> the logic to "WRT the codec". But the existing implementation is also valid.
>
> Look at all the machine drivers, they always use the mask by looking at the codec side. The comment on top means that the SOC side ('the interface') is the dual of the codec side.
>

Yes, you are right. Analyzing from the codec side makes more sense.

> This issue was found during the development of SOF (Sound Open Firmware) where we get the reverse of the intended behavior when using the same conventions in topology files as in machine drivers.
>
>>
>>
>> 2. The suggested commit breaks the existing ASoC.
>>
>> The existing functionality already works with several existing ASoC by
>> Intel. The suggested commit will break it for the following reason:
>>
>> The ALSA topology mechanism loads the binary topology file into ASoC. The
>> suggested commit modifies the parser, but the binaries are already created for
>> the existing functionality. As a result, all existing binaries will be parsed
>> incorrectly.
>
> I know there is a similar inversion in the alsa-lib topology files for Broadwell, the codec is marked as master when it really is slave. I don't know how Intel handled this on SKL.
>
> But you have a point that if people used this inversion in the past it'd break functionality on existing devices which retrieve topology information from ACPI tables and binary files.
>

Yes. The Broadwell conf files, which you mentioned, demonstrate that this functionality is already used as it is.

> Gah. Maybe we should keep this inversion then, document it and compensate for it in topology creating tools. Liam, what do you think?
>
>>
>>
>> 3. The suggested commit should not go into stable.
>>
>> For the reasons explained earlier, applying the suggested commit into stable
>> kernel will break the stable kernel.
>>
>> As I am not in the mailing list, I will not be able to stop Greg K-H
>> <gregkh@linuxfoundation.org> when he will ask "If you, or anyone else, feels it
>> should not be added to the stable tree, please let <stable@vger.kernel.org> know
>> about it."
>>
>> @Mark Brown could you please add me to the thread if such situation happens, so
>> that I could share my point for the stable patches.
>>
>> Best Regards,
>> Kirill
>> _______________________________________________
>> Alsa-devel mailing list
>> Alsa-devel@alsa-project.org
>> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>>
>

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

* Re: [alsa-devel] Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-27  2:30     ` [alsa-devel] " Pierre-Louis Bossart
  2018-02-27  4:50       ` Kirill Marinushkin
@ 2018-02-27 10:38       ` Mark Brown
  2018-02-27 15:13         ` Pierre-Louis Bossart
  1 sibling, 1 reply; 28+ messages in thread
From: Mark Brown @ 2018-02-27 10:38 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Kirill Marinushkin, alsa-devel, Pan Xiuli, stable, Liam Girdwood

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

On Mon, Feb 26, 2018 at 06:30:15PM -0800, Pierre-Louis Bossart wrote:
> On 2/26/18 10:34 AM, Kirill Marinushkin wrote:

> > According to the comment, the existing functionality works correctly "WRT the
> > interface". The suggested commit doesn't fix the behaviour: instead, it reverts
> > the logic to "WRT the codec". But the existing implementation is also valid.

> Look at all the machine drivers, they always use the mask by looking at the
> codec side. The comment on top means that the SOC side ('the interface') is
> the dual of the codec side.

> This issue was found during the development of SOF (Sound Open Firmware)
> where we get the reverse of the intended behavior when using the same
> conventions in topology files as in machine drivers.

Is this perhaps something that the earlier firmware is handling inside
the firmware?

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

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

* Re: [alsa-devel] Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-27 10:38       ` Mark Brown
@ 2018-02-27 15:13         ` Pierre-Louis Bossart
  2018-02-27 15:57           ` Mark Brown
  0 siblings, 1 reply; 28+ messages in thread
From: Pierre-Louis Bossart @ 2018-02-27 15:13 UTC (permalink / raw)
  To: Mark Brown
  Cc: Kirill Marinushkin, alsa-devel, Pan Xiuli, stable, Liam Girdwood

On 2/27/18 2:38 AM, Mark Brown wrote:
> On Mon, Feb 26, 2018 at 06:30:15PM -0800, Pierre-Louis Bossart wrote:
>> On 2/26/18 10:34 AM, Kirill Marinushkin wrote:
> 
>>> According to the comment, the existing functionality works correctly "WRT the
>>> interface". The suggested commit doesn't fix the behaviour: instead, it reverts
>>> the logic to "WRT the codec". But the existing implementation is also valid.
> 
>> Look at all the machine drivers, they always use the mask by looking at the
>> codec side. The comment on top means that the SOC side ('the interface') is
>> the dual of the codec side.
> 
>> This issue was found during the development of SOF (Sound Open Firmware)
>> where we get the reverse of the intended behavior when using the same
>> conventions in topology files as in machine drivers.
> 
> Is this perhaps something that the earlier firmware is handling inside
> the firmware?

For SKL+ the SSP settings come from binary blobs read from ACPI/NHLT 
tables so I am wondering if this inversion is compensated for in the 
tools used to generate the blobs.

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

* Re: [alsa-devel] Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-27 15:13         ` Pierre-Louis Bossart
@ 2018-02-27 15:57           ` Mark Brown
  2018-02-27 20:33             ` [PATCH 0/1] " Kirill Marinushkin
  2018-02-28  6:22               ` Pierre-Louis Bossart
  0 siblings, 2 replies; 28+ messages in thread
From: Mark Brown @ 2018-02-27 15:57 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Kirill Marinushkin, alsa-devel, Pan Xiuli, stable, Liam Girdwood

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

On Tue, Feb 27, 2018 at 07:13:17AM -0800, Pierre-Louis Bossart wrote:
> On 2/27/18 2:38 AM, Mark Brown wrote:
> > On Mon, Feb 26, 2018 at 06:30:15PM -0800, Pierre-Louis Bossart wrote:

> > > This issue was found during the development of SOF (Sound Open Firmware)
> > > where we get the reverse of the intended behavior when using the same
> > > conventions in topology files as in machine drivers.

> > Is this perhaps something that the earlier firmware is handling inside
> > the firmware?

> For SKL+ the SSP settings come from binary blobs read from ACPI/NHLT tables
> so I am wondering if this inversion is compensated for in the tools used to
> generate the blobs.

Ugh, I'm confused here.  Is this a case of SoF differing from the
regular firmware somehow - presumably the stuff coming from the NHLT
table is the same for both firmwares?

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

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

* [PATCH 0/1] Re: Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-27 15:57           ` Mark Brown
@ 2018-02-27 20:33             ` Kirill Marinushkin
  2018-02-27 20:33               ` [PATCH 1/1] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
  2018-02-28  6:31               ` [alsa-devel] [PATCH 0/1] Re: Applied "ASoC: topology: Fix logical " Pierre-Louis Bossart
  2018-02-28  6:22               ` Pierre-Louis Bossart
  1 sibling, 2 replies; 28+ messages in thread
From: Kirill Marinushkin @ 2018-02-27 20:33 UTC (permalink / raw)
  To: Mark Brown
  Cc: Kirill Marinushkin, Pierre-Louis Bossart, Pan Xiuli,
	Liam Girdwood, linux-kernel, alsa-devel

Hello Mark, Pierre-Louis, Pan, Liam,

As there are too much open questions regarding the bclk and fsync inversion in
set_link_hw_format(), I would like to suggest the alternative solution.

This solution will fit both use-cases:

* existing use-cases (Broadwell, etc.)
* new use-cases (Sound Open Firmware, etc.)

The solution includes 1 patch for linux + 1 patch for alsa-lib.
I will send them to this mailing thread.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
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

Kirill Marinushkin (1):
  ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()

 include/uapi/sound/asoc.h | 16 ++++++++++++++--
 sound/soc/soc-topology.c  | 12 +++++++-----
 2 files changed, 21 insertions(+), 7 deletions(-)

-- 
2.13.6

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

* [PATCH 1/1] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-02-27 20:33             ` [PATCH 0/1] " Kirill Marinushkin
@ 2018-02-27 20:33               ` Kirill Marinushkin
  2018-02-27 20:35                 ` [PATCH, alsa-lib] " Kirill Marinushkin
  2018-04-16 17:15                   ` Mark Brown
  2018-02-28  6:31               ` [alsa-devel] [PATCH 0/1] Re: Applied "ASoC: topology: Fix logical " Pierre-Louis Bossart
  1 sibling, 2 replies; 28+ messages in thread
From: Kirill Marinushkin @ 2018-02-27 20:33 UTC (permalink / raw)
  To: Mark Brown
  Cc: Kirill Marinushkin, Pierre-Louis Bossart, Pan Xiuli,
	Liam Girdwood, linux-kernel, alsa-devel

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.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
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
---
 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] 28+ messages in thread

* [PATCH, alsa-lib] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-02-27 20:33               ` [PATCH 1/1] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
@ 2018-02-27 20:35                 ` Kirill Marinushkin
  2018-02-28 15:24                   ` Mark Brown
  2018-04-16 17:15                   ` Mark Brown
  1 sibling, 1 reply; 28+ messages in thread
From: Kirill Marinushkin @ 2018-02-27 20:35 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, alsa-devel, Pan Xiuli, Pierre-Louis Bossart,
	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>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Pan Xiuli <xiuli.pan@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: alsa-devel@alsa-project.org
---
 include/sound/asoc.h                       | 16 ++++++++++++++--
 src/conf/topology/broadwell/broadwell.conf |  4 ++--
 src/topology/pcm.c                         | 20 ++++++++++++++++----
 3 files changed, 32 insertions(+), 8 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/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 58cee31d..d5d5e5b3 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -1137,8 +1137,14 @@ 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;
+			/* For backwards capability,
+			 * "master" == "codec is slave"
+			 */
+			if (!strcmp(val, "master") ||
+			    !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 +1169,14 @@ 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;
+			/* For backwards capability,
+			 * "master" == "codec is slave"
+			 */
+			if (!strcmp(val, "master") ||
+			    !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] 28+ messages in thread

* Re: [alsa-devel] Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-27 15:57           ` Mark Brown
@ 2018-02-28  6:22               ` Pierre-Louis Bossart
  2018-02-28  6:22               ` Pierre-Louis Bossart
  1 sibling, 0 replies; 28+ messages in thread
From: Pierre-Louis Bossart @ 2018-02-28  6:22 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, alsa-devel, Pan Xiuli, stable, Kirill Marinushkin

On 2/27/18 7:57 AM, Mark Brown wrote:
> On Tue, Feb 27, 2018 at 07:13:17AM -0800, Pierre-Louis Bossart wrote:
>> On 2/27/18 2:38 AM, Mark Brown wrote:
>>> On Mon, Feb 26, 2018 at 06:30:15PM -0800, Pierre-Louis Bossart wrote:
> 
>>>> This issue was found during the development of SOF (Sound Open Firmware)
>>>> where we get the reverse of the intended behavior when using the same
>>>> conventions in topology files as in machine drivers.
> 
>>> Is this perhaps something that the earlier firmware is handling inside
>>> the firmware?
> 
>> For SKL+ the SSP settings come from binary blobs read from ACPI/NHLT tables
>> so I am wondering if this inversion is compensated for in the tools used to
>> generate the blobs.
> 
> Ugh, I'm confused here.  Is this a case of SoF differing from the
> regular firmware somehow - presumably the stuff coming from the NHLT
> table is the same for both firmwares?

no we are not using the NHLT info for now but using the one provided in 
topology files. the SOF firmware does not rely on blobs but programs the 
registers based on masks and settings passed. This difference is 
precisely how we exposed a difference in behavior.

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

* Re: Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
@ 2018-02-28  6:22               ` Pierre-Louis Bossart
  0 siblings, 0 replies; 28+ messages in thread
From: Pierre-Louis Bossart @ 2018-02-28  6:22 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, alsa-devel, Pan Xiuli, Kirill Marinushkin, stable

On 2/27/18 7:57 AM, Mark Brown wrote:
> On Tue, Feb 27, 2018 at 07:13:17AM -0800, Pierre-Louis Bossart wrote:
>> On 2/27/18 2:38 AM, Mark Brown wrote:
>>> On Mon, Feb 26, 2018 at 06:30:15PM -0800, Pierre-Louis Bossart wrote:
> 
>>>> This issue was found during the development of SOF (Sound Open Firmware)
>>>> where we get the reverse of the intended behavior when using the same
>>>> conventions in topology files as in machine drivers.
> 
>>> Is this perhaps something that the earlier firmware is handling inside
>>> the firmware?
> 
>> For SKL+ the SSP settings come from binary blobs read from ACPI/NHLT tables
>> so I am wondering if this inversion is compensated for in the tools used to
>> generate the blobs.
> 
> Ugh, I'm confused here.  Is this a case of SoF differing from the
> regular firmware somehow - presumably the stuff coming from the NHLT
> table is the same for both firmwares?

no we are not using the NHLT info for now but using the one provided in 
topology files. the SOF firmware does not rely on blobs but programs the 
registers based on masks and settings passed. This difference is 
precisely how we exposed a difference in behavior.

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

* Re: [alsa-devel] [PATCH 0/1] Re: Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-27 20:33             ` [PATCH 0/1] " Kirill Marinushkin
  2018-02-27 20:33               ` [PATCH 1/1] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
@ 2018-02-28  6:31               ` Pierre-Louis Bossart
  1 sibling, 0 replies; 28+ messages in thread
From: Pierre-Louis Bossart @ 2018-02-28  6:31 UTC (permalink / raw)
  To: Kirill Marinushkin, Mark Brown
  Cc: Pan Xiuli, Liam Girdwood, linux-kernel, alsa-devel

On 2/27/18 12:33 PM, Kirill Marinushkin wrote:
> Hello Mark, Pierre-Louis, Pan, Liam,
> 
> As there are too much open questions regarding the bclk and fsync inversion in
> set_link_hw_format(), I would like to suggest the alternative solution.
> 
> This solution will fit both use-cases:
> 
> * existing use-cases (Broadwell, etc.)
> * new use-cases (Sound Open Firmware, etc.)
> 
> The solution includes 1 patch for linux + 1 patch for alsa-lib.
> I will send them to this mailing thread.

That looks acceptable to me, Xiuli can you test with with the matching 
change in the SOF topology macros (we can keep the 'slave' in M4 files 
but expand to 'codec_slave' in the .conf to avoid making this exception 
visible).

> 
> Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> 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
> 
> Kirill Marinushkin (1):
>    ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
> 
>   include/uapi/sound/asoc.h | 16 ++++++++++++++--
>   sound/soc/soc-topology.c  | 12 +++++++-----
>   2 files changed, 21 insertions(+), 7 deletions(-)
> 

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

* Re: [PATCH, alsa-lib] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-02-27 20:35                 ` [PATCH, alsa-lib] " Kirill Marinushkin
@ 2018-02-28 15:24                   ` Mark Brown
  2018-02-28 15:29                     ` Takashi Iwai
  0 siblings, 1 reply; 28+ messages in thread
From: Mark Brown @ 2018-02-28 15:24 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: Liam Girdwood, alsa-devel, Pan Xiuli, Pierre-Louis Bossart


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

On Tue, Feb 27, 2018 at 09:35:41PM +0100, Kirill Marinushkin wrote:
> The values of bclk and fsync are inverted WRT the codec. But the existing
> solution already works for Broadwell, see the alsa-lib config:

You should include Jaroslav and Takashi when sending alsa-lib patches.

> +			/* For backwards capability,
> +			 * "master" == "codec is slave"
> +			 */
> +			if (!strcmp(val, "master") ||
> +			    !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;

Should we warn on use of "master" since it's being deprecated here (and
might be confusing for users)?

[-- 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] 28+ messages in thread

* Re: [PATCH, alsa-lib] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-02-28 15:24                   ` Mark Brown
@ 2018-02-28 15:29                     ` Takashi Iwai
  2018-02-28 15:59                       ` Mark Brown
  0 siblings, 1 reply; 28+ messages in thread
From: Takashi Iwai @ 2018-02-28 15:29 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Pan Xiuli, Pierre-Louis Bossart, Liam Girdwood,
	Kirill Marinushkin

On Wed, 28 Feb 2018 16:24:03 +0100,
Mark Brown wrote:
> 
> On Tue, Feb 27, 2018 at 09:35:41PM +0100, Kirill Marinushkin wrote:
> > The values of bclk and fsync are inverted WRT the codec. But the existing
> > solution already works for Broadwell, see the alsa-lib config:
> 
> You should include Jaroslav and Takashi when sending alsa-lib patches.

Yep, please at the next time.
(And, don't stick with an old thread, but refresh a new thread.)

> 
> > +			/* For backwards capability,
> > +			 * "master" == "codec is slave"
> > +			 */
> > +			if (!strcmp(val, "master") ||
> > +			    !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;
> 
> Should we warn on use of "master" since it's being deprecated here (and
> might be confusing for users)?

Maybe.  OTOH, it looks fully backward-compatible, so far, so it's not
that confusing yet.


thanks,

Takashi

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

* Re: [PATCH, alsa-lib] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-02-28 15:29                     ` Takashi Iwai
@ 2018-02-28 15:59                       ` Mark Brown
  2018-02-28 20:07                         ` Kirill Marinushkin
  0 siblings, 1 reply; 28+ messages in thread
From: Mark Brown @ 2018-02-28 15:59 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: alsa-devel, Pan Xiuli, Pierre-Louis Bossart, Liam Girdwood,
	Kirill Marinushkin


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

On Wed, Feb 28, 2018 at 04:29:30PM +0100, Takashi Iwai wrote:
> Mark Brown wrote:

> > Should we warn on use of "master" since it's being deprecated here (and
> > might be confusing for users)?

> Maybe.  OTOH, it looks fully backward-compatible, so far, so it's not
> that confusing yet.

Not a compatibility issue, yeah - more just that we've clearly already
got people confused so pushing people to the more explicit name might
avoid further issues down the line.

[-- 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] 28+ messages in thread

* Re: [PATCH, alsa-lib] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-02-28 15:59                       ` Mark Brown
@ 2018-02-28 20:07                         ` Kirill Marinushkin
  2018-02-28 21:27                           ` Takashi Iwai
  2018-03-01  6:03                           ` Pan, Xiuli
  0 siblings, 2 replies; 28+ messages in thread
From: Kirill Marinushkin @ 2018-02-28 20:07 UTC (permalink / raw)
  To: Mark Brown, Takashi Iwai, Pierre-Louis Bossart
  Cc: Liam Girdwood, alsa-devel, Pan Xiuli

@Pierre-Louis

> That looks acceptable to me, Xiuli can you test with with the matching change
> in the SOF topology macros (we can keep the 'slave' in M4 files but expand to
> 'codec_slave' in the .conf to avoid making this exception visible).

I don't see any comments from Pan Xiuli in the whole mailing thread.
Do we still wait for his feedback?


@Mark

>>> Should we warn on use of "master" since it's being deprecated here (and
>>> might be confusing for users)?

>> Maybe. OTOH, it looks fully backward-compatible, so far, so it's not that
>> confusing yet.

> Not a compatibility issue, yeah - more just that we've clearly already got people
> confused so pushing people to the more explicit name might avoid further
> issues down the line.

Agree with that. I will add a warning and send it as a patch v2.


@Takashi

> Yep, please at the next time. (And, don't stick with an old thread, but refresh a
> new thread.)

Yes, I will do so. I want to do this clean, so let me clarify before I start:

1. I will start a new thread, with linux [patch v2]
2. I will send the [patch, alsa-lib v2] in-reply to that linux [patch v2]
3. I will add all currently involved people as CC

Does it look correct?

Best Regards,
Kirill

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

* Re: [PATCH, alsa-lib] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-02-28 20:07                         ` Kirill Marinushkin
@ 2018-02-28 21:27                           ` Takashi Iwai
  2018-03-01  6:03                           ` Pan, Xiuli
  1 sibling, 0 replies; 28+ messages in thread
From: Takashi Iwai @ 2018-02-28 21:27 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: alsa-devel, Pan Xiuli, Pierre-Louis Bossart, Liam Girdwood, Mark Brown

On Wed, 28 Feb 2018 21:07:52 +0100,
Kirill Marinushkin wrote:
> 
> > Yep, please at the next time. (And, don't stick with an old thread, but refresh a
> > new thread.)
> 
> Yes, I will do so. I want to do this clean, so let me clarify before I start:
> 
> 1. I will start a new thread, with linux [patch v2]
> 2. I will send the [patch, alsa-lib v2] in-reply to that linux [patch v2]
> 3. I will add all currently involved people as CC
> 
> Does it look correct?

Yes, should be OK.


Takashi

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

* Re: [PATCH, alsa-lib] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-02-28 20:07                         ` Kirill Marinushkin
  2018-02-28 21:27                           ` Takashi Iwai
@ 2018-03-01  6:03                           ` Pan, Xiuli
  2018-03-02  5:44                             ` Kirill Marinushkin
  1 sibling, 1 reply; 28+ messages in thread
From: Pan, Xiuli @ 2018-03-01  6:03 UTC (permalink / raw)
  To: Kirill Marinushkin, Mark Brown, Takashi Iwai, Pierre-Louis Bossart
  Cc: Liam Girdwood, alsa-devel



On 3/1/2018 04:07, Kirill Marinushkin wrote:
> @Pierre-Louis
>
>> That looks acceptable to me, Xiuli can you test with with the matching change
>> in the SOF topology macros (we can keep the 'slave' in M4 files but expand to
>> 'codec_slave' in the .conf to avoid making this exception visible).
> I don't see any comments from Pan Xiuli in the whole mailing thread.
> Do we still wait for his feedback?

Sorry about the late reply, I have some wrong setting with my mail 
client and found all the mails related in the junk folder.
Thanks Pierre to remind me. I will do the test with the SOF topology and 
sent patch later.
The patches look good to me, we need to keep the old things work. The 
modify is simple but efficient. I will also send a reminder letter about 
these alsa-lib changes to our sof developer.

>
> @Mark
>
>>>> Should we warn on use of "master" since it's being deprecated here (and
>>>> might be confusing for users)?
>>> Maybe. OTOH, it looks fully backward-compatible, so far, so it's not that
>>> confusing yet.
>> Not a compatibility issue, yeah - more just that we've clearly already got people
>> confused so pushing people to the more explicit name might avoid further
>> issues down the line.
> Agree with that. I will add a warning and send it as a patch v2.
>
>
> @Takashi
>
>> Yep, please at the next time. (And, don't stick with an old thread, but refresh a
>> new thread.)
> Yes, I will do so. I want to do this clean, so let me clarify before I start:
>
> 1. I will start a new thread, with linux [patch v2]
> 2. I will send the [patch, alsa-lib v2] in-reply to that linux [patch v2]
> 3. I will add all currently involved people as CC
>
> Does it look correct?
I will look forward to test with new patches.

Thanks
Xiuli

> Best Regards,
> Kirill

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

* Re: [PATCH, alsa-lib] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
  2018-03-01  6:03                           ` Pan, Xiuli
@ 2018-03-02  5:44                             ` Kirill Marinushkin
  0 siblings, 0 replies; 28+ messages in thread
From: Kirill Marinushkin @ 2018-03-02  5:44 UTC (permalink / raw)
  To: Pan, Xiuli, Mark Brown, Takashi Iwai, Pierre-Louis Bossart
  Cc: Liam Girdwood, alsa-devel

Hello Mark, Takashi, Xiuli, Pierre-Louis,

The patch series v2 is available in the new mailing thread, subject
"[PATCH v2] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()".

Best Regards,
Kirill

On 03/01/18 07:03, Pan, Xiuli wrote:
>
>
> On 3/1/2018 04:07, Kirill Marinushkin wrote:
>> @Pierre-Louis
>>
>>> That looks acceptable to me, Xiuli can you test with with the matching change
>>> in the SOF topology macros (we can keep the 'slave' in M4 files but expand to
>>> 'codec_slave' in the .conf to avoid making this exception visible).
>> I don't see any comments from Pan Xiuli in the whole mailing thread.
>> Do we still wait for his feedback?
>
> Sorry about the late reply, I have some wrong setting with my mail client and found all the mails related in the junk folder.
> Thanks Pierre to remind me. I will do the test with the SOF topology and sent patch later.
> The patches look good to me, we need to keep the old things work. The modify is simple but efficient. I will also send a reminder letter about these alsa-lib changes to our sof developer.
>
>>
>> @Mark
>>
>>>>> Should we warn on use of "master" since it's being deprecated here (and
>>>>> might be confusing for users)?
>>>> Maybe. OTOH, it looks fully backward-compatible, so far, so it's not that
>>>> confusing yet.
>>> Not a compatibility issue, yeah - more just that we've clearly already got people
>>> confused so pushing people to the more explicit name might avoid further
>>> issues down the line.
>> Agree with that. I will add a warning and send it as a patch v2.
>>
>>
>> @Takashi
>>
>>> Yep, please at the next time. (And, don't stick with an old thread, but refresh a
>>> new thread.)
>> Yes, I will do so. I want to do this clean, so let me clarify before I start:
>>
>> 1. I will start a new thread, with linux [patch v2]
>> 2. I will send the [patch, alsa-lib v2] in-reply to that linux [patch v2]
>> 3. I will add all currently involved people as CC
>>
>> Does it look correct?
> I will look forward to test with new patches.
>
> Thanks
> Xiuli
>
>> Best Regards,
>> Kirill
>

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

* Re: Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-02-26 18:34   ` Kirill Marinushkin
  2018-02-26 19:47     ` Mark Brown
  2018-02-27  2:30     ` [alsa-devel] " Pierre-Louis Bossart
@ 2018-03-12 16:14     ` Mark Brown
  2018-03-12 23:29       ` [alsa-devel] " Pierre-Louis Bossart
  2 siblings, 1 reply; 28+ messages in thread
From: Mark Brown @ 2018-03-12 16:14 UTC (permalink / raw)
  To: Kirill Marinushkin; +Cc: Pan Xiuli, alsa-devel, stable

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

On Mon, Feb 26, 2018 at 07:34:07PM +0100, Kirill Marinushkin wrote:
> Hello Mark Brown, Pan Xiuli,
> 
> As far as I understand, the suggested commit *breaks* the functionality instead
> of fixing it, and should not be applied. Please correct me if I am wrong.

This discussion ground to a halt a bit (nobody from Intel seems to have
looked at Kirill's patches?) so I'm going to drop this patch for now,
I'll keep a copy around at test/topology.

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

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

* Re: [alsa-devel] Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree
  2018-03-12 16:14     ` Mark Brown
@ 2018-03-12 23:29       ` Pierre-Louis Bossart
  0 siblings, 0 replies; 28+ messages in thread
From: Pierre-Louis Bossart @ 2018-03-12 23:29 UTC (permalink / raw)
  To: Mark Brown, Kirill Marinushkin; +Cc: alsa-devel, Pan Xiuli, stable

On 3/12/18 11:14 AM, Mark Brown wrote:
> On Mon, Feb 26, 2018 at 07:34:07PM +0100, Kirill Marinushkin wrote:
>> Hello Mark Brown, Pan Xiuli,
>>
>> As far as I understand, the suggested commit *breaks* the functionality instead
>> of fixing it, and should not be applied. Please correct me if I am wrong.
> 
> This discussion ground to a halt a bit (nobody from Intel seems to have
> looked at Kirill's patches?) so I'm going to drop this patch for now,
> I'll keep a copy around at test/topology.

Sorry, we did look at Kirill's patches but wanted to test further, and 
of course we are caught in the middle of a release.
It's fine to drop this for now.

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

* Applied "ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()" to the asoc tree
  2018-02-27 20:33               ` [PATCH 1/1] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
@ 2018-04-16 17:15                   ` Mark Brown
  2018-04-16 17:15                   ` Mark Brown
  1 sibling, 0 replies; 28+ messages in thread
From: Mark Brown @ 2018-04-16 17:15 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: Pan Xiuli, Pierre-Louis Bossart, Jaroslav Kysela, Takashi Iwai,
	Mark Brown, Liam Girdwood, linux-kernel, alsa-devel, Mark Brown,
	Mark Brown, alsa-devel, Pan Xiuli, Pierre-Louis Bossart,
	linux-kernel, Liam Girdwood, alsa-devel

The patch

   ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()

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 a941e2fab3207cb0d57dc4ec47b1b12c8ea78b84 Mon Sep 17 00:00:00 2001
From: Kirill Marinushkin <k.marinushkin@gmail.com>
Date: Wed, 4 Apr 2018 06:19:37 +0200
Subject: [PATCH] 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.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.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
Signed-off-by: Mark Brown <broonie@kernel.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 942c6e5eb4b7..1c55252641f3 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -2019,13 +2019,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.17.0

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

* Applied "ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()" to the asoc tree
@ 2018-04-16 17:15                   ` Mark Brown
  0 siblings, 0 replies; 28+ messages in thread
From: Mark Brown @ 2018-04-16 17:15 UTC (permalink / raw)
  To: Kirill Marinushkin
  Cc: Pan Xiuli, Pierre-Louis Bossart, Jaroslav Kysela, Takashi Iwai,
	Mark Brown, Liam Girdwood, linux-kernel, alsa-devel

The patch

   ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()

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 a941e2fab3207cb0d57dc4ec47b1b12c8ea78b84 Mon Sep 17 00:00:00 2001
From: Kirill Marinushkin <k.marinushkin@gmail.com>
Date: Wed, 4 Apr 2018 06:19:37 +0200
Subject: [PATCH] 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.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.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
Signed-off-by: Mark Brown <broonie@kernel.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 942c6e5eb4b7..1c55252641f3 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -2019,13 +2019,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.17.0

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

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

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 22:01 [FIX][PATCH] ASoC: topology: Fix logical inversion in set_link_hw_format() Xiuli Pan
2018-02-26 11:17 ` Applied "ASoC: topology: Fix logical inversion in set_link_hw_format()" to the asoc tree Mark Brown
2018-02-26 11:17   ` Mark Brown
2018-02-26 18:34   ` Kirill Marinushkin
2018-02-26 19:47     ` Mark Brown
2018-02-27  4:38       ` Kirill Marinushkin
2018-02-27  2:30     ` [alsa-devel] " Pierre-Louis Bossart
2018-02-27  4:50       ` Kirill Marinushkin
2018-02-27 10:38       ` Mark Brown
2018-02-27 15:13         ` Pierre-Louis Bossart
2018-02-27 15:57           ` Mark Brown
2018-02-27 20:33             ` [PATCH 0/1] " Kirill Marinushkin
2018-02-27 20:33               ` [PATCH 1/1] ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format() Kirill Marinushkin
2018-02-27 20:35                 ` [PATCH, alsa-lib] " Kirill Marinushkin
2018-02-28 15:24                   ` Mark Brown
2018-02-28 15:29                     ` Takashi Iwai
2018-02-28 15:59                       ` Mark Brown
2018-02-28 20:07                         ` Kirill Marinushkin
2018-02-28 21:27                           ` Takashi Iwai
2018-03-01  6:03                           ` Pan, Xiuli
2018-03-02  5:44                             ` Kirill Marinushkin
2018-04-16 17:15                 ` Applied "ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()" to the asoc tree Mark Brown
2018-04-16 17:15                   ` Mark Brown
2018-02-28  6:31               ` [alsa-devel] [PATCH 0/1] Re: Applied "ASoC: topology: Fix logical " Pierre-Louis Bossart
2018-02-28  6:22             ` [alsa-devel] " Pierre-Louis Bossart
2018-02-28  6:22               ` Pierre-Louis Bossart
2018-03-12 16:14     ` Mark Brown
2018-03-12 23:29       ` [alsa-devel] " Pierre-Louis Bossart

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.