sound/core/pcm_dmaengine.c
Source file repositories/reference/linux-study-clean/sound/core/pcm_dmaengine.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/pcm_dmaengine.c- Extension
.c- Size
- 14267 bytes
- Lines
- 478
- Domain
- Driver Families
- Bucket
- sound/core
- 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.
- 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/module.hlinux/init.hlinux/dmaengine.hlinux/slab.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/dmaengine_pcm.h
Detected Declarations
struct dmaengine_pcm_runtime_datafunction snd_hwparams_to_dma_slave_configfunction snd_dmaengine_pcm_set_config_from_dai_datafunction dmaengine_pcm_dma_completefunction dmaengine_pcm_prepare_and_submitfunction snd_dmaengine_pcm_triggerfunction snd_dmaengine_pcm_pointer_no_residuefunction snd_dmaengine_pcm_pointerfunction snd_dmaengine_pcm_openfunction snd_dmaengine_pcm_sync_stopfunction __snd_dmaengine_pcm_closefunction snd_dmaengine_pcm_closefunction snd_dmaengine_pcm_close_release_chanfunction snd_dmaengine_pcm_refine_runtime_hwparamsfunction pcm_for_each_formatexport snd_dmaengine_pcm_get_chanexport snd_hwparams_to_dma_slave_configexport snd_dmaengine_pcm_set_config_from_dai_dataexport snd_dmaengine_pcm_triggerexport snd_dmaengine_pcm_pointer_no_residueexport snd_dmaengine_pcm_pointerexport snd_dmaengine_pcm_request_channelexport snd_dmaengine_pcm_openexport snd_dmaengine_pcm_sync_stopexport snd_dmaengine_pcm_closeexport snd_dmaengine_pcm_close_release_chanexport snd_dmaengine_pcm_refine_runtime_hwparams
Annotated Snippet
struct dmaengine_pcm_runtime_data {
struct dma_chan *dma_chan;
dma_cookie_t cookie;
unsigned int pos;
};
static inline struct dmaengine_pcm_runtime_data *substream_to_prtd(
const struct snd_pcm_substream *substream)
{
return substream->runtime->private_data;
}
struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream)
{
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
return prtd->dma_chan;
}
EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_get_chan);
/**
* snd_hwparams_to_dma_slave_config - Convert hw_params to dma_slave_config
* @substream: PCM substream
* @params: hw_params
* @slave_config: DMA slave config
*
* This function can be used to initialize a dma_slave_config from a substream
* and hw_params in a dmaengine based PCM driver implementation.
*
* Return: zero if successful, or a negative error code
*/
int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream,
const struct snd_pcm_hw_params *params,
struct dma_slave_config *slave_config)
{
enum dma_slave_buswidth buswidth;
int bits;
bits = params_physical_width(params);
if (bits < 8 || bits > 64)
return -EINVAL;
else if (bits == 8)
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
else if (bits == 16)
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
else if (bits == 24)
buswidth = DMA_SLAVE_BUSWIDTH_3_BYTES;
else if (bits <= 32)
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
else
buswidth = DMA_SLAVE_BUSWIDTH_8_BYTES;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
slave_config->direction = DMA_MEM_TO_DEV;
slave_config->dst_addr_width = buswidth;
} else {
slave_config->direction = DMA_DEV_TO_MEM;
slave_config->src_addr_width = buswidth;
}
slave_config->device_fc = false;
return 0;
}
EXPORT_SYMBOL_GPL(snd_hwparams_to_dma_slave_config);
/**
* snd_dmaengine_pcm_set_config_from_dai_data() - Initializes a dma slave config
* using DAI DMA data.
* @substream: PCM substream
* @dma_data: DAI DMA data
* @slave_config: DMA slave configuration
*
* Initializes the {dst,src}_addr, {dst,src}_maxburst, {dst,src}_addr_width
* fields of the DMA slave config from the same fields of the DAI DMA
* data struct. The src and dst fields will be initialized depending on the
* direction of the substream. If the substream is a playback stream the dst
* fields will be initialized, if it is a capture stream the src fields will be
* initialized. The {dst,src}_addr_width field will only be initialized if the
* SND_DMAENGINE_PCM_DAI_FLAG_PACK flag is set or if the addr_width field of
* the DAI DMA data struct is not equal to DMA_SLAVE_BUSWIDTH_UNDEFINED. If
* both conditions are met the latter takes priority.
*/
void snd_dmaengine_pcm_set_config_from_dai_data(
const struct snd_pcm_substream *substream,
const struct snd_dmaengine_dai_dma_data *dma_data,
struct dma_slave_config *slave_config)
{
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/dmaengine.h`, `linux/slab.h`, `sound/pcm.h`, `sound/pcm_params.h`, `sound/soc.h`, `sound/dmaengine_pcm.h`.
- Detected declarations: `struct dmaengine_pcm_runtime_data`, `function snd_hwparams_to_dma_slave_config`, `function snd_dmaengine_pcm_set_config_from_dai_data`, `function dmaengine_pcm_dma_complete`, `function dmaengine_pcm_prepare_and_submit`, `function snd_dmaengine_pcm_trigger`, `function snd_dmaengine_pcm_pointer_no_residue`, `function snd_dmaengine_pcm_pointer`, `function snd_dmaengine_pcm_open`, `function snd_dmaengine_pcm_sync_stop`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: integration 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.