From patchwork Wed Jan 28 16:54:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 5728761 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1716EBF440 for ; Wed, 28 Jan 2015 16:54:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F63F20306 for ; Wed, 28 Jan 2015 16:54:48 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id DA335202FE for ; Wed, 28 Jan 2015 16:54:46 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 477B9264EE5; Wed, 28 Jan 2015 17:54:45 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 980E8261B35; Wed, 28 Jan 2015 17:54:36 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id BFE1F26262D; Wed, 28 Jan 2015 17:54:35 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id D3183261B11 for ; Wed, 28 Jan 2015 17:54:28 +0100 (CET) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 83B0EADE2; Wed, 28 Jan 2015 16:54:28 +0000 (UTC) Date: Wed, 28 Jan 2015 17:54:28 +0100 Message-ID: From: Takashi Iwai To: alsa-devel@alsa-project.org In-Reply-To: <1422463289-19135-2-git-send-email-tiwai@suse.de> References: <1422463289-19135-1-git-send-email-tiwai@suse.de> <1422463289-19135-2-git-send-email-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.4 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: Stefan Hajnoczi , Chris Rorvick Subject: [alsa-devel] [PATCH v2 1/7] ALSA: line6: Fix volume calculation for big-endian X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Takashi Iwai --- v1->v2: fix the type to __le16, as sparse warns sound/usb/line6/playback.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 1708c05f14db..3226422d2858 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -31,14 +31,16 @@ static void change_volume(struct urb *urb_out, int volume[], return; /* maximum volume - no change */ if (bytes_per_frame == 4) { - short *p, *buf_end; + __le16 *p, *buf_end; p = (short *)urb_out->transfer_buffer; buf_end = p + urb_out->transfer_buffer_length / sizeof(*p); for (; p < buf_end; ++p) { - int val = (*p * volume[chn & 1]) >> 8; - *p = clamp(val, 0x7fff, -0x8000); + short pv = le16_to_cpu(*p); + int val = (pv * volume[chn & 1]) >> 8; + pv = clamp(val, 0x7fff, -0x8000); + *p = cpu_to_le16(pv); ++chn; } } else if (bytes_per_frame == 6) { @@ -114,15 +116,18 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal, return; /* zero volume - no change */ if (bytes_per_frame == 4) { - short *pi, *po, *buf_end; + __le16 *pi, *po, *buf_end; pi = (short *)signal; po = (short *)urb_out->transfer_buffer; buf_end = po + urb_out->transfer_buffer_length / sizeof(*po); for (; po < buf_end; ++pi, ++po) { - int val = *po + ((*pi * volume) >> 8); - *po = clamp(val, 0x7fff, -0x8000); + short pov = le16_to_cpu(*po); + short piv = le16_to_cpu(*pi); + int val = pov + ((piv * volume) >> 8); + pov = clamp(val, 0x7fff, -0x8000); + *po = cpu_to_le16(pov); } }