Skip to contentSkip to conversation

ASoC: Intel: cirrus-common: fix incorrect channel mapping

PATCH In review Brent Lu 4 participants 4 messages Jun 2, 2022 – Jun 3, 2022

Subsystems (3)
lore
Share & tools
lore

Brent Lu

author
#0 lore raw

PATCH v2 1/1 ASoC: Intel: cirrus-common: fix incorrect channel mapping

From: xliu <[email protected]>

The default mapping of ASPRX1 (DAC source) is slot 0. Change the slot mapping of right amplifiers (WR and TR) to slot 1 to receive right channel data. Also update the ACPI instance ID mapping according to HW configuration.

---
 sound/soc/intel/boards/sof_cirrus_common.c | 40 +++++++++++++++++++---
 1 file changed, 36 insertions(+), 4 deletions(-)
sound/soc/intel/boards/sof_cirrus_common.c +36 -4
index e71d74ec1b0b..f4192df962d6 100644
@@ -54,22 +54,29 @@ static struct snd_soc_dai_link_component cs35l41_components[] = {
 	},
 };
 
+/*
+ * Mapping between ACPI instance id and speaker position.
+ *
+ * Four speakers:
+ *         0: Tweeter left, 1: Woofer left
+ *         2: Tweeter right, 3: Woofer right
+ */
 static struct snd_soc_codec_conf cs35l41_codec_conf[] = {
 	{
 		.dlc = COMP_CODEC_CONF(CS35L41_DEV0_NAME),
-		.name_prefix = "WL",
+		.name_prefix = "TL",
 	},
 	{
 		.dlc = COMP_CODEC_CONF(CS35L41_DEV1_NAME),
-		.name_prefix = "WR",
+		.name_prefix = "WL",
 	},
 	{
 		.dlc = COMP_CODEC_CONF(CS35L41_DEV2_NAME),
-		.name_prefix = "TL",
+		.name_prefix = "TR",
 	},
 	{
 		.dlc = COMP_CODEC_CONF(CS35L41_DEV3_NAME),
-		.name_prefix = "TR",
+		.name_prefix = "WR",
 	},
 };
 
@@ -101,6 +108,21 @@ static int cs35l41_init(struct snd_soc_pcm_runtime *rtd)
 	return ret;
 }
 
+/*
+ * Channel map:
+ *
+ * TL/WL: ASPRX1 on slot 0, ASPRX2 on slot 1 (default)
+ * TR/WR: ASPRX1 on slot 1, ASPRX2 on slot 0
+ */
+static const struct {
+	unsigned int rx[2];
+} cs35l41_channel_map[] = {
+	{.rx = {0, 1}}, /* TL */
+	{.rx = {0, 1}}, /* WL */
+	{.rx = {1, 0}}, /* TR */
+	{.rx = {1, 0}}, /* WR */
+};
+
 static int cs35l41_hw_params(struct snd_pcm_substream *substream,
 			     struct snd_pcm_hw_params *params)
 {
@@ -134,6 +156,16 @@ static int cs35l41_hw_params(struct snd_pcm_substream *substream,
 				ret);
 			return ret;
 		}
+
+		/* setup channel map */
+		ret = snd_soc_dai_set_channel_map(codec_dai, 0, NULL,
+						  ARRAY_SIZE(cs35l41_channel_map[i].rx),
+						  (unsigned int *)cs35l41_channel_map[i].rx);
+		if (ret < 0) {
+			dev_err(codec_dai->dev, "fail to set channel map, ret %d\n",
+				ret);
+			return ret;
+		}
 	}
 
 	return 0;
Signature · 1 line
2.25.1
Acked-by on v2 1/1
#1 lore raw
Quoted 9 lines · Brent Lu

From: xliu <[email protected]>

The default mapping of ASPRX1 (DAC source) is slot 0. Change the slot mapping of right amplifiers (WR and TR) to slot 1 to receive right channel data. Also update the ACPI instance ID mapping according to HW configuration.

This v2 looks much better and self-explanatory. Thanks!

