drm/mediatek: dsi: Modify horizontal front/back porch byte formula
Subsystems (3)
Chun-Kuang Hu
maintainerPATCH 1/1 drm/mediatek: dsi: Modify horizontal front/back porch byte formula
From: CK Hu <[email protected]>
In the patch to be fixed, horizontal_backporch_byte become to large for some panel, so roll back that patch. For small hfp or hbp panel, using vm->hfront_porch + vm->hback_porch to calculate horizontal_backporch_byte would make it negtive, so
use horizontal_backporch_byte itself to make it positive.
--- drivers/gpu/drm/mediatek/mtk_dsi.c | 61 +++++++++++------------------- 1 file changed, 22 insertions(+), 39 deletions(-)
drivers/gpu/drm/mediatek/mtk_dsi.c +22 -39
@@ -444,7 +444,10 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)u32 horizontal_sync_active_byte;u32 horizontal_backporch_byte;u32 horizontal_frontporch_byte; +u32 horizontal_front_back_byte; +u32 data_phy_cycles_byte;u32 dsi_tmp_buf_bpp, data_phy_cycles; +u32 delta;struct mtk_phy_timing *timing = &dsi->phy_timing;struct videomode *vm = &dsi->vm;
@@ -466,50 +469,30 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) horizontal_sync_active_byte = (vm->hsync_len * dsi_tmp_buf_bpp -10 );if (dsi->mode_flags &MIPI_DSI_MODE_VIDEO_SYNC_PULSE ) - horizontal_backporch_byte = vm->hback_porch * dsi_tmp_buf_bpp; + horizontal_backporch_byte = vm->hback_porch * dsi_tmp_buf_bpp -10 ;else horizontal_backporch_byte = (vm->hback_porch + vm->hsync_len) * - dsi_tmp_buf_bpp; + dsi_tmp_buf_bpp -10 ; data_phy_cycles = timing->lpx + timing->da_hs_prepare + - timing->da_hs_zero + timing->da_hs_exit; - -if (dsi->mode_flags &MIPI_DSI_MODE_VIDEO_BURST ) { -if ((vm->hfront_porch + vm->hback_porch) * dsi_tmp_buf_bpp > - data_phy_cycles * dsi->lanes +18 ) { - horizontal_frontporch_byte = - vm->hfront_porch * dsi_tmp_buf_bpp - - (data_phy_cycles * dsi->lanes +18 ) * - vm->hfront_porch / - (vm->hfront_porch + vm->hback_porch); - - horizontal_backporch_byte = - horizontal_backporch_byte - - (data_phy_cycles * dsi->lanes +18 ) * - vm->hback_porch / - (vm->hfront_porch + vm->hback_porch); - }else { -DRM_WARN ("HFP less than d-phy, FPS will under 60Hz\n" ); - horizontal_frontporch_byte = vm->hfront_porch * - dsi_tmp_buf_bpp; - } + timing->da_hs_zero + timing->da_hs_exit +3 ; + + delta = dsi->mode_flags &MIPI_DSI_MODE_VIDEO_BURST ?18 :12 ; + + horizontal_frontporch_byte = vm->hfront_porch * dsi_tmp_buf_bpp; + horizontal_front_back_byte = horizontal_frontporch_byte + horizontal_backporch_byte; + data_phy_cycles_byte = data_phy_cycles * dsi->lanes + delta; + +if (horizontal_front_back_byte > data_phy_cycles_byte) { + horizontal_frontporch_byte -= data_phy_cycles_byte * + horizontal_frontporch_byte / + horizontal_front_back_byte; + + horizontal_backporch_byte -= data_phy_cycles_byte * + horizontal_backporch_byte / + horizontal_front_back_byte; }else { -if ((vm->hfront_porch + vm->hback_porch) * dsi_tmp_buf_bpp > - data_phy_cycles * dsi->lanes +12 ) { - horizontal_frontporch_byte = - vm->hfront_porch * dsi_tmp_buf_bpp - - (data_phy_cycles * dsi->lanes +12 ) * - vm->hfront_porch / - (vm->hfront_porch + vm->hback_porch); - horizontal_backporch_byte = horizontal_backporch_byte - - (data_phy_cycles * dsi->lanes +12 ) * - vm->hback_porch / - (vm->hfront_porch + vm->hback_porch); - }else { -DRM_WARN ("HFP less than d-phy, FPS will under 60Hz\n" ); - horizontal_frontporch_byte = vm->hfront_porch * - dsi_tmp_buf_bpp; - } +DRM_WARN ("HFP + HBP less than d-phy, FPS will under 60Hz\n" ); }writel (horizontal_sync_active_byte, dsi->regs +DSI_HSA_WC );
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi CK,
Quoted 115 lines · On Fri, 20 Nov 2020 07:23:35 +0800 Chun-Kuang Hu <[email protected]>…
From: CK Hu <[email protected]>
In the patch to be fixed,
horizontal_backporch_bytebecome to large for some panel, so roll back that patch. For small hfp or hbp panel, usingvm->hfront_porch+vm->hback_porchto calculatehorizontal_backporch_bytewould make it negtive, so
usehorizontal_backporch_byteitself to make it positive.Fixes 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of panel withsmall hfp or hbp")
Signed-off-by CK Hu <[email protected]>Signed-off-by Chun-Kuang Hu <[email protected]>--- drivers/gpu/drm/mediatek/mtk_dsi.c | 61+++++++++++------------------- 1 file changed, 22 insertions(+), 39 deletions(-)
(quoted diff) +0
-0
b/drivers/gpu/drm/mediatek/mtk_dsi.cindex4a188a942c38..65fd99c528af100644 ---a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++b/drivers/gpu/drm/mediatek/mtk_dsi.cdrivers/gpu/drm/mediatek/mtk_dsi.c +3
-0@@ -444,7 +444,10 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) u32 horizontal_sync_active_byte;u32 horizontal_backporch_byte;u32 horizontal_frontporch_byte; +u32 horizontal_front_back_byte; +u32 data_phy_cycles_byte;u32 dsi_tmp_buf_bpp, data_phy_cycles; +u32 delta;struct mtk_phy_timing *timing = &dsi->phy_timing;struct videomode *vm = &dsi->vm;@@ -466,50 +469,30 @@ static void mtk_dsi_config_vdo_timing(struct
mtk_dsi*dsi)horizontal_sync_active_byte= (vm->hsync_len*dsi_tmp_buf_bpp- 10);(quoted diff) +0
-1if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) - horizontal_backporch_byte = vm->hback_porch *
dsi_tmp_buf_bpp;(quoted diff) +1
-0+ horizontal_backporch_byte = vm->hback_porch *
dsi_tmp_buf_bpp- 10; else
horizontal_backporch_byte= (vm->hback_porch+vm->hsync_len) *drivers/gpu/drm/mediatek/mtk_dsi.c +1
-5- dsi_tmp_buf_bpp; + dsi_tmp_buf_bpp -10 ; data_phy_cycles = timing->lpx + timing->da_hs_prepare + - timing->da_hs_zero + timing->da_hs_exit; - -if (dsi->mode_flags &MIPI_DSI_MODE_VIDEO_BURST ) { - if ((vm->hfront_porch + vm->hback_porch) *
dsi_tmp_buf_bpp>drivers/gpu/drm/mediatek/mtk_dsi.c +0
-14- data_phy_cycles * dsi->lanes + 18) { - horizontal_frontporch_byte = - vm->hfront_porch * dsi_tmp_buf_bpp - - (data_phy_cycles * dsi->lanes +18 ) * - vm->hfront_porch / - (vm->hfront_porch + vm->hback_porch); - - horizontal_backporch_byte = - horizontal_backporch_byte - - (data_phy_cycles * dsi->lanes +18 ) * - vm->hback_porch / - (vm->hfront_porch + vm->hback_porch); - } else { - DRM_WARN("HFP less than d-phy, FPS willunder 60Hz\n");
(quoted diff) +0
-1- horizontal_frontporch_byte =
vm->hfront_porch*drivers/gpu/drm/mediatek/mtk_dsi.c +1
-2- dsi_tmp_buf_bpp; - } + timing->da_hs_zero + timing->da_hs_exit +3; +
(quoted diff) +1
-0+ delta = dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST ? 18 :12; +
(quoted diff) +1
-0+ horizontal_frontporch_byte = vm->hfront_porch *
dsi_tmp_buf_bpp;(quoted diff) +1
-0+ horizontal_front_back_byte = horizontal_frontporch_byte +
horizontal_backporch_byte;drivers/gpu/drm/mediatek/mtk_dsi.c +5
-0+ data_phy_cycles_byte = data_phy_cycles * dsi->lanes + delta; + +if (horizontal_front_back_byte > data_phy_cycles_byte) { + horizontal_frontporch_byte -= data_phy_cycles_byte * +
horizontal_frontporch_byte/
+horizontal_front_back_byte; +(quoted diff) +2
-0+ horizontal_backporch_byte -= data_phy_cycles_byte * +
horizontal_backporch_byte/
+horizontal_front_back_byte; } else {(quoted diff) +0
-1- if ((vm->hfront_porch + vm->hback_porch) *
dsi_tmp_buf_bpp>drivers/gpu/drm/mediatek/mtk_dsi.c +0
-7- data_phy_cycles * dsi->lanes + 12) { - horizontal_frontporch_byte = - vm->hfront_porch * dsi_tmp_buf_bpp - - (data_phy_cycles * dsi->lanes +12 ) * - vm->hfront_porch / - (vm->hfront_porch + vm->hback_porch); - horizontal_backporch_byte =
horizontal_backporch_byte-drivers/gpu/drm/mediatek/mtk_dsi.c +0
-5- (data_phy_cycles * dsi->lanes +12 ) * - vm->hback_porch / - (vm->hfront_porch + vm->hback_porch); - }else { - DRM_WARN("HFP less than d-phy, FPS willunder 60Hz\n");
(quoted diff) +0
-1- horizontal_frontporch_byte =
vm->hfront_porch*drivers/gpu/drm/mediatek/mtk_dsi.c +1
-2- dsi_tmp_buf_bpp; - } + DRM_WARN("HFP + HBP less than d-phy, FPS will under60Hz\n"); }
Quoted 1 line
writel(horizontal_sync_active_byte, dsi->regs + DSI_HSA_WC);
Tested on Chromebook ELM.
Thanks,
Bilal
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Bilal Wasim <[email protected]> 於 2020年11月20日 週五 上午8:30寫道:
Quoted 13 lines
Hi CK,
Quoted 7 lines · On Fri, 20 Nov 2020 07:23:35 +0800 Chun-Kuang Hu <[email protected]>…
From: CK Hu <[email protected]>
In the patch to be fixed,
horizontal_backporch_bytebecome to large for some panel, so roll back that patch. For small hfp or hbp panel, usingvm->hfront_porch+vm->hback_porchto calculatehorizontal_backporch_bytewould make it negtive, so
usehorizontal_backporch_byteitself to make it positive.
Applied to mediatek-drm-fixes [1].
[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-fixes
Quoted 108 lines
Quoted 108 lines
Fixes 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of panel withsmall hfp or hbp")
Signed-off-by CK Hu <[email protected]>Signed-off-by Chun-Kuang Hu <[email protected]>--- drivers/gpu/drm/mediatek/mtk_dsi.c | 61+++++++++++------------------- 1 file changed, 22 insertions(+), 39 deletions(-)
(quoted diff) +0
-0
b/drivers/gpu/drm/mediatek/mtk_dsi.cindex4a188a942c38..65fd99c528af100644 ---a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++b/drivers/gpu/drm/mediatek/mtk_dsi.cdrivers/gpu/drm/mediatek/mtk_dsi.c +3
-0@@ -444,7 +444,10 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) u32 horizontal_sync_active_byte;u32 horizontal_backporch_byte;u32 horizontal_frontporch_byte; +u32 horizontal_front_back_byte; +u32 data_phy_cycles_byte;u32 dsi_tmp_buf_bpp, data_phy_cycles; +u32 delta;struct mtk_phy_timing *timing = &dsi->phy_timing;struct videomode *vm = &dsi->vm;@@ -466,50 +469,30 @@ static void mtk_dsi_config_vdo_timing(struct
mtk_dsi*dsi)horizontal_sync_active_byte= (vm->hsync_len*dsi_tmp_buf_bpp - 10); if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)-
horizontal_backporch_byte=vm->hback_porch*dsi_tmp_buf_bpp;
+horizontal_backporch_byte=vm->hback_porch*dsi_tmp_buf_bpp- 10; elsehorizontal_backporch_byte = (vm->hback_porch +
vm->hsync_len) *drivers/gpu/drm/mediatek/mtk_dsi.c +1
-5- dsi_tmp_buf_bpp; + dsi_tmp_buf_bpp -10 ; data_phy_cycles = timing->lpx + timing->da_hs_prepare + - timing->da_hs_zero + timing->da_hs_exit; - -if (dsi->mode_flags &MIPI_DSI_MODE_VIDEO_BURST ) { - if ((vm->hfront_porch + vm->hback_porch) *
dsi_tmp_buf_bpp>drivers/gpu/drm/mediatek/mtk_dsi.c +0
-14- data_phy_cycles * dsi->lanes + 18) { - horizontal_frontporch_byte = - vm->hfront_porch * dsi_tmp_buf_bpp - - (data_phy_cycles * dsi->lanes +18 ) * - vm->hfront_porch / - (vm->hfront_porch + vm->hback_porch); - - horizontal_backporch_byte = - horizontal_backporch_byte - - (data_phy_cycles * dsi->lanes +18 ) * - vm->hback_porch / - (vm->hfront_porch + vm->hback_porch); - } else { - DRM_WARN("HFP less than d-phy, FPS willunder 60Hz\n");
-horizontal_frontporch_byte=vm->hfront_porch*drivers/gpu/drm/mediatek/mtk_dsi.c +1
-2- dsi_tmp_buf_bpp; - } + timing->da_hs_zero + timing->da_hs_exit +3; +
+ delta =dsi->mode_flags&MIPI_DSI_MODE_VIDEO_BURST? 18 :
12; +
+horizontal_frontporch_byte=vm->hfront_porch*dsi_tmp_buf_bpp;
+horizontal_front_back_byte=horizontal_frontporch_byte+horizontal_backporch_byte;drivers/gpu/drm/mediatek/mtk_dsi.c +5
-0+ data_phy_cycles_byte = data_phy_cycles * dsi->lanes + delta; + +if (horizontal_front_back_byte > data_phy_cycles_byte) { + horizontal_frontporch_byte -= data_phy_cycles_byte * +
horizontal_frontporch_byte/
+horizontal_front_back_byte; +(quoted diff) +2
-0+ horizontal_backporch_byte -= data_phy_cycles_byte * +
horizontal_backporch_byte/
+horizontal_front_back_byte; } else {
- if ((vm->hfront_porch+vm->hback_porch) *dsi_tmp_buf_bpp>drivers/gpu/drm/mediatek/mtk_dsi.c +0
-7- data_phy_cycles * dsi->lanes + 12) { - horizontal_frontporch_byte = - vm->hfront_porch * dsi_tmp_buf_bpp - - (data_phy_cycles * dsi->lanes +12 ) * - vm->hfront_porch / - (vm->hfront_porch + vm->hback_porch); - horizontal_backporch_byte =
horizontal_backporch_byte-drivers/gpu/drm/mediatek/mtk_dsi.c +0
-5- (data_phy_cycles * dsi->lanes +12 ) * - vm->hback_porch / - (vm->hfront_porch + vm->hback_porch); - }else { - DRM_WARN("HFP less than d-phy, FPS willunder 60Hz\n");
-horizontal_frontporch_byte=vm->hfront_porch*drivers/gpu/drm/mediatek/mtk_dsi.c +1
-2- dsi_tmp_buf_bpp; - } + DRM_WARN("HFP + HBP less than d-phy, FPS will under60Hz\n"); }
Quoted 8 lines
Quoted 1 line
writel(horizontal_sync_active_byte, dsi->regs + DSI_HSA_WC);Tested on Chromebook ELM.
Tested-by Bilal Wasim <[email protected]>Thanks,
Bilal
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel