sound/soc/codecs/madera.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/madera.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/madera.c- Extension
.c- Size
- 125071 bytes
- Lines
- 4797
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/gcd.hlinux/module.hlinux/pm_runtime.hlinux/slab.hlinux/string_choices.hsound/pcm.hsound/pcm_params.hsound/tlv.hlinux/irqchip/irq-madera.hlinux/mfd/madera/core.hlinux/mfd/madera/registers.hlinux/mfd/madera/pdata.hsound/madera-pdata.hdt-bindings/sound/madera.hmadera.h
Detected Declarations
struct madera_fll_gainsstruct madera_fllao_patchfunction madera_clk_evfunction madera_spin_sysclkfunction madera_sysclk_evfunction madera_check_speaker_overheatfunction madera_spk_evfunction madera_thermal_warnfunction madera_init_overheatfunction madera_free_overheatfunction madera_get_variable_u32_arrayfunction madera_prop_get_inmodefunction madera_prop_get_pdatafunction madera_core_initfunction madera_core_freefunction madera_debug_dump_domain_groupsfunction madera_domain_clk_evfunction madera_out1_demux_putfunction madera_out1_demux_getfunction madera_inmux_putfunction madera_can_change_grp_ratefunction madera_adsp_rate_getfunction madera_adsp_rate_putfunction madera_write_adsp_clk_settingfunction madera_set_adsp_clkfunction madera_rate_putfunction madera_configure_input_modefunction madera_init_inputsfunction madera_init_outputsfunction madera_init_bus_error_irqfunction madera_free_bus_error_irqfunction madera_dfc_putfunction madera_lp_mode_putfunction madera_in_set_vufunction madera_in_evfunction madera_out_evfunction madera_hp_evfunction madera_anc_evfunction madera_set_opclkfunction madera_get_sysclk_settingfunction madera_get_legacy_dspclk_settingfunction madera_get_dspclk_settingfunction madera_set_outclkfunction madera_set_sysclkfunction madera_set_fmtfunction madera_startupfunction madera_hw_params_ratefunction madera_aif_cfg_changed
Annotated Snippet
struct madera_fll_gains {
unsigned int min;
unsigned int max;
int gain; /* main gain */
int alt_gain; /* alternate integer gain */
};
static const struct madera_fll_gains madera_fll_sync_gains[] = {
{ 0, 256000, 0, -1 },
{ 256000, 1000000, 2, -1 },
{ 1000000, 13500000, 4, -1 },
};
static const struct madera_fll_gains madera_fll_main_gains[] = {
{ 0, 100000, 0, 2 },
{ 100000, 375000, 2, 2 },
{ 375000, 768000, 3, 2 },
{ 768001, 1500000, 3, 3 },
{ 1500000, 6000000, 4, 3 },
{ 6000000, 13500000, 5, 3 },
};
static int madera_find_sync_fratio(unsigned int fref, int *fratio)
{
int i;
for (i = 0; i < ARRAY_SIZE(fll_sync_fratios); i++) {
if (fll_sync_fratios[i].min <= fref &&
fref <= fll_sync_fratios[i].max) {
if (fratio)
*fratio = fll_sync_fratios[i].fratio;
return fll_sync_fratios[i].ratio;
}
}
return -EINVAL;
}
static int madera_find_main_fratio(unsigned int fref, unsigned int fout,
int *fratio)
{
int ratio = 1;
while ((fout / (ratio * fref)) > MADERA_FLL_MAX_N)
ratio++;
if (fratio)
*fratio = ratio - 1;
return ratio;
}
static int madera_find_fratio(struct madera_fll *fll, unsigned int fref,
bool sync, int *fratio)
{
switch (fll->madera->type) {
case CS47L35:
switch (fll->madera->rev) {
case 0:
/* rev A0 uses sync calculation for both loops */
return madera_find_sync_fratio(fref, fratio);
default:
if (sync)
return madera_find_sync_fratio(fref, fratio);
else
return madera_find_main_fratio(fref,
fll->fout,
fratio);
}
break;
case CS47L85:
case WM1840:
/* these use the same calculation for main and sync loops */
return madera_find_sync_fratio(fref, fratio);
default:
if (sync)
return madera_find_sync_fratio(fref, fratio);
else
return madera_find_main_fratio(fref, fll->fout, fratio);
}
}
static int madera_calc_fratio(struct madera_fll *fll,
struct madera_fll_cfg *cfg,
unsigned int fref, bool sync)
{
int init_ratio, ratio;
int refdiv, div;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gcd.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/slab.h`, `linux/string_choices.h`, `sound/pcm.h`, `sound/pcm_params.h`.
- Detected declarations: `struct madera_fll_gains`, `struct madera_fllao_patch`, `function madera_clk_ev`, `function madera_spin_sysclk`, `function madera_sysclk_ev`, `function madera_check_speaker_overheat`, `function madera_spk_ev`, `function madera_thermal_warn`, `function madera_init_overheat`, `function madera_free_overheat`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.