summaryrefslogtreecommitdiff
path: root/sound/pci
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2024-06-25 19:25:47 +0200
committerTakashi Iwai <tiwai@suse.de>2024-07-02 09:53:21 +0200
commitd712c58c55d9a4b4cc88ec2e1f8cd2e3b82359b5 (patch)
tree7b818b58b95868265b0d22540667294500266362 /sound/pci
parentf05c1ffc274516ef101d2e0f860bcb9b08c6c622 (diff)
ALSA: pcm: optimize and clarify stream synchronization ID API
Optimize the memory usage in struct snd_pcm_runtime - use boolean value for the standard sync ID scheme. Introduce snd_pcm_set_sync_per_card function to build synchronization IDs. Signed-off-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20240625172836.589380-3-perex@perex.cz
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/emu10k1/p16v.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 773725dbdfbd..a9a75891f1da 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -174,10 +174,6 @@ static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substrea
if (err < 0)
return err;
- *(__u32 *)runtime->sync = cpu_to_le32(substream->pcm->card->number);
- memset(runtime->sync + 4, 0, sizeof(runtime->sync) - 4);
- strncpy(runtime->sync + 4, "P16V", 4);
-
return 0;
}
@@ -225,6 +221,17 @@ static int snd_p16v_pcm_open_capture(struct snd_pcm_substream *substream)
return snd_p16v_pcm_open_capture_channel(substream, 0);
}
+static int snd_p16v_pcm_ioctl_playback(struct snd_pcm_substream *substream,
+ unsigned int cmd, void *arg)
+{
+ if (cmd == SNDRV_PCM_IOCTL1_SYNC_ID) {
+ static const unsigned char id[4] = { 'P', '1', '6', 'V' };
+ snd_pcm_set_sync_per_card(substream, arg, id, 4);
+ return 0;
+ }
+ return snd_pcm_lib_ioctl(substream, cmd, arg);
+}
+
/* prepare playback callback */
static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream)
{
@@ -530,6 +537,7 @@ snd_p16v_pcm_pointer_capture(struct snd_pcm_substream *substream)
static const struct snd_pcm_ops snd_p16v_playback_front_ops = {
.open = snd_p16v_pcm_open_playback_front,
.close = snd_p16v_pcm_close_playback,
+ .ioctl = snd_p16v_pcm_ioctl_playback,
.prepare = snd_p16v_pcm_prepare_playback,
.trigger = snd_p16v_pcm_trigger_playback,
.pointer = snd_p16v_pcm_pointer_playback,