sound/soc/sof/sof-audio.c
Source file repositories/reference/linux-study-clean/sound/soc/sof/sof-audio.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sof/sof-audio.c- Extension
.c- Size
- 29649 bytes
- Lines
- 1055
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.htrace/events/sof.hsof-audio.hops.h
Detected Declarations
function is_aggregated_daifunction is_virtual_widgetfunction sof_reset_route_setup_statusfunction list_for_each_entryfunction sof_widget_free_unlockedfunction for_each_set_bitfunction widgetfunction sof_widget_freefunction sof_widget_setup_unlockedfunction for_each_set_bitfunction for_each_set_bitfunction sof_widget_setupfunction sof_route_setupfunction sof_widget_in_same_directionfunction sof_set_up_same_dir_widget_routesfunction sof_setup_pipeline_connectionsfunction for_each_dapm_widgetsfunction snd_soc_dapm_widget_for_each_sink_pathfunction for_each_dapm_widgetsfunction snd_soc_dapm_widget_for_each_source_pathfunction sof_unprepare_widgets_in_pathfunction sof_prepare_widgets_in_pathfunction sof_free_widgets_in_pathfunction sof_set_up_widgets_in_pathfunction sof_walk_widgets_in_orderfunction for_each_dapm_widgetsfunction sof_widget_list_preparefunction sof_widget_list_unpreparefunction sof_widget_list_setupfunction sof_widget_list_freefunction snd_sof_dsp_only_d0i3_compatible_stream_activefunction list_for_each_entryfunction snd_sof_stream_suspend_ignoredfunction list_for_each_entryfunction list_for_each_entryfunction list_for_each_entryfunction list_for_each_entryfunction snd_sof_find_swidget_snamefunction list_for_each_entryfunction list_for_each_entryfunction sof_dai_get_paramfunction sof_dai_get_mclkfunction sof_dai_get_bclkfunction sof_dai_get_tdm_slotsexport sof_widget_freeexport sof_widget_setupexport snd_sof_dsp_only_d0i3_compatible_stream_activeexport sof_dai_get_mclk
Annotated Snippet
if (sroute->src_widget == widget || sroute->sink_widget == widget) {
if (sroute->setup && tplg_ops && tplg_ops->route_free)
tplg_ops->route_free(sdev, sroute);
sroute->setup = false;
}
}
static int sof_widget_free_unlocked(struct snd_sof_dev *sdev,
struct snd_sof_widget *swidget)
{
const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
struct snd_sof_pipeline *spipe = swidget->spipe;
int err = 0;
int ret;
if (!swidget->private)
return 0;
trace_sof_widget_free(swidget);
/* only free when use_count is 0 */
if (--swidget->use_count)
return 0;
/* reset route setup status for all routes that contain this widget */
sof_reset_route_setup_status(sdev, swidget);
/* free DAI config and continue to free widget even if it fails */
if (WIDGET_IS_DAI(swidget->id)) {
struct snd_sof_dai_config_data data;
unsigned int flags = SOF_DAI_CONFIG_FLAGS_HW_FREE;
data.dai_data = DMA_CHAN_INVALID;
if (tplg_ops && tplg_ops->dai_config) {
err = tplg_ops->dai_config(sdev, swidget, flags, &data);
if (err < 0)
dev_err(sdev->dev, "failed to free config for widget %s\n",
swidget->widget->name);
}
}
/* continue to disable core even if IPC fails */
if (tplg_ops && tplg_ops->widget_free) {
ret = tplg_ops->widget_free(sdev, swidget);
if (ret < 0 && !err)
err = ret;
}
/*
* decrement ref count for cores associated with all modules in the pipeline and clear
* the complete flag
*/
if (swidget->id == snd_soc_dapm_scheduler) {
int i;
for_each_set_bit(i, &spipe->core_mask, sdev->num_cores) {
ret = snd_sof_dsp_core_put(sdev, i);
if (ret < 0) {
dev_err(sdev->dev, "failed to disable target core: %d for pipeline %s\n",
i, swidget->widget->name);
if (!err)
err = ret;
}
}
swidget->spipe->complete = 0;
}
/*
* free the scheduler widget (same as pipe_widget) associated with the current swidget.
* skip for static pipelines
*/
if (swidget->spipe && swidget->dynamic_pipeline_widget &&
swidget->id != snd_soc_dapm_scheduler) {
ret = sof_widget_free_unlocked(sdev, swidget->spipe->pipe_widget);
if (ret < 0 && !err)
err = ret;
}
if (!err)
dev_dbg(sdev->dev, "widget %s freed\n", swidget->widget->name);
return err;
}
int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
{
guard(mutex)(&swidget->setup_mutex);
return sof_widget_free_unlocked(sdev, swidget);
Annotation
- Immediate include surface: `linux/bitfield.h`, `trace/events/sof.h`, `sof-audio.h`, `ops.h`.
- Detected declarations: `function is_aggregated_dai`, `function is_virtual_widget`, `function sof_reset_route_setup_status`, `function list_for_each_entry`, `function sof_widget_free_unlocked`, `function for_each_set_bit`, `function widget`, `function sof_widget_free`, `function sof_widget_setup_unlocked`, `function for_each_set_bit`.
- Atlas domain: Driver Families / sound/soc.
- 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.