Skip to contentSkip to conversation

ASoC: rt721-sdca: Add RT721 SDCA driver

PATCH In review Jack Yu 3 participants 4 messages Oct 1, 2024 – Oct 11, 2024

Subsystems (3)
lore
Share & tools
lore

Jack Yu

author
#0 lore raw

PATCH v3 1/1 ASoC: rt721-sdca: Add RT721 SDCA driver

This is the initial codec driver for rt721-sdca. It's a three functions (jack,mic,amp) soundwire driver.

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
sound/soc/codecs/Kconfig +7 -0
index 7092842480ef..74c14da4ae09 100644
@@ -222,6 +222,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_RT712_SDCA_DMIC_SDW
 	imply SND_SOC_RT715_SDW
 	imply SND_SOC_RT715_SDCA_SDW
+	imply SND_SOC_RT721_SDCA_SDW
 	imply SND_SOC_RT722_SDCA_SDW
 	imply SND_SOC_RT1308_SDW
 	imply SND_SOC_RT1316_SDW
@@ -1743,6 +1744,12 @@ config SND_SOC_RT712_SDCA_DMIC_SDW
 	select REGMAP_SOUNDWIRE
 	select REGMAP_SOUNDWIRE_MBQ
 
+config SND_SOC_RT721_SDCA_SDW
+	tristate "Realtek RT721 SDCA Codec - SDW"
+	depends on SOUNDWIRE
+	select REGMAP_SOUNDWIRE
+	select REGMAP_SOUNDWIRE_MBQ
+
 config SND_SOC_RT722_SDCA_SDW
 	tristate "Realtek RT722 SDCA Codec - SDW"
 	depends on SOUNDWIRE
sound/soc/codecs/Makefile +2 -0
index 54cbc3feae32..3477c6352acc 100644
@@ -259,6 +259,7 @@ snd-soc-rt712-sdca-y := rt712-sdca.o rt712-sdca-sdw.o
 snd-soc-rt712-sdca-dmic-y := rt712-sdca-dmic.o
 snd-soc-rt715-y := rt715.o rt715-sdw.o
 snd-soc-rt715-sdca-y := rt715-sdca.o rt715-sdca-sdw.o
+snd-soc-rt721-sdca-y := rt721-sdca.o rt721-sdca-sdw.o
 snd-soc-rt722-sdca-y := rt722-sdca.o rt722-sdca-sdw.o
 snd-soc-rt9120-y := rt9120.o
 snd-soc-rtq9128-y := rtq9128.o
@@ -662,6 +663,7 @@ obj-$(CONFIG_SND_SOC_RT712_SDCA_SDW)     += snd-soc-rt712-sdca.o
 obj-$(CONFIG_SND_SOC_RT712_SDCA_DMIC_SDW)     += snd-soc-rt712-sdca-dmic.o
 obj-$(CONFIG_SND_SOC_RT715)     += snd-soc-rt715.o
 obj-$(CONFIG_SND_SOC_RT715_SDCA_SDW)     += snd-soc-rt715-sdca.o
+obj-$(CONFIG_SND_SOC_RT721_SDCA_SDW)     += snd-soc-rt721-sdca.o
 obj-$(CONFIG_SND_SOC_RT722_SDCA_SDW)     += snd-soc-rt722-sdca.o
 obj-$(CONFIG_SND_SOC_RT9120)	+= snd-soc-rt9120.o
 obj-$(CONFIG_SND_SOC_RTQ9128)	+= snd-soc-rtq9128.o
sound/soc/codecs/rt721-sdca-sdw.c new file +551 -0

551 lines not on this page · raw message

sound/soc/codecs/rt721-sdca-sdw.h new file +150 -0

150 lines not on this page · raw message

sound/soc/codecs/rt721-sdca.c new file +1547 -0

1,547 lines not on this page · raw message

sound/soc/codecs/rt721-sdca.h new file +268 -0

268 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 6 lines · Jack Yu

This is the initial codec driver for rt721-sdca. It's a three functions (jack,mic,amp) soundwire driver.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: rt721-sdca: Add RT721 SDCA driver

      commit: 86ce355c1f9ab943bbe099ea7d0b8a3af2247f65

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

#2 lore raw
In reply to Jack Yu

Op 01-10-2024 om 11:17 schreef Jack Yu:

Quoted 37 lines

This is the initial codec driver for rt721-sdca. It's a three functions (jack,mic,amp) soundwire driver.

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

[...]

sound/soc/codecs/rt721-sdca.c new file +16 -0
+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;
+

sound/soc/codecs/rt721-sdca.c line 617

Quoted 10 lines
sound/soc/codecs/rt721-sdca.c new file +10 -0
+	/* 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

Quoted 9 lines
sound/soc/codecs/rt721-sdca.c new file +8 -0
+				ctl = p->max - (((0 - regvalue) & 0xffff) / interval_offset);
+		}
+
+		ucontrol->value.integer.value[i] = ctl;
+	}
+
+	return 0;
+}
#3 lore raw
In reply to Jack Yu

Op 01-10-2024 om 11:17 schreef Jack Yu:

Quoted 26 lines

This is the initial codec driver for rt721-sdca. It's a three functions (jack,mic,amp) soundwire driver.

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
[...]

sound/soc/codecs/rt721-sdca.c new file +6 -0
+static void rt721_sdca_jack_detect_handler(struct work_struct *work)
+{
+	struct rt721_sdca_priv *rt721 =
+		container_of(work, struct rt721_sdca_priv, jack_detect_work.work);
+	int btn_type = 0, ret;
+

sound/soc/codecs/rt721-sdca.c line 44

Quoted 10 lines
sound/soc/codecs/rt721-sdca.c new file +10 -0
+	if (!rt721->hs_jack)
+		return;
+
+	if (!rt721->component->card || !rt721->component->card->instantiated)
+		return;
+
+	/* SDW_SCP_SDCA_INT_SDCA_6 is used for jack detection */
+	if (rt721->scp_sdca_stat1 & SDW_SCP_SDCA_INT_SDCA_6) {
+		rt721->jack_type = rt_sdca_headset_detect(rt721->regmap,
+							RT721_SDCA_ENT_GE49);

Variable "ret" is not initialized, no assignment.

Quoted 4 lines
sound/soc/codecs/rt721-sdca.c new file +3 -0
+		if (ret < 0)
+			return;
+	}