Skip to contentSkip to conversation

ASoC: rt1316: Add RT1316 SDCA vendor-specific driver

PATCH Superseded [email protected] 3 participants 6 messages Feb 8, 2021 – Feb 18, 2021 1 message not in the archive

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: rt1316: Add RT1316 SDCA vendor-specific driver

From: Shuming Fan <[email protected]>

This is the initial amplifier driver for rt1316 SDCA version.

---
 sound/soc/codecs/Kconfig      |   6 +
 sound/soc/codecs/Makefile     |   2 +
 sound/soc/codecs/rt1316-sdw.c | 808 ++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt1316-sdw.h |  57 +++
 4 files changed, 873 insertions(+)
 create mode 100644 sound/soc/codecs/rt1316-sdw.c
 create mode 100644 sound/soc/codecs/rt1316-sdw.h
sound/soc/codecs/Kconfig +6 -0
index df34b3b3bb14..0b9e9047377e 100644
@@ -181,6 +181,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_RT711_SDW
 	imply SND_SOC_RT715_SDW
 	imply SND_SOC_RT1308_SDW
+	imply SND_SOC_RT1316_SDW
 	imply SND_SOC_SGTL5000
 	imply SND_SOC_SI476X
 	imply SND_SOC_SIMPLE_AMPLIFIER
@@ -1129,6 +1130,11 @@ config SND_SOC_RT1308_SDW
 	depends on I2C && SOUNDWIRE
 	select REGMAP_SOUNDWIRE
 
+config SND_SOC_RT1316_SDW
+	tristate "Realtek RT1316 Codec - SDW"
+	depends on SOUNDWIRE
+	select REGMAP_SOUNDWIRE
+
 config SND_SOC_RT5514
 	tristate
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index 628b0c9b3e2a..ddf59532e9ca 100644
@@ -170,6 +170,7 @@ snd-soc-rt1015p-objs := rt1015p.o
 snd-soc-rt1305-objs := rt1305.o
 snd-soc-rt1308-objs := rt1308.o
 snd-soc-rt1308-sdw-objs := rt1308-sdw.o
+snd-soc-rt1316-sdw-objs := rt1316-sdw.o
 snd-soc-rt274-objs := rt274.o
 snd-soc-rt286-objs := rt286.o
 snd-soc-rt298-objs := rt298.o
@@ -483,6 +484,7 @@ obj-$(CONFIG_SND_SOC_RT1015P)	+= snd-soc-rt1015p.o
 obj-$(CONFIG_SND_SOC_RT1305)	+= snd-soc-rt1305.o
 obj-$(CONFIG_SND_SOC_RT1308)	+= snd-soc-rt1308.o
 obj-$(CONFIG_SND_SOC_RT1308_SDW)	+= snd-soc-rt1308-sdw.o
+obj-$(CONFIG_SND_SOC_RT1316_SDW)	+= snd-soc-rt1316-sdw.o
 obj-$(CONFIG_SND_SOC_RT274)	+= snd-soc-rt274.o
 obj-$(CONFIG_SND_SOC_RT286)	+= snd-soc-rt286.o
 obj-$(CONFIG_SND_SOC_RT298)	+= snd-soc-rt298.o
sound/soc/codecs/rt1316-sdw.c new file +808 -0

808 lines not on this page · raw message

sound/soc/codecs/rt1316-sdw.h new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
2.29.0
maintainer
#1 lore raw

sound/soc/codecs/rt1316-sdw.c line 222

Quoted 6 lines · On Mon, Feb 08, 2021 at 05:04:32PM +0800, [email protected] wrote:
sound/soc/codecs/rt1316-sdw.c new file +6 -0
+	/* initial settings - blind write */
+	regmap_write(rt1316->regmap, 0xc710, 0x17);
+	regmap_write(rt1316->regmap, 0xc711, 0x80);
+	regmap_write(rt1316->regmap, 0xc712, 0x26);
+	regmap_write(rt1316->regmap, 0xc713, 0x06);
+	regmap_write(rt1316->regmap, 0xc714, 0x80);

These look like a regmap patch?

sound/soc/codecs/rt1316-sdw.c line 421

Quoted 4 lines
sound/soc/codecs/rt1316-sdw.c new file +4 -0
+static const char * const rt1316_xu24_bypass_ctl[] = {
+	"Not Bypass",
+	"Bypass",
+};

Why is this an enum and not a standard switch?

sound/soc/codecs/rt1316-sdw.c line 436

Quoted 10 lines
sound/soc/codecs/rt1316-sdw.c new file +10 -0
+static const char * const rt1316_lr_iv_sel[] = {
+	"0",
+	"1",
+	"2",
+	"3",
+	"4",
+	"5",
+	"6",
+	"7",
+};

This looks like it could just be a regular control and not an enum - this is just a normal sequence of numbers that could be mapped directlym onto a normal control.

