Skip to content

Commit

Permalink
ALSA: usb-audio - Add volume range check and warn if it too big
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Alexey Fisher authored and Takashi Iwai committed Mar 10, 2011
1 parent 848669d commit 80aceff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sound/usb/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 80aceff

Please sign in to comment.