LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [RESEND 1/2] drm: bridge: adv7511: Enable SPDIF DAI
@ 2020-02-24 12:01 Bogdan Togorean
  2020-02-24 12:01 ` [RESEND 2/2] drm: bridge: adv7511: Extend list of audio sample rates Bogdan Togorean
  0 siblings, 1 reply; 5+ messages in thread
From: Bogdan Togorean @ 2020-02-24 12:01 UTC (permalink / raw)
  To: dri-devel
  Cc: airlied, daniel, narmstrong, a.hajda, Laurent.pinchart, jonas,
	jernej.skrabec, tglx, alexios.zavras, linux-kernel,
	Bogdan Togorean

ADV7511 support I2S or SPDIF as audio input interfaces. This commit
enable support for SPDIF.

Signed-off-by: Bogdan Togorean <bogdan.togorean@analog.com>
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/gpu/drm/bridge/adv7511/adv7511_audio.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
index a428185be2c1..1e9b128d229b 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
@@ -119,6 +119,9 @@ int adv7511_hdmi_hw_params(struct device *dev, void *data,
 		audio_source = ADV7511_AUDIO_SOURCE_I2S;
 		i2s_format = ADV7511_I2S_FORMAT_LEFT_J;
 		break;
+	case HDMI_SPDIF:
+		audio_source = ADV7511_AUDIO_SOURCE_SPDIF;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -175,11 +178,21 @@ static int audio_startup(struct device *dev, void *data)
 	/* use Audio infoframe updated info */
 	regmap_update_bits(adv7511->regmap, ADV7511_REG_GC(1),
 				BIT(5), 0);
+	/* enable SPDIF receiver */
+	if (adv7511->audio_source == ADV7511_AUDIO_SOURCE_SPDIF)
+		regmap_update_bits(adv7511->regmap, ADV7511_REG_AUDIO_CONFIG,
+				   BIT(7), BIT(7));
+
 	return 0;
 }
 
 static void audio_shutdown(struct device *dev, void *data)
 {
+	struct adv7511 *adv7511 = dev_get_drvdata(dev);
+
+	if (adv7511->audio_source == ADV7511_AUDIO_SOURCE_SPDIF)
+		regmap_update_bits(adv7511->regmap, ADV7511_REG_AUDIO_CONFIG,
+				   BIT(7), 0);
 }
 
 static int adv7511_hdmi_i2s_get_dai_id(struct snd_soc_component *component,
@@ -213,6 +226,7 @@ static const struct hdmi_codec_pdata codec_data = {
 	.ops = &adv7511_codec_ops,
 	.max_i2s_channels = 2,
 	.i2s = 1,
+	.spdif = 1,
 };
 
 int adv7511_audio_init(struct device *dev, struct adv7511 *adv7511)
-- 
2.25.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RESEND 2/2] drm: bridge: adv7511: Extend list of audio sample rates
  2020-02-24 12:01 [RESEND 1/2] drm: bridge: adv7511: Enable SPDIF DAI Bogdan Togorean
@ 2020-02-24 12:01 ` Bogdan Togorean
  2020-04-07 15:09   ` Andrzej Hajda
  0 siblings, 1 reply; 5+ messages in thread
From: Bogdan Togorean @ 2020-02-24 12:01 UTC (permalink / raw)
  To: dri-devel
  Cc: airlied, daniel, narmstrong, a.hajda, Laurent.pinchart, jonas,
	jernej.skrabec, tglx, alexios.zavras, linux-kernel,
	Bogdan Togorean

ADV7511 support sample rates up to 192kHz. CTS and N parameters should
be computed accordingly so this commit extend the list up to maximum
supported sample rate.

Signed-off-by: Bogdan Togorean <bogdan.togorean@analog.com>
---
 drivers/gpu/drm/bridge/adv7511/adv7511_audio.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
index 1e9b128d229b..13e8cee6e827 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
@@ -27,6 +27,18 @@ static void adv7511_calc_cts_n(unsigned int f_tmds, unsigned int fs,
 	case 48000:
 		*n = 6144;
 		break;
+	case 88200:
+		*n = 12544;
+		break;
+	case 96000:
+		*n = 12288;
+		break;
+	case 176400:
+		*n = 25088;
+		break;
+	case 192000:
+		*n = 24576;
+		break;
 	}
 
 	*cts = ((f_tmds * *n) / (128 * fs)) * 1000;
-- 
2.25.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RESEND 2/2] drm: bridge: adv7511: Extend list of audio sample rates
  2020-02-24 12:01 ` [RESEND 2/2] drm: bridge: adv7511: Extend list of audio sample rates Bogdan Togorean
@ 2020-04-07 15:09   ` Andrzej Hajda
  2020-04-13  8:39     ` Togorean, Bogdan
  0 siblings, 1 reply; 5+ messages in thread
From: Andrzej Hajda @ 2020-04-07 15:09 UTC (permalink / raw)
  To: Bogdan Togorean, dri-devel
  Cc: jernej.skrabec, jonas, airlied, narmstrong, linux-kernel,
	alexios.zavras, Laurent.pinchart, tglx

