sound/soc/codecs/rt1318.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/rt1318.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/rt1318.c- Extension
.c- Size
- 34432 bytes
- Lines
- 1353
- 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/acpi.hlinux/fs.hlinux/module.hlinux/moduleparam.hlinux/init.hlinux/delay.hlinux/pm.hlinux/regmap.hlinux/i2c.hlinux/platform_device.hlinux/firmware.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/soc-dapm.hsound/initval.hsound/tlv.hsound/rt1318.hrt1318.h
Detected Declarations
function rt1318_volatile_registerfunction rt1318_readable_registerfunction rt1318_dac_eventfunction rt1318_dvol_putfunction rt1318_dvol_getfunction rt1318_get_clk_infofunction rt1318_clk_ip_infofunction rt1318_hw_paramsfunction rt1318_set_dai_fmtfunction rt1318_set_dai_sysclkfunction rt1318_pll_calcfunction rt1318_set_dai_pllfunction rt1318_set_tdm_slotfunction rt1318_probefunction rt1318_removefunction rt1318_suspendfunction rt1318_resumefunction rt1318_parse_dtfunction rt1318_calibration_sequencefunction rt1318_r0_calculatefunction rt1318_r0_restorefunction rt1318_calibratefunction rt1318_calibration_workfunction rt1318_i2c_probe
Annotated Snippet
if (in_t == pll_out) {
m_bypass = true;
n = n_t;
goto code_find;
}
red = abs(in_t - pll_out);
if (red < red_t) {
m_bypass = true;
n = n_t;
m = m_t;
if (red == 0)
goto code_find;
red_t = red;
}
for (m_t = 0; m_t <= max_m; m_t++) {
out_t = in_t / (m_t + 2);
red = abs(out_t - pll_out);
if (red < red_t) {
m_bypass = false;
n = n_t;
m = m_t;
if (red == 0)
goto code_find;
red_t = red;
}
}
}
pr_debug("Only get approximation about PLL\n");
code_find:
pll_code->m_bp = m_bypass;
pll_code->k_bp = k_bypass;
pll_code->m_code = m;
pll_code->n_code = n;
pll_code->k_code = k;
return 0;
}
static int rt1318_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
unsigned int freq_in, unsigned int freq_out)
{
struct snd_soc_component *component = dai->component;
struct rt1318_priv *rt1318 = snd_soc_component_get_drvdata(component);
struct rt1318_pll_code pll_code;
int ret;
if (!freq_in || !freq_out) {
dev_dbg(component->dev, "PLL disabled\n");
rt1318->pll_in = 0;
rt1318->pll_out = 0;
return 0;
}
if (source == rt1318->pll_src && freq_in == rt1318->pll_in &&
freq_out == rt1318->pll_out)
return 0;
switch (source) {
case RT1318_PLL_S_BCLK0:
regmap_update_bits(rt1318->regmap, RT1318_CLK1,
RT1318_PLLIN_MASK, RT1318_PLLIN_BCLK0);
break;
case RT1318_PLL_S_BCLK1:
regmap_update_bits(rt1318->regmap, RT1318_CLK1,
RT1318_PLLIN_MASK, RT1318_PLLIN_BCLK1);
break;
case RT1318_PLL_S_RC:
regmap_update_bits(rt1318->regmap, RT1318_CLK1,
RT1318_PLLIN_MASK, RT1318_PLLIN_RC);
break;
case RT1318_PLL_S_MCLK:
regmap_update_bits(rt1318->regmap, RT1318_CLK1,
RT1318_PLLIN_MASK, RT1318_PLLIN_MCLK);
break;
case RT1318_PLL_S_SDW_IN_PLL:
regmap_update_bits(rt1318->regmap, RT1318_CLK1,
RT1318_PLLIN_MASK, RT1318_PLLIN_SDW1);
break;
case RT1318_PLL_S_SDW_0:
regmap_update_bits(rt1318->regmap, RT1318_CLK1,
RT1318_PLLIN_MASK, RT1318_PLLIN_SDW2);
break;
case RT1318_PLL_S_SDW_1:
regmap_update_bits(rt1318->regmap, RT1318_CLK1,
RT1318_PLLIN_MASK, RT1318_PLLIN_SDW3);
break;
case RT1318_PLL_S_SDW_2:
regmap_update_bits(rt1318->regmap, RT1318_CLK1,
RT1318_PLLIN_MASK, RT1318_PLLIN_SDW4);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/fs.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/delay.h`, `linux/pm.h`, `linux/regmap.h`.
- Detected declarations: `function rt1318_volatile_register`, `function rt1318_readable_register`, `function rt1318_dac_event`, `function rt1318_dvol_put`, `function rt1318_dvol_get`, `function rt1318_get_clk_info`, `function rt1318_clk_ip_info`, `function rt1318_hw_params`, `function rt1318_set_dai_fmt`, `function rt1318_set_dai_sysclk`.
- 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.