sound/soc/samsung/idma.c
Source file repositories/reference/linux-study-clean/sound/soc/samsung/idma.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/samsung/idma.c- Extension
.c- Size
- 9702 bytes
- Lines
- 421
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
linux/interrupt.hlinux/platform_device.hlinux/dma-mapping.hlinux/slab.hlinux/module.hsound/pcm.hsound/pcm_params.hsound/soc.hi2s.hidma.hi2s-regs.h
Detected Declarations
struct idma_ctrlfunction idma_getposfunction idma_enqueuefunction idma_setcallbkfunction idma_controlfunction idma_donefunction idma_hw_paramsfunction idma_hw_freefunction idma_preparefunction idma_triggerfunction idma_pointerfunction scoped_guardfunction idma_mmapfunction iis_irqfunction idma_openfunction idma_closefunction idma_freefunction preallocate_idma_bufferfunction idma_newfunction idma_reg_addr_initfunction asoc_idma_platform_probeexport idma_reg_addr_init
Annotated Snippet
struct idma_ctrl {
spinlock_t lock;
int state;
dma_addr_t start;
dma_addr_t pos;
dma_addr_t end;
dma_addr_t period;
dma_addr_t periodsz;
void *token;
void (*cb)(void *dt, int bytes_xfer);
};
static struct idma_info {
spinlock_t lock;
void __iomem *regs;
dma_addr_t lp_tx_addr;
} idma;
static int idma_irq;
static void idma_getpos(dma_addr_t *src)
{
*src = idma.lp_tx_addr +
(readl(idma.regs + I2STRNCNT) & 0xffffff) * 4;
}
static int idma_enqueue(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct idma_ctrl *prtd = substream->runtime->private_data;
u32 val;
scoped_guard(spinlock, &prtd->lock)
prtd->token = (void *) substream;
/* Internal DMA Level0 Interrupt Address */
val = idma.lp_tx_addr + prtd->periodsz;
writel(val, idma.regs + I2SLVL0ADDR);
/* Start address0 of I2S internal DMA operation. */
val = idma.lp_tx_addr;
writel(val, idma.regs + I2SSTR0);
/*
* Transfer block size for I2S internal DMA.
* Should decide transfer size before start dma operation
*/
val = readl(idma.regs + I2SSIZE);
val &= ~(I2SSIZE_TRNMSK << I2SSIZE_SHIFT);
val |= (((runtime->dma_bytes >> 2) &
I2SSIZE_TRNMSK) << I2SSIZE_SHIFT);
writel(val, idma.regs + I2SSIZE);
val = readl(idma.regs + I2SAHB);
val |= AHB_INTENLVL0;
writel(val, idma.regs + I2SAHB);
return 0;
}
static void idma_setcallbk(struct snd_pcm_substream *substream,
void (*cb)(void *, int))
{
struct idma_ctrl *prtd = substream->runtime->private_data;
guard(spinlock)(&prtd->lock);
prtd->cb = cb;
}
static void idma_control(int op)
{
u32 val = readl(idma.regs + I2SAHB);
guard(spinlock)(&idma.lock);
switch (op) {
case LPAM_DMA_START:
val |= (AHB_INTENLVL0 | AHB_DMAEN);
break;
case LPAM_DMA_STOP:
val &= ~(AHB_INTENLVL0 | AHB_DMAEN);
break;
default:
return;
}
writel(val, idma.regs + I2SAHB);
}
static void idma_done(void *id, int bytes_xfer)
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/platform_device.h`, `linux/dma-mapping.h`, `linux/slab.h`, `linux/module.h`, `sound/pcm.h`, `sound/pcm_params.h`, `sound/soc.h`.
- Detected declarations: `struct idma_ctrl`, `function idma_getpos`, `function idma_enqueue`, `function idma_setcallbk`, `function idma_control`, `function idma_done`, `function idma_hw_params`, `function idma_hw_free`, `function idma_prepare`, `function idma_trigger`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.