Skip to contentSkip to conversation

Unify NVIDIA Tegra ASoC machine drivers

PATCH Superseded Dmitry Osipenko 4 participants 14 messages May 18, 2021 – May 19, 2021

Subsystems (4)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover Unify NVIDIA Tegra ASoC machine drivers

During review of the RT5631 machine driver, Jon Hunter suggested that it will be better to squash all the current ASoC machine drivers into a single one. This suggestion is implemented by this patchset. The RT5631 support will come later with the ASUS Transformer changes.

Dmitry Osipenko (2):
of: base: Export of_device_compatible_match()
ASoC: tegra: Unify ASoC machine drivers

 drivers/of/base.c                    |   1 +
 sound/soc/tegra/Kconfig              |  12 +
 sound/soc/tegra/Makefile             |  18 +-
 sound/soc/tegra/tegra_alc5632.c      | 259 ----------
 sound/soc/tegra/tegra_asoc_machine.c | 737 +++++++++++++++++++++++++++
 sound/soc/tegra/tegra_asoc_machine.h |  44 ++
 sound/soc/tegra/tegra_max98090.c     | 276 ----------
 sound/soc/tegra/tegra_rt5640.c       | 222 --------
 sound/soc/tegra/tegra_rt5677.c       | 324 ------------
 sound/soc/tegra/tegra_sgtl5000.c     | 211 --------
 sound/soc/tegra/tegra_wm8753.c       | 185 -------
 sound/soc/tegra/tegra_wm8903.c       | 349 +++----------
 sound/soc/tegra/tegra_wm9712.c       | 166 ------
 sound/soc/tegra/trimslice.c          | 172 -------
 14 files changed, 860 insertions(+), 2116 deletions(-)
 delete mode 100644 sound/soc/tegra/tegra_alc5632.c
 create mode 100644 sound/soc/tegra/tegra_asoc_machine.c
 create mode 100644 sound/soc/tegra/tegra_asoc_machine.h
 delete mode 100644 sound/soc/tegra/tegra_max98090.c
 delete mode 100644 sound/soc/tegra/tegra_rt5640.c
 delete mode 100644 sound/soc/tegra/tegra_rt5677.c
 delete mode 100644 sound/soc/tegra/tegra_sgtl5000.c
 delete mode 100644 sound/soc/tegra/tegra_wm8753.c
 delete mode 100644 sound/soc/tegra/tegra_wm9712.c
 delete mode 100644 sound/soc/tegra/trimslice.c
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 of: base: Export of_device_compatible_match()

The of_device_compatible_match() will be used by the updated NVIDIA Tegra ASoC WM8903 driver which could be build as a loadable module, export the OF function.

---
 drivers/of/base.c | 1 +
 1 file changed, 1 insertion(+)
drivers/of/base.c +1 -0
index 48e941f99558..eeca92467531 100644
@@ -556,6 +556,7 @@ int of_device_compatible_match(struct device_node *device,
 
 	return score;
 }
