sound/soc/sprd/sprd-pcm-dma.c
Source file repositories/reference/linux-study-clean/sound/soc/sprd/sprd-pcm-dma.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sprd/sprd-pcm-dma.c- Extension
.c- Size
- 12871 bytes
- Lines
- 498
- Domain
- Driver Families
- Bucket
- sound/soc
- 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.
- 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/dma-mapping.hlinux/dmaengine.hlinux/dma/sprd-dma.hlinux/kernel.hlinux/module.hlinux/of_reserved_mem.hlinux/platform_device.hsound/pcm.hsound/pcm_params.hsound/soc.hsprd-pcm-dma.h
Detected Declarations
struct sprd_pcm_dma_datastruct sprd_pcm_dma_privatefunction sprd_pcm_openfunction sprd_pcm_closefunction sprd_pcm_dma_completefunction sprd_pcm_release_dma_channelfunction sprd_pcm_request_dma_channelfunction sprd_pcm_hw_paramsfunction sprd_pcm_hw_freefunction sprd_pcm_triggerfunction sprd_pcm_pointerfunction sprd_pcm_newfunction sprd_soc_platform_probe
Annotated Snippet
struct sprd_pcm_dma_data {
struct dma_chan *chan;
struct dma_async_tx_descriptor *desc;
dma_cookie_t cookie;
dma_addr_t phys;
void *virt;
int pre_pointer;
};
struct sprd_pcm_dma_private {
struct snd_pcm_substream *substream;
struct sprd_pcm_dma_params *params;
struct sprd_pcm_dma_data data[SPRD_PCM_CHANNEL_MAX];
int hw_chan;
int dma_addr_offset;
};
static const struct snd_pcm_hardware sprd_pcm_hardware = {
.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE |
SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
.period_bytes_min = 1,
.period_bytes_max = 64 * 1024,
.periods_min = 1,
.periods_max = PAGE_SIZE / SPRD_PCM_DMA_LINKLIST_SIZE,
.buffer_bytes_max = 64 * 1024,
};
static int sprd_pcm_open(struct snd_soc_component *component,
struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct device *dev = component->dev;
struct sprd_pcm_dma_private *dma_private;
int hw_chan = SPRD_PCM_CHANNEL_MAX;
int size, ret, i;
snd_soc_set_runtime_hwparams(substream, &sprd_pcm_hardware);
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
SPRD_PCM_DMA_BRUST_LEN);
if (ret < 0)
return ret;
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
SPRD_PCM_DMA_BRUST_LEN);
if (ret < 0)
return ret;
ret = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
return ret;
dma_private = devm_kzalloc(dev, sizeof(*dma_private), GFP_KERNEL);
if (!dma_private)
return -ENOMEM;
size = runtime->hw.periods_max * SPRD_PCM_DMA_LINKLIST_SIZE;
for (i = 0; i < hw_chan; i++) {
struct sprd_pcm_dma_data *data = &dma_private->data[i];
data->virt = dmam_alloc_coherent(dev, size, &data->phys,
GFP_KERNEL);
if (!data->virt) {
ret = -ENOMEM;
goto error;
}
}
dma_private->hw_chan = hw_chan;
runtime->private_data = dma_private;
dma_private->substream = substream;
return 0;
error:
for (i = 0; i < hw_chan; i++) {
struct sprd_pcm_dma_data *data = &dma_private->data[i];
if (data->virt)
dmam_free_coherent(dev, size, data->virt, data->phys);
}
devm_kfree(dev, dma_private);
return ret;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/dma/sprd-dma.h`, `linux/kernel.h`, `linux/module.h`, `linux/of_reserved_mem.h`, `linux/platform_device.h`, `sound/pcm.h`.
- Detected declarations: `struct sprd_pcm_dma_data`, `struct sprd_pcm_dma_private`, `function sprd_pcm_open`, `function sprd_pcm_close`, `function sprd_pcm_dma_complete`, `function sprd_pcm_release_dma_channel`, `function sprd_pcm_request_dma_channel`, `function sprd_pcm_hw_params`, `function sprd_pcm_hw_free`, `function sprd_pcm_trigger`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
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.