sound/soc/soc-pcm.c
Source file repositories/reference/linux-study-clean/sound/soc/soc-pcm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/soc-pcm.c- Extension
.c- Size
- 85245 bytes
- Lines
- 3124
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/init.hlinux/clk.hlinux/delay.hlinux/pinctrl/consumer.hlinux/slab.hlinux/workqueue.hlinux/export.hlinux/debugfs.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dpcm.hsound/soc-link.hsound/initval.h
Detected Declarations
function DEFINE_GUARDfunction snd_soc_dpcm_can_fe_updatefunction snd_soc_dpcm_can_be_updatefunction snd_soc_dpcm_check_statefunction for_each_dpcm_fefunction snd_soc_dpcm_can_be_free_stopfunction snd_soc_dpcm_can_be_paramsfunction snd_soc_dpcm_can_be_preparedfunction dpcm_show_statefunction for_each_dpcm_befunction dpcm_state_read_filefunction soc_dpcm_debugfs_addfunction dpcm_create_debugfs_statefunction dpcm_remove_debugfs_statefunction dpcm_create_debugfs_statefunction dpcm_set_fe_update_statefunction dpcm_set_be_update_statefunction snd_soc_runtime_actionfunction snd_soc_runtime_ignore_pmdown_timefunction dpcm_dapm_stream_eventfunction for_each_dpcm_befunction soc_pcm_set_dai_paramsfunction soc_pcm_apply_symmetryfunction ratefunction for_each_rtd_cpu_daisfunction soc_pcm_apply_shared_bclkfunction soc_pcm_params_symmetryfunction soc_pcm_update_symmetryfunction soc_pcm_set_msbfunction soc_pcm_apply_msbfunction for_each_rtd_codec_daisfunction for_each_rtd_cpu_daisfunction soc_pcm_hw_initfunction soc_pcm_hw_update_ratefunction soc_pcm_hw_update_chanfunction soc_pcm_hw_update_formatfunction snd_soc_runtime_calc_hwfunction DAIfunction soc_pcm_init_runtime_hwfunction soc_pcm_components_openfunction for_each_rtd_componentsfunction soc_pcm_components_closefunction for_each_rtd_componentsfunction soc_pcm_cleanfunction for_each_rtd_daisfunction __soc_pcm_closefunction soc_pcm_closefunction soc_hw_sanity_check
Annotated Snippet
static const struct file_operations dpcm_state_fops = {
.open = simple_open,
.read = dpcm_state_read_file,
.llseek = default_llseek,
};
void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)
{
if (!rtd->dai_link->dynamic)
return;
if (!rtd->card->debugfs_card_root)
return;
rtd->debugfs_dpcm_root = debugfs_create_dir(rtd->dai_link->name,
rtd->card->debugfs_card_root);
debugfs_create_file("state", 0444, rtd->debugfs_dpcm_root,
rtd, &dpcm_state_fops);
}
static void dpcm_create_debugfs_state(struct snd_soc_dpcm *dpcm, int stream)
{
char *name;
name = kasprintf(GFP_KERNEL, "%s:%s", dpcm->be->dai_link->name,
snd_pcm_direction_name(stream));
if (name) {
dpcm->debugfs_state = debugfs_create_dir(
name, dpcm->fe->debugfs_dpcm_root);
debugfs_create_u32("state", 0644, dpcm->debugfs_state,
&dpcm->state);
kfree(name);
}
}
static void dpcm_remove_debugfs_state(struct snd_soc_dpcm *dpcm)
{
debugfs_remove_recursive(dpcm->debugfs_state);
}
#else
static inline void dpcm_create_debugfs_state(struct snd_soc_dpcm *dpcm,
int stream)
{
}
static inline void dpcm_remove_debugfs_state(struct snd_soc_dpcm *dpcm)
{
}
#endif
/* Set FE's runtime_update state; the state is protected via PCM stream lock
* for avoiding the race with trigger callback.
* If the state is unset and a trigger is pending while the previous operation,
* process the pending trigger action here.
*/
static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd);
static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe,
int stream, enum snd_soc_dpcm_update state)
{
struct snd_pcm_substream *substream =
snd_soc_dpcm_get_substream(fe, stream);
snd_pcm_stream_lock_irq(substream);
if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) {
dpcm_fe_dai_do_trigger(substream,
fe->dpcm[stream].trigger_pending - 1);
fe->dpcm[stream].trigger_pending = 0;
}
fe->dpcm[stream].runtime_update = state;
snd_pcm_stream_unlock_irq(substream);
}
static void dpcm_set_be_update_state(struct snd_soc_pcm_runtime *be,
int stream, enum snd_soc_dpcm_update state)
{
be->dpcm[stream].runtime_update = state;
}
/**
* snd_soc_runtime_action() - Increment/Decrement active count for
* PCM runtime components
* @rtd: ASoC PCM runtime that is activated
* @stream: Direction of the PCM stream
* @action: Activate stream if 1. Deactivate if -1.
*
* Increments/Decrements the active count for all the DAIs and components
* attached to a PCM runtime.
* Should typically be called when a stream is opened.
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/clk.h`, `linux/delay.h`, `linux/pinctrl/consumer.h`, `linux/slab.h`, `linux/workqueue.h`, `linux/export.h`.
- Detected declarations: `function DEFINE_GUARD`, `function snd_soc_dpcm_can_fe_update`, `function snd_soc_dpcm_can_be_update`, `function snd_soc_dpcm_check_state`, `function for_each_dpcm_fe`, `function snd_soc_dpcm_can_be_free_stop`, `function snd_soc_dpcm_can_be_params`, `function snd_soc_dpcm_can_be_prepared`, `function dpcm_show_state`, `function for_each_dpcm_be`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.