From patchwork Sat Apr 6 06:48:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786734 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 1678FCD128A for ; Sat, 6 Apr 2024 06:53:55 +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 BD81F2D1A; Sat, 6 Apr 2024 08:53:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BD81F2D1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712386433; bh=b9NU+IoPft5NMYDWxh1oqo91o5gSbghKURjiIckXI1Y=; 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=q5zxoVcYApRcKTmpfCCtwvetJuEvp6eDxVH1BZN2rGvS6e7XvqZTpZRk6D4Z2pr2C Vv9xT0eq3DAJe4sPyiZ91eT4m9ue5YdN4UPegdmELjCc7+sCh4A7mponuD8mdUqgfH QA/n1EpJmoD/09bpeGUbOl6djRUOg/PdPSNXnmGw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D5F97F805C8; Sat, 6 Apr 2024 08:53:08 +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 50527F805D2; Sat, 6 Apr 2024 08:53:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 33395F80579; Sat, 6 Apr 2024 08:48:59 +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 1F933F8015B for ; Sat, 6 Apr 2024 08:48:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1F933F8015B 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=Cf9kQyhi DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386113; x=1712990913; i=oswald.buddenhagen@gmx.de; bh=X24AK1KIcPQKPmxtllvKqjXta1IbOjB0Eg3I0W6YMic=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Cf9kQyhiYICLXVBDZ03zoVQEmX/CcL5W1Vkirv9HOXq+FVkfEGF5+fwggDZlhHat x4fFu66a209RSZ+okhcNnD/TQ+fmvi1UqAkjgzlmwBdI/KeigKzwTJdrcXKBawuD7 hrUm0gjwIGrQbYTFZ65ppqn3lHb6Lin2bT8i7yGT5PTOAtax6AuBCBUpBCS2Ivoba lrDijGntgGMz6aS01bLqtxginfQW3W6uRvuH//K4V/RiQCZdgtD3oVHOM0O9PsPI+ ue7fqc4yX3ZEe0RuQK+PiDJtVA30XehGTuVLeZariKNVC95WhgwK8yAW5RcZ2f5r9 fjAOuzv2yBQx1cyjfw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N6KUd-1sqQ7D38av-016h7R; Sat, 06 Apr 2024 08:48:33 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-JqW-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 01/17] ALSA: emux: fix /proc teardown at module unload Date: Sat, 6 Apr 2024 08:48:14 +0200 Message-ID: <20240406064830.1029573-2-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:77DVNGq1Kj+ik+SAHMGC58pXPZKQR435JSbnv7VsgAcpkVmvZSE kv6JSmddjoo2PFEOYWlpCngor/gQJmOZeE8dcRLIbsBOACJa4OcOk2li1hdavGejyV+/lOp 3drYI3aejMGH83Xdf1jk7YDu+iyNZoZywNJBtiW48PFcmKxyX8/zKAugBO8xdlLMDetaTkE NiRwnONbXXhMR3KA967Qg== UI-OutboundReport: notjunk:1;M01:P0:F7iMyTDUX1w=;HYH+GvIPzL+enXdgIqgPS+Yfg90 WOHvruMh5QapRc7fBHuXs41ZTNBXzy+rf4Aq1lqJ6bBZRhIUVIHt6a6uHE2/OR2B1lIE9bFu+ kS5UYYj+V/ScrTZRtfBg4ZZ1hVyeE13WcnYN+wHgSl9OF6aczd+b6JNWaC294iscnq46ApT7N 94ryF68KrukP9CGCHQMYplj6SU/aMBIPNCcZvCxCCuG31zXMQaeR5UBXvtH6z9If0NjET0BFA RmrJpv22a4fOEg7QtlF2qYXqfwQ+UD+XQve+GM3ROhx7Rar3IFG9ALZ3UnkhPlF+PJsgBubyd fhapXw3oC0Ku/QOyYP+NAzoBozlCq5y2916si1jCEgdq5Y3TMXJZitRWuf8SSycVH472ePDp3 T4oF2s2CDSB/OborJ1po6vDpJdCHvcFadEWbU/tdfpHtGYjRi5WGvdKWEQb1BFnZz9fjgvmOp 2mCgiuBzzgDKCk9a1bg5aZxQSNoFIOa76nB8sBT7uegg44f2qWGepT6nnQWDdoDNsASTLh4vw g1RAzw26R3s/SyBLwdqCQ1rbzNXAx8Q9adC6zQ3hssg1poEYDWq6LJ0Rj+zVAlTn66k2aDQ+L ATRDtdzyzizBZm7E1YHhImoACxNZfz0JeN/ZpxPiZKntUQeVwJFS3CALMj/BkAMh3s7hZQPC+ Nah764S/0YyPJbXmPwyOGVuxSiw1ZT/Sb7+YQYGWjao4O9RMf6zc/YbeYv4bejP5lp6AAWa68 uGPhICc47o/GOZV5pu78FHO+iDK6nbpPCxYYKoc8YkqyO3nyZx0VAYoFLSxx6IUtg6DNcdnjp ZAcehBLS5QvMYKzN9Jd+AXdXJ6zDMfdJN1uc7ny7leIwM= Message-ID-Hash: YK4MXV6SF4UR2DPCBDIY2ZBCH5QB4SGB X-Message-ID-Hash: YK4MXV6SF4UR2DPCBDIY2ZBCH5QB4SGB 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(+) 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 Sat Apr 6 06:48:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786505 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 C3C74C67861 for ; Sat, 6 Apr 2024 06:54:07 +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 9CC0D2D16; Sat, 6 Apr 2024 08:53:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9CC0D2D16 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712386445; bh=W1q0ORYEUy1ngm+KQcSVJa1wB90nH90F5UPFzkDKfXA=; 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=op6PW9mRsgE6ZEvdCvZUTbfchHblMOciwNFQGxngLSIHcFH2mW1Y2yiKdi3AXX8zJ ua/pamo8NfD8ltNE1Al0nNTkMgxISS+QZ1/eNUwFRW6gdPIMxg+R9yFMC1T1OsSo8d c1B55VNxxTYiKXamuuUkEXu1xk7NTOPj3MBIjF0Q= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D3452F805FC; Sat, 6 Apr 2024 08:53:10 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 9B260F805FA; Sat, 6 Apr 2024 08:53:09 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1EBD2F80578; Sat, 6 Apr 2024 08:49:13 +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 8693CF80114 for ; Sat, 6 Apr 2024 08:48:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8693CF80114 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=VhA9cLV8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386113; x=1712990913; i=oswald.buddenhagen@gmx.de; bh=mCiF/7y5sPx+hhSFI7OtFyOT6jvTkqkO+OyMmEn0OYY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=VhA9cLV8gBqEzUTh8o9qpnsk0gh4Lb2/S1tM0uK46oBT7CwgkW4ZK2lle2No9S8c QJPzL/bCMwyw4BfuEKzRZuyPhza7QugwGraZoWTmYFrZqGPJNkSB532WVbcWdjta/ tlUIY0JLmdi+CRe5zQ88sFE+b1+kNS1atfdMYd6fXWv2hKkmN70+CRW26W9Oc4KHW XbPgMywgM4JxImrjTCsnbIqYYS7yWnzr+qPh9NYYlku08cW5DAl6fckq42qUTgB2K 1WiomOgLvfwQhQQ69dBAc7tccZ1ZOTrNl2k/oRlL0EHov+4UBgbXuLhWmFXQ+D7zG Fk2MrsA791IC+BqhCg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mr9Fs-1sY3su3Ahy-00oCt2; Sat, 06 Apr 2024 08:48:33 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jqb-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 02/17] ALSA: emux: prune unused parameter from snd_soundfont_load_guspatch() Date: Sat, 6 Apr 2024 08:48:15 +0200 Message-ID: <20240406064830.1029573-3-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:yuUhBpK4Ba6OLiTP7mkFMPbHP/xv40Z21hZSPGwVyLqR8bnrkPN JbFifVGPc3jv5bf5QDYpbOiS/5lbVWv0M4i++o99NNBTKilYPsPT/gz5z0Cr0Qo4flgBQiw mVxNc7Wa17KjOE4e+P8pbvHcpwOK4PkI/FT86imHbqcQfIZm01jj/8PCkVpkxFd9g0hrQbN 59NT9QDP0pAoQ+idYhs9A== UI-OutboundReport: notjunk:1;M01:P0:qGk/bqhzG4c=;YNGQ34YrUteBnejP63kBaptJevS /R9fDGjOd3YnK3GPwA5FCzzHqz0840d/gLX3XOLuadg/t2aI3k7rfWlBVFOqM0fJGkpIZ+ELT bhTS7IW1C3/O5XLSQPmCzcOIl/SvtQ5n0H1B47Vma8pjRT79R1GiGmzGqupb1mbzINA9tKkqu PRn8hoRIRbt7FUvznJoUO2Qv3VYOvDI15Hi4b9yJlKX/JTzsIihWZWbXVgX8Ml1+UePin2yrK 489RXlKVkU+6n8ZbFhnUl2n3wl42uBtasfsN1jzjCWGpFNyx/m/Wk5sfrYGOAGH/U4BrFve0a 8hudgF/LpO1qzhA/JX4KIB6mgDb5RWVRUgyDt45jyiB2SeIU+n7cB+5Qb7UX5izy4iPOvg1c3 +EoR4nNkL7ULp5lE/WdRaQsp5Mtatz517SbCLqfRGLnZ+x65TN3GRSOgCmkgXLdAd+7l/nu6O IaWex6V08OL0PZUDw+YyHXWll2KT0rNA1TePyrSAZP7nZG10qVT/BBkkt2GWZbKKddOQd3kZJ gorF+mTPc8/VA4HdyB/sTQF5dVutCjzRdwkm1NFsfjrMVIArpHY+JmA7tUIXhxyCPVeWszNZv Mu7XSngKSVdVfBcEo9qKhmogj2RWs785Ix0uae1/tGVWmrPeffkiv6sBgGOEECf2hWahL93Pk scpbvE0Y1EZDaNNwELMCB/pXj10XNXwhArPMdlyrS9/JQf+ZRot70YiWP0ZO/C8M/WZ+rPjLA oCVNeEsGP7kSr6y8MjA4K99dluv60aMR2cmKxbe0AQxJ/zCPnC3TuWA067qibX+keY9p7QpYT Z3baKP8/12L5T/kfaGBsWEbD2cClKIRI2kAm1acRhJ9PA= Message-ID-Hash: JXKQLT6Z6FITVOEMFJUBA6IA6N2CRTBL X-Message-ID-Hash: JXKQLT6Z6FITVOEMFJUBA6IA6N2CRTBL 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(-) 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 Sat Apr 6 06:48:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786731 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 D386ECD128A for ; Sat, 6 Apr 2024 07:11: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 684632D1A; Sat, 6 Apr 2024 09:11:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 684632D1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387514; bh=RTIDtrrNxRu6jF02BCUn9VGQIZeM+xPk9ksaRegnfJU=; 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=NnGFzEhCDLEHKixXtusHuVq04gSptk8sfnHF70QpJ3xFFIN21ZewrJHz92F5C9lSz 3paVRGRhkNU3N3s1BsgD/ykYqlmVcKnqwHTsHhnyCbL75Y2SgM+jD0lqVfvQi5uVY9 dWVzyPebOyAQL7tnDzMK7Ub9jmDTqIImDzdgnT2A= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3C72BF8059F; Sat, 6 Apr 2024 09:11:35 +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 227A7F805BD; Sat, 6 Apr 2024 09:11:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 26CD7F80238; Sat, 6 Apr 2024 08:51:40 +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 443F4F8055C for ; Sat, 6 Apr 2024 08:48:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 443F4F8055C 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=rv8Nub56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386111; x=1712990911; i=oswald.buddenhagen@gmx.de; bh=JMiNQoU3MTZPWgno5imqbi9Pn68+reNg8u1rCr8bsnQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=rv8Nub56i8TlMHGflKCarhofaTtKYY0Nekg7c/QZacEuigBSi38y+KMqJsWkfDTB OVMgweouRqJpHK0KophFQJHsAvZSw7qwYOHazZr9oCq142Ta5hPXFxv62qIzNZuTt xZYfAGwbXGOcKlAyB4BfHpHAMXTIswjghBXD8EQ6nU2wj+7YZ6xkPi8GEfWcV50OO 7HquSLZ8Iv603rX7MrIFyBKYyt/ZFUBrx9MMkMaUetigJ4rHrVOfKTgT+V05hSX4k CX8tXP6ct/xefkAcBm8rc4MYHceJsIT+Arcv+BPOeiX724YFaCFW2ZhLA4fLpbb+7 CTWWr6NbdS9rT6ykbg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MiacH-1sPZZg0SXf-00fkKu; Sat, 06 Apr 2024 08:48:31 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jqg-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 03/17] ALSA: emux: fix validation of snd_emux.num_ports Date: Sat, 6 Apr 2024 08:48:16 +0200 Message-ID: <20240406064830.1029573-4-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:p26TYhehDN2NOWFykYeYSUuCLETmm9o1WWsEHZ0UWpT8QuJSY/8 0Yr2L+RQS2nAucVURcpHQZUbPgUUV6MuYO2q3f8Ri6GJSQEnodKDRRjqCYQuyT/wMBP59lI nEgqWTRUbCmISvdeSzL2kzPeLQgkvU6x7MSKuv/1Fp4pKcZfKGqDRLWh1UMTic/Ktv8B2GS HqhhkgxAScHc8GwI0hp/w== UI-OutboundReport: notjunk:1;M01:P0:pGQrY4j9Kz0=;GICSpBejhiuN6IX96osWHhncYR5 x/twZP4hn3TemiZ95O1p6pL5M/q29ypOlsUAL73N7ak6szDqIOcXAd9CogXBpBQGjqgiyE+M0 FwsDo0zI5uvvDXN2n78/6vTOhsSxWpAE8+XFztrUFfh6kLgEuv5Xv5Tm/3e5RMrb39s/zYyvL 6d90fy8YgIHfffe3Lp+fahblBA/CgaCWuzH90VsjBGLCYHWpt2qqRnMeGUDgG0tBJd5LTjfu/ UUZTbGx+8kHJJY7jHnzs3yPJDX51JbjJT4+JPcshKMt9l4HalHTm/qv/xUAIoOy/MZk1JWrMd 5Y3GQI3XJfr/GgHp3bJJY7FMdN5Z/nzy5yAK4uSzVMhZceUV91KTN2H+cdVUpWqdLXmT1L59D zMWQyVfSJVsfNGlhRFyOYeYlcjPI4QADWoVHzPFlI9zC/gPhrauMO670dq2FOnsN25Tjh3YCU Py77lYvbKsgtrsXF/FOQYZbA481wVtdAwTZv2SbcD/71dejhO2hZZhZTt2sGEih0DytYYKBUK JQYRFUePyyhysZwmDU5iIN2ZYbdllK8A7jYmrAjqqCm7y8tB9QkbyMhrsFRoii9pkJ2qkuMV/ oosm7c11sAxUZlv1j2ovI/0+iGirH1VW2ZgbhTBsBPgHJL1NycjH7xUtCMcvgWbAlKEn25/s/ w5qEMD0odnQ2JDRHIShTSlhNia9jFFX4vjypDILqVzMsKopL3LACgf0t2AZO2i7niUTGKi+qo 4OnlzBpPvarRSgXwbexDXlZj4tvz+Xo32dzS0n5aLfk4qN1P0XAjl5MIWDdSIGfnhIAcxfxeO 6TEKL634RUMyyICutj0HQwwivDUb8rXDXXuOC1y6d0uLk= Message-ID-Hash: 7EQ5LMQMB7JWXYOFA7FM4MAOZZHVHE3Z X-Message-ID-Hash: 7EQ5LMQMB7JWXYOFA7FM4MAOZZHVHE3Z 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(-) 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 Sat Apr 6 06:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786502 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 5DDC4C67861 for ; Sat, 6 Apr 2024 07:16:00 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C0B862D3A; Sat, 6 Apr 2024 09:15:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C0B862D3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387758; bh=vSdStWXaMF2AmqNZgs9LSwDod9v0StxfAyEnlvsdI50=; 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=Rnd2HOJ47Sh3hgf+RS8XALZoeF/40foy6eaAPm0ptO/215Kxdu4fIzG7gbRodlLa2 Bl8PELl1XP+3l7aBcKKQYO26UIV+kvX9Qgk6Bh5swE1qCZ7rADtNh45pF/dIzRL78D qBsEIJ8z9urummzFoeU3mMwKGg+SlHU4jKRjEhqk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id ADF10F805AA; Sat, 6 Apr 2024 09:15:28 +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 33D9FF80570; Sat, 6 Apr 2024 09:15:27 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 29C03F8020D; Sat, 6 Apr 2024 08:51:40 +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 16F9EF80238 for ; Sat, 6 Apr 2024 08:48:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 16F9EF80238 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=d1Bjq8ul DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386113; x=1712990913; i=oswald.buddenhagen@gmx.de; bh=+L+guLsNZhLsW1/pGV/mleHLAA8DCmUh3bYNY/pzew4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=d1Bjq8ulg4DEFXdQRmaBSg9luqwM3FWNe+MZmjlINZKCn+QFAEjLhKwIYodGJHg8 79nwnn8kVF9k3syHya5FSuY685bLKViBm+amqvc+z59TUDMQZklK5zrwz1moS1htU /Bcfl5jIt7PXKX8d/OQCC3EeDy3cI95grfdmy27jr3RcwZi5kyV8m7aziUoH+TzMZ r9+oInTSEaHug2WON8E8BCbe2b07Dh4wuqUSIPW8wXfRrSmfA3DdyrHt5Ts4F93jR 3narzZ7TX6yHE8ituUHhxsAq6+aV05ZoKRmmnjcX1ym8DXHB6oF014K89E/9ec67m m1ezBtoNLKv+Q9+LQQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MLiCo-1sAWje3FCq-00HhoU; Sat, 06 Apr 2024 08:48:33 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jql-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 04/17] ALSA: emux: fix init of patch_info.truesize in load_data() Date: Sat, 6 Apr 2024 08:48:17 +0200 Message-ID: <20240406064830.1029573-5-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:tYges1QnxTuElXmOCdxnzUAlgas9EAQk7u/rywiVm2411Idot7F gjBepBZyEOcpKAb5uWP94s1AJux4ciwrd+VlwhEM3l49bBqJfTsRrLDFvpKMsMqqkte9CmG eAyJDrw6HWHFUOxosaRWIgaeOmmn9NmSqZFVeOPrLc91aZJRxXNkO2UWk9fURUxv84pLvG9 TGchMl76KsN7yjzT9UWKA== UI-OutboundReport: notjunk:1;M01:P0:qdL6WnzOZ9w=;tguPp1/1KFE4VtkLkAyifk0K3FU T+Xzpwcd0ojXCa6fg/g1bmIMZqV0sceW9nZWSKMoc37jyy82Pj+q2kQDAN7mzGb2E9iO4UOiU Wk2rTYE8OZytADPITioMge0QY2GzhQ8xZgWi0lKSSzOPa8JnWNj48kAdxzpuMblCk/54T5B6t e0Oy5ok5wlz4/NxvvgOPkrv/TkdmiJ7Ro5SxMwbN5Rcq7s8CPamCP4awuhMupUS/UMhRIawic q77m84Lim9v9WSnlOPYUnQpaT4yUStsd3oYUAEHGuMq0hp0wGa1JtTWMiO+9F+0x0YPj77KWp WhMDvwVFkzziwmXrO6vj6ZnRn3ciwjvq6FGPxkkmMDUvTF0FzWO7ywQ8BfBytQD5BjOekZmDt CtW9IRvbdVD8oz7imXJPsNzyx0CnOp0dDsAZYmMPOpqyp2CAc9jmnf9XxXrX898p1JBT5pX9e PDaoyYcX4VF6mN4c57R6XrX9UGWXB6HX7V4S+1houcplGkV3VHCXiVQWnlDYSpB4VORiE+EJQ drKCWFmzrX3Sj+aMZ1jM4p0uG2ZOhLc07ktP5owS6SHW+YwU++k+OcMnv610tFTgKOEsd9+6+ MMZP0ZasshDlvu8MnD7aq1uyTqFAta6m743fJkc1jbl43Bw3wXu8fkIiNEyMcxQtzL082/Y1K e6mgK1+e0mDlxy8gMhhk2fupb7ZM61fkHnWFlSRSgd3QGpM8w0Bl5Ve+4SU6AVvel0LybAz/I PSPY91cQCa9/9S4+NkPc9lfXax8BPM8kjCNwqaDwYYSS9aUBFz3DSjZpjXO5SjDDRKTUCHCSu Yft89w5T9Km1SlwT2Al7QftaixvjzpRPlmavWFH02qlBY= Message-ID-Hash: 4RHOQCZ7K4DSCQYCNLX543QFWPZSXCGA X-Message-ID-Hash: 4RHOQCZ7K4DSCQYCNLX543QFWPZSXCGA 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(-) 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 Sat Apr 6 06:48:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786732 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 7B066C67861 for ; Sat, 6 Apr 2024 07:10:10 +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 AEE3C2CF8; Sat, 6 Apr 2024 09:09:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AEE3C2CF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387408; bh=BEuFMy2pqu7TGRas3rY5lil+/UYJzKp66XWxPYjr/aU=; 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=PX6VN2yan++U7iOKtPn+5ODwLpOzW28ya9Z/IkZvcbieptLx2Ify4v8Yyd78LpqBs ixNNoefmV7ZEh89Vqj9A5yhRj5juASATQHTxyM0C1HgfcuAvWN/UkTSEi688qsiuH2 EHufQSMco2LgzUSdEZEOKVCcO9yStMDGUBzCPI2E= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 204DCF805A0; Sat, 6 Apr 2024 09:09:27 +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 DE06CF805A8; Sat, 6 Apr 2024 09:09:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9E1F1F8020D; Sat, 6 Apr 2024 08:49:49 +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 11E63F80570 for ; Sat, 6 Apr 2024 08:48:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 11E63F80570 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=nRTIzDc6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386111; x=1712990911; i=oswald.buddenhagen@gmx.de; bh=wMBTvJmAvSsnYPNg7taC7rcPrmaCF3wZy8DyeRm4ZW8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=nRTIzDc6feP0iKtajQ5nV7Z5hZs2qpU+2HSiXf3pyOTaMIbzK8bRKcAPBGcKAwGl rq6oiLiLMp5ersliAHmODBH9YjeCyfBXrZChQmahKPHYUgwCU5YpTMtNWT2awjiHI NSttbw5ZjE9EI00eUxHFVto0rZXmOWdl/OGetfJW4sFZZLNAtoc1z7JodI16NEg2+ 8MhDwUssxloVw5kMhI++60szUyyyVzkafufLErYjZrijH5g+VdWf1t9eQd+fonaIg XteKpGIgCF59GqEdPMUP+SoAucU+DG8VFdt1l/Z5ehJnNsD9nM6amTw2U/rqXqs/R IU3tPhGVx8xoKHUnKA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MORAa-1s9yUr0SOU-00PsIe; Sat, 06 Apr 2024 08:48:31 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jqq-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 05/17] ALSA: emu10k1: prune vestiges of SNDRV_SFNT_SAMPLE_{BIDIR,REVERSE}_LOOP support Date: Sat, 6 Apr 2024 08:48:18 +0200 Message-ID: <20240406064830.1029573-6-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:bvj/GQ7WslqAzG8kNT2sOurxtm67KT9kqDVH2EEH+3EpyRsGhr1 A/H8qH/auP6YVtYJ+vA5FMCisM11FRsqfVCzbe/YwTA4FHxzhl5Dh9kF3UsxkgR5ic6HqSj pnhUEFz2QaHFKPEw0CseUAeV6Na36ICVgs/Elm0NHyk9JujyUGbvFOvJNqie5urWzeWpa9f vt1BTAfrQFeShJ3PPUPJw== UI-OutboundReport: notjunk:1;M01:P0:2LIpGgFpTGM=;ubrftGn6pET6IOuU7CCvbCrpbGx 38W3u3aXNoFbyNUOlUX526vOWK3C8K4zV5YvREisq01PdPOQe4TBb2S+CR4+0f8ZwCtmkB86T /5NF3mfa9qIXevsdLHwbJ2c52e/LstmW10mtc/JjG8NI2RwUeGXt//NWKq41AWbx8ZvfWjfAk an80pYHK0IrwIfjw3qCiSsUN0MtjcE/K9+zpxVBR8lJOHUw3RSGZhaLI4EQp1CkcEj3gBrjc3 y7UUEhRBv+c2INBWugX/sdwG93N83H8AxxKQtFzWXPD1UfWd5LT63TZ14trTgI2NUsDF5L3E+ Q45pOyOU1RFpOhAY9C9BGhngd3WAd0UnpK0pscGJL7Tgfu/dC+Jz9LgMXOoiDVkOYFaPewASA gWqQCUW4SbCwq6fLOjG9HZRu7/HCLXDcGN6hiYziBQHx3FDVF1vXEfTQjHPoLj5D4yXIfPlKf RKnSjpw4jiv/9lvEZXdN81nksf1x/gKVRIrGnCmP7G1NwaR9qE56U29KgYlitqCg2Lcj8oOkx qcD1H771Yw7O332EjFsHCtGkdwR6u/wpA+Aa/51Dy00RZ9k9TgWhiOq6MAoa+sk22zaHSpN85 JosWyG3BBHbUmJ+axcrLlL3VXWabrrZxTZh58RdFZCQh+HCRNHqaTWFKVZrGqwx0X7ompkbuh hDPf65/CpFuLefqZns2BwPPfusB/cOYMkOTKTeRz4k90v1KYbwsu7tQRVyGcdW28usO8yL4pB UH42Nzjh0nAMxSJe+KQpt675IQrpxnGLg+FrSJzB8xTBdJwJVQ39FK6/rA4rSYc0/gtdQXV/3 d4275gTnVjbiSaOUgxLXxPKUMSj07IG9Og83dWg5sR7nw= Message-ID-Hash: CBBJ5NVDAOQMLL3RYHW3L3E7ZKGG37QM X-Message-ID-Hash: CBBJ5NVDAOQMLL3RYHW3L3E7ZKGG37QM 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(-) 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 Sat Apr 6 06:48:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786504 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 C2673C67861 for ; Sat, 6 Apr 2024 07:07:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E121B2CF8; Sat, 6 Apr 2024 09:07:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E121B2CF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387249; bh=pH8KkBimLLKgXaFhPqiDG6YL13iUBCUrphttR/Aifc8=; 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=O0Eecso2rSOyZl/IGoQ2gpaW1NjmDDpwFcOiAO/UwemZq/jO6Xvs9CoO+XUPoFRYB tTWKGLDfTQ2CqmYFPtDq3u6DZ0pNCKWIZWt4t2sVcoXmM5HM/R9s2Y1fTftie2atrc FiU1aDppI8ohg+r8RftPi8mpshkVSoyj/56ptZgc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A3071F805CB; Sat, 6 Apr 2024 09:06:46 +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 0035EF805C1; Sat, 6 Apr 2024 09:06:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2C888F80568; Sat, 6 Apr 2024 08:49:41 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5FE8BF8020D for ; Sat, 6 Apr 2024 08:48:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5FE8BF8020D 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=QXLQr4gZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386111; x=1712990911; i=oswald.buddenhagen@gmx.de; bh=ptvax/9dSFpuGqKK44Xq0yGKMVoWvtRK5dnSVCgiW9M=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=QXLQr4gZZC2Ppg9/zuWzd+5lJ4OVQ+azB+ow08E8qUReC6au1iFy5wLmbKeVJocD KLQIgVEWICA8b8u3K5gL29siV5slt9VNQAeI5xmr3Yqeo0zoWjq9RLYUR+DZ2Tpsp rBQIZtf9Dow2mAJofTBxpcP4c+/565d5WZRpbwJPyCX9qcN5oGFhrGObqJqdKYTQb CQ1CEwaZ+5PbNoyzJjCSpabpEXfsgFKZbjvgUqegzmsCZZ2gdajw4HUMlvBZe0hlW yXAcQAyQhaQMUbRDKUtlIUW4K7nMTr48S56QECWaowB7fPtrJYtDrdsiJZDMuei30 qZBHW2ac+7y1j8PIZw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MysRk-1sfisn0SME-00vu8r; Sat, 06 Apr 2024 08:48:31 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jqv-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 06/17] ALSA: emux: centralize & improve patch info validation Date: Sat, 6 Apr 2024 08:48:19 +0200 Message-ID: <20240406064830.1029573-7-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:AdB2s0r0vGr6Noi0mGmFySLY67gC45icAGE1DnzxVuY9I0FHGCt u4L97pYlqtpn8H4o9JqhHK3A3rb8X4s5JTrA+lBNcMTl2pbNShZMEVNWmaG5TewE04py0qD C3S+/Hw8OhIPv6p3qHpJes5Zp063Nzr9yTNpeQedQXHxX4C7KmioLEHGKyY8Qt+OqEMMwFS YmvtfBofqN16N3lVeU8tg== UI-OutboundReport: notjunk:1;M01:P0:kRe0qJHQ5gQ=;9yeI2nOgE5AAy+ugbI4k2NzSfem GnzyLW4e243AxbRGtKVCBzHgT28YtDvdq3Qgs9PH+Ruf5DPNhq44y/iXEsAgsEa50xyU46EWl kMbz19at919mk0od7CafKXcNN6Q+hxEhKtUzWfLAEhy8lYaBqXqTUyiTnxiLGpcxWaXvbAUb4 pQT3Y+EYo3PpEb65B8VsAtRR2vohV5Eruz4+PaeoZNnmcmZ4/cbiRs/+iXfNO4SFfCNVfgM3u ccSMoH5B0pi3Jf+osD0yDkbpEl9qqu3gB5j6sfNc+lF7qElN51decqmh9LWN/hmLjsbLsJDl7 968dXVTrn5wqSnKdUsYbjSG3wWAjfSnJttoCBH/kDNPTVhJaUvGkvyyNPSbSRTP5DTHXlJ0Er MC+bYV9Iffs907OvA6opqIifG2KYq3+TjmeNP7j3p3hXrmdMsGutEquIw9Y2J2otTbIORJhQ1 z55XiMoYfHEcBmOBXAYsPz40K2wtaGaYxF2LLMz+R56a8EQODd8H4o2ktVDoO+XaJikF8RUAr FnIYlBovOM69wudFycFxeEoZEWIiM2XDESFKhZ7INY33JMmmnDAFXP0kTAGDX26xXHHo8xB26 HC3b58sEFcdNzC/sX9PewRg5lMBK9y7b+2vTNimT75M5gY0+jKWlUCG/OYoSmSyj42/xcENnq GLIsq2Uailc4YFIEK/4vT++2lA1/fdmhJwCokW2T+0w9YZnscG1X5qRNcppECMbnWVgsc3pRV KuXDgikne+8aLUm5h21jl6zzBO7TcegMmb1mKnjako7zt5gufcatQCAKfbLe3Dg1iBWS6HctA Ln6vAm36akmbvxFdyHUDbZMtqnsjpM5ygTfCyJ/Fl+OxA= Message-ID-Hash: WHWDQNEDV2R4FDO2INNT5SGBF4ZIX7C7 X-Message-ID-Hash: WHWDQNEDV2R4FDO2INNT5SGBF4ZIX7C7 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(-) 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 Sat Apr 6 06:48:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786730 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 E40A9CD128A for ; Sat, 6 Apr 2024 07:16:14 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 812F12D27; Sat, 6 Apr 2024 09:16:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 812F12D27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387772; bh=8UuZDYkxvUvLVrG1yELcEIVYz+Yz1gCh76RSIPzfC4o=; 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=Zug2tBEF8YAx5ii2tq3RiJ2dazfbo3/givaZ2Mi/AQFHe7pWaJFIfWJmHCZh+I4Ia ugZxE4EZtq6equFcu7xYoV6QZEq61h3DhLh3t3aaTg5oOigGq5r9CTu5lOgmwNPo8h LJlYl0KpV84Hs0L2vvx8YOqJz+j5fsL7Lo9Jhewg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4111EF805D4; Sat, 6 Apr 2024 09:15:34 +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 A8A31F805C0; Sat, 6 Apr 2024 09:15:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 75690F8020D; Sat, 6 Apr 2024 08:51:45 +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 599C5F8016E for ; Sat, 6 Apr 2024 08:48:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 599C5F8016E 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=HMq9Guhi DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386113; x=1712990913; i=oswald.buddenhagen@gmx.de; bh=Rms+ZeEyJCKqoK2eujFCLJP5kZmmnSCDeFDpdkDzd5w=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=HMq9Guhi12c4rDfvqPmqKR/sH3IE/Oc/cwrAXZVvHnSDqfEFZwANybGyoCwy047N Pguxz6DMgiC5nKrZMq9q2+9bEw3rzUcVnvDVtVVvRq318KNb74fyDajpZqdX0g83g BV/45esVG3OpwAB0cWKfIfepyhy4KfOwv2pRDLeC3xhgyLM98hIwP/hkqUiHpBTUN WYaz2vmcwa0e6FXADkQwyKoDVCmNGQmLtLNuqxCuUX+EXi5Ic7AdZzUtMMVHziiSH de9NylK04m0YOBhQAubOl5Bx15/1egTKXusKwMhaetN077+/J1xSKAXL67UFfiz/N c663SQd7xVwR7fbl+g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M2f5Z-1rx8a138jX-004AS3; Sat, 06 Apr 2024 08:48:33 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jr0-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 07/17] ALSA: emux: improve patch ioctl data validation Date: Sat, 6 Apr 2024 08:48:20 +0200 Message-ID: <20240406064830.1029573-8-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:9APvY0lbeI7/aAQTZgYgcBn7R8DcClVpigvCSVoDZmW9BR+DDJe 3NlyGoFY/SucBg4c/OudITYTktG2jL9d5+MdrQE4317F3fSkkadrkpUXU+mDXbHbWD9H7Iy XyF2/LF0hUGL0jLnyqKBcSzKAYnbME3fNrX34T0RviaZ4FtIpP8mrks9v3b03wQCClohkil CwxYNsptdUyZHB7ZSZvFQ== UI-OutboundReport: notjunk:1;M01:P0:1GtagElvqUw=;jlyy2yFh3xxchXNrTB2rx30Zizl 3XRh1IgkPzTWwJ36DLSSSzbjdvoGWkuAbvUrGaMXld1HRolWU+0vZy+ybSQerc6Gcwu3PDtsi Rq4VaQE/WF3fSx5hjOCY6khkmuqCADKvSHKkuxAyMgJ1FLX9PGd2b2sT1JnUiPwTIz8cJvUyG qHdRMkSFs386fs+vDC+YoytJW5BSqZUlGbgQuEIXOKt3TSz6iGvLrXtIMTojurmxJgtoekMhH Z+C09yio9dTnajWwqeP1mMUVdR+Rj5PH2lVM96nDVWPKlghRCCIMYQ96cBsiDV7n+hUGA8Al5 l/S0C5q6IC3fBzUubjvXUn0yq5s0kTy7nbc8n3ja/HYCzbzLJ17WaTuJEXY8WHk1EFHljZch6 lY1l+v/+L6nZCzz1sOvLyrNu3bh4YVyjolelArJaduDNWLdU+uZceJ57s3q/PV6dwMBuda+Sb I4imEkIFFF9tXEZYQeCsezVUDHNrkHjA09m4YGkqKUBoH4B3wamcqjIb6pMoVkvRpTdTQVc2v npjnfhZvuto0pX98WIfGShRunAn63eN/ebUFX24I3GWiK/WKzcEFusYHnNdxPUpfofHJytfan eix98HFKsAebLkJP5YMY84WbZEaCtbAxI2rJRcybS6837dwrEfR2Ekdxbi8fD7alSK01gY+Z3 d+Urx7F3yXqtTysem1OvC9xuNtyvUykZWv4Qt0rftMp2DIzYvbT0FNfZdog/t1UzYXma8TeGc qf7ODs3Hq6H+vS0wzuZHH9+uU7FO/VGbt9D/xLYL0L6Z3mNNvOKn+OwFGpMsDI8Z5L5SARXwU e0rqEWQax+8fZMWJtpWH1aC+r/rat7Ot/qD/EDGIpgwa0= Message-ID-Hash: ZFMI74KZNPRIFCIY7YVMRJUTQZ3SSUAX X-Message-ID-Hash: ZFMI74KZNPRIFCIY7YVMRJUTQZ3SSUAX 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(-) 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 Sat Apr 6 06:48:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786503 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 9B226CD128A for ; Sat, 6 Apr 2024 07:11:41 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A9F422CEE; Sat, 6 Apr 2024 09:11:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A9F422CEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387499; bh=p7BCWML6FR8IUZ131P5oKg1I0CJdZ+QR6Akdg0RubUc=; 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=ExvuDtOifqYeFGa7OcdoY1B4sWkD0Q78+ibG7ew0Np8qUrxNs1+5n3r89wRNHCZhZ Fnwjq5b8uKPCKYVR8pazjQAnvLSZoJmoJ5a/DmKnY1JpAUygdXCEzDMC64YoWsXOGJ DIr/a/ngu6LpAsvBBGywkwIr7SSITS5FekrzLlfY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E283AF80579; Sat, 6 Apr 2024 09:11:08 +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 2BEA8F8056F; Sat, 6 Apr 2024 09:11:08 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6A6DCF8020D; Sat, 6 Apr 2024 08:49:59 +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 8514BF80571 for ; Sat, 6 Apr 2024 08:48:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8514BF80571 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=ery4oyYt DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386111; x=1712990911; i=oswald.buddenhagen@gmx.de; bh=dID5lRQmSL5xQmZb/PuLDbnEgvU6o/RD1hxxbtU8cYQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=ery4oyYtdjJ9vcfRLHKtsrr5eddPl9jjr4o+B6EqVxFJ/bzLeO3GQY1mcCJBbkG2 QzryYB9TSHxXbFxG0vNuunQjOk2RuCF0CNwEoVotDiRY2ttz0m81XlnYnw+mbf+n0 FbXvicaGhzaxVOxVIGwMqVnC2+vpBr88jLPePdsNN/9N/gBj72g155UfbQT6LGfGl kVL1cBnebW8uAvTRtW3wGc7/0oMrGCR89eOaL3La2yboQz9t0n1Y6VDIT+VyymPp6 gwk9PtdwDADOdm2IRJzen3plhnlhEp1BBVQ4vwdJVZzPqhfVU3hfy0x4q1uSx04ra VR50Tqfk3rnWFwuKSw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MNbp3-1s999Q0SC3-00P2ee; Sat, 06 Apr 2024 08:48:31 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jr5-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 08/17] ALSA: emu10k1: move patch loader assertions into low-level functions Date: Sat, 6 Apr 2024 08:48:21 +0200 Message-ID: <20240406064830.1029573-9-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:fIpfomWooofCrLI3+c0bKi1/0aKLBboPyjR1UlaFDrsiHRmm+RJ SvESc55zf72HXY41zVuV4QuFySISCpRSTD8SNj9EiLsp/Gt9rXT6rNWJX0CjHKdBg/f4EWB bCutGpvsvYEFueMKc3MLHS7UJObYPQcBHv2DJFNsT2GvKRcXaEU0dxRYqPUzCtStqATwkjn E58rji2rNKeVDLisSWTrA== UI-OutboundReport: notjunk:1;M01:P0:FxPeO3sGi/0=;/LPsxlrBrJ+Edq0oQ/ANR+hCSIi 84LazBRQPNExPP7UM3zZnt5XHG1nI8y1wRknWe5t94B4Oz6tWYSgJI99Q8v2QmGaRwi1i2PCZ xbxj4P41YzGApqZ8QRfwsfYKzdq79nrldcjsuTVPqvagZrvj0vvr7jJ9HiEF5NNNLxbnSeqxV ECJbX+h1Lxf7GH3SADOsJu+rN60ZEq7CRbz5eqQOs26IGfZ49SbDWXvfPiNShoJAP2XhV8Hz9 v2PPVwMTZAY7j4QJCl5Uzv6T3gRypB3FaqfTVGp/cd+5Y7yNtHlpsUUKsKgKJp7/6MDpG/nZt ARMLXRruv54T0I8Dr3/9YrzlO1MEgZTIhPhKUcdDl1InlDkgE7B6j7OVHmjdKMQG69piZaWAB BgCQW5xX9bGNJKIMDCzyeV1UmnN29L/ElhUcSCveN5OTp3KuDS7p5/u8OsolfpyLleMJj1y+Q YSEe/TyKtD6iU5SsCN4ggioHRYx5L9gsiaEzNSb5niyLT9jWw8TR5GGg3x1gZ6w1y+WHGmBbl bf042Sm+SfLjKrCp6Gh09Wu5KapkMkXsTl93lutP7lX/hXiMmDtYexBsKg5kPqlAsN1tfU6Ll TjYogj8S4tkud5h+kgZ7fHR0mAfKDwTWOF/xQDacnD7eMJBmGuzbYJzGNxEmzx4LlGh9MbEWt KeKRcA1UXC0y6xEwBesYehHm0/Uk2sAEaamCFpQS38bHPM+/DKDryREr0lnWzA3+/5+JA4SG7 Gnad0hzjEHRaK70cqzPvsRKPo0HqSUEYXUFNn86ObLJptTaAZbN4gMAaHKsW2mJZ95WUvCsG1 3IpgIWYaeqIIJB4Q6nwiu0JnQI1oLZ6W55WSsjgcis/sE= Message-ID-Hash: YZQIVSQEXL6CTB2E42QZ5MWOW4QL5ILW X-Message-ID-Hash: YZQIVSQEXL6CTB2E42QZ5MWOW4QL5ILW 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(-) 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 Sat Apr 6 06:48:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786501 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 71AB4C67861 for ; Sat, 6 Apr 2024 07:16:37 +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 B45D02D26; Sat, 6 Apr 2024 09:16:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B45D02D26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387795; bh=pDiirN5vZLdZVcuhTKGgMaUGhzBytCabiuldfDR9JSg=; 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=N7KG+7shoDAhovQmvd7ER8dkWN9ZzmEPJxXa56GF8PxDOyHX1dbVgzRED1FlqrfRA mfKPB9iQSlV/bkHhaa8NR30aaE94oz0ZDdCYtwFaKSWa7SscMgMcGyOf9wIjtnmjnn EwmeAnlRh9qx5mLr9egS72/x79wfJPVDtR+MlF+Y= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D7226F805F1; Sat, 6 Apr 2024 09:15:40 +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 20128F805EF; Sat, 6 Apr 2024 09:15:40 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3165DF8016E; Sat, 6 Apr 2024 08:51:51 +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 B2BF6F80236 for ; Sat, 6 Apr 2024 08:48:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B2BF6F80236 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=LUXOEcBL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386113; x=1712990913; i=oswald.buddenhagen@gmx.de; bh=EjqL4Jn+wjqR1rBaH3UoJsuQTSccmGz+aWS4aNtp4hg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=LUXOEcBLoC9eP3/T5waUeScNGACa91aW8+6UU0zDy7gPJfrQGvPENHd4IIMOYM26 svjZc7KhjzJsqClvJ1KbwF1FivinVA9lNIOiQOrUUNXDckRGgS65La7n0QiizCLCl SJvbv5iDOs1an0aQHE9TkYDBeKcma15dw9eVL9PNqVmlbYWJ9OAOXrkH/Sz3H1IyZ dP2gPRjGxTPuMhRCbIN11sRWrCH8Eh8tqdCj/PyYpwX8JdUH+RzMfU/tGWqOwaYVz PUIsTPxCdWZkSuJ5NfNYSjAce132XzA9hS8XnB8QbrhJqliPhhf1cn2+SqOq7Fce/ VQpJtpKin4nN9hAJpw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MXGvM-1sIjvE3Ht0-00YkHj; Sat, 06 Apr 2024 08:48:33 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-JrA-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 09/17] ALSA: emu10k1: fix sample signedness issues in wavetable loader Date: Sat, 6 Apr 2024 08:48:22 +0200 Message-ID: <20240406064830.1029573-10-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:wFFC7F3LQJARijRCx1CYCCoYIm1fybJJWbiZGm3M05tc2ZXrWAa ZQlfMclYc/t6f3fHXUjFmRvIHWD+osGU7+55XQQF3ki9osyJsovSGKwe2JsyTFxr5ZyqxtD du4rzrm1skyfoP9j0JAvv51UhhUCr09aWZ87AYoMrwOYAQmTsGARBiUZF7kSkBbx8eUPPN7 jMrHNCIuSjvbTvmSgozkQ== UI-OutboundReport: notjunk:1;M01:P0:s52RjdTwwW0=;2wr1Oyo7uKVPY4Rw7pNZVNtU6U0 nWPzCDWvvuC6BknyPt+UJsHCiK/MSFmFNJTeFVlNlIm5TWFXjfDu1Rg4XERJFnFzNAbdtjQft 34yoaeJSrwoAsozcQxvPRSlAc3NeskHeJLiRJrFY9djJyAOnBhTXxq70NE2FDmOhYmgc8AVlG e4G58LhDePhN4gmjc71R7MPYqnGG+mTIQEvXaZeMRCKTYUJwWUJoSoLQFrk/k0pmRXbRbopsN j4yl4RE0gSkPALXG+SC8tk9eRzMLGtwY9gcum9SoRnjO43jI+0HxJDL/MsbvOnfdwVRilFnQv hK6Jm4YEMamK+ZoB+W2+aZqMhjc0mYn38KWP06KJniqWUvqUuPbkwqz/mbPjL3y6fdgp0tRcj ebyHOLfZ4D6NYBgMKSG0MrWkIE9h92QtVqs2csI862Lef7CCI/8IVLHE3Wd2S66v27t9VzX/V 2Mh5XHzVvZBw0CJYzgqAZFOvItXtYCBY0Qvy58/ctF0zxUSA6ANIhh8gP+2LDtkNESeO38p3r Fp1CLoSv5brSBWjh7C2YxZpshEVHwxThxaHu+rFTp1UYWN9ghfWK6Cs03UnBe5bkMzVtid+vk dl1GaKnZBu5+USB+oCkvXQ2619fNhux3CCW2D1ws57g7FxKX/0H2K8J0CL7W6rg3JX868lbHs EescrNgSSSqRfyQNR1fvoY8eCvmbElnUE/NAm4RMTAISrMVRH2BJMxvi5LiS1uQpI13K7l4Xz SY95YSlP+JNUwtww3zQJhBDNt2JmMYmurOFIVg4BTuPTICB1CUJ0ac+k86i6PUPu1QHGf6IzQ Z0rubvdGk6d+U8JfaKtKeSWEjMSzMVw8KSEQc0Y/wwIqw= Message-ID-Hash: C7JER6BQAA6RNJTEJXPO73X2RLZJA2JC X-Message-ID-Hash: C7JER6BQAA6RNJTEJXPO73X2RLZJA2JC 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(-) 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 Sat Apr 6 06:48:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786726 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 08B55CD128A for ; Sat, 6 Apr 2024 07:20:44 +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 5C1342D5D; Sat, 6 Apr 2024 09:20:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5C1342D5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712388042; bh=vMocICrvAW1bjsRzhL21KFzjSIGcLj6CqF/xTe36Sao=; 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=t4Rzvfc85AcHQGfWOxAd3TtK1Z/3NrCqvRaWMr88+/TRMAAwsA9N7WyySA2KfH+hV pzmUvqW1q1QTXYBG9M16wBfK9R58JDIT87cdMFu6+bCXmTU/gwjtLRuLOR2iHYy65r WzRKVh+fYWJ5rnsqgJrKsdhduux9Q4oZiX79j83I= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C0952F8057A; Sat, 6 Apr 2024 09:20:16 +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 3B3A6F8056F; Sat, 6 Apr 2024 09:20:16 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 85C0CF8016E; Sat, 6 Apr 2024 09:01:24 +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 2542BF8056F for ; Sat, 6 Apr 2024 09:00:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2542BF8056F 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=da9h/fwU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386852; x=1712991652; i=oswald.buddenhagen@gmx.de; bh=h1Zi44w73xqIr7qI+WEi+WXB3H7fY5BzJEXJfftEUYo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=da9h/fwUkUZh62r6U6yXxELh4FwFQlFvdYKehVwhx4jgiAO+j8KoHA54bYiyQjbz 4SgMRaV7P4JCcxGpldpoUe6nG7HQSCNH6hSilCP3mquyh1X0+h2uP0QPTJXEx2nd0 ToWJPXUi/NFfXO98UmIBDaAQFqPYCEEgOTArxP4WWaA5bN9fVt+F1enC610Ccqh6U DOD4XiyOLCZGrCYthn+2cnlhXmCdAKegp5aqTH8POvB+EKCKZJqGO0DMa3YV18hl0 ILHIpDIo9Ek/MrDAvAlmyRYR3if/qPC6tiqR7HmYQinJ993CoDn5kXcPYv1VHUV22 vJIW0qJ4FHZoBEihZg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N1wq3-1suq210TIP-012FI4; Sat, 06 Apr 2024 09:00:52 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-JrF-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 10/17] ALSA: emu10k1: fix playback of 8-bit wavetable samples Date: Sat, 6 Apr 2024 08:48:23 +0200 Message-ID: <20240406064830.1029573-11-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:k6J4J/IRHhtxoesp93tenb2Pw1oStDaxdcHJH8Ma+nbQbfXsQ0k VjgpBDe8SCMurkGXp3McHsGC9KEdAYNIkZXxOw4yuAOofrAmMo7M4mFEZCnfgk4Xvvjwivr ius22UCOUDRj0mZAZVCv+afmNZZW9JgcyJt0a8BNqLx5YOJ2yteQZo9v1uR1C3B58nslSeT /tYC+0eo1u92GkXpm8eBw== UI-OutboundReport: notjunk:1;M01:P0:+QcUMwBEIg4=;HLoeVhRmtgAeKlVN2j/wSnh/3vq w8quGvPhs92rqsEKb7aR4OoUcvjwaAkuZg6YFAYQWSBdxtFUgNhaamQvJQLCH+QrMDz1ccW6M Tfmn2+Njog1vYoMc7mdFZKbD4kES08tZ6n2FtAyUmlGu1p/SK+CTR0HCUhDgd7z3w8wBKNOGr 5fB7KrNL9CF1JEFFZjmMo6cKwGMwECEGbwRniDSb+DoGRUxWdsGPxgyt5S77pzNMtQHjFTzRP dOObVzN+8R5s1JJWNgXLMH9Zm+nKGW8LHRCiEvROwOLEmbJP4nHajSxiU9ppVso7Gs4IbwnIN A8sSSgvXXoDB/WXmRpNEE+7RuMkDgtX51PzAX3V5DaO74EJwRfO0t5b7GYg6NwMidopu5mFXz eztGJLW7t8wzGRv7gdCu4o+uy+CpLHVfL4ypXJmmHlzMRjaO5RFIJGMr5zBM7OGHK3mOKPmud qn7poVf8H3dcHv89oIXgFOTy8aSF9eVXTwUVzkltO2tRQxMwuIgCVp/bxrDndBXaGq3AmqaHW QOdZRBppbHk/gSOG3TUqAZguQdbizfNpTo1bgE2IenPd07aEVz+iZLc1OlLKVSP6bwHRxiXNB sAUucCXmp6UuzyHDadU9BwX5Fn3WwtA9uwdVGDl5rt304YXNkmGcPOdj/lLE6AypxKzYbA3SS Mj3NNMjIlUloZQzscUEBsKhBSswGI+4t19Jo0L5Jh/QzNVkadyQ/VsYPaGJJE49bJ9lMYdYSk FiNIIToFKBQhxAg1tVhaUMY/AClXQIP/4h2n/Ydg2iuKVa9tQ7ruJ5+RUf/K3/QqIRPjpD4wr Du1c1gwhfcTM2szolfGtpOexMEXRsM9LEs8mZ3qe0iBV4= Message-ID-Hash: PIGBCWWAXLSRM2D26CJ7GBK74AUJTZZ2 X-Message-ID-Hash: PIGBCWWAXLSRM2D26CJ7GBK74AUJTZZ2 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(-) 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 Sat Apr 6 06:48:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786499 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 8B8A9CD128A for ; Sat, 6 Apr 2024 07:17:44 +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 944172D29; Sat, 6 Apr 2024 09:17:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 944172D29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387862; bh=Qvr3bA0CZ05QmolsgTBN5IInGB0KerKma9mhd0z7OA8=; 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=KbhzjX7vmkIzh+HjWwR6GpgpUXf3zJEOreWRRtu57Je/WdVEaF/7XjFinNKB86fbN wHCX8dubq1TcQIv/T7dUHQypelRPF1qGjcM+UdRY1Ws27V+o1pa2LSXgQWPKwvLXbs Gn6Twm6Btw8wZ1UFjQ7/mh3L1zHq58t8HaJSCKS8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B6857F8057D; Sat, 6 Apr 2024 09:15: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 BFD63F8068F; Sat, 6 Apr 2024 09:15:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 21844F8016E; Sat, 6 Apr 2024 09:01:09 +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 D9D64F80238 for ; Sat, 6 Apr 2024 09:00:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D9D64F80238 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=rgjEmQWZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386852; x=1712991652; i=oswald.buddenhagen@gmx.de; bh=ToXqItrdxbVBXK7vINSYov0aEjVqUUKZhVs+g8M/vAk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=rgjEmQWZ0NmmW8MVfFB4fId0wEU/gC770wJ5BCwgZl60U6J+x4MVwrMdFNXHWjoi A9AVgXv03s2LCuyRjo5Qb5GeyONv3eWoF9sGTFzEkZWABS7Df1otYwJDt87Rox3Uy FH47IFiKvdrcri8RM3XkUwqEmvN8cHupLLMuSS22I5s8rvo5QRMroMSfyHAHcKI43 Po1bxFel/NukVN5YBFhP01jdU/l0wUutYNMxVP259zqDhVmeVCfTD+0SkjLw5hrdG 4Wgqi/uNV0X1YxBrHIoYdbQbuQm2midPblUCv/QTQsvoYMNr2lkzQxDlqehS6+9xW Ac2GzrfAq0Mn6My21A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N4hzZ-1suHX23dl1-011hr8; Sat, 06 Apr 2024 09:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-JrK-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 11/17] ALSA: emu10k1: merge conditions in patch loader Date: Sat, 6 Apr 2024 08:48:24 +0200 Message-ID: <20240406064830.1029573-12-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:rlGr/LT2MU5uaCOgGWeZKX+A00/ocXL7je1NPlFivX7/57Alldx O+pgbjnlNHwZAabcKJmvYwnCbFtY6mW5XGfxOpPFlKfXv+dnAXc8jaBrg/5beDiKdg2zVmF HXixR7+BCkG8yRdZdngXT/UWFF5yVym2Y/I6F8TAVok8K8YqCN+sYKk1/oKzuvknnAOl6W9 xZc25Hr2VIWIFYOKAUp3Q== UI-OutboundReport: notjunk:1;M01:P0:LnFOOsnFfUQ=;cq2oFxD8z79a3qa5Vl2A10suq0T moPSoPa+9RKurBGxOFxtY4T04ZK6a8KjN6fsvm6aHeCHkgUedbf/DvRRZExOBibuW7rhZ8foF nudG2A1IQwHyge7XuIdxU5pso4GQiufQSyFMqdQJdDJTyFAVOFBIvK5s9r6NaT0w/mVe/Ksg9 iYyEyX8uDmB2YWsgeH1umfABnX7oDJHBda/W152pzVx/SBMCxneX2r8Gyx5aeZlb/IlNBldC4 pzxaMpdgfhlWVgyVW8t/buzlYUIk1uYXkdUE9EjD2eIEjeIJyyIvhbMziyR/NLN3Sl28+MC46 x/8kcxO4a/Ydro/GZpEWoknoEy3wQp3nZ9rSgQZ7lzI82MBRldyloQMS806TrUZZblggRYzSf 9h7v3HD5RyMR/EoIzsah8kvpb9lHdpxAdowTNTI8d0hAm6qfKTVxmTL7GHgd1N2HyosSNPbL0 OsDMItEPDi5jabx7TJIaOqVIkwtWU24hYR1olpa1sYI2YkWXnAUSrT0Ywl7ly0SIOXk9oGwa9 O2IVHmwOolyDVxtjY6kiJIEVzR6L9HCVBHx0CzrnKWYGysg8JY8Krv4GalgyREnVYz2jyRV1Y A6+jXUGuRTe87iW9fzuXvRrcAk82xn3ImWmAaP2bk0hQb53PO/e82y8UwFZdWfUFgyyPehjzZ bZCq5IZnzPs/KLDWY/7MJtxVnbeCyOdc2ncBb2vnotYMr8oP4Fl/OgMCYmormgGZah6lV1tiW pZ41TqXSo33SJ1rwRY+yvZx4Qmj4vapJyaFC/YAVK3LBI+dX317YqiUWiYavO9Z4aP6hHMaZr jSHy9FU4/EMbSi4YWkY4DUf4F85BbaSq2xpsR6URv5Sbo= Message-ID-Hash: CRPYJKCMPPX3EESAIEA65EQZOVDYJOHN X-Message-ID-Hash: CRPYJKCMPPX3EESAIEA65EQZOVDYJOHN 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(-) 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 Sat Apr 6 06:48:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786500 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 D06E4C67861 for ; Sat, 6 Apr 2024 07:17:08 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0130C2D15; Sat, 6 Apr 2024 09:16:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0130C2D15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387827; bh=ZNxz9XRfUws3hzgYnAmMbJsNLrK48W67Ch08nhuDE14=; 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=nQiMcJ1gb36kySRO53WH++6DbMKGsW/A3dOYeVYDVg0aUhN6Hji1CcZmOxdh4itRF DGeU59V+F4hTTmBeRm2/I818riz/rCrFovwQSLF8Kp1AS1Lom4/ALtVpSCV5GYlbyp Deh1CgubPRbY9YOmgNqL8CFvP+liu/fMcgWWQwAM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D1BEBF805FE; Sat, 6 Apr 2024 09:15: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 807AAF80639; Sat, 6 Apr 2024 09:15:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BDC23F80570; Sat, 6 Apr 2024 09:01:07 +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 DBF37F8055C for ; Sat, 6 Apr 2024 09:00:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DBF37F8055C 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=oKskrQ4y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386851; x=1712991651; i=oswald.buddenhagen@gmx.de; bh=xn63gzqr9xb3rSSv9m6pshIRgF/4ohQI6zGY6rUcaZo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=oKskrQ4y6TTCXQX4Szz3VPB+q0q6B6hn6ad2X4Lr/HdMvi6dHsQQdWX5rQSdaUsa EBQOQQqmLqq7fwHy2hzd9bnogIpajONqM4EkF0akylRl36VieefYJjQxqzQbbdloU Gaa6oeCEMXGUnVNbA3P0yfcxXXEO9eklwUr5X0M2shAWE33bixIHGN/lQhq3FXcLE nVVeYMoBYmf4A9+RboLaDYCmyhQ9uLPj8ceiL0B0wdhqa6znGBeam3aqigKuLCYlQ Dlnkz4zajhHMFD4qd30CDNBYj8zRJBhnU63uqxxjhZhEfAx5j1TPasSXtajpqMeu7 +KiDPefLbmGFFPnsJQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MqJqD-1sXELA2Voh-00nUO6; Sat, 06 Apr 2024 09:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-JrP-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 12/17] ALSA: emu10k1: fix wavetable offset recalculation Date: Sat, 6 Apr 2024 08:48:25 +0200 Message-ID: <20240406064830.1029573-13-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:nx0bvHlTGeloEcsuMiRFqWaVqwANfyyLmZrond+BPLQGiPM3ec1 yzz2crerYycGnFHUiVStY4sq0HLwkUbxWZX1Lr0/+TgY56CwrUkMSN+/p4VyOrts3/EO8g2 oyyo/xrILGCTBeBhPKh87/3IiGbhXAJ/IgADiQu5+kg79vmv1RyT1Qi5hdob3xRhikiWLpP IN+mTYC+P9me8KXWylHZg== UI-OutboundReport: notjunk:1;M01:P0:9tkejHezi1Y=;LSa+tYg1c/YNvmmEzZLhGqAc3Bw PJEliYfh8mAWbKSrWexLxMfnTgvrSRVnQtVLsWeBJqi4G45sckieeUiRdxl5gSPvGd5fP5elI 8vjutBOA5owZ9RERnHRY8MtK5DWAbDPBkbojQ7gLg/D6meR7t5HaVqrl/hJRR3gg5mQt1r07h ypycou61TzmtvMwXggygh8Vof8UIn08jCt5WGNGPT9J3T6o3en6ZXKejPxIfm40wxjmjtLp5l NvWHQ0Pe5pDZsb0gSdO0SQVlNBjo7Qun2pTrS6hnx2p9JJboVya+ndX2QBclVcNw94pEknlHx LEC1w+cU2MeKav0lyra0II7x14C5pcDf+bXtdJF2OhF8mYBdyvgAEYbhaOVg1OyGLvxONUKNv wMooiZdTikLXOvQ4tYB4mQ/SCV3CzvgcNEzVIOvitR0kxN1nI6+KZBOxyOp7MGxbE2zS+MYE6 BqDjWTdCGr3tDGz0vVG0C+A1LhfqR1hwBDgeyRsMgAE2m+l9A7l4eIoS1cq1oVPnEFwLKM5pH 8xc3uUqcbVfq4fuv5GWWGhKzQGa+N9wJykviMjGCp52zjlZOt3+cWlBqopb11vx940iN0ygab iEcvbXw1kYjt4ggCGFerw78ef1wKXoqAHoTR16IvzLW+V9Dry63VlwG3n5s2afF7liiW+jzER akgOOUmef/BD+OoO1vF7nStRqv62ntgkVa3iL7YfAWnSwgIsy5Gt6LCfebntRmEFaZww9RF+c Q/WSvcjdoEkyvGCPcdeahL8P5kfuO5KXiG7NuoAEi3w1zL99cVs9Nr03aNFHfuRNOw2i7RRuZ mIOIW+cpSvyX51B75Ih4JB0a1LXECPRUaOh6LAaapReQA= Message-ID-Hash: AAMCKWTZRS3X247GDWJ32GAMTFACOTAP X-Message-ID-Hash: AAMCKWTZRS3X247GDWJ32GAMTFACOTAP 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(-) 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 Sat Apr 6 06:48:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786727 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 F32ACC67861 for ; Sat, 6 Apr 2024 07:20:08 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CF23B2D54; Sat, 6 Apr 2024 09:19:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CF23B2D54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712388005; bh=EmHJN1ikWgpJOH4MzzO3lIRmm9J1jB6N4+P1k1tTHGQ=; 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=fSEDYVKvKzvH4TuIXFiEwmmvxJ3bIMXCKEFYySiGc1ESO3Dc+Jet3JweKcXvq5y4S 4NvrJ6UbTcRlH5hP8cAZDN2j6qPIA1FzpfY7gnMXYpqGfmtT++fT9FjeQ7ysiWQG4Q 0yxQ/JQGi5Qz06PNo5RMC9fu/AG8Hxv1Tsz7bJDY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A9337F8059F; Sat, 6 Apr 2024 09:19:34 +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 ABA04F805A9; Sat, 6 Apr 2024 09:19:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4E6E6F8016E; Sat, 6 Apr 2024 09:01:09 +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 E285BF80568 for ; Sat, 6 Apr 2024 09:00:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E285BF80568 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=QRuFMVlx DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386851; x=1712991651; i=oswald.buddenhagen@gmx.de; bh=GrGs9w7QVBfmnd57OsBEJMSLD44lBCfovL1piwD3FAE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=QRuFMVlxrIKO96jyrMfKhL4Sxi0DE1j+SZBIAvQw5Efm/VJwHTtLBNZqWaOqfST3 k7UXFTEctODmGXuzKWmGss/7Rdun5rEyUorhpG7QtWqXgvlpKZwSFk1SGuRpfmALY v7+TGgmh0poh8/gwQx5M6/QxM9nf6VkccAYLbuXNnoi+0d0PbBDVWN0yCwLKVICTh HmU37TyTYfXxbyp6PEVUsAlDYTVpWU7zAQGzDDTMfONVPuSuD52bQOk9MIHErf22L QOzcjy7LSPBEk8aBf/rFnTBpVGc1Imx2Ma8MU0gqtRh6G5977XSuQWnTqD/awSC2K 0l0cZkpAyisc31gwRA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MPXd2-1s6f330mN0-00MZcN; Sat, 06 Apr 2024 09:00:51 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-JrU-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 13/17] ALSA: emu10k1: de-duplicate size calculations for 16-bit samples Date: Sat, 6 Apr 2024 08:48:26 +0200 Message-ID: <20240406064830.1029573-14-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:w+XuBGtyRklhSUfscz2yiRZhl7nlV0YHnwVXvT/YC42ELoyDXn3 fH+iypYSHcKAxMUb2fL9axTwYMeWvPB9SDN57oxDjInh98s9DWGuKwkb4doLlbzjo3+4HKA 5LF2WP0gHMP00OjBvxxewDhl4L5ZQiH7LENXRUH/OQ3a3ks/dHlw+B4gd1HLem3pECpYigT rv/NjPL2uNflnmAjcqcxw== UI-OutboundReport: notjunk:1;M01:P0:8NUHwK5NTGY=;OQEAx0h3IoNeavUdaRtveR0wKde bBkE9XqPY5wrNrwCd8v2mPBox14saluC+K0jaSOZCRLPgXLEj4e0scxdKkoS66D8IfHlX/1K1 ldc5Cr4i51fw33/VFFXNA2lEEViPIARbza4VWPFcp62YKIlDXHJY/tCu5wm+r7/UKi2G0CHVW SsmsDXaAqMOKJS5SOudCRh7/2IzxOtZefCsMfcg0jlISpd4zi5CiNStMIxhwInugdGf0kYXFY 2sgSzsHf4PsANrX1IlMuYK4X7crV2UHRSsU/8iCnZkQobYXRWLABADfeTen9Geqvj21hKCvON dB8Nq89fZizbKd6JbjFav7NA8fSdyeKquZslpx5rSRmXJZV85zqw7UwnGHOAtfaNADP4VzYP7 qFKryHqojvX+5L3sy+Z6OoOJJ4niZEol/bnPSMDWlb8J4eKig9v3zg8qnrXXHaWe0O461wZ5r Q8jyBo1ujwpnahWnEeeC4pucK1Jp7U3Jq62kJWOfuATUcsdr1dAntIRTbavslyuOed736S0Oh 3oweuxIIx9ZTtgWwIgocIg7bTAaQyYo7hSZObZS6vaxSJmDDNHH0ZdSMSxfIZHf04MdAC4sq9 TRx7OjcHWSRffujk3iWlc1dtcGkGzCeAK4Oax3uRUPTEzLqCJOF1ke5B7aUC/ag0viB6v8xuZ C59Ung7LA19Lf/C4hEkZgnDn4yelBokxgMTUiINX60md6eVgTAJL5NTe0ZmcWT6r1dgiPo7zy aJtRetfPocI3qPbQNnpsJTSfo4EO8gUcfIBMTOcb4MSCtUfkfLcsBXia/YfFd225IwoB3yCWh l4M3+rj+BVEvQyFjZs/Z1TnAbI7voAdZNFpCLFyJUEHS8= Message-ID-Hash: A3O2A2PUXYE7C6YS6AAP2IISJUWJPPJY X-Message-ID-Hash: A3O2A2PUXYE7C6YS6AAP2IISJUWJPPJY 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(-) 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 Sat Apr 6 06:48:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786728 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 1E96BCD128A for ; Sat, 6 Apr 2024 07:17:24 +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 659FE2D4C; Sat, 6 Apr 2024 09:17:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 659FE2D4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387842; bh=dSXheRU0j/Whxk1vwWTLbQWWaJKt2GeZKLjQGMz0D1E=; 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=C28siIsm1jGgoDA1b03/KuS5UgF3UQrbxpeLrx69+xruM7mCsLRolnJJ9Bzxy0teA HYiHh6/b8ljBXW/3q339DUav31yHLaqz9iHp2PDiYK7HGG8vApMekx17kRyjBgL7NH bVc+6Jg4ytIfoBm6F9vJa8hmkhliWx5i24Q5tRLg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 689B3F80656; Sat, 6 Apr 2024 09:15:51 +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 3DB8BF80568; Sat, 6 Apr 2024 09:15:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7D157F8055C; Sat, 6 Apr 2024 09:01:08 +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 D6965F80236 for ; Sat, 6 Apr 2024 09:00:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D6965F80236 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=pFgCjxJU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386852; x=1712991652; i=oswald.buddenhagen@gmx.de; bh=oLPP5MolUCUmNN2tCoRHgXVR+DS5YFmKxl4kPpbFj3Q=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=pFgCjxJUz4Tsq4tr3kbrZTYjf33nafS0DaHnLCJAs/uqirRwvEZVm0+9sWSeL5K/ zSS21eIyFjYQNp02lC6n/DY9+iD+22+2TbxWPMbYKSBEdySyCqi8QAQTEKHBPbbED rUY9XAikq2BonXo/IerV98bvi0vDdJ6Ghgut9sXMYt86s03uYgoPYIC2LjF1gQazn Y2aZkMwX+z9yRTONMH2jUqfD9dNLkQv8EichnNXv23Rmrv2m4XkgWse23lXySsUUt VI7I9Ap85Ot90y/FYwSKTgLB7+I2ezzwTZp7Ig8wvq007xUr/vZKNjT+Z8LRcRPFi rAtYVIKsVu3b2dlE1Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N0oFz-1sgYIT1bgT-00wk2y; Sat, 06 Apr 2024 09:00:52 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jre-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 15/17] ALSA: emu10k1: fix wavetable playback position and caching, take 2 Date: Sat, 6 Apr 2024 08:48:28 +0200 Message-ID: <20240406064830.1029573-16-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:PcuwWBN/iOVG4ANsUivDJ1NRk61tGsabPrXKnHKdWhmr3YOG/Kl 4E6tcLqCTAB3pzYNkJLwtTfd+zMG8Cy5kV5BcDzyNcnyeHgQYkMu5cyWcXu4Q/Gnecz1T/A 74GbtYhIHdh3qVGyplcYXxE2gQS1SWRdczi6VKms6RmM2HnIARRAbPRs50TCMgMoFeZRxJJ eGW9YGckWTKh3Q9Qk9JPg== UI-OutboundReport: notjunk:1;M01:P0:hehuMRWD5j8=;BZDCdt68rWmbfmTVA2hKTpAR50C YqfUvo06F8rHR3D7VZERVPQ+oi+bYgf3A1si24UAgpFMA23UHqsEk9gmg7t6q7e4JFp/J7ioG 44KrdVy8h6G8CL/zIREstm5i3YiX/C6t8lqkE0emIB5cyl9FSd9JiHCiKajaAe+XyLJQEKpUh 3LAAwqTotd/o2m3SICqKRMI9WHjJ98jFiCXhOjL0E2tTzUPE5V+qsscu2oiRhec2smHrt3CaI truFzRVe9jQz+oe53yQXFDm33yV5ZmRiwNfsZRY0qLmAhD1l7j9YbeGJNpjid9Xj7Wf23Pl4H nbU2ys3CwZnhj1YYxrU4Z/R9R7wwZqsTxZQFt+MTU/AQop/XZ+grDL4BKxojgI/A1i7L9rmDg tNJYGbD2r9NQp5hJ8ZomKxoAX0tWp4KOdyjbyOw7wvVFBLFfNv8/F9Pv9+88zzZd468Zeeogi 1DWa7HiwmyyPfEzfW3EW3sGpF3W9f2nB6EtZiw2TUlFn6uXBWnDrSfnURdbK2wWNp1Q4wTn8q vI4kJw0QDfY6XzIc+rms5Gd96XIugn4oFn2nXPvGLh388acrHRWkDo3kqg8P53Y43OjX1nbAp O2Eayk+yLzxPXep78MooTXntd0TQKZeLZGT9Og9N6kQNi0x2i9Fw3ORG0c5DtTtYym/PDZwYJ PXCCpt19rXE8Lg6iG/Vzg5P010flxyt/AkC4IkRyS0vEU091yL7y0tij2TLUUgUz4IJ4zOul4 8gqCTZjeWZmCmpQCxJN4s0prW5X5sWOfEVBBD9mtM10xp8CDbOIy5qr58LAbyXy3xDRY94uUU ++w+/Ei3b8dm4sakMEF92IN+1oQpzSaZd4MK4pZMaspQw= Message-ID-Hash: RKSRVWML6ZFD2CXIBFWRYSUYXSTW7LMV X-Message-ID-Hash: RKSRVWML6ZFD2CXIBFWRYSUYXSTW7LMV 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(-) 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 Sat Apr 6 06:48:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786729 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 5E949C67861 for ; Sat, 6 Apr 2024 07:16:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6FE6E2D2C; Sat, 6 Apr 2024 09:16:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6FE6E2D2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712387811; bh=fE5NND4/IUm7tNZy76HpwvBPiTqtYTd9VJ/3+TRj2pk=; 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=gZohArysVQRw/TX+0b0esU4PPyjypkupdXzGHYIzWHdvVqx3rf3dcLw1oQk2kta4f hkbfUvFKAYIiZCFuv3Nlqo09iowx82zJJS5fct+Aytn4S2xJRmZ5JMM5TqOBUiwyWB 25zgwhL1bLY8Qxfe64fRy1jCu8m/hoBIh+yPbxns= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A546EF80616; Sat, 6 Apr 2024 09:15:43 +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 EB593F80612; Sat, 6 Apr 2024 09:15:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AB5C3F80571; Sat, 6 Apr 2024 09:01:05 +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 37B1EF80114 for ; Sat, 6 Apr 2024 09:00:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 37B1EF80114 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=cx/rY2lw DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386850; x=1712991650; i=oswald.buddenhagen@gmx.de; bh=noigTvMp5s9tyXme04vcGcuwtYwZrLpbC++NpHVnp5c=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=cx/rY2lwgfd+3oEoFxbNBHaoYjTJAkeZ1nCnowPrNqg38gc7N7BnY3uR+ORUpcAj yBNec+/zkoqQ6BkokUxx2r5tvjHPKYtpHj0zJ/Ar4X4eNNeCJ9rjpwDg/F3WuNhgR K2hYDo0WGpCmOEuna3Mx3xTpWr23154Y0AIFgangv3K32fHNSiTOfzto5j8ELhwtv yH7xQH+6S38Wch63Hfl4VhX653Hhc/PWTf7aO07REi+yGGvLXciqjypwHR9wgmD64 Vp6yGtVY/eO7GbiqlRMPeFOsW0HWpdclGEfy9aSDHkGrLmMta9ktASg17vL2XjVp1 Eq81yhbA7QyXlO2kag== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MTiU3-1sMsj11cej-00U0vw; Sat, 06 Apr 2024 09:00:50 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jrj-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 16/17] ALSA: emu10k1: shrink blank space in front of wavetable samples Date: Sat, 6 Apr 2024 08:48:29 +0200 Message-ID: <20240406064830.1029573-17-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:g1t6kYYlaOfIbfaNuO+Yh8FBQ91T5AohATvHHqzaSKBNXAx8mHY 2PwBzVytLKZ0TYlcmVghKFLUhGKllV0VIiYPruYp/4azElUJD1qp819brHyJA/sK9Cx9qIB eLiPSdrVOrZKJ0qJVrAakx1vxIvZAn1WTCMsWPy0hOjMgeAaVSVMKZTR5if9qEVlvcoD+LK AOvu7d4XYB9GpNYuOCiGA== UI-OutboundReport: notjunk:1;M01:P0:lIjDtme9SNo=;Wfz4uvgP4LLdeHumr+ZF+5awTjr XSH2axB9ge0OWa8RAFoDoQZz8/kfo6EkUCgmTRqXU0Ppud+xyJ1ZZyTUVAFRy6yO9m+tEy9wU Y1o8PJFbyxrTnrfXtT6s9dL4CIa5wHf3aUW7l+d097ECjCu/Wq154xKryBFxN/Z+gFA6u4USi a9Hn+SX+4OB86jT8xC8/LwyFo3XWcEdT1RqrvRcwfSRHG2yzP0Ht74317F2XM2mVNCfQc7aMZ bZaVbpFtiSYDe7JGj9JiVPrNoOtf1QhmljpwRJ466Zkupjv6p0IjaXMQlDF35cIGMdQm8FBik HZnn0VyqSGzrBRDAh3Vh8fAwkOiXv3tNDcDxNjXtK4NjKGWmo/1xsuyGhena/9KhJUBx5bIew rKK9daDJ5dGfRGe302Qrvp5uYvjPl6gTpTK3+QdekRzocmuCe0aDOqQWGRVInVUJzs5BSHrya L4xU+/IC83eIDE3T7KgWXKenoQ8dE7YiUeOiHjhdxKp+68p5rZxW7+OzJaeohzms5DuVSry+x Vhfvw3hSNLfj2Ls3kQJ5RBBGqkS8moN/C8Y6hD+Wd1mppHLOm4GFpb1e1hJnmccCz92q3EH6u ZDF0yn0m7UxaVWlPamkx/aZ5fDpXRi6raXgcW4NrD5q5PO1dGKmkYjgWQ+uTRMoCblNAgg3xT aDRVN9Wf46omi4tmFNr9q+4MzcYts/ozgLt4DZBOB877PDkTr1Gl6Ta63wbeQncclgtEqmn7+ EwGpjmUqf75LiAdHtO7MYaMWzyhpnrtvuZWsdBPcC1l2vGFqHWC+UQnowsEsPLiTfK/uK3iAW mSGVHh0ZGTIOE1isnSX7gRgx88GKcQAW4ss7W/ScTMSho= Message-ID-Hash: DBX6BROZFQ5BY55AFR72GLIWJFWNEWGW X-Message-ID-Hash: DBX6BROZFQ5BY55AFR72GLIWJFWNEWGW 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(-) 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 Sat Apr 6 06:48:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 786498 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 9C1A4CD128A for ; Sat, 6 Apr 2024 07:20:28 +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 EF78B2D40; Sat, 6 Apr 2024 09:20:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EF78B2D40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1712388027; bh=cLtY130+PEFam7ffB8P4qGwOien/n8p+NeRIB2hPy7Y=; 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=chj2zB4tiPYXpWuvNojXNcKF+ndK28SsBx3Rx6J+bXLseLBZPZo9bcfJgBbpV9epg mhN1xkTvMGNQfE++DqNl07SJaDDwdel8UkXBayrS33cM4nW+2tWCmSiIsK/p12Jcki wwQVR5sr7+gZY1U+IIIXPjClQfxsXEHjDOSgIApU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C9DFEF805D3; Sat, 6 Apr 2024 09:19:40 +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 3F665F805AF; Sat, 6 Apr 2024 09:19:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 604E8F8020D; Sat, 6 Apr 2024 09:01:16 +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 C3871F8015B for ; Sat, 6 Apr 2024 09:00:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C3871F8015B 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=jkN87bln DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1712386853; x=1712991653; i=oswald.buddenhagen@gmx.de; bh=MK7C7/qbd6SpeemEa5wD3OKm4EbYaThgvFONupi9WjM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=jkN87bln5w+u3xwzulbLGkSQzW0zQrmPYi+9by3E5E8o8B2yo5y3fI2tZjOF0prM XboCPcr8ocP6mbF+nt6XWJIHLArnHwuDsAfNxgjvq9VwIa62PlxnAyN5k/BmULOaz fOkaav11z5V6iAFFHnSe9/T6zlJVgxKI0LgPcFDRhLrzlooYqokbUHysy4khR8nGW j2Ez8Evym68MP18P1zK9Ik9zGbp0FVGbVdhRManqcc7icqIKSsGstu69cXqw5WPZg TNFQbcgNb1JtwK5Ep9+GmTaAvYvQbfmS9gvWmV0OSm5Gn98NPAJP557kkzAuKwaaR JzqBrc5057HLwKnmIg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.118]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MxDkw-1shNmO3sPA-00xYKb; Sat, 06 Apr 2024 09:00:53 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rszqo-Jro-00; Sat, 06 Apr 2024 08:48:30 +0200 From: Oswald Buddenhagen To: alsa-devel@alsa-project.org Cc: Takashi Iwai , Jaroslav Kysela , Arthur Marsh Subject: [PATCH v3 17/17] ALSA: emux: simplify snd_sf_list.callback handling Date: Sat, 6 Apr 2024 08:48:30 +0200 Message-ID: <20240406064830.1029573-18-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> References: <20240406064830.1029573-1-oswald.buddenhagen@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:GDkzlo9rojuPSQs37f1lTfMO8kpFNuoXP/r8KIas0vE9EM+EEbP GBWvSAUoslXlDUfR9XeW8H3yRsdAKxzAamhLITTX1mNCKwc2AoSHKX70lythecaYUJTr3s4 +SOa4EwkJ/X2xTF65gjid/MQx21ykK23tmCUVVSu5iMo9LZ31VZyMoJy0k5hqplv3Uv9P2I En+TcyvxwqJjlp0L7u7hA== UI-OutboundReport: notjunk:1;M01:P0:+sT6CLk85HA=;nt6PCZZ0JfqiU1sLFD56Cd++GZG +VLhgkFpJNPDRztPhX43RakSw2FqA70ZpKqUc3VK9SjaSmKF+/vs12NVaROFgwdtD6fFse2XC /9tZo+zFhqp7TVys5hbMjWMBZfxspBk/mzAzgW+FMB2gqzLKoNXyIIfbMVu9kGM8uEQyzE1Bx hU3Oxy/B7JitCcbg52BFCi+/C8pbbr5+r3lpSHvktw0Nh89a2UGtwBuA5/WVdvCdOYLfmP6YH 6hO7oOjr3jUnqsU7kYDdCBILjp39YZXVzUheOqEs/H65WezDHf3rY/X6f4nuufvCkrT2H+jPE OLqNbKhXJD1k6Y20Hq+lhes9wzgFMu+5AnOdGPp6WlM02zGcmDaSkQ+5PvZpVve0xi6Wdw5Mn bmUo2JtQkAVGsy3CelMY4HyrWQYn0TZAB5BmNtVg9C9FMerWvi6maGD1g0Z+0S8LEC3XPScNM zEsVtyTNiKTg3cB+12EQs83jztlNtfl7xHVgqPCRLVBrD932qsBOdnze9fyV9sRadQskiaKYC rNqyeZYUECAPNy+RK7QpfmnzhsL+JKM0eD6UZcJ1AvzABZqX6fLJ8y+J+jOO3bMT9pfA+zhvv 62TFfog4jn2EX7BQSDsof3W6Rs/4tImybc+Y2z3u4tiNbbGhy7PhIfZ1eNSjdInZcoF2wEaHz JQqG/BRrwXZ89EaYstYi5fpw+ANvfIOqDmyepF+CqB2AJC4mnsMXB+u5KTUGNlPCXdfDwrqNw pF1DjeFHpoCSP0W6ny1Dz9OWcuRMakEbV2N2B5QFtgI+1/6Ca8DeMOHvPbBFmAbKZpHbHlo1K 1YDKZSeN7N0R/QRr9Ex63ka9M5jeqbq10YsPnbZbtcwnk= Message-ID-Hash: P6B6NFF333PJX6MZCDOND7ZX3HWY5MG2 X-Message-ID-Hash: P6B6NFF333PJX6MZCDOND7ZX3HWY5MG2 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(-) 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); } }