sound/soc/codecs/cs42l84.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/cs42l84.c
Extension
.c
Size
33523 bytes
Lines
1126
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 cs42l84_private {
	struct regmap *regmap;
	struct device *dev;
	struct gpio_desc *reset_gpio;
	struct snd_soc_jack *jack;
	struct mutex irq_lock;
	u8 tip_state;
	u8 ring_state;
	int pll_config;
	int bclk;
	u8 pll_mclk_f;
	u32 srate;
	u8 stream_use;
	int hs_type;
};

static bool cs42l84_volatile_register(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case CS42L84_DEVID ... CS42L84_DEVID+5:
	case CS42L84_TSRS_PLUG_INT_STATUS:
	case CS42L84_PLL_LOCK_STATUS:
	case CS42L84_TSRS_PLUG_STATUS:
	case CS42L84_HS_DET_STATUS2:
		return true;
	default:
		return false;
	}
}

static const struct regmap_config cs42l84_regmap = {
	.reg_bits = 16,
	.val_bits = 8,

	.volatile_reg = cs42l84_volatile_register,

	.max_register = 0x73fe,

	.cache_type = REGCACHE_MAPLE,

	.use_single_read = true,
	.use_single_write = true,
};

static int cs42l84_put_dac_vol(struct snd_kcontrol *kctl,
			struct snd_ctl_elem_value *val)
{
	struct snd_soc_component *component = snd_kcontrol_chip(kctl);
	struct soc_mixer_control *mc = (struct soc_mixer_control *) kctl->private_value;
	int vola, volb;
	int ret, ret2, updated = 0;

	vola = val->value.integer.value[0] + mc->min;
	volb = val->value.integer.value[1] + mc->min;

	if (vola < mc->min || vola > mc->max || volb < mc->min || volb > mc->max)
		return -EINVAL;

	ret = snd_soc_component_update_bits(component, CS42L84_FRZ_CTL,
					    CS42L84_FRZ_CTL_ENGAGE,
					    CS42L84_FRZ_CTL_ENGAGE);
	if (ret < 0)
		goto bail;
	updated |= ret;

	ret = snd_soc_component_update_bits(component, CS42L84_DAC_CHA_VOL_LSB,
					    0xff, vola & 0xff);
	if (ret < 0)
		goto bail;
	updated |= ret;

	ret = snd_soc_component_update_bits(component, CS42L84_DAC_CHA_VOL_MSB,
					    0xff, (vola >> 8) & 0x01);
	if (ret < 0)
		goto bail;
	updated |= ret;

	ret = snd_soc_component_update_bits(component, CS42L84_DAC_CHB_VOL_LSB,
					    0xff, volb & 0xff);
	if (ret < 0)
		goto bail;
	updated |= ret;

	ret = snd_soc_component_update_bits(component, CS42L84_DAC_CHB_VOL_MSB,
					    0xff, (volb >> 8) & 0x01);
	if (ret < 0)
		goto bail;
	ret |= updated;

bail:

Annotation

Implementation Notes