sound/soc/codecs/max98090.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/max98090.c
Extension
.c
Size
87488 bytes
Lines
2724
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct dmic_table {
	int pclk;
	struct {
		int freq;
		int comp[6]; /* One each for 8, 16, 32, 44.1, 48, and 96 kHz */
	} settings[6]; /* One for each dmic divisor. */
};

static const struct dmic_table dmic_table[] = { /* One for each pclk freq. */
	{
		.pclk = 11289600,
		.settings = {
			{ .freq = 2, .comp = { 7, 8, 3, 3, 3, 3 } },
			{ .freq = 1, .comp = { 7, 8, 2, 2, 2, 2 } },
			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
			{ .freq = 0, .comp = { 7, 8, 6, 6, 6, 6 } },
			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
		},
	},
	{
		.pclk = 12000000,
		.settings = {
			{ .freq = 2, .comp = { 7, 8, 3, 3, 3, 3 } },
			{ .freq = 1, .comp = { 7, 8, 2, 2, 2, 2 } },
			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
			{ .freq = 0, .comp = { 7, 8, 5, 5, 6, 6 } },
			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
		}
	},
	{
		.pclk = 12288000,
		.settings = {
			{ .freq = 2, .comp = { 7, 8, 3, 3, 3, 3 } },
			{ .freq = 1, .comp = { 7, 8, 2, 2, 2, 2 } },
			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
			{ .freq = 0, .comp = { 7, 8, 6, 6, 6, 6 } },
			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
		}
	},
	{
		.pclk = 13000000,
		.settings = {
			{ .freq = 2, .comp = { 7, 8, 1, 1, 1, 1 } },
			{ .freq = 1, .comp = { 7, 8, 0, 0, 0, 0 } },
			{ .freq = 0, .comp = { 7, 8, 1, 1, 1, 1 } },
			{ .freq = 0, .comp = { 7, 8, 4, 4, 5, 5 } },
			{ .freq = 0, .comp = { 7, 8, 1, 1, 1, 1 } },
			{ .freq = 0, .comp = { 7, 8, 1, 1, 1, 1 } },
		}
	},
	{
		.pclk = 19200000,
		.settings = {
			{ .freq = 2, .comp = { 0, 0, 0, 0, 0, 0 } },
			{ .freq = 1, .comp = { 7, 8, 1, 1, 1, 1 } },
			{ .freq = 0, .comp = { 7, 8, 5, 5, 6, 6 } },
			{ .freq = 0, .comp = { 7, 8, 2, 2, 3, 3 } },
			{ .freq = 0, .comp = { 7, 8, 1, 1, 2, 2 } },
			{ .freq = 0, .comp = { 7, 8, 5, 5, 6, 6 } },
		}
	},
};

static int max98090_find_divisor(int target_freq, int pclk)
{
	int current_diff = INT_MAX;
	int test_diff;
	int divisor_index = 0;
	int i;

	for (i = 0; i < ARRAY_SIZE(dmic_divisors); i++) {
		test_diff = abs(target_freq - (pclk / dmic_divisors[i]));
		if (test_diff < current_diff) {
			current_diff = test_diff;
			divisor_index = i;
		}
	}

	return divisor_index;
}

static int max98090_find_closest_pclk(int pclk)
{
	int m1;
	int m2;
	int i;

Annotation

Implementation Notes