On 24.02.2020 13:01, Bogdan Togorean wrote:
> ADV7511 support sample rates up to 192kHz. CTS and N parameters should
> be computed accordingly so this commit extend the list up to maximum
> supported sample rate.
>
> Signed-off-by: Bogdan Togorean <bogdan.togorean@analog.com>
> ---
>  drivers/gpu/drm/bridge/adv7511/adv7511_audio.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
> index 1e9b128d229b..13e8cee6e827 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
> @@ -27,6 +27,18 @@ static void adv7511_calc_cts_n(unsigned int f_tmds, unsigned int fs,
>  	case 48000:
>  		*n = 6144;
>  		break;
> +	case 88200:
> +		*n = 12544;
> +		break;
> +	case 96000:
> +		*n = 12288;
> +		break;
> +	case 176400:
> +		*n = 25088;
> +		break;
> +	case 192000:
> +		*n = 24576;
> +		break;


I would put:

case 32000:
case 48000:
case 96000:
case 192000:
    *n = fs * 128 / 1000;
    break;
case 44100:
case 88200:
case 176400:
    *n = fs * 128 / 900;
    break;

To uncover the magic. Up to you.

Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>


Regards
Andrzej
>  	}
>  
>  	*cts = ((f_tmds * *n) / (128 * fs)) * 1000;



^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [RESEND 2/2] drm: bridge: adv7511: Extend list of audio sample rates
  2020-04-07 15:09   ` Andrzej Hajda
@ 2020-04-13  8:39     ` Togorean, Bogdan
  0 siblings, 0 replies; 5+ messages in thread
From: Togorean, Bogdan @ 2020-04-13  8:39 UTC (permalink / raw)
  To: Andrzej Hajda, dri-devel
  Cc: jernej.skrabec, jonas, airlied, narmstrong, linux-kernel,
	alexios.zavras, Laurent.pinchart, tglx

> > ADV7511 support sample rates up to 192kHz. CTS and N parameters should
> > be computed accordingly so this commit extend the list up to maximum
> > supported sample rate.
> >
> > Signed-off-by: Bogdan Togorean <bogdan.togorean@analog.com>
> > ---
> >  drivers/gpu/drm/bridge/adv7511/adv7511_audio.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
> b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
> > index 1e9b128d229b..13e8cee6e827 100644
> > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
> > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
> > @@ -27,6 +27,18 @@ static void adv7511_calc_cts_n(unsigned int f_tmds,
> unsigned int fs,
> >  	case 48000:
> >  		*n = 6144;
> >  		break;
> > +	case 88200:
> > +		*n = 12544;
> > +		break;
> > +	case 96000:
> > +		*n = 12288;
> > +		break;
> > +	case 176400:
> > +		*n = 25088;
> > +		break;
> > +	case 192000:
> > +		*n = 24576;
> > +		break;
> 
> 
> I would put:
> 
> case 32000:
> case 48000:
> case 96000:
> case 192000:
>     *n = fs * 128 / 1000;
>     break;
> case 44100:
> case 88200:
> case 176400:
>     *n = fs * 128 / 900;
>     break;
> 
> To uncover the magic. Up to you.
Great solution Andrzej,

Thank you for your suggestion.

Regards,
Bogdan
> 
> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
> 
> 
> Regards
> Andrzej
> >  	}
> >
> >  	*cts = ((f_tmds * *n) / (128 * fs)) * 1000;
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RESEND 2/2] drm: bridge: adv7511: Extend list of audio sample rates
  2020-04-07  9:13 [RESEND 1/2] drm: bridge: adv7511: Enable SPDIF DAI Bogdan Togorean
@ 2020-04-07  9:13 ` Bogdan Togorean
  0 siblings, 0 replies; 5+ messages in thread
From: Bogdan Togorean @ 2020-04-07  9:13 UTC (permalink / raw)
  To: dri-devel
  Cc: Bogdan Togorean, Andrzej Hajda, Neil Armstrong, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, David Airlie, Daniel Vetter,
	Steve Winslow, Alexios Zavras, Greg Kroah-Hartman,
	Richard Fontana, Thomas Gleixner, linux-kernel

ADV7511 support sample rates up to 192kHz. CTS and N parameters should
be computed accordingly so this commit extend the list up to maximum
supported sample rate.

Signed-off-by: Bogdan Togorean <bogdan.togorean@analog.com>
---
 drivers/gpu/drm/bridge/adv7511/adv7511_audio.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
index 1e9b128d229b..13e8cee6e827 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_audio.c
@@ -27,6 +27,18 @@ static void adv7511_calc_cts_n(unsigned int f_tmds, unsigned int fs,
 	case 48000:
 		*n = 6144;
 		break;
+	case 88200:
+		*n = 12544;
+		break;
+	case 96000:
+		*n = 12288;
+		break;
+	case 176400:
+		*n = 25088;
+		break;
+	case 192000:
+		*n = 24576;
+		break;
 	}
 
 	*cts = ((f_tmds * *n) / (128 * fs)) * 1000;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-13  8:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 12:01 [RESEND 1/2] drm: bridge: adv7511: Enable SPDIF DAI Bogdan Togorean
2020-02-24 12:01 ` [RESEND 2/2] drm: bridge: adv7511: Extend list of audio sample rates Bogdan Togorean
2020-04-07 15:09   ` Andrzej Hajda
2020-04-13  8:39     ` Togorean, Bogdan
2020-04-07  9:13 [RESEND 1/2] drm: bridge: adv7511: Enable SPDIF DAI Bogdan Togorean
2020-04-07  9:13 ` [RESEND 2/2] drm: bridge: adv7511: Extend list of audio sample rates Bogdan Togorean

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).