sound/soc/codecs/nau8821.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/nau8821.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/nau8821.c
Extension
.c
Size
64590 bytes
Lines
2007
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct nau8821_fll {
	int mclk_src;
	int ratio;
	int fll_frac;
	int fll_int;
	int clk_ref_div;
};

struct nau8821_fll_attr {
	unsigned int param;
	unsigned int val;
};

/* scaling for mclk from sysclk_src output */
static const struct nau8821_fll_attr mclk_src_scaling[] = {
	{ 1, 0x0 },
	{ 2, 0x2 },
	{ 4, 0x3 },
	{ 8, 0x4 },
	{ 16, 0x5 },
	{ 32, 0x6 },
	{ 3, 0x7 },
	{ 6, 0xa },
	{ 12, 0xb },
	{ 24, 0xc },
	{ 48, 0xd },
	{ 96, 0xe },
	{ 5, 0xf },
};

/* ratio for input clk freq */
static const struct nau8821_fll_attr fll_ratio[] = {
	{ 512000, 0x01 },
	{ 256000, 0x02 },
	{ 128000, 0x04 },
	{ 64000, 0x08 },
	{ 32000, 0x10 },
	{ 8000, 0x20 },
	{ 4000, 0x40 },
};

static const struct nau8821_fll_attr fll_pre_scalar[] = {
	{ 0, 0x0 },
	{ 1, 0x1 },
	{ 2, 0x2 },
	{ 3, 0x3 },
};

/* over sampling rate */
struct nau8821_osr_attr {
	unsigned int osr;
	unsigned int clk_src;
};

static const struct nau8821_osr_attr osr_dac_sel[] = {
	{ 64, 2 },	/* OSR 64, SRC 1/4 */
	{ 256, 0 },	/* OSR 256, SRC 1 */
	{ 128, 1 },	/* OSR 128, SRC 1/2 */
	{ 0, 0 },
	{ 32, 3 },	/* OSR 32, SRC 1/8 */
};

static const struct nau8821_osr_attr osr_adc_sel[] = {
	{ 32, 3 },	/* OSR 32, SRC 1/8 */
	{ 64, 2 },	/* OSR 64, SRC 1/4 */
	{ 128, 1 },	/* OSR 128, SRC 1/2 */
	{ 256, 0 },	/* OSR 256, SRC 1 */
};

struct nau8821_dmic_speed {
	unsigned int param;
	unsigned int val;
};

static const struct nau8821_dmic_speed dmic_speed_sel[] = {
	{ 0, 0x0 },	/*SPEED 1, SRC 1 */
	{ 1, 0x1 },	/*SPEED 2, SRC 1/2 */
	{ 2, 0x2 },	/*SPEED 4, SRC 1/4 */
	{ 3, 0x3 },	/*SPEED 8, SRC 1/8 */
};

static const struct reg_default nau8821_reg_defaults[] = {
	{ NAU8821_R01_ENA_CTRL, 0x00ff },
	{ NAU8821_R03_CLK_DIVIDER, 0x0050 },
	{ NAU8821_R04_FLL1, 0x0 },
	{ NAU8821_R05_FLL2, 0x00bc },
	{ NAU8821_R06_FLL3, 0x0008 },
	{ NAU8821_R07_FLL4, 0x0010 },
	{ NAU8821_R08_FLL5, 0x4000 },
	{ NAU8821_R09_FLL6, 0x6900 },

Annotation

Implementation Notes