* [PATCH v1 0/2] ASoC: intel/sdw_utils: Add volume limits to CS35L56 and CS42L43 speakers
@ 2025-04-30 10:31 Stefan Binding
2025-04-30 10:31 ` [PATCH v1 1/2] ASoC: intel/sdw_utils: Add volume limit to cs42l43 speakers Stefan Binding
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Stefan Binding @ 2025-04-30 10:31 UTC (permalink / raw)
To: Mark Brown, Vijendar Mukunda, Bard Liao, Péter Ujfalusi
Cc: linux-sound, linux-kernel, patches, Stefan Binding
Both CS35L56 and CS42L43 have maximum volumes above 0dB.
However, for many use cases, this can cause distorted audio, depending
various factors, such as other signal-processing elements in the chain,
for example if the audio passes through a gain control before reaching
the amp or the signal path has been tuned for a particular maximum
gain in the amp.
In the cases where systems use the soc_sdw_* drivers, audio above the
0dB volume will likely always be distorted, therefore apply a 0dB
limit to those devices.
Stefan Binding (2):
ASoC: intel/sdw_utils: Add volume limit to cs42l43 speakers
ASoC: intel/sdw_utils: Add volume limit to cs35l56 speakers
include/sound/soc_sdw_utils.h | 1 +
sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c | 4 ++++
sound/soc/sdw_utils/soc_sdw_cs42l43.c | 10 ++++++++
sound/soc/sdw_utils/soc_sdw_cs_amp.c | 24 ++++++++++++++++++++
4 files changed, 39 insertions(+)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 1/2] ASoC: intel/sdw_utils: Add volume limit to cs42l43 speakers
2025-04-30 10:31 [PATCH v1 0/2] ASoC: intel/sdw_utils: Add volume limits to CS35L56 and CS42L43 speakers Stefan Binding
@ 2025-04-30 10:31 ` Stefan Binding
2025-04-30 12:05 ` Charles Keepax
2025-04-30 10:31 ` [PATCH v1 2/2] ASoC: intel/sdw_utils: Add volume limit to cs35l56 speakers Stefan Binding
2025-05-01 6:38 ` [PATCH v1 0/2] ASoC: intel/sdw_utils: Add volume limits to CS35L56 and CS42L43 speakers Mark Brown
2 siblings, 1 reply; 5+ messages in thread
From: Stefan Binding @ 2025-04-30 10:31 UTC (permalink / raw)
To: Mark Brown, Vijendar Mukunda, Bard Liao, Péter Ujfalusi
Cc: linux-sound, linux-kernel, patches, Stefan Binding
The volume control for cs42l43 speakers has a maximum gain of +31.5 dB.
However, for many use cases, this can cause distorted audio, depending
various factors, such as other signal-processing elements in the chain,
for example if the audio passes through a gain control before reaching
the codec or the signal path has been tuned for a particular maximum
gain in the codec.
In the case of systems which use the soc_sdw_cs42l43 driver, audio will
likely be distorted in all cases above 0 dB, therefore add a volume
limit of 128, which is 0 dB maximum volume inside this driver.
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
sound/soc/sdw_utils/soc_sdw_cs42l43.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/sound/soc/sdw_utils/soc_sdw_cs42l43.c b/sound/soc/sdw_utils/soc_sdw_cs42l43.c
index 668c9d28a1c1..b415d45d520d 100644
--- a/sound/soc/sdw_utils/soc_sdw_cs42l43.c
+++ b/sound/soc/sdw_utils/soc_sdw_cs42l43.c
@@ -20,6 +20,8 @@
#include <sound/soc-dapm.h>
#include <sound/soc_sdw_utils.h>
+#define CS42L43_SPK_VOLUME_0DB 128 /* 0dB Max */
+
static const struct snd_soc_dapm_route cs42l43_hs_map[] = {
{ "Headphone", NULL, "cs42l43 AMP3_OUT" },
{ "Headphone", NULL, "cs42l43 AMP4_OUT" },
@@ -117,6 +119,14 @@ int asoc_sdw_cs42l43_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_so
return -ENOMEM;
}
+ ret = snd_soc_limit_volume(card, "cs42l43 Speaker Digital Volume",
+ CS42L43_SPK_VOLUME_0DB);
+ if (ret)
+ dev_err(card->dev, "cs42l43 speaker volume limit failed: %d\n", ret);
+ else
+ dev_info(card->dev, "Setting CS42L43 Speaker volume limit to %d\n",
+ CS42L43_SPK_VOLUME_0DB);
+
ret = snd_soc_dapm_add_routes(&card->dapm, cs42l43_spk_map,
ARRAY_SIZE(cs42l43_spk_map));
if (ret)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 2/2] ASoC: intel/sdw_utils: Add volume limit to cs35l56 speakers
2025-04-30 10:31 [PATCH v1 0/2] ASoC: intel/sdw_utils: Add volume limits to CS35L56 and CS42L43 speakers Stefan Binding
2025-04-30 10:31 ` [PATCH v1 1/2] ASoC: intel/sdw_utils: Add volume limit to cs42l43 speakers Stefan Binding
@ 2025-04-30 10:31 ` Stefan Binding
2025-05-01 6:38 ` [PATCH v1 0/2] ASoC: intel/sdw_utils: Add volume limits to CS35L56 and CS42L43 speakers Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Stefan Binding @ 2025-04-30 10:31 UTC (permalink / raw)
To: Mark Brown, Vijendar Mukunda, Bard Liao, Péter Ujfalusi
Cc: linux-sound, linux-kernel, patches, Stefan Binding
The volume control for cs35l56 speakers has a maximum gain of +12 dB.
However, for many use cases, this can cause distorted audio, depending
various factors, such as other signal-processing elements in the chain,
for example if the audio passes through a gain control before reaching
the amp or the signal path has been tuned for a particular maximum
gain in the amp.
In the case of systems which use the soc_sdw_* driver, audio will
likely be distorted in all cases above 0 dB, therefore add a volume
limit of 400, which is 0 dB maximum volume inside this driver.
The volume limit should be applied to both soundwire and soundwire
bridge configurations.
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
include/sound/soc_sdw_utils.h | 1 +
sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c | 4 ++++
sound/soc/sdw_utils/soc_sdw_cs_amp.c | 24 ++++++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/include/sound/soc_sdw_utils.h b/include/sound/soc_sdw_utils.h
index 36a4a1e1d8ca..d8bd5d37131a 100644
--- a/include/sound/soc_sdw_utils.h
+++ b/include/sound/soc_sdw_utils.h
@@ -226,6 +226,7 @@ int asoc_sdw_cs_amp_init(struct snd_soc_card *card,
bool playback);
int asoc_sdw_cs_spk_feedback_rtd_init(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_dai *dai);
+int asoc_sdw_cs35l56_volume_limit(struct snd_soc_card *card, const char *name_prefix);
/* MAXIM codec support */
int asoc_sdw_maxim_init(struct snd_soc_card *card,
diff --git a/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c b/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c
index 246e5c2e0af5..c7e55f443351 100644
--- a/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c
+++ b/sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c
@@ -60,6 +60,10 @@ static int asoc_sdw_bridge_cs35l56_asp_init(struct snd_soc_pcm_runtime *rtd)
/* 4 x 16-bit sample slots and FSYNC=48000, BCLK=3.072 MHz */
for_each_rtd_codec_dais(rtd, i, codec_dai) {
+ ret = asoc_sdw_cs35l56_volume_limit(card, codec_dai->component->name_prefix);
+ if (ret)
+ return ret;
+
ret = snd_soc_dai_set_tdm_slot(codec_dai, tx_mask, rx_mask, 4, 16);
if (ret < 0)
return ret;
diff --git a/sound/soc/sdw_utils/soc_sdw_cs_amp.c b/sound/soc/sdw_utils/soc_sdw_cs_amp.c
index 4b6181cf2971..35b550bcd4de 100644
--- a/sound/soc/sdw_utils/soc_sdw_cs_amp.c
+++ b/sound/soc/sdw_utils/soc_sdw_cs_amp.c
@@ -16,6 +16,25 @@
#define CODEC_NAME_SIZE 8
#define CS_AMP_CHANNELS_PER_AMP 4
+#define CS35L56_SPK_VOLUME_0DB 400 /* 0dB Max */
+
+int asoc_sdw_cs35l56_volume_limit(struct snd_soc_card *card, const char *name_prefix)
+{
+ char *volume_ctl_name;
+ int ret;
+
+ volume_ctl_name = kasprintf(GFP_KERNEL, "%s Speaker Volume", name_prefix);
+ if (!volume_ctl_name)
+ return -ENOMEM;
+
+ ret = snd_soc_limit_volume(card, volume_ctl_name, CS35L56_SPK_VOLUME_0DB);
+ if (ret)
+ dev_err(card->dev, "%s limit set failed: %d\n", volume_ctl_name, ret);
+
+ kfree(volume_ctl_name);
+ return ret;
+}
+EXPORT_SYMBOL_NS(asoc_sdw_cs35l56_volume_limit, "SND_SOC_SDW_UTILS");
int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
{
@@ -40,6 +59,11 @@ int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai
snprintf(widget_name, sizeof(widget_name), "%s SPK",
codec_dai->component->name_prefix);
+
+ ret = asoc_sdw_cs35l56_volume_limit(card, codec_dai->component->name_prefix);
+ if (ret)
+ return ret;
+
ret = snd_soc_dapm_add_routes(&card->dapm, &route, 1);
if (ret)
return ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/2] ASoC: intel/sdw_utils: Add volume limit to cs42l43 speakers
2025-04-30 10:31 ` [PATCH v1 1/2] ASoC: intel/sdw_utils: Add volume limit to cs42l43 speakers Stefan Binding
@ 2025-04-30 12:05 ` Charles Keepax
0 siblings, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2025-04-30 12:05 UTC (permalink / raw)
To: Stefan Binding
Cc: Mark Brown, Vijendar Mukunda, Bard Liao, Péter Ujfalusi,
linux-sound, linux-kernel, patches
On Wed, Apr 30, 2025 at 11:31:19AM +0100, Stefan Binding wrote:
> The volume control for cs42l43 speakers has a maximum gain of +31.5 dB.
> However, for many use cases, this can cause distorted audio, depending
> various factors, such as other signal-processing elements in the chain,
> for example if the audio passes through a gain control before reaching
> the codec or the signal path has been tuned for a particular maximum
> gain in the codec.
>
> In the case of systems which use the soc_sdw_cs42l43 driver, audio will
> likely be distorted in all cases above 0 dB, therefore add a volume
> limit of 128, which is 0 dB maximum volume inside this driver.
>
> Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
> ---
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 0/2] ASoC: intel/sdw_utils: Add volume limits to CS35L56 and CS42L43 speakers
2025-04-30 10:31 [PATCH v1 0/2] ASoC: intel/sdw_utils: Add volume limits to CS35L56 and CS42L43 speakers Stefan Binding
2025-04-30 10:31 ` [PATCH v1 1/2] ASoC: intel/sdw_utils: Add volume limit to cs42l43 speakers Stefan Binding
2025-04-30 10:31 ` [PATCH v1 2/2] ASoC: intel/sdw_utils: Add volume limit to cs35l56 speakers Stefan Binding
@ 2025-05-01 6:38 ` Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2025-05-01 6:38 UTC (permalink / raw)
To: Vijendar Mukunda, Bard Liao, Péter Ujfalusi, Stefan Binding
Cc: linux-sound, linux-kernel, patches
On Wed, 30 Apr 2025 11:31:18 +0100, Stefan Binding wrote:
> Both CS35L56 and CS42L43 have maximum volumes above 0dB.
> However, for many use cases, this can cause distorted audio, depending
> various factors, such as other signal-processing elements in the chain,
> for example if the audio passes through a gain control before reaching
> the amp or the signal path has been tuned for a particular maximum
> gain in the amp.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: intel/sdw_utils: Add volume limit to cs42l43 speakers
commit: 02b44a2b2bdcee03cbb92484d31e9ca1b91b2a38
[2/2] ASoC: intel/sdw_utils: Add volume limit to cs35l56 speakers
commit: d5463e531c128ff1b141fdba2e13345cd50028a4
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-01 6:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-30 10:31 [PATCH v1 0/2] ASoC: intel/sdw_utils: Add volume limits to CS35L56 and CS42L43 speakers Stefan Binding
2025-04-30 10:31 ` [PATCH v1 1/2] ASoC: intel/sdw_utils: Add volume limit to cs42l43 speakers Stefan Binding
2025-04-30 12:05 ` Charles Keepax
2025-04-30 10:31 ` [PATCH v1 2/2] ASoC: intel/sdw_utils: Add volume limit to cs35l56 speakers Stefan Binding
2025-05-01 6:38 ` [PATCH v1 0/2] ASoC: intel/sdw_utils: Add volume limits to CS35L56 and CS42L43 speakers Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox