From patchwork Thu Apr 4 10:00:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13617514 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 13E42CD1292 for ; Thu, 4 Apr 2024 10:02:43 +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 A49262C72; Thu, 4 Apr 2024 12:02:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A49262C72 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712224960; bh=QkfNAiDSNvw4HDF9IAG3GweNjgJwMxMVQuifEYn6CBk=; 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=jE52PtMbtV8CFNquVHP3gFe2w+CntP8raTL5CHRWciOxwdtno/Gkw6IjGjaE4gpD2 GOe2ZdHTnGQ+QfOqrXctRQ8V6m9by4H8Gk7wzDeaYaBpOzsVpgLxmDJEf7ghu2gytX prUw5f+5hkV18z9osUJR7dvhrsFtu/PLx9ks6d5I= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 45D56F805B5; Thu, 4 Apr 2024 12:02:09 +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 E2C3BF805AC; Thu, 4 Apr 2024 12:02:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A995FF80579; Thu, 4 Apr 2024 12:01:03 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (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 A0078F80007 for ; Thu, 4 Apr 2024 12:00:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A0078F80007 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=Kufm4905 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224851; x=1712829651; i=oswald.buddenhagen@gmx.de; bh=MIfdnOpAF4SC3w5tCHsYtBAisxAuFKXcIIE5ASAQfmg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Kufm4905F50l1lQLsLBbHqG3A/o98Ev9uWkIFtirXtxjQDAMnTCZ2wZuO85ommFK Wy92TOA2T2mHthcpXtubpOuJrP8IqrSWrFngeFJh2kd69omGqJe3qxj/HQr4yt/rV aGMGTwJ1azE6myU3IrE8J84cvmM0JucY5p7BTfWzy9Qzb5SM9JA9k2R/EQStme1Qb ogykziLsjWm07aEujrzaQYe854YIgBpJbTYicj3Ucd93xQSG5dZ22dh99tDuBVGnW WgaNlVgdK2n4cE8GAzE2I+B0+6iydhIRUrv4tIxSY2ZY6nkAEyBwmtoesTh2/DY9x Dtos+J4gSVilTWB+5Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MBm1e-1rxmUW3G8K-00C76n; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RG1-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 13/17] ALSA: emu10k1: de-duplicate size calculations for 16-bit samples Date: Thu, 4 Apr 2024 12:00:44 +0200 Message-ID: <20240404100048.819674-14-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:jZjutnPYZxsxlAkZENVGY0Cl0UP3gVaeZHGCPqb1E7rSTYXZ3Y+ TkjGunkNgtLIgijQXqDDc3DrNoe6FJ/wbC30ghnV8dhclTrVv4ID39jD9c/UP6/dD3fU9P7 IQvvcpX0bBwFiIkboWzvK4Jff+gWYsSreQNX1H9hE13cXjBLWLaF19xpqDTmK0O2eqs9sHb R3xPxk1TBkmpWayTJD/Aw== UI-OutboundReport: notjunk:1;M01:P0:O2sjyQn7NGU=;xoZp14iWUSmxdXttwuMtxrOk+Ub 7q8Yfssp9uDR2l/T4igXim3ex+ONlCTvj/aPwpQrs36jpO29jeG2CyzYy6FJmbuIOtpyTpXU2 UAfKgx8IswCb+PYfhtSOO7LKQwumeYGZl96HnIxlOpN2O6uNAJUaxv9x4+EcbkZzOkMyjQYaC u7AOnG07m5pApo0amip7FyTsULDtgFWJtT5Y/xgqGfFxu3QNQxqYE1IwZgjFu/Y4TdttVYg53 dkE1b7QEvC37Jl6meEQAstLE/tbjWaTW7jH9hUqZoTBsJ37rf8qR40AzGzZVlw/hHfj44Yeld ogsV0Uohglgw+KEIe94eLeOlbgTDYy5P3u2Dx+O0TYSjYWmOwyk3dUO+lflyW0DHinj07Rvl3 C94sgGlo3OgbXz9br20I7dMA6v4yMXkTQL1grMsFNmITq1fvqJg1ifV1msnkQE65Vs5xpkJci mncjplIihdrEKbYikQp0vqQmc6vJl+KNL+ti1lrv4I34pLNNu9wlTRteh8tdk8xYKQ8juRpmp 16m6QfzX6G3HF6PZdsX7TtltdFKJToAVq1NfDH1esSD/wQb10Xh5voxIWhwydFddFgU0wIcVI EWJD05LMNLjvMYqYUshV0Drb/tNYOZ88KKvtNkXUvvgfr0o2VR3RkP//1uvrvAvnk6Bk+s2WG 2jfp44IPe4frADWl8TOL1AOigbfNqQH7FnaNOiWi24OQLBkOR/rjjH1JQ2kjR2ET3NSwmtAwA yoiFrERl7Db1MzsU4uFEn5M4s1XEWCJfXh9M8eyZ+90kH4iNiBXaCVZki6GOKDnxaDEfLRp4E 4Vy7OHdyAppxiSFUqNEw5OlyrlpMOe/fU9NrCBUIZjIpg= Message-ID-Hash: YM4B3OYNEV46N5NZQPPO5T57JCQYJSKX X-Message-ID-Hash: YM4B3OYNEV46N5NZQPPO5T57JCQYJSKX 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 ad16de99b800..481fe03fef4d 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;