sound/soc/codecs/wm8996.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/wm8996.c
Extension
.c
Size
94925 bytes
Lines
3094
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 wm8996_priv {
	struct device *dev;
	struct regmap *regmap;
	struct snd_soc_component *component;

	struct gpio_desc *ldo_ena;

	int sysclk;
	int sysclk_src;

	int fll_src;
	int fll_fref;
	int fll_fout;

	struct completion fll_lock;

	u16 dcs_pending;
	struct completion dcs_done;

	u16 hpout_ena;
	u16 hpout_pending;

	struct regulator_bulk_data supplies[WM8996_NUM_SUPPLIES];
	struct notifier_block disable_nb[WM8996_NUM_SUPPLIES];
	int bg_ena;

	struct wm8996_pdata pdata;

	int rx_rate[WM8996_AIFS];
	int bclk_rate[WM8996_AIFS];

	/* Platform dependent ReTune mobile configuration */
	int num_retune_mobile_texts;
	const char **retune_mobile_texts;
	int retune_mobile_cfg[2];
	struct soc_enum retune_mobile_enum;

	struct snd_soc_jack *jack;
	bool detecting;
	bool jack_mic;
	int jack_flips;
	wm8996_polarity_fn polarity_cb;

#ifdef CONFIG_GPIOLIB
	struct gpio_chip gpio_chip;
#endif
};

/* We can't use the same notifier block for more than one supply and
 * there's no way I can see to get from a callback to the caller
 * except container_of().
 */
#define WM8996_REGULATOR_EVENT(n) \
static int wm8996_regulator_event_##n(struct notifier_block *nb, \
				    unsigned long event, void *data)	\
{ \
	struct wm8996_priv *wm8996 = container_of(nb, struct wm8996_priv, \
						  disable_nb[n]); \
	if (event & REGULATOR_EVENT_DISABLE) { \
		regcache_mark_dirty(wm8996->regmap);	\
	} \
	return 0; \
}

WM8996_REGULATOR_EVENT(0)
WM8996_REGULATOR_EVENT(1)
WM8996_REGULATOR_EVENT(2)

static const struct reg_default wm8996_reg[] = {
	{ WM8996_POWER_MANAGEMENT_1, 0x0 },
	{ WM8996_POWER_MANAGEMENT_2, 0x0 },
	{ WM8996_POWER_MANAGEMENT_3, 0x0 },
	{ WM8996_POWER_MANAGEMENT_4, 0x0 },
	{ WM8996_POWER_MANAGEMENT_5, 0x0 },
	{ WM8996_POWER_MANAGEMENT_6, 0x0 },
	{ WM8996_POWER_MANAGEMENT_7, 0x10 },
	{ WM8996_POWER_MANAGEMENT_8, 0x0 },
	{ WM8996_LEFT_LINE_INPUT_VOLUME, 0x0 },
	{ WM8996_RIGHT_LINE_INPUT_VOLUME, 0x0 },
	{ WM8996_LINE_INPUT_CONTROL, 0x0 },
	{ WM8996_DAC1_HPOUT1_VOLUME, 0x88 },
	{ WM8996_DAC2_HPOUT2_VOLUME, 0x88 },
	{ WM8996_DAC1_LEFT_VOLUME, 0x2c0 },
	{ WM8996_DAC1_RIGHT_VOLUME, 0x2c0 },
	{ WM8996_DAC2_LEFT_VOLUME, 0x2c0 },
	{ WM8996_DAC2_RIGHT_VOLUME, 0x2c0 },
	{ WM8996_OUTPUT1_LEFT_VOLUME, 0x80 },
	{ WM8996_OUTPUT1_RIGHT_VOLUME, 0x80 },
	{ WM8996_OUTPUT2_LEFT_VOLUME, 0x80 },
	{ WM8996_OUTPUT2_RIGHT_VOLUME, 0x80 },

Annotation

Implementation Notes