All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Alexey Fisher <bug-track@fisher-privat.net>
Cc: alsa-devel@alsa-project.org
Subject: Re: [regression] probably in mixer.c code
Date: Tue, 08 Nov 2011 10:59:01 +0100	[thread overview]
Message-ID: <s5haa87gcka.wl%tiwai@suse.de> (raw)
In-Reply-To: <4EB8ED09.2090301@fisher-privat.net>

At Tue, 08 Nov 2011 09:49:13 +0100,
Alexey Fisher wrote:
> 
> Hallo all, Takashi,
> 
> there is one regression in current linux main tree:
> 
> cval->res quirks do not work any more. See usb/mixer.c:1150
> Are there was some work in this area or may be some one bisected this 
> bug down?

Are you referring to the device 046d:09a4, which sets the mixer range
manually?  If yes, does the patch below work?


Takashi

---
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 60f65ac..92feff1 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -765,6 +765,28 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl)
  * interface to ALSA control for feature/mixer units
  */
 
+/* convert from USB descriptions to dB scale
+ * USB descriptions contain the dB scale in 1/256 dB unit
+ * while ALSA TLV contains in 1/100 dB unit
+ */
+static int convert_cval_to_dB(struct usb_mixer_elem_info *cval)
+{
+	cval->dBmin = (convert_signed_value(cval, cval->min) * 100) / 256;
+	cval->dBmax = (convert_signed_value(cval, cval->max) * 100) / 256;
+	if (cval->dBmin > cval->dBmax) {
+		/* something is wrong; assume it's either from/to 0dB */
+		if (cval->dBmin < 0)
+			cval->dBmax = 0;
+		else if (cval->dBmin > 0)
+			cval->dBmin = 0;
+		if (cval->dBmin > cval->dBmax) {
+			/* totally crap, return an error */
+			return -EINVAL;
+		}
+	}
+	return 0;
+}
+
 /*
  * retrieve the minimum and maximum values for the specified control
  */
@@ -844,24 +866,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
 		cval->initialized = 1;
 	}
 
-	/* USB descriptions contain the dB scale in 1/256 dB unit
-	 * while ALSA TLV contains in 1/100 dB unit
-	 */
-	cval->dBmin = (convert_signed_value(cval, cval->min) * 100) / 256;
-	cval->dBmax = (convert_signed_value(cval, cval->max) * 100) / 256;
-	if (cval->dBmin > cval->dBmax) {
-		/* something is wrong; assume it's either from/to 0dB */
-		if (cval->dBmin < 0)
-			cval->dBmax = 0;
-		else if (cval->dBmin > 0)
-			cval->dBmin = 0;
-		if (cval->dBmin > cval->dBmax) {
-			/* totally crap, return an error */
-			return -EINVAL;
-		}
-	}
-
-	return 0;
+	return convert_cval_to_dB(cval);
 }
 
 
@@ -1134,6 +1139,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
 			snd_printk(KERN_INFO
 				 "set volume quirk for UDA1321/N101 chip\n");
 			cval->max = -256;
+			convert_cval_to_dB(cval);
 		}
 		break;
 
@@ -1144,6 +1150,8 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
 			cval->min = 6080;
 			cval->max = 8768;
 			cval->res = 192;
+			cval->initialized = 1;
+			convert_cval_to_dB(cval);
 		}
 		break;
 

  reply	other threads:[~2011-11-08  9:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08  8:49 [regression] probably in mixer.c code Alexey Fisher
2011-11-08  9:59 ` Takashi Iwai [this message]
2011-11-08 11:25   ` Alexey Fisher
2011-11-08 12:11     ` Takashi Iwai
2011-11-08 12:39       ` Alexey Fisher
2011-11-08 13:05         ` Takashi Iwai
2011-11-08 13:09           ` Takashi Iwai
2011-11-08 14:32             ` Alexey Fisher
2011-11-08 14:54               ` Takashi Iwai
2011-11-08 16:46                 ` Alexey Fisher
2011-11-08 16:55                   ` Takashi Iwai

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=s5haa87gcka.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=bug-track@fisher-privat.net \
    /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.