+EXPORT_SYMBOL(of_device_compatible_match);
 
 /**
  * of_machine_is_compatible - Test root of device tree for a given compatible value
Signature · 1 line
2.30.2
#3 lore raw

PATCH 2/2 ASoC: tegra: Unify ASoC machine drivers

In reply to Dmitry Osipenko

Squash all machine drivers into a single-universal one. This reduces code duplication, eases addition of a new drivers and upgrades older code to a modern Linux kernel APIs.

---
 sound/soc/tegra/Kconfig              |  12 +
 sound/soc/tegra/Makefile             |  18 +-
 sound/soc/tegra/tegra_alc5632.c      | 259 ----------
 sound/soc/tegra/tegra_asoc_machine.c | 737 +++++++++++++++++++++++++++
 sound/soc/tegra/tegra_asoc_machine.h |  44 ++
 sound/soc/tegra/tegra_max98090.c     | 276 ----------
 sound/soc/tegra/tegra_rt5640.c       | 222 --------
 sound/soc/tegra/tegra_rt5677.c       | 324 ------------
 sound/soc/tegra/tegra_sgtl5000.c     | 211 --------
 sound/soc/tegra/tegra_wm8753.c       | 185 -------
 sound/soc/tegra/tegra_wm8903.c       | 349 +++----------
 sound/soc/tegra/tegra_wm9712.c       | 166 ------
 sound/soc/tegra/trimslice.c          | 172 -------
 13 files changed, 859 insertions(+), 2116 deletions(-)
 delete mode 100644 sound/soc/tegra/tegra_alc5632.c
 create mode 100644 sound/soc/tegra/tegra_asoc_machine.c
 create mode 100644 sound/soc/tegra/tegra_asoc_machine.h
 delete mode 100644 sound/soc/tegra/tegra_max98090.c
 delete mode 100644 sound/soc/tegra/tegra_rt5640.c
 delete mode 100644 sound/soc/tegra/tegra_rt5677.c
 delete mode 100644 sound/soc/tegra/tegra_sgtl5000.c
 delete mode 100644 sound/soc/tegra/tegra_wm8753.c
 delete mode 100644 sound/soc/tegra/tegra_wm9712.c
 delete mode 100644 sound/soc/tegra/trimslice.c
sound/soc/tegra/Kconfig +12 -0
index a4e6760944d0..83c87f35a7d3 100644
@@ -117,9 +117,13 @@ config SND_SOC_TEGRA_AUDIO_GRAPH_CARD
 	  few things for Tegra audio. Most of the code is re-used from
 	  audio graph driver and the same DT bindings are used.
 
+config SND_SOC_TEGRA_MACHINE_DRV
+	tristate
+
 config SND_SOC_TEGRA_RT5640
 	tristate "SoC Audio support for Tegra boards using an RT5640 codec"
 	depends on I2C && GPIOLIB
+	select SND_SOC_TEGRA_MACHINE_DRV
 	select SND_SOC_RT5640
 	help
 	  Say Y or M here if you want to add support for SoC audio on Tegra
@@ -128,6 +132,7 @@ config SND_SOC_TEGRA_RT5640
 config SND_SOC_TEGRA_WM8753
 	tristate "SoC Audio support for Tegra boards using a WM8753 codec"
 	depends on I2C && GPIOLIB
+	select SND_SOC_TEGRA_MACHINE_DRV
 	select SND_SOC_WM8753
 	help
 	  Say Y or M here if you want to add support for SoC audio on Tegra
@@ -136,6 +141,7 @@ config SND_SOC_TEGRA_WM8753
 config SND_SOC_TEGRA_WM8903
 	tristate "SoC Audio support for Tegra boards using a WM8903 codec"
 	depends on I2C && GPIOLIB
+	select SND_SOC_TEGRA_MACHINE_DRV
 	select SND_SOC_WM8903
 	help
 	  Say Y or M here if you want to add support for SoC audio on Tegra
@@ -145,6 +151,7 @@ config SND_SOC_TEGRA_WM8903
 config SND_SOC_TEGRA_WM9712
 	tristate "SoC Audio support for Tegra boards using a WM9712 codec"
 	depends on GPIOLIB
+	select SND_SOC_TEGRA_MACHINE_DRV
 	select SND_SOC_TEGRA20_AC97
 	select SND_SOC_WM9712
 	help
@@ -154,6 +161,7 @@ config SND_SOC_TEGRA_WM9712
 config SND_SOC_TEGRA_TRIMSLICE
 	tristate "SoC Audio support for TrimSlice board"
 	depends on I2C
+	select SND_SOC_TEGRA_MACHINE_DRV
 	select SND_SOC_TLV320AIC23_I2C
 	help
 	  Say Y or M here if you want to add support for SoC audio on the
@@ -162,6 +170,7 @@ config SND_SOC_TEGRA_TRIMSLICE
 config SND_SOC_TEGRA_ALC5632
 	tristate "SoC Audio support for Tegra boards using an ALC5632 codec"
 	depends on I2C && GPIOLIB
+	select SND_SOC_TEGRA_MACHINE_DRV
 	select SND_SOC_ALC5632
 	help
 	  Say Y or M here if you want to add support for SoC audio on the
@@ -170,6 +179,7 @@ config SND_SOC_TEGRA_ALC5632
 config SND_SOC_TEGRA_MAX98090
 	tristate "SoC Audio support for Tegra boards using a MAX98090 codec"
 	depends on I2C && GPIOLIB
+	select SND_SOC_TEGRA_MACHINE_DRV
 	select SND_SOC_MAX98090
 	help
 	  Say Y or M here if you want to add support for SoC audio on Tegra
@@ -178,6 +188,7 @@ config SND_SOC_TEGRA_MAX98090
 config SND_SOC_TEGRA_RT5677
 	tristate "SoC Audio support for Tegra boards using a RT5677 codec"
 	depends on I2C && GPIOLIB
+	select SND_SOC_TEGRA_MACHINE_DRV
 	select SND_SOC_RT5677
 	help
 	  Say Y or M here if you want to add support for SoC audio on Tegra
@@ -186,6 +197,7 @@ config SND_SOC_TEGRA_RT5677
 config SND_SOC_TEGRA_SGTL5000
 	tristate "SoC Audio support for Tegra boards using a SGTL5000 codec"
 	depends on I2C && GPIOLIB
+	select SND_SOC_TEGRA_MACHINE_DRV
 	select SND_SOC_SGTL5000
 	help
 	  Say Y or M here if you want to add support for SoC audio on Tegra
sound/soc/tegra/Makefile +2 -16
index b17dd6eef92a..b930ea7c75f1 100644
@@ -29,24 +29,10 @@ obj-$(CONFIG_SND_SOC_TEGRA186_DSPK) += snd-soc-tegra186-dspk.o
 obj-$(CONFIG_SND_SOC_TEGRA210_ADMAIF) += snd-soc-tegra210-admaif.o
 
 # Tegra machine Support
-snd-soc-tegra-rt5640-objs := tegra_rt5640.o
-snd-soc-tegra-rt5677-objs := tegra_rt5677.o
-snd-soc-tegra-wm8753-objs := tegra_wm8753.o
 snd-soc-tegra-wm8903-objs := tegra_wm8903.o
-snd-soc-tegra-wm9712-objs := tegra_wm9712.o
-snd-soc-tegra-trimslice-objs := trimslice.o
-snd-soc-tegra-alc5632-objs := tegra_alc5632.o
-snd-soc-tegra-max98090-objs := tegra_max98090.o
-snd-soc-tegra-sgtl5000-objs := tegra_sgtl5000.o
+snd-soc-tegra-machine-objs := tegra_asoc_machine.o
 snd-soc-tegra-audio-graph-card-objs := tegra_audio_graph_card.o
 
-obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o
-obj-$(CONFIG_SND_SOC_TEGRA_RT5677) += snd-soc-tegra-rt5677.o
-obj-$(CONFIG_SND_SOC_TEGRA_WM8753) += snd-soc-tegra-wm8753.o
 obj-$(CONFIG_SND_SOC_TEGRA_WM8903) += snd-soc-tegra-wm8903.o
-obj-$(CONFIG_SND_SOC_TEGRA_WM9712) += snd-soc-tegra-wm9712.o
-obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += snd-soc-tegra-trimslice.o
-obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o
-obj-$(CONFIG_SND_SOC_TEGRA_MAX98090) += snd-soc-tegra-max98090.o
-obj-$(CONFIG_SND_SOC_TEGRA_SGTL5000) += snd-soc-tegra-sgtl5000.o
+obj-$(CONFIG_SND_SOC_TEGRA_MACHINE_DRV) += snd-soc-tegra-machine.o
 obj-$(CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD) += snd-soc-tegra-audio-graph-card.o
sound/soc/tegra/tegra_alc5632.c deleted +0 -259

259 lines not on this page · raw message

sound/soc/tegra/tegra_asoc_machine.c new file +737 -0

737 lines not on this page · raw message

sound/soc/tegra/tegra_asoc_machine.h new file +44 -0

44 lines not on this page · raw message

sound/soc/tegra/tegra_max98090.c deleted +0 -276

276 lines not on this page · raw message

sound/soc/tegra/tegra_rt5640.c deleted +0 -222

222 lines not on this page · raw message

sound/soc/tegra/tegra_rt5677.c deleted +0 -324

324 lines not on this page · raw message

sound/soc/tegra/tegra_sgtl5000.c deleted +0 -211

211 lines not on this page · raw message

sound/soc/tegra/tegra_wm8753.c deleted +0 -185

185 lines not on this page · raw message

sound/soc/tegra/tegra_wm8903.c +64 -285

414 lines not on this page · raw message

sound/soc/tegra/tegra_wm9712.c deleted +0 -166

166 lines not on this page · raw message

sound/soc/tegra/trimslice.c deleted +0 -172

67 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.30.2

Part of the diff is not shown here. View the raw message.

maintainer
#4 lore raw

Re: [PATCH v1 2/2] ASoC: tegra: Unify ASoC machine drivers

Quoted 3 lines · Dmitry Osipenko

Squash all machine drivers into a single-universal one. This reduces code duplication, eases addition of a new drivers and upgrades older code to a modern Linux kernel APIs.

Nice, I never understood why each codec needed it's own machine driver (and typically in turn compatible string).

Quoted 8 lines

---

[...]

Quoted 39 lines
sound/soc/tegra/tegra_wm8903.c +6 -14
index e4863fa37b0c..fdf74bfd728e 100644
@@ -14,192 +14,80 @@
  *         [email protected] or [email protected]
  */
 
