sound/soc/codecs/wm5100.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/wm5100.c
Extension
.c
Size
78170 bytes
Lines
2692
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 wm5100_fll {
	int fref;
	int fout;
	int src;
	struct completion lock;
};

/* codec private data */
struct wm5100_priv {
	struct device *dev;
	struct regmap *regmap;
	struct snd_soc_component *component;

	struct regulator_bulk_data core_supplies[WM5100_NUM_CORE_SUPPLIES];
	struct gpio_desc *reset;
	struct gpio_desc *ldo_ena;
	struct gpio_desc *hp_pol;

	int rev;

	int sysclk;
	int asyncclk;

	bool aif_async[WM5100_AIFS];
	bool aif_symmetric[WM5100_AIFS];
	int sr_ref[WM5100_SYNC_SRS];

	bool out_ena[2];

	struct snd_soc_jack *jack;
	bool jack_detecting;
	bool jack_mic;
	int jack_mode;
	int jack_flips;

	struct wm5100_fll fll[2];

	struct wm5100_pdata pdata;

#ifdef CONFIG_GPIOLIB
	struct gpio_chip gpio_chip;
#endif
};

static int wm5100_sr_code[] = {
	0,
	12000,
	24000,
	48000,
	96000,
	192000,
	384000,
	768000,
	0,
	11025,
	22050,
	44100,
	88200,
	176400,
	352800,
	705600,
	4000,
	8000,
	16000,
	32000,
	64000,
	128000,
	256000,
	512000,
};

static int wm5100_sr_regs[WM5100_SYNC_SRS] = {
	WM5100_CLOCKING_4,
	WM5100_CLOCKING_5,
	WM5100_CLOCKING_6,
};

static int wm5100_alloc_sr(struct snd_soc_component *component, int rate)
{
	struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component);
	int sr_code, sr_free, i;

	for (i = 0; i < ARRAY_SIZE(wm5100_sr_code); i++)
		if (wm5100_sr_code[i] == rate)
			break;
	if (i == ARRAY_SIZE(wm5100_sr_code)) {
		dev_err(component->dev, "Unsupported sample rate: %dHz\n", rate);
		return -EINVAL;
	}
	sr_code = i;

Annotation

Implementation Notes