Skip to contentSkip to conversation

ASoC: rt1316: Add RT1316 SDCA vendor-specific driver

PATCH Superseded [email protected] 4 participants 6 messages Feb 18, 2021 – Feb 22, 2021

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 | 753 ++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt1316-sdw.h |  55 +++
 4 files changed, 816 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 e4cf14e66a51..ae833a54bcb3 100644
@@ -182,6 +182,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
@@ -1144,6 +1145,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 81357dc62ea0..1585bc1d9a25 100644
@@ -173,6 +173,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
@@ -487,6 +488,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 +753 -0

753 lines not on this page · raw message

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

55 lines not on this page · raw message

Signature · 1 line
2.29.0
maintainer
#1 lore raw

Dne 18. 02. 21 v 10:12 [email protected] napsal(a):

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

Quoted 2 lines
sound/soc/codecs/rt1316-sdw.c new file +2 -0
+	SND_SOC_DAPM_SWITCH("DAC L", SND_SOC_NOPM, 0, 0, &rt1316_sto_dac_l),
+	SND_SOC_DAPM_SWITCH("DAC R", SND_SOC_NOPM, 0, 0, &rt1316_sto_dac_r),

Truly, I don't understand the reason to have a separate L/R switch when we can map this functionality to one stereo (multichannel) control.

It's an issue for all ASoC drivers. We should consider to be more strict for the new ones.

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
#2 lore raw
Quoted 10 lines · Jaroslav Kysela

Dne 18. 02. 21 v 10:12 [email protected] napsal(a):

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

Quoted 2 lines
sound/soc/codecs/rt1316-sdw.c new file +2 -0
+	SND_SOC_DAPM_SWITCH("DAC L", SND_SOC_NOPM, 0, 0, &rt1316_sto_dac_l),
+	SND_SOC_DAPM_SWITCH("DAC R", SND_SOC_NOPM, 0, 0, &rt1316_sto_dac_r),

Truly, I don't understand the reason to have a separate L/R switch when we can map this functionality to one stereo (multichannel) control.

It's an issue for all ASoC drivers. We should consider to be more strict for the new ones.

At the same time we have to recognize that the L/R notion only makes sense at the input to the amplifier. The amplifier may recombine channels to deal with orientation/posture or simply select a specific input, and drive different speakers (e.g. tweeter/woofer). Dac L and R are often an abuse of language when the system have multi-way speakers. Exhibit A for this is the TigerLake device with 2 RT1316 and 4 speakers. L/R don't make sense to describe amplifier outputs and speaker position.

There's also a difficult balance to be found between exposing all the capabilities of the device, and making integration and userspace simpler. I2C/IS2 and SoundWire devices tend to expose more controls than HDaudio ones, and that was driven by a desire to optimize as much as possible. Some devices are designed with limited number of controls, others provide hooks to tweak everything in the system by exposing literally have thousands of controls. I don't think we should pick and choose which controls we want to expose, that's the codec vendor's job IMHO (or the device class definition when standard and applicable)

maintainer
#3 lore raw

Dne 18. 02. 21 v 15:49 Pierre-Louis Bossart napsal(a):

Quoted 14 lines · Jaroslav Kysela
Quoted 10 lines

Dne 18. 02. 21 v 10:12 [email protected] napsal(a):

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

Quoted 2 lines
sound/soc/codecs/rt1316-sdw.c new file +2 -0
+	SND_SOC_DAPM_SWITCH("DAC L", SND_SOC_NOPM, 0, 0, &rt1316_sto_dac_l),
+	SND_SOC_DAPM_SWITCH("DAC R", SND_SOC_NOPM, 0, 0, &rt1316_sto_dac_r),

Truly, I don't understand the reason to have a separate L/R switch when we can map this functionality to one stereo (multichannel) control.

It's an issue for all ASoC drivers. We should consider to be more strict for the new ones.

Quoted 7 lines

At the same time we have to recognize that the L/R notion only makes sense at the input to the amplifier. The amplifier may recombine channels to deal with orientation/posture or simply select a specific input, and drive different speakers (e.g. tweeter/woofer). Dac L and R are often an abuse of language when the system have multi-way speakers. Exhibit A for this is the TigerLake device with 2 RT1316 and 4 speakers. L/R don't make sense to describe amplifier outputs and speaker position.

My point is a bit different. If the channels are supposed to be used together (which usually mean a kind of the stereo operation in this case), it does not make much sense to split this control to separate single channels. It's just a waste of resources.

