diff mbox series

[v3,07/10] drm: rcar-du: Skip LVDS1 output on Gen3 when using dual-link LVDS mode

Message ID 20190528141234.15425-8-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series R-Car DU: LVDS dual-link mode support | expand

Commit Message

Laurent Pinchart May 28, 2019, 2:12 p.m. UTC
In dual-link LVDS mode, the LVDS1 encoder is used as a companion for
LVDS0, and both encoders transmit data from DU0. The LVDS1 output of DU1
can't be used in that case, don't create an encoder and connector for
it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
Changess since v2:

- Remove unneeded bridge NULL check
---
 drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 12 ++++++++++++
 drivers/gpu/drm/rcar-du/rcar_du_kms.c     |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

Comments

Sam Ravnborg May 28, 2019, 4:42 p.m. UTC | #1
Hi Laurent.

On Tue, May 28, 2019 at 05:12:31PM +0300, Laurent Pinchart wrote:
> In dual-link LVDS mode, the LVDS1 encoder is used as a companion for
> LVDS0, and both encoders transmit data from DU0. The LVDS1 output of DU1
> can't be used in that case, don't create an encoder and connector for
> it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
> Changess since v2:
> 
> - Remove unneeded bridge NULL check
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 12 ++++++++++++
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c     |  2 +-
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> index 6c91753af7bc..0f00bdfe2366 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> @@ -16,6 +16,7 @@
>  #include "rcar_du_drv.h"
>  #include "rcar_du_encoder.h"
>  #include "rcar_du_kms.h"
> +#include "rcar_lvds.h"
>  
>  /* -----------------------------------------------------------------------------
>   * Encoder
> @@ -97,6 +98,17 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
>  		}
>  	}
>  
> +	/*
> +	 * On Gen3 skip the LVDS1 output if the LVDS1 encoder is used as a
> +	 * companion for LVDS0 in dual-link mode.
> +	 */
> +	if (rcdu->info->gen >= 3 && output == RCAR_DU_OUTPUT_LVDS1) {

Both subject and comment above says "On Gen3", but the code looks like
it implements "On Gen3 or newer" - due to use of ">=".
Looks wrong to me.

	Sam
Laurent Pinchart May 28, 2019, 4:50 p.m. UTC | #2
Hi Sam,

On Tue, May 28, 2019 at 06:42:13PM +0200, Sam Ravnborg wrote:
> On Tue, May 28, 2019 at 05:12:31PM +0300, Laurent Pinchart wrote:
> > In dual-link LVDS mode, the LVDS1 encoder is used as a companion for
> > LVDS0, and both encoders transmit data from DU0. The LVDS1 output of DU1
> > can't be used in that case, don't create an encoder and connector for
> > it.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > ---
> > Changess since v2:
> > 
> > - Remove unneeded bridge NULL check
> > ---
> >  drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 12 ++++++++++++
> >  drivers/gpu/drm/rcar-du/rcar_du_kms.c     |  2 +-
> >  2 files changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> > index 6c91753af7bc..0f00bdfe2366 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> > @@ -16,6 +16,7 @@
> >  #include "rcar_du_drv.h"
> >  #include "rcar_du_encoder.h"
> >  #include "rcar_du_kms.h"
> > +#include "rcar_lvds.h"
> >  
> >  /* -----------------------------------------------------------------------------
> >   * Encoder
> > @@ -97,6 +98,17 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> >  		}
> >  	}
> >  
> > +	/*
> > +	 * On Gen3 skip the LVDS1 output if the LVDS1 encoder is used as a
> > +	 * companion for LVDS0 in dual-link mode.
> > +	 */
> > +	if (rcdu->info->gen >= 3 && output == RCAR_DU_OUTPUT_LVDS1) {
> 
> Both subject and comment above says "On Gen3", but the code looks like
> it implements "On Gen3 or newer" - due to use of ">=".
> Looks wrong to me.

Gen3 is the newest generation :-) We thus use >= through the DU and LVDS
drivers to prepare for support of Gen4, just in case.
Sam Ravnborg May 28, 2019, 5:02 p.m. UTC | #3
Hi Laurent.

On Tue, May 28, 2019 at 07:50:52PM +0300, Laurent Pinchart wrote:
> Hi Sam,
> 
> On Tue, May 28, 2019 at 06:42:13PM +0200, Sam Ravnborg wrote:
> > On Tue, May 28, 2019 at 05:12:31PM +0300, Laurent Pinchart wrote:
> > > In dual-link LVDS mode, the LVDS1 encoder is used as a companion for
> > > LVDS0, and both encoders transmit data from DU0. The LVDS1 output of DU1
> > > can't be used in that case, don't create an encoder and connector for
> > > it.
> > > 
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > > Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > > ---
> > > Changess since v2:
> > > 
> > > - Remove unneeded bridge NULL check
> > > ---
> > >  drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 12 ++++++++++++
> > >  drivers/gpu/drm/rcar-du/rcar_du_kms.c     |  2 +-
> > >  2 files changed, 13 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> > > index 6c91753af7bc..0f00bdfe2366 100644
> > > --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> > > +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> > > @@ -16,6 +16,7 @@
> > >  #include "rcar_du_drv.h"
> > >  #include "rcar_du_encoder.h"
> > >  #include "rcar_du_kms.h"
> > > +#include "rcar_lvds.h"
> > >  
> > >  /* -----------------------------------------------------------------------------
> > >   * Encoder
> > > @@ -97,6 +98,17 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> > >  		}
> > >  	}
> > >  
> > > +	/*
> > > +	 * On Gen3 skip the LVDS1 output if the LVDS1 encoder is used as a
> > > +	 * companion for LVDS0 in dual-link mode.
> > > +	 */
> > > +	if (rcdu->info->gen >= 3 && output == RCAR_DU_OUTPUT_LVDS1) {
> > 
> > Both subject and comment above says "On Gen3", but the code looks like
> > it implements "On Gen3 or newer" - due to use of ">=".
> > Looks wrong to me.
> 
> Gen3 is the newest generation :-) We thus use >= through the DU and LVDS
> drivers to prepare for support of Gen4, just in case.
OK, but I guess we agree that the comment needs a small update them.

Actually I implicitly reads that it is only from Gen3 onwards that the
LVDS1 encoder can be used as a companion.
My initial understanding reading the comment was that this implmented a
workaround for Gen3 - but it is a workarounf for missing features in
older than Gen3.
So, assuming this is correct, when trying to specify a companion on
older then Gen3 should result in some kind of error/warning?
(Maybe it does).

	Sam
Laurent Pinchart June 6, 2019, 7:57 a.m. UTC | #4
Hi Sam,

On Tue, May 28, 2019 at 07:02:42PM +0200, Sam Ravnborg wrote:
> On Tue, May 28, 2019 at 07:50:52PM +0300, Laurent Pinchart wrote:
> > On Tue, May 28, 2019 at 06:42:13PM +0200, Sam Ravnborg wrote:
> >> On Tue, May 28, 2019 at 05:12:31PM +0300, Laurent Pinchart wrote:
> >>> In dual-link LVDS mode, the LVDS1 encoder is used as a companion for
> >>> LVDS0, and both encoders transmit data from DU0. The LVDS1 output of DU1
> >>> can't be used in that case, don't create an encoder and connector for
> >>> it.
> >>> 
> >>> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> >>> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> >>> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> >>> ---
> >>> Changess since v2:
> >>> 
> >>> - Remove unneeded bridge NULL check
> >>> ---
> >>>  drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 12 ++++++++++++
> >>>  drivers/gpu/drm/rcar-du/rcar_du_kms.c     |  2 +-
> >>>  2 files changed, 13 insertions(+), 1 deletion(-)
> >>> 
> >>> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> >>> index 6c91753af7bc..0f00bdfe2366 100644
> >>> --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> >>> +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> >>> @@ -16,6 +16,7 @@
> >>>  #include "rcar_du_drv.h"
> >>>  #include "rcar_du_encoder.h"
> >>>  #include "rcar_du_kms.h"
> >>> +#include "rcar_lvds.h"
> >>>  
> >>>  /* -----------------------------------------------------------------------------
> >>>   * Encoder
> >>> @@ -97,6 +98,17 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
> >>>  		}
> >>>  	}
> >>>  
> >>> +	/*
> >>> +	 * On Gen3 skip the LVDS1 output if the LVDS1 encoder is used as a
> >>> +	 * companion for LVDS0 in dual-link mode.
> >>> +	 */
> >>> +	if (rcdu->info->gen >= 3 && output == RCAR_DU_OUTPUT_LVDS1) {
> >> 
> >> Both subject and comment above says "On Gen3", but the code looks like
> >> it implements "On Gen3 or newer" - due to use of ">=".
> >> Looks wrong to me.
> > 
> > Gen3 is the newest generation :-) We thus use >= through the DU and LVDS
> > drivers to prepare for support of Gen4, just in case.
>
> OK, but I guess we agree that the comment needs a small update them.
> 
> Actually I implicitly reads that it is only from Gen3 onwards that the
> LVDS1 encoder can be used as a companion.
> My initial understanding reading the comment was that this implmented a
> workaround for Gen3 - but it is a workarounf for missing features in
> older than Gen3.

I wouldn't say workaround, it just makes sure that we don't try to
support LVDS dual-mode on older SoCs as the feature was added in Gen3
hardware.

> So, assuming this is correct, when trying to specify a companion on
> older then Gen3 should result in some kind of error/warning?
> (Maybe it does).

The property is ignored in that case. I could add an error message, but
I'm not sure I should, as we don't usually check that DT nodes don't
contain any other property than the ones specified in the DT bindings
(an automatic DT runtime validator based on the YAML bindings could be
interesting ;-)).
Sam Ravnborg June 6, 2019, 9:29 a.m. UTC | #5
Hi Laurent.

