From: Liam Girdwood <lrg@slimlogic.co.uk>
To: Stuart Longland <redhatter@gentoo.org>
Cc: Takashi Iwai <tiwai@suse.de>,
ALSA Development List <alsa-devel@alsa-project.org>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Linux ARM Kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV
Date: Fri, 18 Jun 2010 11:29:24 +0100 [thread overview]
Message-ID: <1276856964.3054.1.camel@odin> (raw)
In-Reply-To: <1276829770-31557-1-git-send-email-redhatter@gentoo.org>
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
WARNING: multiple messages have this Message-ID (diff)
From: lrg@slimlogic.co.uk (Liam Girdwood)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV
Date: Fri, 18 Jun 2010 11:29:24 +0100 [thread overview]
Message-ID: <1276856964.3054.1.camel@odin> (raw)
In-Reply-To: <1276829770-31557-1-git-send-email-redhatter@gentoo.org>
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
WARNING: multiple messages have this Message-ID (diff)
From: Liam Girdwood <lrg@slimlogic.co.uk>
To: Stuart Longland <redhatter@gentoo.org>
Cc: ALSA Development List <alsa-devel@alsa-project.org>,
Takashi Iwai <tiwai@suse.de>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Linux ARM Kernel <linux-arm-kernel@lists.infradead.org>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV
Date: Fri, 18 Jun 2010 11:29:24 +0100 [thread overview]
Message-ID: <1276856964.3054.1.camel@odin> (raw)
In-Reply-To: <1276829770-31557-1-git-send-email-redhatter@gentoo.org>
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
next prev parent reply other threads:[~2010-06-18 10:29 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-11 5:55 Update on TLV320AIC3204 Driver Stuart Longland
2010-06-11 10:18 ` Mark Brown
2010-06-15 0:27 ` Stuart Longland
2010-06-15 5:11 ` Stuart Longland
2010-06-15 5:23 ` Stuart Longland
2010-06-15 9:00 ` Mark Brown
2010-06-15 13:42 ` Peter Ujfalusi
2010-06-15 13:53 ` Mark Brown
2010-06-16 5:33 ` Peter Ujfalusi
2010-06-16 14:51 ` Mark Brown
2010-06-15 22:59 ` Stuart Longland
2010-06-18 2:38 ` SOC_DOUBLE_R_SX_TLV (was Update on TLV320AIC3204 Driver) Stuart Longland
2010-06-18 2:56 ` [PATCH] ASoC: Fix overflow bug in SOC_DOUBLE_R_SX_TLV Stuart Longland
2010-06-18 2:56 ` Stuart Longland
2010-06-18 2:56 ` Stuart Longland
2010-06-18 10:29 ` Liam Girdwood [this message]
2010-06-18 10:29 ` Liam Girdwood
2010-06-18 10:29 ` Liam Girdwood
2010-06-19 1:36 ` Mark Brown
2010-06-19 1:36 ` Mark Brown
2010-06-19 1:36 ` Mark Brown
2010-06-15 7:21 ` Update on TLV320AIC3204 Driver Mark Brown
2010-06-15 0:29 ` Update on TLV320AIC3204 Driver [File 1/3] Stuart Longland
2010-06-15 0:33 ` Update on TLV320AIC3204 Driver [File 2/3] Stuart Longland
2010-06-15 0:34 ` Update on TLV320AIC3204 Driver [File 3/3] Stuart Longland
2010-06-15 14:20 ` Update on TLV320AIC3204 Driver [File 1/3] Mark Brown
2010-06-15 22:46 ` Stuart Longland
2010-06-16 9:35 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1276856964.3054.1.camel@odin \
--to=lrg@slimlogic.co.uk \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=redhatter@gentoo.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.