sound/pci/aw2/aw2-alsa.c
Source file repositories/reference/linux-study-clean/sound/pci/aw2/aw2-alsa.c
File Facts
- System
- Linux kernel
- Corpus path
sound/pci/aw2/aw2-alsa.c- Extension
.c- Size
- 18241 bytes
- Lines
- 640
- Domain
- Driver Families
- Bucket
- sound/pci
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/pci.hlinux/dma-mapping.hlinux/slab.hlinux/interrupt.hlinux/delay.hlinux/io.hlinux/module.hsound/core.hsound/initval.hsound/pcm.hsound/pcm_params.hsound/control.hsaa7146.haw2-saa7146.h
Detected Declarations
struct aw2_pcm_devicestruct aw2function snd_aw2_freefunction snd_aw2_createfunction snd_aw2_probefunction snd_aw2_pcm_playback_openfunction snd_aw2_pcm_playback_closefunction snd_aw2_pcm_capture_openfunction snd_aw2_pcm_capture_closefunction snd_aw2_pcm_prepare_playbackfunction snd_aw2_pcm_prepare_capturefunction snd_aw2_pcm_trigger_playbackfunction snd_aw2_pcm_trigger_capturefunction snd_aw2_pcm_pointer_playbackfunction snd_aw2_pcm_pointer_capturefunction snd_aw2_new_pcmfunction snd_aw2_control_switch_capture_infofunction snd_aw2_control_switch_capture_getfunction snd_aw2_control_switch_capture_put
Annotated Snippet
static struct pci_driver aw2_driver = {
.name = KBUILD_MODNAME,
.id_table = snd_aw2_ids,
.probe = snd_aw2_probe,
};
module_pci_driver(aw2_driver);
/* operators for playback PCM alsa interface */
static const struct snd_pcm_ops snd_aw2_playback_ops = {
.open = snd_aw2_pcm_playback_open,
.close = snd_aw2_pcm_playback_close,
.prepare = snd_aw2_pcm_prepare_playback,
.trigger = snd_aw2_pcm_trigger_playback,
.pointer = snd_aw2_pcm_pointer_playback,
};
/* operators for capture PCM alsa interface */
static const struct snd_pcm_ops snd_aw2_capture_ops = {
.open = snd_aw2_pcm_capture_open,
.close = snd_aw2_pcm_capture_close,
.prepare = snd_aw2_pcm_prepare_capture,
.trigger = snd_aw2_pcm_trigger_capture,
.pointer = snd_aw2_pcm_pointer_capture,
};
static const struct snd_kcontrol_new aw2_control = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "PCM Capture Route",
.index = 0,
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
.private_value = 0xffff,
.info = snd_aw2_control_switch_capture_info,
.get = snd_aw2_control_switch_capture_get,
.put = snd_aw2_control_switch_capture_put
};
/*********************************
* FUNCTION IMPLEMENTATIONS
********************************/
/* component-destructor */
static void snd_aw2_free(struct snd_card *card)
{
struct aw2 *chip = card->private_data;
/* Free hardware */
snd_aw2_saa7146_free(&chip->saa7146);
}
/* chip-specific constructor */
static int snd_aw2_create(struct snd_card *card,
struct pci_dev *pci)
{
struct aw2 *chip = card->private_data;
int err;
/* initialize the PCI entry */
err = pcim_enable_device(pci);
if (err < 0)
return err;
pci_set_master(pci);
/* check PCI availability (32bit DMA) */
if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
dev_err(card->dev, "Impossible to set 32bit mask DMA\n");
return -ENXIO;
}
/* initialize the stuff */
chip->card = card;
chip->pci = pci;
chip->irq = -1;
/* (1) PCI resource allocation */
chip->iobase_virt = pcim_iomap_region(pci, 0, "Audiowerk2");
if (IS_ERR(chip->iobase_virt))
return PTR_ERR(chip->iobase_virt);
chip->iobase_phys = pci_resource_start(pci, 0);
/* (2) initialization of the chip hardware */
snd_aw2_saa7146_setup(&chip->saa7146, chip->iobase_virt);
if (devm_request_irq(&pci->dev, pci->irq, snd_aw2_saa7146_interrupt,
IRQF_SHARED, KBUILD_MODNAME, chip)) {
dev_err(card->dev, "Cannot grab irq %d\n", pci->irq);
return -EBUSY;
}
chip->irq = pci->irq;
card->sync_irq = chip->irq;
Annotation
- Immediate include surface: `linux/init.h`, `linux/pci.h`, `linux/dma-mapping.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/delay.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `struct aw2_pcm_device`, `struct aw2`, `function snd_aw2_free`, `function snd_aw2_create`, `function snd_aw2_probe`, `function snd_aw2_pcm_playback_open`, `function snd_aw2_pcm_playback_close`, `function snd_aw2_pcm_capture_open`, `function snd_aw2_pcm_capture_close`, `function snd_aw2_pcm_prepare_playback`.
- Atlas domain: Driver Families / sound/pci.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.