linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Vijendar Mukunda <Vijendar.Mukunda@amd.com>,
	broonie@kernel.org, alsa-devel@alsa-project.org
Cc: Alexander.Deucher@amd.com, Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Ravulapati Vishnu vardhan rao 
	<Vishnuvardhanrao.Ravulapati@amd.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	Chuhong Yuan <hslester96@gmail.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ASoC: amd: add support for rt5682 codec in machine driver
Date: Tue, 9 Mar 2021 12:36:27 -0600	[thread overview]
Message-ID: <e8c08384-93be-ee88-80b2-381f154bfa19@linux.intel.com> (raw)
In-Reply-To: <1615301217-4556-1-git-send-email-Vijendar.Mukunda@amd.com>



> +++ b/sound/soc/amd/Kconfig
> @@ -5,14 +5,15 @@ config SND_SOC_AMD_ACP
>   	 This option enables ACP DMA support on AMD platform.
>   
>   config SND_SOC_AMD_CZ_DA7219MX98357_MACH
> -	tristate "AMD CZ support for DA7219 and MAX9835"
> +	tristate "AMD CZ support for DA7219, RT5682 and MAX9835"
>   	select SND_SOC_DA7219
> +	select SND_SOC_RT5682

select SND_SOC_RT5682_I2C

>   	select SND_SOC_MAX98357A
>   	select SND_SOC_ADAU7002
>   	select REGULATOR
>   	depends on SND_SOC_AMD_ACP && I2C && GPIOLIB
>   	help
> -	 This option enables machine driver for DA7219 and MAX9835.
> +	 This option enables machine driver for DA7219, RT5682 and MAX9835.
>   
>   config SND_SOC_AMD_CZ_RT5645_MACH
>   	tristate "AMD CZ support for RT5645"
> diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c
> index 849288d..ff2b639 100644
> --- a/sound/soc/amd/acp-da7219-max98357a.c
> +++ b/sound/soc/amd/acp-da7219-max98357a.c
> @@ -1,7 +1,7 @@
>   /*
>    * Machine driver for AMD ACP Audio engine using DA7219 & MAX98357 codec
>    *
> - * Copyright 2017 Advanced Micro Devices, Inc.
> + * Copyright 2017-2021 Advanced Micro Devices, Inc.
>    *
>    * Permission is hereby granted, free of charge, to any person obtaining a
>    * copy of this software and associated documentation files (the "Software"),

convert to SPDX?

> @@ -41,14 +41,19 @@
>   #include "acp.h"
>   #include "../codecs/da7219.h"
>   #include "../codecs/da7219-aad.h"
> +#include "../codecs/rt5682.h"
>   
>   #define CZ_PLAT_CLK 48000000
>   #define DUAL_CHANNEL		2
> +#define RT5682_PLL_FREQ (48000 * 512)
>   
>   static struct snd_soc_jack cz_jack;
>   static struct clk *da7219_dai_wclk;
>   static struct clk *da7219_dai_bclk;
> -extern bool bt_uart_enable;
> +static struct clk *rt5682_dai_wclk;
> +static struct clk *rt5682_dai_bclk;
> +extern int bt_uart_enable;
> +void *soc_is_rltk_max(struct device *dev);
>   
>   static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
>   {
> @@ -128,6 +133,88 @@ static void da7219_clk_disable(void)
>   	clk_disable_unprepare(da7219_dai_bclk);
>   }
>   
> +static int cz_rt5682_init(struct snd_soc_pcm_runtime *rtd)
> +{
> +	int ret;
> +	struct snd_soc_card *card = rtd->card;
> +	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
> +	struct snd_soc_component *component = codec_dai->component;
> +
> +	dev_info(codec_dai->dev, "codec dai name = %s\n", codec_dai->name);
> +
> +	/* Set codec sysclk */
> +	ret = snd_soc_dai_set_sysclk(codec_dai, RT5682_SCLK_S_PLL2,
> +				     RT5682_PLL_FREQ, SND_SOC_CLOCK_IN);
> +	if (ret < 0) {
> +		dev_err(codec_dai->dev,
> +			"Failed to set rt5682 SYSCLK: %d\n", ret);
> +		return ret;
> +	}
> +	/* set codec PLL */
> +	ret = snd_soc_dai_set_pll(codec_dai, RT5682_PLL2, RT5682_PLL2_S_MCLK,
> +				  CZ_PLAT_CLK, RT5682_PLL_FREQ);
> +	if (ret < 0) {
> +		dev_err(codec_dai->dev, "can't set rt5682 PLL: %d\n", ret);
> +		return ret;
> +	}
> +
> +	rt5682_dai_wclk = devm_clk_get(component->dev, "rt5682-dai-wclk");
> +	if (IS_ERR(rt5682_dai_wclk))
> +		return PTR_ERR(rt5682_dai_wclk);
> +
> +	rt5682_dai_bclk = devm_clk_get(component->dev, "rt5682-dai-bclk");
> +	if (IS_ERR(rt5682_dai_bclk))
> +		return PTR_ERR(rt5682_dai_bclk);
> +
> +	ret = snd_soc_card_jack_new(card, "Headset Jack",
> +				    SND_JACK_HEADSET | SND_JACK_LINEOUT |
> +				    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
> +				    SND_JACK_BTN_2 | SND_JACK_BTN_3,
> +				    &cz_jack, NULL, 0);
> +	if (ret) {
> +		dev_err(card->dev, "HP jack creation failed %d\n", ret);
> +		return ret;
> +	}
> +
> +	snd_jack_set_key(cz_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
> +	snd_jack_set_key(cz_jack.jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
> +	snd_jack_set_key(cz_jack.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
> +	snd_jack_set_key(cz_jack.jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
> +
> +	ret = snd_soc_component_set_jack(component, &cz_jack, NULL);
> +	if (ret) {
> +		dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
> +		return ret;
> +	}
> +	return 0;
> +}
> +
> +static int rt5682_clk_enable(struct snd_pcm_substream *substream)
> +{
> +	int ret = 0;

useless init

> +	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
> +
> +	/*
> +	 * Set wclk to 48000 because the rate constraint of this driver is
> +	 * 48000. ADAU7002 spec: "The ADAU7002 requires a BCLK rate that is
> +	 * minimum of 64x the LRCLK sample rate." DA7219 is the only clk
> +	 * source so for all codecs we have to limit bclk to 64X lrclk.

copy doesn't seem correct, this isn't about DA7219

> +	 */
> +	clk_set_rate(rt5682_dai_wclk, 48000);
> +	clk_set_rate(rt5682_dai_bclk, 48000 * 64);
> +	ret = clk_prepare_enable(rt5682_dai_bclk);
> +	if (ret < 0) {
> +		dev_err(rtd->dev, "can't enable master clock %d\n", ret);
> +		return ret;
> +	}
> +	return ret;
> +}
> +


      reply	other threads:[~2021-03-09 18:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 14:46 [PATCH] ASoC: amd: add support for rt5682 codec in machine driver Vijendar Mukunda
2021-03-09 18:36 ` Pierre-Louis Bossart [this message]

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=e8c08384-93be-ee88-80b2-381f154bfa19@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Vijendar.Mukunda@amd.com \
    --cc=Vishnuvardhanrao.Ravulapati@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=hslester96@gmail.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --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).