From patchwork Mon Apr 1 10:07:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784850 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3EF6CD1288 for ; Mon, 1 Apr 2024 12:22:46 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AD2652368; Mon, 1 Apr 2024 14:22:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AD2652368 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711974164; bh=xyeTfR64KLMcUjtzhkWAPMzPv/EIOESNPTsCQma9bCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=QFXXFA8XMIPXZFtrtt4Qkr2kJK4NWREEfiWgbk+KZqApzQcXi50JBuXn2K4IoCoAr 8z5SPuc95q/H3iGqXOnhXkc+Kt2x6UvAmEfkbZRXnzCf0WhLf1Wm7vcABz8VTaUmJ5 Mk+tTFwfjzza7zwY2IykCwX1IihUZTRUdr9NGHDY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 78CF5F805F8; Mon, 1 Apr 2024 14:21:48 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 82C2BF805F5; Mon, 1 Apr 2024 14:21:48 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3D22F805B6; Mon, 1 Apr 2024 14:21:41 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1C0F3F8055C for ; Mon, 1 Apr 2024 14:21:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1C0F3F8055C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.a=rsa-sha256 header.s=s31663417 header.b=sai1W66J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711974088; x=1712578888; i=oswald.buddenhagen@gmx.de; bh=Xpjsn2AGjwSg6ZwqFy/jANXMV+0QadhgI0lm7U1ty64=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=sai1W66JRVw1DMmhm8mGZJHAj27/3AQArYvoZ1ApzBNxr+At8wcv8EtegPgxow1W meowGXuulG3bICc8WmDMMs8NCVML3hIiLBeCDjsGHY6qA72IQ29ardtzXK1Jm6zbB mcy3aEnP3ODuvwLEc3YNWkEDK4BSSoKITmyKQOMTipbs7/vA0PBMS7iFIfYtd/9Ae WKVYf1RyOIUZH/0CVMUXCtfD5di9oP4JyrSunjB1vLptzm/4bGNB7ECkKPWjCVDeT uqUhyuzsIIu7BNCyno/et1SBRuQVASv+DfrUj5nWKo/BJVONS3AChGy94HSYQzhkD kisfgkP+teAweyhESA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MFbRs-1s2nna0rUc-00HAmJ; Mon, 01 Apr 2024 14:21:28 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7ex-00; Mon, 01 Apr 2024 12:07:42 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH 15/18] ALSA: emu10k1: de-duplicate size calculations for 16-bit samples Date: Mon, 1 Apr 2024 12:07:39 +0200 Message-ID: <20240401100742.506001-16-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240401100742.506001-1-oswald.buddenhagen@gmx.de> References: <20240401100742.506001-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:FoIPsZ7m3ObqZm++3YeMx/0VJNAD7A44lR/K6Vg47P9Uk6kBo2I wRBX/n9zaZRQ20ajj2Sucs4ImXKWOZ1JMXXdLVGGHfq/3QTfW+BZvJVfSj9wr4p0jFNQWOr EkiwuJ3ZgCFxDnihgfTasQS9JpL2ZxGh4C0ik+84cUCJ3aBoxak8iNuWnj3E2URo8gJB0+x SdPqX1hdj2yT7XPXv+dKw== UI-OutboundReport: notjunk:1;M01:P0:awqNW5ZKoPU=;NaTZ+X0pV5p+gUQp/CpKEW7A3UX tTsEVUdAUk/us/rhwmG5TrC0EEOzeOLT9jomMamDZ8EhT6+tUiA7yNG0GuQ25mabMuBgh0KRD HJ1KJkArqPXPuikSnBLomNEX2QjBT4vQlZbS7bGA9CGi0+LHbXkXf0Mu6WYcMPl/XYYF6klPQ QG23QfRiMwJRHG0OBZjBWMNdEiLQqGu0pADH/PkglOEL2fDHLNN++XjUtT9vHo0eZmKjJyClo hIxOrnOqbuzm7XiVADXbhfiRy5+DxXXgSzaKG72oG1q2IwfU5pIqqcIGDDtMTgYGtSXX76jAw Xj2lbTXGir0v0Gs02mUaQB2/dGe4g14JXEiryR+WPhA3Itg3441Y3etOsa78wvKe1cA5r/ppL T5S1hq4g7U/hQKZ5Js39ArpYThtBv1OwCKbzMLz8NWtJbZY8kJRHo/SNx03Op1fbcqqd5RBVL 1fYKdjNmzdi/z+O8RYhPtwWpNrIWl7Oqu+PBfGzcxzE8lBjXQ4qMNVXUlVGBDCfozge4QmD9E l037u/C3OXEVZwBiC6VHqiO3Qce3YQT3p82Wfzh0b6aXVNSkYOThp0so8DQR5Qqmis97jtviT rN4URgSEZh54z4z09uhierNtTDF0hRJk30HyJoFj4kOAd0akRibvVnvjxAdkgAasRiVuelkGH +66ElVBRhahNDbKBvnODENF/N4uVt9KZY6GaOPQyJ9noERteJI0PMuk8T2B18m71eRTrgo0Il SoYyrpSBuf9Lktl24x20BAmOvDkht+zQxLiboYgTtpXmt2ZPVtJwjQ08mRgljmXNV0vET2Guo RZ0Wps+uBZ1YSSwFhlR8AeapnxYp2Ql4CXMoC+3LrNIhQ= Message-ID-Hash: VFLGW6D4Q6PVD6YDJOTONDOZ66DPL673 X-Message-ID-Hash: VFLGW6D4Q6PVD6YDJOTONDOZ66DPL673 X-MailFrom: oswald.buddenhagen@gmx.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of repeatedly checking the sample width, assign a size shift centrally. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_patch.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index eb8365650bd4..699aa0fec97b 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -28,6 +28,7 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, { u8 fill; u32 xor; + int shift; int offset; int truesize, size, blocksize; struct snd_emu10k1 *emu; @@ -43,9 +44,11 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, } if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS) { + shift = 0; fill = 0x80; xor = (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_UNSIGNED) ? 0 : 0x80808080; } else { + shift = 1; fill = 0; xor = (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_UNSIGNED) ? 0x80008000 : 0; } @@ -68,9 +71,7 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, sp->v.loopend += BLANK_HEAD_SIZE; /* try to allocate a memory block */ - blocksize = truesize; - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) - blocksize *= 2; + blocksize = truesize << shift; sp->block = snd_emu10k1_synth_alloc(emu, blocksize); if (sp->block == NULL) { dev_dbg(emu->card->dev, @@ -83,16 +84,12 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, /* write blank samples at head */ offset = 0; - size = BLANK_HEAD_SIZE; - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) - size *= 2; + size = BLANK_HEAD_SIZE << shift; snd_emu10k1_synth_memset(emu, sp->block, offset, size, fill); offset += size; /* copy provided samples */ - size = sp->v.size; - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) - size *= 2; + size = sp->v.size << shift; if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size, xor)) { snd_emu10k1_synth_free(emu, sp->block); sp->block = NULL;