sound/soc/codecs/rt5645.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/rt5645.c
Extension
.c
Size
132933 bytes
Lines
4368
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 rt5645_eq_param_s {
	unsigned short reg;
	unsigned short val;
};

struct rt5645_eq_param_s_be16 {
	__be16 reg;
	__be16 val;
};

static const char *const rt5645_supply_names[] = {
	"avdd",
	"cpvdd",
};

struct rt5645_platform_data {
	/* IN2 can optionally be differential */
	bool in2_diff;

	unsigned int dmic1_data_pin;
	/* 0 = IN2N; 1 = GPIO5; 2 = GPIO11 */
	unsigned int dmic2_data_pin;
	/* 0 = IN2P; 1 = GPIO6; 2 = GPIO10; 3 = GPIO12 */

	unsigned int jd_mode;
	/* Use level triggered irq */
	bool level_trigger_irq;
	/* Invert JD1_1 status polarity */
	bool inv_jd1_1;
	/* Invert HP detect status polarity */
	bool inv_hp_pol;

	/* Only 1 speaker connected */
	bool mono_speaker;

	/* Value to assign to snd_soc_card.long_name */
	const char *long_name;

	/* Some (package) variants have the headset-mic pin not-connected */
	bool no_headset_mic;
};

struct rt5645_priv {
	struct snd_soc_component *component;
	struct rt5645_platform_data pdata;
	struct regmap *regmap;
	struct i2c_client *i2c;
	struct gpio_desc *gpiod_hp_det;
	struct gpio_desc *gpiod_cbj_sleeve;
	struct snd_soc_jack *hp_jack;
	struct snd_soc_jack *mic_jack;
	struct snd_soc_jack *btn_jack;
	struct delayed_work jack_detect_work, rcclock_work;
	struct regulator_bulk_data supplies[ARRAY_SIZE(rt5645_supply_names)];
	struct rt5645_eq_param_s *eq_param;
	struct timer_list btn_check_timer;
	struct mutex jd_mutex;

	int codec_type;
	int sysclk;
	int sysclk_src;
	int lrck[RT5645_AIFS];
	int bclk[RT5645_AIFS];
	int master[RT5645_AIFS];

	int pll_src;
	int pll_in;
	int pll_out;

	int jack_type;
	bool en_button_func;
	int v_id;
};

static int rt5645_reset(struct snd_soc_component *component)
{
	return snd_soc_component_write(component, RT5645_RESET, 0);
}

static bool rt5645_volatile_register(struct device *dev, unsigned int reg)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(rt5645_ranges); i++) {
		if (reg >= rt5645_ranges[i].range_min &&
			reg <= rt5645_ranges[i].range_max) {
			return true;
		}
	}

Annotation

Implementation Notes