sound/soc/codecs/es8389.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/es8389.c
Extension
.c
Size
42568 bytes
Lines
1037
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	es8389_private {
	struct regmap *regmap;
	struct clk *mclk;
	struct regulator_bulk_data core_supply[2];
	unsigned int sysclk;
	int mastermode;

	u8 mclk_src;
	u8 vddd;
	int version;
	enum snd_soc_bias_level bias_level;
};

static const char * const es8389_core_supplies[] = {
	"vddd",
	"vdda",
};

static bool es8389_volatile_register(struct device *dev,
			unsigned int reg)
{
	if ((reg  <= 0xff))
		return true;
	else
		return false;
}

static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -9550, 50, 0);
static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -9550, 50, 0);
static const DECLARE_TLV_DB_SCALE(pga_vol_tlv, 0, 300, 0);
static const DECLARE_TLV_DB_SCALE(mix_vol_tlv, -9500, 100, 0);
static const DECLARE_TLV_DB_SCALE(alc_target_tlv, -3200, 200, 0);
static const DECLARE_TLV_DB_SCALE(alc_max_level, -3200, 200, 0);

static int es8389_dmic_set(struct snd_kcontrol *kcontrol,
	struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_dapm_kcontrol_to_component(kcontrol);
	struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_to_dapm(kcontrol);
	struct es8389_private *es8389 = snd_soc_component_get_drvdata(component);
	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
	unsigned int val;
	bool changed1, changed2;

	val = ucontrol->value.integer.value[0];
	if (val > 1)
		return -EINVAL;

	if (val) {
		regmap_update_bits_check(es8389->regmap, ES8389_DMIC_EN, 0xC0, 0xC0, &changed1);
		regmap_update_bits_check(es8389->regmap, ES8389_ADC_MODE, 0x03, 0x03, &changed2);
	} else {
		regmap_update_bits_check(es8389->regmap, ES8389_DMIC_EN, 0xC0, 0x00, &changed1);
		regmap_update_bits_check(es8389->regmap, ES8389_ADC_MODE, 0x03, 0x00, &changed2);
	}

	if (changed1 & changed2)
		return snd_soc_dapm_mux_update_power(dapm, kcontrol, val, e, NULL);
	else
		return 0;
}

static const char *const alc[] = {
	"ALC OFF",
	"ADCR ALC ON",
	"ADCL ALC ON",
	"ADCL & ADCL ALC ON",
};

static const char *const ramprate[] = {
	"0.125db/1  LRCK",
	"0.125db/4  LRCK",
	"0.125db/8  LRCK",
	"0.125db/16  LRCK",
	"0.125db/32  LRCK",
	"0.125db/64  LRCK",
	"0.125db/128  LRCK",
	"0.125db/256  LRCK",
	"0.125db/512  LRCK",
	"0.125db/1024  LRCK",
	"0.125db/2048  LRCK",
	"0.125db/4096  LRCK",
	"0.125db/8192  LRCK",
	"0.125db/16384  LRCK",
	"0.125db/32768  LRCK",
	"0.125db/65536  LRCK",
};

static const char *const winsize[] = {
	"2 LRCK",

Annotation

Implementation Notes