Justin Vreeland 794d92
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Justin Vreeland 794d92
From: Icenowy Zheng <icenowy@aosc.io>
Justin Vreeland 794d92
Date: Mon, 16 Mar 2020 21:35:02 +0800
Justin Vreeland 794d92
Subject: [PATCH] drm/sun4i: sun6i_mipi_dsi: fix horizontal timing calculation
Justin Vreeland 794d92
Justin Vreeland 794d92
The max() function call in horizontal timing calculation shouldn't pad a
Justin Vreeland 794d92
length already subtracted with overhead to overhead, instead it should
Justin Vreeland 794d92
only prevent the set timing to underflow.
Justin Vreeland 794d92
Justin Vreeland 794d92
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Justin Vreeland 794d92
---
Justin Vreeland 794d92
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 10 +++++-----
Justin Vreeland 794d92
 1 file changed, 5 insertions(+), 5 deletions(-)
Justin Vreeland 794d92
Justin Vreeland 794d92
diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
Justin Vreeland 794d92
index aa67cb037e9d..52e009dc632b 100644
Justin Vreeland 794d92
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
Justin Vreeland 794d92
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
Justin Vreeland 794d92
@@ -556,7 +556,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
Justin Vreeland 794d92
 		 */
Justin Vreeland 794d92
 #define HSA_PACKET_OVERHEAD	10
Justin Vreeland 794d92
 		hsa = max((unsigned int)HSA_PACKET_OVERHEAD,
Justin Vreeland 794d92
-			  (mode->hsync_end - mode->hsync_start) * Bpp - HSA_PACKET_OVERHEAD);
Justin Vreeland 794d92
+			  (mode->hsync_end - mode->hsync_start) * Bpp) - HSA_PACKET_OVERHEAD;
Justin Vreeland 794d92
Justin Vreeland 794d92
 		/*
Justin Vreeland 794d92
 		 * The backporch is set using a blanking packet (4
Justin Vreeland 794d92
@@ -565,7 +565,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
Justin Vreeland 794d92
 		 */
Justin Vreeland 794d92
 #define HBP_PACKET_OVERHEAD	6
Justin Vreeland 794d92
 		hbp = max((unsigned int)HBP_PACKET_OVERHEAD,
Justin Vreeland 794d92
-			  (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD);
Justin Vreeland 794d92
+			  (mode->htotal - mode->hsync_end) * Bpp) - HBP_PACKET_OVERHEAD;
Justin Vreeland 794d92
Justin Vreeland 794d92
 		/*
Justin Vreeland 794d92
 		 * The frontporch is set using a sync event (4 bytes)
Justin Vreeland 794d92
@@ -575,7 +575,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
Justin Vreeland 794d92
 		 */
Justin Vreeland 794d92
 #define HFP_PACKET_OVERHEAD	16
Justin Vreeland 794d92
 		hfp = max((unsigned int)HFP_PACKET_OVERHEAD,
Justin Vreeland 794d92
-			  (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD);
Justin Vreeland 794d92
+			  (mode->hsync_start - mode->hdisplay) * Bpp) - HFP_PACKET_OVERHEAD;
Justin Vreeland 794d92
Justin Vreeland 794d92
 		/*
Justin Vreeland 794d92
 		 * The blanking is set using a sync event (4 bytes)
Justin Vreeland 794d92
@@ -584,8 +584,8 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
Justin Vreeland 794d92
 		 */
Justin Vreeland 794d92
 #define HBLK_PACKET_OVERHEAD	10
Justin Vreeland 794d92
 		hblk = max((unsigned int)HBLK_PACKET_OVERHEAD,
Justin Vreeland 794d92
-			   (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp -
Justin Vreeland 794d92
-			   HBLK_PACKET_OVERHEAD);
Justin Vreeland 794d92
+			   (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp) -
Justin Vreeland 794d92
+			   HBLK_PACKET_OVERHEAD;
Justin Vreeland 794d92
Justin Vreeland 794d92
 		/*
Justin Vreeland 794d92
 		 * And I'm not entirely sure what vblk is about. The driver in
Justin Vreeland 794d92
-- 
Justin Vreeland 794d92
2.28.0
Justin Vreeland 794d92