+#include <linux/gpio/consumer.h>
+#include <linux/of.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
 
 #include <sound/core.h>
 #include <sound/jack.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
 #include <sound/soc.h>
 
 #include "../codecs/wm8903.h"
 
-#include "tegra_asoc_utils.h"
+#include "tegra_asoc_machine.h"
 
-#define DRV_NAME "tegra-snd-wm8903"
+static struct snd_soc_jack_pin tegra_wm8903_mic_jack_pins[] = {
+	{ .pin = "Mic Jack", .mask = SND_JACK_MICROPHONE },
+};
 
-struct tegra_wm8903 {
-	int gpio_spkr_en;
-	int gpio_hp_det;
-	int gpio_hp_mute;
-	int gpio_int_mic_en;
-	int gpio_ext_mic_en;
-	struct tegra_asoc_utils_data util_data;

sound/soc/tegra/tegra_wm8903.c line 43

Quoted 10 lines
sound/soc/tegra/tegra_wm8903.c +10 -0
+static const char * const tegra_active_low_hp_compats[] = {
+	"ad,tegra-audio-plutux",
+	"ad,tegra-audio-wm8903-medcom-wide",
+	"ad,tegra-audio-wm8903-tec",
+	"nvidia,tegra-audio-wm8903-cardhu",
+	"nvidia,tegra-audio-wm8903-harmony",
+	"nvidia,tegra-audio-wm8903-picasso",
+	"nvidia,tegra-audio-wm8903-seaboard",
+	"nvidia,tegra-audio-wm8903-ventana",
+	NULL,

I think this list should be added to the main match table below with data having a flag for active low HP. Then you only match once, don't need the exported function and the next difference is much easier to add.

Quoted 37 lines
sound/soc/tegra/tegra_wm8903.c +11 -20
 };
 
-static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream,
-					struct snd_pcm_hw_params *params)
+static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
 {
-	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
-	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+	struct tegra_machine *machine = snd_soc_card_get_drvdata(rtd->card);
+	struct device_node *np = rtd->card->dev->of_node;
 	struct snd_soc_card *card = rtd->card;
-	struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
-	int srate, mclk;
 	int err;
 
-	srate = params_rate(params);
-	switch (srate) {
-	case 64000:
-	case 88200:
-	case 96000:
-		mclk = 128 * srate;
-		break;
-	default:
-		mclk = 256 * srate;
-		break;
-	}
-	/* FIXME: Codec only requires >= 3MHz if OSR==0 */
-	while (mclk < 6000000)
-		mclk *= 2;
+	/*
+	 * Older version of machine driver was ignoring GPIO polarity,
+	 * forcing it to active-low.  This means that all older device-trees
+	 * which set the polarity to active-high are wrong and we need to fix
+	 * up them.
+	 */
+	if (of_device_compatible_match(np, tegra_active_low_hp_compats)) {
+		bool active_low = gpiod_is_active_low(machine->gpiod_hp_det);

[...]

Quoted 35 lines
sound/soc/tegra/tegra_wm8903.c +14 -6
+static const struct tegra_asoc_data tegra_wm8903_data = {
+	.mclk_rate = tegra_asoc_machine_mclk_rate,
+	.card = &snd_soc_tegra_wm8903,
+	.add_common_dapm_widgets = true,
+	.add_common_controls = true,
+	.add_common_soc_ops = true,
+	.add_mic_jack = true,
+	.add_hp_jack = true,
+};
 
 static const struct of_device_id tegra_wm8903_of_match[] = {
-	{ .compatible = "nvidia,tegra-audio-wm8903", },
+	{ .compatible = "nvidia,tegra-audio-wm8903", .data = &tegra_wm8903_data },
 	{},
 };
+MODULE_DEVICE_TABLE(of, tegra_wm8903_of_match);
 
 static struct platform_driver tegra_wm8903_driver = {
 	.driver = {
-		.name = DRV_NAME,
-		.pm = &snd_soc_pm_ops,
+		.name = "tegra-wm8903",
 		.of_match_table = tegra_wm8903_of_match,
+		.pm = &snd_soc_pm_ops,
 	},
-	.probe = tegra_wm8903_driver_probe,
+	.probe = tegra_asoc_machine_probe,
 };
 module_platform_driver(tegra_wm8903_driver);
 
 MODULE_AUTHOR("Stephen Warren <[email protected]>");
 MODULE_DESCRIPTION("Tegra+WM8903 machine ASoC driver");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:" DRV_NAME);
-MODULE_DEVICE_TABLE(of, tegra_wm8903_of_match);
maintainer
#2 lore raw

Re: [PATCH v1 1/2] of: base: Export of_device_compatible_match()

In reply to Dmitry Osipenko
Quoted 14 lines · Dmitry Osipenko

The of_device_compatible_match() will be used by the updated NVIDIA Tegra ASoC WM8903 driver which could be build as a loadable module, export the OF function.

---
 drivers/of/base.c | 1 +
 1 file changed, 1 insertion(+)
drivers/of/base.c +0 -0
index 48e941f99558..eeca92467531 100644

drivers/of/base.c int of_device_compatible_match(struct device_node *device, · line 559

Quoted 4 lines
drivers/of/base.c +1 -0
@@ -556,6 +556,7 @@ int of_device_compatible_match(struct device_node *device,
 
 	return score;
 }
+EXPORT_SYMBOL(of_device_compatible_match);

I should document this, but there's a number of of_* functions that have only a few users and I want to get rid of. This is one of them. Grep this function and you'll notice most should be using of_machine_is_compatible instead and we're left with sunxi_mbus...

Rob

maintainer
#5 lore raw

Re: [PATCH v1 2/2] ASoC: tegra: Unify ASoC machine drivers

In reply to Rob Herring
Quoted 8 lines · Rob Herring
Quoted 3 lines · Dmitry Osipenko

Squash all machine drivers into a single-universal one. This reduces code duplication, eases addition of a new drivers and upgrades older code to a modern Linux kernel APIs.

Nice, I never understood why each codec needed it's own machine driver (and typically in turn compatible string).

It's generally the clocking configuration, things with fancy clock trees don't play so nicely with generic systems where we want to configure them at runtime, or things with complex routing in the CPU where we only recently started getting bindings that were functional enough to use. Tegra is fairly complex internally.

#13 lore raw

Re: [PATCH v1 2/2] ASoC: tegra: Unify ASoC machine drivers

In reply to Rob Herring

18.05.2021 21:09, Rob Herring пишет:

Quoted 6 lines
Quoted 6 lines
sound/soc/tegra/tegra_wm8903.c +6 -0
+static const char * const tegra_active_low_hp_compats[] = {
+	"ad,tegra-audio-plutux",
+	"ad,tegra-audio-wm8903-medcom-wide",
+	"ad,tegra-audio-wm8903-tec",
+	"nvidia,tegra-audio-wm8903-cardhu",
+	"nvidia,tegra-audio-wm8903-harmony",
Quoted 9 lines

sound/soc/tegra/tegra_wm8903.c line 43

Quoted 4 lines
sound/soc/tegra/tegra_wm8903.c +4 -0
+	"nvidia,tegra-audio-wm8903-picasso",
+	"nvidia,tegra-audio-wm8903-seaboard",
+	"nvidia,tegra-audio-wm8903-ventana",
+	NULL,

I think this list should be added to the main match table below with data having a flag for active low HP. Then you only match once, don't need the exported function and the next difference is much easier to add.

Thank you for the suggestion. You're right that these compats will take precedence.

I'm also now thinking that it should be okay to assume that the GPIO is active-low by default. I haven't seen tegra boards with the active-high configuration.

I'll remove the use of the exported function in v2.

#6 lore raw

Re: [PATCH v1 2/2] ASoC: tegra: Unify ASoC machine drivers

In reply to Mark Brown

18.05.2021 21:34, Mark Brown пишет:

Quoted 7 lines · Rob Herring
Quoted 5 lines · Dmitry Osipenko
Quoted 4 lines

Squash all machine drivers into a single-universal one. This reduces code duplication, eases addition of a new drivers and upgrades older code to a modern Linux kernel APIs.

Quoted 9 lines
Quoted 2 lines

Nice, I never understood why each codec needed it's own machine driver (and typically in turn compatible string).

It's generally the clocking configuration, things with fancy clock trees don't play so nicely with generic systems where we want to configure them at runtime, or things with complex routing in the CPU where we only recently started getting bindings that were functional enough to use. Tegra is fairly complex internally.

This is true, but still it's more optimal to use flags in a single common driver for the minor differences rather than to duplicate 90% of the code. In practice majority of tegra boards are derived from the same reference design, thus the h/w configurations are mostly the same.

#8 lore raw

Question about Tegra UCMs

In reply to Mark Brown

Mark, could you please help me to understand the UCM naming scheme that ALSA uses..

About a year ago I tried to complain to Jaroslav Kysela in a comment to the UCM change [1] that it should be breaking the naming scheme of Tegra UCMs, but haven't got a meaningful reply and moved on to other things.

[1] https://github.com/alsa-project/alsa-ucm-conf/commit/8ff2d50745efbb6959324f672460e413f0b618b8

Today I noticed that the naming scheme changed again and I still don't understand what to do about it.

I have two devices:

1. Acer Picasso tablet that uses "Acer Iconia Tab A500 WM8903" for the card model name.

2. Google Nexus 7 that uses "ASUS Google Nexus 7 ALC5642".

Previously UCMs were picked up by pulseaudio from these paths:

1. /usr/share/alsa/ucm2/Acer Iconia Tab A500 WM8903/
2. /usr/share/alsa/ucm2/ASUS Google Nexus 7 ALC5642/

Now the lookup paths are changed to:

1. /usr/share/alsa/ucm2/Acer_Iconia_Tab/
2. /usr/share/alsa/ucm2/ASUS_Google_Nex/

Strace shows that pulseaudio searches UCMs only at these paths.

The output of /proc/asound/cards:

0 [WM8903 ]: Acer_Iconia_Tab - Acer Iconia Tab A500 WM8903

                      Acer Iconia Tab A500 WM8903

0 [ALC5642 ]: ASUS_Google_Nex - ASUS Google Nexus 7 ALC5642
ASUS Google Nexus 7 ALC5642

IIUC, the "ucm2/Tegra/codec_name" scheme [2] that the current ALSA UCM uses simply doesn't work at all. Is there anything on the kernel side that I could change to get a working naming scheme? If yes, I may try to do something about it in the v2, thanks in advance.

[2] https://github.com/alsa-project/alsa-ucm-conf/tree/master/ucm2/Tegra

maintainer
#9 lore raw

Re: Question about Tegra UCMs

Dne 19. 05. 21 v 0:31 Dmitry Osipenko napsal(a):

Quoted 5 lines

Mark, could you please help me to understand the UCM naming scheme that ALSA uses..

About a year ago I tried to complain to Jaroslav Kysela in a comment to the UCM change [1] that it should be breaking the naming scheme of Tegra UCMs, but haven't got a meaningful reply and moved on to other things.

[1] https://github.com/alsa-project/alsa-ucm-conf/commit/8ff2d50745efbb6959324f672460e413f0b618b8

I'm sorry about that, but it's better to create a tracked ticket (issue or pull request).

Quoted 10 lines

Today I noticed that the naming scheme changed again and I still don't understand what to do about it.

I have two devices:

1. Acer Picasso tablet that uses "Acer Iconia Tab A500 WM8903" for the card model name.

2. Google Nexus 7 that uses "ASUS Google Nexus 7 ALC5642".

Previously UCMs were picked up by pulseaudio from these paths:

Quoted 7 lines

1. /usr/share/alsa/ucm2/Acer Iconia Tab A500 WM8903/
2. /usr/share/alsa/ucm2/ASUS Google Nexus 7 ALC5642/

Now the lookup paths are changed to:

1. /usr/share/alsa/ucm2/Acer_Iconia_Tab/
2. /usr/share/alsa/ucm2/ASUS_Google_Nex/

Yes, it's based on the driver name (which is incorrectly set /or not set/ in your case).

Lookup paths (with description):

https://github.com/alsa-project/alsa-ucm-conf/blob/master/ucm2/ucm.conf

The latest scheme is even different - lookups were moved to ucm2/conf.d with redirection to the more descriptive layered configuration tree structure, so the other developers can immediately identify the hardware which is configured. See Qualcomm examples. The long card names does not help us so much.

Quoted 9 lines

Strace shows that pulseaudio searches UCMs only at these paths.

The output of /proc/asound/cards:

0 [WM8903 ]: Acer_Iconia_Tab - Acer Iconia Tab A500 WM8903

                      Acer Iconia Tab A500 WM8903

0 [ALC5642 ]: ASUS_Google_Nex - ASUS Google Nexus 7 ALC5642
ASUS Google Nexus 7 ALC5642

Fields are explained in:

https://github.com/alsa-project/alsa-ucm-conf/blob/master/ucm2/README.md

Quoted 1 line

Is there anything on the kernel side that I could change to get a working naming scheme? If yes, I may try to do something about it in the v2, thanks in advance.

Try to set a meaningful driver name (usually the code handling the ASoC card creation). It should be very close to the kernel module name (but more user friendly). The current code for your hardware use the auto-generated driver name from the ALSA long name.

Then try to reuse the existing configs - for example your Nexus 7 config has many blocks from codecs/rt5640/* .

Anyway, create a PR so we can discuss the details.

Jaroslav

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

Re: Question about Tegra UCMs

In reply to Dmitry Osipenko
Quoted 1 line · Dmitry Osipenko

Mark, could you please help me to understand the UCM naming scheme that ALSA uses..

I have no real idea, sorry. Most of my userspace work has been with Android which doesn't use UCM.

Quoted 4 lines

IIUC, the "ucm2/Tegra/codec_name" scheme [2] that the current ALSA UCM uses simply doesn't work at all. Is there anything on the kernel side that I could change to get a working naming scheme? If yes, I may try to do something about it in the v2, thanks in advance.

Could you elaborate on the way in which it simply doesn't work at all? I'd expect there to be something in there that first tries to match on something to do with the specific hardware platform to take account of plastics differences but that'd be a userspace change.

Please fix your mail client to word wrap within paragraphs at something substantially less than 80 columns. Doing this makes your messages much easier to read and reply to.

#10 lore raw

Re: Question about Tegra UCMs

In reply to Jaroslav Kysela

19.05.2021 14:13, Jaroslav Kysela пишет:

Quoted 52 lines

Dne 19. 05. 21 v 0:31 Dmitry Osipenko napsal(a):

Quoted 5 lines

Mark, could you please help me to understand the UCM naming scheme that ALSA uses..

About a year ago I tried to complain to Jaroslav Kysela in a comment to the UCM change [1] that it should be breaking the naming scheme of Tegra UCMs, but haven't got a meaningful reply and moved on to other things.

[1] https://github.com/alsa-project/alsa-ucm-conf/commit/8ff2d50745efbb6959324f672460e413f0b618b8

I'm sorry about that, but it's better to create a tracked ticket (issue or pull request).

Quoted 10 lines

Today I noticed that the naming scheme changed again and I still don't understand what to do about it.

I have two devices:

1. Acer Picasso tablet that uses "Acer Iconia Tab A500 WM8903" for the card model name.

2. Google Nexus 7 that uses "ASUS Google Nexus 7 ALC5642".

Previously UCMs were picked up by pulseaudio from these paths:

Quoted 7 lines

1. /usr/share/alsa/ucm2/Acer Iconia Tab A500 WM8903/
2. /usr/share/alsa/ucm2/ASUS Google Nexus 7 ALC5642/

Now the lookup paths are changed to:

1. /usr/share/alsa/ucm2/Acer_Iconia_Tab/
2. /usr/share/alsa/ucm2/ASUS_Google_Nex/

Yes, it's based on the driver name (which is incorrectly set /or not set/ in your case).

Lookup paths (with description):

https://github.com/alsa-project/alsa-ucm-conf/blob/master/ucm2/ucm.conf

The latest scheme is even different - lookups were moved to ucm2/conf.d with redirection to the more descriptive layered configuration tree structure, so the other developers can immediately identify the hardware which is configured. See Qualcomm examples. The long card names does not help us so much.

Quoted 9 lines

Strace shows that pulseaudio searches UCMs only at these paths.

The output of /proc/asound/cards:

0 [WM8903 ]: Acer_Iconia_Tab - Acer Iconia Tab A500 WM8903

                      Acer Iconia Tab A500 WM8903

0 [ALC5642 ]: ASUS_Google_Nex - ASUS Google Nexus 7 ALC5642
ASUS Google Nexus 7 ALC5642

Fields are explained in:

Quoted 8 lines

https://github.com/alsa-project/alsa-ucm-conf/blob/master/ucm2/README.md

Quoted 1 line

Is there anything on the kernel side that I could change to get a working naming scheme? If yes, I may try to do something about it in the v2, thanks in advance.

Try to set a meaningful driver name (usually the code handling the ASoC card creation). It should be very close to the kernel module name (but more user friendly). The current code for your hardware use the auto-generated driver name from the ALSA long name.

The current name isn't auto-generated, it's specified via the nvidia,model device-tree property.

Quoted 4 lines

Then try to reuse the existing configs - for example your Nexus 7 config has many blocks from codecs/rt5640/* .

Anyway, create a PR so we can discuss the details.

I will create the PR, thank you very much. It's important problem which can't be postponed anymore since sound doesn't work without UCMs on Tegra devices.

#12 lore raw

Re: Question about Tegra UCMs

In reply to Mark Brown

19.05.2021 14:38, Mark Brown пишет:

Quoted 12 lines · Dmitry Osipenko
Quoted 2 lines

Mark, could you please help me to understand the UCM naming scheme that ALSA uses..

I have no real idea, sorry. Most of my userspace work has been with Android which doesn't use UCM.

Quoted 4 lines

IIUC, the "ucm2/Tegra/codec_name" scheme [2] that the current ALSA UCM uses simply doesn't work at all. Is there anything on the kernel side that I could change to get a working naming scheme? If yes, I may try to do something about it in the v2, thanks in advance.

Quoted 4 lines

Could you elaborate on the way in which it simply doesn't work at all? I'd expect there to be something in there that first tries to match on something to do with the specific hardware platform to take account of plastics differences but that'd be a userspace change.

I also expect that there should be some kind of fall back matching, but I don't see it happening. I will work with Jaroslav on this trouble.

Quoted 4 lines

Please fix your mail client to word wrap within paragraphs at something substantially less than 80 columns. Doing this makes your messages much easier to read and reply to.

I turned off the word wrapping for that email to make it more readable in a generic email clients since it contained long lines which shouldn't be wrapped.

maintainer
#7 lore raw

Re: [PATCH v1 2/2] ASoC: tegra: Unify ASoC machine drivers

In reply to Dmitry Osipenko
Quoted 8 lines · Dmitry Osipenko

18.05.2021 21:34, Mark Brown пишет:

Quoted 5 lines

It's generally the clocking configuration, things with fancy clock trees don't play so nicely with generic systems where we want to configure them at runtime, or things with complex routing in the CPU where we only recently started getting bindings that were functional enough to use. Tegra is fairly complex internally.

Quoted 4 lines

This is true, but still it's more optimal to use flags in a single common driver for the minor differences rather than to duplicate 90% of the code. In practice majority of tegra boards are derived from the same reference design, thus the h/w configurations are mostly the same.

If you can do it yes, though some of the CODECs can have sufficiently interesting clocking to make it useful to do something different - not sure if any of those are upstream though, WM8903 ought to with the right board I think.