From: Paul Menzel <pmenzel@molgen.mpg.de>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: Paul Menzel <pmenzel@molgen.mpg.de>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: pcsp: Only autoload if the pcspkr input driver is disabled
Date: Fri, 20 Nov 2026 13:03:04 +0100 [thread overview]
Message-ID: <20261120120307.629996-1-pmenzel@molgen.mpg.de> (raw)
The input driver pcspkr and snd-pcsp both register a platform driver
named "pcspkr" for the platform device of the same name, and both
declare the module alias platform:pcspkr. With both built as modules,
as distribution configurations do, udev loads both for the device, and
the second one fails to register its driver on every boot. On a Dell
XPS 13 9310 with Linux 7.4-rc1 and the Debian configuration:
[ 0.793761] input: PC Speaker as /devices/platform/pcspkr/input/input7
[ 0.813617] Error: Driver 'pcspkr' is already registered, aborting...
Which driver ends up handling the beeps depends on the module load
order. The help text of SND_PCSP already says that the driver is not
needed for beeps, and that it may become the default sound card. Debian
therefore removes the alias since 2014 [1], and Ubuntu blacklists
snd_pcsp. With pcspkr built in, snd-pcsp cannot register its driver at
all, so the alias is useless there, too.
Only declare the alias if INPUT_PCSPKR is disabled. Then snd-pcsp is
loaded automatically and takes over the beeps as before. Otherwise only
pcspkr is loaded automatically, and users wanting PCM sound from the PC
speaker keep pcspkr from loading and load snd-pcsp explicitly, which is
already needed today for a deterministic result. Document it in the
Kconfig help text.
Tested on the Dell XPS 13 9310 with Linux 7.4-rc1 and the Debian
configuration (INPUT_PCSPKR=m, SND_PCSP=m), with snd-pcsp not
blacklisted: without this change, the error above is logged; with it,
only pcspkr is loaded and provides the PC Speaker input device, and after
`rmmod pcspkr`, `modprobe snd-pcsp` binds snd-pcsp and creates its sound
card. In QEMU with x86_64_defconfig, kvm_guest.config and SND_PCSP=m,
with systemd-udevd loading the modules, the same holds for
INPUT_PCSPKR=m, and with INPUT_PCSPKR=n, snd-pcsp is still loaded
automatically, binds the device, and creates its sound card and PC
Speaker input device.
[1]: https://bugs.debian.org/697709
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
---
Notes:
Tool use: Claude Code (claude-opus-5-5) analysed the conflict, wrote the patch
and the commit message, and ran the build, modinfo, QEMU and hardware
tests; the author reviewed it.
QEMU 11.1.2 test: the guest boots the host’s root file system read-only
over 9p, with the test kernel’s modules bind-mounted over
/usr/lib/modules from the second (writable) share. The init script
starts systemd-udevd, runs `udevadm trigger` and `udevadm settle`, and
records the loaded modules, the driver bound to the pcspkr platform
device, the PC Speaker input devices and /proc/asound/cards; with
pcspkr loaded, again after `rmmod pcspkr; modprobe snd-pcsp`. No audio
backend is configured, so this checks loading and binding, not sound.
qemu-system-x86_64 -enable-kvm -cpu host -smp 2 -m 1G \
-machine q35 -display none -no-reboot -nic none \
-serial file:$OUT/console \
-kernel $OUT/kernel/boot/vmlinuz-7.4.0-rc2-pcsp-fix-n \
-append "console=ttyS0,115200 root=root rootfstype=9p rootflags=trans=virtio,version=9p2000.L,cache=none ro init=$GUEST_INIT" \
-fsdev local,id=root,path=/,security_model=none,readonly=on,multidevs=remap \
-device virtio-9p-pci,fsdev=root,mount_tag=root \
-fsdev local,id=out,path=$OUT,security_model=none,multidevs=remap \
-device virtio-9p-pci,fsdev=out,mount_tag=out
sound/drivers/Kconfig | 5 ++++-
sound/drivers/pcsp/pcsp.c | 7 +++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index 6debd8e95cb7a..4d875d0f5a17b 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -55,7 +55,10 @@ config SND_PCSP
If you don't have a sound card in your computer, you can include a
driver for the PC speaker which allows it to act like a primitive
sound card.
- This driver also replaces the pcspkr driver for beeps.
+ This driver also replaces the pcspkr driver for beeps. If the
+ pcspkr driver (INPUT_PCSPKR) is enabled too, only pcspkr is loaded
+ automatically. To use this driver instead, prevent pcspkr from
+ loading, and load this driver explicitly.
You can compile this as a module which will be called snd-pcsp.
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
index ff6bb375c9001..d7d28ec2250b6 100644
--- a/sound/drivers/pcsp/pcsp.c
+++ b/sound/drivers/pcsp/pcsp.c
@@ -22,7 +22,14 @@
MODULE_AUTHOR("Stas Sergeev <stsp@users.sourceforge.net>");
MODULE_DESCRIPTION("PC-Speaker driver");
MODULE_LICENSE("GPL");
+/*
+ * The input driver pcspkr binds to the same platform device and has the same
+ * driver name, so only one of the two can be loaded. If pcspkr is available,
+ * let it handle the beeps, and leave loading this driver to the user.
+ */
+#if !IS_ENABLED(CONFIG_INPUT_PCSPKR)
MODULE_ALIAS("platform:pcspkr");
+#endif
static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
--
2.54.0
next reply other threads:[~2026-11-20 12:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 12:03 Paul Menzel [this message]
2026-11-20 17:07 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120120307.629996-1-pmenzel@molgen.mpg.de \
--to=pmenzel@molgen.mpg.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®