sound/xen/xen_snd_front_alsa.c
Source file repositories/reference/linux-study-clean/sound/xen/xen_snd_front_alsa.c
File Facts
- System
- Linux kernel
- Corpus path
sound/xen/xen_snd_front_alsa.c- Extension
.c- Size
- 21595 bytes
- Lines
- 840
- Domain
- Driver Families
- Bucket
- sound/xen
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/platform_device.hsound/core.hsound/pcm.hsound/pcm_params.hxen/xenbus.hxen/xen-front-pgdir-shbuf.hxen_snd_front.hxen_snd_front_alsa.hxen_snd_front_cfg.hxen_snd_front_evtchnl.h
Detected Declarations
struct xen_snd_front_pcm_stream_infostruct xen_snd_front_pcm_instance_infostruct xen_snd_front_card_infostruct alsa_sndif_sample_formatfunction to_sndif_formatfunction to_sndif_formats_maskfunction to_alsa_formats_maskfunction stream_clearfunction stream_freefunction stream_getfunction alsa_hw_rulefunction alsa_openfunction alsa_closefunction shbuf_setup_backstorefunction alsa_hw_paramsfunction alsa_hw_freefunction alsa_preparefunction alsa_triggerfunction xen_snd_front_alsa_handle_cur_posfunction alsa_pointerfunction alsa_pb_copyfunction alsa_cap_copyfunction alsa_pb_fill_silencefunction new_pcm_instancefunction xen_snd_front_alsa_initfunction xen_snd_front_alsa_fini
Annotated Snippet
struct xen_snd_front_pcm_stream_info {
struct xen_snd_front_info *front_info;
struct xen_snd_front_evtchnl_pair *evt_pair;
/* This is the shared buffer with its backing storage. */
struct xen_front_pgdir_shbuf shbuf;
u8 *buffer;
size_t buffer_sz;
int num_pages;
struct page **pages;
int index;
bool is_open;
struct snd_pcm_hardware pcm_hw;
/* Number of processed frames as reported by the backend. */
snd_pcm_uframes_t be_cur_frame;
/* Current HW pointer to be reported via .period callback. */
atomic_t hw_ptr;
/* Modulo of the number of processed frames - for period detection. */
u32 out_frames;
};
struct xen_snd_front_pcm_instance_info {
struct xen_snd_front_card_info *card_info;
struct snd_pcm *pcm;
struct snd_pcm_hardware pcm_hw;
int num_pcm_streams_pb;
struct xen_snd_front_pcm_stream_info *streams_pb;
int num_pcm_streams_cap;
struct xen_snd_front_pcm_stream_info *streams_cap;
};
struct xen_snd_front_card_info {
struct xen_snd_front_info *front_info;
struct snd_card *card;
struct snd_pcm_hardware pcm_hw;
int num_pcm_instances;
struct xen_snd_front_pcm_instance_info *pcm_instances;
};
struct alsa_sndif_sample_format {
u8 sndif;
snd_pcm_format_t alsa;
};
static const struct alsa_sndif_sample_format ALSA_SNDIF_FORMATS[] = {
{
.sndif = XENSND_PCM_FORMAT_U8,
.alsa = SNDRV_PCM_FORMAT_U8
},
{
.sndif = XENSND_PCM_FORMAT_S8,
.alsa = SNDRV_PCM_FORMAT_S8
},
{
.sndif = XENSND_PCM_FORMAT_U16_LE,
.alsa = SNDRV_PCM_FORMAT_U16_LE
},
{
.sndif = XENSND_PCM_FORMAT_U16_BE,
.alsa = SNDRV_PCM_FORMAT_U16_BE
},
{
.sndif = XENSND_PCM_FORMAT_S16_LE,
.alsa = SNDRV_PCM_FORMAT_S16_LE
},
{
.sndif = XENSND_PCM_FORMAT_S16_BE,
.alsa = SNDRV_PCM_FORMAT_S16_BE
},
{
.sndif = XENSND_PCM_FORMAT_U24_LE,
.alsa = SNDRV_PCM_FORMAT_U24_LE
},
{
.sndif = XENSND_PCM_FORMAT_U24_BE,
.alsa = SNDRV_PCM_FORMAT_U24_BE
},
{
.sndif = XENSND_PCM_FORMAT_S24_LE,
.alsa = SNDRV_PCM_FORMAT_S24_LE
},
{
.sndif = XENSND_PCM_FORMAT_S24_BE,
.alsa = SNDRV_PCM_FORMAT_S24_BE
},
{
.sndif = XENSND_PCM_FORMAT_U32_LE,
Annotation
- Immediate include surface: `linux/platform_device.h`, `sound/core.h`, `sound/pcm.h`, `sound/pcm_params.h`, `xen/xenbus.h`, `xen/xen-front-pgdir-shbuf.h`, `xen_snd_front.h`, `xen_snd_front_alsa.h`.
- Detected declarations: `struct xen_snd_front_pcm_stream_info`, `struct xen_snd_front_pcm_instance_info`, `struct xen_snd_front_card_info`, `struct alsa_sndif_sample_format`, `function to_sndif_format`, `function to_sndif_formats_mask`, `function to_alsa_formats_mask`, `function stream_clear`, `function stream_free`, `function stream_get`.
- Atlas domain: Driver Families / sound/xen.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.