aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/line6/playback.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-03-05 07:03:28 -0500
committerTakashi Iwai <tiwai@suse.de>2015-03-05 07:03:28 -0500
commitf44f07cf3910f84b15b2a78c4933d5946bf409cf (patch)
tree2c6fdb326267aca7379e5ad2667a7cb3f48318a5 /sound/usb/line6/playback.c
parent096a020a9ef5c947577d3b57199bfc9b7e686b49 (diff)
ALSA: line6: Clamp values correctly
The usages of clamp() macro in sound/usb/line6/playback.c are just wrong, the low and high values are swapped. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/line6/playback.c')
-rw-r--r--sound/usb/line6/playback.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c
index 05dee690f487..97ed593f6010 100644
--- a/sound/usb/line6/playback.c
+++ b/sound/usb/line6/playback.c
@@ -39,7 +39,7 @@ static void change_volume(struct urb *urb_out, int volume[],
39 for (; p < buf_end; ++p) { 39 for (; p < buf_end; ++p) {
40 short pv = le16_to_cpu(*p); 40 short pv = le16_to_cpu(*p);
41 int val = (pv * volume[chn & 1]) >> 8; 41 int val = (pv * volume[chn & 1]) >> 8;
42 pv = clamp(val, 0x7fff, -0x8000); 42 pv = clamp(val, -0x8000, 0x7fff);
43 *p = cpu_to_le16(pv); 43 *p = cpu_to_le16(pv);
44 ++chn; 44 ++chn;
45 } 45 }
@@ -54,7 +54,7 @@ static void change_volume(struct urb *urb_out, int volume[],
54 54
55 val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16); 55 val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16);
56 val = (val * volume[chn & 1]) >> 8; 56 val = (val * volume[chn & 1]) >> 8;
57 val = clamp(val, 0x7fffff, -0x800000); 57 val = clamp(val, -0x800000, 0x7fffff);
58 p[0] = val; 58 p[0] = val;
59 p[1] = val >> 8; 59 p[1] = val >> 8;
60 p[2] = val >> 16; 60 p[2] = val >> 16;
@@ -126,7 +126,7 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal,
126 short pov = le16_to_cpu(*po); 126 short pov = le16_to_cpu(*po);
127 short piv = le16_to_cpu(*pi); 127 short piv = le16_to_cpu(*pi);
128 int val = pov + ((piv * volume) >> 8); 128 int val = pov + ((piv * volume) >> 8);
129 pov = clamp(val, 0x7fff, -0x8000); 129 pov = clamp(val, -0x8000, 0x7fff);
130 *po = cpu_to_le16(pov); 130 *po = cpu_to_le16(pov);
131 } 131 }
132 } 132 }