Re: [PATCH 7/7] drm/vc4: dpi: Fix format mapping for RGB565

From: Laurent Pinchart
Date: Sat Oct 15 2022 - 13:19:37 EST


Hi Maxime and Dave,

Thank you for the patch.

On Thu, Oct 13, 2022 at 11:56:51AM +0200, Maxime Ripard wrote:
> From: Dave Stevenson <dave.stevenson@xxxxxxxxxxxxxxx>
>
> The mapping is incorrect for RGB565_1X16 as it should be
> DPI_FORMAT_18BIT_666_RGB_1 instead of DPI_FORMAT_18BIT_666_RGB_3.

The driver includes the following macro definitions and comments:

/* Outputs 00000000rrrrrggggggbbbbb */
# define DPI_FORMAT_16BIT_565_RGB_1 1
/* Outputs 000rrrrr00gggggg000bbbbb */
# define DPI_FORMAT_16BIT_565_RGB_2 2
/* Outputs 00rrrrr000gggggg00bbbbb0 */
# define DPI_FORMAT_16BIT_565_RGB_3 3

MEDIA_BUS_FMT_RGB565_1X16 is defined as described in
https://linuxtv.org/downloads/v4l-dvb-apis/userspace-api/v4l/subdev-formats.html#id3:

Bit | 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Data | r4 r3 r2 r1 r0 g5 g4 g3 g2 g1 g0 b4 b3 b2 b1 b0

This seems to match DPI_FORMAT_16BIT_565_RGB_1 indeed.

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

> Fixes: 08302c35b59d ("drm/vc4: Add DPI driver")
> Signed-off-by: Dave Stevenson <dave.stevenson@xxxxxxxxxxxxxxx>
> Signed-off-by: Maxime Ripard <maxime@xxxxxxxxxx>
> ---
> drivers/gpu/drm/vc4/vc4_dpi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
> index fdae02760b6d..a7bebfa5d5b0 100644
> --- a/drivers/gpu/drm/vc4/vc4_dpi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
> @@ -185,7 +185,7 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
> DPI_FORMAT);
> break;
> case MEDIA_BUS_FMT_RGB565_1X16:
> - dpi_c |= VC4_SET_FIELD(DPI_FORMAT_16BIT_565_RGB_3,
> + dpi_c |= VC4_SET_FIELD(DPI_FORMAT_16BIT_565_RGB_1,
> DPI_FORMAT);
> break;
> case MEDIA_BUS_FMT_RGB565_1X24_CPADHI:
>

--
Regards,

Laurent Pinchart