The current patch code:

one channel control "DAC L"
one channel control "DAC R"

The one control:

two channels control "DAC"

From the user space POV, the only difference is the value write operation (both channels are set using one ioctl).

Quoted 9 lines

There's also a difficult balance to be found between exposing all the capabilities of the device, and making integration and userspace simpler. I2C/IS2 and SoundWire devices tend to expose more controls than HDaudio ones, and that was driven by a desire to optimize as much as possible. Some devices are designed with limited number of controls, others provide hooks to tweak everything in the system by exposing literally have thousands of controls. I don't think we should pick and choose which controls we want to expose, that's the codec vendor's job IMHO (or the device class definition when standard and applicable)

The problem with ASoC tree is that many of those controls are not supposed to be configured/used by the end user, but in UCM or other higher level layer configuration, because they're a part of the hw/driver setup.

I think that we should classify those controls so the standard user space tools can hide them, but it's another problem.

Jaroslav

Signature · 2 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
maintainer
#4 lore raw
Quoted 6 lines · Jaroslav Kysela

The problem with ASoC tree is that many of those controls are not supposed to be configured/used by the end user, but in UCM or other higher level layer configuration, because they're a part of the hw/driver setup.

I think that we should classify those controls so the standard user space tools can hide them, but it's another problem.

Well, as has been discussed in the past ideally ALSA would have a mechanism for exposing topology information and userspace would have some chance of picking which controls make sense for use on non-trivial hardware. The particular set of controls that it makes sense to adjust from userspace is going to vary depending on the use case, it's not something that can be decided in the kernel.

#5 lore raw
In reply to Jaroslav Kysela
Quoted 23 lines · Jaroslav Kysela

Dne 18. 02. 21 v 15:49 Pierre-Louis Bossart napsal(a):

Quoted 14 lines · Jaroslav Kysela
Quoted 10 lines

Dne 18. 02. 21 v 10:12 [email protected] napsal(a):

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

Quoted 2 lines
sound/soc/codecs/rt1316-sdw.c new file +2 -0
+	SND_SOC_DAPM_SWITCH("DAC L", SND_SOC_NOPM, 0, 0, &rt1316_sto_dac_l),
+	SND_SOC_DAPM_SWITCH("DAC R", SND_SOC_NOPM, 0, 0, &rt1316_sto_dac_r),

Truly, I don't understand the reason to have a separate L/R switch when we can map this functionality to one stereo (multichannel) control.

It's an issue for all ASoC drivers. We should consider to be more strict for the new ones.

Quoted 7 lines

At the same time we have to recognize that the L/R notion only makes sense at the input to the amplifier. The amplifier may recombine channels to deal with orientation/posture or simply select a specific input, and drive different speakers (e.g. tweeter/woofer). Dac L and R are often an abuse of language when the system have multi-way speakers. Exhibit A for this is the TigerLake device with 2 RT1316 and 4 speakers. L/R don't make sense to describe amplifier outputs and speaker position.

Quoted 4 lines

My point is a bit different. If the channels are supposed to be used together (which usually mean a kind of the stereo operation in this case), it does not make much sense to split this control to separate single channels. It's just a waste of resources.

In this case the control affects analog resources and speaker outputs, so in this case I will assume that it's perfectly ok to have a single speaker. Put differently, assuming that the two channels will always be used is not quite right.

Quoted 11 lines

The current patch code:

one channel control "DAC L"
one channel control "DAC R"

The one control:

two channels control "DAC"

From the user space POV, the only difference is the value write operation
(both channels are set using one ioctl).

SDCA mandates that all devices are able to consume stereo data, even if there is a single speaker connected. It's useful IMHO if you provide controls so that one of the two DACs is switched off.

Quoted 20 lines
Quoted 10 lines

There's also a difficult balance to be found between exposing all the capabilities of the device, and making integration and userspace simpler. I2C/IS2 and SoundWire devices tend to expose more controls than HDaudio ones, and that was driven by a desire to optimize as much as possible. Some devices are designed with limited number of controls, others provide hooks to tweak everything in the system by exposing literally have thousands of controls. I don't think we should pick and choose which controls we want to expose, that's the codec vendor's job IMHO (or the device class definition when standard and applicable)

The problem with ASoC tree is that many of those controls are not supposed to be configured/used by the end user, but in UCM or other higher level layer configuration, because they're a part of the hw/driver setup.

I think that we should classify those controls so the standard user space tools can hide them, but it's another problem.

Jaroslav