Re: [PATCH v3] ASoC: rt721-sdca: Add RT721 SDCA driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Op 01-10-2024 om 11:17 schreef Jack Yu:
This is the initial codec driver for rt721-sdca.
It's a three functions (jack,mic,amp) soundwire driver.

Signed-off-by: Jack Yu <jack.yu@xxxxxxxxxxx>

v2: Fix typo in mbq default registers.
v3: Include soundwire common functions for Realtek.
---
  sound/soc/codecs/Kconfig          |    7 +
  sound/soc/codecs/Makefile         |    2 +
  sound/soc/codecs/rt721-sdca-sdw.c |  551 ++++++++++
  sound/soc/codecs/rt721-sdca-sdw.h |  150 +++
  sound/soc/codecs/rt721-sdca.c     | 1547 +++++++++++++++++++++++++++++
  sound/soc/codecs/rt721-sdca.h     |  268 +++++
  6 files changed, 2525 insertions(+)
  create mode 100644 sound/soc/codecs/rt721-sdca-sdw.c
  create mode 100644 sound/soc/codecs/rt721-sdca-sdw.h
  create mode 100644 sound/soc/codecs/rt721-sdca.c
  create mode 100644 sound/soc/codecs/rt721-sdca.h

[...]
+static int rt721_sdca_dmic_set_gain_get(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
+	struct rt721_sdca_priv *rt721 = snd_soc_component_get_drvdata(component);
+	struct rt721_sdca_dmic_kctrl_priv *p =
+		(struct rt721_sdca_dmic_kctrl_priv *)kcontrol->private_value;
+	unsigned int boost_step = 0x0a00;
+	unsigned int vol_max = 0x1e00;
+	unsigned int regvalue, ctl, i;
+	unsigned int adc_vol_flag = 0;
+	const unsigned int interval_offset = 0xc0;
+
+	if (strstr(ucontrol->id.name, "FU1E Capture Volume"))
+		adc_vol_flag = 1;
+
+	/* check all channels */
+	for (i = 0; i < p->count; i++) {
+		regmap_read(rt721->mbq_regmap, p->reg_base + i, &regvalue);
+
+		if (!adc_vol_flag) /* boost gain */
+			ctl = regvalue / boost_step;
+		else { /* ADC gain */
+			if (adc_vol_flag)
+				ctl = p->max - (((vol_max - regvalue) & 0xffff) / interval_offset);
+			else
At this point it is dead code.
BTW This was detected by Coverity Scan; CID 1600271
+				ctl = p->max - (((0 - regvalue) & 0xffff) / interval_offset);
+		}
+
+		ucontrol->value.integer.value[i] = ctl;
+	}
+
+	return 0;
+}




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux