summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-07-19 22:06:01 +0100
committerMark Brown <broonie@kernel.org>2026-07-19 22:06:01 +0100
commit07f545657dabf9b009fc484414933fd2a359b4d3 (patch)
tree3ba5c3083e385653e9511c243b24d9211e1d7d28
parent2330e5fee602116357f6c9e56b4c9bcf25ff1327 (diff)
parent58b638e7c4559b35367a25e319adfe91e8f5ebe7 (diff)
ASoC: tas2562: Volume setting fixes
Mark Brown <broonie@kernel.org> says: 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. Link: https://patch.msgid.link/20260715-asoc-tas2562-put-retval-v1-0-97bf467c924e@kernel.org
-rw-r--r--sound/soc/codecs/tas2562.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sound/soc/codecs/tas2562.c b/sound/soc/codecs/tas2562.c
index cdd695c3807e..0b8644ad74f1 100644
--- a/sound/soc/codecs/tas2562.c
+++ b/sound/soc/codecs/tas2562.c
@@ -472,10 +472,18 @@ 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];
+ 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;
+
+ reg_val = float_vol_db_lookup[index];
+
/*
* The device applies the 32-bit coefficient to the playback path on
* the write to DVC_CFG4 (the LSB, book 0 page 2 reg 0x0F), so the
@@ -502,7 +510,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 */
@@ -740,6 +748,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);