All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jyri Sarha <jsarha@ti.com>
To: Russell King <rmk+kernel@armlinux.org.uk>,
	Sven Van Asbroeck <thesven73@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: David Airlie <airlied@linux.ie>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH RFC 3/3] drm/i2c: tda998x: add support for bclk_ratio
Date: Mon, 25 Feb 2019 15:47:19 +0200	[thread overview]
Message-ID: <0e450e81-9281-5f1a-e943-ff7f8b0a1401@ti.com> (raw)
In-Reply-To: <E1gxILr-0004Mm-WE@rmk-PC.armlinux.org.uk>

On 22/02/2019 23:27, Russell King wrote:
> It appears that TDA998x derives the CTS value using the supplied I2S
> bit clock (BCLK) rather than 128·fs.  TDA998x uses two constants named
> m and k in the CTS generator such that we have this relationship
> between the source BCLK and the sink fs:
> 
> 	128·fs_sink = BCLK·m / k
> 
> Where BCLK = bclk_ratio·fs_source.
> 
> We have been lucky up to now that all users have scaled their bclk_ratio
> to match the sample width - for example, on Beagle Bone Black, with a
> 16-bit sample width, BCLK = 32·fs, which increases to 64·fs for 32-bit
> samples.  24-bit samples are sent as 32-bit.
> 
> We are now starting to see users whose I2S blocks send at 64·fs for
> 16-bit samples, which means TDA998x now breaks.
> 
> ASoC has a snd_soc_dai_set_bclk_ratio() call available which sets the
> ratio of BCLK to the sample rate.  Implement support for this.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Works at least on Beaglebone-black.

Tested-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Jyri Sarha <jsarha@ti.com>

> ---
>  drivers/gpu/drm/i2c/tda998x_drv.c | 20 +++++++++++++-------
>  include/drm/i2c/tda998x.h         |  1 +
>  2 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
> index 645d884fb9e8..f2d40235acf9 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -895,21 +895,26 @@ tda998x_configure_audio(struct tda998x_priv *priv,
>  		reg_write(priv, REG_MUX_AP, MUX_AP_SELECT_I2S);
>  		clksel_aip = AIP_CLKSEL_AIP_I2S;
>  		clksel_fs = AIP_CLKSEL_FS_ACLK;
> -		switch (params->sample_width) {
> +		switch (params->bclk_ratio) {
>  		case 16:
> +			cts_n = CTS_N_M(3) | CTS_N_K(0);
> +			break;
> +		case 32:
>  			cts_n = CTS_N_M(3) | CTS_N_K(1);
>  			break;
> -		case 18:
> -		case 20:
> -		case 24:
> +		case 48:
>  			cts_n = CTS_N_M(3) | CTS_N_K(2);
>  			break;
> -		default:
> -		case 32:
> +		case 64:
>  			cts_n = CTS_N_M(3) | CTS_N_K(3);
>  			break;
> +		case 128:
> +			cts_n = CTS_N_M(0) | CTS_N_K(0);
> +			break;
> +		default:
> +			dev_err(&priv->hdmi->dev, "unsupported I2S bclk ratio\n");
> +			return -EINVAL;
>  		}
> -
>  		switch (params->format & AFMT_I2S_MASK) {
>  		case AFMT_I2S_LEFT_J:
>  			i2s_fmt = I2S_FORMAT_LEFT_J;
> @@ -997,6 +1002,7 @@ static int tda998x_audio_hw_params(struct device *dev, void *data,
>  	struct tda998x_priv *priv = dev_get_drvdata(dev);
>  	int i, ret;
>  	struct tda998x_audio_params audio = {
> +		.bclk_ratio = daifmt->bclk_ratio,
>  		.sample_width = params->sample_width,
>  		.sample_rate = params->sample_rate,
>  		.cea = params->cea,
> diff --git a/include/drm/i2c/tda998x.h b/include/drm/i2c/tda998x.h
> index b0864f0be017..4e0f0cd2d428 100644
> --- a/include/drm/i2c/tda998x.h
> +++ b/include/drm/i2c/tda998x.h
> @@ -19,6 +19,7 @@ enum {
>  struct tda998x_audio_params {
>  	u8 config;
>  	u8 format;
> +	u8 bclk_ratio;
>  	unsigned sample_width;
>  	unsigned sample_rate;
>  	struct hdmi_audio_infoframe cea;
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-02-25 13:47 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 21:26 [PATCH RFC 0/3] tda998x updates for DAI formats and bclk_ratio Russell King - ARM Linux admin
2019-02-22 21:27 ` [PATCH RFC 1/3] drm/i2c: tda998x: implement different I2S flavours Russell King
2019-02-25 13:26   ` Jyri Sarha
2019-02-25 13:28   ` Peter Ujfalusi
2019-02-25 13:40     ` Russell King - ARM Linux admin
2019-02-25 16:23   ` Sven Van Asbroeck
2019-02-22 21:27 ` [PATCH RFC 2/3] ASoC: hdmi-codec: add support for bclk_ratio Russell King
2019-02-25 13:45   ` Jyri Sarha
2019-02-25 14:03     ` Russell King - ARM Linux admin
2019-02-25 20:58       ` Jyri Sarha
2019-02-25 23:01         ` Russell King - ARM Linux admin
2019-02-27 11:47         ` Russell King - ARM Linux admin
2019-02-27 17:48           ` Jyri Sarha
2019-02-27 18:00             ` Russell King - ARM Linux admin
2019-02-27 20:24               ` Jyri Sarha
2019-02-27 18:01       ` Sven Van Asbroeck
2019-02-27 19:56         ` Russell King - ARM Linux admin
2019-02-27 20:22           ` Sven Van Asbroeck
2019-02-27 20:24           ` Russell King - ARM Linux admin
2019-03-01 12:36     ` Mark Brown
2019-03-01 14:05       ` Jyri Sarha
2019-03-01 14:59         ` Russell King - ARM Linux admin
2019-03-01 16:35           ` Jyri Sarha
2019-03-04 16:59       ` Sven Van Asbroeck
2019-03-04 17:32         ` Jyri Sarha
2019-02-22 21:27 ` [PATCH RFC 3/3] drm/i2c: tda998x: " Russell King
2019-02-25 13:47   ` Jyri Sarha [this message]
2019-02-25 16:26   ` Sven Van Asbroeck

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=0e450e81-9281-5f1a-e943-ff7f8b0a1401@ti.com \
    --to=jsarha@ti.com \
    --cc=airlied@linux.ie \
    --cc=broonie@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=peter.ujfalusi@ti.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=thesven73@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.