sound/soc/meson/axg-card.c
Source file repositories/reference/linux-study-clean/sound/soc/meson/axg-card.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/meson/axg-card.c- Extension
.c- Size
- 9691 bytes
- Lines
- 374
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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_platform.hsound/soc.hsound/soc-dai.haxg-tdm.hmeson-card.h
Detected Declarations
struct axg_dai_link_tdm_maskstruct axg_dai_link_tdm_datafunction axg_card_tdm_be_hw_paramsfunction axg_card_tdm_dai_initfunction for_each_rtd_codec_daisfunction axg_card_tdm_dai_lb_initfunction axg_card_add_tdm_loopbackfunction axg_card_parse_cpu_tdm_slotsfunction axg_card_parse_codecs_masksfunction for_each_child_of_node_scopedfunction axg_card_parse_tdmfunction axg_card_cpu_is_capture_fefunction axg_card_cpu_is_playback_fefunction axg_card_cpu_is_tdm_ifacefunction axg_card_cpu_is_codecfunction axg_card_add_link
Annotated Snippet
struct axg_dai_link_tdm_mask {
u32 tx;
u32 rx;
};
struct axg_dai_link_tdm_data {
unsigned int mclk_fs;
unsigned int slots;
unsigned int slot_width;
u32 *tx_mask;
u32 *rx_mask;
struct axg_dai_link_tdm_mask *codec_masks;
};
/*
* Base params for the codec to codec links
* Those will be over-written by the CPU side of the link
*/
static const struct snd_soc_pcm_stream codec_params = {
.formats = SNDRV_PCM_FMTBIT_S24_LE,
.rate_min = 5525,
.rate_max = 192000,
.channels_min = 1,
.channels_max = 8,
};
static int axg_card_tdm_be_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card);
struct axg_dai_link_tdm_data *be =
(struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];
return meson_card_i2s_set_sysclk(substream, params, be->mclk_fs);
}
static const struct snd_soc_ops axg_card_tdm_be_ops = {
.hw_params = axg_card_tdm_be_hw_params,
};
static int axg_card_tdm_dai_init(struct snd_soc_pcm_runtime *rtd)
{
struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card);
struct axg_dai_link_tdm_data *be =
(struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];
struct snd_soc_dai *codec_dai;
int ret, i;
for_each_rtd_codec_dais(rtd, i, codec_dai) {
ret = snd_soc_dai_set_tdm_slot(codec_dai,
be->codec_masks[i].tx,
be->codec_masks[i].rx,
be->slots, be->slot_width);
if (ret && ret != -ENOTSUPP) {
dev_err(codec_dai->dev,
"setting tdm link slots failed\n");
return ret;
}
}
ret = axg_tdm_set_tdm_slots(snd_soc_rtd_to_cpu(rtd, 0), be->tx_mask, be->rx_mask,
be->slots, be->slot_width);
if (ret) {
dev_err(snd_soc_rtd_to_cpu(rtd, 0)->dev, "setting tdm link slots failed\n");
return ret;
}
return 0;
}
static int axg_card_tdm_dai_lb_init(struct snd_soc_pcm_runtime *rtd)
{
struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card);
struct axg_dai_link_tdm_data *be =
(struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];
int ret;
/* The loopback rx_mask is the pad tx_mask */
ret = axg_tdm_set_tdm_slots(snd_soc_rtd_to_cpu(rtd, 0), NULL, be->tx_mask,
be->slots, be->slot_width);
if (ret) {
dev_err(snd_soc_rtd_to_cpu(rtd, 0)->dev, "setting tdm link slots failed\n");
return ret;
}
return 0;
}
static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
Annotation
- Immediate include surface: `linux/module.h`, `linux/of_platform.h`, `sound/soc.h`, `sound/soc-dai.h`, `axg-tdm.h`, `meson-card.h`.
- Detected declarations: `struct axg_dai_link_tdm_mask`, `struct axg_dai_link_tdm_data`, `function axg_card_tdm_be_hw_params`, `function axg_card_tdm_dai_init`, `function for_each_rtd_codec_dais`, `function axg_card_tdm_dai_lb_init`, `function axg_card_add_tdm_loopback`, `function axg_card_parse_cpu_tdm_slots`, `function axg_card_parse_codecs_masks`, `function for_each_child_of_node_scoped`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source 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.