sound/soc/sunxi/sun8i-codec-analog.c
Source file repositories/reference/linux-study-clean/sound/soc/sunxi/sun8i-codec-analog.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sunxi/sun8i-codec-analog.c- Extension
.c- Size
- 27465 bytes
- Lines
- 854
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hsound/soc.hsound/soc-dapm.hsound/tlv.hsun8i-adda-pr-regmap.h
Detected Declarations
struct sun8i_codec_analog_quirksfunction sun8i_headphone_amp_eventfunction sun8i_codec_add_headphonefunction sun8i_codec_add_mbiasfunction sun8i_codec_add_hmicfunction sun8i_codec_add_lineinfunction sun8i_codec_add_lineoutfunction sun8i_codec_add_mic2function sun8i_codec_analog_add_mixerfunction sun8i_codec_analog_cmpnt_probefunction sun8i_codec_analog_probe
Annotated Snippet
struct sun8i_codec_analog_quirks {
bool has_headphone;
bool has_hmic;
bool has_linein;
bool has_lineout;
bool has_mbias;
bool has_mic2;
};
static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = {
.has_headphone = true,
.has_hmic = true,
.has_linein = true,
.has_mbias = true,
.has_mic2 = true,
};
static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = {
.has_linein = true,
.has_lineout = true,
.has_mbias = true,
.has_mic2 = true,
};
static int sun8i_codec_analog_add_mixer(struct snd_soc_component *cmpnt,
const struct sun8i_codec_analog_quirks *quirks)
{
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(cmpnt);
struct device *dev = cmpnt->dev;
int ret;
if (!quirks->has_mic2 && !quirks->has_linein) {
/*
* Apply the special widget set which has uses a control
* without MIC2 and Line In, for SoCs without these.
* TODO: not all special cases are supported now, this case
* is present because it's the case of V3s.
*/
ret = snd_soc_dapm_new_controls(dapm,
sun8i_v3s_codec_mixer_widgets,
ARRAY_SIZE(sun8i_v3s_codec_mixer_widgets));
if (ret) {
dev_err(dev, "Failed to add V3s Mixer DAPM widgets: %d\n", ret);
return ret;
}
} else {
/* Apply the generic mixer widget set. */
ret = snd_soc_dapm_new_controls(dapm,
sun8i_codec_mixer_widgets,
ARRAY_SIZE(sun8i_codec_mixer_widgets));
if (ret) {
dev_err(dev, "Failed to add Mixer DAPM widgets: %d\n", ret);
return ret;
}
}
ret = snd_soc_dapm_add_routes(dapm, sun8i_codec_mixer_routes,
ARRAY_SIZE(sun8i_codec_mixer_routes));
if (ret) {
dev_err(dev, "Failed to add Mixer DAPM routes: %d\n", ret);
return ret;
}
return 0;
}
static const struct sun8i_codec_analog_quirks sun8i_v3s_quirks = {
.has_headphone = true,
.has_hmic = true,
};
static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt)
{
struct device *dev = cmpnt->dev;
const struct sun8i_codec_analog_quirks *quirks;
int ret;
/*
* This would never return NULL unless someone directly registers a
* platform device matching this driver's name, without specifying a
* device tree node.
*/
quirks = of_device_get_match_data(dev);
/* Add controls, widgets, and routes for individual features */
ret = sun8i_codec_analog_add_mixer(cmpnt, quirks);
if (ret)
return ret;
if (quirks->has_headphone) {
Annotation
- Immediate include surface: `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`, `sound/soc.h`, `sound/soc-dapm.h`.
- Detected declarations: `struct sun8i_codec_analog_quirks`, `function sun8i_headphone_amp_event`, `function sun8i_codec_add_headphone`, `function sun8i_codec_add_mbias`, `function sun8i_codec_add_hmic`, `function sun8i_codec_add_linein`, `function sun8i_codec_add_lineout`, `function sun8i_codec_add_mic2`, `function sun8i_codec_analog_add_mixer`, `function sun8i_codec_analog_cmpnt_probe`.
- 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.