From 7c145d68717d2b1ee522f2709a1964fd9370da67 Mon Sep 17 00:00:00 2001
From: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
Date: Mon, 29 Apr 2024 14:54:49 +0100
Subject: [PATCH 1074/1085] drm: rp1: dpi: Add support for
 MEDIA_BUS_FMT_RGB565_1X24_CPADHI

This new format corresponds to the Raspberry Pi legacy DPI mode 3.

Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
---
 drivers/gpu/drm/rp1/rp1-dpi/rp1_dpi_hw.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/rp1/rp1-dpi/rp1_dpi_hw.c
+++ b/drivers/gpu/drm/rp1/rp1-dpi/rp1_dpi_hw.c
@@ -319,8 +319,14 @@ static u32 set_output_format(u32 bus_for
 		*shift |= OSHIFT_RGB(29, 19, 9);
 		return OMASK_RGB(0x3fc, 0x3fc, 0x3fc);
 
+	case MEDIA_BUS_FMT_RGB565_1X24_CPADHI:
+		/* This should match Raspberry Pi legacy "mode 3" */
+		*shift |= OSHIFT_RGB(26, 17, 6);
+		*rgbsz &= DPI_DMA_RGBSZ_BPP_MASK;
+		return OMASK_RGB(0x3e0, 0x3f0, 0x3e0);
+
 	default:
-		/* RGB666_1x24_CPADHI, BGR666_1X24_CPADHI and "RGB565_666" formats */
+		/* RGB666_1x24_CPADHI, BGR666_1X24_CPADHI and "mode 4" formats */
 		*shift |= OSHIFT_RGB(27, 17, 7);
 		*rgbsz &= DPI_DMA_RGBSZ_BPP_MASK;
 		return OMASK_RGB(0x3f0, 0x3f0, 0x3f0);