> > > Gen3 is the newest generation :-) We thus use >= through the DU and LVDS
> > > drivers to prepare for support of Gen4, just in case.
> >
> > OK, but I guess we agree that the comment needs a small update them.
> > 
> > Actually I implicitly reads that it is only from Gen3 onwards that the
> > LVDS1 encoder can be used as a companion.
> > My initial understanding reading the comment was that this implmented a
> > workaround for Gen3 - but it is a workarounf for missing features in
> > older than Gen3.
> 
> I wouldn't say workaround, it just makes sure that we don't try to
> support LVDS dual-mode on older SoCs as the feature was added in Gen3
> hardware.
> 
> > So, assuming this is correct, when trying to specify a companion on
> > older then Gen3 should result in some kind of error/warning?
> > (Maybe it does).
> 
> The property is ignored in that case. I could add an error message, but
> I'm not sure I should, as we don't usually check that DT nodes don't
> contain any other property than the ones specified in the DT bindings
> (an automatic DT runtime validator based on the YAML bindings could be
> interesting ;-)).
Again, thanks for taking your time.
This clarifies it nicely.

	Sam
Kieran Bingham June 7, 2019, 11:19 p.m. UTC | #6
Hi Laurent,

On 28/05/2019 15:12, Laurent Pinchart wrote:
> In dual-link LVDS mode, the LVDS1 encoder is used as a companion for
> LVDS0, and both encoders transmit data from DU0. The LVDS1 output of DU1
> can't be used in that case, don't create an encoder and connector for
> it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

