ALSA: pcmtest: Add a volume control with event fault injection
Subsystems (3)
v2 cover ALSA: pcmtest: Add a volume control with event fault injection
Hello Takashi,
This is the non-RFC version of [1], which Mark found reasonable [2].
Patch 1 fixes the places where pcmtest.rst does not match the driver. Patch 2 adds the volume control and its two fault parameters, and documents them.
mixer-test results on the new control, under qemu on sound/for-next:
no fault all 8 checks pass
inject_ctl_no_event=1 only event_missing fails
inject_ctl_spurious_event=1 only event_spurious fails
The pcmtest selftest still passes all 10 tests.
Changes since the RFC:
- document the new parameters
- rename the control to "Test Playback Volume", which the OSS mixer emulation does not map
- add the documentation fix as patch 1
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Prepared with Claude Code (Claude Opus 5.5). Tested on x86_64 under qemu.
Best regards,
HyeongJun An
HyeongJun An (2):
ALSA: doc: pcmtest: Update to match the driver
ALSA: pcmtest: Add a volume control with event fault injection
Documentation/sound/cards/pcmtest.rst | 25 ++++++++-- sound/drivers/pcmtest.c | 68 +++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 ALSA: doc: pcmtest: Update to match the driver
The documentation does not match the driver in a few places.
The inject_open_err parameter is missing from the parameter list and from the list of callbacks that can return an error. The fill_mode parameter is a short, not a bool. The selftest is alsa/test-pcmtest-driver.c, not alsa/pcmtest-test.sh. Pause support is not listed.
Fix these.
--- Documentation/sound/cards/pcmtest.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
Documentation/sound/cards/pcmtest.rst +7 -4
@@ -16,22 +16,24 @@ At this moment the driver can do the following things: * Generate random or pattern-based capturing data * Inject delays into the playback and capturing processes * Inject errors during the PCM callbacks + * Pause the streams It supports up to 8 substreams and 4 channels. Also it supports both interleaved and non-interleaved access modes. Also, this driver can check the playback stream for containing the predefined pattern, -which is used in the corresponding selftest (alsa/pcmtest-test.sh) 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. +which is used in the corresponding selftest (alsa/test-pcmtest-driver.c) 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. Configuration ------------- The driver has several parameters besides the common ALSA module parameters: - * fill_mode (bool) - Buffer fill mode (see below) + * fill_mode (short) - Buffer fill mode (see below) * inject_delay (int) + * inject_open_err (bool) * inject_hwpars_err (bool) * inject_prepare_err (bool) * inject_trigger_err (bool)
@@ -93,6 +95,7 @@ writing '1' to the 'inject_hwpars_err' module parameter: Errors can be injected into the following PCM callbacks: + * open (EBUSY) * hw_params (EBUSY) * prepare (EINVAL) * trigger (EINVAL)
Signature · 1 line
2.43.0
PATCH v2 2/2 ALSA: pcmtest: Add a volume control with event fault injection
In reply to HyeongJun AnThe mixer-test selftest checks that a control sends an event when its value changes, and only then. No virtual driver has a control that breaks this rule, so without broken hardware nothing shows that these checks work.
Add a stereo volume control to pcmtest, and two parameters that make its put callback report the wrong result. With inject_ctl_no_event it reports no change, and with inject_ctl_spurious_event it reports a change every time. Document both parameters.
The control is always present. It is named "Test Playback Volume", a name that the OSS mixer emulation does not map.
With both parameters off, mixer-test passes on the control. With either one on, only the matching event check fails.
--- Documentation/sound/cards/pcmtest.rst | 14 ++++++ sound/drivers/pcmtest.c | 68 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+)
Documentation/sound/cards/pcmtest.rst +14 -0
@@ -17,6 +17,7 @@ At this moment the driver can do the following things: * Inject delays into the playback and capturing processes * Inject errors during the PCM callbacks * Pause the streams + * Report wrong change results from a mixer control It supports up to 8 substreams and 4 channels. Also it supports both interleaved and non-interleaved access modes.
@@ -37,6 +38,8 @@ The driver has several parameters besides the common ALSA module parameters: * inject_hwpars_err (bool) * inject_prepare_err (bool) * inject_trigger_err (bool) + * inject_ctl_no_event (bool) + * inject_ctl_spurious_event (bool) Capture Data Generation
@@ -100,6 +103,17 @@ Errors can be injected into the following PCM callbacks: * prepare (EINVAL) * trigger (EINVAL) +Control event injection +----------------------- + +The driver has a 'Test Playback Volume' control. Its 'put' callback reports a change +only when the value changes, so a change event is sent only then. + +With 'inject_ctl_no_event' set, the callback reports no change, and no event is sent +even when the value changes. With 'inject_ctl_spurious_event' set, it reports a change +on every accepted write. The mixer-test selftest (alsa/mixer-test.c) checks for both. +If both parameters are set, 'inject_ctl_no_event' wins. + Playback test -------------
sound/drivers/pcmtest.c +68 -0
114 lines not on this page · raw message
Signature · 1 line
2.43.0
Takashi Iwai
AppliedQuoted 26 lines · HyeongJun An
Hello Takashi,
This is the non-RFC version of [1], which Mark found reasonable [2].
Patch 1 fixes the places where
pcmtest.rstdoes not match the driver. Patch 2 adds the volume control and its two fault parameters, and documents them.mixer-test results on the new control, under qemu on
sound/for-next:no fault all 8 checks pass
inject_ctl_no_event=1 onlyevent_missingfails
inject_ctl_spurious_event=1 onlyevent_spuriousfailsThe pcmtest selftest still passes all 10 tests.
Changes since the RFC:
- document the new parameters
- rename the control to "Test Playback Volume", which the OSS mixer emulation does not map
- add the documentation fix as patch 1[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Quoted 8 lines
Prepared with Claude Code (Claude Opus 5.5). Tested on
x86_64under qemu.Best regards,
HyeongJun AnHyeongJun An (2):
ALSA: doc: pcmtest: Update to match the driver
ALSA: pcmtest: Add a volume control with event fault injection
Applied both patches to for-next branch. Thanks.
Takashi