From patchwork Mon Apr 1 10:07:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 785945 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 F308DCD1292 for ; Mon, 1 Apr 2024 10:11:08 +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 F3FA521A4; Mon, 1 Apr 2024 12:10:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F3FA521A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711966267; bh=jPDkcBk/SJQNsvgeAqqI70H4V8gh3/HjBiCRa6Z+XSY=; 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=kJ5+8VMmJnePhaiZcGBJkvaTx6+dg/HA2gHtRj4cMaHHxUzCBs8cXyl66J56oXuhV ORU/F9AMWFLYtvfV8GBKZnDYIkXbl7SesstnwkBp+pr1R5i4aE8hxfqrhakjHJD0xs fQfmsZ0kRDhD4HZ15J1jHcFGFOQ4DW6S+0eBs9+M= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C6FE9F805EF; Mon, 1 Apr 2024 12:09:12 +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 F31DAF80618; Mon, 1 Apr 2024 12:09:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A27DFF805C4; Mon, 1 Apr 2024 12:09:07 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 A9679F80236 for ; Mon, 1 Apr 2024 12:07:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A9679F80236 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=GvWnxL0t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711966066; x=1712570866; i=oswald.buddenhagen@gmx.de; bh=aHgNEoh2oL/YTOIIO+HEgQH655EOrifvL+ft5bV2Fk4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=GvWnxL0t78eMq01f+ImIEGINJoMhDMOYDR7GmqUqKrfM3uvHvGvl8HHEGgp6Bz8y FLhy2gjGcfPFQyTOXNGe157CLXWZ4IcNxA5PfH/z7b29QMDdKVYsDY0Ca01fJWXp5 q0S6++nYnH2hTxC26WGMgtr4eTk/x17VnUG0TsFUeYyCDJaOr8rusp9Vvok3jsvYM fclbhQ/tt6HAztJdqXdQWYORuEJD8+qSEaYm+O1e5YfWOkBafPRO4ZVq3R5T+Tuco tAP8vbUiqyM7EoHKAKjpPciyRctunItF72qJwkAbgsR8p6E+Y90aBrVWHENtvqsqB L+P+U6hxbp2u1XFOXg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MS3il-1sFGWz3Sjj-00TW2Z; Mon, 01 Apr 2024 12:07:45 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7dp-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 01/18] ALSA: emux: fix /proc teardown at module unload Date: Mon, 1 Apr 2024 12:07:25 +0200 Message-ID: <20240401100742.506001-2-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:bmifMtec5zWF9mNop6bbm5ohEPcIELPsG+fIH+SkJwxrDqs2cVl ynnyp0Bx5/dqJvYF5IzXhPD7mZtVhKORp/oH9Qt21cXDkN9MdSjyVCvP061a5d/xTdgopdP RHXVaMRoEbtx4fxwg6lCA+XHaY8QSRoN2VeCGp/QGHxIS1dSdThkq4ROAM9UeOKcknFJDR3 HvR5DBQi3ePzPsYVTa+yw== UI-OutboundReport: notjunk:1;M01:P0:FoCQEuOXREU=;fVS5wscW0aBg1q9XZijdv71ZugM XfldPBHosBx5BLiDmwJB5wjGs3UfpoBnvI/cYUNZnzYmvcUXzPHItuJdVch6tSZBzM4HoDyJc ZDwih8Vw65l20vCXVuA7GviYcuLahC+4y26E0Ef0XnUIRSoi59Oveefp1mQvhb3Lmiv7gvEae K7qqZt45Qzc1AZ+Hz44aJTwwulrAjtDvdCwPeBXrkWvonO6eOLIF8hMNOdWqBT32g71dG9O5h oqKoEqNtAZvC2wfuizq0ZHxT8FNbWbjq2O/tjPBd3Fp9X3CXGRTN1+MMSGvMniK+jBhAXjst2 ODGGg/7YSjuDI49Ey8sN4a9f6Gxus9l7pMyQWmSm2BWHg+kES03HP5TXhfX/83fObA0gG/4kw eBYIX3/HcuPxGiyllUQliynKdzGu+/boLg1gLYBAKDktn/ZI+s5ECIpuhH9Sd34fS8lMvErBM WNcvYm7aD36+jVSewOEqmCGMXCalxig03IoAZr/Drx9SN5lq9vWkXnBFDsy1jgxgG5XaAopkD GmfQY4hr8kL4bVShEJz53p4ZvFQoHmPbuARUPR4mwgsWY+h2ZtKCLn5csTLozymgzJ95LMg20 SMD4nOXeUtl9UsoITbH11dwTpaP0i/Aq6dZzJt6KYXwJM4J7sHHzK173Y9UBC24mr8Io8yq2H 7JQz3MSUrNrlwKgW+KZ+DFkO1RterOzrGewENUsu2p9syVH9jl6FmQws/5LVhDZmw0v3hiFS3 ApQsEzwF7cPxe4pUFHj9voIG0/TNI8nS3HBHJ9I6EISC+ijzGdmFnIjrzBCD6xE2iWdtrjYsI p6eh745FF6q6ELDvpueN8dBxTfssX4xTfJZa1orDU+j4I= Message-ID-Hash: 4SX2JFMMU5PHSTQYT6BTQDP3RXKBFLIC X-Message-ID-Hash: 4SX2JFMMU5PHSTQYT6BTQDP3RXKBFLIC 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: We forgot to remember the wavetable /proc entry, so we'd fail to free it at module unload. This matters only when only the synth module is unloaded, as unloading the card driver would tear down the sub-entry anyway. Signed-off-by: Oswald Buddenhagen --- sound/synth/emux/emux_proc.c | 1 + 1 file changed, 1 insertion(+) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/synth/emux/emux_proc.c b/sound/synth/emux/emux_proc.c index 7993e6a01e54..820351f52551 100644 --- a/sound/synth/emux/emux_proc.c +++ b/sound/synth/emux/emux_proc.c @@ -102,6 +102,7 @@ void snd_emux_proc_init(struct snd_emux *emu, struct snd_card *card, int device) entry->content = SNDRV_INFO_CONTENT_TEXT; entry->private_data = emu; entry->c.text.read = snd_emux_proc_info_read; + emu->proc = entry; } void snd_emux_proc_free(struct snd_emux *emu) From patchwork Mon Apr 1 10:07:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784854 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 92203CD1288 for ; Mon, 1 Apr 2024 10:10:13 +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 E643120C1; Mon, 1 Apr 2024 12:09:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E643120C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711966206; bh=w80JfGIsSC3/iFftH3e/00GvagaEyUQiANdz/LDp858=; 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=GBZQQzgA4+dJHurYh0iqVxkrzwowVINL7S66L8u/nDlqsGGwB5Q1e8EbRJRG3WDEP E4huPPS7UxE7ISwbEwvkTAcuAafIDVpzWbWI30jb/OSK3OuBGFwn/6c4+MYFskd2fo yPcWr+94zjJE6jfbM53G5EpMl7p8/OstvVNfB8+w= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B31DAF80694; Mon, 1 Apr 2024 12:08:22 +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 23227F806AD; Mon, 1 Apr 2024 12:08:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0A1B8F8065E; Mon, 1 Apr 2024 12:08:16 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 20D23F8056F for ; Mon, 1 Apr 2024 12:07:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 20D23F8056F 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=OVjne0oK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711966063; x=1712570863; i=oswald.buddenhagen@gmx.de; bh=gT0Fc3s0V7arG50ohbQehwLq67lOsar3syDQYGHBBr4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=OVjne0oKC2+wMJFxooPr0tGh3wceA4nJr+g44rg+Zqg+U+o7m/8YRSJEKf6dFMv0 zcR300BW8SSHY14mNdH7CiaCIss+CiBBpB9X5FykMitPughRUVeI8gA8LVmNWdQaZ srPdreawoIWLjHSRRMiTIR4pY/mLoUiApCG5Sx3v6FIEtM+g2K0FBc0TQ+X/UU+wr 6EoZxqId7YoeXgUMsI2lV1t4AvrzGqOFtdpI7zcV6+11+NwwX/Ec6RctVwViTVN/X 5DLbu1KeFNafNGw6IfUO0RiUreksME8lvMjOWQwOLvPO6HC/w+xQNriVVe4ZirNcm n/FXiC7woHTxFsCXOg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M6DWi-1rtSZL0qDY-006frn; Mon, 01 Apr 2024 12:07:43 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7du-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 02/18] ALSA: emux: prune unused parameter from snd_soundfont_load_guspatch() Date: Mon, 1 Apr 2024 12:07:26 +0200 Message-ID: <20240401100742.506001-3-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:iESeTNFIgd6pizp9aZxMAcRK/xLC4yhcdfRAfLxZzjcnKmZF3qs UP4fgAwNX5WDFnJaySbWm7H4y8xyotGQoAc1fRX2LseEV8MMXAs/fIVLgfbTWm6LjzAe93y 6Vxo+xMepA2YiWboY+BNxkmuJtatcRhcvt5deLN9mrv4ZX+gG2MyNZK+Q6TZCyVqXHLCb+I r3nzJzyd+2+Ws+QNeiDkA== UI-OutboundReport: notjunk:1;M01:P0:w4FXZXYjTRA=;YhCtQBtFOSYDwVeHWcxKJk2UiK5 a3kfcJU1AqxFWAQ2g5TAPcEMXpQGBDmL0iB0TH+fcpku5ZM3CJLdCjb9gWaqwYmbihSIHFFI9 QbXXySoIJUF3tIXDycsltsG4tr2XabSLtlH3mFnvhBXFZw/RcVDYJfiZ7b0DQWjM9maolfDna PaDxoNflM82bz4fnGTqKSLLW0vMWuKVK1IUv0KdmZwEvb6VhdmfVMriIJRMrwUH07wIyz9OGf xmCBX03uzChsg8jRJ+2lkv+M6UwWL1BFiBuzZHxWOVLU1yttuM38u32d1WoihfZvrDD6PBuYI O7N7elFODdvJ3swsKWtBnIlE1NETKaA+dTVQxV9RoFG0VJr4yfGChIq5xDRg6HDv3/Nz71kp/ mmm8ci2iSnEGxoK2fH8ZHpjIG6OOZo2ZeqnZ3yy2U2FuUbIm6aw5CoRFg9dFn4qD8QZ15J20b bKcLoj4H/7gUDvgT1Dj0Wctyh+G1gvUkWmToDBrUcSL6Pfxi663BxbhRkjJNoVrx1rD5vLdEq 6PpCy/5U7H2xPgAtQEEg565M1WbgZqPh/6LHmv69de/BrwPSqtd+kBdB8dOp20fsfRkAe3PA2 G3jq9fvBpoSzUOkDOXRFHONN7U5SO7kC8a27rQass4uq3KnSMXgtd0TEeZR/HVU4Ep5bmLawQ 1HLLsyf5eANZWVqV8wdDpQP5lrLsUYYEEeq8x/QuhXXQDuG2+VchUSXgCBoA9M4w+FuqgFvt4 xzgs9zpLRtHyCsssWpn4rwIR5CjGRaMYsWctiIDTUatuP4g4abBHlE/MeTo2AZXWxGA72hT51 VNYwR+sdosyKotN24TKtcSr1t5rsd0HVdZdk7o+nHwGos= Message-ID-Hash: KSMA2SLIV5BWQITBEDAA7WTVGO3TI57N X-Message-ID-Hash: KSMA2SLIV5BWQITBEDAA7WTVGO3TI57N 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: The `client` parameter was not used, so eliminate it from the call chain. Signed-off-by: Oswald Buddenhagen --- include/sound/soundfont.h | 2 +- sound/synth/emux/emux_hwdep.c | 3 +-- sound/synth/emux/emux_oss.c | 3 +-- sound/synth/emux/soundfont.c | 7 +++---- 4 files changed, 6 insertions(+), 9 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/include/sound/soundfont.h b/include/sound/soundfont.h index e445688a4f4f..98ed98d89d6d 100644 --- a/include/sound/soundfont.h +++ b/include/sound/soundfont.h @@ -89,7 +89,7 @@ struct snd_sf_list { int snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data, long count, int client); int snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data, - long count, int client); + long count); int snd_soundfont_close_check(struct snd_sf_list *sflist, int client); struct snd_sf_list *snd_sf_new(struct snd_sf_callback *callback, diff --git a/sound/synth/emux/emux_hwdep.c b/sound/synth/emux/emux_hwdep.c index 81719bfb8ed7..fd8f978cde1c 100644 --- a/sound/synth/emux/emux_hwdep.c +++ b/sound/synth/emux/emux_hwdep.c @@ -27,8 +27,7 @@ snd_emux_hwdep_load_patch(struct snd_emux *emu, void __user *arg) if (patch.key == GUS_PATCH) return snd_soundfont_load_guspatch(emu->sflist, arg, - patch.len + sizeof(patch), - TMP_CLIENT_ID); + patch.len + sizeof(patch)); if (patch.type >= SNDRV_SFNT_LOAD_INFO && patch.type <= SNDRV_SFNT_PROBE_DATA) { diff --git a/sound/synth/emux/emux_oss.c b/sound/synth/emux/emux_oss.c index d8d32671f703..04df46b269d3 100644 --- a/sound/synth/emux/emux_oss.c +++ b/sound/synth/emux/emux_oss.c @@ -205,8 +205,7 @@ snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format, return -ENXIO; if (format == GUS_PATCH) - rc = snd_soundfont_load_guspatch(emu->sflist, buf, count, - SF_CLIENT_NO(p->chset.port)); + rc = snd_soundfont_load_guspatch(emu->sflist, buf, count); else if (format == SNDRV_OSS_SOUNDFONT_PATCH) { struct soundfont_patch_info patch; if (count < (int)sizeof(patch)) diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index 16f00097cb95..e1e47518ac92 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -941,8 +941,7 @@ int snd_sf_vol_table[128] = { /* load GUS patch */ static int -load_guspatch(struct snd_sf_list *sflist, const char __user *data, - long count, int client) +load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count) { struct patch_info patch; struct snd_soundfont *sf; @@ -1122,11 +1121,11 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, /* load GUS patch */ int snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data, - long count, int client) + long count) { int rc; lock_preset(sflist); - rc = load_guspatch(sflist, data, count, client); + rc = load_guspatch(sflist, data, count); unlock_preset(sflist); return rc; } From patchwork Mon Apr 1 10:07:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 785946 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 133B9CD1288 for ; Mon, 1 Apr 2024 10:10:34 +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 4570C227E; Mon, 1 Apr 2024 12:10:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4570C227E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711966232; bh=Y25qGKh1Kh1VRLsyyRo5Clgw0Oj//q0xuohdKfr9hHk=; 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=I90phEuHG5mJ7sjrVFQmkPrZFr564jDAo2lJQNPUTPlY0D+nKvh7BrPAZODixY1DV VVi3CEdMWSQ8zh5f9u4jPzqzOMsgJcTaW2t2Ckvbx/wyBnAnDwotHjAhYaYuw9u8VK 3s9GP3xwA5G5uFUccyfLBymV31yiTLmalWq4EIIc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 29605F805A1; Mon, 1 Apr 2024 12:09:06 +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 6841EF805AA; Mon, 1 Apr 2024 12:09:06 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E9C0AF8057D; Mon, 1 Apr 2024 12:09:01 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 406FEF80568 for ; Mon, 1 Apr 2024 12:07:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 406FEF80568 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=YGQptbZY DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711966063; x=1712570863; i=oswald.buddenhagen@gmx.de; bh=YhQPRxRn3axvs5eoP6C+dAAGrMyhTu4iH/cIsd1W9zo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=YGQptbZYBMBpYAV3nyrQDr5aB1hzfYYl+hzNGn2Ew9F23i2/Ntt2obycwybjQl66 PP8C7P5Mp6qjiaeLAhD9FKegeX/SvT2cqva8RVB6I6/6puZonKp+5PIzO/pnv1OxD vX029CHSGS9o4TkMXIlDd1ptp4W9tlwgewSciOxV17cnxQ8/Sw4PwNmXw5g3n1/Kf DTtWYx9rVch8w+jAOEb6L6Wp6l6R/TV4wPz7nFzvraaGO/XiDnlmRoPPwcrHENX+c uqG0zjpYmnJZFqfMf2FQhZ0uvyJjh0E3BxjpeWjXHkmRI5cBj+1fO7xMDsRPemiRy cUlU6Y2ztmvGfUInPA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N8GMq-1svDGJ0pk0-0149Lb; Mon, 01 Apr 2024 12:07:43 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7dz-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 03/18] ALSA: emux: fix validation of snd_emux.num_ports Date: Mon, 1 Apr 2024 12:07:27 +0200 Message-ID: <20240401100742.506001-4-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:jObIqgvKZ7AroiwqCzdjtcn21fxyqFAWtjTPaHUtl7+AjQjHLji Ml9nhVZ20JvUX/a6Y00fssN231cehJJUyXr7z+365gVT/mL/uhg/094DMC9sUIAZ5xZMxwp skCH07T7J399UF0jqVSAqYPae/XmiUL59iv//7mHJV+oD1TB30xDtu+Ltb6q/NbAOvUX1AO DbJ1YuG0DAvDXrIfzaQ1A== UI-OutboundReport: notjunk:1;M01:P0:7vW0BtHI/dQ=;buIzqvy5FznymgyQnFYya9eKHFL EaMiWSpRo69IdGMMHpGHD8LNK3+zyYjv4DhNoMlbt8AS5zYvT7roQEcl2pgdw1yOUrSLoKzwi oaBJ07/U7JINPYxv2BZ7p3KNtVypyItoOWA9QUal/mVNBLeAchOjxlx30ZkHGrDi6Fnwu+qf5 ghXjKPxaFIZ86Cg8Db4ZPFHQ3/Ox4u/Sxq+oCEGlH4DPbfRP9L2pqQDzOsYmaOA1W9jnMlvgS I/kSsqopee6j6BNrrwBbKq0V24QY4u7jz+MkQu1Vz3KtlPMiUQePDRdf6jfG4f2LFI6HuUHdh YyV5L3MxPmdr4t6VVYYJmq7QMd2iKuHMd7DuOYtMbel96X44LnQnFblhG68NZ8QLxOpgIi3nO 1mW7CWRqBuqMZIJHH/kHfJ9/izICyMjgc/aMW7Zzt0QYwFlC1BMlEXM7HPY52UyJe+5hLBTDL JQDUOwWqKUmvXA5siI71PlT5dC6AtFDKfKLWQ2L9m+K/hIXVeyK5t5cPboCic72K7T3UPNX52 YVvfCLKjwO/Nmx5we48zzDGOlHWKAwHGcK7M6SEHxFVWJ+2unaTdAjC8VzE5iV6XAABR73ZSt rLfsFL0HFcDgjp/MVvfgCpIVzxfph7XlyhCtWVSPiwvBJqYpGL9I2zrRfuM4XmG20/mmTbqjr GoBf9ObOhaMczqg2Cv5e0bd5/8sFv8w2ZnAvzn+AEpzazpMhHwaCZUCzQA7TVg3R2IPaQniHl 6wOgTUNduSImhPIFZVyYIKMZSTaKnVABvqtvEeKYsh9UIGsMfmjlAQ6/iq0lbjIzlX1Lxwhn8 RrXHr/KsECVg1sfDg4voMe5s6JHvMi8M5N4w5dg2N27Ks= Message-ID-Hash: TBYJRTEZLH52NRHS5AYWJ3SS557QKE2D X-Message-ID-Hash: TBYJRTEZLH52NRHS5AYWJ3SS557QKE2D 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: Both bounds had off-by-one errors. Signed-off-by: Oswald Buddenhagen --- sound/synth/emux/emux_seq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index b227c7e0bc2a..1adaa75df2f6 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -65,11 +65,11 @@ snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index) return -ENODEV; } - if (emu->num_ports < 0) { + if (emu->num_ports <= 0) { snd_printk(KERN_WARNING "seqports must be greater than zero\n"); emu->num_ports = 1; - } else if (emu->num_ports >= SNDRV_EMUX_MAX_PORTS) { - snd_printk(KERN_WARNING "too many ports." + } else if (emu->num_ports > SNDRV_EMUX_MAX_PORTS) { + snd_printk(KERN_WARNING "too many ports. " "limited max. ports %d\n", SNDRV_EMUX_MAX_PORTS); emu->num_ports = SNDRV_EMUX_MAX_PORTS; } From patchwork Mon Apr 1 10:07:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784855 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 F062DCD1283 for ; Mon, 1 Apr 2024 10:09:40 +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 3B49322AB; Mon, 1 Apr 2024 12:09:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3B49322AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711966179; bh=YIwbIZ6D+FCvdDacAGPsNTeusqvHMyZJnVxHcW8EYOw=; 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=rLaNv0oM96+QI7PWFF0wZ0jgiKDlbMHXoTFKXORDcxSAwXpPrQwSQwRmipABLcPKK hZ1zXa1CD5eIvh4bwCnM5S3G1yt/ikjkQ5XEJVlJoQllq/tUskTcOOyp1jSLKWaD7F P17s9vDfdqMJh2Nh67tcXfkVokCMFRGW7yYyO8ME= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A7BDDF8064F; Mon, 1 Apr 2024 12:08:14 +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 0983BF80571; Mon, 1 Apr 2024 12:08:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B1E62F80609; Mon, 1 Apr 2024 12:08:09 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (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 84760F8055C for ; Mon, 1 Apr 2024 12:07:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 84760F8055C 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=rf1tWWQe DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711966063; x=1712570863; i=oswald.buddenhagen@gmx.de; bh=BKRzh0jN6jwk4FV1MW84OiCzx2QTtPr9DeRxFjCpOmA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=rf1tWWQeAFYRzwoP8GsxHe+FKUWcEReWvWfz7xBfBFrihABesqA7V5BBSNolC68C 99qI1SCXD4KWunq91PqZ1BBqR+2HQDOgeJrPsyHUyii92xhUEDSKbsBEZUUIKn1kz TKrH71tw5cH+o2oKxM8wNdIdKlsk+4Cm3iu7Z2hr+UCXOxkoONZb3i4ULxbIhIFsP smd9Hb3qpyC+JPaZfegaxmCgNTYebSku+bLUu5HwJbirTQOU/JqodvB6bay9Hj0sZ B5Fwp0bzIfpkJO244XshJZtrW7TJgBewtWwUnicMXyNXFJnvmhUqQ84qPUNKlEcH/ oUyrzz+6jL93WIkLpQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MPokN-1sD2YW10p1-00MptT; Mon, 01 Apr 2024 12:07:43 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7e4-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 04/18] ALSA: emux: fix init of patch_info.truesize in load_data() Date: Mon, 1 Apr 2024 12:07:28 +0200 Message-ID: <20240401100742.506001-5-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:G3rSiJ8DS/wmwmyxOX+mRs56xPxKj+7FyV5rH1619Y4yEO+3h/t iMslymP6AaCHvF+lWi+jXm1naB9FJs9IhfQehf0q/kYy5lG1MC55AECY5WBHtAoS9y2fn97 LtIzj9Qdjn1k32dI/NNCAyLtZjegRfiepE1v3YdGLQTCqoj4cGothwK/tcNvvDf9HvguvLo fMFvEW7IB0JWBdklMl+uA== UI-OutboundReport: notjunk:1;M01:P0:2ild0AsdVjA=;SPNsFEKCgEG5bEzFRC2SyFK/iqb zUqacry6LTZZii6eNFoYx3CIm2XZBPOz8ylIA6QTyVxrojaUYZcFN1EeQ3/DGYky/JQpRcyht Ks20sk/48Ekk2UJ7LoYJBQn05EWaA+zozRDA4OfbYJuzrj01TdfY8l7/w4SrWNaeH+gR6PZIJ oU8yTN3Mf0vx3UKf66eMSUpTCB71bHECGRmRdDcHHr2mcFXkOYAsx9G7H29s+kG+wOJvaS8GO vLD26iA8ON6DeVXB49kOZvzewhn5NzC8YLq9QbBvotpFw5LnwG+iYrBy5l0R7uuLyX3s0AJIJ 6OXGhVOAlrZMWxu77miq+v8kQefQW3zkQz3Qo6Q4n0Y4ZpbSnxOluEDFTPvcki5XZi3ggBrx3 99Ux7S63uXueEiYDmGAr5fNRKfz9DXj0LC7ko60Ou+vSaMJcPogQc1fzrd8BsMPMPeUCmq3be y8vJloEYRstYVjg0QOtgb2Vyjn39cySsB4sTgEmf2gs9iZ9Edi/Gb8N5cC01TkEPHjSKlAGvK PXihzZT8f36X7eLN+XHMLEUlUBMfFpNskE4lw1B96XTO3vbMM/IJbivbvcdLuwFPRAlth8rFV qiLYDdEE9qXvvopxU+IL5sQNm+DjOVKig0U26bx/EqJdWc8MUzQpJBmZVDETLzhbNzEmttHxz wj+29fCvM2Vk3LNxSnDcVmJBTJxMhHsKk84yB4iuJiexag9f0o/18U0JaJiEdd54iLGTG0uHQ yDDT4MiRLn17SDh4En5tT0+M/LXaXf554nV2RkgvvJWDmj4FuW2vVpIvTx8S0JfYsHpVD1b/c AiD5GkT1bktKeAo8Up9PWI+akgBnvzIt5R8q6cOjC4W48= Message-ID-Hash: INISSTAQLD5V6K3PU5BUFJVTWOZZEO6D X-Message-ID-Hash: INISSTAQLD5V6K3PU5BUFJVTWOZZEO6D 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: The field is explicitly documented to be initialized by the driver (which it actually is). Also, using patch_info.size would be actually wrong for 16-bit data, as one field counts samples, while the other counts bytes. load_guspatch() already did it right. Signed-off-by: Oswald Buddenhagen --- sound/synth/emux/soundfont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index e1e47518ac92..ad0231d7a39d 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -735,7 +735,7 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) sp->v = sample_info; sp->v.sf_id = sf->id; sp->v.dummy = 0; - sp->v.truesize = sp->v.size; + sp->v.truesize = 0; /* * If there is wave data then load it. From patchwork Mon Apr 1 10:07:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 785949 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 74774CD1283 for ; Mon, 1 Apr 2024 10:08:53 +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 4F38922AC; Mon, 1 Apr 2024 12:08:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4F38922AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711966131; bh=iEN1KqrjQn+PNiPB7210cC49xYYGKZcR+MLxEG2w4dE=; 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=bgEyuNPl8UReZvi+HFGUel1HUyD0+IFsN2zMBOgi0bZYQGJVlPFa7GMWZ0nz4L1zx ylSzBNMj4ZORhrPbKELg6uoLq5Jmn5I5VcwpRUYOet/F8XwPPDdnoAIMiJ+jqZeyzr rS6xafTRpO3qGO3zpG3ShpBKBrI+dQmn4qLJaKKc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id BE878F805EA; Mon, 1 Apr 2024 12:08:01 +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 447F6F805EB; Mon, 1 Apr 2024 12:08:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 92B20F805BD; Mon, 1 Apr 2024 12:07:57 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 9E70AF8020D for ; Mon, 1 Apr 2024 12:07:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9E70AF8020D 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=Wa3x/XdV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711966066; x=1712570866; i=oswald.buddenhagen@gmx.de; bh=TUz8ah5z8pNT083e8DQKx/8kl8YBAd0RX2+UgScRUnc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Wa3x/XdVMcPVhz5ToWJvQtGIC6FIUkjf3OxHBbkQguIFHIts50eRU61rbZCq4afQ ofQ4KR95TfznfFbkRmiJjqLaE1pjZEEuZlSs/LdXPeitZejtNa07m7Mvk0sx5KVZn 0L0K4msJ6IrxRkAx8vsU9jpfHprS4woJcgpu9G5c024Iac2G9vrIx/1mREq0Ht9tw B3huvj/EdtQc5aL1j8ESXON7XEFt5J5m0KSEXBdgM4Yzkv19gcShDCKyu1EnoJV+c rcyI5y4JSgxcCAkzGENdgvfwFTEqMPiKngTLKpcbUBhCPFa/xfwMG/7bxUr7cO9+b wh5HimEe1bI3RmgbwA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M7K3Y-1ruYUs3ddc-007jWm; Mon, 01 Apr 2024 12:07:45 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7e9-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 05/18] ALSA: emu10k1: prune vestiges of SNDRV_SFNT_SAMPLE_{BIDIR,REVERSE}_LOOP support Date: Mon, 1 Apr 2024 12:07:29 +0200 Message-ID: <20240401100742.506001-6-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:YNtA1YxaPvWyD+slmpGZQQSEj+m2PmnVNPzrMCStPYfP3yEDFsx APkDqKo+XhSBT+w59QdRmMeAmbyoRbwXb7mogTQNQej/igJ3Kr1wzM6/IGwW2uYFH6mZVtS mde26jHCBLgjyIT2OA01CKD8VyFUYG0M1FV2pmxD4lSoBThR88gj37bxkQcqsrAwOZHP615 0+QhlwayALhJifbg0arfg== UI-OutboundReport: notjunk:1;M01:P0:VG7oq8BLiNA=;vcpCQrTrUMDf1pJ5kYbTzm0CxrK Kk7ceDf6dRFmuyAiTpuMKBzVmpq0WMO2yvhRPu3jb0vbvcxtWgmeAw1IoiPSL1z+1RgeQ7s0O SMab89jtJmN1A2BfiH72j+QxHS3D3lRlmPbGsUoY4DRyXzm/9TRjifYQIZF+gfSb4ALkj7n0t mHvK8d9Q1BlXUt3DimscKHdGCvLaPVES1bioYxEqu7RiElpJ/BeDS0DesaOI0lzVFxX15mmNj UuxkyLclV+Xb3/Ctul828v7kM2QjlCTHTJue63a6bXnW+bquuWUafEwhXlIHVakIvvOMnoFw8 bTfF0cC9IHxiawNjEOy7+Rp3iD6actE+9I6W07vzV+Zawh6KvOW9tKrl664WJ5FJS5sq7Sdi4 gGtKXsIt24wVdInjpF1uMTCh8/G4k+pWKmSrB/4fJugRqaBdivyxjGn/RMzrN98GqRpjM5VPE rqrVF19HMnAegL1RGypEyHcX5eUy9y2lwCmWWvwq34bMAKCm77lxJEr3/kWoy+LYgZ7Q4YwMP N+PmmGjB62UZAOLwICsVE5j7pO/cYRv41EYQdme1jCOYFrQXo1a6odHLV5Gn7BG+K41GLBBhB dbv7GbXmJ4XP9D3oqeDBK8O60YqecpATxfT29GRXt2pLgbK/FsixgpjZp5B+wAUK5L6rjJdgF LvKI320bED5/jS2194hVloKgV+HHwrONd02GavKfcDvh9ohahJHqiV2uMJmngtgyPmQYYE6ok NlCSc3/iRpLNSqZ2dOPRpLwk9Cpv3msluapnKLjjbb5pcwwyXFmA66nTQE8NeNWcYSU9nZY21 IET2rShcibfwdft8yki0txhVGhhGkztzbyp9wQDwyCaE8= Message-ID-Hash: EIBVPM6I4EZ5KDQQHUGFDL5R7JYKUKRA X-Message-ID-Hash: EIBVPM6I4EZ5KDQQHUGFDL5R7JYKUKRA 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: This is required only to implement WAVE_BIDIR_LOOP and WAVE_LOOP_BACK in the GUS patch loader. It has not worked on emu10k1 since before ALSA hit mainline, yet nobody appears to have complained. And as it isn't super easy to implement, just admit defeat and clean up the code. If somebody wanted to resurrect the feature, the emu8k driver could serve as a template, but the code would be quite different. But arguably, this should be done in user space in the first place, as this doesn't represent a hardware feature (somewhat ironically, the actual GUS driver has no synth support, and therefore no GUS patch loader). Note that instead of properly rejecting affected samples, we continue to just pretend that the feature wasn't requested. This is extremely questionable behavior, but avoids that possibly unused instruments suddenly prevent loading the entire file, which would break backwards compatibility. But at least we log a warning now. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_patch.c | 73 ++++--------------------------- 1 file changed, 8 insertions(+), 65 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index 89890f24509f..49214c226808 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -28,8 +28,6 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, { int offset; int truesize, size, blocksize; - __maybe_unused int loopsize; - int loopend, sampleend; unsigned int start_addr; struct snd_emu10k1 *emu; @@ -43,32 +41,24 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, return 0; } + if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP | SNDRV_SFNT_SAMPLE_REVERSE_LOOP)) { + /* should instead return -ENOTSUPP; but compatibility */ + printk(KERN_WARNING "Emu10k1 wavetable patch %d with unsupported loop feature\n", + sp->v.sample); + } + /* recalculate address offset */ sp->v.end -= sp->v.start; sp->v.loopstart -= sp->v.start; sp->v.loopend -= sp->v.start; sp->v.start = 0; - /* some samples have invalid data. the addresses are corrected in voice info */ - sampleend = sp->v.end; - if (sampleend > sp->v.size) - sampleend = sp->v.size; - loopend = sp->v.loopend; - if (loopend > sampleend) - loopend = sampleend; - /* be sure loop points start < end */ if (sp->v.loopstart >= sp->v.loopend) swap(sp->v.loopstart, sp->v.loopend); /* compute true data size to be loaded */ truesize = sp->v.size + BLANK_HEAD_SIZE; - loopsize = 0; -#if 0 /* not supported */ - if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP|SNDRV_SFNT_SAMPLE_REVERSE_LOOP)) - loopsize = sp->v.loopend - sp->v.loopstart; - truesize += loopsize; -#endif if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_NO_BLANK) truesize += BLANK_LOOP_SIZE; @@ -96,65 +86,18 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, snd_emu10k1_synth_bzero(emu, sp->block, offset, size); offset += size; - /* copy start->loopend */ - size = loopend; + /* copy provided samples */ + size = sp->v.size; if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) size *= 2; if (offset + size > blocksize) return -EINVAL; if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) { snd_emu10k1_synth_free(emu, sp->block); sp->block = NULL; return -EFAULT; } offset += size; - data += size; - -#if 0 /* not supported yet */ - /* handle reverse (or bidirectional) loop */ - if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP|SNDRV_SFNT_SAMPLE_REVERSE_LOOP)) { - /* copy loop in reverse */ - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) { - int woffset; - unsigned short *wblock = (unsigned short*)block; - woffset = offset / 2; - if (offset + loopsize * 2 > blocksize) - return -EINVAL; - for (i = 0; i < loopsize; i++) - wblock[woffset + i] = wblock[woffset - i -1]; - offset += loopsize * 2; - } else { - if (offset + loopsize > blocksize) - return -EINVAL; - for (i = 0; i < loopsize; i++) - block[offset + i] = block[offset - i -1]; - offset += loopsize; - } - - /* modify loop pointers */ - if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_BIDIR_LOOP) { - sp->v.loopend += loopsize; - } else { - sp->v.loopstart += loopsize; - sp->v.loopend += loopsize; - } - /* add sample pointer */ - sp->v.end += loopsize; - } -#endif - - /* loopend -> sample end */ - size = sp->v.size - loopend; - if (size < 0) - return -EINVAL; - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) - size *= 2; - if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) { - snd_emu10k1_synth_free(emu, sp->block); - sp->block = NULL; - return -EFAULT; - } - offset += size; /* clear rest of samples (if any) */ if (offset < blocksize) From patchwork Mon Apr 1 10:07:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784856 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 87962CD1283 for ; Mon, 1 Apr 2024 10:09:09 +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 9AD7F211E; Mon, 1 Apr 2024 12:08:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9AD7F211E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711966147; bh=p5H8qT3c61nxNpGeIRjF9vQy0bV7RzOPQCe3zgQYZS0=; 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=U9oX3oW680ITgRfp6BQyhOrdPvNJWgOw1YzFXRlAPvJDqZqX/sJCbtXeOs0C8CtrN oTqtJBm4l8p8JAPjmG3OhyIsMKgb8Nkbg7MZ24fg89tE4fcygnOGTKH1uOQRQ1enUv 99y4NCM1BVHtH3CSjGlUd8IfQQzPC/1Q7hnvtFyQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4E3ADF80605; Mon, 1 Apr 2024 12:08:07 +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 8C1EEF80607; Mon, 1 Apr 2024 12:08:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E5910F805F0; Mon, 1 Apr 2024 12:08:03 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 50A79F8016E for ; Mon, 1 Apr 2024 12:07:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 50A79F8016E 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=ZhP/vasr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711966066; x=1712570866; i=oswald.buddenhagen@gmx.de; bh=wc/b2wKYlaKGB4GrE+oPQYlWRWZPL4Kua9Hy2ujNQDM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=ZhP/vasrcWPejFV4GRPcvKBd7bh55z8QW31t8MVYmsShAE8OIxlX3niYGIco5vfh x3wReWzgPw5ElNpeoSvswvoW6kKX6jXdOe1zPwtPTbANFnsPonz7tHLEVuDoBZdum SL75A/nlfn+Lrby5weIeDcZEA9lxiAJTAwreujnDwYXl/aUP+M0q3J27rFzXI0rpF 9FdTl1jozTngXmQy11Vyl5ZwqMQrgAEqFBTK0YOJnjE3SaWJBxOJb4ZTyHM0UicQZ 81cFqigZ+IHH7r8SNMdEcbuqF+3RE0/pMWMyEtaQK/HkQf2U4r4+GDAucArsjlnNU eXCPuZb0W60O+7R4pg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N7zBb-1suw0r3SuB-0150ig; Mon, 01 Apr 2024 12:07:45 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7eE-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 06/18] ALSA: emux: centralize & improve patch info validation Date: Mon, 1 Apr 2024 12:07:30 +0200 Message-ID: <20240401100742.506001-7-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:VNDo2xugJQJxXq3f1LZ+BDg+tTOX4UYnl2gMicSjvO9RaqXpSpY v32NFAMgUBMjHTpvFbbBeoqx7MgDE44EY9pUI0K1eYStfILFcxEyMX5aHU8WtGzs8/j2wXG kLnFxDMbHOyiJ73kSCBHj8kVEsYsl848Lo4xl5aF3X7ZFmRq/asS8uuh+FHdVPfCAzD/AFO fbxZalIFcVp7gUb7b90Tw== UI-OutboundReport: notjunk:1;M01:P0:tTYLddqBOfo=;8wtnKcddPeo9RjUW3aX08antoZT VibbQtL2X2D8WWKrM/BlrEIGVEwm2zgRw9Goe84PCbb3MRq1OAC5t3jZ37az4Q8LmUlrzADqw Q6w0XpVyP27Qy5nd8BhFUYV2crnmxGjPVflE9zMo0Hor2Z1XXoikQbhXc/5SOdZQuzqy7zzFa S5CFer4ylBeBpdAtX32ijqmV9h/sljRiQIDG4tbDYKz8z3Y1h5KAuCrK4RhVOgJeN3u4Xp3Wb kWw6OOYVnMu60fMf2MyG4117QK+EJtiBIOAuXPUokQMcTAmrEUKTI3a/TA2SdkrWpZoTfhibU oeFDQLQzD9/9f//oQRxg5cor1mNQgHX7yXyL+J1Cg8agqo/NNFM7u0gI6wAbLrNgsO66+Ezv6 Mj6UI8a8GKcfL/VxnPsvFXetwINOor6bVTYRY666wxF/LK9aSge1bIJqxeVmuDutqBgCWqfN+ 2+oyYedTnvMNSmXBJlW6Uj9eb7V+igEt2KK/i/bRmhhI9+pP4QMKBHPQqmYVdk0ME6LTHNO2f VF2H8HFM6/W7xuP/Mx3OpZS+KcDD1PXGYbODUws+lS6h4RW+Hk+bqzlBXbLzqsVxqDPGPirXr ZRzMtdtLGKfmv/okhzFI7/cs6ArOAIhaS0gW7JMYQxiW6Bq7rXUucDCnKIoSxk9V901Y3lWJM iQWWQoi0i9gGjj4V9KfjjNkaF5eYHX5F5VSDbS9VqU57WQZxXUT0vj3L97BTqLsZYlQMa2KY/ MspDbQ/vW/SihL18SHFf7uqzZdx1s/EnTBTi9FjgK5NaMJnyj8ktWZvjS/KdHd7dzByo7HHXy rFwF0mlCJCquoTRNQKF5y0QK94BGhbnudXOGQjVCmPgQg= Message-ID-Hash: RTBGDSQEVLLIBFO2XSVAQSAPW3P7YJHE X-Message-ID-Hash: RTBGDSQEVLLIBFO2XSVAQSAPW3P7YJHE 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: This does several closely related things: - Move the code from the drivers into the SoundFont loader, which de-duplicates it. - Sort of explain the weird "recalculate address offset" feature. Note that I don't think it actually makes any sense - the calling user space code should do that. The background is certainly that the source data (the SoundFont format) uses pointers into a single wave block (and the API allows doing the same for on-board ROM), but the API expects the wave data from user space to be pre-chopped into individual patches anyway. - Make sure that the specified offsets actually lie within the supplied wave data. Note that we don't validate ROM offsets, so one can play back anything within the sound card's address space. - In load_guspatch(), don't call the sample_new callback anymore when the patch size is zero, as was already the case in load_data(). The callbacks would instantly return in that case anyway; these checks are now removed. Signed-off-by: Oswald Buddenhagen --- sound/isa/sb/emu8000_patch.c | 13 ----------- sound/pci/emu10k1/emu10k1_patch.c | 16 ------------- sound/synth/emux/soundfont.c | 37 ++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 30 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/isa/sb/emu8000_patch.c b/sound/isa/sb/emu8000_patch.c index 8c1e7f2bfc34..ab4f988f080d 100644 --- a/sound/isa/sb/emu8000_patch.c +++ b/sound/isa/sb/emu8000_patch.c @@ -148,13 +148,6 @@ snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, if (snd_BUG_ON(!sp)) return -EINVAL; - if (sp->v.size == 0) - return 0; - - /* be sure loop points start < end */ - if (sp->v.loopstart > sp->v.loopend) - swap(sp->v.loopstart, sp->v.loopend); - /* compute true data size to be loaded */ truesize = sp->v.size; if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP|SNDRV_SFNT_SAMPLE_REVERSE_LOOP)) @@ -177,12 +170,6 @@ snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, return -EFAULT; } - /* recalculate address offset */ - sp->v.end -= sp->v.start; - sp->v.loopstart -= sp->v.start; - sp->v.loopend -= sp->v.start; - sp->v.start = 0; - /* dram position (in word) -- mem_offset is byte */ dram_offset = EMU8000_DRAM_OFFSET + (sp->block->offset >> 1); dram_start = dram_offset; diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index 49214c226808..47d69a0e44bc 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -35,28 +35,12 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, if (snd_BUG_ON(!sp || !hdr)) return -EINVAL; - if (sp->v.size == 0) { - dev_dbg(emu->card->dev, - "emu: rom font for sample %d\n", sp->v.sample); - return 0; - } - if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP | SNDRV_SFNT_SAMPLE_REVERSE_LOOP)) { /* should instead return -ENOTSUPP; but compatibility */ printk(KERN_WARNING "Emu10k1 wavetable patch %d with unsupported loop feature\n", sp->v.sample); } - /* recalculate address offset */ - sp->v.end -= sp->v.start; - sp->v.loopstart -= sp->v.start; - sp->v.loopend -= sp->v.start; - sp->v.start = 0; - - /* be sure loop points start < end */ - if (sp->v.loopstart >= sp->v.loopend) - swap(sp->v.loopstart, sp->v.loopend); - /* compute true data size to be loaded */ truesize = sp->v.size + BLANK_HEAD_SIZE; if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_NO_BLANK) diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index ad0231d7a39d..6d6f0102ed5b 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -689,6 +689,21 @@ find_sample(struct snd_soundfont *sf, int sample_id) } +static int +validate_sample_info(struct soundfont_sample_info *si) +{ + if (si->end < 0 || si->end > si->size) + return -EINVAL; + if (si->loopstart < 0 || si->loopstart > si->end) + return -EINVAL; + if (si->loopend < 0 || si->loopend > si->end) + return -EINVAL; + /* be sure loop points start < end */ + if (si->loopstart > si->loopend) + swap(si->loopstart, si->loopend); + return 0; +} + /* * Load sample information, this can include data to be loaded onto * the soundcard. It can also just be a pointer into soundcard ROM. @@ -727,6 +742,21 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) return -EINVAL; } + if (sample_info.size > 0) { + if (sample_info.start < 0) + return -EINVAL; + + // Here we "rebase out" the start address, because the + // real start is the start of the provided sample data. + sample_info.end -= sample_info.start; + sample_info.loopstart -= sample_info.start; + sample_info.loopend -= sample_info.start; + sample_info.start = 0; + + if (validate_sample_info(&sample_info) < 0) + return -EINVAL; + } + /* Allocate a new sample structure */ sp = sf_sample_new(sflist, sf); if (!sp) @@ -974,6 +1004,11 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count) smp->v.loopend = patch.loop_end; smp->v.size = patch.len; + if (validate_sample_info(&smp->v) < 0) { + sf_sample_delete(sflist, sf, smp); + return -EINVAL; + } + /* set up mode flags */ smp->v.mode_flags = 0; if (!(patch.mode & WAVE_16_BITS)) @@ -1011,7 +1046,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count) /* * load wave data */ - if (sflist->callback.sample_new) { + if (smp->v.size > 0 && sflist->callback.sample_new) { rc = sflist->callback.sample_new (sflist->callback.private_data, smp, sflist->memhdr, data, count); From patchwork Mon Apr 1 10:07:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 785948 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 8FDF4CD1283 for ; Mon, 1 Apr 2024 10:09:27 +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 9DA7C210F; Mon, 1 Apr 2024 12:09:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9DA7C210F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711966165; bh=yNlbA+5v9353GezzUIbNK70BCnj9zI4T7LWgvcgAZRI=; 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=f5CyipPkJzUE4C8tBE6WpqRBrDlRfFRYRkZaFebLcbs7wrB2hJFbyqLrgS7K/KuUZ W0Na70KXGGxtxUgwz/9b6GqH+V/xEnFxwO6WIPSR7qnG3Mlitu1MdcOsokM2Z1ZDdb 1hjRPNpU7ypuxFkYEp66e5WC6pu2FE2yiA3Sc3EM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 85327F80622; Mon, 1 Apr 2024 12:08:11 +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 BDA46F80623; Mon, 1 Apr 2024 12:08:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A71D1F805F3; Mon, 1 Apr 2024 12:08:06 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (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 5F587F80570 for ; Mon, 1 Apr 2024 12:07:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5F587F80570 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=R2waYRo9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711966063; x=1712570863; i=oswald.buddenhagen@gmx.de; bh=2GdLrZxDjdbvVF1lEmdcI8u4pC5LW9+4fvqwPQfg7dw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=R2waYRo9TMJcjzT3uIiSy4Gtlo6KTrx1aYA58WmBIuCWvlEMakfCS+kay/q9NKAm 3ytxh8y0POmrHk4U4ocpnzBaHkKBmM6uGjqSRbXDSyvjhSzm9hQy8ShmX5oZqn0HT iuL06iDyhaqmlV+YB77H5th1gcniPoQEd/FgCbXQpUaOnJDzIlQrRWbEYtdv1HPH4 dGBNdvNlc4tgzyhGD1jzh7UVKdIEt+8goQB0yOrGdDpF9AsQh9puncy9E5HMfVs95 JglC8iPqz9zdpa/VFwIrhdHf/hAjSDV8gf+ZtxQcppupndokKPCDpy9cVg1NQrRne DCgKmJZYXoUXkKXCZw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MaJ81-1sNWP40qF3-00WCHO; Mon, 01 Apr 2024 12:07:43 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7eJ-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 07/18] ALSA: emux: improve patch ioctl data validation Date: Mon, 1 Apr 2024 12:07:31 +0200 Message-ID: <20240401100742.506001-8-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:Z/q+2LLGyEN7//d4CiaT3co7zvWHxi2sZ23coWRxZWomUAsqoaT 89PG4vH8P1y4Imy5xIyLP+egNvsiV9pdkjQmHfWKI/J4P1m+UtxyXJ9ftaAEAJ91iFi/Hac kfKGJB+7agDKIMPIc/ItwN7envZpkDlzyrQQou1lLOzlANHvvazjdCwBWSxwx/jrXV1p3GF 8pTmnota+rDeE1IEOzotA== UI-OutboundReport: notjunk:1;M01:P0:qd9jzYW/y38=;ZdtGEmiOd6tOegKEtv6GMDIVuv7 VDLt2bScllC+Oo7Hi43fZP9VYJkL2QB8iXKx61Ge+qZ6BvFVZBVCsWES5t4iqVg0SbOKe5var IzLxm+FZ0Ou3lctqh+x8xDED6tw6GGpBI2UDp9swKeruyrGYC6C1AkwCfr7RXpwNcxUyZ8hPu 4Yx/YDJH+sckASGU/EHG5fnPibzMhUX21tAICUzVVF1D1Pbncpda1Wq4dFE8YitQclgY/urEu ZuqrY3WVN4ADWUXQzdPK6/XRLJp0VMuG+c1m4jnFkp1EyXGUIPcdnEt/9vp2SGP1F5FlRCY2q 86y2ezurkXlWOgQyBGp9U2Cf7CdtsnOTs9XXtsbTzKI5Sp+tBczRuw1S2kwwGx7ngZrx3tyiB 5F1nBHYid18sU37WjSk+xQee2MZ2SqjWeLPQcHmBjGwvhUtsj3gUoEKQgj44M8eFfNgcmRHU8 oSIeAnvrpU3//nKzOjkY4yA0foru0gOm5ynK0cFi1zem1wet9FDE0Gpz92PwnAjBQxv28enOg ciGqb9+wISKxtDIzdUIOUNvxTDrcS3N2qGWeJdg0PJLOEi+vahDkytv/jk9WLY+RUEetXDQRm 3vvNDma7K2Onr8Zo3YKw1x5Btf/9OHxBtcQn9Q0U65QZOTbZjqEuEcKqmQSd+c9Ym67uACWNy I7MU59c9q47rVPBALqkNGDsP7f/n+jXEBdO+z5UksXkGDooxjKbtWO0OvjIo9pQm2CeyaMRkz RiUzKM/ziNgt5j83lfPzCecKscB3fxpt350hLisqwJpdxsFRaFb6x6zLjUJoOpYi4ZaaLE1gX TQdJQ/Ew/JzS+R4lhhMEA2FRKfIhFBlA2SH01YmaG4MYQ= Message-ID-Hash: 2JKIT364YL7B4UKNR7O3YWBMVW5IOY6G X-Message-ID-Hash: 2JKIT364YL7B4UKNR7O3YWBMVW5IOY6G 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: In load_data(), make the validation of and skipping over the main info block match that in load_guspatch(). In load_guspatch(), add checking that the specified patch length matches the actually supplied data, like load_data() already did. Signed-off-by: Oswald Buddenhagen --- sound/synth/emux/soundfont.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index 6d6f0102ed5b..4edc693da8e7 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -716,22 +716,25 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) struct snd_soundfont *sf; struct soundfont_sample_info sample_info; struct snd_sf_sample *sp; - long off; /* patch must be opened */ sf = sflist->currsf; if (!sf) return -EINVAL; if (is_special_type(sf->type)) return -EINVAL; + if (count < (long)sizeof(sample_info)) { + return -EINVAL; + } if (copy_from_user(&sample_info, data, sizeof(sample_info))) return -EFAULT; + data += sizeof(sample_info); + count -= sizeof(sample_info); - off = sizeof(sample_info); - - if (sample_info.size != (count-off)/2) + // SoundFont uses S16LE samples. + if (sample_info.size * 2 != count) return -EINVAL; /* Check for dup */ @@ -774,7 +777,7 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) int rc; rc = sflist->callback.sample_new (sflist->callback.private_data, sp, sflist->memhdr, - data + off, count - off); + data, count); if (rc < 0) { sf_sample_delete(sflist, sf, sp); return rc; @@ -986,10 +989,12 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count) } if (copy_from_user(&patch, data, sizeof(patch))) return -EFAULT; - count -= sizeof(patch); data += sizeof(patch); + if ((patch.len << (patch.mode & WAVE_16_BITS ? 1 : 0)) != count) + return -EINVAL; + sf = newsf(sflist, SNDRV_SFNT_PAT_TYPE_GUS|SNDRV_SFNT_PAT_SHARED, NULL); if (sf == NULL) return -ENOMEM; From patchwork Mon Apr 1 10:07:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784857 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 5BE05CD1283 for ; Mon, 1 Apr 2024 10:08:31 +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 68E6721DD; Mon, 1 Apr 2024 12:08:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 68E6721DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711966109; bh=FnOnXxs8cQNILDz6eCQFTAc8g65/4WFFfJ64clc+g3Q=; 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=PhEKrBD46hbOp1ec7mX8TPc/S9BeXI4CJ3hEznlldSXL1Zsa64LJYSPAciqVrUcoz 37mgLSeA5tXQzy/XDQVlSQTsIdNFA9uJrLv/+r/yPFho3nmyHofA4ThdZIKQuPtOTa P+AUwbQb5TXEWFrC7RfkQGUkdI/VIRTHGapWKoSQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3B4CEF805AA; Mon, 1 Apr 2024 12:07:56 +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 89401F805AA; Mon, 1 Apr 2024 12:07:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4965AF80579; Mon, 1 Apr 2024 12:07:53 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (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 87474F80130 for ; Mon, 1 Apr 2024 12:07:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 87474F80130 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=LyvRRhcT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711966066; x=1712570866; i=oswald.buddenhagen@gmx.de; bh=WsiPGGqNN85sMCbUgri9GR8KKSrWW90a8p1Jz8kA+Oo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=LyvRRhcTU5Fuco0uMLMUhQs3geq09NNGdcmbVSKFwkr1Zxgqb3PQQJr3FK0F314k 8cC6wISkZZxCPnN+JMLBb9OH+RHZckDM0TKDoHpbmC76fZpqc8pj/KvaZQzKBW1JM 5Yu0mCxAYDEJXeYDZMV9TcvHFfDIvztd8AqUKBKlyiEkYZ+b+AQc/5T+NKqNGvbaL lbgT4tDe7Bo5/cWkmrt2eTjA/7n1G9KIVMrw6aJstyYOA25n6Bcvbbu2umWK70e5S U1xJQOWVSOSl2/9ddHqWP8Qbqy6fhClRa42XncYyCS0kCxReP6Vl9LnpLW0zc9wHj PBu5q6KhUXETZZw16A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MA7KU-1rxKAm3T7S-00Bf9y; Mon, 01 Apr 2024 12:07:45 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7eO-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 08/18] ALSA: emu10k1: move patch loader assertions into low-level functions Date: Mon, 1 Apr 2024 12:07:32 +0200 Message-ID: <20240401100742.506001-9-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:AlLLswnd6yDoX8NBc7X9uCfMIB1oc4qRk9ghrRUYYu7eqvl3pcI sywBO8R8TjQd33tnEbOJn/Wsqjkphc/QyoVzFluDMBeE6APBCffiQd9Flx3xleVis3UlqYN 99cmPSU9jbqcBzisRysAFdlo/BnYkXqYJBPkWjkfY6N9Yq3L6hqHt0potOK0kl05W8fZ//g Gil8U2y6ktSG9vR/mJiLg== UI-OutboundReport: notjunk:1;M01:P0:6o5uZYfoP0E=;+uWuajZ6OP+fMMJFOYPcFRcxbUy klshLIHL3WAUSOZik2kjLepmeks8CjjcMnKKrRPpIRe9a/VRuxRsVk/d1G65f9m/eZe3rtv8T KTL49r07k3fOz8TvrkxnqwTMm5mvkd6PPPgUz4ENdlHRy7wYQRpGODBWXgW5j1ZrJfTCFpT13 8D4WX19kQq3nhybbf+VGft5/ZAIHI9tFqRO0vKRktKSeARYmP4amLnPR4/Pfdfqt6tJ3pmntZ ZdvLkFs7SLQqfyE8ydCZVn0RLT3uOJnwNp/w7mmm2+zDp4rQSjEk0VbIXH9PxrYvU0LymBToO FrDJ0ue/BesSoj1o0VS53kGX7O22YEtM5xpXuQgll84hyjPVovUC//Hf/ss5Mw3C5r1hb3yoP /uGiOtPqgq2HrvkATylZdblM31vb0P6Ahu0qwvpRzLe9tqzw75YB7lWFGoTFcpRgY0mflR7DU f1GhOboM1iU6Fm2+FmuCcdxcVRj/RY2o+0Jq8NBI3K3yiAzPED7DxkUZhKGrLaivrg+Ksc7/R ZvmHWJai9NrhEoWi/rjdv4DPWNwyBn/24V3bf0JnDrytGrz32w12XnNMQf5EYlVDY5+V8+t4D COw9c/HY3PsA9ukZQ2Uufspa3aC4XT6zeUKjo+NSVRUcaOAvGIxicM9ySLMkuSgkjXbPSTq6Q JY3RGSmUg6RlsLiujsZlgIMHLvNLSvMnLohPeRmx87em5Pjto/EIP6+pM8juTXRNZQESC4xFW 7eHzll7WDdbD7py107hrRYDSJrPvD9pvWiBZl8+NtcJ3dI5BMJJKZYb86fCs8tDSyie4JII2j dDlnS8FxC6zDi3vvmK+5YNo3ugRthzAMLFS7mqsfRoZWo= Message-ID-Hash: SCKLCX6SK4QES6VH5X2RRH4QHKWNULQZ X-Message-ID-Hash: SCKLCX6SK4QES6VH5X2RRH4QHKWNULQZ 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: Convert some checks in snd_emu10k1_sample_new() back into assertions (as they were prior to da3cec35dd (ALSA: Kill snd_assert() in sound/pci/*, 2008-08-08)), and move them into the low-level memory access functions they protect. Signed-off-by: Oswald Buddenhagen --- Side note: this eliminates the memory leaks in the now gone error paths. I don't think it was actually possible to trigger these even before the foregoing cleanups. But if it were, it would allow a user with access to the audio device a scope-limited DoS attack on it. This would be only a very minor security hole, given that on modern systems it would merely enable the current seat owner to be a nuisance to their successor, by making a reboot necessary. --- sound/pci/emu10k1/emu10k1_patch.c | 4 ---- sound/pci/emu10k1/memory.c | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index 47d69a0e44bc..55bb60d31fe4 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -65,17 +65,13 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, size = BLANK_HEAD_SIZE; if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) size *= 2; - if (offset + size > blocksize) - return -EINVAL; snd_emu10k1_synth_bzero(emu, sp->block, offset, size); offset += size; /* copy provided samples */ size = sp->v.size; if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) size *= 2; - if (offset + size > blocksize) - return -EINVAL; if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) { snd_emu10k1_synth_free(emu, sp->block); sp->block = NULL; diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index 20b07117574b..fc9444404151 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -574,6 +574,9 @@ int snd_emu10k1_synth_bzero(struct snd_emu10k1 *emu, struct snd_util_memblk *blk void *ptr; struct snd_emu10k1_memblk *p = (struct snd_emu10k1_memblk *)blk; + if (snd_BUG_ON(offset + size > p->mem.size)) + return -EFAULT; + offset += blk->offset & (PAGE_SIZE - 1); end_offset = offset + size; page = get_aligned_page(offset); @@ -604,6 +607,9 @@ int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_me void *ptr; struct snd_emu10k1_memblk *p = (struct snd_emu10k1_memblk *)blk; + if (snd_BUG_ON(offset + size > p->mem.size)) + return -EFAULT; + offset += blk->offset & (PAGE_SIZE - 1); end_offset = offset + size; page = get_aligned_page(offset); From patchwork Mon Apr 1 10:07:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784853 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 53C39CD1283 for ; Mon, 1 Apr 2024 10:10:47 +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 B9E5221B6; Mon, 1 Apr 2024 12:10:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B9E5221B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711966245; bh=2TCwY/Gyk4NOU2VJqc4FGFU3S5jupvdli4moBN3tV/E=; 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=fN4UPV+1Za8Qbr+szFhQN2IwAB1lrwhslRt3MpLQ8C6nhfC7zuHNFQ2sMaebpcJUd ttJHBb6AygvP/J16Lhwm8pnej4TK1u5mzsmycrxkUJP7h0UIKRDuOaxjuEYVihUmkU cwTOrBDhP/9a98S/u1bSbD6X2q4pX9BY183uGrg8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 67942F805C3; Mon, 1 Apr 2024 12:09:10 +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 0325BF805C9; Mon, 1 Apr 2024 12:09:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73361F80568; Mon, 1 Apr 2024 12:09:04 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (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 96B53F80238 for ; Mon, 1 Apr 2024 12:07:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 96B53F80238 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=WA8jeHMQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711966066; x=1712570866; i=oswald.buddenhagen@gmx.de; bh=CAZ1ScoqbFZwHXnTKkLI/ab/oBnNr0cVzQYRhQr1P38=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=WA8jeHMQOonFdZWwVErCyR9ueoxIOFIH7yPYIIPV5uf/A77FpwH2fNTGzyytx21x wHzqIjNdtCmJ5TClnxqj/swbobPvLIedV+aHLGd0cgYcpX1RRS62chSy4WCe+rar5 n3+o/F6hl3rLHS/njEXDwMD7cV4dFMiKYLA+bCbBfAKMcshjbtcnKpb3riAsTve/X PGZH8cNQD3oliJcz6eRz8uBhgSygLNzpnogqRXl4vWTuJ/rVooEDuTEYT9wJ1FK6/ LWgNBV18qNEdZzP+7Ug1fUD8USMfrJJsXCOWU3YawKFuQIt7uSSdZlX1FwUrZBnpz wJGOukVFaWSgfII0FA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.100]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MfYPY-1sSWL03eCe-00fyO5; Mon, 01 Apr 2024 12:07:45 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7eT-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 09/18] ALSA: emu10k1: fix sample signedness issues in wavetable loader Date: Mon, 1 Apr 2024 12:07:33 +0200 Message-ID: <20240401100742.506001-10-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:/mu1YBF27/V9751SXEP/l9yIuLli7+cd559FkWQ3JwQCGyQuut6 HbSjVWvI5SGX00E4JaG1hqy6XzLCqxWc7d5C9aPljwOGkm7xEOxXR6/MxWCY0ylhzARH1wY qfwCpzz+CBpIJJW9aSoRVv1GMwxKdD3UdS/PAgrL6Zr5s71QxO116ckwJnxN+TapzM86lrC tFmw3p0lEC+IK3hj74ONA== UI-OutboundReport: notjunk:1;M01:P0:AbcgJMoWNeQ=;EaKkEKiijbkUJ9CU9DixzexXQP8 4NTRLIpxFs1kcYjlywoOMmQf/MTq5YhoFaDFQl+f1NVyjG1rBDZd94RW6G/aKe/VDahusYLzR B2Qe5Jerd/dv8jAj2U/gKFYbpq3hemIysb6pfxNEoipoR4obYHZRzSn4S1tRXe9GCw/mLErel P1OK2rfCzp527zcbbfBgmBK5V1PuxwVqG86zOGq6cB6vfv5eZWA31+fAOqBPccu/vRru6Zse7 KBfRPbjfP9R/cQ8SNhNdWqQM/r97mnJxKIbM4h1JK1M6hwPAWud8+Z3J/HO62dj1nZjfF54RO aa5LXCRv4+oTT9czZuTp14k72SOU2x4BVFwhsSOeEKH/pSC3dwzf3qWqWVVEsXyM6kvUEktXZ 7YN4Y5S+gMYas+1JMzGxzd6vT10OMCFGLLczZDYgVekU/PIcDA+zmaxWiDTMq8cvIdzuYEe7V aiGVhxDpoPlrLzyyhhDdRmmhFJGJmQfPnYEwpO+OMjNO56hC4WTUKZNIYR0unts207DHBgeYH iG8A6f0QBYkSf1TtBBZoRxtXYQqcmnR9MSFmcFn4mP25yeN++rRkkLyJC2L6/gnxcp1F17VNk BuAVFQicySuALa6WMS+6adHT2SKLpaqdx34qfRNJ85JrxHuVh4p4jXvIKkqdjI0twu8p8nPb2 5PjxolE5sFiuGke6xt5IkWNKmDBwScX1sEPhTlhd3cnUPYF1bY3gje78aeA9YHDK47iWVwD0U YHewJXtnmP5/sKHd/JGFnCcc29wPym8uyWFU5RYRkw0Af7SQNaKcsS+Tml3EFf8qG6PftG94V EicaCZmel5vKKM/3lN0lllOOKF7EHya7ks/omCr71Srko= Message-ID-Hash: WFAWSG3YO6VFZWI7TJNOJLOVS5HACMCP X-Message-ID-Hash: WFAWSG3YO6VFZWI7TJNOJLOVS5HACMCP 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: The hardware supports S16LE and U8 samples, while U16LE and S8 (which the driver implicitly claims to support) require sign flipping. Note that this matters only for the GUS patch loader, as the implemented SoundFont v2.01 spec is limited to S16LE. Signed-off-by: Oswald Buddenhagen --- include/sound/emu10k1.h | 4 +-- sound/pci/emu10k1/emu10k1_patch.c | 30 ++++++++----------- sound/pci/emu10k1/memory.c | 49 +++++++++++++++++++++++++------ 3 files changed, 55 insertions(+), 28 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 1af9e6819392..9e3bd4f81460 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1882,8 +1882,8 @@ int snd_emu10k1_alloc_pages_maybe_wider(struct snd_emu10k1 *emu, size_t size, struct snd_dma_buffer *dmab); struct snd_util_memblk *snd_emu10k1_synth_alloc(struct snd_emu10k1 *emu, unsigned int size); int snd_emu10k1_synth_free(struct snd_emu10k1 *emu, struct snd_util_memblk *blk); -int snd_emu10k1_synth_bzero(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, int offset, int size); -int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, int offset, const char __user *data, int size); +int snd_emu10k1_synth_memset(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, int offset, int size, u8 value); +int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, int offset, const char __user *data, int size, u32 xor); int snd_emu10k1_memblk_map(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk); /* voice allocation */ diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index 55bb60d31fe4..eb3d1ef8a33a 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -26,6 +26,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, struct snd_util_memhdr *hdr, const void __user *data, long count) { + u8 fill; + u32 xor; int offset; int truesize, size, blocksize; unsigned int start_addr; @@ -41,6 +43,14 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, sp->v.sample); } + if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS) { + fill = 0x80; + xor = (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_UNSIGNED) ? 0 : 0x80808080; + } else { + fill = 0; + xor = (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_UNSIGNED) ? 0x80008000 : 0; + } + /* compute true data size to be loaded */ truesize = sp->v.size + BLANK_HEAD_SIZE; if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_NO_BLANK) @@ -65,46 +75,32 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, size = BLANK_HEAD_SIZE; if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) size *= 2; - snd_emu10k1_synth_bzero(emu, sp->block, offset, size); + 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; - if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) { + if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size, xor)) { snd_emu10k1_synth_free(emu, sp->block); sp->block = NULL; return -EFAULT; } offset += size; /* clear rest of samples (if any) */ if (offset < blocksize) - snd_emu10k1_synth_bzero(emu, sp->block, offset, blocksize - offset); + snd_emu10k1_synth_memset(emu, sp->block, offset, blocksize - offset, fill); if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_NO_BLANK) { /* if no blank loop is attached in the sample, add it */ if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_SINGLESHOT) { sp->v.loopstart = sp->v.end + BLANK_LOOP_START; sp->v.loopend = sp->v.end + BLANK_LOOP_END; } } -#if 0 /* not supported yet */ - if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_UNSIGNED) { - /* unsigned -> signed */ - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) { - unsigned short *wblock = (unsigned short*)block; - for (i = 0; i < truesize; i++) - wblock[i] ^= 0x8000; - } else { - for (i = 0; i < truesize; i++) - block[i] ^= 0x80; - } - } -#endif - /* recalculate offset */ start_addr = BLANK_HEAD_SIZE * 2; if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index fc9444404151..d29711777161 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -565,10 +565,10 @@ static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset) } /* - * bzero(blk + offset, size) + * memset(blk + offset, value, size) */ -int snd_emu10k1_synth_bzero(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, - int offset, int size) +int snd_emu10k1_synth_memset(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, + int offset, int size, u8 value) { int page, nextofs, end_offset, temp, temp1; void *ptr; @@ -588,20 +588,47 @@ int snd_emu10k1_synth_bzero(struct snd_emu10k1 *emu, struct snd_util_memblk *blk temp = temp1; ptr = offset_ptr(emu, page + p->first_page, offset); if (ptr) - memset(ptr, 0, temp); + memset(ptr, value, temp); offset = nextofs; page++; } while (offset < end_offset); return 0; } -EXPORT_SYMBOL(snd_emu10k1_synth_bzero); +EXPORT_SYMBOL(snd_emu10k1_synth_memset); + +// Note that the value is assumed to be suitably repetitive. +static void xor_range(void *ptr, int size, u32 value) +{ + if ((long)ptr & 1) { + *(u8 *)ptr ^= (u8)value; + ptr++; + size--; + } + if (size > 1 && ((long)ptr & 2)) { + *(u16 *)ptr ^= (u16)value; + ptr += 2; + size -= 2; + } + while (size > 3) { + *(u32 *)ptr ^= value; + ptr += 4; + size -= 4; + } + if (size > 1) { + *(u16 *)ptr ^= (u16)value; + ptr += 2; + size -= 2; + } + if (size > 0) + *(u8 *)ptr ^= (u8)value; +} /* - * copy_from_user(blk + offset, data, size) + * copy_from_user(blk + offset, data, size) ^ xor */ int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, - int offset, const char __user *data, int size) + int offset, const char __user *data, int size, u32 xor) { int page, nextofs, end_offset, temp, temp1; void *ptr; @@ -620,8 +647,12 @@ int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_me if (temp1 < temp) temp = temp1; ptr = offset_ptr(emu, page + p->first_page, offset); - if (ptr && copy_from_user(ptr, data, temp)) - return -EFAULT; + if (ptr) { + if (copy_from_user(ptr, data, temp)) + return -EFAULT; + if (xor) + xor_range(ptr, temp, xor); + } offset = nextofs; data += temp; page++; From patchwork Mon Apr 1 10:07:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784849 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 B7B8ACD1288 for ; Mon, 1 Apr 2024 12:23:21 +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 1ACFC2340; Mon, 1 Apr 2024 14:23:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1ACFC2340 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711974200; bh=Q9tT60ciMRcMcS2X9ot+Kwz1z5LZ6bIsTpqlYG/inlk=; 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=u0qydz4vG7vsShFB0Zk0y0T8Fq0u++04JsxIOgs3zOTBsnf0Arqi39lJVEDiQL0UH vvnj6+S6V8VVbNM9lRgXphYfu2BJCpv39nH5XXvPUAEjT4YRGbrCVlT7kCyaiSddeR 3Hox8hV6CnG5PM48UG/Z8H04ClLNY+AYW0OF/Zzc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CEDB3F8063C; Mon, 1 Apr 2024 14:21:54 +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 4A83AF80621; Mon, 1 Apr 2024 14:21:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7AD18F805C5; Mon, 1 Apr 2024 14:21:44 +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 6C3F4F80570 for ; Mon, 1 Apr 2024 14:21:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6C3F4F80570 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=ORnW5ePy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711974089; x=1712578889; i=oswald.buddenhagen@gmx.de; bh=NSV6IaeMXQT3x2MlXFGRPWdrqgOejDE8n6OulzTKamc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=ORnW5ePya4o2t9xCkRU6roeF9f+A01RF/5GQWwbsX4S+9OCIOlP82uiET0pq9veG 8ZP8SVbb8RH5JV6M7l3+zMAzyXNod1jYdmzJjlddA7q5yVlKpphXHuG4uoptFRlve 1qTQ4UbnWL3mcHzOwEyvYDIddfIs3mRul4eQpaXZukw8U0e8TwVQzA8A9N7rAkw0e jXspsqP2wyzJZlhdafu7QcVOA4JoaXHhEShhByZ+dUOTYu24IGjuFfgogh4U0JyBt 0gBzS4E/dHFxIP2GDyqn5gdwESlKCKz0C8uTP7ZUjLGpX99ZIsIeXpSM04cYmEZzB WAepGaCHlGVPyfM58w== 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 1MAONd-1rxZ8F3rA3-00Bva2; Mon, 01 Apr 2024 14:21:28 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7eY-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 10/18] ALSA: emu10k1: fix playback of 8-bit wavetable samples Date: Mon, 1 Apr 2024 12:07:34 +0200 Message-ID: <20240401100742.506001-11-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:ub7K3W7n2ezRSpwOkWJMgdNmR7grRDQduLQblH6gVExcjY7Xek4 b44GHgw6cmyplZWHo6Tlrv0YLewj5IrSfruS04EcaExohlmmbMPJ+fCERLGKSJ2FFUtnUxd QHr9q1kIZ8DGWpfaNpYvswtFzXb+ih7vsXgXFRiNTUz3ueeTpZOiuxoKJrlxg0iebZrT/4t Nviil2xLGWaZZTK/7aJdA== UI-OutboundReport: notjunk:1;M01:P0:IpZij+8Rh4o=;rgMRXZbf2mBGS83SxpgKpQDok1q OpCv8Bg2MM6+8yOosCsom6BDHsLd56fnAiwDYBhX1qXvCOIzOQwwzcWkffNFPx38JHZGJQQXa R3Ay7Y6OAy/dAAne2uPS179VtDn1FboRVY9gKRttUmAnpOpbzcSbuFVIjQ+wDLRt0H3kkpen+ F1/KzSMn5bAIPS7H4xyaST8Jhv9w9LMhQnVuTW1QjI9yvVAXe8dRh36Ut4r2XFe4Qi42CVR4g 14BPFcOXQx53r5Se3lpoGS6X8cbwHrAW2qTkh9xDKrSS2g99gbL0bt4rHhbTupB7zbazYMb5E MMYtEQPkxXgG1MgcC4ZZRzIjYwTzDZRP4Xf6gfeBUP4N4IYny4EVm29xyxXwkSqlR8rPi1A9h LWXBRus3m413MeRGwkJFKrJt61AL7o50vzbHnZjHJrAIiizDHnydjOyZQLUhyi0jEyRtOze3Z oEBbsFGcO5tJrNzQHQ/KNRMXhdC+uwOe1HIauf0Q03DS8nDbJmRyont6tD+6ivCgxSo4PQfN7 UKbynYhNYh6YLnjrTsNbXu/hIa86SnO/lhtREJhPjd02Gbzxjsdy53+1Dsyor6Uq0BYq509rq kayzOaxYwjhI36d8PyTKdON8seunsGfopviji13BP556y/hvU9IscHrzthEiSqRCRHZdSeEwa 7skGbTpyxm8h+BtxybHsd4RkAMXZJA+CH6kKFTXQLJhxPklkZnqsYov0VJtd7YL7jDxWahiyR 55jM8TLuLfczllgziMqlTSw2Jpg4dpBdAQyA3qhkToYej+IEZNNaqsY08YXTo6/WR6nysJxml 4TF5HecYdouFZOasT2WyWkdsmrpglPIGR1UOjPdKgmcUA= Message-ID-Hash: SB2TV6C45F74AIT3XWITSO3FBI2BOK72 X-Message-ID-Hash: SB2TV6C45F74AIT3XWITSO3FBI2BOK72 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: Samples are byte-sized in this mode, and thus the offset calculation needs no shifting. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_callback.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c index d36234b88fb4..2ed72bea1d8f 100644 --- a/sound/pci/emu10k1/emu10k1_callback.c +++ b/sound/pci/emu10k1/emu10k1_callback.c @@ -310,27 +310,29 @@ start_voice(struct snd_emux_voice *vp) { unsigned int temp; int ch; + bool w_16; u32 psst, dsl, map, ccca, vtarget; unsigned int addr, mapped_offset; struct snd_midi_channel *chan; struct snd_emu10k1 *hw; struct snd_emu10k1_memblk *emem; hw = vp->hw; ch = vp->ch; if (snd_BUG_ON(ch < 0)) return -EINVAL; chan = vp->chan; + w_16 = !(vp->reg.sample_mode & SNDRV_SFNT_SAMPLE_8BITS); emem = (struct snd_emu10k1_memblk *)vp->block; if (emem == NULL) return -EINVAL; emem->map_locked++; if (snd_emu10k1_memblk_map(hw, emem) < 0) { /* dev_err(hw->card->devK, "emu: cannot map!\n"); */ return -ENOMEM; } - mapped_offset = snd_emu10k1_memblk_offset(emem) >> 1; + mapped_offset = snd_emu10k1_memblk_offset(emem) >> w_16; vp->reg.start += mapped_offset; vp->reg.end += mapped_offset; vp->reg.loopstart += mapped_offset; @@ -371,7 +373,7 @@ start_voice(struct snd_emux_voice *vp) unsigned int shift = (vp->apitch - 0xe000) >> 10; ccca |= shift << 25; } - if (vp->reg.sample_mode & SNDRV_SFNT_SAMPLE_8BITS) + if (!w_16) ccca |= CCCA_8BITSELECT; vtarget = (unsigned int)vp->vtarget << 16; From patchwork Mon Apr 1 10:07:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 785942 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 B4A77CD1292 for ; Mon, 1 Apr 2024 12:23:00 +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 E286E22C8; Mon, 1 Apr 2024 14:22:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E286E22C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711974178; bh=sMxR7didSW4peuOKg2wIx7TiCvta31TNa0qLvs3bktk=; 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=CQo9uewg7EWW5bMIKUsBEijRdVvaEbWdOY4SNs1PGZm1ZUxVe1Oc8d9jecaCsHc+F 4BkCstM6smsSHoKXSo/yALbAlIhnIH9s0qs105CJdvEeHjcRAgEujkFpMW2BBjQQyf RJjSywWKzeDTJla9KNROv6Z4LhffSusi8/ET/9gk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 622D6F80608; Mon, 1 Apr 2024 14:21:52 +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 14556F80608; Mon, 1 Apr 2024 14:21:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 21E3FF805D4; Mon, 1 Apr 2024 14:21:44 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (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 D630DF80236 for ; Mon, 1 Apr 2024 14:21:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D630DF80236 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=QY7TiEwx DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711974087; x=1712578887; i=oswald.buddenhagen@gmx.de; bh=VC6vB3IHWNk+FHs+yPTuGSG9dzbiQj4ozp9KMsU8LGQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=QY7TiEwxc2iPHNWeyDTwOga7/1zFu1ZGUaxCSFmsDlBFr6IpuWio7MmRNxxmaPL2 PDZ6u2tln7kTxmky1mlsfMvXlj74BGw7ev7VYuQFMuQmfV51TT3nZr3Fk9ECNWl/9 GsP0MMyQLz4XN89rpEZnuGOyHQpdByZtbK1fo2GmlLulQhtLefTaQrIZ+EKE13AyK Oe4qKLTquD1b6GZ8OiiyQJObdiVlh4ZTZ/3bl04ap6hEeQGJRLdKpLe4DnIzpXeFB ndGdYiYHlo/xl1RGOP9iE5PdyRxUQKnCuas2aVn1wgP4vN+QGRmrfUSRXBjjHbVZK 6nYoKckbBXfZbvv9Xg== 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 1N3bWr-1sqU4K2pwR-010bOQ; Mon, 01 Apr 2024 14:21:27 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7ed-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 11/18] ALSA: emu10k1: make wavetable sample playback start position exact Date: Mon, 1 Apr 2024 12:07:35 +0200 Message-ID: <20240401100742.506001-12-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:2mwzfk61bk2+a3HrM9btjOsaYesGpukqwy42gIa8CEVbmYNQLGi dy9JsXHlnYB56+qKkpbEw0GpWLNC/tCO8weYJdV68ONEP4c7CYlVeDptibdoT75r3EtrVyp OpDum2N2R942EOn49hktN3kn72njYx0dCC35sa0KeVjjTjVh1adV3kmlkpdXmB8O77lE5V1 V6Nueqm5ttxW2+1IBJf4Q== UI-OutboundReport: notjunk:1;M01:P0:yTaERdMiZ1A=;Ch/VCJkl7v+Xd06+Ce/bXgOFmXs Y2GGfq5leJok53kuSdIE63amEYh/O1sxVVAO4UNnu5f4KPHahNrmV+le6xbmRLy/htx2+M/g4 4q8tR+9h0z/FKFVUixFUZFjPNEthsLmNYRwu2ctCVfEFR7N6tSBIBrF0ToDefXKCRHEqKUBVU wE+arl/V5CM80+SSMhwkFWeBSx2MBBIl9BeZ1GmUEIYWXBeM+9TkFFn1yL/TqLB7HFb1fQoJT kc0pQu8d8gDvow4q7Xj+wkVJdn0Qg7FzcwjFei0l7mR5Jk7KoRIi5OQT8RjD56HkG+WRL7vDx 9/VwDyn9vFRZOT0D+0P76r55/RoWA+5ZaBEunSTgPiX+wjehVBbGHxiFyCoqf+jYX2gA+LDZV LxZ7eul52Owa+cczy9bABxPlBIO8w5EMm8ykbLqQI33W1d58m/M3yni9t6r0+l2/WK7cSqkjp feqwCSainHm48QoYYLwoukPNfI11iWLufD7PiZs3gFFWstTOyJVa2k5VJFTeU/q53h8YP10Pf 38XwqPTUADJ+WyFrCf38V4xIVGav5TvsFeLnincyB8zz7lgxOxYmB7v1mMhFUgFDMj7fJEceS 5jxiIzQuKg4BmmBJ4psDhP1lY9v2b8287zq/hJlqYQuOH72Qs2FgZiX1H2o2a4oEmMFKOyYqo q1YyVrb6Wfo9xUMZSz8J2ZKTHuu9U+VGVGOO70I2HK715T+A0nJYHCjQ0f6XxsY2XCZckG/SX sQxgCzSb7LnrVDGK6oJEgjzyvIitlvy8EBVOwwSIv+ghVOaJcYYHE2cSS0Ig3DG5RQSTTwUZ9 TY3jsfqlc+IQVHv/qmenM7gbpQNZ+79gyp/XUM4ePUh1w= Message-ID-Hash: HFESYTFNA3KDHQBP3G5F5MTTG2OYG7SD X-Message-ID-Hash: HFESYTFNA3KDHQBP3G5F5MTTG2OYG7SD 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: This amends df335e9a8b (ALSA: emu10k1: fix synthesizer sample playback position and caching, 2023-05-18), because now I know that the samples are preceded by a blank block anyway, so we can just compensate for the interpolator read-ahead without any additional fiddling. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_callback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c index 2ed72bea1d8f..ef26e4d3e2a3 100644 --- a/sound/pci/emu10k1/emu10k1_callback.c +++ b/sound/pci/emu10k1/emu10k1_callback.c @@ -255,7 +255,7 @@ lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, /* check if sample is finished playing (non-looping only) */ if (bp != best + V_OFF && bp != best + V_FREE && (vp->reg.sample_mode & SNDRV_SFNT_SAMPLE_SINGLESHOT)) { - val = snd_emu10k1_ptr_read(hw, CCCA_CURRADDR, vp->ch) - 64; + val = snd_emu10k1_ptr_read(hw, CCCA_CURRADDR, vp->ch) - 64 + 3; if (val >= vp->reg.loopstart) bp = best + V_OFF; } @@ -364,7 +364,7 @@ start_voice(struct snd_emux_voice *vp) map = (hw->silent_page.addr << hw->address_mode) | (hw->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0); - addr = vp->reg.start + 64; + addr = vp->reg.start + 64 - 3; temp = vp->reg.parm.filterQ; ccca = (temp << 28) | addr; if (vp->apitch < 0xe400) From patchwork Mon Apr 1 10:07:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784848 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 75809CD1288 for ; Mon, 1 Apr 2024 12:23:53 +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 DAECB2392; Mon, 1 Apr 2024 14:23:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DAECB2392 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711974231; bh=i1MKyT8QO4wIu40gxuXDJvXDfvxGsy3bkylSqyBrOAs=; 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=S/+Tf9F+qxINwXF7Dt9DGWvAsuKwQCBQKnPCW4zRe5PYnxtT3Xst1cUtnM9+RlT1n RhVafetsaykHBynNAz5tt3+ZTaMZHy29y17XSeHKD9uZv0EcsBCiC9W168Jpy/0bTk gA7S6bf4sMzQE+E/00V6sIKSDrYaR/tT9fWqyWvk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id DA2E7F8069A; Mon, 1 Apr 2024 14:22:00 +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 5A57AF80698; Mon, 1 Apr 2024 14:22:00 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 88091F805F4; Mon, 1 Apr 2024 14:21:49 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (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 B179FF8016E for ; Mon, 1 Apr 2024 14:21:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B179FF8016E 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=FXRMH7v9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711974089; x=1712578889; i=oswald.buddenhagen@gmx.de; bh=yMNH/+4MdRULa5SQu4CR7W2OySNlVuYrctHNpEh3LHE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=FXRMH7v9JUcpUi37qnLz1YKk6dRVDG1voJegIbxGXxKPAm1ZPnEOcVjsyAWgQf1t J0Vryawmh3jT28Z7vtnO4nL+J8Ul07F43/M+JGHAGsbrZ0O/LGkMVX8o2YI8IIi2l xesIfcaH91VN9ujPMxTwBfMeuReYBiEMpid1qNk2TnhEabMMnAd3hEDEtN39eFTcX r+I/rUig8vuZM5xn0A5kbdBCkCdVDkDhCgVdqzWZ8HjeL2fIpZ6j/StZ04hGHILPC PqJrAd8BIoN63N3oITTkid4e+afDdMh2263nJVnrP5BbzTvAMbcXQjbzW2vsbs5Lm elV7QkTYn//NQbMKNA== 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 1MHG8g-1s4RxZ1c2a-00DKUn; Mon, 01 Apr 2024 14:21:29 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7ei-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 12/18] ALSA: emu10k1: shrink blank space in front of wavetable samples Date: Mon, 1 Apr 2024 12:07:36 +0200 Message-ID: <20240401100742.506001-13-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:3jjOhjoZdXKDdMZCp/anVt6oJaQG32lf4dayvytu92ct20UGLdD RhN87uICWLrvPWzcRd1jPyiN3qpqRwPzA5SW01golfFsBglSp9oa+xQYB809OcOLxnx0GwY x/xQJH3mzLUoR1+yfrUOjiOxCg49Q3hgbVaMD8Fq29wpsFwtSAya0lFeuUfHmpZpfwyGLYh tno/K2m1W6S6UgFJcpB2A== UI-OutboundReport: notjunk:1;M01:P0:qSNe2GTVKUU=;FWSI5E3php6opP6cXAoF/GgLs6C a+/gsjmB53eGX0xP3NHIwgu9KCg6vj4gNxhUyfzA+XnjAxf5m+JC5dBakgLAn49MP4Qi0w2md VZhi55sgoBfeH/r4lXT4tFb0GE3OpHUW1gcL9SbQPB1HZsbK56rFiaLAl1IL7jSIuzNYMvtx3 lGAAVgd1ChHt7cC7WUTT9DA71VON7PBWMEmEmhEcJdAcGYFBrYvbWVBPOkKitCfdkjFFsJSdC NNEt7+RU11LcGYB90lmp2lAG2Qkz6eZ0W2HeeNf6tCoJbpqx3rPn6HM0gELu8ARmthG2jPclg y0Zcj2eusQ1c1pYAst384F7DTMkvGm9vL5M04JD0zULs39p7jCRAb6jiseG9qgU5G9nmRUh88 C6XwSngbPRrZ0OiqBDPGAA/dCYm0uPcqL2XWF9XRtLSnKMdKpLXVisyc/gItD5twcu6JuO5aq Xmm8QYqK5onHnui57bFGHp9Upz2TWsjBsnaJps4vL57VB5Pv3QPNUgD6G0Sz4TjFoh87hsB64 jPnqVlhggfeDYi49/9hxEzur3WU4NVFV6l/Uun8+Cibx1eXS9i6qClNKSZ4m0yROMVgxpGByS XBc5CvCXVnARzEKqzOx/2fM/Hm5hXI0Dd5pdA/Dc6g070iXwuSgYMmATG0q7mVSojYWhlAZyi 9ol9wkdt7jmD2EIGDzpFx6YLWdu2/fT6nI0u5CHl1Uc0kTksfYBuh4HN3qc6l3eNU5vP8w4iC GOxnA8QJCayh0MiuiK18wSU72Td9Bjs/fqFLuNA2F0oyOsF3J7fOuWvnmc1ta40R9XezLgQSR cpWzfI5fQy8Ik/p/GzqQdhRcrTvVapE2VGAeq0eJfYaIk= Message-ID-Hash: 4QLD2P7OV2NBTCE5K2PDZ5PVCDL76KSA X-Message-ID-Hash: 4QLD2P7OV2NBTCE5K2PDZ5PVCDL76KSA 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: There is no need for it to be 32 samples - 3 will do just fine (which is the interpolator's epsilon). The old size was presumably meant to compensate for the cache's presence, but we're now handling that properly. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index eb3d1ef8a33a..a2ba6246dbc7 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -16,7 +16,7 @@ #define BLANK_LOOP_START 4 #define BLANK_LOOP_END 8 #define BLANK_LOOP_SIZE 12 -#define BLANK_HEAD_SIZE 32 +#define BLANK_HEAD_SIZE 3 /* * allocate a sample block and copy data from userspace From patchwork Mon Apr 1 10:07:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 785941 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 C9D04CD1292 for ; Mon, 1 Apr 2024 12:23:41 +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 D5CD72390; Mon, 1 Apr 2024 14:23:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D5CD72390 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711974219; bh=lF1BBIluGxrDjhQOQ3oCHejcgQ7bQW4CJ1hx/bEh7ro=; 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=paXFqCArceegT3jKxqK8xTC1yvKmyY7bdbQQ8kV8mK6NC5NfQrLMO8IADxZ+HC5oC H10GJ4BrFsLwcaPZGe3US1WKXoBPcVhMBQLS2Ro/3kVw2vta3TUdTlMF7m7IfB2SjS nu3L9VocLOAopMobvn1O7IG1ii8srn0jOBo8nSK4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B0AE8F8067E; Mon, 1 Apr 2024 14:21:57 +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 83964F80673; Mon, 1 Apr 2024 14:21:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EC650F805EB; Mon, 1 Apr 2024 14:21:46 +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 F18CCF80238 for ; Mon, 1 Apr 2024 14:21:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F18CCF80238 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=eajH5Cr1 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=lIxFNvaFLMZ4Wu3nEyl/CSG1r9On5GGz5QAPXFujn64=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=eajH5Cr1SrqdXw3Fu9EJA2S2AZt7youyP91e4d9PV0jvQl30tCMi0qcFQggpk7h9 /mCj9YJwj+bixH/WI3yD6+fEdRGUVlmKy6FKGwZjrG2FnlxmMrA+GTrMbQjgRdBIk f9zXrcTwZKuJRnKmyGtPdictiE6nfID2ItQFMlyGtCqs96B3oCeAhR4qP/lWsTEjZ dFHDF3Jx3/serQZbP0vKagyY0lRKucX+MJxcjT9kR6EPScbWbEhK6ZVGgIRC6UyNm vToo16wqGPEAHp1ELUgxlN032HYe9JvWdCGQyI2Wt0qY/0NtHlNKFHhuMIgqiZjmZ qq3WX090cAhf1/gSYA== 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 1MkHQh-1sXB451nar-00kiQu; Mon, 01 Apr 2024 14:21:28 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7en-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 13/18] ALSA: emu10k1: merge conditions in patch loader Date: Mon, 1 Apr 2024 12:07:37 +0200 Message-ID: <20240401100742.506001-14-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:L/zRDdry4zhkaDjB4nGt8K5rDJCZOctdxN78+SSdRmS7RRsumlL TrovMcsLwZy1n75T4hdxm96EDlqa43lcuH0QlPGk8i/FHmD4TZb6B4+JK21T1KXSYmnvaDz fz1xg40hRIc7xD/tY75vaCOnZbMPWH9n1w/boFNaawCHkF7H/Myc3HrZJfoJ1RC39gcCQf+ xGlxc18aps2m+RDzhzEiw== UI-OutboundReport: notjunk:1;M01:P0:dgrhDZwhw+4=;4czIy96roT6fRlBYa4AX+tHNjrz d/rmH+0+7BS/YcxIu6YpZxvJwfJVK51muo5WNdvgOyza6UTCce26+70bujDzO4+nYU9hpvOWL 2mgLWl8GScDRpRGUc6A/56EAT4gtElRwvM5s4+wB7r5TDhzCk0xctRSTXemUqwVC7qu4Y0YXC p1aQL7QyH8hvFXIrbTzeX9C5HeULdUxVA/RgIym+mgZtHzUxdMWvd9sZ0Shh3SVpm95jkq5a5 G62/kzHopeyR9pz+wm/4alByJOkfPVLLXrGa4463UfXZ0YD7z5EiMer5/fvlZd98aRs7n4H5m ucHlOPappJVxfg0T1m/7/6Ot7+ii0NyrbUIPUKVgwWcNRKG4fyaAiOupGF4vd5mEgVC21O+fw nLKQK7vOoag1JXKx/ah72jn8MrHp5n+r1miS+V/YD5Jfx2IagG7/1gJkuN/aJ98y9Vx2RXu60 QfGECQ4IdoBBTDe/q8Me1sKjpeWEyjE+Y1EcpQDXD1kvNjtNd81dLStwT50AjUCY4LTKffoDk vm5SK0VHFtqoix/teikgchvZwkOTpK//iXqLMU6PN4BqLmRjxRNbsyjhhHtbYHhim7rTQotot BsXwwZ+tWLCqFhXf1tAh7JEBHJoI/rlgPGfOIsMz/5S0uxrYv8bwcwHMnzf6WDa6NLzldFXye c19VAZ7XMPiC3yGKMeDU5z3Kndr99ZdskowJjU7rlMCTnTt0PMUmpZbKd6QEx1dgxmQ9836gF NL6tGkgizLetEhdB5bZrJTBqruEYFnulTZfYNYhUkDbWQMMlVhA8uy1pm6cS7SEY10iNidKpE SDd3C2g6j1LTJoAX1pBj5SRl8u45zesIBJ65tCj9benCU= Message-ID-Hash: LIPZGUD4GK6A5WMKWRCP54DJZCXB7UWY X-Message-ID-Hash: LIPZGUD4GK6A5WMKWRCP54DJZCXB7UWY 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: This de-duplicates the code slightly. But the real reason is that it moves the code up, which the next patch will depend on. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_patch.c | 16 +++++++--------- 1 file changed, 7 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 a2ba6246dbc7..c7d54f38d28c 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -53,8 +53,14 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, /* compute true data size to be loaded */ truesize = sp->v.size + BLANK_HEAD_SIZE; - if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_NO_BLANK) + if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_NO_BLANK) { truesize += BLANK_LOOP_SIZE; + /* if no blank loop is attached in the sample, add it */ + if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_SINGLESHOT) { + sp->v.loopstart = sp->v.end + BLANK_LOOP_START; + sp->v.loopend = sp->v.end + BLANK_LOOP_END; + } + } /* try to allocate a memory block */ blocksize = truesize; @@ -93,14 +99,6 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, if (offset < blocksize) snd_emu10k1_synth_memset(emu, sp->block, offset, blocksize - offset, fill); - if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_NO_BLANK) { - /* if no blank loop is attached in the sample, add it */ - if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_SINGLESHOT) { - sp->v.loopstart = sp->v.end + BLANK_LOOP_START; - sp->v.loopend = sp->v.end + BLANK_LOOP_END; - } - } - /* recalculate offset */ start_addr = BLANK_HEAD_SIZE * 2; if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) From patchwork Mon Apr 1 10:07:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 785940 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 890F2CD1292 for ; Mon, 1 Apr 2024 12:24:15 +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 BFDA721B6; Mon, 1 Apr 2024 14:24:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BFDA721B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711974253; bh=phG6hMmRktyZLOVg+7TkRrTGOtgfboaALXpa6eHwtgA=; 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=h4lNkBVwULlLCdNCVtSGYWA6BCdTr1jznSxGVsa1x/KigFNGZGOgTzTF4K+6mLH4p wkioS2TW5gvoaBmvtk5Cnk7VVj8WtKo/QqZKM3uGNdCTtnHK2oC3Ieq3NiXFXLehJF 5VatSX5GRdW6vPcMbdrGm39qk2X6aTRn3fYH2K/Q= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E14EEF806BC; Mon, 1 Apr 2024 14:22:04 +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 CBDDAF806B5; Mon, 1 Apr 2024 14:22:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4C382F80600; Mon, 1 Apr 2024 14:21:50 +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 7BBE4F8020D for ; Mon, 1 Apr 2024 14:21:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7BBE4F8020D 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=KLaQQqpM DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711974089; x=1712578889; i=oswald.buddenhagen@gmx.de; bh=N+qXgc++moh3UpHq5GwB2BTSLu0+WsnSqCyKOAQ55qo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=KLaQQqpMsUovezNFfGeSmBZD5Ryv08zAsj8A43GQf7a51NNon/7JDaLuOFlHjUGF ojDu0+693t3xkyPzEWGF30GVq32GR4AANlfSzKlpBSa2qLih9frP8UBRVaIO9XueP aNhwIhJOA0eA27SB1bz5W0LUQpsoggn/1HPM07sn5OE9zCfqHqX085JPHDJ3rhsma DpqP1W6bAkFJ2sk3CwfoXATC1S/QQgtmVgVh8L8XC8Kw42j02fBrupJBHQjUN5it5 NxZ/rZ2GZYYtT1xpRO4CmEV8TrqgDCeB73ATD+z4Ph9dCj8KpSIoqiFnA+Ywfg6Ds DWeqG2PNE162O0yMIA== 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 1MuDc7-1shAvc2ax3-00uW3c; Mon, 01 Apr 2024 14:21:29 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7es-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 14/18] ALSA: emu10k1: fix wavetable offset recalculation Date: Mon, 1 Apr 2024 12:07:38 +0200 Message-ID: <20240401100742.506001-15-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:vLAQrOFl91Ipf440/++p9ydbBTkY78S6rLq1k8tFo5Ek9gm//fz XueAgalC2Pyo6mxUjTvlSTZNn6Cv0oyPB1JV/NXQg1BrvToQxBDI1wQmWWTy+PgV4ANDoMZ q4H1+SgBPbJxzIvdS86JY5eVGQYi9eGS4PvulZ0VINj9RLR/CE0IgIs40v9lcoB3o1PKzwX 6/PcmxBhCcGTkSx7VBpow== UI-OutboundReport: notjunk:1;M01:P0:1ti4O3dzWdM=;UkX4ogIwi6PZ7meNhGNVeosZ5YN FHB1/NV1n5i4+B5DmKl8FVacqL9OdbXMlf7tLv46fcWGh5NxTQN4o0SIvtg+LafL+T0Hn/Dl1 3Pz5o/+6JwW2NH2ZyMBNeZvmDj+OhZsrzyAWHLeTivX7oC2DDzUX4PTcLfQCBUDnseD6sdYcp eiZ6AnIflRWzlCa9jFWKR9xOyi5wdK9FSV/b4BG3T2KSlaW0iSnhdQ7Uzka0uyMB4p2OQ3STt f3bLnLndOcKKa2l41JR6ixWPMBJdjI2sbIDSzGtyNQmKT88DNsyt8vHQMG/Phm49GymWgflmb n0WwwDKL4wp5VNL+QzcD1ooB1FpXch3aOs2AhtSw+8D5y/DZn3Evs0KACnhz/NlfzuoZzbXw/ FJXm7DtsEWk2H/8mHiFfQvaich9iLsbZPJFN0nRKYNCu7cgxxkwgVYKNDhGQ4V5fzs//s9POd CQu6PYmR2xpmxGyPf02oBPy9R1yhgKYyxpthwQIsONlJbo1fs+KJ05e/rsxY3RojDl2Mz6MeZ ZB1eLwzXrGta8kj5gxfwIigDJgk9+0MvJ/FNA0gGm4LPsjgjTfa0l2o7l4x+4ke80N08nqTYf B3YjHbjdg/WXECTng0WI3wDg8RtE/bpeb7hTBJNuPaoepCw1wU/qtq4lD5ad/ooX028rm8lQh wokaxhGnyQdPO5uoFoAtA3Bzdy7CDJWfJHtde19UIkPd1k8TH4S8+8sx9UPEXU3ZSHEdC8ON+ 9EEZDlrhn/N4nxNwdkZbVUwQdwqV9FI/RORUnEmDuUiCaShdwCSW46X4jkvhKfVK7xekfZdeM 5p/f2KVkQZzevtOhGB2GqlPbcTYiBiAyOrD0T9V5KuF7o= Message-ID-Hash: PKDD2T5OB75NBJOCNDHJE7FCZLZ6Z4NL X-Message-ID-Hash: PKDD2T5OB75NBJOCNDHJE7FCZLZ6Z4NL 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: The offsets are counted in samples, not in bytes. While the code block is being rewritten, also move it up a bit, to avoid churn in a subsequent patch. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_patch.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index c7d54f38d28c..eb8365650bd4 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -30,7 +30,6 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, u32 xor; int offset; int truesize, size, blocksize; - unsigned int start_addr; struct snd_emu10k1 *emu; emu = rec->hw; @@ -62,6 +61,12 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, } } + /* recalculate offset */ + sp->v.start += BLANK_HEAD_SIZE; + sp->v.end += BLANK_HEAD_SIZE; + sp->v.loopstart += BLANK_HEAD_SIZE; + sp->v.loopend += BLANK_HEAD_SIZE; + /* try to allocate a memory block */ blocksize = truesize; if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) @@ -99,15 +104,6 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, if (offset < blocksize) snd_emu10k1_synth_memset(emu, sp->block, offset, blocksize - offset, fill); - /* recalculate offset */ - start_addr = BLANK_HEAD_SIZE * 2; - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) - start_addr >>= 1; - sp->v.start += start_addr; - sp->v.end += start_addr; - sp->v.loopstart += start_addr; - sp->v.loopend += start_addr; - return 0; } 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; From patchwork Mon Apr 1 10:07:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784851 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 31777CD1292 for ; Mon, 1 Apr 2024 12:22:14 +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 260C7233F; Mon, 1 Apr 2024 14:22:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 260C7233F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711974132; bh=/6bHgOjJBJyV98vE/wprMwW6DUyEX0wYBugNwx5yRmA=; 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=mAaU2/snabooAYhW43ZRD0WW/LfU6cmK+trv2At9vu5ZUJHW095LoWbJuDrINc9cn ggNC1o+WChy1WwaofWNl8v1HBsn3oTZLEBrTTx8IKcsMP5eD2INFFPiI120sUa2Gbr yqIOtE1eB4WGoHn2m4GgLHOYYlRmixHOHZI+rx0g= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 05B6DF805BB; Mon, 1 Apr 2024 14:21:39 +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 A0FF5F805B2; Mon, 1 Apr 2024 14:21:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6C040F8056F; Mon, 1 Apr 2024 14:21:35 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (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 03265F8016E for ; Mon, 1 Apr 2024 14:21:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 03265F8016E 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=jZhKQ8iY 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=QbpXbcE+ZR9RSM7KyHuCqE1u/L252UQLp182kXonEls=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=jZhKQ8iYcgndnOMQRqK5GKKjbqg9B8qZpBe3rX2e3MbckIj9z6/nIw+lS0HH/sqC C7YGIaMMPXl+5lKbVtA0a6aaCvSnw8c9cYFMid6xFazcVKWVdwJ+v75aR/6sRFQzi pasKwNR+Mfhw/rvlbPRNZESt9QBJr1fZuWqIuCIXpE1/zfQNkKU08SvGFlHXA0hqI xvhRHu8ThP9HEgbjUu+GZLXHDslB8TLbADVMYApt3Jz+iEBnfXbcb/lsBAFlk/7J9 rfm/K+zvrIeGjQh9+/OmT5o6avTj1H5mS4fGBqP40EkgoTctv1EkyAGq4cLlJo92i uT9e+4LemWRFfe2Rpw== 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 1MDhlV-1s0qv23tI7-00AqBW; Mon, 01 Apr 2024 14:21:28 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7f2-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 16/18] ALSA: emu10k1: improve cache behavior documentation Date: Mon, 1 Apr 2024 12:07:40 +0200 Message-ID: <20240401100742.506001-17-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:LcO2aHQ3NFprCOFU7uoh57T1ky1K3X/E1yL5oommICcvANdg4LN G+5pXjjKo+SCt8YCbOb4psR8Ars2JIi8nQ933Qb1l3gMrmBxpw5I/7HXKiGzeScS5pxURXi plLLg38DAU3R0Mxw0GCYg3OX7si7bO1zCvxfJCHrNO4LVXrglFBzzJvNK+Gb37U09hiDreD NTbpZBVz2sFl13NMW7jTg== UI-OutboundReport: notjunk:1;M01:P0:ci4kz/pjyIs=;4kp+df/TufPnJrV6yigLfX0oEnq K/5zdN701ZNFDRbAuMsZF4tjg8VDyQMOdn8B6ms7EdPaaqp9nD6VLSsA15mGhcpy66+CDPF4c dCgMXq8hh919qU2fZjtm7MSCmrELd8282gy3DVnT12XQYh+75y2BJIiDBMSXVnn/C1mGOyv3Y arffGYJ997yJriMFVRlEm+dM/aMlNXK4LmQIaA/Wf2YAfGKvLFEb3Lld4VJj1qqojeP2cFdUD SKInK4mZ5rJUPlcaq47SFnqpCh85hgp0ui/i76EXiJOqmMncM6yYIBwlgTX+KgZrG2J/Fhxmw o4OzHNKJwkZDuZwDqaXuc7EhfE5nl9TqqxPQBa/z7dzwT8ZPuviXz4i8YQ5mvqs3MFsC/2CIl Ht851YCUu/DRNaY4BrgwKsq/smZ3RbJKPjvRQeGIuid3H0HHO8MhzaszqCrEJ43tRab0+THzZ uGjJO+iAGeB+LkzbY/SxHTBAJDWdL/v71klMtGoVKs941/Y6C1OJUjCunr9hG2s7ok5VQqSv8 z4XPLB3s1eUehcoVuXwOhmR8AHNSZeJlExmG/KRFe5+eD69h8Xx99l9wLoWuJvv9S5qjMyBqe kZyNYPoAwIj1T6g6WWvxP+fgLM7whTLzc/zZ5LF9JyzVwONazGLpYqqFVagZlhO5CSTreLbco 9fWyIvzQSed0Y2eEpvytXIp/yK3DZnBRVT5dk9u97SG1q+ddKkm82C78JU8ZeIU/1smFhfW92 +qw4UuXEWcQ2TjGTJQaKgpmKSwvUAdd9+B0q35zonAeuFVUTpC32tHXYry1DSgA5DzXpQ25tF 6VKUrdxipWDIlk/TclswHJU45oO/1ch1xG6zGwEBJDf98= Message-ID-Hash: CFPB2DMMBKY4TZ7P6JNKB5H2UPS7DQYI X-Message-ID-Hash: CFPB2DMMBKY4TZ7P6JNKB5H2UPS7DQYI 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: Resulting from more reverse engineering in the course of debugging. Signed-off-by: Oswald Buddenhagen --- include/sound/emu10k1.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 9e3bd4f81460..12c7dc760724 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -598,17 +598,25 @@ SUB_REG(PEFE, FILTERAMOUNT, 0x000000ff) /* Filter envlope amount */ // In stereo mode, the two channels' caches are concatenated into one, // and hold the interleaved frames. // The cache holds 64 frames, so the upper half is not used in 8-bit mode. -// All registers mentioned below count in frames. -// The cache is a ring buffer; CCR_READADDRESS operates modulo 64. -// The cache is filled from (CCCA_CURRADDR - CCR_CACHEINVALIDSIZE) -// into (CCR_READADDRESS - CCR_CACHEINVALIDSIZE). +// All registers mentioned below count in frames. Shortcuts: +// CA = CCCA_CURRADDR, CRA = CCR_READADDRESS, +// CLA = CCR_CACHELOOPADDRHI:CLP_CACHELOOPADDR, +// CIS = CCR_CACHEINVALIDSIZE, LIS = CCR_LOOPINVALSIZE, +// CLF = CCR_CACHELOOPFLAG, LF = CCR_LOOPFLAG +// The cache is a ring buffer; CRA operates modulo 64. +// The cache is filled from (CA - CIS) into (CRA - CIS). // The engine has a fetch threshold of 32 bytes, so it tries to keep -// CCR_CACHEINVALIDSIZE below 8 (16-bit stereo), 16 (16-bit mono, -// 8-bit stereo), or 32 (8-bit mono). The actual transfers are pretty -// unpredictable, especially if several voices are running. -// Frames are consumed at CCR_READADDRESS, which is incremented afterwards, -// along with CCCA_CURRADDR and CCR_CACHEINVALIDSIZE. This implies that the -// actual playback position always lags CCCA_CURRADDR by exactly 64 frames. +// CIS below 8 (16-bit stereo), 16 (16-bit mono, 8-bit stereo), or +// 32 (8-bit mono). The actual transfers are pretty unpredictable, +// especially if several voices are running. +// Frames are consumed at CRA, which is incremented afterwards, +// along with CA and CIS. This implies that the actual playback +// position always lags CA by exactly 64 frames. +// When CA reaches DSL_LOOPENDADDR, LF is set for one frame's time. +// LF's rising edge causes the current values of CA and CIS to be +// copied into CLA and LIS, resp., and CLF to be set. +// If CLF is set, the first LIS of the CIS frames are instead +// filled from (CLA - LIS), and CLF is subsequently reset. #define CD0 0x20 /* Cache data registers 0 .. 0x1f */ #define PTB 0x40 /* Page table base register */ From patchwork Mon Apr 1 10:07:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 785943 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 6DCE2CD1292 for ; Mon, 1 Apr 2024 12:22:26 +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 8210F22A7; Mon, 1 Apr 2024 14:22:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8210F22A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711974144; bh=p8VmdSIv36jVt1+XfF+1230eiSuQYLGhBqA4Dda0Zts=; 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=a5znKBDKnQ6f3LFra912yqNeMcFSi3soWSVGMYF/lA1P6WtIljfIGd7SfI+vajJmI NV4Bhysa5Xr/rp4UAs59Z0WU3SAUBL6wCdpcDz/p5dKEx9ffrVrpyS270AWfqZoa94 IUzmQFb0RUuixj6u0dRTYta3/ZJVylhhXidF0YnI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F32F6F805CA; Mon, 1 Apr 2024 14:21:44 +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 856E6F805CA; Mon, 1 Apr 2024 14:21:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F2D52F805A9; Mon, 1 Apr 2024 14:21:39 +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 3C0EDF80130 for ; Mon, 1 Apr 2024 14:21:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3C0EDF80130 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=DxUnoiMP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711974087; x=1712578887; i=oswald.buddenhagen@gmx.de; bh=E1WN3O0eUQEwMp/eD3Qkah51/EPsPD29CUxxCxLVB1M=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=DxUnoiMPokkLBXoPYaEIRbop4kksKtBblTeu820kgP2Azn6+jfrdKRvNtLS8Uhni rO7DQicPbq4CtNun4M86f+a5eJOFy4RGlQv8sfV+IFouXY5YDeSOkZJnS4SMdFlGQ OMX/K4oo5u6SABwNKCDTNnHYQqHJUVtE0Sc15FnqvAVnxorrlTjYxFRbpPaGx3y9c OGPveoqd7GiDof4x9B7S1tcOLnSIgnaPODp9TnvWuvI8ySdUuU7ZN9GSt3n8S2XeA Ip5w4QJYlDoFOQBm8MZ7rWF9pP8uYO2lILrcSEJS+dmYdJ1sgVkP4yBpkFG/VVYmF HEuNSBUZ8AJamJ+1Vg== 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 1MkYXs-1sXReL1sn0-00m5kB; Mon, 01 Apr 2024 14:21:27 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7f7-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 17/18] ALSA: emu10k1: fix playback of short wavetable samples Date: Mon, 1 Apr 2024 12:07:41 +0200 Message-ID: <20240401100742.506001-18-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:wsylWHzTkGnzHdAfoNc3djnONHlB7kuKB2dB3Z6YZWW8I/jCxGi E2d5e1YUm8I8T+D++gCpBH4WMCmyhx+GMq2VVvwbFr1wfTgrEKeLFkDZH3dHXkTpZgnN1Qy xkZ1oUIJzkskmKCtZVEIOYY/hYmmZwKJU4yFDwJfyBHXZ2YMCWKZFhYNv27UmaEUAFtQuR9 oUqdsOA+ps0oNIHxwV/Sw== UI-OutboundReport: notjunk:1;M01:P0:fX2A6gU7Zus=;aW6K/avbk5PVSZRjBp8/PIQCHSR sY3jTr15WSlh5teNQ3EfZUuaYh4t0TIvBYXbnKpps0plXLvObDz5QWOXIlM+XY5KjtFuFy0ud +H4ZgniSKfEG0Eq/y1NdA8ohjd7FQ4UlcurOh1GhF0aCR4tcHvCt1/dPSAg84Qgito27zLX9p C2t94bTAs5BNEXACKXcP+ZImBf1YirP9BavbxLs7rTs9qo8491RO7eFAy2cG5+JUvQ62dK8BX 2er6/m1KlKReMDEd1b1b6N7GEImy661UsCR0ljO2/vNCKZKqlvWRIJEhJlZQt1Un/7ZTCqmF6 5am5LPfu1y7bFhWIVYuJLs88DGHc4tfbzLak/VPI8gYItHf+yJ6+uffzHLgtIHQu6lq3xs2vv oTOckk2cdsRv7nX0Us44yCMqEeu1bVzi8ReVuqBJNp3FTa1ou6X4lsBxvCr5KeiMqCrz5yr83 kXMOX2Jwg+dwr1U90srpJrhgMifzh3pqHL3tUvB6qcYewe6pSznlRQ5pGsF1ohNKMAK3VSalx 7vNo9mvbBZ6XxjCsWzPSiZKS22m9zYCVIeatZJ9vfGS8s5pP267h+8btwxlYffdJf0S+UYJBA GKi9mtcpZyyHoteXE9hO2u4U3pK2Deg6dW6xl2wyP32OwNHfmZj7zPxCmspWOU8z9MBhmtZoG LGgocHNKYfnh8quTBkzuoKOxQPWjndgPRYbJK4uHqFY5Cp4aqMsRL2x+DFebdxw0lWcpkley3 lKZHUhWB3JycHNDNQIXgiZCTKjkkOgmbjhFd7sgfKKGhMEmuFpIDtL+06MY/176kMdCl4Tvrh ivPRVdFAC4wFUv8SG3A7i7jaP5TT/8I87wsk3O6oBEeY4= Message-ID-Hash: ZFJMFHCMGRR6UT6A5BHM67UJCEVUMSID X-Message-ID-Hash: ZFJMFHCMGRR6UT6A5BHM67UJCEVUMSID 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: As already anticipated in the linked commit, playback was broken for very short samples. That's because we'd set the current position beyond the end of the loop, so while the start would now be correct (due to the cache lag), we'd run off the end of the sample and play garbage. Fixing the playback position itself wouldn't be that hard (just modulo it), but this wouldn't address pre-filling the cache with the right data. We could pre-fill the cache manually, but that's slow, requires additional code for each sample width, and is made even more complex by the driver's virtual address space having no contiguous mapping for the CPU. We could have the engine fill the cache piece-wise (which is really what happens when playback is running), but that would also be complex, and we'd need to wait for the engine to handle each piece, so it wouldn't be that much faster than the manual fill. For the case of requiring only one loop iteration prior to reaching the cache size, one could leverage the engine's looping mechanism around CCR_CACHELOOPFLAG, but this special case doesn't seem worth the complexity. So we just unroll the loop as far as necessary to be able to play back the sample without any fiddling. Pedantically, this would be incorrect for loop-until-release samples with a low loop end which are released very quickly, but that would be relatively harmless, is not a plausible use case in the first place, and SoundFont sample mode 3 isn't actually implemented anyway (it's conflated with mode 1, infinite looping). Fixes: df335e9a8b (ALSA: emu10k1: fix synthesizer sample playback position and caching, 2023-05-18) Link: https://bugzilla.kernel.org/show_bug.cgi?id=218625 Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_patch.c | 53 ++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 5 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index 699aa0fec97b..dbfa89435ac2 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -31,6 +31,7 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, int shift; int offset; int truesize, size, blocksize; + int loop_start, loop_end, loop_size, data_end, unroll; struct snd_emu10k1 *emu; emu = rec->hw; @@ -64,12 +65,35 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, } } + loop_start = sp->v.loopstart; + loop_end = sp->v.loopend; + loop_size = loop_end - loop_start; + if (!loop_size) + return -EINVAL; + data_end = sp->v.end; + /* recalculate offset */ sp->v.start += BLANK_HEAD_SIZE; sp->v.end += BLANK_HEAD_SIZE; sp->v.loopstart += BLANK_HEAD_SIZE; sp->v.loopend += BLANK_HEAD_SIZE; + // Automatic pre-filling of the cache does not work in the presence + // of loops (*), and we don't want to fill it manually, as that is + // fiddly and slow. So we unroll the loop until the loop end is + // beyond the cache size. + // (*) Strictly speaking, a single iteration is supported (that's + // how it works when the playback engine runs), but handling this + // special case is not worth it. + unroll = 0; + while (sp->v.loopend < 64) { + truesize += loop_size; + sp->v.loopstart += loop_size; + sp->v.loopend += loop_size; + sp->v.end += loop_size; + unroll++; + } + /* try to allocate a memory block */ blocksize = truesize << shift; sp->block = snd_emu10k1_synth_alloc(emu, blocksize); @@ -89,19 +113,38 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, offset += size; /* copy provided samples */ - 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; - return -EFAULT; + if (unroll && loop_end <= data_end) { + size = loop_end << shift; + if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size, xor)) + goto faulty; + offset += size; + + data += loop_start << shift; + while (--unroll > 0) { + size = loop_size << shift; + if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size, xor)) + goto faulty; + offset += size; + } + + size = (data_end - loop_start) << shift; + } else { + size = data_end << shift; } + if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size, xor)) + goto faulty; offset += size; /* clear rest of samples (if any) */ if (offset < blocksize) snd_emu10k1_synth_memset(emu, sp->block, offset, blocksize - offset, fill); return 0; + +faulty: + snd_emu10k1_synth_free(emu, sp->block); + sp->block = NULL; + return -EFAULT; } /* From patchwork Mon Apr 1 10:07:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 784847 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 5E8A2CD1292 for ; Mon, 1 Apr 2024 12:24:26 +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 C635023D3; Mon, 1 Apr 2024 14:24:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C635023D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1711974264; bh=rPXQPugvGLGgdzjUfMrFaept3p4iWG4Qqh732gVllDY=; 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=W0kb8z7yliaYpw0eV+p++ZclkcncnFHAJPF1amMVWZPfU7RMIgX077O8TwlSHH/jd b1bD4ojapmKCem/85XFdrhPX2A3XMIgDmNJiBQu2UynWEy+VafUnYtsrbpXvfRe3nB 4Gn6VUyiWRLZM4lHuhOnAYnyqu4E0RZCN24jkBoc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3FBDF806D5; Mon, 1 Apr 2024 14:22:07 +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 D7EC5F806E5; Mon, 1 Apr 2024 14:22:06 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C15B8F8067C; Mon, 1 Apr 2024 14:21:56 +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 CA067F80568 for ; Mon, 1 Apr 2024 14:21:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CA067F80568 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=M0sdZ9lm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1711974090; x=1712578890; i=oswald.buddenhagen@gmx.de; bh=MUOivZ7Cu3IgAolz222zrK5VXW8zypYQVAP8txCHrVw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=M0sdZ9lmjafUWsI2P6vNPlTL+eJuhyp5jUhDug/SanDSqcDsDJe7ffU94WLWDj9l GuKAymJNjFoyi0Gf1K20fphpqZ4mHe3j1piRphiKZGVa6nVcTMIP03rQuzXHhIQwe HOtTqEKu6GBb2nZRnp+LsZ0ogXqdvG0aB3tZpDtHxeuy9mwiuR6oM6sx3F13UXgem RuvN3RyjSO3gJaCIDYthzrpQoCbajSMuic8Py/GwGPYvvjIXQvI2rI2ZTVF0xonHO KtAHEikBri0ucj/V/wxgLUE5aXtKUPz2sqGxLax4kQI26VvzRIFk3YXJisgTDHmtu APWHKnQ8m9z8w+t3Sg== 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 1Msq2E-1sfnsn4Bqa-00t8Tt; Mon, 01 Apr 2024 14:21:30 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rrEZq-7fC-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 18/18] ALSA: emux: simplify snd_sf_list.callback handling Date: Mon, 1 Apr 2024 12:07:42 +0200 Message-ID: <20240401100742.506001-19-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:slklNzdey/ZFPGtbkyCUgvuevz4tcJOgxwjYU5XPHlwfnYXD8+4 y8ECjX8TIVvngrainvO+iTouSNSJ/MUfvuggn4UD4ZcfCqZ5v+LfMV5oejPVume2kewUTOS wYn6lEhShMPSPQ2IupRonOn6nEPVaw8OwNwVAgHjuayz5hdQANuvWGeelyA0QN783ASXCzn s5bkmbbiex7fch0ZHs2lQ== UI-OutboundReport: notjunk:1;M01:P0:AImAWOaQO+g=;EUjdXI1603PXy22v+XsWGLyD7cf lQGkjD3vkedxxi3gotjtwgz02Mumaa8Dh551ORBQiqZhCSMS3Rv6PfSzj2NlaocL1T+S0dvjF Qx34dpEnMzaZjpgn1+Ej00YPSC/SbZhWUr31A+OFvhRpZWQgQn2++NzMI+iZ8OgRhTnFyArWb QAD4BGDDVFbgvwKZKFQRp7xzdlFKFf1A3cwT+Esx3WVua/BWTOVuAQDZWY6meBCjy15zyijpE 3ljA1UTEV+gU5ZCKPCQQOCHCYXRYdTYPl2XvXE59q9xwKi41aNvUD72ADk3lNaHdzQ9UNSWpa 2CeGzwuvxaVHU6IG18I3f3z+Ikp/LZGeVTvQn7v3rBCVNTA0MaCV6px7fSKyeTElbUqA+46eJ oa+/Ii0GnnjyUrsT1eaxIeGLr6edr5C3sAE5POujfoeU4S9dd37iOrXOXINW9T5byZ+dqfVj4 4QMtjkEInkjbVOOaNrj1jZMadgV2CHx5K4mTodKNhqGY8Zwcd14L6uqtnbkms6d4gSPrkudg4 u5XWC4xgcUTqxQxXmjcPpLbkhGYABPVHsFFdJsapgsU6GbWIrstudqJOp7cuXfMms9anuj92r 88np01yD7JVGUnGnM+oRqW9jm2FihBt50HeTGUW5HglkWWQMFZLsdN0LgENf3EV787aXstztC TtvMVygwv/Yqcqnx1dknQGN4CypmNsaeYEkmSGo2bGQaJZ860RA/e0ZeLqeFcAz1d5pe6Rrvp VI3Qq8Z13SH8U3UfPr4Ua6bTmhefyK+0VtSpthYuUq4pGmd1OqN5LZwSWfuH9HOrSyN/+QbT3 k0JyX7B0kZCmxC3Arw/bPI1T4noaph9KIC6yaYB6GPvdg= Message-ID-Hash: NAAFVRFOK73CIJHPFCATSOJB4L3NVGSY X-Message-ID-Hash: NAAFVRFOK73CIJHPFCATSOJB4L3NVGSY 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: Both drivers provide both sample_new and sample_free, and it makes no sense to pretend that they could not. In fact, load_data() would already crash if sample_new was null. So remove the remaining null checks. Contrary to that, the emu10k1 driver actually has a null sample_reset, though I'm not convinced that this inconsistency is justified. Signed-off-by: Oswald Buddenhagen --- sound/synth/emux/emux.c | 6 ++---- sound/synth/emux/soundfont.c | 12 +++++------- 2 files changed, 7 insertions(+), 11 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index a82af9374852..01444fc960d0 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -94,10 +94,8 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch /* create soundfont list */ memset(&sf_cb, 0, sizeof(sf_cb)); sf_cb.private_data = emu; - if (emu->ops.sample_new) - sf_cb.sample_new = sf_sample_new; - if (emu->ops.sample_free) - sf_cb.sample_free = sf_sample_free; + sf_cb.sample_new = sf_sample_new; + sf_cb.sample_free = sf_sample_free; if (emu->ops.sample_reset) sf_cb.sample_reset = sf_sample_reset; emu->sflist = snd_sf_new(&sf_cb, emu->memhdr); diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index 4edc693da8e7..2373ed580bf8 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -1051,7 +1051,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count) /* * load wave data */ - if (smp->v.size > 0 && sflist->callback.sample_new) { + if (smp->v.size > 0) { rc = sflist->callback.sample_new (sflist->callback.private_data, smp, sflist->memhdr, data, count); @@ -1416,9 +1416,8 @@ snd_sf_clear(struct snd_sf_list *sflist) } for (sp = sf->samples; sp; sp = nextsp) { nextsp = sp->next; - if (sflist->callback.sample_free) - sflist->callback.sample_free(sflist->callback.private_data, - sp, sflist->memhdr); + sflist->callback.sample_free(sflist->callback.private_data, + sp, sflist->memhdr); kfree(sp); } kfree(sf); @@ -1520,9 +1519,8 @@ snd_soundfont_remove_unlocked(struct snd_sf_list *sflist) nextsp = sp->next; sf->samples = nextsp; sflist->mem_used -= sp->v.truesize; - if (sflist->callback.sample_free) - sflist->callback.sample_free(sflist->callback.private_data, - sp, sflist->memhdr); + sflist->callback.sample_free(sflist->callback.private_data, + sp, sflist->memhdr); kfree(sp); } }