Skip to content

Commit 315a3d5

Browse files
ivanorlov2206tiwai
authored andcommitted
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: Ivan Orlov <ivan.orlov0322@gmail.com> Acked-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20230606193254.20791-2-ivan.orlov0322@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent f091ec7 commit 315a3d5

4 files changed

Lines changed: 753 additions & 0 deletions

File tree

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22423,6 +22423,14 @@ L: linux-fsdevel@vger.kernel.org
2242322423
S: Maintained
2242422424
F: fs/vboxsf/*
2242522425

22426+
VIRTUAL PCM TEST DRIVER
22427+
M: Ivan Orlov <ivan.orlov0322@gmail.com>
22428+
L: alsa-devel@alsa-project.org
22429+
S: Maintained
22430+
F: Documentation/sound/cards/pcmtest.rst
22431+
F: sound/drivers/pcmtest.c
22432+
F: tools/testing/selftests/alsa/test-pcmtest-driver.c
22433+
2242622434
VIRTUAL SERIO DEVICE DRIVER
2242722435
M: Stephen Chandler Paul <thatslyude@gmail.com>
2242822436
S: Maintained

sound/drivers/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,22 @@ config SND_ALOOP
109109
To compile this driver as a module, choose M here: the module
110110
will be called snd-aloop.
111111

112+
config SND_PCMTEST
113+
tristate "Virtual PCM test driver"
114+
select SND_PCM
115+
help
116+
Say 'Y' or 'M' to include support for the Virtual PCM test driver.
117+
This driver is aimed at extended testing of the userspace applications
118+
which use the ALSA API, as well as the PCM middle layer testing.
119+
120+
It can generate random or pattern-based data into the capture stream,
121+
check the playback stream for containing the selected pattern, inject
122+
time delays during capture/playback, redefine the RESET ioctl operation
123+
to perform the PCM middle layer testing and inject errors during the
124+
PCM callbacks. It supports both interleaved and non-interleaved access
125+
modes. You can find the corresponding selftest in the 'alsa'
126+
selftests folder.
127+
112128
config SND_VIRMIDI
113129
tristate "Virtual MIDI soundcard"
114130
depends on SND_SEQUENCER

sound/drivers/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ snd-dummy-objs := dummy.o
88
snd-aloop-objs := aloop.o
99
snd-mtpav-objs := mtpav.o
1010
snd-mts64-objs := mts64.o
11+
snd-pcmtest-objs := pcmtest.o
1112
snd-portman2x4-objs := portman2x4.o
1213
snd-serial-u16550-objs := serial-u16550.o
1314
snd-serial-generic-objs := serial-generic.o
@@ -17,6 +18,7 @@ snd-virmidi-objs := virmidi.o
1718
obj-$(CONFIG_SND_DUMMY) += snd-dummy.o
1819
obj-$(CONFIG_SND_ALOOP) += snd-aloop.o
1920
obj-$(CONFIG_SND_VIRMIDI) += snd-virmidi.o
21+
obj-$(CONFIG_SND_PCMTEST) += snd-pcmtest.o
2022
obj-$(CONFIG_SND_SERIAL_U16550) += snd-serial-u16550.o
2123
obj-$(CONFIG_SND_SERIAL_GENERIC) += snd-serial-generic.o
2224
obj-$(CONFIG_SND_MTPAV) += snd-mtpav.o

0 commit comments

Comments
 (0)