sound/soc/mediatek/common/mtk-soundcard-driver.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/common/mtk-soundcard-driver.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/common/mtk-soundcard-driver.c- Extension
.c- Size
- 8988 bytes
- Lines
- 344
- 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
linux/module.hlinux/of.hlinux/of_platform.hsound/soc.hmtk-dsp-sof-common.hmtk-soc-card.hmtk-soundcard-driver.h
Detected Declarations
function Copyrightfunction set_dailink_daifmtfunction parse_dai_link_infofunction for_each_card_prelinksfunction clean_card_referencefunction mtk_soundcard_startupfunction mtk_soundcard_playback_startupfunction mtk_soundcard_capture_startupfunction mtk_soundcard_common_probeexport parse_dai_link_infoexport clean_card_referenceexport mtk_soundcard_startupexport mtk_soundcard_common_playback_opsexport mtk_soundcard_common_capture_opsexport mtk_soundcard_common_probe
Annotated Snippet
if (strcmp(str, of_clk_table[i].name) == 0) {
dai_link->dai_fmt &= ~SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK;
dai_link->dai_fmt |= of_clk_table[i].val;
break;
}
}
}
return 0;
}
int parse_dai_link_info(struct snd_soc_card *card)
{
struct device *dev = card->dev;
struct snd_soc_dai_link *dai_link;
const char *dai_link_name;
int ret, i;
/* Loop over all the dai link sub nodes */
for_each_available_child_of_node_scoped(dev->of_node, sub_node) {
if (of_property_read_string(sub_node, "link-name",
&dai_link_name))
return -EINVAL;
for_each_card_prelinks(card, i, dai_link) {
if (!strcmp(dai_link_name, dai_link->name))
break;
}
if (i >= card->num_links)
return -EINVAL;
ret = set_card_codec_info(dev, sub_node, dai_link);
if (ret < 0)
return ret;
ret = set_dailink_daifmt(sub_node, dai_link);
if (ret < 0)
return ret;
}
return 0;
}
EXPORT_SYMBOL_GPL(parse_dai_link_info);
void clean_card_reference(struct snd_soc_card *card)
{
struct snd_soc_dai_link *dai_link;
int i;
/* release codec reference gotten by set_card_codec_info */
for_each_card_prelinks(card, i, dai_link)
snd_soc_of_put_dai_link_codecs(dai_link);
}
EXPORT_SYMBOL_GPL(clean_card_reference);
int mtk_soundcard_startup(struct snd_pcm_substream *substream,
enum mtk_pcm_constraint_type ctype)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct mtk_soc_card_data *soc_card = snd_soc_card_get_drvdata(rtd->card);
const struct mtk_pcm_constraints_data *mpc = &soc_card->card_data->pcm_constraints[ctype];
int ret;
if (unlikely(!mpc))
return -EINVAL;
ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
mpc->rates);
if (ret < 0) {
dev_err(rtd->dev, "hw_constraint_list rate failed\n");
return ret;
}
ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_CHANNELS,
mpc->channels);
if (ret < 0) {
dev_err(rtd->dev, "hw_constraint_list channel failed\n");
return ret;
}
return 0;
}
EXPORT_SYMBOL_GPL(mtk_soundcard_startup);
static int mtk_soundcard_playback_startup(struct snd_pcm_substream *substream)
{
return mtk_soundcard_startup(substream, MTK_CONSTRAINT_PLAYBACK);
Annotation
- Immediate include surface: `linux/module.h`, `linux/of.h`, `linux/of_platform.h`, `sound/soc.h`, `mtk-dsp-sof-common.h`, `mtk-soc-card.h`, `mtk-soundcard-driver.h`.
- Detected declarations: `function Copyright`, `function set_dailink_daifmt`, `function parse_dai_link_info`, `function for_each_card_prelinks`, `function clean_card_reference`, `function mtk_soundcard_startup`, `function mtk_soundcard_playback_startup`, `function mtk_soundcard_capture_startup`, `function mtk_soundcard_common_probe`, `export parse_dai_link_info`.
- 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.