sound/soc/codecs/rt715-sdca.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/rt715-sdca.c
Extension
.c
Size
29980 bytes
Lines
1073
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

if (ucontrol->value.integer.value[i] != rt715->kctl_2ch_orig[i]) {
			k_changed = 1;
			break;
		}
	}

	for (i = 0; i < 2; i++) {
		rt715->kctl_2ch_orig[i] = ucontrol->value.integer.value[i];
		gain_val =
			rt715_sdca_vol_gain(ucontrol->value.integer.value[i], mc->max,
				mc->shift);
		ret = regmap_write(rt715->mbq_regmap, mc->reg + i, gain_val);
		if (ret != 0) {
			dev_err(component->dev, "%s: Failed to write 0x%x=0x%x\n",
				__func__, mc->reg + i, gain_val);
			return ret;
		}
	}

	return k_changed;
}

static int rt715_sdca_set_amp_gain_4ch_put(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
	struct rt715_sdca_priv *rt715 = snd_soc_component_get_drvdata(component);
	struct rt715_sdca_kcontrol_private *p =
		(struct rt715_sdca_kcontrol_private *)kcontrol->private_value;
	unsigned int reg_base = p->reg_base, k_changed = 0;
	const unsigned int gain_sft = 0x2f;
	unsigned int gain_val, i;
	int ret;

	for (i = 0; i < 4; i++) {
		if (ucontrol->value.integer.value[i] != rt715->kctl_4ch_orig[i]) {
			k_changed = 1;
			break;
		}
	}

	for (i = 0; i < 4; i++) {
		rt715->kctl_4ch_orig[i] = ucontrol->value.integer.value[i];
		gain_val =
			rt715_sdca_vol_gain(ucontrol->value.integer.value[i], p->max,
				gain_sft);
		ret = regmap_write(rt715->mbq_regmap, reg_base + i,
				gain_val);
		if (ret != 0) {
			dev_err(component->dev, "%s: Failed to write 0x%x=0x%x\n",
				__func__, reg_base + i, gain_val);
			return ret;
		}
	}

	return k_changed;
}

static int rt715_sdca_set_amp_gain_8ch_put(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
	struct rt715_sdca_priv *rt715 = snd_soc_component_get_drvdata(component);
	struct rt715_sdca_kcontrol_private *p =
		(struct rt715_sdca_kcontrol_private *)kcontrol->private_value;
	unsigned int reg_base = p->reg_base, i, k_changed = 0;
	const unsigned int gain_sft = 8;
	unsigned int gain_val, reg;
	int ret;

	for (i = 0; i < 8; i++) {
		if (ucontrol->value.integer.value[i] != rt715->kctl_8ch_orig[i]) {
			k_changed = 1;
			break;
		}
	}

	for (i = 0; i < 8; i++) {
		rt715->kctl_8ch_orig[i] = ucontrol->value.integer.value[i];
		gain_val =
			rt715_sdca_boost_gain(ucontrol->value.integer.value[i], p->max,
				gain_sft);
		reg = i < 7 ? reg_base + i : (reg_base - 1) | BIT(15);
		ret = regmap_write(rt715->mbq_regmap, reg, gain_val);
		if (ret != 0) {
			dev_err(component->dev, "%s: Failed to write 0x%x=0x%x\n",
				__func__, reg, gain_val);
			return ret;
		}
	}

Annotation

Implementation Notes