sound/soc/rockchip/rockchip_pdm.c
Source file repositories/reference/linux-study-clean/sound/soc/rockchip/rockchip_pdm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/rockchip/rockchip_pdm.c- Extension
.c- Size
- 16067 bytes
- Lines
- 721
- 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/clk.hlinux/of.hlinux/pm_runtime.hlinux/rational.hlinux/regmap.hlinux/reset.hsound/dmaengine_pcm.hsound/pcm_params.hrockchip_pdm.h
Detected Declarations
struct rk_pdm_devstruct rk_pdm_clkrefstruct rk_pdm_ds_ratioenum rk_pdm_versionfunction get_pdm_clkfunction get_pdm_ds_ratiofunction get_pdm_cic_ratiofunction samplerate_to_bitfunction rockchip_pdm_rxctrlfunction rockchip_pdm_hw_paramsfunction rockchip_pdm_set_fmtfunction rockchip_pdm_triggerfunction rockchip_pdm_dai_probefunction rockchip_pdm_runtime_suspendfunction rockchip_pdm_runtime_resumefunction rockchip_pdm_wr_regfunction rockchip_pdm_rd_regfunction rockchip_pdm_volatile_regfunction rockchip_pdm_precious_regfunction rockchip_pdm_path_parsefunction rockchip_pdm_probefunction rockchip_pdm_removefunction rockchip_pdm_suspendfunction rockchip_pdm_resume
Annotated Snippet
struct rk_pdm_dev {
struct device *dev;
struct clk *clk;
struct clk *hclk;
struct regmap *regmap;
struct snd_dmaengine_dai_dma_data capture_dma_data;
struct reset_control *reset;
enum rk_pdm_version version;
};
struct rk_pdm_clkref {
unsigned int sr;
unsigned int clk;
unsigned int clk_out;
};
struct rk_pdm_ds_ratio {
unsigned int ratio;
unsigned int sr;
};
static struct rk_pdm_clkref clkref[] = {
{ 8000, 40960000, 2048000 },
{ 11025, 56448000, 2822400 },
{ 12000, 61440000, 3072000 },
{ 8000, 98304000, 2048000 },
{ 12000, 98304000, 3072000 },
};
static struct rk_pdm_ds_ratio ds_ratio[] = {
{ 0, 192000 },
{ 0, 176400 },
{ 0, 128000 },
{ 1, 96000 },
{ 1, 88200 },
{ 1, 64000 },
{ 2, 48000 },
{ 2, 44100 },
{ 2, 32000 },
{ 3, 24000 },
{ 3, 22050 },
{ 3, 16000 },
{ 4, 12000 },
{ 4, 11025 },
{ 4, 8000 },
};
static unsigned int get_pdm_clk(struct rk_pdm_dev *pdm, unsigned int sr,
unsigned int *clk_src, unsigned int *clk_out)
{
unsigned int i, count, clk, div, rate;
clk = 0;
if (!sr)
return clk;
count = ARRAY_SIZE(clkref);
for (i = 0; i < count; i++) {
if (sr % clkref[i].sr)
continue;
div = sr / clkref[i].sr;
if ((div & (div - 1)) == 0) {
*clk_out = clkref[i].clk_out;
rate = clk_round_rate(pdm->clk, clkref[i].clk);
if (rate != clkref[i].clk)
continue;
clk = clkref[i].clk;
*clk_src = clkref[i].clk;
break;
}
}
if (!clk) {
clk = clk_round_rate(pdm->clk, PDM_SIGNOFF_CLK_RATE);
*clk_src = clk;
}
return clk;
}
static unsigned int get_pdm_ds_ratio(unsigned int sr)
{
unsigned int i, count, ratio;
ratio = 0;
if (!sr)
return ratio;
count = ARRAY_SIZE(ds_ratio);
for (i = 0; i < count; i++) {
if (sr == ds_ratio[i].sr)
Annotation
- Immediate include surface: `linux/module.h`, `linux/clk.h`, `linux/of.h`, `linux/pm_runtime.h`, `linux/rational.h`, `linux/regmap.h`, `linux/reset.h`, `sound/dmaengine_pcm.h`.
- Detected declarations: `struct rk_pdm_dev`, `struct rk_pdm_clkref`, `struct rk_pdm_ds_ratio`, `enum rk_pdm_version`, `function get_pdm_clk`, `function get_pdm_ds_ratio`, `function get_pdm_cic_ratio`, `function samplerate_to_bit`, `function rockchip_pdm_rxctrl`, `function rockchip_pdm_hw_params`.
- 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.