sound/soc/mediatek/common/mtk-dsp-sof-common.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/common/mtk-dsp-sof-common.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/common/mtk-dsp-sof-common.c- Extension
.c- Size
- 7712 bytes
- Lines
- 275
- 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.
- 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
mtk-dsp-sof-common.hmtk-soc-card.h
Detected Declarations
function Copyrightfunction for_each_card_rtdsfunction for_each_rtd_cpu_daisfunction mtk_sof_card_probefunction for_each_pcm_streamsfunction for_each_dpcm_fefunction for_each_dpcm_befunction mtk_sof_check_tplg_be_dai_link_fixupfunction list_for_each_entryfunction mtk_sof_card_late_probefunction for_each_card_rtdsfunction for_each_rtd_cpu_daisfunction snd_soc_dapm_widget_for_each_source_pathfunction mtk_sof_dailink_parse_ofexport mtk_sof_dai_link_fixupexport mtk_sof_card_probeexport mtk_sof_card_late_probeexport mtk_sof_dailink_parse_of
Annotated Snippet
for_each_card_rtds(card, runtime) {
if (strcmp(runtime->dai_link->name, conn->sof_link))
continue;
for_each_rtd_cpu_dais(runtime, j, cpu_dai) {
if (snd_soc_dai_stream_active(cpu_dai, conn->stream_dir) > 0) {
sof_dai_link = runtime->dai_link;
break;
}
}
break;
}
if (sof_dai_link && sof_dai_link->be_hw_params_fixup)
ret = sof_dai_link->be_hw_params_fixup(runtime, params);
break;
}
return ret;
}
EXPORT_SYMBOL_GPL(mtk_sof_dai_link_fixup);
int mtk_sof_card_probe(struct snd_soc_card *card)
{
int i;
struct snd_soc_dai_link *dai_link;
struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card);
/* Set stream_name to help sof bind widgets */
for_each_card_prelinks(card, i, dai_link) {
if (dai_link->no_pcm && !dai_link->stream_name && dai_link->name)
dai_link->stream_name = dai_link->name;
}
INIT_LIST_HEAD(&soc_card_data->sof_dai_link_list);
return 0;
}
EXPORT_SYMBOL_GPL(mtk_sof_card_probe);
static struct snd_soc_pcm_runtime *mtk_sof_find_tplg_be(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card);
const struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv;
struct snd_soc_pcm_runtime *fe;
struct snd_soc_pcm_runtime *be;
struct snd_soc_dpcm *dpcm;
int i, stream;
for_each_pcm_streams(stream) {
fe = NULL;
for_each_dpcm_fe(rtd, stream, dpcm) {
fe = dpcm->fe;
if (fe)
break;
}
if (!fe)
continue;
for_each_dpcm_be(fe, stream, dpcm) {
be = dpcm->be;
if (be == rtd)
continue;
for (i = 0; i < sof_priv->num_streams; i++) {
const struct sof_conn_stream *conn = &sof_priv->conn_streams[i];
if (!strcmp(be->dai_link->name, conn->sof_link))
return be;
}
}
}
return NULL;
}
/* fixup the BE DAI link to match any values from topology */
static int mtk_sof_check_tplg_be_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{
struct snd_soc_card *card = rtd->card;
struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card);
const struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv;
struct snd_soc_pcm_runtime *sof_be;
struct mtk_dai_link *dai_link;
int ret = 0;
Annotation
- Immediate include surface: `mtk-dsp-sof-common.h`, `mtk-soc-card.h`.
- Detected declarations: `function Copyright`, `function for_each_card_rtds`, `function for_each_rtd_cpu_dais`, `function mtk_sof_card_probe`, `function for_each_pcm_streams`, `function for_each_dpcm_fe`, `function for_each_dpcm_be`, `function mtk_sof_check_tplg_be_dai_link_fixup`, `function list_for_each_entry`, `function mtk_sof_card_late_probe`.
- 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.