And finally, Last one...

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> ---
> Changess since v2:
> 
> - Remove unneeded bridge NULL check
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 12 ++++++++++++
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c     |  2 +-
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> index 6c91753af7bc..0f00bdfe2366 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
> @@ -16,6 +16,7 @@
>  #include "rcar_du_drv.h"
>  #include "rcar_du_encoder.h"
>  #include "rcar_du_kms.h"
> +#include "rcar_lvds.h"
>  
>  /* -----------------------------------------------------------------------------
>   * Encoder
> @@ -97,6 +98,17 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
>  		}
>  	}
>  
> +	/*
> +	 * On Gen3 skip the LVDS1 output if the LVDS1 encoder is used as a
> +	 * companion for LVDS0 in dual-link mode.
> +	 */
> +	if (rcdu->info->gen >= 3 && output == RCAR_DU_OUTPUT_LVDS1) {
> +		if (rcar_lvds_dual_link(bridge)) {
> +			ret = -ENOLINK;
> +			goto done;
> +		}
> +	}
> +
>  	ret = drm_encoder_init(rcdu->ddev, encoder, &encoder_funcs,
>  			       DRM_MODE_ENCODER_NONE, NULL);
>  	if (ret < 0)
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> index f8f7fff34dff..95c81e59e2f1 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -378,7 +378,7 @@ static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu,
>  	}
>  
>  	ret = rcar_du_encoder_init(rcdu, output, entity);
> -	if (ret && ret != -EPROBE_DEFER)
> +	if (ret && ret != -EPROBE_DEFER && ret != -ENOLINK)
>  		dev_warn(rcdu->dev,
>  			 "failed to initialize encoder %pOF on output %u (%d), skipping\n",
>  			 entity, output, ret);
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
index 6c91753af7bc..0f00bdfe2366 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c
@@ -16,6 +16,7 @@ 
 #include "rcar_du_drv.h"
 #include "rcar_du_encoder.h"
 #include "rcar_du_kms.h"
+#include "rcar_lvds.h"
 
 /* -----------------------------------------------------------------------------
  * Encoder
@@ -97,6 +98,17 @@  int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 		}
 	}
 
+	/*
+	 * On Gen3 skip the LVDS1 output if the LVDS1 encoder is used as a
+	 * companion for LVDS0 in dual-link mode.
+	 */
+	if (rcdu->info->gen >= 3 && output == RCAR_DU_OUTPUT_LVDS1) {
+		if (rcar_lvds_dual_link(bridge)) {
+			ret = -ENOLINK;
+			goto done;
+		}
+	}
+
 	ret = drm_encoder_init(rcdu->ddev, encoder, &encoder_funcs,
 			       DRM_MODE_ENCODER_NONE, NULL);
 	if (ret < 0)
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index f8f7fff34dff..95c81e59e2f1 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -378,7 +378,7 @@  static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu,
 	}
 
 	ret = rcar_du_encoder_init(rcdu, output, entity);
-	if (ret && ret != -EPROBE_DEFER)
+	if (ret && ret != -EPROBE_DEFER && ret != -ENOLINK)
 		dev_warn(rcdu->dev,
 			 "failed to initialize encoder %pOF on output %u (%d), skipping\n",
 			 entity, output, ret);