From: Takashi Iwai <tiwai@suse.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: Re: ALSA: line6: Fix volume calculation for big-endian
Date: Thu, 05 Mar 2015 13:01:39 +0100 [thread overview]
Message-ID: <s5hvbif64bg.wl-tiwai@suse.de> (raw)
In-Reply-To: <20150305102149.GA10971@mwanda>
At Thu, 5 Mar 2015 13:21:49 +0300,
Dan Carpenter wrote:
>
> Hello Takashi Iwai,
>
> The patch 0416980d0a2b: "ALSA: line6: Fix volume calculation for
> big-endian" from Jan 28, 2015, leads to the following static checker
> warning:
>
> sound/usb/line6/playback.c:42 change_volume()
> warn: always clamps to s16min
> sound/usb/line6/playback.c:57 change_volume()
> warn: always clamps to (-8388608)
> sound/usb/line6/playback.c:129 add_monitor_signal()
> warn: always clamps to s16min
>
> sound/usb/line6/playback.c
> 25 static void change_volume(struct urb *urb_out, int volume[],
> 26 int bytes_per_frame)
> 27 {
> 28 int chn = 0;
> 29
> 30 if (volume[0] == 256 && volume[1] == 256)
> 31 return; /* maximum volume - no change */
> 32
> 33 if (bytes_per_frame == 4) {
> 34 __le16 *p, *buf_end;
> 35
> 36 p = (__le16 *)urb_out->transfer_buffer;
> 37 buf_end = p + urb_out->transfer_buffer_length / sizeof(*p);
> 38
> 39 for (; p < buf_end; ++p) {
> 40 short pv = le16_to_cpu(*p);
> 41 int val = (pv * volume[chn & 1]) >> 8;
> 42 pv = clamp(val, 0x7fff, -0x8000);
> ^^^^^^^^^^^^^^^^
> You didn't really add this, but you might know what was intended here.
> It is a complete mystery to me. :)
No mystery, just left/right swapped. It's a common mistake, and
you'll feel the same when you go from Paris to London and look at a
street. I'll fix them (the code, not the street).
thanks,
Takashi
WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: Re: ALSA: line6: Fix volume calculation for big-endian
Date: Thu, 05 Mar 2015 12:01:39 +0000 [thread overview]
Message-ID: <s5hvbif64bg.wl-tiwai@suse.de> (raw)
In-Reply-To: <20150305102149.GA10971@mwanda>
At Thu, 5 Mar 2015 13:21:49 +0300,
Dan Carpenter wrote:
>
> Hello Takashi Iwai,
>
> The patch 0416980d0a2b: "ALSA: line6: Fix volume calculation for
> big-endian" from Jan 28, 2015, leads to the following static checker
> warning:
>
> sound/usb/line6/playback.c:42 change_volume()
> warn: always clamps to s16min
> sound/usb/line6/playback.c:57 change_volume()
> warn: always clamps to (-8388608)
> sound/usb/line6/playback.c:129 add_monitor_signal()
> warn: always clamps to s16min
>
> sound/usb/line6/playback.c
> 25 static void change_volume(struct urb *urb_out, int volume[],
> 26 int bytes_per_frame)
> 27 {
> 28 int chn = 0;
> 29
> 30 if (volume[0] = 256 && volume[1] = 256)
> 31 return; /* maximum volume - no change */
> 32
> 33 if (bytes_per_frame = 4) {
> 34 __le16 *p, *buf_end;
> 35
> 36 p = (__le16 *)urb_out->transfer_buffer;
> 37 buf_end = p + urb_out->transfer_buffer_length / sizeof(*p);
> 38
> 39 for (; p < buf_end; ++p) {
> 40 short pv = le16_to_cpu(*p);
> 41 int val = (pv * volume[chn & 1]) >> 8;
> 42 pv = clamp(val, 0x7fff, -0x8000);
> ^^^^^^^^^^^^^^^^
> You didn't really add this, but you might know what was intended here.
> It is a complete mystery to me. :)
No mystery, just left/right swapped. It's a common mistake, and
you'll feel the same when you go from Paris to London and look at a
street. I'll fix them (the code, not the street).
thanks,
Takashi
next prev parent reply other threads:[~2015-03-05 12:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-05 10:21 ALSA: line6: Fix volume calculation for big-endian Dan Carpenter
2015-03-05 10:21 ` Dan Carpenter
2015-03-05 12:01 ` Takashi Iwai [this message]
2015-03-05 12:01 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hvbif64bg.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.