mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Kirill Marinushkin <kmarinushkin@birdec.com>,
	Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <lgirdwood@gmail.com>
Cc: Matthias Reichl <hias@horus.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	<alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ASoC: pcm512x: Add support for data formats RJ and LJ
Date: Tue, 10 Nov 2020 08:59:50 +0200	[thread overview]
Message-ID: <690508c7-7029-6781-a1a2-0609e37cb9e6@ti.com> (raw)
In-Reply-To: <20201109212133.25869-1-kmarinushkin@birdec.com>



On 09/11/2020 23.21, Kirill Marinushkin wrote:
> Currently, pcm512x driver supports only I2S data format.
> This commit adds RJ and LJ as well.
> 
> I don't expect regression WRT existing sound cards, because:
> 
> * default value in corresponding register of pcm512x codec is 0 ==  I2S
> * existing in-tree sound cards with pcm512x codec are configured for I2S
> * i don't see how existing off-tree sound cards with pcm512x codec could be
>   configured differently - it would not work
> * tested explicitly, that there is no regression with Raspberry Pi +
>   sound card `sound/soc/bcm/hifiberry_dacplus.c`
> 
> Signed-off-by: Kirill Marinushkin <kmarinushkin@birdec.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Matthias Reichl <hias@horus.com>
> Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Cc: alsa-devel@alsa-project.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  sound/soc/codecs/pcm512x.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
> index 8153d3d01654..c6e975fb4a43 100644
> --- a/sound/soc/codecs/pcm512x.c
> +++ b/sound/soc/codecs/pcm512x.c
> @@ -1167,6 +1167,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream,
>  	struct snd_soc_component *component = dai->component;
>  	struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component);
>  	int alen;
> +	int afmt;
>  	int gpio;
>  	int clock_output;
>  	int master_mode;
> @@ -1195,6 +1196,22 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream,
>  		return -EINVAL;
>  	}
>  
> +	switch (pcm512x->fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
> +	case SND_SOC_DAIFMT_I2S:
> +		afmt = PCM512x_AFMT_I2S;
> +		break;
> +	case SND_SOC_DAIFMT_RIGHT_J:
> +		afmt = PCM512x_AFMT_RTJ;
> +		break;
> +	case SND_SOC_DAIFMT_LEFT_J:
> +		afmt = PCM512x_AFMT_LTJ;
> +		break;
> +	default:
> +		dev_err(component->dev, "unsupported DAI format: 0x%x\n",
> +			pcm512x->fmt);
> +		return -EINVAL;
> +	}
> +

The bus format and

>  	switch (pcm512x->fmt & SND_SOC_DAIFMT_MASTER_MASK) {

>  	case SND_SOC_DAIFMT_CBS_CFS:
>  		ret = regmap_update_bits(pcm512x->regmap,

the clock generation role should be set in pcm512x_set_fmt(), in that
way you can deny specific setups earlier.

I would also add DSP_A and DSP_B modes at the same time, DSP_A would
need a write of 1 to register 41 (PCM512x_I2S_2, offset = 1), other
formats should set the offset to 0.

> @@ -1236,6 +1253,13 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream,
>  		return ret;
>  	}
>  
> +	ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1,
> +				 PCM512x_AFMT, afmt);
> +	if (ret != 0) {
> +		dev_err(component->dev, "Failed to set data format: %d\n", ret);
> +		return ret;
> +	}
> +
>  	if (pcm512x->pll_out) {
>  		ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_A, 0x11);
>  		if (ret != 0) {
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  reply	other threads:[~2020-11-10  7:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 21:21 Kirill Marinushkin
2020-11-10  6:59 ` Peter Ujfalusi [this message]
2020-11-11  7:54   ` Kirill Marinushkin
2020-11-12  7:41     ` Peter Ujfalusi
2020-11-12  7:57       ` Kirill Marinushkin
2020-11-12  8:59         ` Peter Ujfalusi
2020-11-11 21:43   ` [PATCH v2] ASoC: pcm512x: Add support for more data formats Kirill Marinushkin

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=690508c7-7029-6781-a1a2-0609e37cb9e6@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=hias@horus.com \
    --cc=kmarinushkin@birdec.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®