sound/soc/fsl/fsl_utils.c
Source file repositories/reference/linux-study-clean/sound/soc/fsl/fsl_utils.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/fsl/fsl_utils.c- Extension
.c- Size
- 8712 bytes
- Lines
- 334
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/clk-provider.hlinux/module.hlinux/of_address.hlinux/pm_runtime.hsound/soc.hfsl_utils.h
Detected Declarations
function fsl_asoc_get_dma_channelfunction fsl_asoc_get_pll_clocksfunction fsl_asoc_reparent_pll_clocksfunction fsl_asoc_constrain_ratesfunction statefunction fsl_asoc_put_xr_sxfunction fsl_asoc_get_enum_doublefunction fsl_asoc_put_enum_doublefunction fsl_asoc_get_volswfunction fsl_asoc_put_volswexport fsl_asoc_get_dma_channelexport fsl_asoc_get_pll_clocksexport fsl_asoc_reparent_pll_clocksexport fsl_asoc_constrain_ratesexport fsl_asoc_get_xr_sxexport fsl_asoc_put_xr_sxexport fsl_asoc_get_enum_doubleexport fsl_asoc_put_enum_doubleexport fsl_asoc_get_volswexport fsl_asoc_put_volsw
Annotated Snippet
clk_is_match(pp, pll11k_clk)) {
pll = pp;
break;
}
p = pp;
}
npll = (do_div(ratio, 8000) ? pll11k_clk : pll8k_clk);
reparent = (pll && !clk_is_match(pll, npll));
if (reparent) {
ret = clk_set_parent(p, npll);
if (ret < 0)
dev_warn(dev, "failed to set parent:%d\n", ret);
}
}
EXPORT_SYMBOL(fsl_asoc_reparent_pll_clocks);
/**
* fsl_asoc_constrain_rates - constrain rates according to clocks
*
* @target_constr: target constraint
* @original_constr: original constraint
* @pll8k_clk: PLL clock pointer for 8kHz
* @pll11k_clk: PLL clock pointer for 11kHz
* @ext_clk: External clock pointer
* @target_rates: target rates array
*
* This function constrain rates according to clocks
*/
void fsl_asoc_constrain_rates(struct snd_pcm_hw_constraint_list *target_constr,
const struct snd_pcm_hw_constraint_list *original_constr,
struct clk *pll8k_clk, struct clk *pll11k_clk,
struct clk *ext_clk, int *target_rates)
{
int i, j, k = 0;
u64 clk_rate[3];
*target_constr = *original_constr;
if (pll8k_clk || pll11k_clk || ext_clk) {
target_constr->list = target_rates;
target_constr->count = 0;
for (i = 0; i < original_constr->count; i++) {
clk_rate[0] = clk_get_rate(pll8k_clk);
clk_rate[1] = clk_get_rate(pll11k_clk);
clk_rate[2] = clk_get_rate(ext_clk);
for (j = 0; j < 3; j++) {
if (clk_rate[j] != 0 &&
do_div(clk_rate[j], original_constr->list[i]) == 0) {
target_rates[k++] = original_constr->list[i];
target_constr->count++;
break;
}
}
}
/* protection for if there is no proper rate found*/
if (!target_constr->count)
*target_constr = *original_constr;
}
}
EXPORT_SYMBOL(fsl_asoc_constrain_rates);
/*
* Below functions are used by mixer interface to avoid accessing registers
* which are volatile at pm runtime suspend state (cache_only is enabled).
*/
int fsl_asoc_get_xr_sx(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
int ret = 0;
ret = pm_runtime_resume_and_get(component->dev);
if (ret)
return ret;
ret = snd_soc_get_xr_sx(kcontrol, ucontrol);
pm_runtime_put_autosuspend(component->dev);
return ret;
}
EXPORT_SYMBOL_GPL(fsl_asoc_get_xr_sx);
int fsl_asoc_put_xr_sx(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
int ret = 0;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/module.h`, `linux/of_address.h`, `linux/pm_runtime.h`, `sound/soc.h`, `fsl_utils.h`.
- Detected declarations: `function fsl_asoc_get_dma_channel`, `function fsl_asoc_get_pll_clocks`, `function fsl_asoc_reparent_pll_clocks`, `function fsl_asoc_constrain_rates`, `function state`, `function fsl_asoc_put_xr_sx`, `function fsl_asoc_get_enum_double`, `function fsl_asoc_put_enum_double`, `function fsl_asoc_get_volsw`, `function fsl_asoc_put_volsw`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.