sound/soc/codecs/nau8824.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/nau8824.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/nau8824.c- Extension
.c- Size
- 65563 bytes
- Lines
- 2059
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/dmi.hlinux/init.hlinux/i2c.hlinux/regmap.hlinux/slab.hlinux/clk.hlinux/acpi.hlinux/math64.hlinux/semaphore.hsound/initval.hsound/tlv.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/jack.hnau8824.h
Detected Declarations
function nau8824_sema_acquirefunction nau8824_sema_releasefunction nau8824_readable_regfunction nau8824_writeable_regfunction nau8824_volatile_regfunction nau8824_output_dac_eventfunction nau8824_spk_eventfunction nau8824_pump_eventfunction system_clock_controlfunction dmic_clock_controlfunction nau8824_is_jack_insertedfunction nau8824_int_status_clear_allfunction nau8824_eject_jackfunction nau8824_jdet_workfunction nau8824_setup_auto_irqfunction nau8824_button_decodefunction nau8824_interruptfunction nau8824_get_osrfunction nau8824_dai_startupfunction nau8824_hw_paramsfunction nau8824_set_fmtfunction nau8824_set_tdm_slotfunction nau8824_calc_fll_paramfunction nau8824_fll_applyfunction nau8824_set_pllfunction nau8824_config_sysclkfunction nau8824_set_sysclkfunction nau8824_resume_setupfunction nau8824_set_bias_levelfunction nau8824_component_probefunction nau8824_suspendfunction nau8824_resumefunction nau8824_enable_jack_detectfunction nau8824_reset_chipfunction nau8824_setup_buttonsfunction nau8824_init_regsfunction nau8824_setup_irqfunction nau8824_print_device_propertiesfunction nau8824_read_device_propertiesfunction nau8824_check_quirksfunction nau8824_i2c_probeexport nau8824_enable_jack_detectexport nau8824_components
Annotated Snippet
if (nau8824_is_jack_inserted(nau8824)) {
nau8824_config_sysclk(nau8824,
NAU8824_CLK_INTERNAL, 0);
} else {
nau8824_config_sysclk(nau8824, NAU8824_CLK_DIS, 0);
}
clk_disable_unprepare(nau8824->mclk);
} else {
dev_dbg(nau8824->dev, "system clock control : POWER ON\n");
ret = clk_prepare_enable(nau8824->mclk);
if (ret)
return ret;
/* Check the clock source setting is proper or not
* no matter the source is from FLL or MCLK.
*/
regmap_read(regmap, NAU8824_REG_FLL1, &value);
clk_fll = value & NAU8824_FLL_RATIO_MASK;
/* It's error to use internal clock when playback */
regmap_read(regmap, NAU8824_REG_FLL6, &value);
error = value & NAU8824_DCO_EN;
if (!error) {
/* Check error depending on source is FLL or MCLK. */
regmap_read(regmap, NAU8824_REG_CLK_DIVIDER, &value);
if (clk_fll)
error = !(value & NAU8824_CLK_SRC_VCO);
else
error = value & NAU8824_CLK_SRC_VCO;
}
/* Recover the clock source setting if error. */
if (error) {
if (clk_fll) {
regmap_update_bits(regmap,
NAU8824_REG_FLL6, NAU8824_DCO_EN, 0);
regmap_update_bits(regmap,
NAU8824_REG_CLK_DIVIDER,
NAU8824_CLK_SRC_MASK,
NAU8824_CLK_SRC_VCO);
} else {
nau8824_config_sysclk(nau8824,
NAU8824_CLK_MCLK, 0);
}
}
}
return 0;
}
static int dmic_clock_control(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component);
int src;
unsigned int freq;
freq = clk_get_rate(nau8824->mclk);
if (!freq)
freq = nau8824->fs * 256;
/* The DMIC clock is gotten from system clock (256fs) divided by
* DMIC_SRC (1, 2, 4, 8, 16, 32). The clock has to be equal or
* less than 3.072 MHz.
*/
for (src = 0; src < 5; src++) {
if (freq / (0x1 << src) <= DMIC_CLK)
break;
}
dev_dbg(nau8824->dev, "dmic src %d for mclk %d\n", src, freq);
regmap_update_bits(nau8824->regmap, NAU8824_REG_CLK_DIVIDER,
NAU8824_CLK_DMIC_SRC_MASK, (src << NAU8824_CLK_DMIC_SRC_SFT));
return 0;
}
static const struct snd_kcontrol_new nau8824_adc_ch0_dmic =
SOC_DAPM_SINGLE("Switch", NAU8824_REG_ENA_CTRL,
NAU8824_ADC_CH0_DMIC_SFT, 1, 0);
static const struct snd_kcontrol_new nau8824_adc_ch1_dmic =
SOC_DAPM_SINGLE("Switch", NAU8824_REG_ENA_CTRL,
NAU8824_ADC_CH1_DMIC_SFT, 1, 0);
static const struct snd_kcontrol_new nau8824_adc_ch2_dmic =
SOC_DAPM_SINGLE("Switch", NAU8824_REG_ENA_CTRL,
NAU8824_ADC_CH2_DMIC_SFT, 1, 0);
static const struct snd_kcontrol_new nau8824_adc_ch3_dmic =
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/dmi.h`, `linux/init.h`, `linux/i2c.h`, `linux/regmap.h`, `linux/slab.h`, `linux/clk.h`.
- Detected declarations: `function nau8824_sema_acquire`, `function nau8824_sema_release`, `function nau8824_readable_reg`, `function nau8824_writeable_reg`, `function nau8824_volatile_reg`, `function nau8824_output_dac_event`, `function nau8824_spk_event`, `function nau8824_pump_event`, `function system_clock_control`, `function dmic_clock_control`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.