Skip to content

Commit

Permalink
ALSA: usb-audio - Correct bogus volume dB information
Browse files Browse the repository at this point in the history
Some USB devices give bogus dB information and it screws up PA.
It's better to detect a broken value and correct it in the driver
before exposing the value to the outside.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Jun 17, 2009
1 parent b8e1c73 commit eedbdf0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sound/usb/usbmixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,15 @@ static int mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
*/
scale[2] = (convert_signed_value(cval, cval->min) * 100) / 256;
scale[3] = (convert_signed_value(cval, cval->max) * 100) / 256;
if (scale[3] <= scale[2]) {
/* something is wrong; assume it's either from/to 0dB */
if (scale[2] < 0)
scale[3] = 0;
else if (scale[2] > 0)
scale[2] = 0;
else /* totally crap, return an error */
return -EINVAL;
}
if (copy_to_user(_tlv, scale, sizeof(scale)))
return -EFAULT;
return 0;
Expand Down

0 comments on commit eedbdf0

Please sign in to comment.