Commit 315a3d57 authored by Ivan Orlov's avatar Ivan Orlov Committed by Takashi Iwai
Browse files

ALSA: Implement the new Virtual PCM Test Driver



We have a lot of different virtual media drivers, which can be used for
testing of the userspace applications and media subsystem middle layer.
However, all of them are aimed at testing the video functionality and
simulating the video devices. For audio devices we have only snd-dummy
module, which is good in simulating the correct behavior of an ALSA device.
I decided to write a tool, which would help to test the userspace ALSA
programs (and the PCM middle layer as well) under unusual circumstances
to figure out how they would behave. So I came up with this Virtual PCM
Test Driver.

This new Virtual PCM Test Driver has several features which can be useful
during the userspace ALSA applications testing/fuzzing, or testing/fuzzing
of the PCM middle layer. Not all of them can be implemented using the
existing virtual drivers (like dummy or loopback). Here is what can this
driver do:

- Simulate both capture and playback processes
- Generate random or pattern-based capture data
- Inject delays into the playback and capturing processes
- Inject errors during the PCM callbacks

Also, this driver can check the playback stream for containing the
predefined pattern, which is used in the corresponding selftest to check
the PCM middle layer data transferring functionality. Additionally, this
driver redefines the default RESET ioctl, and the selftest covers this PCM
API functionality as well.

The driver supports both interleaved and non-interleaved access modes, and
have separate pattern buffers for each channel. The driver supports up to
4 channels and up to 8 substreams.

Signed-off-by: default avatarIvan Orlov <ivan.orlov0322@gmail.com>
Acked-by: default avatarJaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230606193254.20791-2-ivan.orlov0322@gmail.com


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f091ec76
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -22423,6 +22423,14 @@ L: linux-fsdevel@vger.kernel.org
S:	Maintained
F:	fs/vboxsf/*
VIRTUAL PCM TEST DRIVER
M:	Ivan Orlov <ivan.orlov0322@gmail.com>
L:	alsa-devel@alsa-project.org
S:	Maintained
F:	Documentation/sound/cards/pcmtest.rst
F:	sound/drivers/pcmtest.c
F:	tools/testing/selftests/alsa/test-pcmtest-driver.c
VIRTUAL SERIO DEVICE DRIVER
M:	Stephen Chandler Paul <thatslyude@gmail.com>
S:	Maintained
+16 −0
Original line number Diff line number Diff line
@@ -109,6 +109,22 @@ config SND_ALOOP
	  To compile this driver as a module, choose M here: the module
	  will be called snd-aloop.

config SND_PCMTEST
	tristate "Virtual PCM test driver"
	select SND_PCM
	help
	  Say 'Y' or 'M' to include support for the Virtual PCM test driver.
	  This driver is aimed at extended testing of the userspace applications
	  which use the ALSA API, as well as the PCM middle layer testing.

	  It can generate random or pattern-based data into the capture stream,
	  check the playback stream for containing the selected pattern, inject
	  time delays during capture/playback, redefine the RESET ioctl operation
	  to perform the PCM middle layer testing and inject errors during the
	  PCM callbacks. It supports both interleaved and non-interleaved access
	  modes. You can find the corresponding selftest in the 'alsa'
	  selftests folder.

config SND_VIRMIDI
	tristate "Virtual MIDI soundcard"
	depends on SND_SEQUENCER
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ snd-dummy-objs := dummy.o
snd-aloop-objs := aloop.o
snd-mtpav-objs := mtpav.o
snd-mts64-objs := mts64.o
snd-pcmtest-objs := pcmtest.o
snd-portman2x4-objs := portman2x4.o
snd-serial-u16550-objs := serial-u16550.o
snd-serial-generic-objs := serial-generic.o
@@ -17,6 +18,7 @@ snd-virmidi-objs := virmidi.o
obj-$(CONFIG_SND_DUMMY) += snd-dummy.o
obj-$(CONFIG_SND_ALOOP) += snd-aloop.o
obj-$(CONFIG_SND_VIRMIDI) += snd-virmidi.o
obj-$(CONFIG_SND_PCMTEST) += snd-pcmtest.o
obj-$(CONFIG_SND_SERIAL_U16550) += snd-serial-u16550.o
obj-$(CONFIG_SND_SERIAL_GENERIC) += snd-serial-generic.o
obj-$(CONFIG_SND_MTPAV) += snd-mtpav.o
+727 −0

File added.

Preview size limit exceeded, changes collapsed.