From patchwork Thu Apr 4 10:00: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: 786271 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 20482CD1292 for ; Thu, 4 Apr 2024 10:03:19 +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 78F252C88; Thu, 4 Apr 2024 12:03:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 78F252C88 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712224997; 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=hDX62lP+GsLwGK+152B8f+/I49W1F3Te27HEBDZO6XN/mpl+1qOr6L2+eNAaoziBW Skv3pZVR9UovuUUtTpXrVm+NqfCsqxky606Ufd2bJ9hw++XdEEWtkeOX9wrwU+9LU+ Q/9t/LIccPxH6PgvTYTDe3OAJGu8aQHZ7AgsnPmM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8C29CF805E9; Thu, 4 Apr 2024 12:02: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 7AC2DF805F9; Thu, 4 Apr 2024 12:02:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5CF0EF8056F; Thu, 4 Apr 2024 12:01:11 +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 1AB20F8016E for ; Thu, 4 Apr 2024 12:00:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1AB20F8016E 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=bhc8dMFd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224851; x=1712829651; i=oswald.buddenhagen@gmx.de; bh=aHgNEoh2oL/YTOIIO+HEgQH655EOrifvL+ft5bV2Fk4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=bhc8dMFdfi9uULHWv4AqH1pa0hts7BadyuhLZuWqeG9C0AiDA0fOA7n1xArCG/xk tLbNgj0VRI65gFimPb+6kbgoIXJHAhfS/ZMgdA46CGtm23N3Q0bfixN8GMbtMxb6F dxmB7AnSqvG/0KDu1O8i07w3i/xqHzG7A9lWLw+FVnVu64QjltgdsdbTmVVJP8PHJ iTWNnr+H7UJdlWbXgC7fYs9TCPHm0KkGdp4VUAqS2zulMxK1vVo1GUfwc28+1Y8uK 9PiJl7bl7Ig7m5bRa2wmWSgXNxrznlJk4GvHdWb1oFNW70JwljmiLXaYkec6BPkmA fEj0xMbuCjFN+gIE6A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MOzT4-1sAvc43DY4-00PQZ8; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RF3-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 01/17] ALSA: emux: fix /proc teardown at module unload Date: Thu, 4 Apr 2024 12:00:32 +0200 Message-ID: <20240404100048.819674-2-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:9BB6sT8NluweYbfKeAlUhV6mZPJsC0qCYIqNyScjVOxoXaUpjTg N9QMybeVDNCF8+udhpW/QGECDtqpe4uBU0DJWfIas4dl7CY8UCyRZUMEpNAYe6JwR+zYFiT IIqP7CL3YmtWlEW6TGcEO7dqXYrBtbNJ4ap0Emh3mPKOtKkewShUGRO/8afPy+mTNyXayVE QeoOW7XouN28UInV/VcJg== UI-OutboundReport: notjunk:1;M01:P0:gNy0a7E3U/Y=;vFFwMlskXs0zN7BowtfmFeoxudW 6V9wGAQjagrF6JzNkTaw6sXzwfL/N/w1Yv3P4AS6xSUgER2/M6QaO/mX/RPVykHlp5QV9OSXk 6VmCPNB5g9rEWAGUsDuztgdpagDsmNTmjL8aDKkXFdQ1E+CbOB1a+G1sfLJf/eUkgZOpsYNSt Xv9BJy0i9JU9UGuxW+QvzVRo/Wetzo4p9D00q+NT+yBQSSV/xQFvf09/LrTDBSU/Dgdy2hiUg LP/uT0NFXZgvrttnLXRemmZc6LWc3q26jksWEKz7pzUV65zcjLH8/9MaGqVkYvvDCgcIstQST NnUdTdW3Y4TIfKEPPO4UpgzTa1D0rUzL0S/c/QBdggyM9Bwgi2TiY47L27dDBV/PlkT7Y3YYQ 5ubYH7/TP9Oz8GIUr6rU+UYvU7+CoUXlk3A9EpJMYhtG1vlGEm1uJivrzI1BjEWucB8CdajXw iuE7NSScR2vP1DQKi0cOQn1GzVFqeSKUCbJd2jJe9pmWJQYSMaqSpnpAB9wZn4MKch0punAEW LSJnSq08nIGUfBeuCax28GKQh6iMic0kbbKWnJqDOfepR1YvmxfRWGXGHA0e6tBNuXl1IH0JC HVfR9/KyYoVDfv1SHcwaO1r+OHC6iCeOdPO72pcVrySvpqKaAxiWKHbTzK9nxLt5YY5+ORNpA tD8t4YVY8VgvzJPxHoM+F9LI4Jn9EPmv1zXTsamxTfg+rUAD58na2aLH90HNDyhnQx6PHbk1G hPa6jxItJHnqzBg43V6Muazbl+KdpTikiDcI5/rCASEDhxiq8i+ox0Lf59rxlH1JZ+TmlAUCd ywJ8K/10ycPvJypB2GohiiNX6aTM0mou1l4tmusFPYIBQ= Message-ID-Hash: UPTVQ6IAXCPBWY7EZXPV5I2RVBML4X2L X-Message-ID-Hash: UPTVQ6IAXCPBWY7EZXPV5I2RVBML4X2L 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 Thu Apr 4 10:00: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: 786270 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 898D5CD1297 for ; Thu, 4 Apr 2024 10:03:56 +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 AC9292C70; Thu, 4 Apr 2024 12:03:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AC9292C70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225034; 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=rd2/cqJxbiLRhNu9TMMJYsgMl4/8ag9nGqVN7pgNbVN/OOEFzqZDiseumvVwVwEXA 9QhZ1Ha5wcEpE12WgfKHokPugQh5bloO3efjnBfOvp/S3x46pa78a7B6Vh5OlA2IN0 yq7mJ8oA/8I2OCuV0Y4uxnaZmQkiGg4HMWuhE+TA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8B786F805C8; Thu, 4 Apr 2024 12:02:59 +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 6A1AEF805C1; Thu, 4 Apr 2024 12:02:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5696BF8016E; Thu, 4 Apr 2024 12:01:23 +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 A0151F80238 for ; Thu, 4 Apr 2024 12:00:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A0151F80238 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=KMrfxJfA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224851; x=1712829651; i=oswald.buddenhagen@gmx.de; bh=gT0Fc3s0V7arG50ohbQehwLq67lOsar3syDQYGHBBr4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=KMrfxJfARCra9fgBv/Utwp0sggsnZkJtbu2yv5bmkH1drOrk+iA0fAJFNlsEhdff 6chOm/fKAR4XkcgpFWEgnm8PQIXu0oiBdXCNt/S8M0MahqIXxK+zhOa+T80Tr81Vj IU2HXUrPmpQf5l9MKlZTuynxefmKxgxI75rOn0dKW3dnk1+K7MxvFcdHHPiE3Q/AC rf4KWcIXivOMnr4LGiP1bYdg0+lOqzYWt2XuOYHzrrUw9pmvQqnmYqlTn1BBDtQH8 C4qCFwfadKUo76jtk8xEXGNAQ/xsbsrqtuOuFfbnrdF1WCLv8pCJ4xpz/HnzonX2q YCDCmFWHQOx75bDJdw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MBlxW-1rxmUZ0du0-00CD33; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RF8-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 02/17] ALSA: emux: prune unused parameter from snd_soundfont_load_guspatch() Date: Thu, 4 Apr 2024 12:00:33 +0200 Message-ID: <20240404100048.819674-3-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:1DhF6qoHkopmsJvlbNJaTK0nG5cvGVDuXx4Y8cTzKa8OwROg39v 68Z9aAfTCi3nb5a72Yu17uYZ5qoGvK56MIB7cDn7AMnFD4UVQpAgToKGOL/rED18pumagJX yAxK90+6wV+9IE2NQ/JRJ8jsY2idirHeF3UQDFFYE9pjojUgiJEd7xWJ9/bOAZSL/vrGNdY +3YDN5EKYn3/A5sL+StLw== UI-OutboundReport: notjunk:1;M01:P0:hao7kNkAiek=;56He34GNceFiD6051Kim49nunjx qeyZxCKOK/rgNOVSewQToqwX01/yLQ1pY6rignnNKOBK9IACS8F9yIAenh0vuDBERi8TNRsbl HG1LekRcorneRTaJqCyC4S9JwqcWmTPXJIviVs2zzLmw3taK4UtnunQWeRUIeyxZDgj4F5rkz DK6LTUwG0z1AhgRFDrgLCbaqh9iD6GtW5bRGfzKVFFSeX5e2dX2uUFrNQOFfVRaxbLxla4RLh mxnJ3DWKCfdzaSi9xFED25sGcvXGR2RcFyL1h6zKJO+BuKvhNI3Si6ts19KaJGz4/wZUFWazC lhUt4PyCtjMpQ8fx8C0XWGqxhVramhtmY+0gTtosCIeMaaBnPFeiLFG50qJQ0Yr8SO7YbVuq3 dlptMZjb7bzCP04NgV4CpEISQzD6JRqhgCMybwlov8wVzqR5WiJ3O9zTeGq/5ygsjbBTvz5J0 crPtlPuuQxoYYeCrHU9XbHKAFY0v9eL996ScYAseNENgYdGxqtR11XQhss25Tmlv9VLRYgFkz ddp6DNfFW8vufD6sQ1QHDle88T5iiAlJuxxa6Nruvtre64nP5sjPIKgZRw6VYGTQC33gDrshL oY7cg6kLmugTqcc5QSK3Vzjnf/E+EFHTanUfUJPB/8GVlEt3veflW8ZUt2Y2K0EWpt9r6F8uJ AGwvEHlXbMf9RjN+Dj+V/rYNBLop6WP9jbVzM3V74yoXxa1tA4MT9pxWvyR4L4V9T0jvnrOZN Su9P1oxDQ+MFnqeTRlJTdfec5gSyMjoaWKGnA9ipLv3PvmAEnnAd6LnxdsHuGBOUEvKThtt8M a2hUXOTAas6Bt7Ph7GjCqds4E7jViyeBgyfp5+09qgvdw= Message-ID-Hash: MTFVKWUA26SBVI4RQEYRU4NBPYXHXRVD X-Message-ID-Hash: MTFVKWUA26SBVI4RQEYRU4NBPYXHXRVD 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 Thu Apr 4 10:00: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: 785877 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 447C5CD1292 for ; Thu, 4 Apr 2024 10:03:02 +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 33ADE2C70; Thu, 4 Apr 2024 12:02:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 33ADE2C70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712224980; 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=HH0Gh90eulhH3Zp8ABCNeiGi57mPB4gKfvXJ+F1/ykzUl3FStALmDz0Kx6qGG/9v6 NY1ue5AZv8wBixwL3X3dqQb7XTeC79MeC65UoEEu3C8DeQtzvHvCxkMvzQAzhuoNnr JwmVxaLix0bz7CME0C4OkXDNm0IU80X7uYHUYsuQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5FCF3F805B3; Thu, 4 Apr 2024 12:02: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 A6D87F805D5; Thu, 4 Apr 2024 12:02:09 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A0396F80578; Thu, 4 Apr 2024 12:01:06 +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 57BADF80114 for ; Thu, 4 Apr 2024 12:00:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 57BADF80114 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=JmZQoUwV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224852; x=1712829652; i=oswald.buddenhagen@gmx.de; bh=YhQPRxRn3axvs5eoP6C+dAAGrMyhTu4iH/cIsd1W9zo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=JmZQoUwVNq9aDMvNrbqeRtEHOvb8UCI7xgm+cJRUIFj/eXpSuIoM8EYGkdGvvusx 1JaYG5w/aAgJwUxckivZq3QYXnSXOiceXRGbx87PLc2idsBBS9DdVIfBVfjeP87lI qoShQJ8a1RJwP0dLeGVCfO2+eL6km52QlNMCo7dmfMGM7HmqU+7C/xEBoMoh850Ym 84CdsyIip6p3vCbCZOocKWMaRmm4ag+Wx5+OBjtO0Y+fxkFNTy7XRukxhTV+7nzHQ yH0PMvLsbrD2fOhV8f/w5BDE2yae7t7F43MqKf7iNn89fI316BHzStZ1rd9RNcD/V jABPirg53G9ic1jBvw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MrQEn-1sdQpT3MIR-00oUbU; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFD-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 03/17] ALSA: emux: fix validation of snd_emux.num_ports Date: Thu, 4 Apr 2024 12:00:34 +0200 Message-ID: <20240404100048.819674-4-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ofl7FRD9w5YwtxG2PkkRrgGEivTzakky3Nzp3n22Gug5BtoijAX pDia57PTqgLPCysnUAtWCKYKKlNb2XefIBpmnarUj+GCxIeFMwyk3w/YKe6uaapcz7gQjWf tu5bG0fy7xI8eV11suMSHaEhusOzhOJo8JUJVy6Li7p/ij2qhzb4XmODyqgfvxKGezmki6T xe85VKQYEDXVUPO0mqtKQ== UI-OutboundReport: notjunk:1;M01:P0:3W9YbSAhzqQ=;nryRaPlu7frZjWpJ79LKpVnt6L4 cgUwAdA/Q/OxMamKlC+YYf9WG2qds/W0jrv6CgKTB4r4XB6/LArsRxPbyHui+5IPoIiVbel8o ufwd4GwmwNjcWsm6p6PAZxOS/iESIYaWb7BBkYgeW9az3sum8I3nDoF8ZCz6v4B7gzPyERMmG xByiTJ7m8PBY8Z8XDLeNUza9/bups1+iq7KHSF3FJT6hZbtE3zKwEWtFVDcpLej+tfaDlyxiB nfZofS/1Qq9zQrMQeNfVFZ8Dkt+9lYhkxLY9cihOH7DTzlsRWJwZZEiw0LYwOl4P894k93716 kf150QAY58gHSpKbTZTuaqhRgIDCTiUTHL9I7UGB8+CanynbO1zwElwibR3E09rpJn3uQLFWs V2gPxIqHDmeXle/zTtdx9RSlZf183dW9qqX2MojYMUxiUsBn25PJDcrvTYtF4EbnM4ZIMjCQ0 IbkvlGhHDQ1YhK+GFwGw2xQWnBb+Ba2bZTWaeJg0bnm7reeJx9pubqsh+ifZoKE8TZaVXUy74 /PGk8MsMPBQw7o6D7ZssEZwb+tX5haKaSrjMgiEUjIw4H1yxaKCCN2LGK4mRLA7sWfJr1AYa3 v+IAp0CTwsPoZoYAkLdREqbx+CU+2KZOwBxSAur8G/m339udxx7+TGJ++fovMHN996VZPMkxT 2HYA8lpOlsp2KV+jX6GoQa0zJiaZZOdFqw4Xef8l5KoDrfca5mCrgAF5WWN6AgQtGQtqEZ72q Ba0LQeL4HvbMZhd1gRhUjVKpL4efYLftQ== Message-ID-Hash: KKFBYRN4GLYONPJIJ7ZAEDJQTKX6GN6I X-Message-ID-Hash: KKFBYRN4GLYONPJIJ7ZAEDJQTKX6GN6I 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 Thu Apr 4 10:00: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: 785871 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 A3CF4CD1284 for ; Thu, 4 Apr 2024 10:06:22 +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 B1A2E2CBD; Thu, 4 Apr 2024 12:06:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B1A2E2CBD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225180; 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=QTPwebGPuDtOt97a4vUJaI8/MDkf99njgrHE05f9+fxOJWOnJ/fxg0ErogaG2lvcz 9QkH1H813Kyl9yhTBGLFcLycgrXjHwmcV9GBaiWnsYX9/qpL4BR6uDvQ7DBMKX+FpV SXadNHp4D0H7GHobwGCQY19VbdwgMSgZ6YS8J9pg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 353F4F80714; Thu, 4 Apr 2024 12:03:47 +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 21B51F80713; Thu, 4 Apr 2024 12:03:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DB756F806C0; Thu, 4 Apr 2024 12:03:42 +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 8244AF8020D for ; Thu, 4 Apr 2024 12:00:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8244AF8020D 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=cT7YZLZW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224851; x=1712829651; i=oswald.buddenhagen@gmx.de; bh=BKRzh0jN6jwk4FV1MW84OiCzx2QTtPr9DeRxFjCpOmA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=cT7YZLZWPy5Np4vNlFLrfX0BBUf9yI82l03CUNTprrP53a0cNAIo0gMuur4pEP4h GYfLfs9lKmA7AaMEKo6rdhwEihynz+RQUfuODsBGl2xjFYote6DiRyBInJreiCIkM qkkJuOofTvweVarGDLouXzVqnPNpufR2DG4bzDlSeqjgRIHA232NH0QewAD//lEuc dt6pQB88jEXOoLfV9oCyiD7iqQpxwka/CEQgBfybRYi5re/PBLfRnFq+iMQTHmGeb f/t7KPQk4ij7P7wcYXWu/XJrdwrvmUQESfM3OXSqBOej4arLArG2t+A1znwZV+af0 +z3SgFsi6yi86d+Xbw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MEm2D-1s2z193DPH-00GFCH; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFI-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 04/17] ALSA: emux: fix init of patch_info.truesize in load_data() Date: Thu, 4 Apr 2024 12:00:35 +0200 Message-ID: <20240404100048.819674-5-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:THqLUx/zdPTTmiYiRbsoIObrTwqA0wDrsgnqTSMSzR2Il0PRVhp zMPOIm/ixmw+aJ3iVp9Bca4YfIT9IwDh79JdN99Pg2LGNNjpGnGzDgTmK26vWHZwT3/0G59 l7kZdhNg+O8mji6YwxA0usR8mIdQRjQl+XYN0iNarPyzm6PeUhwmV9iBYa3MOtMXMtnaEZq HxcoyskS6zeB21m0+HXhw== UI-OutboundReport: notjunk:1;M01:P0:SrMp/VBSqek=;/Ps4LyF/1nmjeSTR2aYkkmIBCQd Y+FR12TtFN096RNyJB9vzgLb40ODnXOP1c8xF2FzG5ADR9cNAkiFCF5iAuNnZCkTfdYqbJIsR AsWs5Jfal4101PhPPDGq5kCcEtcfmQqrtmUD82+wN3pVE5vt8qWkGkKwbtq4sz5Dv5tTcrTBM gEqgxmU4a13gycDLQ5Wo17zrIuPgXVfPjKFiuPmo5MaL8ik+c3lHe4SAfPCbF06REHk7+eyu9 V5uEWsfip3e118WgIyaTIJ0SOX2S0j4s0S7fW4fxsC7N/Nbl3jCO+kMQhNPkDffa7iGe2LOww MQCHr6aj8mIMBDC25TdO65xGsXH63iMaCfTNVPnuDjh+cM9bIaGW11nu5owC9a4xW6Mj3zk9d whPY3hW5NChRVuscHQh0UAZUNqEJXY3gq9ouP8kL/4f9BZPZcKjYubm6m2tBUOYZt+59SELet Ez6S3rXEIPNoZPM9/ts4jCt6dWFXBf/AcE6+rtwqAmX0L+EbKwGcwziSC5/PViPqUfsGSpRg0 dbTmUZff7mEIuiP063/+sQPtyp+ZAhGPmjDOwKGwCOZOeiJPi6rMDRmZNVmj0jD0gXFIsmEN+ PvH3q5UNUipb1NyZqfcONQlzLCIjINi1g9ZruEwuSNX/GcI9+YM3ScudUDF4whaQyBFD9eHiG jOQIG1hwYNmOmVfK5scRtUlznFEK9ouTN3GEe7Ngg6rfK4nxy56dz5jFjTEh0IEgrKYWwQ1yW YSYUUlOGIS5z0JKldGknlMhRnOm4Ict57I7l8QhSSprPeOUTKfw1Ss8Fx8rFTAqUqL2/ovtxo ZuE+8pPqrKFuKzqpAKDqwbnY4Kc0FoYExstNuitu9ERvQ= Message-ID-Hash: ST3B3WG6ZKMVYZ5CKPZ2X5YWV3UMUZLT X-Message-ID-Hash: ST3B3WG6ZKMVYZ5CKPZ2X5YWV3UMUZLT 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 Thu Apr 4 10:00: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: 785875 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 7D5C3CD1292 for ; Thu, 4 Apr 2024 10:04: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 A60102C81; Thu, 4 Apr 2024 12:03:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A60102C81 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225047; 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=UMFre3Pj00lu40KDSP58A8c1cnkF7rNszJai+EZ+/zgX7M3jveiqc0c9B1GRai9Ou qrTKj4Dxzb7OyatkVS0VU+QifXU3K9+juBLtb0wLvIR6YU3D5csxyyTbuLwChvuC8F RNQ81AmjNg3gyThltZdztKm/7BsbJPPXFlUE1yPE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 578F4F80638; Thu, 4 Apr 2024 12:03: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 A4AE5F8060C; Thu, 4 Apr 2024 12:02:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D8DC3F8016E; Thu, 4 Apr 2024 12:01:29 +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 E4797F80570 for ; Thu, 4 Apr 2024 12:00:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E4797F80570 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=Y7DcyFbn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224851; x=1712829651; i=oswald.buddenhagen@gmx.de; bh=TUz8ah5z8pNT083e8DQKx/8kl8YBAd0RX2+UgScRUnc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Y7DcyFbnfDt1ZThlGI2cPGkDU+D4nryak0719ue5hvoO37qDmm9MhoJ5pKJEpDlW iIApHK0qDacyiZhs7aPHWJgKPm8zvjYSVJgxCIihswTorHWSmsf0TS5eqN08Ioyn6 GnaCCwqjiQa92Ts1M8kV+CO54oehqVj/w7YkE6IkB2niZQdvfW4O5AhD0mZDFeS9a qeEw+EtlXVYkRVYbHCU7X34YlmW7SEmtBlutcCa45orVBHkqLkihYN5pCCVCXB9lb GiaT+1Gn2x7I+NmEqi/wTbojVAZfKjdzQj94Ylu9fT9sbvgsoKlEaDgRV8ibO4k54 uNIT5XWjeLtq0/k76w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MqaxO-1sensB0mrQ-00mfMg; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFN-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 05/17] ALSA: emu10k1: prune vestiges of SNDRV_SFNT_SAMPLE_{BIDIR,REVERSE}_LOOP support Date: Thu, 4 Apr 2024 12:00:36 +0200 Message-ID: <20240404100048.819674-6-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ESkvr/u4kvFeDcA3F2nAvwudrXYtfhJK34kNYdS2pmpIgFwkF1d Jb/rXopYDzGFksZ/yMUXzxjtKv+8HHTrUBh5P8Pb12NnELw3/y0W/2E9HUjFD4pufhvBqiJ aGYpWGCyh6oQZFd4CUIRl8JsFBwpNBBCTB5eqsRhTc7kMCUwu5CzYjzMrGvCQZsSGYR+LVW m99J4FWVH0JUOcXpp7N0A== UI-OutboundReport: notjunk:1;M01:P0:UfHc/XmSlUQ=;e0gyY8qJMXf9Xr2ShsupMA7GQYu 47DHqAjs3ogsF0bKcswx2acoo+ddodDvSz9hhGSfWPk5RFguc5Y4KZWyi1ygfaojMts45MdE2 0EUXCFMu7Xvat/BxjZFWT+g7/PG7LCS2HEvUtqguuBQrSe66u3jpR/glcKgfsq0rFf4a++NtM aCqDGHYhKOmOPxc4Q8sI/RfQIY0KlkDJy9WxyPWOTSDTwcJSt8Egv9N9L5VG0cERNQV+wNzEq M/M9d5O++FnToVO8oN0s11WoBr3XFOotjb9WUOpWOmWnanqPb0KcpoLkJjRajQqZA/dwFA1oS LWt7nm+vJqc+YiHgoEUkncO+veO3AmUtAz6DzXDRVqI622hYXVafvG4IicyaMjIOJ5m6Bb8R2 YdEqK+JWAnVR2bH6wTeEWCDywBw3B/srCDREhNeuC8qBMcRUHxjrWsLrYoBl7vhx+YnSrtxMv NkGvotFZh2UMm3eJnZSgT9vQwC2h9EnLp/z5vwpOglX1uWf9R/zCOo9dPWwXQxj2+ClH9Iecq IG9rWvQq7Nbh302FXsnqg3r0Uyqd+cSvKHeDoQkV1JoyjT65P3bZZmn2afUb6V3zYRqQEldXF 9EOR+P/Yp4rF9BTpLnSvvPqhDefH2gJNV1V67mqrCxVKzvKVAI++XME8ZQs7Kf2ISSyCrc3qf j+MVYPw+mlyoYPstiRIW7SWgx2BbHiX5uUCqLgbeEV6dKSANudDgDQV/WVkwEXIV1h+Q3ovZV 0fBGoJhuhDsmlEMh3ChH8VSDFIGvZ/SC+NDbAqWnqyKgkgdp1iQAo85O8XbBWib3bILasDGj9 gY3KuQI30E3ost61G7xNIkon7OwWasM9Cd5CR6jhfKcHo= Message-ID-Hash: IYCARJ3H76JPHJUEKSBPCY6LZUQ2B5EC X-Message-ID-Hash: IYCARJ3H76JPHJUEKSBPCY6LZUQ2B5EC 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 Thu Apr 4 10:00: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: 785870 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 2D7F3CD1284 for ; Thu, 4 Apr 2024 10:06:50 +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 2E5402C9F; Thu, 4 Apr 2024 12:06:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2E5402C9F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225208; 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=eWiSemUWsEoS7loenqywX97t2mSRWJSujmKCtTusxRfEUroRoH8lO/19Ahm50KJdL na26kP6MHQJkhajlR+KYOqKhV82X4NYEW7cGqK296jL8rMt/+QUCToC1IedgU3w/Ct RY1FemGmYk0wWlAzEZxXt/85WdBS3H9kvWC/sfeM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D5DEFF8060F; Thu, 4 Apr 2024 12:03: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 5F5D6F80791; Thu, 4 Apr 2024 12:03:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BB678F8060F; Thu, 4 Apr 2024 12:03:49 +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 75258F80568 for ; Thu, 4 Apr 2024 12:00:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 75258F80568 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=EaMRzeET DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224851; x=1712829651; i=oswald.buddenhagen@gmx.de; bh=wc/b2wKYlaKGB4GrE+oPQYlWRWZPL4Kua9Hy2ujNQDM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=EaMRzeETOgCRJkneGqpPrKJxS0jPQdj8oTrL1ucHo//Xj+TlCUM9NTqCVlUz83N2 3/fmREpWENK2lIdgeldvIMWTg9BqJH4HBPS5V90IduEugyV42aBZogTqkpy0+soTF 6tL5RAYppSzBxVrHKCiHhmvOC0lDP1zY5giyicPcar6Rc5tPX9zHjCz2iqgpuD+0q r7oy8PI7JNc+Te7We6+5DOokUM4QpTw72hrwevt5v6ergXGU3mPO9GsvGNW8u/mMq H8sPbdBjMii96sg6/lTQpMxaTVQfTiCYD5y/IAKQX+TPwH/HjGrzNd7bbBYWC9GOD VbPJWBCTM0UCYMlKMw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N4QsO-1sqIqr0dx0-011Q7g; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFS-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 06/17] ALSA: emux: centralize & improve patch info validation Date: Thu, 4 Apr 2024 12:00:37 +0200 Message-ID: <20240404100048.819674-7-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Agec8423UNwgTmIPHB/JY3Scx73I78tY1GaTiBH+HkBo0zYKxS4 sfqnemtwBEV4tsoBJU06y3uMMDNID56xvtqHhoQfU+p2jTWRYEs1Qm6+1CCY9h4N8fVCwys mT24m9Br5LwpT0TfrkCD7GL+y5Vive+4K2exCeyPqKC+FYmamZpPNbPj+nSzfvNbWExr6AZ hXirwyl3h7dm9EmrVTOUQ== UI-OutboundReport: notjunk:1;M01:P0:GvLFlI9TuI4=;I3pNPhChd2eRiUYtDr58DXCXKdl 0YXeDX0eNFLEYGjMqaWGRAKEfLP3HswL9YeMNdxZ1KLirNsx6IFuhHUg+YknhU7IFl3uTikU8 rI0HvvZ+5pL3nlg8cseb5oDvecPrkUlwlAT+n38/iArBLb5b6aF3/YpRNIwnImj1UMFDuLpU+ hN1s3CPa3kMrHVN54ZNk/IYbu/xJomG6gMfbptd46P1UfSxKz+dJQTBWIb29gxZE9l/dF1+pa A5fSxJ6aogshRp6KLywHofvYHlSf6MwMd0cTqQbfD3s4d4O2YAsTFhmDQeCrr7KiAWpogaZvG ZqbQIC/Lyvqsgs0LNuo2cMD1p/jUWRRMElqOQQNCHdQSk1CwyMwUt7/q3a3th1WBNVsNjVn+z Jv/9/yvFdl3DxN7Wog8kisZF9EiBVe3X7Ck7J+j0FKQuhyHeaJeOQwZ8zid0XsRrk5dY3ME44 /njTXs0E9hIZC0xMzgdW69G7rgSr0g0c4rd1CREaHtttiXUJn8nfGH4i04h+Ay/LVueDp/0P8 7m37DmDDS2u06tt5l9KuXHDSfJ2i1dFKWa1/c1671IY+YLR5dBCZyxlvwWDwXq4muzyhzZBUE KJS64AIowuuS61keB6VyqlrDFEH0aZvCFanorwCmUrkpOh8vtqRn+T+3xdsisSCInytpCjn1k 2pTxT4XPimCpcyCWYrXdfEppo7r9OJg92kq7ZZFeDn9H0RlUl3XFi0CLPIQ8FHBGJnG3RhlCi TYhpxvJ8+Pkz+pCmDnCUrUX8uhhwIDCof9G+PVAlUJH8A1XBjL6ilr2POiCwkMnKk8eodWOwe x8di5RRVLdoYDb/G7b1SeLnxKWNpKulYqkirMCdHtPo7k= Message-ID-Hash: XLDIBU6ELG3V3U6QKKWLVFUDHYWM6QH7 X-Message-ID-Hash: XLDIBU6ELG3V3U6QKKWLVFUDHYWM6QH7 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 Thu Apr 4 10:00: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: 786265 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 71CE3CD1284 for ; Thu, 4 Apr 2024 10:06: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 BEDCA2CCB; Thu, 4 Apr 2024 12:06:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BEDCA2CCB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225192; 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=ceeH6qy2xPXTneLcsEQn8sM9LYMbQ2Kgpbjiny2PhEgUpypNEV8CM56dT9BzLukY9 wAe7DzGui38XqmQ9CFWK2jQdA8mhf/3LY/EBftCtHRE704cDZRLuZTMriRiYw/kzws dBikbFttIZJTPny/sCurBiWCoGtiHbczA89MHzXc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F3421F8074C; Thu, 4 Apr 2024 12:03: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 7CF1AF80750; Thu, 4 Apr 2024 12:03:48 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DD96BF8020D; Thu, 4 Apr 2024 12:03:42 +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 5BE3AF8055C for ; Thu, 4 Apr 2024 12:00:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5BE3AF8055C 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=ZuZvRQui DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224851; x=1712829651; i=oswald.buddenhagen@gmx.de; bh=2GdLrZxDjdbvVF1lEmdcI8u4pC5LW9+4fvqwPQfg7dw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=ZuZvRQuiTzxTn8dCuJdIW7MfwNqWsfJTwrmKeQknlXcA1vzKR1qxX3ItG2Z91RxM 4fUKSJZ919cJTa10rxm/F9OOrzAKf8V0Dd+WphBi9/j5I5rnVZCsLa1TCXCdwwwo0 85wNtu3TClfZJ4S7O8sk82Tdjnr72BEWwXtIuwhNCneNdIJffl7Ts7tmchymMtJAM YGNDee30SbuyTyope2fYEDkwmn3GOC+ovj9kDh89BLjLec/edn3tCqWkO8TR7sUlj CZOF7n8F09qbna+hNg4aOuBJi8MYTFmMtWfV1Y873/CVbn75IFDXWcZkk0tBoHb0Q QASL/xKSxyEF2d3WlQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MwQXH-1siMkw0lKn-00sJyq; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFX-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 07/17] ALSA: emux: improve patch ioctl data validation Date: Thu, 4 Apr 2024 12:00:38 +0200 Message-ID: <20240404100048.819674-8-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:OyPmB4NFJuE3anL3mC3APIoT4TtFGbl9zdn3481ckOXlWqe5R0J K1BO20LFvKTSFB7zbv1Y8Lelez7n2ypYybMJYwuB6/NOwTCJmAK+43XmlI4GSXDbtd21dtG klzZ+5lTiAGSW+S/6rQdSU8AhpA6nIn8vpf7ejwSWfvGAVRdzY3h44DoBD/j8SFWKHRZ1m8 NZd5V/+F2sLnXMXYLxRyg== UI-OutboundReport: notjunk:1;M01:P0:61d9gOi6YAk=;ad3dicwwrJTEUhLovQzCA0pZweY g13mxxU3QnygYjF2LH55YWlnTrmXoKBdiSNXwUU3H1ueLTpm+J4yhsHfhsu+aVDNcy5zImrwd b0PkwlWOft1KcCo9310qZOooNOJIhYVgWwTTEoLXgpab5yRFt5lNxrF2KeobC4dc/eCJhzXAA 49zOhfoPLo4JaNRGvqYVbbHL7KPgROl60uaRo4z4UVH/Kki+yDvrhtq2yg/hYz+vtbpU2YK5V uavBRWlfhas0ZcyQFyswSF0ndOfCvR5RjVar6QnJVEuR41C0hkqf282kcCvWKP5QlkBD48gQI Zp03uetWN8j/r383c5zhraNkMoZVcpNzRNtjzWhbQO76/kWNsm7f2827Fxju88AA+xKmYMu5H 442B5xfyoH/gGLE/v7engzFm5IsYs4jAl3aVdY7f28h09QAlEISFxZQjzEhJA9qxd842H7Quz IJxyOv/jkOBVpK/u8oB9lCzgvf+ed+AmgqKFz08QE1C9Lwh7vrvJ9GZB6a66r9uwRb/3LNmva nh20BTBU9uCAvQaxGvlK2pnPyUFWVQX3yfM7PYQizX0fUkSbDBVaO6EOydamGLHQTIRIWm8za 8nPmTVsgkH2wlzBi4erEAr00aceecr2FzgX2Up27sFcRbpwOnSW4bA3x7d+W84L8d8LYi5Tq0 X9eREKIkR4TigZ/68tNnz4ZwhyNPR+yuskQ/ZBN2hPHMpiMCsbNK5Rbx5QCTdKM3wtcYbVngX b/5AWXuHYFvy1S3q9aTawcpLgZk0YEjxiIpnebdM97uxf2eHX8bLmk6qCz9n0Yvq+ocKuOk7u 4rhTlS0A/DnBdfLOKarfAmph2dCQ5yKzfbJci79jbS67E= Message-ID-Hash: HRRTTDFIJMQCZHT7II7U54ANVA3V35OI X-Message-ID-Hash: HRRTTDFIJMQCZHT7II7U54ANVA3V35OI 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 Thu Apr 4 10:00: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: 785876 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 D632FCD1284 for ; Thu, 4 Apr 2024 10:03:38 +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 20B2A2C7E; Thu, 4 Apr 2024 12:03:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 20B2A2C7E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225017; 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=IKsVxTwTFv5EI4DBmWrsOmhORSEP32WvWh2n9Sha/ZKUY96byGOLfHwYxTZ7A12YD GWqsMJOl7uiuHQWdzLmX4HJ4mh1CT9Gs7H7k+QtcI9uUu+veM4TKY7VIH9tUOdWuHL g0VXqr4J5obPOEv3Q4y35EJBMOxcElW+Pui51xCM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 24F74F805BB; Thu, 4 Apr 2024 12:02:55 +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 A1950F805BD; Thu, 4 Apr 2024 12:02:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 56513F8016E; Thu, 4 Apr 2024 12:01:17 +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 4F00DF80236 for ; Thu, 4 Apr 2024 12:00:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4F00DF80236 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=gHJI5jeY DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224852; x=1712829652; i=oswald.buddenhagen@gmx.de; bh=WsiPGGqNN85sMCbUgri9GR8KKSrWW90a8p1Jz8kA+Oo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=gHJI5jeYteWtunxAKCnhfeXz1BzvCVr9fhP/LIdBD2UGfOlvxrl6kBJXAoo8Msd9 225V0TqOFojsfGM+Uawcu2OTKh/SmuUNdZLthUmDbCWOfl4VSXBO1t+I39v7PeShc iTg1wjtRDNdOSDR+G4N9w6c+cuDHIFFY6bG2OzFCuc4/pqycZmOefS2tTUTxGNCbb OisJ2SjCWbvlTlRP8dfwETFfj1G23LP8hOT0PpCL/aOEbvWUEkkMK6Erjyr6Fe7Zm dtf/aaRktqs4pKqMGZ1lf5t02MVOykzXe3bQ006iIa8f1zCYtW4PeHTYLefJkHR9f kpb0OMxd/fOzWguZNA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Ma24s-1sLtye3QsG-00VzAi; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFc-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 08/17] ALSA: emu10k1: move patch loader assertions into low-level functions Date: Thu, 4 Apr 2024 12:00:39 +0200 Message-ID: <20240404100048.819674-9-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:e6i01XEIphHuqT69UyOciKR1WlKC9JZEMwg9A9838Sybp/OuDaB Nih8BjeFwMWA0wCbL4TYzPKEI25M9WEn3kyKQ292WuBiM1ABiiwGXcmAk3JuKSaG/LaWiI4 4Zg42EHNodpHeJuusB2mYbiYJg4iXHDqeyxjhh1KmMHeTxg8yHwN+NKHghHjPV6JW2D9z46 DvVDkuCF0vGAITyZhLLQQ== UI-OutboundReport: notjunk:1;M01:P0:bOPHSf1hwQw=;dC6Y3WbK9GwlH9PaSffvvfrKFv/ eSpP3CKxt1wTAWswmf+5P9CJjPRw3QsFofYBgYaRP7LJ7JQGpkef9Jn/xouqECHo8N4NQRZhp 9KV2YNkByCp9J8bfXFKn7/YRGUq79mL2bzpa0dDsLupmcKtJLU1iiCnlLkqGjvrPwHcjWhiwI OAb4Cgyj04ntp68xc58Hm2jKVuxlFD5kehwrTnMQFV9eYsrAABJZL+2c+/13OGU3HbWAQJ/zW 8ilbjKI1cDwkJmA6BNiH8Zj4jz6X8x4k11Jo6N4MzMFDD057JJnDVvluq/6IcjRSeePZkfov8 n9g3pM4EDwWGfi0LTSnXfSgwJzv17chvoxvLc0h1FLwpo6B0igcuRv68AKqbK9oOwaOf2Xth8 +ECiaIxDHp8Ed0qCsDqnHWPKjFR0clVvO3aBomYu/MZVcUmHMQAJjxsj4yHQZ8nCNAeKjzWg+ DDbkzwf1W70fvT5IXcdN5pmQVepxvpRIwhNSr75efBldIYZ/80w/gyTIh6RKySiKoHrMf/GPU 1etb0mC7JmWPkBuVKcWefm0IEInDZ3Ye/lOHF79xQkAlX0yioFu8of9ufeYmpbWnx80T0j3p2 OFprH8JuyFyXr5mctGajun4jFmoIPBqrrP/VHnB5zvCvCc9y7eWKpps4+PxqL24q7biRc0X7/ Z5JwYR/mRxBxMKTptXaNUFJWG7fy3gVVisN37fN7zyKnVUlNjlHeIGmyNaIiUtPZecyCkxdGm n6v1QCy23DDsl/M0vYZOFkHyZ5RVp7KqIw7NgH7MwKGaxYC5exXJMdSnR8gmJ+RzRZ+xnxIuh 7XNyyMUhe8snEqQaXZ6xlD+wjV7gLSrWWmJdaFs/GaLrQ= Message-ID-Hash: NYC2ITBTIFTAULSQKKKCBAWRERBLF7PA X-Message-ID-Hash: NYC2ITBTIFTAULSQKKKCBAWRERBLF7PA 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 Thu Apr 4 10:00: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: 785873 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 CAB9BCD1292 for ; Thu, 4 Apr 2024 10:05:16 +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 BACB52C62; Thu, 4 Apr 2024 12:05:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BACB52C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225114; 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=SLosJSWayZW6Exy+Vl0+qvObStLVCl/VOX2GkI6Sl3ztlj3spilWdXQySGBs0RBTt Nf62cf8funwPrxbu6YFe95nuYVpFxImTqB5R6p6zVbRYBuL0HdtC1WT1aN9toRkKcl 4FzAwZjVtPm+/G2w5DOjbmD9rqPm2b6l0R/pkbrc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 143F8F8069E; Thu, 4 Apr 2024 12:03:31 +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 97D90F80688; Thu, 4 Apr 2024 12:03:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 40A29F8057E; Thu, 4 Apr 2024 12:03:27 +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 05F0DF80588 for ; Thu, 4 Apr 2024 12:03:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 05F0DF80588 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=p4D38zgs DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224976; x=1712829776; i=oswald.buddenhagen@gmx.de; bh=CAZ1ScoqbFZwHXnTKkLI/ab/oBnNr0cVzQYRhQr1P38=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=p4D38zgs0UcfkPr/ujp82xUhd7VQ1egRFyvx1xtOrrddQIVSVEoq8heU4ECMRzam UqE8oucV3rVs5Qldru0TxPqjvbBI5N8ez6bBlDXmRmCwiRsQj1rxASQS04A+tNzSZ jukY4wKpSIu/hKE+Jh/MlwmC/Qo8c7EK9+3MnPtWp381SwHcfYzp6KfGmPrywlmiI ym8Q14TcGTqdhB7vY/jcFsZVld+rIaZVyaQnoI1aX5pP4ccWsPf2KqLtNsl7Abxad nzkqhAe3C6skaIfTs6N3G7yedBZEtvyNcUNPHuNs/cXElbkVPM1OREx6vuaWy5n7x U1JAcP+jYJ0iTR6bWw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MAfYm-1rysS82E8G-00B1PM; Thu, 04 Apr 2024 12:02:56 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFh-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 09/17] ALSA: emu10k1: fix sample signedness issues in wavetable loader Date: Thu, 4 Apr 2024 12:00:40 +0200 Message-ID: <20240404100048.819674-10-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:+6fR5qoKew9hF6bnDQILkOU1HmuQA2JL/kftacw2bbtzw7lw/c7 NQiP6Rdkftm0cvu1moBCBQXOpGwYwSe1qWCN2F0vsbWz6XHOQbqJbNEzUrjMxeeNhkRX+uq lnzPKKXCfKfUMO1PUfUkOs2rHfwErMNWSts5YvYg2pB9tbY8uilr3LMAHYEC+F+CxTgdDQF HwLHnXNEQCo7xAoN9O7dg== UI-OutboundReport: notjunk:1;M01:P0:vZom+YAd6QQ=;y4o8DidJjaULG+KlDd9iTdTsS3Q ZjgOvP7vCLkpo4qbit0rVs2g9jhZnTniojk+hlK8a+fcjeK0aanFylaekYS/dI+ZRb33D5DeR TCLzs7mIJfdxBFCpfFedDb7qRMkOX3JHfkc2Ia87hsYeEbCtaJHbIyyvoOKh6euhqJc+Co6Gm 9sMQRxl3r/e7obG1o+Jp5i/QLzmz5lG4pLYLJVmnY75wK2rgbY3PiyT8SvNH1C4RZu6tpZIT3 S8d6zNAqnjZ2LnpdGgIqKZREjBO4dG1aeN6HOKtdU8oqmys61G32GPM/9C7q9BTUw/9xgLAM6 /NNxpuKbbnHwEDcKKeUcL38LBkHG8cb3x5yP7eFawNydnOL0Rg7e2s1a4BEPf8YSRdX+GhShs /uxwGRNmOx7eK1AfYJUEAYWMUgMBfPnqhumq68wN2M9dOyPzA0RCpOUgTKM3BtNgekKIDGffO mslFS2S7/m5WZT+/+bVikYOFlQuqwPpDzkMs3Q85uYGnezzBDq3h79fieDwEoVin53xH63aEP jVQ1r/iYhi2DCRmIBjrODa6S7OY9qc3HuEvKEBlK7NzlFWI7XW9XLEp4Eck3gMuWz2N8M+lv6 /WNZXDIzuZeD1MTg/EUeFpe+JDAezWk8P382Z58kh8gA1dFS8zQU+8B69K49icy4cMSM6sNMC k6573EFvKJ1WNufPdPNLT8sxquOmqVeJVrV3i1g6yXfwN4smCNOU9hg9NhKUWpgmdM1lfBdby EvsdSI4B/WPcfLwgHgOZ4fYRAhszZkhhNcsU8wAESpsppK6HmfHFiC2JEU34ym+9Z7yk6hCLb CVsmT9axO+/+ipVTgP0Q9Y45gSdse2YRaYD+/M2Z77w9w= Message-ID-Hash: X6X6KRCZXTVMHR5OXTCTMWS6BMN6PL5H X-Message-ID-Hash: X6X6KRCZXTVMHR5OXTCTMWS6BMN6PL5H 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 Thu Apr 4 10:00: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: 785869 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 9AB89CD1284 for ; Thu, 4 Apr 2024 10:07: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 B03BD2CE3; Thu, 4 Apr 2024 12:07:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B03BD2CE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225245; bh=8lNlf3jlZZqm/2NB4g/MllgFXVAvssLgW1cFiWUJeow=; 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=Aa5n1tSGc8rcRQPMmuEXo2Sh/auZfWj6RUkslYLkP91Ks2V9nTL+Xo7hyLoKKWI+R J4Olc9zffH1+YSoDyllK5+KL75LvwfkkT/j8aW9EltSANK/ef6ISNGzL07WOcnOzaS 8V9DYLiTam2UOfEHD4IEeZtSKOGK0RQDN6YMEKbY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 93475F80814; Thu, 4 Apr 2024 12:04: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 870D8F80805; Thu, 4 Apr 2024 12:04:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 02B29F80798; Thu, 4 Apr 2024 12:03:57 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (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 C86CCF8057A for ; Thu, 4 Apr 2024 12:03:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C86CCF8057A 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=dv/UnmzP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224977; x=1712829777; i=oswald.buddenhagen@gmx.de; bh=cXVA4THpoOuQmvVhbCnJNxDK0wsu4gIMaNVjdufjhV4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=dv/UnmzPleMPU1w20UnzOfTbpJkFGXhmmP1ftlq0d+VM69TKpBAVpn+YvI2pzT9q xoCgjV0TWqxDhrdtdpq0LAPbojfBtcO2C/NKTQEVir7+lOJ30rJNsBbxjipvdNuNt EMMMdFgUXUpTCIhVgYYgDim3X0WrSNEgUg4e14HDEiaR2MhMnyIz9f4vNiBub9cso qP4C/UiABtBWemHS9Q1uCP9lqhKqgRnmdZ7fogYWO5l9uEVlh6T8me+ILPj9VEwbs NShO1mF+goXOH8/82rtzqwaUf8uLatDXZbi3TigsjnRKFvGrAVXSc8rr4wpkz4i61 iJtD3KVDiucFaPE4WQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N4Qwg-1sqIoo47Wg-011TqA; Thu, 04 Apr 2024 12:02:57 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFm-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 10/17] ALSA: emu10k1: fix playback of 8-bit wavetable samples Date: Thu, 4 Apr 2024 12:00:41 +0200 Message-ID: <20240404100048.819674-11-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:IU96ncvC4RwCBM5LcW3eqCDw8rCZq1a7/Detz4fA2ZrjX5l3UE8 mKRCIXHO+1MMzYBFmxy2V48O8p6pBj9NGjNJ29OZmAErZSa+GTCOVArkPdb9gL5aigHVIFp 3+iObDGhqyxVEUVyt3s1aS6TXdfCDZ/9cf1e+L82yhuGljiMTA3PKGv3y4FXIwnxzz79TCb 0tuold43IUw3cQL0w82ag== UI-OutboundReport: notjunk:1;M01:P0:TK8heQhuk4Y=;2Evw5wNBAsT1gnKw6aUJ/WarTns 8hh4Rd6D8oz0jT0jiKLuPVN4YCvxAJJsDrNw7Q90j5tRCfaFQSrOzTk0MzDRie0NgXlOw02Zv lTVT5ovWh1Q5UoazB8GoEn57hKBNsea0hC2/SAqHyJ1QG5YZwFaoj7GnWljfqGgdvn27JhyOO ZwNg1h4GdMu7C6V7naIUGm+H9idaYcfe+rGauou1S3dOgo6Xu2sWzDou8Nm3g1rPnQpuz+Pa9 Fo314tghlGLJS+EXp7L6I6oy6Fkh35eresoXiQOkM0BRE3z6v1NP+49zDVvNIioz2z5p+N883 qsoKpQpDzdJDHSuXkt/zeGGxkEgop0SjD2wss8h7gy9lf4JGqNYV/Q5FRrW2mYQCa6F+Oe1gO 8/Nz3KXWNZw5KJqxfUkAhcg0aYiqZCr2wJWCxFE/lLD35GoZEV43OeYg/+mvV6cWwcZ6Znd6T 9ntfVTL2kNV5R286DZ7/fI8fWbc+5i30z50M1S+r3pt3PZKsdN0ftLkz5UpD9b9wKPF/q9ldo V+cY8YkHq/wThWZ5XnmpJTbeJL1HMVu4xgDU9Pba9IsukcL/j1S7JTJBvAbs9Rc2qRy+NYp0T i/+5BbVzGrfB8ljzlgRMWuknAdcdi2G3dIG0FFLwAYWVLclUluN4D1hqglqXb2VJlUUE1cXrz dsy4jSN73JG/G5TioRWbW9ktUm4aFLmKO0G1c3IiI05cdOgOChXrpHy8Hq0pcA8g7zlViWc5J wcv51ftn6p9b9JTL8jECD76L7vzxdA4wCWt9vuCdoAEXYeDMJD+p2Wuz4MXMd2O3DJ8XCMTmL 0FEpTgRJL9pjtN7YgXkitJQYigKTfOTXkHFbFsYzBn1Es= Message-ID-Hash: HVGC6KTBMHXKTU4QU53KLYKUITZTKT2W X-Message-ID-Hash: HVGC6KTBMHXKTU4QU53KLYKUITZTKT2W 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 941bfbf812ed..5f6c47cbb809 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 Thu Apr 4 10:00: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: 785872 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 DB07FCD1292 for ; Thu, 4 Apr 2024 10:05:48 +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 36EBB2CAD; Thu, 4 Apr 2024 12:05:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 36EBB2CAD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225147; bh=CwEvP0862EPc/Yp83HZbeJKnDpp1Zn4yzWA5vTmp2oM=; 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=cJ8+uxh+fjFwopjCkWzzg4rjHmEON3Z/AMgO/R9hMauvMzFIVovABNRkcQD50Afi/ d/Y3ssKCjXr/bnQmOdhjhdaW23tXHx6+WMFp0smhaJLI6RW8ylcaE9W0951GuHSN1L Cs2Ltzpnjy32HzQXyQJ1giAt+PrajZXE7fNUm4a4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 57F61F806AD; Thu, 4 Apr 2024 12:03:41 +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 21F66F806CF; Thu, 4 Apr 2024 12:03:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 492DFF805B5; Thu, 4 Apr 2024 12:03:37 +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 D3ADBF805D9 for ; Thu, 4 Apr 2024 12:03:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D3ADBF805D9 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=QH3P1Kx5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224977; x=1712829777; i=oswald.buddenhagen@gmx.de; bh=y3ZFAjtMGdLBY2mwalA3DpZ7EPCNzVIgYxzw1qmK5fA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=QH3P1Kx5GIU8xXCQe3nMrQ9IdvPBkWD+aYtwuxUD7pG6ZfW8DbRE2TWcB1V5tgei eRCfgFdNKaxOl+gOAynHRfsFYO3ujjTmcn2jq1OyZuo15MgTp68Nq9NCd34MgnLqn kFRlZinnvsj5F0SQIRh9Dyg/qiXA8RZ9meFeirMn3G7EwVGL/R7v1L1mMKbN3GEB/ N07fggXOtNE1M2IJD4uSlPGEXAp5A6kInkJOXCeLY2K68l7dznFhgzGM11cOpm4gr KGqmuK8MUjTmOYx1E1KHLvWW/GKNIn4pU+5U06C52Dyda4lhq6CHDDHSH0fXwAuRn 0MG/7LoW8s8AMXm/RA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mk0NU-1sYDCj0qK0-00kM9w; Thu, 04 Apr 2024 12:02:57 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFr-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 11/17] ALSA: emu10k1: merge conditions in patch loader Date: Thu, 4 Apr 2024 12:00:42 +0200 Message-ID: <20240404100048.819674-12-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:A7iepGdEXn+ylbyHXG17tRgwaL0YIwxWITMGQyOM5f7BBE/qftC ZGsZqMvrfJ3nCzrVDouS+P9qeGPVM1sOEH8Xn+npKAHWaRB2hLiNBNBeO/MC2Zi4d4M2e75 11Z7hvoN0/W1l0ugfgcHgT704p55crv34CYjtBuWQesfml1uFe515U6qKvLFp+pYZnyzv9q IDC9JW/tQnyE9lHWxPuZw== UI-OutboundReport: notjunk:1;M01:P0:aLYE2Y9DXxI=;U0uP+ARq+371HU7oR6RJ67KDN8L 1CfO1IzSUc/A48kifWlsdzzHwGbiWbK2c33rArzUqSjl+5oCHwlUwVcz2H/sKfGmURwb54oVZ suok+WPfpJOVCHlU7scjPqKecZk0gtpJhYKIkiFigfTmQJSsncgBuPMlmrU2sdWhi7ymv4C+I 0A8utGvijV2Dx2K9qqb1a3n6jI9Co/9JEBOFOLkuTBStPy14vnPDoNxiY2AOXliA/Rp1XTtSS LLIGXOCG87XBay9U1ovSr8sfRZk9KREczYSfWepPIPy30+6bR+TepLZ/GjWmPJjwIlNXnSFgm vrZiXQk1DOaRRj4FBsg3djXeA3tu0mO6Gk/Cu/FkxJi1iCjJXzLCZ7ykQSyqmvxUC9+QnTYN/ OZJy4ZW18aKaW98iRrq0jID27eEZC05o5nTNTJTScjg1k7QZHRx/LHDOxqFuVDfSPy8Yq/fsc 9UbqsciMM8W32XaGTsYE4PsYyE3ZVtB6wtqR4p7jvONB+4U4GShoOoy5rBMyBGSihzjb/cyui t+RcWRUwha2b+rekNOU/1Hbz3Si+YIEYlFRlToxXdklFoS+cXSmHl0YW3u0LntFemZ0ow/5Ev BK3YpcFm/K1l5RNeJ1EENU+BrSEghwiwGYMtwf6zLcCGzvwwVP8vUY2v8YsRhUdd8BGMMy2nT Pf44QtPpxgJ0L1bYIgWXJq/OMUijMu8liKYe5yy5c9iG+/OgWOOfEtVRVi0qJzKKskojX/ST5 1z8z8QMk/YLFMX5TMsdNKjW9vebkvKZLthl49c2bPYZ2HM8UeFfee5apGEmvCVMRNaG2+43US YypMBYKewnVh1g9xEyWYqokixgh/ArF+3bbyqvwiiYl5g= Message-ID-Hash: FUIMQNLM2WNBCLMCG3D5ANKEUSD66GC3 X-Message-ID-Hash: FUIMQNLM2WNBCLMCG3D5ANKEUSD66GC3 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 eb3d1ef8a33a..281881f7d0a4 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 Thu Apr 4 10:00:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786264 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 082EBCD1292 for ; Thu, 4 Apr 2024 10:07:06 +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 400E92CD7; Thu, 4 Apr 2024 12:06:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 400E92CD7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225224; bh=dJcSfwcjGZwXSI1L1lIntiuYVFyMF8fd9RGOCI5IqaA=; 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=O6N4AfRBil3bbPXolw9iKjC7QK0WWECERX5S2cbQ2/WMMvK3sEYvRsVPoacjh2n8n nlmC6jtAPUGzR8nXljzeFrjb4RaNpyGOEgoz4sQLz2BcqoWVlmnDRglJvTTHLePzFO h2emfajzNU5Njm0eY8vii7bp9kQNGNlfWkRkzr2Y= Received: by alsa1.perex.cz (Postfix, from userid 50401) id AFD8CF807D0; Thu, 4 Apr 2024 12:03: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 40AACF807DC; Thu, 4 Apr 2024 12:03:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A875BF80796; Thu, 4 Apr 2024 12:03:53 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (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 B3D21F8057B for ; Thu, 4 Apr 2024 12:03:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B3D21F8057B 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=heFkiQz4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224977; x=1712829777; i=oswald.buddenhagen@gmx.de; bh=Rifiz2tzvBk5vL5iFP4v7h+O9i+ihFbVM/EJLCqOuNM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=heFkiQz4L6RjbpHR0KkfP+kxrBv5h/L9kj3TXjDYSjG4XnicJpvJLAiPucgfHEf+ zftTBAwvu8ot+39248XbDg8chvTFS/o0A/X+lzoj5T+f6qO15wib43f+cA/1FUs0E zPC994onLp6FzeE1JmsJnAMRaie8dt281+K5b5JR6svDLFthXBTrRwkM1aWEov6oS i6osCv1CMfHuOGVlrKEWr8d8IoDKjktXDKkxjXudUP+LbDTxUVfPJx7pM7+hKzVRI vDmjN1nhTkaPnUpaiflci1cyjpyyukSQ4SiA9h4T0bV2wwlqAwtdQhkTOk4489vSZ Sgn88150/7XPjCRiVw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MbzuB-1sO4ic1izX-00dVsV; Thu, 04 Apr 2024 12:02:57 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RFw-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 12/17] ALSA: emu10k1: fix wavetable offset recalculation Date: Thu, 4 Apr 2024 12:00:43 +0200 Message-ID: <20240404100048.819674-13-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:pOUdD7xcVm9jB9KUAkRGqrnAezulu590VAqRw1SLVJgX4PRhM22 KdJwtjViqE8/EdwzUjpEU42Y7sH7VuBPTWwkt0GdkhDhnLC828c8RyzxYg6IIIOj25dnK9D 6PxKqJ+GWs9sEUjEH1XxhdjWi1X/fB62J3IYWpj53iop8PvWdalhjAg4+Rwv0nNS0vm4gmI i3tRYAehBn+jSJjT5hY2w== UI-OutboundReport: notjunk:1;M01:P0:EfW1tp/gnWU=;eV4XQJCPXoUdJB03vcJHM8wtMTE 48frAg420LmYiSDGK8tzN9cs4iXuJz/fY0OEc9Bjk3LoeJvW/NyaxhnArnmdELMMaS3Hrmm0Z 6gwn0t5dzHSZVnUUO4o42G4Qie3JzMIxGdIUZNPYwVycMZUbHraDP/gehy5IZSJemyePyu771 ij/sGQBKulBgAhMPh4fycz6hOiE1OAf+v3yiQoBDKKKmLnwf/BJtgDZZSfdGMWtsTnmX6B0Hk VZ0gqdxAnXbOWHwmqIQuTmG3ujwDV56sIXuAhslTPnAUKj4rXBAom5MbpzviWmC/IVzyNj5ma SNWbSR7Fx7Mtmgt3d2gasjBXvYfkXYQ+WyNDMwGI4Jol5mstk0dMa/d1XtRhMeCsRd/7N5y4Z qbG4R4EDuwWWCif5oKrA0fYsQpstuN6NxQ3WgwO2k2LK0kV22lY+l7fMEXcFzAYpiMUE6r0es 85e5h7IKC1WNJEJHmSxJqbIIHYuJFA/DhDMA246PP0Iohi5yDLAnHEEo8X8Q+c61fbfOTR8yo M3kD+4q2jXaXHKG5ts5OilXySkbXW7wkkL7OCyJ6aZL4ajJPnHORccTJzFlZ1l6jgc1pHl5R4 COeIYP/9cUywILTtPsaSdGtU+ZECn4jhTi6r6ufrZS8g9Ahinu6RZ8tuiI1JwhZq6o0LqaZd0 qEmwKV4riuU+/s8/d6gRwxAp2z53NRrxkWqAYnBvacJQJzbofs7ro1Ke0IDwoG/5Rl75O5jY8 Mcs1lSPptjEwFWwA6SjYaVurtVWdy2juUjurLguTU8ukQySMBBSqlGnIMSdF0ZSfghm/zQ1+4 G5svPprTmwDEitmM/bv44SLk69r6utm/m5uAMGZdGrz08= Message-ID-Hash: S474I7ZDQTNAMQZ4HZUL6KD6Y55VEP7S X-Message-ID-Hash: S474I7ZDQTNAMQZ4HZUL6KD6Y55VEP7S 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 281881f7d0a4..ad16de99b800 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 Thu Apr 4 10:00:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13E42CD1292 for ; Thu, 4 Apr 2024 10:02:43 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A49262C72; Thu, 4 Apr 2024 12:02:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A49262C72 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712224960; bh=QkfNAiDSNvw4HDF9IAG3GweNjgJwMxMVQuifEYn6CBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=jE52PtMbtV8CFNquVHP3gFe2w+CntP8raTL5CHRWciOxwdtno/Gkw6IjGjaE4gpD2 GOe2ZdHTnGQ+QfOqrXctRQ8V6m9by4H8Gk7wzDeaYaBpOzsVpgLxmDJEf7ghu2gytX prUw5f+5hkV18z9osUJR7dvhrsFtu/PLx9ks6d5I= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 45D56F805B5; Thu, 4 Apr 2024 12:02:09 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id E2C3BF805AC; Thu, 4 Apr 2024 12:02:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A995FF80579; Thu, 4 Apr 2024 12:01:03 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A0078F80007 for ; Thu, 4 Apr 2024 12:00:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A0078F80007 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.a=rsa-sha256 header.s=s31663417 header.b=Kufm4905 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224851; x=1712829651; i=oswald.buddenhagen@gmx.de; bh=MIfdnOpAF4SC3w5tCHsYtBAisxAuFKXcIIE5ASAQfmg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Kufm4905F50l1lQLsLBbHqG3A/o98Ev9uWkIFtirXtxjQDAMnTCZ2wZuO85ommFK Wy92TOA2T2mHthcpXtubpOuJrP8IqrSWrFngeFJh2kd69omGqJe3qxj/HQr4yt/rV aGMGTwJ1azE6myU3IrE8J84cvmM0JucY5p7BTfWzy9Qzb5SM9JA9k2R/EQStme1Qb ogykziLsjWm07aEujrzaQYe854YIgBpJbTYicj3Ucd93xQSG5dZ22dh99tDuBVGnW WgaNlVgdK2n4cE8GAzE2I+B0+6iydhIRUrv4tIxSY2ZY6nkAEyBwmtoesTh2/DY9x Dtos+J4gSVilTWB+5Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MBm1e-1rxmUW3G8K-00C76n; Thu, 04 Apr 2024 12:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RG1-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 13/17] ALSA: emu10k1: de-duplicate size calculations for 16-bit samples Date: Thu, 4 Apr 2024 12:00:44 +0200 Message-ID: <20240404100048.819674-14-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:jZjutnPYZxsxlAkZENVGY0Cl0UP3gVaeZHGCPqb1E7rSTYXZ3Y+ TkjGunkNgtLIgijQXqDDc3DrNoe6FJ/wbC30ghnV8dhclTrVv4ID39jD9c/UP6/dD3fU9P7 IQvvcpX0bBwFiIkboWzvK4Jff+gWYsSreQNX1H9hE13cXjBLWLaF19xpqDTmK0O2eqs9sHb R3xPxk1TBkmpWayTJD/Aw== UI-OutboundReport: notjunk:1;M01:P0:O2sjyQn7NGU=;xoZp14iWUSmxdXttwuMtxrOk+Ub 7q8Yfssp9uDR2l/T4igXim3ex+ONlCTvj/aPwpQrs36jpO29jeG2CyzYy6FJmbuIOtpyTpXU2 UAfKgx8IswCb+PYfhtSOO7LKQwumeYGZl96HnIxlOpN2O6uNAJUaxv9x4+EcbkZzOkMyjQYaC u7AOnG07m5pApo0amip7FyTsULDtgFWJtT5Y/xgqGfFxu3QNQxqYE1IwZgjFu/Y4TdttVYg53 dkE1b7QEvC37Jl6meEQAstLE/tbjWaTW7jH9hUqZoTBsJ37rf8qR40AzGzZVlw/hHfj44Yeld ogsV0Uohglgw+KEIe94eLeOlbgTDYy5P3u2Dx+O0TYSjYWmOwyk3dUO+lflyW0DHinj07Rvl3 C94sgGlo3OgbXz9br20I7dMA6v4yMXkTQL1grMsFNmITq1fvqJg1ifV1msnkQE65Vs5xpkJci mncjplIihdrEKbYikQp0vqQmc6vJl+KNL+ti1lrv4I34pLNNu9wlTRteh8tdk8xYKQ8juRpmp 16m6QfzX6G3HF6PZdsX7TtltdFKJToAVq1NfDH1esSD/wQb10Xh5voxIWhwydFddFgU0wIcVI EWJD05LMNLjvMYqYUshV0Drb/tNYOZ88KKvtNkXUvvgfr0o2VR3RkP//1uvrvAvnk6Bk+s2WG 2jfp44IPe4frADWl8TOL1AOigbfNqQH7FnaNOiWi24OQLBkOR/rjjH1JQ2kjR2ET3NSwmtAwA yoiFrERl7Db1MzsU4uFEn5M4s1XEWCJfXh9M8eyZ+90kH4iNiBXaCVZki6GOKDnxaDEfLRp4E 4Vy7OHdyAppxiSFUqNEw5OlyrlpMOe/fU9NrCBUIZjIpg= Message-ID-Hash: YM4B3OYNEV46N5NZQPPO5T57JCQYJSKX X-Message-ID-Hash: YM4B3OYNEV46N5NZQPPO5T57JCQYJSKX X-MailFrom: oswald.buddenhagen@gmx.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of repeatedly checking the sample width, assign a size shift centrally. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_patch.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index ad16de99b800..481fe03fef4d 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -28,6 +28,7 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, { u8 fill; u32 xor; + int shift; int offset; int truesize, size, blocksize; struct snd_emu10k1 *emu; @@ -43,9 +44,11 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, } if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS) { + shift = 0; fill = 0x80; xor = (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_UNSIGNED) ? 0 : 0x80808080; } else { + shift = 1; fill = 0; xor = (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_UNSIGNED) ? 0x80008000 : 0; } @@ -68,9 +71,7 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, sp->v.loopend += BLANK_HEAD_SIZE; /* try to allocate a memory block */ - blocksize = truesize; - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) - blocksize *= 2; + blocksize = truesize << shift; sp->block = snd_emu10k1_synth_alloc(emu, blocksize); if (sp->block == NULL) { dev_dbg(emu->card->dev, @@ -83,16 +84,12 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, /* write blank samples at head */ offset = 0; - size = BLANK_HEAD_SIZE; - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) - size *= 2; + size = BLANK_HEAD_SIZE << shift; snd_emu10k1_synth_memset(emu, sp->block, offset, size, fill); offset += size; /* copy provided samples */ - size = sp->v.size; - if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS)) - size *= 2; + size = sp->v.size << shift; if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size, xor)) { snd_emu10k1_synth_free(emu, sp->block); sp->block = NULL; From patchwork Thu Apr 4 10:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786268 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 508F8CD1292 for ; Thu, 4 Apr 2024 10:05:01 +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 9E7992C8B; Thu, 4 Apr 2024 12:04:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9E7992C8B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225099; 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=Qx01+yBMJSH+edWr1vL3IALfjNy8hd7Z91PHIVql53AGKukq/09hn0zfBdbZPOlTe Nc3TKSD2yv9nhoWU2eKHtB2dwT/Xv4fJR+aQRoJDNz3TlON6Ebbw3ZwcvV1xKBL8Fu uvdYEiHGrOhmAmdp7NUUldZ7SObKfx1AFQtjxlDw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 08BCDF805F2; Thu, 4 Apr 2024 12:03:29 +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 E997AF8067C; Thu, 4 Apr 2024 12:03:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CF336F80578; Thu, 4 Apr 2024 12:03:24 +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 1E323F805D6 for ; Thu, 4 Apr 2024 12:03:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1E323F805D6 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=b8TvTxQh DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224976; x=1712829776; i=oswald.buddenhagen@gmx.de; bh=QbpXbcE+ZR9RSM7KyHuCqE1u/L252UQLp182kXonEls=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=b8TvTxQhpjTEGzmfTUShuAzbJg/IwGiP/UVfTNkrDMSOAV4nMQdbI/MZV9KNbueW JvX/B+gQRtO+/Bsf+RNoQHBRNXeBWJkBOfAKdnMZHfNuQJfAbPAcTZkj65X+pMOXb YFzfV2pRGCi8ADWwSymtEDDwyOxdeNLnScP+3AUMwo0W9mf4jh6VvJx0Zk62ed7LB vIeRrQf7YB1T4uqCN6bikzaOBXMFHyvMTYOTXo4HYHxgoDAGIsDZhPvNQx6tgylwX fjtj6N8ANMgGiElIcv+0jUY0urgm/gNPkU8w6pTmyQorvYDjpSZEGZBUwuTWkTvfk 8fmKyrJVn4g91u5RvQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MuUnK-1sidIw1KhG-00rcU6; Thu, 04 Apr 2024 12:02:56 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RG6-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 14/17] ALSA: emu10k1: improve cache behavior documentation Date: Thu, 4 Apr 2024 12:00:45 +0200 Message-ID: <20240404100048.819674-15-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:RShzJIdSN/XlrC4KSiDVgiWyWCtZzJvQ0gURYuFuabSmrSjofsX FsugpTaIxRckDnwwYLIPee4D8UFC6jTe/srTByo+KHysrpNarJkbQNPo33IQuxo3uzuvdpf dw1Ni0rGGd6tcbIzZTEzjeIPkyE78K7QMHp9rztY+tmApKrVzdfNgd8K8LgWFoRJO2lCC+R RC/ituEkvKenSNVJ5L/ZQ== UI-OutboundReport: notjunk:1;M01:P0:Fkc+a9lB7nI=;lr4vL+bbJFahDVn2bm0KthnkRcs OgJsf27u1dvb4W/2k7EguCdl0dV5LMRDqsNqLCyFyx4XUuWS/+CEKWfwZIzr22L+aIg8hGdZO SeBGRs5qCHDSQy6vsGSwo1f3OzH81m2udyp++Uaa3VXe2yXsl4mGav4WMpHH2F+/9jlQ3xbru qmkUHEuT7nqdrHdHfThB6uB9ngyJ5DKzhZaxw1xjrExjFUZErYQTO3uvLiuandlk2cnytL38g rroTpnNOWbBBLbbBYj0cXouCP0VD+FS/TvuT5p87Kn/pCzD/qfoAs01Qz1MKe+ZgKUPPaxo7n 6JxtGOkhOBu2/5i+JmjNoccvJ23vFA8FpqtFIpY23FIdsIyGcMIUJrFAugMAxadVBvBuS9Ehc A6jxJ98L6jItdJ6F+qW7Zo0Q0oRLesWJCNQ41/iSR2VEc/t0Pv9USRAeV0tnfekuP29A6mrEB s+HpXTTPW3lp1Ohzh77DVOzDafJxM1pLKsoMNp0A1qD+c7NXMrqvKRwq0CAQDYOpXY+aXIwG9 vFwVxTDk6IWcfUW1C0PsyhzWnBChQn69/82qxyXBWUV2Y6nwtZle9alBidmHk/hXPkmm5DbIa TBS55ndbyU8+3+G+b3sUqM7bgTUD6CF7erPjHSJj5PxaXmIgEQl0HEoQlZpiNSbYl7UYmiVa0 CO7B6GeNlclSaFjfsAaorFKV8w/Q/XrgoE2KwkQ2Pf69Mw8C1ElNjHHBoxhVt8M8RUgV/tPri 8gg6tKy1Mi7dM8fx+W4HOyu/QcMRdm/nL9HutJDYy2t8h7hnBRLRjFBsTsgD6rnPvOsd4MtGd JABWuE/UkOdwPRh3Yh+p0YOVNlU/v67ZVQcLgeVrIrZKc= Message-ID-Hash: GKYF32YZCO6QDMPFPL7GQCXNNWYQUYXI X-Message-ID-Hash: GKYF32YZCO6QDMPFPL7GQCXNNWYQUYXI 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 Thu Apr 4 10:00:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 785874 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 A7CD5CD1292 for ; Thu, 4 Apr 2024 10:04:39 +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 B436E2C85; Thu, 4 Apr 2024 12:04:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B436E2C85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225077; bh=UVaRbStp7hUjjGdyl2p8A28xU1X5HHz84M1EfTPwcXg=; 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=Sr24o75tifFcOTNgXxkmuhjM+4pwEerQvX6C4yA7Lqje/Y42xx6Ry6yrtq0iuC3ti VgHkmCbGa3l2RA1BFDRlgh9z8uHEKK1BooJKOTn+2JUxW9AizK3uAeSL1FeIO8jyLE 8+qnPCCPRTVZQL7NMVzJXV0xWL2JU3Yl2lQBH+gI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C8E80F805E6; Thu, 4 Apr 2024 12:03:26 +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 01AD2F805EF; Thu, 4 Apr 2024 12:03:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8B086F805CB; Thu, 4 Apr 2024 12:03:20 +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 57A8BF805C3 for ; Thu, 4 Apr 2024 12:03:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 57A8BF805C3 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=nISaqBOs DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224978; x=1712829778; i=oswald.buddenhagen@gmx.de; bh=xQbIjFYLrIebpq0KXYLOANYrTHMgZbtxlkCRs6zkRSk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=nISaqBOszsfRfaZVSjqj3sIrwd33eZuHAqQhZTocIiJodh+tyvvFFQ5wNdEvDmup 4Zed7JahkurWLuaAF3ZJ3w+bHIizOJvYD7OX+jYk5d05lHKXtWYzdqR6WEg9/UIMT cCJxwWgXUSB5eo75+1zv7vU687nyOtCnsUSlQ3FlLv7oJ0oWRDn1ZUOAsX3l5Yf7Q eKZWqgSZQyzp+3vZoqZirbe0bOujHiU4eecQx5vgiF1yZKvKdRrD9EwIRzYj3s1cu NrlcaSEJLJMcTw9rwObrxMJtOyf3jlP7xOPDGmTpvZT6Yee+V/jWjaNVqZMvfl2n5 jE9z/bkqErgcjvoC1w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M7b2T-1rtfuW3V77-0080bl; Thu, 04 Apr 2024 12:02:57 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RGB-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 15/17] ALSA: emu10k1: fix wavetable playback position and caching, take 2 Date: Thu, 4 Apr 2024 12:00:46 +0200 Message-ID: <20240404100048.819674-16-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:tr87jKOq6VdhwboNFWnkw/9G95FOaxyKvtEKdzYtyeUyeOyzbDK tJ8B5nOELsHgGgcNf1H1uwSCIRNOQrItyWDAFyKT15PGAP27J/9Zxbswe0iKpZ4wA6rEL7A uX/lP4NfRPJ1m3nMxNwQgjYlVSbZuM1DZjQ7cj4ysm2pkgHtJUo3p+u86DeZlN0P0Z5P5gL qMH2xpzZ2kmrOJYHMSgeg== UI-OutboundReport: notjunk:1;M01:P0:v4cfGg9Sgdo=;ol6KXKETxqzy4wxex25peJKH1M6 5VNB1iI06ePmR9FwFyeHR79+zGhRgId2h2vJdGL5U0+MwReibBqwRiNUtulyv4EU1FyTm/mAW hwQk2M7V4XWqOoPL+t6QCohshhghOgdIjh8+fDvE2a7p4HCtdcQwLx2X8Vq0dqH+sS9f5vxMg eNhlt6j2IzR8bhUwpHI46xx4POPjWJmdqWHBH1PIuVR2W5AubB9Xxd4XiYBFcIgmHIwHU3XnD VnXivdyiQnVZ/Q1uZf3h4BmBCW1Za8PHqsw5L6mZ20tItP1jx4le+r0XjfqXzsGEPR+wS9ahZ 0lMBOwQ856L2s55v9Fx5qtj0iTguqjyXObloX3+rLMZVoMmqGY8Q+mye60zJYJ5Ez4u4m03En YWZ9Y0S6FgW5LJjhJhbOHglywYGvi+KCUywRNk8bXUxgkbEKynMp8zgbjTBbG5jAHfW56+vQZ 5IrKgrdAkwV4MoEbEND91NxlBTzr1LRySNdzsZ1/R0KMqVZCt/wBy6g0U7pfPHDkDLWl6i5hI fODXD4nt8/TSeXfRffdKtuWpePB+kcaMpK+wWfZbwCl+0cUIxQ0tVDY/43OKdDe1pONYOR/wK AwVOFp6sYR9WMIZivoNROgOlqunzZrXLk4QGfv7mujdvaFkD2YpHa+lhZ/lf84mOy9pM5YHp3 kumvQjNc49ngk5MuNQpYkznLJy/Rpw8e4h+ByT13OuDp7fZJfuyb26zvb/y2Q1/KObpeFH//0 TT519JMC+s1IqWKdQ8orFiRdfYvoO4FN/IO74M3Vct/3SnrG5gezlmkO+67tNFs0PuYJC+aY/ uEd6gJQDqX3YPuTRut8Z/xOrVyWUb6mj78gn0jYw8+6l8= Message-ID-Hash: OD6XUHJ64QWDTX37SDIJ6NL2PO3LKT5O X-Message-ID-Hash: OD6XUHJ64QWDTX37SDIJ6NL2PO3LKT5O 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: Compensate for the cache lag of 64 frames, and actually populate the cache. Without these, the playback would start with garbage (which would be (mostly?) masqueraded by the note's attack phase). Note that we set the starting address only 61 frames ahead, to compensate for the interpolator's epsilon. Unlike for PCM playback, we don't even need to manually silence-fill the first frames in the cache, because we insert some silence in front of each sample anyway. A challenge are extremely short samples with a loop end below the cache size, because a) we'd have to wrap the current address to be within the loop and b) automatic pre-filling of the cache with the right data does not work in this case. 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, we 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). Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_callback.c | 7 ++-- sound/pci/emu10k1/emu10k1_patch.c | 53 +++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 7 deletions(-) -- 2.42.0.419.g70bf8a5751 diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c index 5f6c47cbb809..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); + 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; + addr = vp->reg.start + 64 - 3; temp = vp->reg.parm.filterQ; ccca = (temp << 28) | addr; if (vp->apitch < 0xe400) @@ -432,6 +432,9 @@ start_voice(struct snd_emux_voice *vp) /* Q & current address (Q 4bit value, MSB) */ CCCA, ccca, + /* cache */ + CCR, REG_VAL_PUT(CCR_CACHEINVALIDSIZE, 64), + /* reset volume */ VTFT, vtarget | vp->ftarget, CVCF, vtarget | CVCF_CURRENTFILTER_MASK, diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index 481fe03fef4d..2a13fb32c1d2 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 Thu Apr 4 10:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786266 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 2F822CD1284 for ; Thu, 4 Apr 2024 10:06:01 +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 74E082CA3; Thu, 4 Apr 2024 12:05:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 74E082CA3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225159; bh=ptunjXYqX4p7CWPV8NdSfujnriOUxut6Sa5rdWHF1JI=; 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=ZskOuq+R2kgRffs3JW93Zh2yE0aKci1hoboaq9t/sRuXDhlxptg7rQlnTb3svnWfP H6CSVDRZlcGBkmaNcnQxWKJHDBM3NEqc6nBoz5uMwaC3w/3GgwfO3xVFfj9W0m/vAi yOFB6S1XW+NMLzFYf7pGpz3K8gDyEOyS4BS/Z6sI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9F000F806E3; Thu, 4 Apr 2024 12:03: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 E3D02F806E8; Thu, 4 Apr 2024 12:03:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 17972F806AA; Thu, 4 Apr 2024 12:03:40 +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 53726F80570 for ; Thu, 4 Apr 2024 12:03:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 53726F80570 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=H9Hl6hqt DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224976; x=1712829776; i=oswald.buddenhagen@gmx.de; bh=i5SGJFWlFLgQYFLfk9ipHeSb5dL2GEn/l3xvsB3Xb7A=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=H9Hl6hqtIHJU6iF9/6aB0+IkT7dZIYwq5V8Lvv8HA/n/UTgePVYszdKa3vUaPF2q PWBMl1CW/BaJj9gRlGDMiCK5/XwzXx7Xw8A8h2g1ajwgkb05J+k8WqNx0+WwDGZVL VFvfzlfI3BL2HaXBYW8n7OYlfVE50iyvSMVO8dZxOLeL47E0UBiG+hh0vQ0y5+3x+ UBy8SnpP/2UcYEGJyth39kOzYXlOO7zrxxH8t/1aBnK6fiOnPl+xUMBY9BxAwVr2k ei8t2WCfU1egeEkZjZEL9rKzyugrkrA8r7L4rq5ek18mN4eWlfhETZ3m3ihNtNdND nAeylXcwHUsEAtRngw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MowKc-1sawl40U9O-00qO2A; Thu, 04 Apr 2024 12:02:56 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RGG-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 16/17] ALSA: emu10k1: shrink blank space in front of wavetable samples Date: Thu, 4 Apr 2024 12:00:47 +0200 Message-ID: <20240404100048.819674-17-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:c33L9W2v3XazVATdDNOtxDx6aezhkm44UNHjw78H6vfJlzxYy25 pCYER/8vG1VOpFhuCa9XucuNq2HkQ/EtG+k5k2Nrgu+oxfFPkuOYVXas2NXQCR7twtSVzkN 5RYVAUCtOds3o93IrXCfOLfYK5HGfz0VSWucvC4By93+i9DpLGhL2r5p+/nZNFMl63RV/ZF f/fVQq8Yiq2NJ6S9/gVgA== UI-OutboundReport: notjunk:1;M01:P0:QDGEL0Scoh4=;QZpvas9D0Eet9//huWKGKAQ9cWf pMtpP3lyQddWdQviS2iab5OXKZqcACC+ZB0tUXqBUybszjzMkuaDm+SicRvFEAQVMw14JwJ2P qKgoZ5sVePuf56Koazg/ADHsuGkOd/JfyYfR1m4jtYtd8zFKw90EfptoAdNGaw9F9ylaD8Jkj 7YarMGEDGqCwrj8ddqwsPcigWbo0tT583zDfnB/NO1Sjf2X8HQkn4vvBqMouhre59LtaX7M2b U/K8TCvxejYbcg6cgYTD/L8b898jnJhgjrXtCpSShumI4NnOo3reDWgcnxCes2yU13D1s11Sf fA7Wy+1/3z5x0Qn7AwRvD/csEAZC+r3KEc+gDvllJZJejIRHLzVzZelp1emdg9erqJgAdRFhc mUqMw4ilytSx9nBvVPmvkw9Ep1YIs/2avn4L0AFo/Hb1RzSTu7MlgPmHwOa2mL4fTNbGPcJlj GifDpm8YBVqLUeLRZZDLxj7bYn/UqOSMnxxZTkQqm7676CE2UlLI/JEenWqt1EHaswWhYBxvY kmKizxORzFR3HRlVRIGQWCnOvn05jPx7vSI6opVRm9ndTEnqbCRsBWCukWxJlGcerA4wPJgr+ HfuJAmihQ6yEqeVJ1y18BCJDvl0VB9IWKizbvAcSAeXqFr6TgiYrc9pZry7xCsff7jVSHYXhf vuSqkBMHQ+U+g+og4Nk4T/EDYMw3FRhcYPOeAl61KRkGp85tW+12iIm8XZ/k6um/4EdNXfiKz LIvbvGiHM2+aEt96ad86KtsW9Dvq/JfrVAPBMxdVKUzVgxgGIuM7ysIg9U1AdJIzkRzEysFWm fRc2YD49ndoZKVIb2F9IBkM28h4H4ABP2driEXsGdGRBA= Message-ID-Hash: 6IBVRRSNQT32XDTY5ON56A7XILJXH47M X-Message-ID-Hash: 6IBVRRSNQT32XDTY5ON56A7XILJXH47M 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 2a13fb32c1d2..dbfa89435ac2 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 Thu Apr 4 10:00:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786267 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 51A2CCD1292 for ; Thu, 4 Apr 2024 10:05:30 +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 A7AB92CB2; Thu, 4 Apr 2024 12:05:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A7AB92CB2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712225128; 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=q3QDSOqnqCd8NZ5Og2+zkCiFj0ZzfDHN5g4qzjSqPXgxrvAFxpLobFDn0Lxxd1WJm ErLtQdzvbPfUv6hCg2aANN6Lb2//G6yHas9CpbJ3l/o35438tGt1fYw2swHwOoyJdd vJZD33DqYLEyX4o5MMC5Dw4ubAQtZVmR7UEePeZQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1A535F806B5; Thu, 4 Apr 2024 12:03: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 79A6AF806B2; Thu, 4 Apr 2024 12:03:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 691CFF805D2; Thu, 4 Apr 2024 12:03:34 +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 CAF5EF805D5 for ; Thu, 4 Apr 2024 12:03:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CAF5EF805D5 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=lga2SKAm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712224978; x=1712829778; i=oswald.buddenhagen@gmx.de; bh=MUOivZ7Cu3IgAolz222zrK5VXW8zypYQVAP8txCHrVw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=lga2SKAmYxCpdoFK8gcu+FYaY8UaOB3eLh4He8wc8wDboUUVpYPFoNyfKrdycLUH m3iotnNidIyD1JIxkTmKDBDuKFsivreGAVY2W11uNnRLeTeq2YBeXFLwGXDkFvbwU SprJbHKsUsuqKieGdmxt9qQiMySDCWsY54HTSzmfIeSeh7CbLEpzqv5s0oXFbNEnQ 4xVgycOaTlK6v8CMOK/4i4RPfdFuzF0IcDXe/qwJBadJS1Vme3ZDH1dkRbggvdYeD 8aaJX50xcspgBFtsXsQxNiK8O6H53DQHpTwg2HyumDfd88PcjnB9NOy9DexoafMuL V/iFEtHr4uIvsGJMcw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.126]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MEm27-1s2z3B0ECR-00GEKp; Thu, 04 Apr 2024 12:02:58 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rsJto-RGL-00; Thu, 04 Apr 2024 12:00:48 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v2 17/17] ALSA: emux: simplify snd_sf_list.callback handling Date: Thu, 4 Apr 2024 12:00:48 +0200 Message-ID: <20240404100048.819674-18-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.42.0.419.g70bf8a5751 In-Reply-To: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> References: <20240404100048.819674-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:MCMfKnoV/bK7BfAeOwOPkyphksOyanzWAdq0F7eCAipYbNeWT67 okxEigcOemaXDUyHIfbdpuxBxr5VJRrtfCJeGB6aT8lYLrzVukZNNqiS1ke9dmpIwhGlx/r W37cTfqJE0W5HkratL0ly++LS/Tvo0KfmlvsvdHUuQgx0HR5DD5ZeFsau7NNupmCeDzTY9e L8m3ekRqcUcgebD/DhksQ== UI-OutboundReport: notjunk:1;M01:P0:Gc7z00Buc3c=;kE+IuqjF2FpDsoxfMnZcup1Xip7 +Yy/3k4AtK7YIunCvWhv4VqZqpxdZ+1SNytpug5QePlMAT6ijuyT0AOtmok0jyaxV53XlI5de 0kxBfiyV5Zx4/xZjwxAAeb+EfPZ3Yw4XQeYdK1oc/xZBCvaX1TM3bbT7YBKtQbcL3SZPV1qo8 a0jNOqLVU/kP/PE1upBfPVGjeMjG+wBWn5mOomr5SJknAbwXF3R0qa7E69uul2V/QQUvUCfmE LoQb/lmoGqor8PTNgGxK7HHKqpdrGRYhox1me2CcexsgG5MzdnhIO0C6GlhePMgnp5A8h2+rl ZhD57BPx+WAEHPL4gm0muteONRmMKaxgADVZC/UYp4LhVVpWysLgyoPtIpxdA8BeQGKFoFtSt XQGd2B4Q1pVuPESJPxC3RyHJMBGCl5jqVg1WRTKXOtW+UM8icnB84fgpOx67WUG8HjVqr8BhV dqY3FZGmKCG6ReKMuenOC/4ldtoGHe+MCVv24om+5KGFuGUHFdcBX8rzZ+P84eAOAIheooo2F OHQnt1ltlrgQ/FrBkDNPZ2I+KyM4FMZzmSCJKYLZKw2KMx6mtJ13TbqU7J/VGs7y8GlG1V454 fx6GQqlp3oO+GdZcT2Cih2vbOD2luZvBtlD2wNbU5qfVZrOyEB0jdl3PzuteVwYUrVzaAMUHo Hi6QmgsNQSDEEMCfx9gZ9K8D3tCWO1XK8caEaF3B8g806azpV9IVHFyDbtX00n2fMqeW0ImUe 5l8ALqZz1c4kNeiwc4ioDD7P4gIS0M1ek3+uG/HO25Mtn4DKq1owAINh6Wv8sMBOX22nBw4lf WXYV4/ftLpucAZ3GfqeJ8ttbpw6f+jKOOVwFYtbAqq7Q0= Message-ID-Hash: ATC3MSFZ33OTE6MNPUETTA3GWJZTWESN X-Message-ID-Hash: ATC3MSFZ33OTE6MNPUETTA3GWJZTWESN 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); } }