sound/soc/meson/gx-card.c
Source file repositories/reference/linux-study-clean/sound/soc/meson/gx-card.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/meson/gx-card.c- Extension
.c- Size
- 3647 bytes
- Lines
- 143
- 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.hmeson-card.h
Detected Declarations
struct gx_dai_link_i2s_datafunction gx_card_i2s_be_hw_paramsfunction gx_card_parse_i2sfunction gx_card_cpu_identifyfunction gx_card_add_link
Annotated Snippet
struct gx_dai_link_i2s_data {
unsigned int mclk_fs;
};
/*
* 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 gx_card_i2s_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 gx_dai_link_i2s_data *be =
(struct gx_dai_link_i2s_data *)priv->link_data[rtd->id];
return meson_card_i2s_set_sysclk(substream, params, be->mclk_fs);
}
static const struct snd_soc_ops gx_card_i2s_be_ops = {
.hw_params = gx_card_i2s_be_hw_params,
};
static int gx_card_parse_i2s(struct snd_soc_card *card,
struct device_node *node,
int *index)
{
struct meson_card *priv = snd_soc_card_get_drvdata(card);
struct snd_soc_dai_link *link = &card->dai_link[*index];
struct gx_dai_link_i2s_data *be;
/* Allocate i2s link parameters */
be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL);
if (!be)
return -ENOMEM;
priv->link_data[*index] = be;
/* Setup i2s link */
link->ops = &gx_card_i2s_be_ops;
link->dai_fmt = meson_card_parse_daifmt(node, link->cpus->of_node);
of_property_read_u32(node, "mclk-fs", &be->mclk_fs);
return 0;
}
static int gx_card_cpu_identify(struct snd_soc_dai_link_component *c,
char *match)
{
if (of_device_is_compatible(c->of_node, DT_PREFIX "aiu")) {
if (strstr(c->dai_name, match))
return 1;
}
/* dai not matched */
return 0;
}
static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
int *index)
{
struct snd_soc_dai_link *dai_link = &card->dai_link[*index];
struct snd_soc_dai_link_component *cpu;
int ret;
cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL);
if (!cpu)
return -ENOMEM;
dai_link->cpus = cpu;
dai_link->num_cpus = 1;
ret = meson_card_parse_dai(card, np, dai_link->cpus);
if (ret)
return ret;
if (gx_card_cpu_identify(dai_link->cpus, "FIFO"))
return meson_card_set_fe_link(card, dai_link, np, true);
ret = meson_card_set_be_link(card, dai_link, np);
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/module.h`, `linux/of_platform.h`, `sound/soc.h`, `sound/soc-dai.h`, `meson-card.h`.
- Detected declarations: `struct gx_dai_link_i2s_data`, `function gx_card_i2s_be_hw_params`, `function gx_card_parse_i2s`, `function gx_card_cpu_identify`, `function gx_card_add_link`.
- 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.