From patchwork Wed Jan 28 16:41:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 5728751 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 275EC9F399 for ; Wed, 28 Jan 2015 16:46:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63069202EB for ; Wed, 28 Jan 2015 16:46:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7CB7E2027D for ; Wed, 28 Jan 2015 16:46:50 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 93498265282; Wed, 28 Jan 2015 17:46:49 +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 A85D0265050; Wed, 28 Jan 2015 17:43:06 +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 0517B264F3A; Wed, 28 Jan 2015 17:43:00 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 43ACC264FE7 for ; Wed, 28 Jan 2015 17:41:37 +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 70DD3ADDB; Wed, 28 Jan 2015 16:41:36 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Wed, 28 Jan 2015 17:41:23 +0100 Message-Id: <1422463289-19135-2-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422463289-19135-1-git-send-email-tiwai@suse.de> References: <1422463289-19135-1-git-send-email-tiwai@suse.de> Cc: Stefan Hajnoczi , Chris Rorvick Subject: [alsa-devel] [PATCH 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: , MIME-Version: 1.0 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 --- sound/usb/line6/playback.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 1708c05f14db..5858f5f18e11 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c @@ -37,8 +37,10 @@ static void change_volume(struct urb *urb_out, int volume[], 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) { @@ -121,8 +123,11 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal, 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); } }