Quoted 81 lines
---
 sound/soc/intel/boards/sof_cirrus_common.c | 40 +++++++++++++++++++---
 1 file changed, 36 insertions(+), 4 deletions(-)
sound/soc/intel/boards/sof_cirrus_common.c +36 -4
index e71d74ec1b0b..f4192df962d6 100644
@@ -54,22 +54,29 @@ static struct snd_soc_dai_link_component cs35l41_components[] = {
 	},
 };
 
+/*
+ * Mapping between ACPI instance id and speaker position.
+ *
+ * Four speakers:
+ *         0: Tweeter left, 1: Woofer left
+ *         2: Tweeter right, 3: Woofer right
+ */
 static struct snd_soc_codec_conf cs35l41_codec_conf[] = {
 	{
 		.dlc = COMP_CODEC_CONF(CS35L41_DEV0_NAME),
-		.name_prefix = "WL",
+		.name_prefix = "TL",
 	},
 	{
 		.dlc = COMP_CODEC_CONF(CS35L41_DEV1_NAME),
-		.name_prefix = "WR",
+		.name_prefix = "WL",
 	},
 	{
 		.dlc = COMP_CODEC_CONF(CS35L41_DEV2_NAME),
-		.name_prefix = "TL",
+		.name_prefix = "TR",
 	},
 	{
 		.dlc = COMP_CODEC_CONF(CS35L41_DEV3_NAME),
-		.name_prefix = "TR",
+		.name_prefix = "WR",
 	},
 };
 
@@ -101,6 +108,21 @@ static int cs35l41_init(struct snd_soc_pcm_runtime *rtd)
 	return ret;
 }
 
+/*
+ * Channel map:
+ *
+ * TL/WL: ASPRX1 on slot 0, ASPRX2 on slot 1 (default)
+ * TR/WR: ASPRX1 on slot 1, ASPRX2 on slot 0
+ */
+static const struct {
+	unsigned int rx[2];
+} cs35l41_channel_map[] = {
+	{.rx = {0, 1}}, /* TL */
+	{.rx = {0, 1}}, /* WL */
+	{.rx = {1, 0}}, /* TR */
+	{.rx = {1, 0}}, /* WR */
+};
+
 static int cs35l41_hw_params(struct snd_pcm_substream *substream,
 			     struct snd_pcm_hw_params *params)
 {
@@ -134,6 +156,16 @@ static int cs35l41_hw_params(struct snd_pcm_substream *substream,
 				ret);
 			return ret;
 		}
+
+		/* setup channel map */
+		ret = snd_soc_dai_set_channel_map(codec_dai, 0, NULL,
+						  ARRAY_SIZE(cs35l41_channel_map[i].rx),
+						  (unsigned int *)cs35l41_channel_map[i].rx);
+		if (ret < 0) {
+			dev_err(codec_dai->dev, "fail to set channel map, ret %d\n",
+				ret);
+			return ret;
+		}
 	}
 
 	return 0;
Acked-by Pierre-Louis Bossart
#2 lore raw
git send-email \
    --in-reply-to=53e13af2-d279-372c-0b5b-fdf3277e0231@linux.intel.com<mailto:--in-reply-to=53e13af2-d279-372c-0b5b-fdf3277e0231@linux.intel.com> \

    [email protected]<mailto:[email protected]> \

    [email protected]<mailto:[email protected]> \

    [email protected]<mailto:[email protected]> \

Best Regards

--Xiang Liu
Email: [email protected]<mailto:[email protected]>
Mobile: +86 13810448973

From: Pierre-Louis Bossart <[email protected]>
Date: Thursday, June 2, 2022 at 22:23
To: Brent Lu <[email protected]>, [email protected] <[email protected]>
Cc: Cezary Rojewski <[email protected]>, [email protected] <[email protected]>, Takashi Iwai <[email protected]>, Jie Yang <[email protected]>, Liam Girdwood <[email protected]>, Mark Brown <[email protected]>, Xiang Liu <[email protected]>, Bard Liao <[email protected]>
Subject: Re: [PATCH v2] ASoC: Intel: cirrus-common: fix incorrect channel mapping
Caution: EXTERNAL email

