* [PATCH 0/3] ASoC: tas2562: Volume setting fixes
@ 2026-07-15 20:18 Mark Brown
2026-07-15 20:18 ` [PATCH 1/3] ASoC: tas2562: Validate values for volume writes Mark Brown
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Mark Brown @ 2026-07-15 20:18 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Sen Wang, Liam Girdwood
Cc: Haidar Lee, linux-sound, linux-kernel, Mark Brown, stable
While reviewing another fix for the tas2562 volume control I noticed a
few issues with the put() operation, this series fixes them.
It's also a bit weird that the volume control is defined with twice as
many values as can actually be set, probably the best fix there is to
regnerate the table of volume values with the intermediate values.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
Mark Brown (3):
ASoC: tas2562: Validate values for volume writes
ASoC: tas2562: Fix event generation for volume control
ASoC: tas2562: Fix default digital volume
sound/soc/codecs/tas2562.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa
change-id: 20260715-asoc-tas2562-put-retval-a5dd3e90fdb2
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] ASoC: tas2562: Validate values for volume writes
2026-07-15 20:18 [PATCH 0/3] ASoC: tas2562: Volume setting fixes Mark Brown
@ 2026-07-15 20:18 ` Mark Brown
2026-07-15 20:18 ` [PATCH 2/3] ASoC: tas2562: Fix event generation for volume control Mark Brown
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2026-07-15 20:18 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Sen Wang, Liam Girdwood
Cc: Haidar Lee, linux-sound, linux-kernel, Mark Brown, stable
tas2562_volume_control_put() does not do any validation of the control
value written by userspace, it uses it to look up a value in a fixed
size array which can easily be overflowed and then writes whatever value
it gets back to the device. Add validation that we are loading a value
we have in the array.
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
---
sound/soc/codecs/tas2562.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c
index 2f7cfc2be970..82bc0078a5c7 100644
--- a/sound/soc/codecs/tas2562.c
+++ b/sound/soc/codecs/tas2562.c
@@ -471,10 +471,14 @@ static int tas2562_volume_control_put(struct snd_kcontrol *kcontrol,
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct tas2562_data *tas2562 = snd_soc_component_get_drvdata(component);
- int ret;
+ int ret, index;
u32 reg_val;
- reg_val = float_vol_db_lookup[ucontrol->value.integer.value[0]/2];
+ index = ucontrol->value.integer.value[0] / 2;
+ if (index < 0 || index >= ARRAY_SIZE(float_vol_db_lookup))
+ return -EINVAL;
+
+ reg_val = float_vol_db_lookup[index];
ret = snd_soc_component_write(component, TAS2562_DVC_CFG4,
(reg_val & 0xff));
if (ret)
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] ASoC: tas2562: Fix event generation for volume control
2026-07-15 20:18 [PATCH 0/3] ASoC: tas2562: Volume setting fixes Mark Brown
2026-07-15 20:18 ` [PATCH 1/3] ASoC: tas2562: Validate values for volume writes Mark Brown
@ 2026-07-15 20:18 ` Mark Brown
2026-07-15 20:18 ` [PATCH 3/3] ASoC: tas2562: Fix default digital volume Mark Brown
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2026-07-15 20:18 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Sen Wang, Liam Girdwood
Cc: Haidar Lee, linux-sound, linux-kernel, Mark Brown
ALSA put() operations should return 0 for noop updates and 1 if the
value of the control changed, this is used by the ALSA core to generate
events to userspace. tas2562_volume_control_put() does not implement
this, it just writes whatever value userspace wrote to the device and
returns 0 regardless of what the previous value was. Fix this by
suppressing writes if the value is unchanged and returning 1 if the
writes succeed.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/tas2562.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c
index 82bc0078a5c7..9b863b000470 100644
--- a/sound/soc/codecs/tas2562.c
+++ b/sound/soc/codecs/tas2562.c
@@ -474,6 +474,9 @@ static int tas2562_volume_control_put(struct snd_kcontrol *kcontrol,
int ret, index;
u32 reg_val;
+ if (tas2562->volume_lvl == ucontrol->value.integer.value[0])
+ return 0;
+
index = ucontrol->value.integer.value[0] / 2;
if (index < 0 || index >= ARRAY_SIZE(float_vol_db_lookup))
return -EINVAL;
@@ -498,7 +501,7 @@ static int tas2562_volume_control_put(struct snd_kcontrol *kcontrol,
tas2562->volume_lvl = ucontrol->value.integer.value[0];
- return 0;
+ return 1;
}
/* Digital Volume Control. From 0 dB to -110 dB in 1 dB steps */
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] ASoC: tas2562: Fix default digital volume
2026-07-15 20:18 [PATCH 0/3] ASoC: tas2562: Volume setting fixes Mark Brown
2026-07-15 20:18 ` [PATCH 1/3] ASoC: tas2562: Validate values for volume writes Mark Brown
2026-07-15 20:18 ` [PATCH 2/3] ASoC: tas2562: Fix event generation for volume control Mark Brown
@ 2026-07-15 20:18 ` Mark Brown
2026-07-16 8:32 ` Cezary Rojewski
2026-07-16 8:31 ` [PATCH 0/3] ASoC: tas2562: Volume setting fixes Cezary Rojewski
2026-07-19 21:06 ` Mark Brown
4 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2026-07-15 20:18 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Sen Wang, Liam Girdwood
Cc: Haidar Lee, linux-sound, linux-kernel, Mark Brown
The tas2562 digital volume is spread over four registers and is implemented
as lookups into a table so the driver stores the value for the userspace
control in the driver data. This defaults to 0 due to kzalloc() but the
register default is 0x40400000 which maps onto something a bit over the
largest value defined in the lookup table. While it's not an exact match
update the default to the largest value, avoiding user surprise due to a
sudden change on first write.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/tas2562.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c
index 9b863b000470..5fdbfec8ce3f 100644
--- a/sound/soc/codecs/tas2562.c
+++ b/sound/soc/codecs/tas2562.c
@@ -738,6 +738,8 @@ static int tas2562_probe(struct i2c_client *client)
data->client = client;
data->dev = &client->dev;
data->model_id = (uintptr_t)i2c_get_match_data(client);
+ /* Register default is 0x40400000, this is closest */
+ data->volume_lvl = (ARRAY_SIZE(float_vol_db_lookup) - 1) * 2;
tas2562_parse_dt(data);
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] ASoC: tas2562: Volume setting fixes
2026-07-15 20:18 [PATCH 0/3] ASoC: tas2562: Volume setting fixes Mark Brown
` (2 preceding siblings ...)
2026-07-15 20:18 ` [PATCH 3/3] ASoC: tas2562: Fix default digital volume Mark Brown
@ 2026-07-16 8:31 ` Cezary Rojewski
2026-07-19 21:06 ` Mark Brown
4 siblings, 0 replies; 7+ messages in thread
From: Cezary Rojewski @ 2026-07-16 8:31 UTC (permalink / raw)
To: Mark Brown
Cc: Haidar Lee, linux-sound, linux-kernel, stable, Shenghao Ding,
Kevin Lu, Baojun Xu, Sen Wang, Liam Girdwood
On 7/15/2026 10:18 PM, Mark Brown wrote:
> While reviewing another fix for the tas2562 volume control I noticed a
> few issues with the put() operation, this series fixes them.
>
> It's also a bit weird that the volume control is defined with twice as
> many values as can actually be set, probably the best fix there is to
> regnerate the table of volume values with the intermediate values.
For the series:
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] ASoC: tas2562: Fix default digital volume
2026-07-15 20:18 ` [PATCH 3/3] ASoC: tas2562: Fix default digital volume Mark Brown
@ 2026-07-16 8:32 ` Cezary Rojewski
0 siblings, 0 replies; 7+ messages in thread
From: Cezary Rojewski @ 2026-07-16 8:32 UTC (permalink / raw)
To: Mark Brown
Cc: Haidar Lee, linux-sound, linux-kernel, Shenghao Ding, Kevin Lu,
Baojun Xu, Sen Wang, Liam Girdwood
On 7/15/2026 10:18 PM, Mark Brown wrote:
> The tas2562 digital volume is spread over four registers and is implemented
> as lookups into a table so the driver stores the value for the userspace
> control in the driver data. This defaults to 0 due to kzalloc() but the
> register default is 0x40400000 which maps onto something a bit over the
> largest value defined in the lookup table. While it's not an exact match
> update the default to the largest value, avoiding user surprise due to a
> sudden change on first write.
>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
> sound/soc/codecs/tas2562.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c
> index 9b863b000470..5fdbfec8ce3f 100644
> --- a/sound/soc/codecs/tas2562.c
> +++ b/sound/soc/codecs/tas2562.c
> @@ -738,6 +738,8 @@ static int tas2562_probe(struct i2c_client *client)
> data->client = client;
> data->dev = &client->dev;
> data->model_id = (uintptr_t)i2c_get_match_data(client);
> + /* Register default is 0x40400000, this is closest */
> + data->volume_lvl = (ARRAY_SIZE(float_vol_db_lookup) - 1) * 2;
Sounds like bug fix to me and a Fixes: candidate. That's a nitpick
though and not a blocker.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] ASoC: tas2562: Volume setting fixes
2026-07-15 20:18 [PATCH 0/3] ASoC: tas2562: Volume setting fixes Mark Brown
` (3 preceding siblings ...)
2026-07-16 8:31 ` [PATCH 0/3] ASoC: tas2562: Volume setting fixes Cezary Rojewski
@ 2026-07-19 21:06 ` Mark Brown
4 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2026-07-19 21:06 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Sen Wang, Liam Girdwood, Mark Brown
Cc: Haidar Lee, linux-sound, linux-kernel, stable
On Wed, 15 Jul 2026 21:18:08 +0100, Mark Brown wrote:
> ASoC: tas2562: Volume setting fixes
>
> While reviewing another fix for the tas2562 volume control I noticed a
> few issues with the put() operation, this series fixes them.
>
> It's also a bit weird that the volume control is defined with twice as
> many values as can actually be set, probably the best fix there is to
> regnerate the table of volume values with the intermediate values.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/3] ASoC: tas2562: Validate values for volume writes
https://git.kernel.org/broonie/sound/c/8fb41964f7e4
[2/3] ASoC: tas2562: Fix event generation for volume control
https://git.kernel.org/broonie/sound/c/9a9269dbbf1a
[3/3] ASoC: tas2562: Fix default digital volume
https://git.kernel.org/broonie/sound/c/58b638e7c455
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] 7+ messages in thread
end of thread, other threads:[~2026-07-20 13:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15 20:18 [PATCH 0/3] ASoC: tas2562: Volume setting fixes Mark Brown
2026-07-15 20:18 ` [PATCH 1/3] ASoC: tas2562: Validate values for volume writes Mark Brown
2026-07-15 20:18 ` [PATCH 2/3] ASoC: tas2562: Fix event generation for volume control Mark Brown
2026-07-15 20:18 ` [PATCH 3/3] ASoC: tas2562: Fix default digital volume Mark Brown
2026-07-16 8:32 ` Cezary Rojewski
2026-07-16 8:31 ` [PATCH 0/3] ASoC: tas2562: Volume setting fixes Cezary Rojewski
2026-07-19 21:06 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®