sound/soc/meson/axg-tdm-interface.c
Source file repositories/reference/linux-study-clean/sound/soc/meson/axg-tdm-interface.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/meson/axg-tdm-interface.c- Extension
.c- Size
- 14642 bytes
- Lines
- 585
- 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/clk.hlinux/module.hlinux/of_platform.hsound/pcm_params.hsound/soc.hsound/soc-dai.haxg-tdm.h
Detected Declarations
function axg_tdm_slots_totalfunction axg_tdm_set_tdm_slotsfunction axg_tdm_iface_set_sysclkfunction axg_tdm_iface_set_fmtfunction axg_tdm_iface_startupfunction axg_tdm_iface_set_streamfunction axg_tdm_iface_set_lrclkfunction axg_tdm_iface_set_sclkfunction axg_tdm_iface_hw_paramsfunction axg_tdm_iface_hw_freefunction axg_tdm_iface_triggerfunction axg_tdm_iface_remove_daifunction for_each_pcm_streamsfunction axg_tdm_iface_probe_daifunction for_each_pcm_streamsfunction axg_tdm_iface_set_bias_levelfunction axg_tdm_iface_probeexport axg_tdm_set_tdm_slots
Annotated Snippet
if (!iface->mclk) {
dev_warn(dai->dev, "master clock not provided\n");
} else {
ret = clk_set_rate(iface->mclk, freq);
if (!ret)
iface->mclk_rate = freq;
}
}
return ret;
}
static int axg_tdm_iface_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
case SND_SOC_DAIFMT_BP_FP:
if (!iface->mclk) {
dev_err(dai->dev, "cpu clock master: mclk missing\n");
return -ENODEV;
}
break;
case SND_SOC_DAIFMT_BC_FC:
break;
case SND_SOC_DAIFMT_BP_FC:
case SND_SOC_DAIFMT_BC_FP:
dev_err(dai->dev, "only BP_FP and BC_FC are supported\n");
fallthrough;
default:
return -EINVAL;
}
iface->fmt = fmt;
return 0;
}
static int axg_tdm_iface_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
struct axg_tdm_stream *ts =
snd_soc_dai_get_dma_data(dai, substream);
int ret;
if (!axg_tdm_slots_total(ts->mask)) {
dev_err(dai->dev, "interface has not slots\n");
return -EINVAL;
}
if (snd_soc_component_active(dai->component)) {
/* Apply component wide rate symmetry */
ret = snd_pcm_hw_constraint_single(substream->runtime,
SNDRV_PCM_HW_PARAM_RATE,
iface->rate);
} else {
/* Limit rate according to the slot number and width */
unsigned int max_rate =
MAX_SCLK / (iface->slots * iface->slot_width);
ret = snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_RATE,
0, max_rate);
}
if (ret < 0)
dev_err(dai->dev, "can't set iface rate constraint\n");
else
ret = 0;
return ret;
}
static int axg_tdm_iface_set_stream(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
struct axg_tdm_stream *ts = snd_soc_dai_get_dma_data(dai, substream);
unsigned int channels = params_channels(params);
unsigned int width = params_width(params);
/* Save rate and sample_bits for component symmetry */
iface->rate = params_rate(params);
/* Make sure this interface can cope with the stream */
if (axg_tdm_slots_total(ts->mask) < channels) {
dev_err(dai->dev, "not enough slots for channels\n");
Annotation
- Immediate include surface: `linux/clk.h`, `linux/module.h`, `linux/of_platform.h`, `sound/pcm_params.h`, `sound/soc.h`, `sound/soc-dai.h`, `axg-tdm.h`.
- Detected declarations: `function axg_tdm_slots_total`, `function axg_tdm_set_tdm_slots`, `function axg_tdm_iface_set_sysclk`, `function axg_tdm_iface_set_fmt`, `function axg_tdm_iface_startup`, `function axg_tdm_iface_set_stream`, `function axg_tdm_iface_set_lrclk`, `function axg_tdm_iface_set_sclk`, `function axg_tdm_iface_hw_params`, `function axg_tdm_iface_hw_free`.
- 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.