Quoted 9 lines · Brent Lu

From: xliu <[email protected]>

The default mapping of ASPRX1 (DAC source) is slot 0. Change the slot mapping of right amplifiers (WR and TR) to slot 1 to receive right channel data. Also update the ACPI instance ID mapping according to HW configuration.

This v2 looks much better and self-explanatory. Thanks!

Quoted 81 lines
---
 sound/soc/intel/boards/sof_cirrus_common.c | 40 +++++++++++++++++++---
 1 file changed, 36 insertions(+), 4 deletions(-)
sound/soc/intel/boards/sof_cirrus_common.c +36 -4
index e71d74ec1b0b..f4192df962d6 100644
@@ -54,22 +54,29 @@ static struct snd_soc_dai_link_component cs35l41_components[] = {
       },
 };
 
+/*
+ * Mapping between ACPI instance id and speaker position.
+ *
+ * Four speakers:
+ *         0: Tweeter left, 1: Woofer left
+ *         2: Tweeter right, 3: Woofer right
+ */
 static struct snd_soc_codec_conf cs35l41_codec_conf[] = {
       {
               .dlc = COMP_CODEC_CONF(CS35L41_DEV0_NAME),
-             .name_prefix = "WL",
+             .name_prefix = "TL",
       },
       {
               .dlc = COMP_CODEC_CONF(CS35L41_DEV1_NAME),
-             .name_prefix = "WR",
+             .name_prefix = "WL",
       },
       {
               .dlc = COMP_CODEC_CONF(CS35L41_DEV2_NAME),
-             .name_prefix = "TL",
+             .name_prefix = "TR",
       },
       {
               .dlc = COMP_CODEC_CONF(CS35L41_DEV3_NAME),
-             .name_prefix = "TR",
+             .name_prefix = "WR",
       },
 };
 
@@ -101,6 +108,21 @@ static int cs35l41_init(struct snd_soc_pcm_runtime *rtd)
       return ret;
 }
 
+/*
+ * Channel map:
+ *
+ * TL/WL: ASPRX1 on slot 0, ASPRX2 on slot 1 (default)
+ * TR/WR: ASPRX1 on slot 1, ASPRX2 on slot 0
+ */
+static const struct {
+     unsigned int rx[2];
+} cs35l41_channel_map[] = {
+     {.rx = {0, 1}}, /* TL */
+     {.rx = {0, 1}}, /* WL */
+     {.rx = {1, 0}}, /* TR */
+     {.rx = {1, 0}}, /* WR */
+};
+
 static int cs35l41_hw_params(struct snd_pcm_substream *substream,
                            struct snd_pcm_hw_params *params)
 {
@@ -134,6 +156,16 @@ static int cs35l41_hw_params(struct snd_pcm_substream *substream,
                               ret);
                       return ret;
               }
+
+             /* setup channel map */
+             ret = snd_soc_dai_set_channel_map(codec_dai, 0, NULL,
+                                               ARRAY_SIZE(cs35l41_channel_map[i].rx),
+                                               (unsigned int *)cs35l41_channel_map[i].rx);
+             if (ret < 0) {
+                     dev_err(codec_dai->dev, "fail to set channel map, ret %d\n",
+                             ret);
+                     return ret;
+             }
       }
 
       return 0;
maintainer
#3 lore raw
In reply to Brent Lu
Quoted 8 lines · Brent Lu

From: xliu <[email protected]>

The default mapping of ASPRX1 (DAC source) is slot 0. Change the slot mapping of right amplifiers (WR and TR) to slot 1 to receive right channel data. Also update the ACPI instance ID mapping according to HW configuration.

[...]

Applied to

broonie/sound.git for-linus

Thanks!

[1/1] ASoC: Intel: cirrus-common: fix incorrect channel mapping

      commit: d69a155555c9d57463b788c400f6b452d976bacd

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