Unify NVIDIA Tegra ASoC machine drivers
Subsystems (3)
v2 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.
This series needs to be approved by Jaroslav Kysela before it can be merged.
Changelog:
v2: - Dropped use of of_device_compatible_match(), like it was suggested
by Rob Herring in a review comment to v1.
- Added patch that sets card's driver_name of as Tegra ASoC drivers. In a comment to v1 Jaroslav Kysela suggested that the Tegra drivers don't set the card name properly and he was right.
I opened pull request with the new Tegra UCMs and updated lookup paths for older UCMs [1].
[1] https://github.com/alsa-project/alsa-ucm-conf/pull/92
Dmitry Osipenko (2):
ASoC: tegra: Set driver_name=tegra for all machine drivers
ASoC: tegra: Unify ASoC machine drivers
sound/soc/tegra/Kconfig | 12 + sound/soc/tegra/Makefile | 18 +- sound/soc/tegra/tegra_alc5632.c | 259 ---------- sound/soc/tegra/tegra_asoc_machine.c | 732 +++++++++++++++++++++++++++ sound/soc/tegra/tegra_asoc_machine.h | 45 ++ 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 | 357 +++---------- sound/soc/tegra/tegra_wm9712.c | 166 ------ sound/soc/tegra/trimslice.c | 172 ------- 13 files changed, 862 insertions(+), 2117 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
PATCH v2 1/2 ASoC: tegra: Set driver_name=tegra for all machine drivers
The driver_name="tegra" is now required by the newer ALSA UCMs, otherwise Tegra UCMs don't match by the path/name.
All Tegra machine drivers are specifying the card's name, but it has no effect if model name is specified in the device-tree since it overrides the card's name. We need to set the driver_name to "tegra" in order to get a usable lookup path for the updated ALSA UCMs. The new UCM lookup path has a form of driver_name/card_name.
The old lookup paths that are based on driver module name continue to work as before. Note that UCM matching never worked for Tegra ASoC drivers if they were compiled as built-in, this is fixed by supporting the new naming scheme.
--- sound/soc/tegra/tegra20_ac97.c | 1 + sound/soc/tegra/tegra_alc5632.c | 1 + sound/soc/tegra/tegra_max98090.c | 1 + sound/soc/tegra/tegra_rt5640.c | 1 + sound/soc/tegra/tegra_rt5677.c | 1 + sound/soc/tegra/tegra_sgtl5000.c | 1 + sound/soc/tegra/tegra_wm8753.c | 1 + sound/soc/tegra/tegra_wm8903.c | 1 + sound/soc/tegra/tegra_wm9712.c | 1 + sound/soc/tegra/trimslice.c | 1 + 10 files changed, 10 insertions(+)
sound/soc/tegra/tegra20_ac97.c +1 -0
@@ -220,6 +220,7 @@ static int tegra20_ac97_probe(struct snd_soc_dai *dai)static struct snd_soc_dai_driver tegra20_ac97_dai = { .name ="tegra-ac97-pcm" , + .driver_name ="tegra" , .probe = tegra20_ac97_probe, .playback = { .stream_name ="PCM Playback" ,
sound/soc/tegra/tegra_alc5632.c +1 -0
@@ -139,6 +139,7 @@ static struct snd_soc_dai_link tegra_alc5632_dai = {static struct snd_soc_card snd_soc_tegra_alc5632 = { .name ="tegra-alc5632" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_alc5632_dai, .num_links =1 ,
sound/soc/tegra/tegra_max98090.c +1 -0
@@ -182,6 +182,7 @@ static struct snd_soc_dai_link tegra_max98090_dai = {static struct snd_soc_card snd_soc_tegra_max98090 = { .name ="tegra-max98090" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_max98090_dai, .num_links =1 ,
sound/soc/tegra/tegra_rt5640.c +1 -0
@@ -132,6 +132,7 @@ static struct snd_soc_dai_link tegra_rt5640_dai = {static struct snd_soc_card snd_soc_tegra_rt5640 = { .name ="tegra-rt5640" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_rt5640_dai, .num_links =1 ,
sound/soc/tegra/tegra_rt5677.c +1 -0
@@ -175,6 +175,7 @@ static struct snd_soc_dai_link tegra_rt5677_dai = {static struct snd_soc_card snd_soc_tegra_rt5677 = { .name ="tegra-rt5677" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_rt5677_dai, .num_links =1 ,
sound/soc/tegra/tegra_sgtl5000.c +1 -0
@@ -97,6 +97,7 @@ static struct snd_soc_dai_link tegra_sgtl5000_dai = {static struct snd_soc_card snd_soc_tegra_sgtl5000 = { .name ="tegra-sgtl5000" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_sgtl5000_dai, .num_links =1 ,
sound/soc/tegra/tegra_wm8753.c +1 -0
@@ -101,6 +101,7 @@ static struct snd_soc_dai_link tegra_wm8753_dai = {static struct snd_soc_card snd_soc_tegra_wm8753 = { .name ="tegra-wm8753" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_wm8753_dai, .num_links =1 ,
sound/soc/tegra/tegra_wm8903.c +1 -0
@@ -235,6 +235,7 @@ static struct snd_soc_dai_link tegra_wm8903_dai = {static struct snd_soc_card snd_soc_tegra_wm8903 = { .name ="tegra-wm8903" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_wm8903_dai, .num_links =1 ,
sound/soc/tegra/tegra_wm9712.c +1 -0
@@ -54,6 +54,7 @@ static struct snd_soc_dai_link tegra_wm9712_dai = {static struct snd_soc_card snd_soc_tegra_wm9712 = { .name ="tegra-wm9712" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &tegra_wm9712_dai, .num_links =1 ,
sound/soc/tegra/trimslice.c +1 -0
@@ -94,6 +94,7 @@ static struct snd_soc_dai_link trimslice_tlv320aic23_dai = {static struct snd_soc_card snd_soc_trimslice = { .name ="tegra-trimslice" , + .driver_name ="tegra" , .owner =THIS_MODULE , .dai_link = &trimslice_tlv320aic23_dai, .num_links =1 ,
Signature · 1 line
2.30.2
Re: [PATCH v2 1/2] ASoC: tegra: Set driver_name=tegra for all machine drivers
20.05.2021 20:50, Dmitry Osipenko пишет:
sound/soc/tegra/tegra20_ac97.c static int tegra20_ac97_probe(struct snd_soc_dai *dai) · line 225
Quoted 5 lines
static struct
snd_soc_dai_drivertegra20_ac97_dai= {sound/soc/tegra/tegra20_ac97.c +1
-0.name = "tegra-ac97-pcm", + .driver_name = "tegra", .probe = tegra20_ac97_probe, .playback = {
This is incorrect version of the patch, snd_soc_dai_driver doesn't have driver_name. I missed to fix it properly on rebase of the patches. The rest of the patches is okay. This will be fixed in v3 if we'll agree that this is the correct approach, I'm waiting for the v2 feedback for now.
PATCH v2 2/2 ASoC: tegra: Unify ASoC machine drivers
In reply to Dmitry OsipenkoSquash 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/tegra20_ac97.c | 1 - sound/soc/tegra/tegra_alc5632.c | 260 ---------- sound/soc/tegra/tegra_asoc_machine.c | 732 +++++++++++++++++++++++++++ sound/soc/tegra/tegra_asoc_machine.h | 45 ++ sound/soc/tegra/tegra_max98090.c | 277 ---------- sound/soc/tegra/tegra_rt5640.c | 223 -------- sound/soc/tegra/tegra_rt5677.c | 325 ------------ sound/soc/tegra/tegra_sgtl5000.c | 212 -------- sound/soc/tegra/tegra_wm8753.c | 186 ------- sound/soc/tegra/tegra_wm8903.c | 358 +++---------- sound/soc/tegra/tegra_wm9712.c | 167 ------ sound/soc/tegra/trimslice.c | 173 ------- 14 files changed, 862 insertions(+), 2127 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
@@ -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
@@ -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/tegra20_ac97.c +0 -1
@@ -220,7 +220,6 @@ static int tegra20_ac97_probe(struct snd_soc_dai *dai)static struct snd_soc_dai_driver tegra20_ac97_dai = { .name ="tegra-ac97-pcm" , - .driver_name ="tegra" , .probe = tegra20_ac97_probe, .playback = { .stream_name ="PCM Playback" ,
sound/soc/tegra/tegra_alc5632.c deleted +0 -260
260 lines not on this page · raw message
sound/soc/tegra/tegra_asoc_machine.c new file +732 -0
732 lines not on this page · raw message
sound/soc/tegra/tegra_asoc_machine.h new file +45 -0
45 lines not on this page · raw message
sound/soc/tegra/tegra_max98090.c deleted +0 -277
277 lines not on this page · raw message
sound/soc/tegra/tegra_rt5640.c deleted +0 -223
223 lines not on this page · raw message
sound/soc/tegra/tegra_rt5677.c deleted +0 -325
325 lines not on this page · raw message
sound/soc/tegra/tegra_sgtl5000.c deleted +0 -212
212 lines not on this page · raw message
sound/soc/tegra/tegra_wm8753.c deleted +0 -186
186 lines not on this page · raw message
sound/soc/tegra/tegra_wm8903.c +71 -287
427 lines not on this page · raw message
sound/soc/tegra/tegra_wm9712.c deleted +0 -167
167 lines not on this page · raw message
sound/soc/tegra/trimslice.c deleted +0 -173
44 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.
Jaroslav Kysela
maintainerRe: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
Dne 20. 05. 21 v 19:50 Dmitry Osipenko napsal(a):
sound/soc/tegra/tegra_asoc_machine.c line 472
Quoted 11 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.
sound/soc/tegra/tegra_asoc_machine.c new file +5
-0+static struct snd_soc_card snd_soc_tegra_wm9712 = { + .dai_link = &tegra_wm9712_dai, + .num_links =1 , + .fully_routed = true, +};
Please, could you also initialize snd_soc_card->components? It may be useful to pass the codec identification to the user space like:
.components = "codec:wm9712"
The passed information should be consistent. You may look into the Intel ASoC drivers for the examples (card->components initialization). There are also hints about the number of connected microphones ("cfg-mic:2" - configuration with 2 microphones) or the codec purpose ("hs:rt711" - headset codec is RT711) etc.
Jaroslav
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Mark Brown
maintainerRe: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
Quoted 14 lines · Jaroslav Kysela
Dne 20. 05. 21 v 19:50 Dmitry Osipenko napsal(a):
sound/soc/tegra/tegra_asoc_machine.c line 472
Quoted 9 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.
sound/soc/tegra/tegra_asoc_machine.c new file +5
-0+static struct snd_soc_card snd_soc_tegra_wm9712 = { + .dai_link = &tegra_wm9712_dai, + .num_links =1 , + .fully_routed = true, +};Please, could you also initialize
snd_soc_card->components? It may be useful to pass the codec identification to the user space like:
Quoted 1 line
.components = "codec:wm9712"
Hrm, if this is important to userspace shouldn't the core be doing something by default given that it already knows all the components going into the card?
Quoted 5 lines
The passed information should be consistent. You may look into the Intel ASoC drivers for the examples (
card->componentsinitialization). There are also hints about the number of connected microphones ("cfg-mic:2" - configuration with 2 microphones) or the codec purpose ("hs:rt711" - headset codec is RT711) etc.
This sort of stuff is more something that the card should layer on top.
Jaroslav Kysela
maintainerRe: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
Dne 20. 05. 21 v 21:08 Mark Brown napsal(a):
Quoted 15 lines · Jaroslav Kysela
Quoted 13 lines
Dne 20. 05. 21 v 19:50 Dmitry Osipenko napsal(a):
sound/soc/tegra/tegra_asoc_machine.c line 472
Quoted 9 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.
sound/soc/tegra/tegra_asoc_machine.c new file +5
-0+static struct snd_soc_card snd_soc_tegra_wm9712 = { + .dai_link = &tegra_wm9712_dai, + .num_links =1 , + .fully_routed = true, +};Please, could you also initialize
snd_soc_card->components? It may be useful to pass the codec identification to the user space like:
Quoted 5 lines
Quoted 1 line
.components = "codec:wm9712"
Hrm, if this is important to userspace shouldn't the core be doing something by default given that it already knows all the components going into the card?
I don't think that we can pass the complex topology in the simple string (127 chars). For the time, it's better to pass only the vital information which the user space requires for the fine-grained hw configuration detection and description.
For the above example, the "codec:" prefix may be replaced by the purpose string (like "hs:" - headset, "spk:" - speaker) etc. This information is not available in the ASoC components (purpose / location / exact I/O config etc.).
Quoted 7 lines
Quoted 5 lines
The passed information should be consistent. You may look into the Intel ASoC drivers for the examples (
card->componentsinitialization). There are also hints about the number of connected microphones ("cfg-mic:2" - configuration with 2 microphones) or the codec purpose ("hs:rt711" - headset codec is RT711) etc.This sort of stuff is more something that the card should layer on top.
It would be nice to have this layer with the topology description, but until someone designs it, it's much easier to describe the configuration and hints in the simple string passed to the user space.
Actually, for ACPI/PCI platforms, the information is gathered from the tables or detected by PCI IDs. For the device tree. It may be worth to allow to pass this string from the device tree, too. I believe that the DT config author has enough information to describe the hardware.
Jaroslav
Signature · 2 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
Re: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
In reply to Jaroslav Kysela20.05.2021 22:02, Jaroslav Kysela пишет:
Quoted 15 lines
Dne 20. 05. 21 v 19:50 Dmitry Osipenko napsal(a):
sound/soc/tegra/tegra_asoc_machine.c line 472
Quoted 11 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.
sound/soc/tegra/tegra_asoc_machine.c new file +5
-0+static struct snd_soc_card snd_soc_tegra_wm9712 = { + .dai_link = &tegra_wm9712_dai, + .num_links =1 , + .fully_routed = true, +};Please, could you also initialize
snd_soc_card->components? It may be useful to pass the codec identification to the user space like:
Quoted 7 lines
.components = "codec:wm9712"
The passed information should be consistent. You may look into the Intel ASoC drivers for the examples (
card->componentsinitialization). There are also hints about the number of connected microphones ("cfg-mic:2" - configuration with 2 microphones) or the codec purpose ("hs:rt711" - headset codec is RT711) etc.
Alright, I see why you're wanting this. It may allow us to have more generic UCMs and group them together.
Jon Hunter
maintainerRe: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
In reply to Dmitry OsipenkoQuoted 36 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.
Suggested-by Jonathan Hunter <[email protected]>Co-developed-by Ion Agorria <[email protected]>Signed-off-by Ion Agorria <[email protected]>Co-developed-by Svyatoslav Ryhel <[email protected]>Signed-off-by Svyatoslav Ryhel <[email protected]>Signed-off-by Dmitry Osipenko <[email protected]>--- sound/soc/tegra/Kconfig | 12 + sound/soc/tegra/Makefile | 18 +- sound/soc/tegra/tegra20_ac97.c | 1 - sound/soc/tegra/tegra_alc5632.c | 260 ---------- sound/soc/tegra/tegra_asoc_machine.c | 732 +++++++++++++++++++++++++++ sound/soc/tegra/tegra_asoc_machine.h | 45 ++ sound/soc/tegra/tegra_max98090.c | 277 ---------- sound/soc/tegra/tegra_rt5640.c | 223 -------- sound/soc/tegra/tegra_rt5677.c | 325 ------------ sound/soc/tegra/tegra_sgtl5000.c | 212 -------- sound/soc/tegra/tegra_wm8753.c | 186 ------- sound/soc/tegra/tegra_wm8903.c | 358 +++---------- sound/soc/tegra/tegra_wm9712.c | 167 ------ sound/soc/tegra/trimslice.c | 173 ------- 14 files changed, 862 insertions(+), 2127 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
...
Review
Quoted 2 lines
(quoted diff) +2
-0+static unsigned int tegra_max98090_mclk_rate(unsigned int srate) +{
Minor comment, but I wonder if there is a better name for the above function? This function is using a fixed rate as opposed to scaling it with sample rate which can be common and not really specific to the max98090 codec.
Quoted 33 lines
sound/soc/tegra/tegra_asoc_machine.c new file +33
-0+unsigned int mclk; + +switch (srate) { +case 8000 : +case 16000 : +case 24000 : +case 32000 : +case 48000 : +case 64000 : +case 96000 : + mclk =12288000 ; +break ; +case 11025 : +case 22050 : +case 44100 : +case 88200 : + mclk =11289600 ; +break ; +default : + mclk =12000000 ; +break ; + } + +return mclk; +} + +unsigned int tegra_asoc_machine_mclk_rate (unsigned int srate) +{ +unsigned int mclk; + +switch (srate) { +case 64000 : +case 88200 :
sound/soc/tegra/tegra_asoc_machine.c line 254
Quoted 10 lines
sound/soc/tegra/tegra_asoc_machine.c new file +10
-0+case 96000 : + mclk =128 * srate; +break ; +default : + mclk =256 * srate; +break ; + } +/* FIXME: Codec only requires >= 3MHz if OSR==0 */ +while (mclk <6000000 ) + mclk *=2 ;
So this appears to be specific to the wm8903 codec or at least this is where it came from. And given that the switch statement is not complete in terms of the sample rates (ie. only has a subset), I am wondering if set should keep this specific to the wm8903 codec?
Quoted 13 lines
sound/soc/tegra/tegra_asoc_machine.c new file +13
-0+ +return mclk; +} +EXPORT_SYMBOL_GPL(tegra_asoc_machine_mclk_rate);> + +static int tegra_machine_hw_params(struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *codec_dai =asoc_rtd_to_codec (rtd,0 ); +struct snd_soc_card *card = rtd->card; +struct tegra_machine *machine =snd_soc_card_get_drvdata (card); +unsigned int srate =params_rate (params); +unsigned int mclk = machine->asoc->mclk_rate (srate);
sound/soc/tegra/tegra_asoc_machine.c line 278
Quoted 10 lines
sound/soc/tegra/tegra_asoc_machine.c new file +10
-0+const unsigned int clk_id =0 ; +int err; + + err =tegra_asoc_utils_set_rate (&machine->util_data, srate, mclk); +if (err <0 ) { +dev_err (card->dev,"Can't configure clocks: %d\n" , err); +return err; + } + + err =snd_soc_dai_set_sysclk (codec_dai, clk_id, mclk,SND_SOC_CLOCK_IN );
Looks like clk_id is always 0. Most likely all the clock ids passed are 0 by default but I wonder if we should not assume this in case something changes in the future?
Cheers
Jon
Signature · 1 line
nvpublic
Re: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
21.05.2021 16:12, Jon Hunter пишет:
Quoted 41 lines · Dmitry Osipenko
Quoted 36 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.
Suggested-by Jonathan Hunter <[email protected]>Co-developed-by Ion Agorria <[email protected]>Signed-off-by Ion Agorria <[email protected]>Co-developed-by Svyatoslav Ryhel <[email protected]>Signed-off-by Svyatoslav Ryhel <[email protected]>Signed-off-by Dmitry Osipenko <[email protected]>--- sound/soc/tegra/Kconfig | 12 + sound/soc/tegra/Makefile | 18 +- sound/soc/tegra/tegra20_ac97.c | 1 - sound/soc/tegra/tegra_alc5632.c | 260 ---------- sound/soc/tegra/tegra_asoc_machine.c | 732 +++++++++++++++++++++++++++ sound/soc/tegra/tegra_asoc_machine.h | 45 ++ sound/soc/tegra/tegra_max98090.c | 277 ---------- sound/soc/tegra/tegra_rt5640.c | 223 -------- sound/soc/tegra/tegra_rt5677.c | 325 ------------ sound/soc/tegra/tegra_sgtl5000.c | 212 -------- sound/soc/tegra/tegra_wm8753.c | 186 ------- sound/soc/tegra/tegra_wm8903.c | 358 +++---------- sound/soc/tegra/tegra_wm9712.c | 167 ------ sound/soc/tegra/trimslice.c | 173 ------- 14 files changed, 862 insertions(+), 2127 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...
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static unsigned int tegra_max98090_mclk_rate(unsigned int srate) +{Minor comment, but I wonder if there is a better name for the above function? This function is using a fixed rate as opposed to scaling it with sample rate which can be common and not really specific to the max98090 codec.
I'll rename it in v3, thank you for suggestion.
Quoted 40 lines
Quoted 40 lines
sound/soc/tegra/tegra_asoc_machine.c new file +40
-0+unsigned int mclk; + +switch (srate) { +case 8000 : +case 16000 : +case 24000 : +case 32000 : +case 48000 : +case 64000 : +case 96000 : + mclk =12288000 ; +break ; +case 11025 : +case 22050 : +case 44100 : +case 88200 : + mclk =11289600 ; +break ; +default : + mclk =12000000 ; +break ; + } + +return mclk; +} + +unsigned int tegra_asoc_machine_mclk_rate (unsigned int srate) +{ +unsigned int mclk; + +switch (srate) { +case 64000 : +case 88200 : +case 96000 : + mclk =128 * srate; +break ; +default : + mclk =256 * srate; +break ; + }
Quoted 8 lines
sound/soc/tegra/tegra_asoc_machine.c line 254
Quoted 3 lines
sound/soc/tegra/tegra_asoc_machine.c new file +3
-0+/* FIXME: Codec only requires >= 3MHz if OSR==0 */ +while (mclk <6000000 ) + mclk *=2 ;So this appears to be specific to the wm8903 codec or at least this is where it came from. And given that the switch statement is not complete in terms of the sample rates (ie. only has a subset), I am wondering if set should keep this specific to the wm8903 codec?
The RT5631 codec of Asus Transformers will re-use this function.
IIUC, the default switch-case works properly for all rates below 64KHz, at least I haven't had any problems with it. Could you please clarify why you are saying that the switch statement appears to be incomplete?
Quoted 19 lines
Quoted 19 lines
sound/soc/tegra/tegra_asoc_machine.c new file +19
-0+ +return mclk; +} +EXPORT_SYMBOL_GPL(tegra_asoc_machine_mclk_rate);> + +static int tegra_machine_hw_params(struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *codec_dai =asoc_rtd_to_codec (rtd,0 ); +struct snd_soc_card *card = rtd->card; +struct tegra_machine *machine =snd_soc_card_get_drvdata (card); +unsigned int srate =params_rate (params); +unsigned int mclk = machine->asoc->mclk_rate (srate); +const unsigned int clk_id =0 ; +int err; + + err =tegra_asoc_utils_set_rate (&machine->util_data, srate, mclk); +if (err <0 ) { +dev_err (card->dev,"Can't configure clocks: %d\n" , err);
Quoted 8 lines
sound/soc/tegra/tegra_asoc_machine.c line 278
Quoted 4 lines
sound/soc/tegra/tegra_asoc_machine.c new file +4
-0+return err; + } + + err =snd_soc_dai_set_sysclk (codec_dai, clk_id, mclk,SND_SOC_CLOCK_IN );Looks like
clk_idis always 0. Most likely all the clock ids passed are 0 by default but I wonder if we should not assume this in case something changes in the future?
Initially I had the same thought and even made the clk_id customizable, but then decided that for now it will be cleaner to hardcode ID to 0 since it will be very easy to customize the ID if will become necessary.
None of the currently supported devices use a different ID. I see now that the older Galaxy Tab 10 may need to use ID=1, so perhaps indeed it won't hurt to make it customizable already. I'll reconsider it for v3.
Thank you for the review.
Jon Hunter
maintainerRe: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
On 21/05/2021 20:05, Dmitry Osipenko wrote:
...
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
sound/soc/tegra/tegra_asoc_machine.c new file +14
-0+unsigned int tegra_asoc_machine_mclk_rate (unsigned int srate) +{ +unsigned int mclk; + +switch (srate) { +case 64000 : +case 88200 : +case 96000 : + mclk =128 * srate; +break ; +default : + mclk =256 * srate; +break ; + }Quoted 8 lines
sound/soc/tegra/tegra_asoc_machine.c line 254
Quoted 3 lines
sound/soc/tegra/tegra_asoc_machine.c new file +3
-0+/* FIXME: Codec only requires >= 3MHz if OSR==0 */ +while (mclk <6000000 ) + mclk *=2 ;So this appears to be specific to the wm8903 codec or at least this is where it came from. And given that the switch statement is not complete in terms of the sample rates (ie. only has a subset), I am wondering if set should keep this specific to the wm8903 codec?
Quoted 1 line
The RT5631 codec of Asus Transformers will re-use this function.
OK, but does it need this FIXME part? That appears to be codec specific.
Quoted 3 lines
IIUC, the default switch-case works properly for all rates below 64KHz, at least I haven't had any problems with it. Could you please clarify why you are saying that the switch statement appears to be incomplete?
It looks a bit weird because less than 64kHz and greater than 96kHz we use 256 and for only 64kHz, 88.2kHz and 96kHz we use 128. So it is not clear to me which sample rates have actually been tested with this and if this is complete or not?
Is it intended that we use 256 for sample rates greater than 96kHz?
Jon
Re: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
24.05.2021 15:22, Jon Hunter пишет:
Quoted 29 lines · Dmitry Osipenko
...
Quoted 23 lines
Quoted 22 lines
Quoted 7 lines
sound/soc/tegra/tegra_asoc_machine.c new file +7
-0+unsigned int tegra_asoc_machine_mclk_rate (unsigned int srate) +{ +unsigned int mclk; + +switch (srate) { +case 64000 : +case 88200 :sound/soc/tegra/tegra_asoc_machine.c line 254
Quoted 10 lines
sound/soc/tegra/tegra_asoc_machine.c new file +10
-0+case 96000 : + mclk =128 * srate; +break ; +default : + mclk =256 * srate; +break ; + } +/* FIXME: Codec only requires >= 3MHz if OSR==0 */ +while (mclk <6000000 ) + mclk *=2 ;So this appears to be specific to the wm8903 codec or at least this is where it came from. And given that the switch statement is not complete in terms of the sample rates (ie. only has a subset), I am wondering if set should keep this specific to the wm8903 codec?
Quoted 3 lines
Quoted 1 line
The RT5631 codec of Asus Transformers will re-use this function.
OK, but does it need this FIXME part? That appears to be codec specific.
Downstream RT5631 Tegra driver has exactly the same FIXME.
Although, I now see that downstream RT5631 uses 384*srate for the default cases.
I also see that WM8994 driver that we have in grate-kernel for Galaxy Tab and SGH-I927 also re-uses that mclk_rate function.
Quoted 10 lines
Quoted 3 lines
IIUC, the default switch-case works properly for all rates below 64KHz, at least I haven't had any problems with it. Could you please clarify why you are saying that the switch statement appears to be incomplete?
It looks a bit weird because less than 64kHz and greater than 96kHz we use 256 and for only 64kHz, 88.2kHz and 96kHz we use 128. So it is not clear to me which sample rates have actually been tested with this and if this is complete or not?
Is it intended that we use 256 for sample rates greater than 96kHz?
The 128*srate gives MCLK >6MHZ for 64/88/96, 256*srate gives MCLK >6MHZ for rates below 64kHZ. Looks like the goal is to get MCLK >6MHZ.
The WM8903 datasheet says:
"The following operating frequency limits must be observed when
configuring CLK_SYS. Failure to observe these limits will result in degraded noise performance and/or incorrect
ADC/DAC functionality.
If DAC_OSR = 0 then CLK_SYS 3MHz
If DAC_OSR = 1 then CLK_SYS 6MHz"
Where DAC_OSR is DAC Oversampling Control
0 = Low power (normal oversample)
1 = High performance (double rate)
I see that DAC_OSR=0 by default, it can be switched to 1 by userspace ALSA control.
Jon Hunter
maintainerRe: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
Quoted 30 lines · Dmitry Osipenko
24.05.2021 15:22, Jon Hunter пишет:
Quoted 29 lines · Dmitry Osipenko
...
Quoted 23 lines
Quoted 22 lines
Quoted 7 lines
sound/soc/tegra/tegra_asoc_machine.c new file +7
-0+unsigned int tegra_asoc_machine_mclk_rate (unsigned int srate) +{ +unsigned int mclk; + +switch (srate) { +case 64000 : +case 88200 :sound/soc/tegra/tegra_asoc_machine.c line 254
Quoted 10 lines
sound/soc/tegra/tegra_asoc_machine.c new file +10
-0+case 96000 : + mclk =128 * srate; +break ; +default : + mclk =256 * srate; +break ; + } +/* FIXME: Codec only requires >= 3MHz if OSR==0 */ +while (mclk <6000000 ) + mclk *=2 ;So this appears to be specific to the wm8903 codec or at least this is where it came from. And given that the switch statement is not complete in terms of the sample rates (ie. only has a subset), I am wondering if set should keep this specific to the wm8903 codec?
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
The RT5631 codec of Asus Transformers will re-use this function.
OK, but does it need this FIXME part? That appears to be codec specific.
Downstream RT5631 Tegra driver has exactly the same FIXME.
What downstream branch are you referring to? I still don't think that that is a good reason to make this 'FIXME' the standard going forward and hence I would prefer that it is kept specific the wm8903. Otherwise people will keep using this code without understanding if this is needed/correct.
Quoted 15 lines
Although, I now see that downstream RT5631 uses 384*srate for the default cases.
I also see that WM8994 driver that we have in grate-kernel for Galaxy Tab and SGH-I927 also re-uses that
mclk_ratefunction.Quoted 9 lines
Quoted 3 lines
IIUC, the default switch-case works properly for all rates below 64KHz, at least I haven't had any problems with it. Could you please clarify why you are saying that the switch statement appears to be incomplete?
It looks a bit weird because less than 64kHz and greater than 96kHz we use 256 and for only 64kHz, 88.2kHz and 96kHz we use 128. So it is not clear to me which sample rates have actually been tested with this and if this is complete or not?
Quoted 4 lines
Quoted 1 line
Is it intended that we use 256 for sample rates greater than 96kHz?
The 128*srate gives MCLK >6MHZ for 64/88/96, 256*srate gives MCLK >6MHZ for rates below 64kHZ. Looks like the goal is to get MCLK >6MHZ.
The wm8903 supports 8kHz sample rates and 256*8000 is less than 6MHz. Yes the FIXME loop corrects this, but you could also extend the case statement to multiply by 512 for 8kHz.
Quoted 10 lines
The WM8903 datasheet says:
"The following operating frequency limits must be observed when
configuring CLK_SYS. Failure to observe these limits will result in degraded noise performance and/or incorrectADC/DAC functionality.
If
DAC_OSR= 0 thenCLK_SYS3MHz
IfDAC_OSR= 1 thenCLK_SYS6MHz"
Quoted 7 lines
Where
DAC_OSRis DAC Oversampling Control
0 = Low power (normal oversample)
1 = High performance (double rate)I see that DAC_OSR=0 by default, it can be switched to 1 by userspace ALSA control.
Yes that is all fine, but again this is specific to the wm8903.
Jon
Signature · 1 line
nvpublic
Re: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
24.05.2021 21:50, Jon Hunter пишет:
Quoted 36 lines · Dmitry Osipenko
Quoted 34 lines
24.05.2021 15:22, Jon Hunter пишет:
Quoted 32 lines · Dmitry Osipenko
...
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
sound/soc/tegra/tegra_asoc_machine.c new file +14
-0+unsigned int tegra_asoc_machine_mclk_rate (unsigned int srate) +{ +unsigned int mclk; + +switch (srate) { +case 64000 : +case 88200 : +case 96000 : + mclk =128 * srate; +break ; +default : + mclk =256 * srate; +break ; + }Quoted 8 lines
sound/soc/tegra/tegra_asoc_machine.c line 254
Quoted 3 lines
sound/soc/tegra/tegra_asoc_machine.c new file +3
-0+/* FIXME: Codec only requires >= 3MHz if OSR==0 */ +while (mclk <6000000 ) + mclk *=2 ;So this appears to be specific to the wm8903 codec or at least this is where it came from. And given that the switch statement is not complete in terms of the sample rates (ie. only has a subset), I am wondering if set should keep this specific to the wm8903 codec?
Quoted 1 line
The RT5631 codec of Asus Transformers will re-use this function.
OK, but does it need this FIXME part? That appears to be codec specific.
Quoted 7 lines
Quoted 1 line
Downstream RT5631 Tegra driver has exactly the same FIXME.
What downstream branch are you referring to? I still don't think that that is a good reason to make this 'FIXME' the standard going forward and hence I would prefer that it is kept specific the wm8903. Otherwise people will keep using this code without understanding if this is needed/correct.
This is the original RT5631 driver from ASUS [1].
I briefly looked at the RT5631 datasheet and don't see it saying anything about the clk rate requirement >=6MHz. There are PLL tables with the MCLK for the reference clock. For now I'm not sure what downstream kernel tries to achieve, perhaps we should try to check whether all audio rates work for RT5631.
Quoted 15 lines
Quoted 15 lines
Although, I now see that downstream RT5631 uses 384*srate for the default cases.
I also see that WM8994 driver that we have in grate-kernel for Galaxy Tab and SGH-I927 also re-uses that
mclk_ratefunction.Quoted 9 lines
Quoted 3 lines
IIUC, the default switch-case works properly for all rates below 64KHz, at least I haven't had any problems with it. Could you please clarify why you are saying that the switch statement appears to be incomplete?
It looks a bit weird because less than 64kHz and greater than 96kHz we use 256 and for only 64kHz, 88.2kHz and 96kHz we use 128. So it is not clear to me which sample rates have actually been tested with this and if this is complete or not?
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Is it intended that we use 256 for sample rates greater than 96kHz?
The 128*srate gives MCLK >6MHZ for 64/88/96, 256*srate gives MCLK >6MHZ for rates below 64kHZ. Looks like the goal is to get MCLK >6MHZ.
The wm8903 supports 8kHz sample rates and 256*8000 is less than 6MHz. Yes the FIXME loop corrects this, but you could also extend the case statement to multiply by 512 for 8kHz.
But what benefits this extension will bring to us if the end result is the same?
Quoted 14 lines
Quoted 14 lines
The WM8903 datasheet says:
"The following operating frequency limits must be observed when
configuring CLK_SYS. Failure to observe these limits will result in degraded noise performance and/or incorrectADC/DAC functionality.
If
DAC_OSR= 0 thenCLK_SYS3MHz
IfDAC_OSR= 1 thenCLK_SYS6MHz"Where
DAC_OSRis DAC Oversampling Control
0 = Low power (normal oversample)
1 = High performance (double rate)
Quoted 5 lines
Quoted 3 lines
I see that DAC_OSR=0 by default, it can be switched to 1 by userspace ALSA control.
Yes that is all fine, but again this is specific to the wm8903.
Alright, I'll move it to the WM8903 driver in v4. It won't be a problem to make that function shared once will be actually needed.
Jon Hunter
maintainerRe: [PATCH v2 2/2] ASoC: tegra: Unify ASoC machine drivers
On 24/05/2021 22:02, Dmitry Osipenko wrote:
...
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
The 128*srate gives MCLK >6MHZ for 64/88/96, 256*srate gives MCLK >6MHZ for rates below 64kHZ. Looks like the goal is to get MCLK >6MHZ.
The wm8903 supports 8kHz sample rates and 256*8000 is less than 6MHz. Yes the FIXME loop corrects this, but you could also extend the case statement to multiply by 512 for 8kHz.
But what benefits this extension will bring to us if the end result is the same?
For the wm8903, nothing, but that is not the concern really.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
The WM8903 datasheet says:
"The following operating frequency limits must be observed when
configuring CLK_SYS. Failure to observe these limits will result in degraded noise performance and/or incorrectADC/DAC functionality.
If
DAC_OSR= 0 thenCLK_SYS3MHz
IfDAC_OSR= 1 thenCLK_SYS6MHz"Where
DAC_OSRis DAC Oversampling Control
0 = Low power (normal oversample)
1 = High performance (double rate)
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I see that DAC_OSR=0 by default, it can be switched to 1 by userspace ALSA control.
Yes that is all fine, but again this is specific to the wm8903.
Alright, I'll move it to the WM8903 driver in v4. It won't be a problem to make that function shared once will be actually needed.
Thanks, but it should only be shared if other codecs actually have this same requirement. From what you have said about the rt5631 it is not clear that it actually is the same or not.
Jon
Signature · 1 line
nvpublic