sound/soc/codecs/wm8731.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/wm8731.c
Extension
.c
Size
16899 bytes
Lines
652
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 _coeff_div {
	u32 mclk;
	u32 rate;
	u16 fs;
	u8 sr:4;
	u8 bosr:1;
	u8 usb:1;
};

/* codec mclk clock divider coefficients */
static const struct _coeff_div coeff_div[] = {
	/* 48k */
	{12288000, 48000, 256, 0x0, 0x0, 0x0},
	{18432000, 48000, 384, 0x0, 0x1, 0x0},
	{12000000, 48000, 250, 0x0, 0x0, 0x1},

	/* 32k */
	{12288000, 32000, 384, 0x6, 0x0, 0x0},
	{18432000, 32000, 576, 0x6, 0x1, 0x0},
	{12000000, 32000, 375, 0x6, 0x0, 0x1},

	/* 8k */
	{12288000, 8000, 1536, 0x3, 0x0, 0x0},
	{18432000, 8000, 2304, 0x3, 0x1, 0x0},
	{11289600, 8000, 1408, 0xb, 0x0, 0x0},
	{16934400, 8000, 2112, 0xb, 0x1, 0x0},
	{12000000, 8000, 1500, 0x3, 0x0, 0x1},

	/* 96k */
	{12288000, 96000, 128, 0x7, 0x0, 0x0},
	{18432000, 96000, 192, 0x7, 0x1, 0x0},
	{12000000, 96000, 125, 0x7, 0x0, 0x1},

	/* 44.1k */
	{11289600, 44100, 256, 0x8, 0x0, 0x0},
	{16934400, 44100, 384, 0x8, 0x1, 0x0},
	{12000000, 44100, 272, 0x8, 0x1, 0x1},

	/* 88.2k */
	{11289600, 88200, 128, 0xf, 0x0, 0x0},
	{16934400, 88200, 192, 0xf, 0x1, 0x0},
	{12000000, 88200, 136, 0xf, 0x1, 0x1},
};

/* rates constraints */
static const unsigned int wm8731_rates_12000000[] = {
	8000, 32000, 44100, 48000, 96000, 88200,
};

static const unsigned int wm8731_rates_12288000_18432000[] = {
	8000, 32000, 48000, 96000,
};

static const unsigned int wm8731_rates_11289600_16934400[] = {
	8000, 44100, 88200,
};

static const struct snd_pcm_hw_constraint_list wm8731_constraints_12000000 = {
	.list = wm8731_rates_12000000,
	.count = ARRAY_SIZE(wm8731_rates_12000000),
};

static const
struct snd_pcm_hw_constraint_list wm8731_constraints_12288000_18432000 = {
	.list = wm8731_rates_12288000_18432000,
	.count = ARRAY_SIZE(wm8731_rates_12288000_18432000),
};

static const
struct snd_pcm_hw_constraint_list wm8731_constraints_11289600_16934400 = {
	.list = wm8731_rates_11289600_16934400,
	.count = ARRAY_SIZE(wm8731_rates_11289600_16934400),
};

static inline int get_coeff(int mclk, int rate)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
		if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
			return i;
	}
	return 0;
}

static int wm8731_hw_params(struct snd_pcm_substream *substream,
			    struct snd_pcm_hw_params *params,
			    struct snd_soc_dai *dai)
{
	struct snd_soc_component *component = dai->component;

Annotation

Implementation Notes