From: Rob Herring <robh@kernel.org>
To: Dmitry Osipenko <digetx@gmail.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>,
Jaroslav Kysela <perex@perex.cz>, Ion Agorria <ion@agorria.com>,
Svyatoslav Ryhel <clamor95@gmail.com>,
Frank Rowand <frowand.list@gmail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
linux-tegra@vger.kernel.org, devicetree@vger.kernel.org,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 2/2] ASoC: tegra: Unify ASoC machine drivers
Date: Tue, 18 May 2021 13:09:49 -0500 [thread overview]
Message-ID: <20210518180949.GA949047@robh.at.kernel.org> (raw)
In-Reply-To: <20210518001356.19227-3-digetx@gmail.com>
On Tue, May 18, 2021 at 03:13:56AM +0300, Dmitry Osipenko wrote:
> 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).
>
> Suggested-by: Jonathan Hunter <jonathanh@nvidia.com>
> Co-developed-by: Ion Agorria <ion@agorria.com>
> Signed-off-by: Ion Agorria <ion@agorria.com>
> Co-developed-by: Svyatoslav Ryhel <clamor95@gmail.com>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
[...]
> diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
> index e4863fa37b0c..fdf74bfd728e 100644
> --- a/sound/soc/tegra/tegra_wm8903.c
> +++ b/sound/soc/tegra/tegra_wm8903.c
> @@ -14,192 +14,80 @@
> * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
> */
>
> +#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;
> +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.
> };
>
> -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);
[...]
> +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 <swarren@nvidia.com>");
> MODULE_DESCRIPTION("Tegra+WM8903 machine ASoC driver");
> MODULE_LICENSE("GPL");
> -MODULE_ALIAS("platform:" DRV_NAME);
> -MODULE_DEVICE_TABLE(of, tegra_wm8903_of_match);
next prev parent reply other threads:[~2021-05-18 18:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-18 0:13 [PATCH v1 0/2] Unify NVIDIA Tegra ASoC machine drivers Dmitry Osipenko
2021-05-18 0:13 ` [PATCH v1 1/2] of: base: Export of_device_compatible_match() Dmitry Osipenko
2021-05-18 18:14 ` Rob Herring
2021-05-18 0:13 ` [PATCH v1 2/2] ASoC: tegra: Unify ASoC machine drivers Dmitry Osipenko
2021-05-18 18:09 ` Rob Herring [this message]
2021-05-18 18:34 ` Mark Brown
2021-05-18 20:16 ` Dmitry Osipenko
2021-05-19 20:09 ` Mark Brown
2021-05-18 22:31 ` Question about Tegra UCMs Dmitry Osipenko
2021-05-19 11:13 ` Jaroslav Kysela
2021-05-19 13:15 ` Dmitry Osipenko
2021-05-19 11:38 ` Mark Brown
2021-05-19 13:19 ` Dmitry Osipenko
2021-05-18 20:11 ` [PATCH v1 2/2] ASoC: tegra: Unify ASoC machine drivers Dmitry Osipenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210518180949.GA949047@robh.at.kernel.org \
--to=robh@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=clamor95@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=digetx@gmail.com \
--cc=frowand.list@gmail.com \
--cc=ion@agorria.com \
--cc=jonathanh@nvidia.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=perex@perex.cz \
--cc=thierry.reding@gmail.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).