sound/soc/sunxi/sun8i-codec.c
Source file repositories/reference/linux-study-clean/sound/soc/sunxi/sun8i-codec.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sunxi/sun8i-codec.c- Extension
.c- Size
- 54812 bytes
- Lines
- 1721
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/delay.hlinux/clk.hlinux/input.hlinux/io.hlinux/irq.hlinux/mutex.hlinux/of.hlinux/pm_runtime.hlinux/regmap.hlinux/log2.hsound/jack.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/tlv.h
Detected Declarations
struct sun8i_codec_aifstruct sun8i_codec_quirksstruct sun8i_codecstruct sun8i_codec_clk_divfunction sun8i_codec_runtime_resumefunction sun8i_codec_runtime_suspendfunction sun8i_codec_get_hw_ratefunction sun8i_codec_update_sample_ratefunction sun8i_codec_set_fmtfunction sun8i_codec_set_tdm_slotfunction sun8i_codec_startupfunction sun8i_codec_get_bclk_divfunction sun8i_codec_get_lrck_div_orderfunction sun8i_codec_get_sysclk_ratefunction sun8i_codec_hw_paramsfunction sun8i_codec_hw_freefunction sun8i_codec_aif_eventfunction sun8i_codec_component_probefunction sun8i_codec_set_hmic_biasfunction sun8i_codec_jack_workfunction sun8i_codec_jack_irqfunction sun8i_codec_enable_jack_detectfunction sun8i_codec_disable_jack_detectfunction sun8i_codec_component_set_jackfunction sun8i_codec_volatile_regfunction sun8i_codec_probefunction sun8i_codec_remove
Annotated Snippet
struct sun8i_codec_aif {
unsigned int lrck_div_order;
unsigned int sample_rate;
unsigned int slots;
unsigned int slot_width;
unsigned int active_streams : 2;
unsigned int open_streams : 2;
};
struct sun8i_codec_quirks {
bool bus_clock : 1;
bool jack_detection : 1;
bool legacy_widgets : 1;
bool lrck_inversion : 1;
};
enum {
SUN8I_JACK_STATUS_DISCONNECTED,
SUN8I_JACK_STATUS_WAITING_HBIAS,
SUN8I_JACK_STATUS_CONNECTED,
};
struct sun8i_codec {
struct snd_soc_component *component;
struct regmap *regmap;
struct clk *clk_bus;
struct clk *clk_module;
const struct sun8i_codec_quirks *quirks;
struct sun8i_codec_aif aifs[SUN8I_CODEC_NAIFS];
struct snd_soc_jack *jack;
struct delayed_work jack_work;
int jack_irq;
int jack_status;
int jack_type;
int jack_last_sample;
ktime_t jack_hbias_ready;
struct mutex jack_mutex;
int last_hmic_irq;
unsigned int sysclk_rate;
int sysclk_refcnt;
};
static struct snd_soc_dai_driver sun8i_codec_dais[];
static int sun8i_codec_runtime_resume(struct device *dev)
{
struct sun8i_codec *scodec = dev_get_drvdata(dev);
int ret;
ret = clk_prepare_enable(scodec->clk_bus);
if (ret) {
dev_err(dev, "Failed to enable the bus clock\n");
return ret;
}
regcache_cache_only(scodec->regmap, false);
ret = regcache_sync(scodec->regmap);
if (ret) {
dev_err(dev, "Failed to sync regmap cache\n");
return ret;
}
return 0;
}
static int sun8i_codec_runtime_suspend(struct device *dev)
{
struct sun8i_codec *scodec = dev_get_drvdata(dev);
regcache_cache_only(scodec->regmap, true);
regcache_mark_dirty(scodec->regmap);
clk_disable_unprepare(scodec->clk_bus);
return 0;
}
static int sun8i_codec_get_hw_rate(unsigned int sample_rate)
{
switch (sample_rate) {
case 7350:
case 8000:
return 0x0;
case 11025:
return 0x1;
case 12000:
return 0x2;
case 14700:
case 16000:
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/clk.h`, `linux/input.h`, `linux/io.h`, `linux/irq.h`, `linux/mutex.h`, `linux/of.h`.
- Detected declarations: `struct sun8i_codec_aif`, `struct sun8i_codec_quirks`, `struct sun8i_codec`, `struct sun8i_codec_clk_div`, `function sun8i_codec_runtime_resume`, `function sun8i_codec_runtime_suspend`, `function sun8i_codec_get_hw_rate`, `function sun8i_codec_update_sample_rate`, `function sun8i_codec_set_fmt`, `function sun8i_codec_set_tdm_slot`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.