* [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV
[not found] <20100618023810.GS7759@www.longlandclan.yi.org>
@ 2010-06-18 2:56 ` Stuart Longland
2010-06-18 10:29 ` Liam Girdwood
2010-06-19 1:36 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Stuart Longland @ 2010-06-18 2:56 UTC (permalink / raw)
To: ALSA Development List
Cc: alsa-devel, Takashi Iwai, Liam Girdwood, Mark Brown,
Linux ARM Kernel, Linux Kernel
When SX_TLV widgets are read, if the gain is set to a value below 0dB,
the mixer control is erroniously read as being at maximum volume.
The value read out of the CODEC register is never sign-extended, and
when the minimum value is subtracted (read; added, since the minimum is
negative) the result is a number greater than the maximum allowed value
for the control, and hence it saturates.
Solution: Mask the result so that it "wraps around", emulating
sign-extension.
Signed-off-by: Stuart Longland <redhatter@gentoo.org>
---
sound/soc/soc-core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a82a797..0470288 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2400,8 +2400,8 @@ int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
int val = snd_soc_read(codec, mc->reg) & mask;
int valr = snd_soc_read(codec, mc->rreg) & mask;
- ucontrol->value.integer.value[0] = ((val & 0xff)-min);
- ucontrol->value.integer.value[1] = ((valr & 0xff)-min);
+ ucontrol->value.integer.value[0] = ((val & 0xff)-min) & mask;
+ ucontrol->value.integer.value[1] = ((valr & 0xff)-min) & mask;
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r_sx);
--
1.6.4.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV
2010-06-18 2:56 ` [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV Stuart Longland
@ 2010-06-18 10:29 ` Liam Girdwood
2010-06-19 1:36 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2010-06-18 10:29 UTC (permalink / raw)
To: Stuart Longland
Cc: ALSA Development List, Takashi Iwai, Mark Brown,
Linux ARM Kernel, Linux Kernel
On Fri, 2010-06-18 at 12:56 +1000, Stuart Longland wrote:
> When SX_TLV widgets are read, if the gain is set to a value below 0dB,
> the mixer control is erroniously read as being at maximum volume.
>
> The value read out of the CODEC register is never sign-extended, and
> when the minimum value is subtracted (read; added, since the minimum is
> negative) the result is a number greater than the maximum allowed value
> for the control, and hence it saturates.
>
> Solution: Mask the result so that it "wraps around", emulating
> sign-extension.
>
> Signed-off-by: Stuart Longland <redhatter@gentoo.org>
> ---
> sound/soc/soc-core.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index a82a797..0470288 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2400,8 +2400,8 @@ int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol,
> int val = snd_soc_read(codec, mc->reg) & mask;
> int valr = snd_soc_read(codec, mc->rreg) & mask;
>
> - ucontrol->value.integer.value[0] = ((val & 0xff)-min);
> - ucontrol->value.integer.value[1] = ((valr & 0xff)-min);
> + ucontrol->value.integer.value[0] = ((val & 0xff)-min) & mask;
> + ucontrol->value.integer.value[1] = ((valr & 0xff)-min) & mask;
> return 0;
> }
> EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r_sx);
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV
2010-06-18 2:56 ` [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV Stuart Longland
2010-06-18 10:29 ` Liam Girdwood
@ 2010-06-19 1:36 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2010-06-19 1:36 UTC (permalink / raw)
To: Stuart Longland
Cc: ALSA Development List, Takashi Iwai, Liam Girdwood,
Linux ARM Kernel, Linux Kernel
On Fri, Jun 18, 2010 at 12:56:10PM +1000, Stuart Longland wrote:
> When SX_TLV widgets are read, if the gain is set to a value below 0dB,
> the mixer control is erroniously read as being at maximum volume.
Applied, thanks.
BTW, you might want to have a look at the CCs - you probably don't need
to CCing the ARM list for ASoC patches that aren't ARM specific, for
example.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-19 1:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20100618023810.GS7759@www.longlandclan.yi.org>
2010-06-18 2:56 ` [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV Stuart Longland
2010-06-18 10:29 ` Liam Girdwood
2010-06-19 1:36 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome