History log of /linux-master/sound/drivers/pcmtest.c
Revision Date Author Comments
# eb99b1b7 06-Dec-2023 Ivan Orlov <ivan.orlov0322@gmail.com>

ALSA: pcmtest: stop timer before buffer is released

Stop timer in the 'trigger' and 'sync_stop' callbacks since we want
the timer to be stopped before the DMA buffer is released. Otherwise,
it could trigger a kernel panic in some circumstances, for instance
when the DMA buffer is already released but the timer callback is
still running.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20231206223211.12761-1-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 22459ef3 22-Aug-2023 Ivan Orlov <ivan.orlov0322@gmail.com>

ALSA: pcmtest: Add support for pcm pausing

Add pause push/release support to the virtual PCM test driver. Add
'suspend' boolean field to the pcmtst_buf_iter structure, so we can
pause the timer without shutting it down. Update the trigger callback
handler correspondingly. Extract buffer initialization to the
'reset_buf_iterator' function since it is used in multiple places now.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230822150541.8450-1-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 62da99b5 15-Aug-2023 Takashi Iwai <tiwai@suse.de>

ALSA: pcmtest: Update comment about PCM copy ops

Just an update of a comment mentioning the old PCM callbacks to
correct to the new PCM copy ops.

Link: https://lore.kernel.org/r/20230815190136.8987-17-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# bba0498b 04-Aug-2023 Ivan Orlov <ivan.orlov0322@gmail.com>

ALSA: pcmtest: Remove redundant definitions

Remove redundant definitions of DEVNAME and CARD_NAME, as they're not
useful. The former is not used anywhere, and the latter is used only
in module parameters descriptions.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230804110740.9867-2-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 205b96e3 04-Aug-2023 Ivan Orlov <ivan.orlov0322@gmail.com>

ALSA: pcmtest: Move buffer iterator initialization to prepare callback

Trigger callback is not the best place for buffer iterator
initialization, so move it out to the prepare callback, where it
have to be.

Minor enhancement: remove blank line.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230804110740.9867-1-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f9d1b819 13-Jul-2023 Ivan Orlov <ivan.orlov0322@gmail.com>

ALSA: pcmtest: minor optimizations

Decrease the buffer filling overhead with conditional remainder
calculation in the 'inc_buf_pos' inline function.

Fix the driver to use already defined variables where it is possible
in 'check_buf_block_ni' and 'fill_block_pattern_n' functions.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230713075953.13692-2-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 678a0bbe 13-Jul-2023 Ivan Orlov <ivan.orlov0322@gmail.com>

ALSA: pcmtest: Add 'open' PCM callback error injection

Extend 'pcmtest' virtual driver with 'open' callback error injection
functionality, as it already can inject errors into other PCM callbacks.
Add module parameter which enables EBUSY error injection in the 'open'
PCM callback.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230713075953.13692-1-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 35bc3efb 07-Jul-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

ALSA: pcmtest: Don't use static storage to track per device data

While there is probably only ever a single instance of such a pcmtst
device, it's still bad style to use a static variable to store per
device data. Make use of platform_get_drvdata() and
platform_set_drvdata() which fixes a data corruption if there should be
two or more such devices (or this driver is used as a template for
another driver).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230707075058.3402832-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# cb2bffde 07-Jul-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

ALSA: pcmtest: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new() which already returns void. Eventually after all drivers
are converted, .remove_new() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230707075058.3402832-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 315a3d57 06-Jun-2023 Ivan Orlov <ivan.orlov0322@gmail.com>

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>