Skip to content

Commit

Permalink
ALSA: Implement the new Virtual PCM Test Driver
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ivan Orlov authored and Takashi Iwai committed Jun 7, 2023
1 parent f091ec7 commit 315a3d5
Show file tree
Hide file tree
Showing 4 changed files with 753 additions and 0 deletions.
8 changes: 8 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions sound/drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sound/drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 315a3d5

Please sign in to comment.