sound/arm/aaci.c
Source file repositories/reference/linux-study-clean/sound/arm/aaci.c
File Facts
- System
- Linux kernel
- Corpus path
sound/arm/aaci.c- Extension
.c- Size
- 24587 bytes
- Lines
- 1068
- Domain
- Driver Families
- Bucket
- sound/arm
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/delay.hlinux/init.hlinux/ioport.hlinux/device.hlinux/spinlock.hlinux/interrupt.hlinux/err.hlinux/amba/bus.hlinux/io.hsound/core.hsound/initval.hsound/ac97_codec.hsound/pcm.hsound/pcm_params.haaci.h
Detected Declarations
function Copyrightfunction aaci_ac97_writefunction aaci_ac97_readfunction aaci_chan_wait_readyfunction aaci_fifo_irqfunction scoped_guardfunction scoped_guardfunction aaci_irqfunction FLfunction aaci_pcm_openfunction aaci_pcm_closefunction aaci_pcm_hw_freefunction aaci_pcm_hw_paramsfunction aaci_pcm_preparefunction aaci_pcm_pointerfunction aaci_pcm_playback_stopfunction aaci_pcm_playback_startfunction aaci_pcm_playback_triggerfunction aaci_pcm_capture_stopfunction aaci_pcm_capture_startfunction aaci_pcm_capture_triggerfunction aaci_pcm_capture_preparefunction aaci_do_suspendfunction aaci_do_resumefunction aaci_suspendfunction aaci_resumefunction aaci_probe_ac97function aaci_free_cardfunction aaci_init_pcmfunction aaci_size_fifofunction aaci_probefunction aaci_remove
Annotated Snippet
if (v == reg) {
v = readl(aaci->base + AACI_SL2RX) >> 4;
break;
} else if (--retries) {
dev_warn(&aaci->dev->dev,
"ac97 read back fail. retry\n");
continue;
} else {
dev_warn(&aaci->dev->dev,
"wrong ac97 register read back (%x != %x)\n",
v, reg);
v = ~0;
}
} while (retries);
return v;
}
static inline void
aaci_chan_wait_ready(struct aaci_runtime *aacirun, unsigned long mask)
{
u32 val;
int timeout = 5000;
do {
udelay(1);
val = readl(aacirun->base + AACI_SR);
} while (val & mask && timeout--);
}
/*
* Interrupt support.
*/
static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
{
if (mask & ISR_ORINTR) {
dev_warn(&aaci->dev->dev, "RX overrun on chan %d\n", channel);
writel(ICLR_RXOEC1 << channel, aaci->base + AACI_INTCLR);
}
if (mask & ISR_RXTOINTR) {
dev_warn(&aaci->dev->dev, "RX timeout on chan %d\n", channel);
writel(ICLR_RXTOFEC1 << channel, aaci->base + AACI_INTCLR);
}
if (mask & ISR_RXINTR) {
struct aaci_runtime *aacirun = &aaci->capture;
bool period_elapsed = false;
void *ptr;
if (!aacirun->substream || !aacirun->start) {
dev_warn(&aaci->dev->dev, "RX interrupt???\n");
writel(0, aacirun->base + AACI_IE);
return;
}
scoped_guard(spinlock, &aacirun->lock) {
ptr = aacirun->ptr;
do {
unsigned int len = aacirun->fifo_bytes;
u32 val;
if (aacirun->bytes <= 0) {
aacirun->bytes += aacirun->period;
period_elapsed = true;
}
if (!(aacirun->cr & CR_EN))
break;
val = readl(aacirun->base + AACI_SR);
if (!(val & SR_RXHF))
break;
if (!(val & SR_RXFF))
len >>= 1;
aacirun->bytes -= len;
/* reading 16 bytes at a time */
for( ; len > 0; len -= 16) {
asm(
"ldmia %1, {r0, r1, r2, r3}\n\t"
"stmia %0!, {r0, r1, r2, r3}"
: "+r" (ptr)
: "r" (aacirun->fifo)
: "r0", "r1", "r2", "r3", "cc");
if (ptr >= aacirun->end)
ptr = aacirun->start;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/init.h`, `linux/ioport.h`, `linux/device.h`, `linux/spinlock.h`, `linux/interrupt.h`, `linux/err.h`.
- Detected declarations: `function Copyright`, `function aaci_ac97_write`, `function aaci_ac97_read`, `function aaci_chan_wait_ready`, `function aaci_fifo_irq`, `function scoped_guard`, `function scoped_guard`, `function aaci_irq`, `function FL`, `function aaci_pcm_open`.
- Atlas domain: Driver Families / sound/arm.
- 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.