sound/soc/codecs/sgtl5000.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/sgtl5000.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/sgtl5000.c- Extension
.c- Size
- 52063 bytes
- Lines
- 1840
- 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/moduleparam.hlinux/init.hlinux/delay.hlinux/slab.hlinux/pm.hlinux/i2c.hlinux/clk.hlinux/log2.hlinux/of.hlinux/regmap.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/regulator/consumer.hsound/core.hsound/tlv.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/initval.hsgtl5000.h
Detected Declarations
struct sgtl5000_privenum sgtl5000_regulator_suppliesenum sgtl5000_micbias_resistorfunction hp_sel_inputfunction mute_outputfunction restore_outputfunction vag_power_onfunction vag_power_consumersfunction vag_power_offfunction mic_bias_eventfunction vag_and_mute_controlfunction headphone_pga_eventfunction adc_updown_depopfunction dac_updown_depopfunction dac_info_volswfunction dac_get_volswfunction dac_put_volswfunction avc_get_thresholdfunction avc_put_thresholdfunction sgtl5000_mute_streamfunction sgtl5000_set_dai_fmtfunction sgtl5000_set_dai_sysclkfunction sgtl5000_set_clockfunction sgtl5000_pcm_hw_paramsfunction sgtl5000_set_bias_levelfunction sgtl5000_volatilefunction sgtl5000_readablefunction sgtl5000_set_power_regsfunction sgtl5000_enable_regulatorsfunction sgtl5000_probefunction sgtl5000_of_xlate_dai_idfunction sgtl5000_fill_defaultsfunction sgtl5000_i2c_probefunction sgtl5000_i2c_removefunction sgtl5000_i2c_shutdown
Annotated Snippet
struct sgtl5000_priv {
int sysclk; /* sysclk rate */
int master; /* i2s master or not */
int fmt; /* i2s data format */
struct regulator_bulk_data supplies[SGTL5000_SUPPLY_NUM];
int num_supplies;
struct regmap *regmap;
struct clk *mclk;
int revision;
u8 micbias_resistor;
u8 micbias_voltage;
u8 lrclk_strength;
u8 sclk_strength;
u16 mute_state[LAST_POWER_EVENT + 1];
};
static inline int hp_sel_input(struct snd_soc_component *component)
{
return (snd_soc_component_read(component, SGTL5000_CHIP_ANA_CTRL) &
SGTL5000_HP_SEL_MASK) >> SGTL5000_HP_SEL_SHIFT;
}
static inline u16 mute_output(struct snd_soc_component *component,
u16 mute_mask)
{
u16 mute_reg = snd_soc_component_read(component,
SGTL5000_CHIP_ANA_CTRL);
snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_CTRL,
mute_mask, mute_mask);
return mute_reg;
}
static inline void restore_output(struct snd_soc_component *component,
u16 mute_mask, u16 mute_reg)
{
snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_CTRL,
mute_mask, mute_reg);
}
static void vag_power_on(struct snd_soc_component *component, u32 source)
{
if (snd_soc_component_read(component, SGTL5000_CHIP_ANA_POWER) &
SGTL5000_VAG_POWERUP)
return;
snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
/* When VAG powering on to get local loop from Line-In, the sleep
* is required to avoid loud pop.
*/
if (hp_sel_input(component) == SGTL5000_HP_SEL_LINE_IN &&
source == HP_POWER_EVENT)
msleep(SGTL5000_VAG_POWERUP_DELAY);
}
static int vag_power_consumers(struct snd_soc_component *component,
u16 ana_pwr_reg, u32 source)
{
int consumers = 0;
/* count dac/adc consumers unconditional */
if (ana_pwr_reg & SGTL5000_DAC_POWERUP)
consumers++;
if (ana_pwr_reg & SGTL5000_ADC_POWERUP)
consumers++;
/*
* If the event comes from HP and Line-In is selected,
* current action is 'DAC to be powered down'.
* As HP_POWERUP is not set when HP muxed to line-in,
* we need to keep VAG power ON.
*/
if (source == HP_POWER_EVENT) {
if (hp_sel_input(component) == SGTL5000_HP_SEL_LINE_IN)
consumers++;
} else {
if (ana_pwr_reg & SGTL5000_HP_POWERUP)
consumers++;
}
return consumers;
}
static void vag_power_off(struct snd_soc_component *component, u32 source)
{
u16 ana_pwr = snd_soc_component_read(component,
SGTL5000_CHIP_ANA_POWER);
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/delay.h`, `linux/slab.h`, `linux/pm.h`, `linux/i2c.h`, `linux/clk.h`.
- Detected declarations: `struct sgtl5000_priv`, `enum sgtl5000_regulator_supplies`, `enum sgtl5000_micbias_resistor`, `function hp_sel_input`, `function mute_output`, `function restore_output`, `function vag_power_on`, `function vag_power_consumers`, `function vag_power_off`, `function mic_bias_event`.
- 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.