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