Quoted 8 lines
sound/soc/codecs/rt1316-sdw.c new file +8 -0
+static int rt1316_sdw_set_tdm_slot(struct snd_soc_dai *dai,
+				   unsigned int tx_mask,
+				   unsigned int rx_mask,
+				   int slots, int slot_width)
+{
+	struct snd_soc_component *component = dai->component;
+	struct rt1316_sdw_priv *rt1316 =
+		snd_soc_component_get_drvdata(component);

sound/soc/codecs/rt1316-sdw.c line 569

Quoted 10 lines
sound/soc/codecs/rt1316-sdw.c new file +10 -0
+
+	if (tx_mask)
+		return -EINVAL;
+
+	if (slots > 2)
+		return -EINVAL;
+
+	rt1316->rx_mask = rx_mask;
+	rt1316->slots = slots;
+	/* slot_width is not used since it's irrelevant for SoundWire */

I wouldn't expect to see any TDM stuff at all for SoundWire? I do see some crept through though :/

#2 lore raw
Quoted 14 lines
Quoted 14 lines
sound/soc/codecs/rt1316-sdw.c new file +13 -0
+static int rt1316_sdw_set_tdm_slot(struct snd_soc_dai *dai,
+				   unsigned int tx_mask,
+				   unsigned int rx_mask,
+				   int slots, int slot_width)
+{
+	struct snd_soc_component *component = dai->component;
+	struct rt1316_sdw_priv *rt1316 =
+		snd_soc_component_get_drvdata(component);
+
+	if (tx_mask)
+		return -EINVAL;
+
+	if (slots > 2)
Quoted 8 lines

sound/soc/codecs/rt1316-sdw.c line 569

Quoted 5 lines
sound/soc/codecs/rt1316-sdw.c new file +5 -0
+		return -EINVAL;
+
+	rt1316->rx_mask = rx_mask;
+	rt1316->slots = slots;
+	/* slot_width is not used since it's irrelevant for SoundWire */

I wouldn't expect to see any TDM stuff at all for SoundWire? I do see some crept through though :/

We only use the mask information to let codecs/amplifiers know which channels they need to pick in a stream. This is useful e.g. when we have two (or more) amplifiers on the same link, and you want to tell amplifierA to use ch0 and amplifierB to use ch1.

IIRC there was a similar concept in AC97, there was a mask information to tell devices which channel(s) they were supposed to work on. There are really not a lot of new concepts in SoundWire, the main change is the ability to share the same link to transport different data types/widths. It remains a serial multi-drop link and shares a lot of attributes with previous solutions. That's what lead us to use the same API, even if the slot_width is undefined/irrelevant.

In most cases though all amplifiers on Intel-based solutions extract the same information, and the output will be dynamically selected based on kcontrol information. This is easier to use for e.g. orientation and posture changes.

maintainer
#3 lore raw
Quoted 11 lines · Pierre-Louis Bossart
Quoted 6 lines

sound/soc/codecs/rt1316-sdw.c line 569

Quoted 3 lines
sound/soc/codecs/rt1316-sdw.c new file +3 -0
+	rt1316->rx_mask = rx_mask;
+	rt1316->slots = slots;
+	/* slot_width is not used since it's irrelevant for SoundWire */

I wouldn't expect to see any TDM stuff at all for SoundWire? I do see some crept through though :/

We only use the mask information to let codecs/amplifiers know which channels they need to pick in a stream. This is useful e.g. when we have two (or more) amplifiers on the same link, and you want to tell amplifierA to use ch0 and amplifierB to use ch1.

...

Quoted 4 lines

In most cases though all amplifiers on Intel-based solutions extract the same information, and the output will be dynamically selected based on kcontrol information. This is easier to use for e.g. orientation and posture changes.

Right, this was my expectation for how this would work - dynamic control at runtime so you can do stuff like that rather than a more static setup like slot assignment is normally..

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#5 lore raw
Quoted 8 lines · Shuming [范書銘]
Quoted 3 lines

Right, this was my expectation for how this would work - dynamic control at runtime so you can do stuff like that rather than a more static setup like slot assignment is normally..

Actually, the "RX Channel Select" control could select the channel. This control could select the different channels to output dynamically. However, could I keep the rt1316_sdw_set_tdm_slot() here? There will be more options to set this configuration.

If there's a control to override it at runtime then duplicating that with set_tdm_slot() seems like it's going to be a route to confusion if people change it?

#6 lore raw
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

Right, this was my expectation for how this would work - dynamic control at runtime so you can do stuff like that rather than a more static setup like slot assignment is normally..

Quoted 8 lines
Quoted 4 lines

Actually, the "RX Channel Select" control could select the channel. This control could select the different channels to output dynamically. However, could I keep the rt1316_sdw_set_tdm_slot() here? There will be more options to set this configuration.

If there's a control to override it at runtime then duplicating that with set_tdm_slot() seems like it's going to be a route to confusion if people change it?

Sorry for the late reply.
Ok, I will remove the set_tdm_slot() and send v2 patch.