From: Takashi Iwai Subject: Re: [PATCH] snd_tlv_convert_from_dB: fix decreasing gain across entries Date: Tue, 01 Oct 2013 12:25:18 +0200 Message-ID: References: <1380576349-3695-1-git-send-email-swarren@wwwdotorg.org> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 94F992651EB for ; Tue, 1 Oct 2013 12:22:38 +0200 (CEST) In-Reply-To: <1380576349-3695-1-git-send-email-swarren@wwwdotorg.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Stephen Warren Cc: alsa-devel@alsa-project.org, Stephen Warren List-Id: alsa-devel@alsa-project.org At Mon, 30 Sep 2013 15:25:49 -0600, Stephen Warren wrote: > > From: Stephen Warren > > Currently, for a TLV consisting of TLV_DB_SCALE_ITEMs, if e.g. alsamixer > calls snd_mixer_selem_set_playback_dB() with a value that is in-between > two TLV_DB_SCALE_ITEMs, and xdir is negative, the selected raw hardware > value is the minimum in the first range above that value, rather than the > maximum in the last range below that value. > > The user-visible symptom is that in alsamixer, pressing the down key to > reduce the value sticks at certain points, and cannot be incrementally > reduced any further, although directly selecting a much lower value (e.g. > by pressing 0..9) works as expected. This is triggered e.g. by > sound/soc/codec/max98090.c's max98090_hp_tlv[]. > > Fix this by checking whether xdir is positive or not, rather than > checking whether it has a non-zero value. The code to select the previous > range's max value is already present. This matches how xdir is used in > other parts of the code. > > Signed-off-by: Stephen Warren Thanks, applied. Takashi > --- > src/control/tlv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/control/tlv.c b/src/control/tlv.c > index 6b0b9f4..b08d887 100644 > --- a/src/control/tlv.c > +++ b/src/control/tlv.c > @@ -312,7 +312,7 @@ int snd_tlv_convert_from_dB(unsigned int *tlv, long rangemin, long rangemax, > submin, submax, > db_gain, value, xdir); > else if (db_gain < dbmin) { > - *value = xdir || pos == 2 ? submin : prev_submax; > + *value = xdir > 0 || pos == 2 ? submin : prev_submax; > return 0; > } > prev_submax = submax; > -- > 1.8.1.5 >