aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/mixer.c
diff options
context:
space:
mode:
authorAlexey Fisher <bug-track@fisher-privat.net>2011-03-10 08:53:38 -0500
committerTakashi Iwai <tiwai@suse.de>2011-03-10 10:47:56 -0500
commit80acefff3bc7bd53d46c16c683ab66c0ece20810 (patch)
tree85078478ccf6f934688dbda6b9056a9867bba6cd /sound/usb/mixer.c
parent848669da3a92fa6ab815e0517af3294afb3ea928 (diff)
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/mixer.c')
-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 7df89b3d7ded..3e3116c5bc52 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,
987 struct snd_kcontrol *kctl; 987 struct snd_kcontrol *kctl;
988 struct usb_mixer_elem_info *cval; 988 struct usb_mixer_elem_info *cval;
989 const struct usbmix_name_map *map; 989 const struct usbmix_name_map *map;
990 unsigned int range;
990 991
991 control++; /* change from zero-based to 1-based value */ 992 control++; /* change from zero-based to 1-based value */
992 993
@@ -1136,6 +1137,21 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc,
1136 1137
1137 } 1138 }
1138 1139
1140 range = (cval->max - cval->min) / cval->res;
1141 /* Are there devices with volume range more than 255? I use a bit more
1142 * to be sure. 384 is a resolution magic number found on Logitech
1143 * devices. It will definitively catch all buggy Logitech devices.
1144 */
1145 if (range > 384) {
1146 snd_printk(KERN_WARNING "usb_audio: Warning! Unlikely big "
1147 "volume range (=%u), cval->res is probably wrong.",
1148 range);
1149 snd_printk(KERN_WARNING "usb_audio: [%d] FU [%s] ch = %d, "
1150 "val = %d/%d/%d", cval->id,
1151 kctl->id.name, cval->channels,
1152 cval->min, cval->max, cval->res);
1153 }
1154
1139 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", 1155 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
1140 cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res); 1156 cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res);
1141 add_control_to_empty(state, kctl); 1157 add_control_to_empty(state, kctl);