drivers/media/pci/saa7134/saa7134-alsa.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/saa7134/saa7134-alsa.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/saa7134/saa7134-alsa.c- Extension
.c- Size
- 30395 bytes
- Lines
- 1260
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
saa7134.hsaa7134-reg.hlinux/init.hlinux/slab.hlinux/time.hlinux/wait.hlinux/module.hsound/core.hsound/control.hsound/pcm.hsound/pcm_params.hsound/initval.hlinux/interrupt.hlinux/vmalloc.h
Detected Declarations
function saa7134_dma_stopfunction saa7134_dma_startfunction saa7134_irq_alsa_donefunction saa7134_alsa_irqfunction snd_card_saa7134_capture_triggerfunction saa7134_alsa_dma_initfunction saa7134_alsa_dma_mapfunction saa7134_alsa_dma_unmapfunction saa7134_alsa_dma_freefunction dsp_buffer_initfunction dsp_buffer_freefunction snd_saa7134_capsrc_setfunction snd_card_saa7134_capture_preparefunction snd_card_saa7134_capture_pointerfunction snd_card_saa7134_runtime_freefunction snd_card_saa7134_hw_paramsfunction snd_card_saa7134_hw_freefunction snd_card_saa7134_capture_closefunction snd_card_saa7134_capture_openfunction callbackfunction snd_card_saa7134_pcmfunction snd_saa7134_volume_infofunction snd_saa7134_volume_getfunction snd_saa7134_volume_putfunction snd_saa7134_capsrc_infofunction snd_saa7134_capsrc_getfunction snd_saa7134_capsrc_putfunction snd_card_saa7134_new_mixerfunction snd_saa7134_freefunction alsa_card_saa7134_createfunction alsa_device_initfunction alsa_device_exitfunction saa7134_alsa_initfunction list_for_each_entryfunction saa7134_alsa_exit
Annotated Snippet
if (report & SAA7134_IRQ_REPORT_DONE_RA3) {
handled = 1;
saa_writel(SAA7134_IRQ_REPORT,
SAA7134_IRQ_REPORT_DONE_RA3);
saa7134_irq_alsa_done(dev, status);
} else {
goto out;
}
}
if (loop == 10) {
pr_debug("error! looping IRQ!");
}
out:
return IRQ_RETVAL(handled);
}
/*
* ALSA capture trigger
*
* - One of the ALSA capture callbacks.
*
* Called whenever a capture is started or stopped. Must be defined,
* but there's nothing we want to do here
*
*/
static int snd_card_saa7134_capture_trigger(struct snd_pcm_substream * substream,
int cmd)
{
struct snd_pcm_runtime *runtime = substream->runtime;
snd_card_saa7134_pcm_t *pcm = runtime->private_data;
struct saa7134_dev *dev=pcm->dev;
int err = 0;
spin_lock(&dev->slock);
if (cmd == SNDRV_PCM_TRIGGER_START) {
/* start dma */
saa7134_dma_start(dev);
} else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
/* stop dma */
saa7134_dma_stop(dev);
} else {
err = -EINVAL;
}
spin_unlock(&dev->slock);
return err;
}
static int saa7134_alsa_dma_init(struct saa7134_dev *dev,
unsigned long nr_pages)
{
struct saa7134_dmasound *dma = &dev->dmasound;
struct page *pg;
int i;
dma->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT);
if (NULL == dma->vaddr) {
pr_debug("vmalloc_32(%lu pages) failed\n", nr_pages);
return -ENOMEM;
}
pr_debug("vmalloc is at addr %p, size=%lu\n",
dma->vaddr, nr_pages << PAGE_SHIFT);
memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT);
dma->nr_pages = nr_pages;
dma->sglist = vzalloc(array_size(sizeof(*dma->sglist), dma->nr_pages));
if (NULL == dma->sglist)
goto vzalloc_err;
sg_init_table(dma->sglist, dma->nr_pages);
for (i = 0; i < dma->nr_pages; i++) {
pg = vmalloc_to_page(dma->vaddr + i * PAGE_SIZE);
if (NULL == pg)
goto vmalloc_to_page_err;
sg_set_page(&dma->sglist[i], pg, PAGE_SIZE, 0);
}
return 0;
vmalloc_to_page_err:
vfree(dma->sglist);
dma->sglist = NULL;
vzalloc_err:
vfree(dma->vaddr);
dma->vaddr = NULL;
return -ENOMEM;
Annotation
- Immediate include surface: `saa7134.h`, `saa7134-reg.h`, `linux/init.h`, `linux/slab.h`, `linux/time.h`, `linux/wait.h`, `linux/module.h`, `sound/core.h`.
- Detected declarations: `function saa7134_dma_stop`, `function saa7134_dma_start`, `function saa7134_irq_alsa_done`, `function saa7134_alsa_irq`, `function snd_card_saa7134_capture_trigger`, `function saa7134_alsa_dma_init`, `function saa7134_alsa_dma_map`, `function saa7134_alsa_dma_unmap`, `function saa7134_alsa_dma_free`, `function dsp_buffer_init`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.