summaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorAlexey Fisher <bug-track@fisher-privat.net>2011-03-10 14:53:38 +0100
committerTakashi Iwai <tiwai@suse.de>2011-03-10 16:47:56 +0100
commit80acefff3bc7bd53d46c16c683ab66c0ece20810 (patch)
tree85078478ccf6f934688dbda6b9056a9867bba6cd /sound/usb
parent848669da3a92fa6ab815e0517af3294afb3ea928 (diff)
downloadop-kernel-dev-80acefff3bc7bd53d46c16c683ab66c0ece20810.zip
op-kernel-dev-80acefff3bc7bd53d46c16c683ab66c0ece20810.tar.gz
ALSA: usb-audio - Add volume range check and warn if it too big
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/mixer.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 7df89b3..3e3116c 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -987,6 +987,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
struct snd_kcontrol *kctl;
struct usb_mixer_elem_info *cval;
const struct usbmix_name_map *map;
+ unsigned int range;
control++; /* change from zero-based to 1-based value */
@@ -1136,6 +1137,21 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
}
+ range = (cval->max - cval->min) / cval->res;
+ /* Are there devices with volume range more than 255? I use a bit more
+ * to be sure. 384 is a resolution magic number found on Logitech
+ * devices. It will definitively catch all buggy Logitech devices.
+ */
+ if (range > 384) {
+ snd_printk(KERN_WARNING "usb_audio: Warning! Unlikely big "
+ "volume range (=%u), cval->res is probably wrong.",
+ range);
+ snd_printk(KERN_WARNING "usb_audio: [%d] FU [%s] ch = %d, "
+ "val = %d/%d/%d", cval->id,
+ kctl->id.name, cval->channels,
+ cval->min, cval->max, cval->res);
+ }
+
snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res);
add_control_to_empty(state, kctl);
OpenPOWER on IntegriCloud