[5/7] drm/vc4: dpi: Support BGR666 formats

Message ID 20221013-rpi-dpi-improvements-v1-5-8a7a96949cb0@cerno.tech
State New
Headers
Series drm/vc4: dpi: Various improvements |

Commit Message

Maxime Ripard Oct. 13, 2022, 9:56 a.m. UTC
  From: Joerg Quinten <aBUGSworstnightmare@gmail.com>

The VC4 DPI output can support multiple BGR666 variants, but they were
never added to the driver. Let's add the the support for those formats.

Signed-off-by: Joerg Quinten <aBUGSworstnightmare@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/gpu/drm/vc4/vc4_dpi.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Laurent Pinchart Oct. 15, 2022, 5:26 p.m. UTC | #1
Hi Maxime and Joerg,

Thank you for the patch.

On Thu, Oct 13, 2022 at 11:56:49AM +0200, Maxime Ripard wrote:
> From: Joerg Quinten <aBUGSworstnightmare@gmail.com>
> 
> The VC4 DPI output can support multiple BGR666 variants, but they were
> never added to the driver. Let's add the the support for those formats.
> 
> Signed-off-by: Joerg Quinten <aBUGSworstnightmare@gmail.com>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/vc4/vc4_dpi.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
> index 7da3dd1db50e..ecbe4cd87036 100644
> --- a/drivers/gpu/drm/vc4/vc4_dpi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
> @@ -170,10 +170,16 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
>  				dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR,
>  						       DPI_ORDER);
>  				break;
> +			case MEDIA_BUS_FMT_BGR666_1X24_CPADHI:
> +				dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
> +				fallthrough;
>  			case MEDIA_BUS_FMT_RGB666_1X24_CPADHI:
>  				dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_2,
>  						       DPI_FORMAT);
>  				break;
> +			case MEDIA_BUS_FMT_BGR666_1X18:
> +				dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
> +				fallthrough;
>  			case MEDIA_BUS_FMT_RGB666_1X18:
>  				dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_1,
>  						       DPI_FORMAT);
>
  
Laurent Pinchart Oct. 15, 2022, 5:30 p.m. UTC | #2
On Sat, Oct 15, 2022 at 08:26:48PM +0300, Laurent Pinchart wrote:
> Hi Maxime and Joerg,
> 
> Thank you for the patch.
> 
> On Thu, Oct 13, 2022 at 11:56:49AM +0200, Maxime Ripard wrote:
> > From: Joerg Quinten <aBUGSworstnightmare@gmail.com>
> > 
> > The VC4 DPI output can support multiple BGR666 variants, but they were
> > never added to the driver. Let's add the the support for those formats.
> > 
> > Signed-off-by: Joerg Quinten <aBUGSworstnightmare@gmail.com>
> > Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> > ---
> >  drivers/gpu/drm/vc4/vc4_dpi.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
> > index 7da3dd1db50e..ecbe4cd87036 100644
> > --- a/drivers/gpu/drm/vc4/vc4_dpi.c
> > +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
> > @@ -170,10 +170,16 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
> >  				dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR,
> >  						       DPI_ORDER);
> >  				break;
> > +			case MEDIA_BUS_FMT_BGR666_1X24_CPADHI:
> > +				dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
> > +				fallthrough;

Upon closer inspection of the code, I think you also need

-			dpi_c &= ~DPI_FORMAT_MASK;
+			dpi_c &= ~(DPI_ORDER_MASK | DPI_FORMAT_MASK);

a few lines above.

> >  			case MEDIA_BUS_FMT_RGB666_1X24_CPADHI:
> >  				dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_2,
> >  						       DPI_FORMAT);
> >  				break;
> > +			case MEDIA_BUS_FMT_BGR666_1X18:
> > +				dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
> > +				fallthrough;
> >  			case MEDIA_BUS_FMT_RGB666_1X18:
> >  				dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_1,
> >  						       DPI_FORMAT);
> >
  
Dave Stevenson Oct. 17, 2022, 5:26 p.m. UTC | #3
Hi Laurent

Thanks for the review.

On Sat, 15 Oct 2022 at 18:31, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> On Sat, Oct 15, 2022 at 08:26:48PM +0300, Laurent Pinchart wrote:
> > Hi Maxime and Joerg,
> >
> > Thank you for the patch.
> >
> > On Thu, Oct 13, 2022 at 11:56:49AM +0200, Maxime Ripard wrote:
> > > From: Joerg Quinten <aBUGSworstnightmare@gmail.com>
> > >
> > > The VC4 DPI output can support multiple BGR666 variants, but they were
> > > never added to the driver. Let's add the the support for those formats.
> > >
> > > Signed-off-by: Joerg Quinten <aBUGSworstnightmare@gmail.com>
> > > Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> >
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >
> > > ---
> > >  drivers/gpu/drm/vc4/vc4_dpi.c | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
> > > index 7da3dd1db50e..ecbe4cd87036 100644
> > > --- a/drivers/gpu/drm/vc4/vc4_dpi.c
> > > +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
> > > @@ -170,10 +170,16 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
> > >                             dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR,
> > >                                                    DPI_ORDER);
> > >                             break;
> > > +                   case MEDIA_BUS_FMT_BGR666_1X24_CPADHI:
> > > +                           dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
> > > +                           fallthrough;
>
> Upon closer inspection of the code, I think you also need
>
> -                       dpi_c &= ~DPI_FORMAT_MASK;
> +                       dpi_c &= ~(DPI_ORDER_MASK | DPI_FORMAT_MASK);
>
> a few lines above.

Hmm, curious as there appears to be a difference between our vendor
tree and mainline in the contents of a patch with almost the same
commit text.

https://github.com/torvalds/linux/commit/7a70b0b97889a89f397913c971cadfc6db9b310a
vs https://github.com/raspberrypi/linux/commit/9d9dc236a9ee9021363b8601b6188e7be86d1971

Our tree leaves dpi_c effectively clear, and selects the default at
the end. Mainline sets the default first.


Even so, dpi_c gets initialised with
dpi_c = DPI_ENABLE;
dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT);
dpi_c &= ~DPI_FORMAT_MASK;
so at this point in the switch, the DPI_ORDER bits haven't changed
from the default of 0.

  Dave

> > >                     case MEDIA_BUS_FMT_RGB666_1X24_CPADHI:
> > >                             dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_2,
> > >                                                    DPI_FORMAT);
> > >                             break;
> > > +                   case MEDIA_BUS_FMT_BGR666_1X18:
> > > +                           dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
> > > +                           fallthrough;
> > >                     case MEDIA_BUS_FMT_RGB666_1X18:
> > >                             dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_1,
> > >                                                    DPI_FORMAT);
> > >
>
> --
> Regards,
>
> Laurent Pinchart
  

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index 7da3dd1db50e..ecbe4cd87036 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -170,10 +170,16 @@  static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
 				dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR,
 						       DPI_ORDER);
 				break;
+			case MEDIA_BUS_FMT_BGR666_1X24_CPADHI:
+				dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
+				fallthrough;
 			case MEDIA_BUS_FMT_RGB666_1X24_CPADHI:
 				dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_2,
 						       DPI_FORMAT);
 				break;
+			case MEDIA_BUS_FMT_BGR666_1X18:
+				dpi_c |= VC4_SET_FIELD(DPI_ORDER_BGR, DPI_ORDER);
+				fallthrough;
 			case MEDIA_BUS_FMT_RGB666_1X18:
 				dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_1,
 						       DPI_FORMAT);