STRUCT VIRTIO_PCM_SUBSTREAM(9)
π struct virtio_pcm_substream(9) π
okay so real quick before we dive in: this is a page from the Kernel API Manual and it's all about struct virtio_pcm_substream β yes bestie, the VirtIO PCM substream itself, the main character of the sound subsystem. buckle up π
β¨ NAME β¨
struct virtio_pcm_substream β VirtIO PCM substream. that's it, that's the vibe. π
πΈ SYNOPSIS πΈ
here's the whole struct, copied exactly because we do not paraphrase code in this house π«Ά
struct virtio_pcm_substream {
struct virtio_snd *snd;
u32 nid;
u32 sid;
u32 direction;
u32 features;
struct snd_pcm_substream *substream;
struct snd_pcm_indirect pcm_indirect;
struct snd_pcm_hardware hw;
struct work_struct elapsed_period;
spinlock_t lock;
size_t buffer_bytes;
size_t hw_ptr;
bool xfer_enabled;
bool xfer_xrun;
bool stopped;
bool suspended;
struct virtio_pcm_msg **msgs;
unsigned int nmsgs;
unsigned int msg_count;
wait_queue_head_t msg_empty;
};
π Members π
every single field, no skips, no cap. let's go field by field π₯
sndβ the VirtIO sound device. the whole reason we're here tbh πnidβ function group node identifier.sidβ stream identifier.directionβ which way the stream data flows,(SNDRV_PCM_STREAM_XXX). pick a lane bestie π¦featuresβ the stream's VirtIO feature bit map, written as(1 << VIRTIO_SND_PCM_F_XXX).substreamβ the kernel ALSA substream. iconic struct adjacent β¨pcm_indirectβ the kernel indirect pcm structure.hwβ the kernel ALSA substream hardware descriptor.elapsed_periodβ kernel work that handles the elapsed period state. lowkey busy little worker bee πlockβ spinlock that protects fields shared by interrupt handlers and substream operators. very much the bouncer at the club πͺπbuffer_bytesβ current buffer size in bytes.hw_ptrβ substream hardware pointer value in bytes, and its range is literally[0 ... buffer_bytes)β note that the top end is exclusive, so don't come for me πxfer_enabledβ data transfer state(0 - off, 1 - on).xfer_xrunβ data underflow/overflow state(0 - no xrun, 1 - xrun). if this is 1 we're having a bad time πstoppedβTrueif the substream is stopped and must be released on the device side.suspendedβTrueif the substream is suspended and must be reconfigured on the device side at resume.msgsβ allocated I/O messages.nmsgsβ number of allocated I/O messages.msg_countβ number of pending I/O messages in the virtqueue.msg_emptyβ the thing that notifies whenmsg_countis zero. the "we're empty, come thru" signal π«Ά
β SEE ALSO β
go read these next, iykyk:
- Kernel file
./sound/virtio/virtio_pcm.h struct virtio_pcm_stream(9)struct virtio_pcm(9)
ok that's the whole page, every field accounted for, nothing dropped π now go make some sound drivers slay π
and finally, mwah, this little writeup lives in ./sound/virtio and it's dated October 2026 β signing off, struct virtio_pcm_substream(9), no notes, periodt πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms