Introduce TXVMVPRMSET0R_BPP_MASK macro and use FIELD_PREP() to generate
appropriate bitfield from mask and value without bitshift, assign this
value into vprmset0r. Remove TXVMVPRMSET0R_CSPC_RGB which is never used,
replace it with code comment next to TXVMVPRMSET0R_CSPC_YCbCr.

Replace (mode->flags & DRM_MODE_FLAG_P.SYNC) test with inverted conditional
(mode->flags & DRM_MODE_FLAG_N.SYNC) and bitwise orr vprmset0r with either
or both TXVMVPRMSET0R_HSPOL_LOW and TXVMVPRMSET0R_VSPOL_LOW if conditional
matches.

Do not convert bits and bitfields to BIT() and GENMASK() yet, to be
consisten with the current style. Conversion to BIT() and GENMASK()
macros is done at the very end of this series in the last two patches.

Reviewed-by: Tomi Valkeinen <[email protected]>
Signed-off-by: Marek Vasut <[email protected]>
---
Cc: David Airlie <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Kieran Bingham <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Magnus Damm <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: Tomi Valkeinen <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
NOTE: No functional change expected, this is a preparatory patch which
partly removes macros which evaluate to zeroes from rcar_mipi_dsi_regs.h .
The other patches in this series proceed with that job, piece by piece,
to make it all reviewable.
---
V2: Move FIELD_PREP() back into rcar_mipi_dsi_regs.h
V3: No change
V4: Add RB from Tomi
---
 drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c  | 12 ++++++------
 .../gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h | 16 +++++++---------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c 
b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
index 78e512de7cf96..9413b76d0bfce 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi.c
@@ -490,12 +490,12 @@ static void rcar_mipi_dsi_set_display_timing(struct 
rcar_mipi_dsi *dsi,
 
        rcar_mipi_dsi_write(dsi, TXVMSETR, setr);
 
-       /* Configuration for Video Parameters */
-       vprmset0r = (mode->flags & DRM_MODE_FLAG_PVSYNC ?
-                    TXVMVPRMSET0R_VSPOL_HIG : TXVMVPRMSET0R_VSPOL_LOW)
-                 | (mode->flags & DRM_MODE_FLAG_PHSYNC ?
-                    TXVMVPRMSET0R_HSPOL_HIG : TXVMVPRMSET0R_HSPOL_LOW)
-                 | TXVMVPRMSET0R_CSPC_RGB | TXVMVPRMSET0R_BPP_24;
+       /* Configuration for Video Parameters, input is always RGB888 */
+       vprmset0r = TXVMVPRMSET0R_BPP_24;
+       if (mode->flags & DRM_MODE_FLAG_NVSYNC)
+               vprmset0r |= TXVMVPRMSET0R_VSPOL_LOW;
+       if (mode->flags & DRM_MODE_FLAG_NHSYNC)
+               vprmset0r |= TXVMVPRMSET0R_HSPOL_LOW;
 
        vprmset1r = TXVMVPRMSET1R_VACTIVE(mode->vdisplay)
                  | TXVMVPRMSET1R_VSA(mode->vsync_end - mode->vsync_start);
diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h 
b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h
index 75b0ae207a640..88ed427f6dd2e 100644
--- a/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h
+++ b/drivers/gpu/drm/renesas/rcar-du/rcar_mipi_dsi_regs.h
@@ -171,15 +171,13 @@
 #define TXVMPSPHSETR_DT_YCBCR16                
FIELD_PREP(TXVMPSPHSETR_DT_MASK, 0x2c)
 
 #define TXVMVPRMSET0R                  0x1d0
-#define TXVMVPRMSET0R_HSPOL_HIG                (0 << 17)
-#define TXVMVPRMSET0R_HSPOL_LOW                (1 << 17)
-#define TXVMVPRMSET0R_VSPOL_HIG                (0 << 16)
-#define TXVMVPRMSET0R_VSPOL_LOW                (1 << 16)
-#define TXVMVPRMSET0R_CSPC_RGB         (0 << 4)
-#define TXVMVPRMSET0R_CSPC_YCbCr       (1 << 4)
-#define TXVMVPRMSET0R_BPP_16           (0 << 0)
-#define TXVMVPRMSET0R_BPP_18           (1 << 0)
-#define TXVMVPRMSET0R_BPP_24           (2 << 0)
+#define TXVMVPRMSET0R_HSPOL_LOW                (1 << 17) /* 0:High 1:Low */
+#define TXVMVPRMSET0R_VSPOL_LOW                (1 << 16) /* 0:High 1:Low */
+#define TXVMVPRMSET0R_CSPC_YCbCr       (1 << 4) /* 0:RGB 1:YCbCr */
+#define TXVMVPRMSET0R_BPP_MASK         (7 << 0)
+#define TXVMVPRMSET0R_BPP_16           FIELD_PREP(TXVMVPRMSET0R_BPP_MASK, 0)
+#define TXVMVPRMSET0R_BPP_18           FIELD_PREP(TXVMVPRMSET0R_BPP_MASK, 1)
+#define TXVMVPRMSET0R_BPP_24           FIELD_PREP(TXVMVPRMSET0R_BPP_MASK, 2)
 
 #define TXVMVPRMSET1R                  0x1d4
 #define TXVMVPRMSET1R_VACTIVE(x)       (((x) & 0x7fff) << 16)
-- 
2.51.0

Reply via email to