linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself
@ 2020-11-15  0:14 Chun-Kuang Hu
  2020-11-15  0:53 ` Chun-Kuang Hu
  0 siblings, 1 reply; 8+ messages in thread
From: Chun-Kuang Hu @ 2020-11-15  0:14 UTC (permalink / raw)
  To: Jitao Shi, Bilal Wasim, Philipp Zabel, David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, linux-mediatek, CK Hu, Chun-Kuang Hu

From: CK Hu <ck.hu@mediatek.com>

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.

Fixes: 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of panel with small hfp or hbp")

Signed-off-by: CK Hu <ck.hu@mediatek.com>
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 53 ++++++++++--------------------
 1 file changed, 18 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 4a188a942c38..2a64fdaed9a7 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -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;
@@ -474,42 +477,22 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
 	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;
-		}
+	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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself
  2020-11-15  0:14 [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself Chun-Kuang Hu
@ 2020-11-15  0:53 ` Chun-Kuang Hu
  2020-11-15 19:25   ` Bilal Wasim
  0 siblings, 1 reply; 8+ messages in thread
From: Chun-Kuang Hu @ 2020-11-15  0:53 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: Jitao Shi, Bilal Wasim, Philipp Zabel, David Airlie,
	Daniel Vetter, linux-kernel, DRI Development,
	moderated list:ARM/Mediatek SoC support, CK Hu

Hi, Bilal:

Please help to test this patch on your Chromebook elm, thanks.

Regards,
Chun-Kuang Hu

Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2020年11月15日 週日 上午8:14寫道:
>
> From: CK Hu <ck.hu@mediatek.com>
>
> 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.
>
> Fixes: 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of panel with small hfp or hbp")
>
> Signed-off-by: CK Hu <ck.hu@mediatek.com>
> Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> ---
>  drivers/gpu/drm/mediatek/mtk_dsi.c | 53 ++++++++++--------------------
>  1 file changed, 18 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
> index 4a188a942c38..2a64fdaed9a7 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
> @@ -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;
> @@ -474,42 +477,22 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
>         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;
> -               }
> +       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);
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself
  2020-11-15  0:53 ` Chun-Kuang Hu
@ 2020-11-15 19:25   ` Bilal Wasim
  2020-11-15 23:12     ` Chun-Kuang Hu
  0 siblings, 1 reply; 8+ messages in thread
From: Bilal Wasim @ 2020-11-15 19:25 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: Jitao Shi, Philipp Zabel, David Airlie, Daniel Vetter,
	linux-kernel, DRI Development,
	moderated list:ARM/Mediatek SoC support, CK Hu

Hi CK, 

On Sun, 15 Nov 2020 08:53:24 +0800
Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:

> Hi, Bilal:
> 
> Please help to test this patch on your Chromebook elm, thanks.
> 
> Regards,
> Chun-Kuang Hu

Just tried this patch on the Chromebook Elm, and it doesn't work. The
HDMI screen remains black, though the rest of the system keeps on
operating normally.

> 
> Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2020年11月15日 週日
> 上午8:14寫道:
> >
> > From: CK Hu <ck.hu@mediatek.com>
> >
> > 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.
> >
> > Fixes: 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of panel
> > with small hfp or hbp")
> >
> > Signed-off-by: CK Hu <ck.hu@mediatek.com>
> > Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> > ---
> >  drivers/gpu/drm/mediatek/mtk_dsi.c | 53
> > ++++++++++-------------------- 1 file changed, 18 insertions(+), 35
> > deletions(-)
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> > b/drivers/gpu/drm/mediatek/mtk_dsi.c index
> > 4a188a942c38..2a64fdaed9a7 100644 ---
> > a/drivers/gpu/drm/mediatek/mtk_dsi.c +++
> > b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -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;
> > @@ -474,42 +477,22 @@ static void mtk_dsi_config_vdo_timing(struct
> > mtk_dsi *dsi) 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;
> > -               }
> > +       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);
> > --
> > 2.17.1
> >  

Thanks,
Bilal

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself
  2020-11-15 19:25   ` Bilal Wasim
@ 2020-11-15 23:12     ` Chun-Kuang Hu
  2020-11-16 11:53       ` Bilal Wasim
  0 siblings, 1 reply; 8+ messages in thread
From: Chun-Kuang Hu @ 2020-11-15 23:12 UTC (permalink / raw)
  To: Bilal Wasim
  Cc: Chun-Kuang Hu, Jitao Shi, Philipp Zabel, David Airlie,
	Daniel Vetter, linux-kernel, DRI Development,
	moderated list:ARM/Mediatek SoC support, CK Hu

Hi, Bilal:

Bilal Wasim <bilalwasim676@gmail.com> 於 2020年11月16日 週一 上午3:25寫道:
>
> Hi CK,
>
> On Sun, 15 Nov 2020 08:53:24 +0800
> Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
>
> > Hi, Bilal:
> >
> > Please help to test this patch on your Chromebook elm, thanks.
> >
> > Regards,
> > Chun-Kuang Hu
>
> Just tried this patch on the Chromebook Elm, and it doesn't work. The
> HDMI screen remains black, though the rest of the system keeps on
> operating normally.

Could you print this information, so I could find out the solution for
both small hbp and elm.

vm->hfront_porch, vm->hback_porch, dsi_tmp_buf_bpp,
data_phy_cycles_byte, and the final horizontal_frontporch_byte,
horizontal_backporch_byte.

Regards,
Chun-Kuang.

>
> >
> > Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2020年11月15日 週日
> > 上午8:14寫道:
> > >
> > > From: CK Hu <ck.hu@mediatek.com>
> > >
> > > 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.
> > >
> > > Fixes: 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of panel
> > > with small hfp or hbp")
> > >
> > > Signed-off-by: CK Hu <ck.hu@mediatek.com>
> > > Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> > > ---
> > >  drivers/gpu/drm/mediatek/mtk_dsi.c | 53
> > > ++++++++++-------------------- 1 file changed, 18 insertions(+), 35
> > > deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > b/drivers/gpu/drm/mediatek/mtk_dsi.c index
> > > 4a188a942c38..2a64fdaed9a7 100644 ---
> > > a/drivers/gpu/drm/mediatek/mtk_dsi.c +++
> > > b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -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;
> > > @@ -474,42 +477,22 @@ static void mtk_dsi_config_vdo_timing(struct
> > > mtk_dsi *dsi) 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;
> > > -               }
> > > +       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);
> > > --
> > > 2.17.1
> > >
>
> Thanks,
> Bilal

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself
  2020-11-15 23:12     ` Chun-Kuang Hu
@ 2020-11-16 11:53       ` Bilal Wasim
  2020-11-16 16:43         ` Chun-Kuang Hu
  0 siblings, 1 reply; 8+ messages in thread
From: Bilal Wasim @ 2020-11-16 11:53 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: Jitao Shi, Philipp Zabel, David Airlie, Daniel Vetter,
	linux-kernel, DRI Development,
	moderated list:ARM/Mediatek SoC support, CK Hu

Hi CK, 

On Mon, 16 Nov 2020 07:12:55 +0800
Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:

> Hi, Bilal:
> 
> Bilal Wasim <bilalwasim676@gmail.com> 於 2020年11月16日 週一
> 上午3:25寫道:
> >
> > Hi CK,
> >
> > On Sun, 15 Nov 2020 08:53:24 +0800
> > Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
> >  
> > > Hi, Bilal:
> > >
> > > Please help to test this patch on your Chromebook elm, thanks.
> > >
> > > Regards,
> > > Chun-Kuang Hu  
> >
> > Just tried this patch on the Chromebook Elm, and it doesn't work.
> > The HDMI screen remains black, though the rest of the system keeps
> > on operating normally.  
> 
> Could you print this information, so I could find out the solution for
> both small hbp and elm.
> 
> vm->hfront_porch, vm->hback_porch, dsi_tmp_buf_bpp,
> data_phy_cycles_byte, and the final horizontal_frontporch_byte,
> horizontal_backporch_byte.

Here are the values I got, 

[    2.506400] [drm] vm->hfront_porch: 48
[    2.506402] [drm] vm->hback_porch: 200
[    2.506404] [drm] dsi_tmp_buf_bpp: 3
[    2.506406] [drm] data_phy_cycles_byte: 180
[    2.506408] [drm] horizontal_frontporch_byte: 110
[    2.506409] [drm] horizontal_backporch_byte: 455

Please let me know if I can help debug this in any other way.

Thanks, 
Bilal

> 
> Regards,
> Chun-Kuang.
> 
> >  
> > >
> > > Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2020年11月15日 週日
> > > 上午8:14寫道:  
> > > >
> > > > From: CK Hu <ck.hu@mediatek.com>
> > > >
> > > > 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.
> > > >
> > > > Fixes: 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of panel
> > > > with small hfp or hbp")
> > > >
> > > > Signed-off-by: CK Hu <ck.hu@mediatek.com>
> > > > Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> > > > ---
> > > >  drivers/gpu/drm/mediatek/mtk_dsi.c | 53
> > > > ++++++++++-------------------- 1 file changed, 18
> > > > insertions(+), 35 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c index
> > > > 4a188a942c38..2a64fdaed9a7 100644 ---
> > > > a/drivers/gpu/drm/mediatek/mtk_dsi.c +++
> > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -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;
> > > > @@ -474,42 +477,22 @@ static void
> > > > mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) 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;
> > > > -               }
> > > > +       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); --
> > > > 2.17.1
> > > >  
> >
> > Thanks,
> > Bilal  


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself
  2020-11-16 11:53       ` Bilal Wasim
@ 2020-11-16 16:43         ` Chun-Kuang Hu
  2020-11-17 11:58           ` Bilal Wasim
  0 siblings, 1 reply; 8+ messages in thread
From: Chun-Kuang Hu @ 2020-11-16 16:43 UTC (permalink / raw)
  To: Bilal Wasim
  Cc: Chun-Kuang Hu, Jitao Shi, Philipp Zabel, David Airlie,
	Daniel Vetter, linux-kernel, DRI Development,
	moderated list:ARM/Mediatek SoC support, CK Hu

Hi, Bilal:

Bilal Wasim <bilalwasim676@gmail.com> 於 2020年11月16日 週一 下午7:53寫道:
>
> Hi CK,
>
> On Mon, 16 Nov 2020 07:12:55 +0800
> Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
>
> > Hi, Bilal:
> >
> > Bilal Wasim <bilalwasim676@gmail.com> 於 2020年11月16日 週一
> > 上午3:25寫道:
> > >
> > > Hi CK,
> > >
> > > On Sun, 15 Nov 2020 08:53:24 +0800
> > > Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
> > >
> > > > Hi, Bilal:
> > > >
> > > > Please help to test this patch on your Chromebook elm, thanks.
> > > >
> > > > Regards,
> > > > Chun-Kuang Hu
> > >
> > > Just tried this patch on the Chromebook Elm, and it doesn't work.
> > > The HDMI screen remains black, though the rest of the system keeps
> > > on operating normally.
> >
> > Could you print this information, so I could find out the solution for
> > both small hbp and elm.
> >
> > vm->hfront_porch, vm->hback_porch, dsi_tmp_buf_bpp,
> > data_phy_cycles_byte, and the final horizontal_frontporch_byte,
> > horizontal_backporch_byte.
>
> Here are the values I got,
>
> [    2.506400] [drm] vm->hfront_porch: 48
> [    2.506402] [drm] vm->hback_porch: 200
> [    2.506404] [drm] dsi_tmp_buf_bpp: 3
> [    2.506406] [drm] data_phy_cycles_byte: 180
> [    2.506408] [drm] horizontal_frontporch_byte: 110
> [    2.506409] [drm] horizontal_backporch_byte: 455
>
> Please let me know if I can help debug this in any other way.
>

How about this patch [1] ?

[1] https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2536217/2

> Thanks,
> Bilal
>
> >
> > Regards,
> > Chun-Kuang.
> >
> > >
> > > >
> > > > Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2020年11月15日 週日
> > > > 上午8:14寫道:
> > > > >
> > > > > From: CK Hu <ck.hu@mediatek.com>
> > > > >
> > > > > 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.
> > > > >
> > > > > Fixes: 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of panel
> > > > > with small hfp or hbp")
> > > > >
> > > > > Signed-off-by: CK Hu <ck.hu@mediatek.com>
> > > > > Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> > > > > ---
> > > > >  drivers/gpu/drm/mediatek/mtk_dsi.c | 53
> > > > > ++++++++++-------------------- 1 file changed, 18
> > > > > insertions(+), 35 deletions(-)
> > > > >
> > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c index
> > > > > 4a188a942c38..2a64fdaed9a7 100644 ---
> > > > > a/drivers/gpu/drm/mediatek/mtk_dsi.c +++
> > > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -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;
> > > > > @@ -474,42 +477,22 @@ static void
> > > > > mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) 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;
> > > > > -               }
> > > > > +       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); --
> > > > > 2.17.1
> > > > >
> > >
> > > Thanks,
> > > Bilal
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself
  2020-11-16 16:43         ` Chun-Kuang Hu
@ 2020-11-17 11:58           ` Bilal Wasim
  2020-11-17 12:01             ` Bilal Wasim
  0 siblings, 1 reply; 8+ messages in thread
From: Bilal Wasim @ 2020-11-17 11:58 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: Jitao Shi, Philipp Zabel, David Airlie, Daniel Vetter,
	linux-kernel, DRI Development,
	moderated list:ARM/Mediatek SoC support, CK Hu

Hi CK,

On Tue, 17 Nov 2020 00:43:44 +0800
Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:

> Hi, Bilal:
> 
> Bilal Wasim <bilalwasim676@gmail.com> 於 2020年11月16日 週一
> 下午7:53寫道:
> >
> > Hi CK,
> >
> > On Mon, 16 Nov 2020 07:12:55 +0800
> > Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
> >  
> > > Hi, Bilal:
> > >
> > > Bilal Wasim <bilalwasim676@gmail.com> 於 2020年11月16日 週一
> > > 上午3:25寫道:  
> > > >
> > > > Hi CK,
> > > >
> > > > On Sun, 15 Nov 2020 08:53:24 +0800
> > > > Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
> > > >  
> > > > > Hi, Bilal:
> > > > >
> > > > > Please help to test this patch on your Chromebook elm, thanks.
> > > > >
> > > > > Regards,
> > > > > Chun-Kuang Hu  
> > > >
> > > > Just tried this patch on the Chromebook Elm, and it doesn't
> > > > work. The HDMI screen remains black, though the rest of the
> > > > system keeps on operating normally.  
> > >
> > > Could you print this information, so I could find out the
> > > solution for both small hbp and elm.
> > >
> > > vm->hfront_porch, vm->hback_porch, dsi_tmp_buf_bpp,
> > > data_phy_cycles_byte, and the final horizontal_frontporch_byte,
> > > horizontal_backporch_byte.  
> >
> > Here are the values I got,
> >
> > [    2.506400] [drm] vm->hfront_porch: 48
> > [    2.506402] [drm] vm->hback_porch: 200
> > [    2.506404] [drm] dsi_tmp_buf_bpp: 3
> > [    2.506406] [drm] data_phy_cycles_byte: 180
> > [    2.506408] [drm] horizontal_frontporch_byte: 110
> > [    2.506409] [drm] horizontal_backporch_byte: 455
> >
> > Please let me know if I can help debug this in any other way.
> >  
> 
> How about this patch [1] ?
> 
> [1]
> https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2536217/2

This patch works, though it doesn't apply cleanly on 5.9-rc3 (had to
manually patch the mtk_dsi.c file). 

Here are the various variable values, if you're interested. 

[    2.453292] [drm] vm->hfront_porch: 48
[    2.453293] [drm] vm->hback_porch: 200
[    2.453295] [drm] dsi_tmp_buf_bpp: 3
[    2.453296] [drm] data_phy_cycles_byte: 192
[    2.453298] [drm] horizontal_frontporch_byte: 107
[    2.453299] [drm] horizontal_backporch_byte: 436

Thanks, 
Bilal

> 
> > Thanks,
> > Bilal
> >  
> > >
> > > Regards,
> > > Chun-Kuang.
> > >  
> > > >  
> > > > >
> > > > > Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2020年11月15日 週日
> > > > > 上午8:14寫道:  
> > > > > >
> > > > > > From: CK Hu <ck.hu@mediatek.com>
> > > > > >
> > > > > > 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.
> > > > > >
> > > > > > Fixes: 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of
> > > > > > panel with small hfp or hbp")
> > > > > >
> > > > > > Signed-off-by: CK Hu <ck.hu@mediatek.com>
> > > > > > Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> > > > > > ---
> > > > > >  drivers/gpu/drm/mediatek/mtk_dsi.c | 53
> > > > > > ++++++++++-------------------- 1 file changed, 18
> > > > > > insertions(+), 35 deletions(-)
> > > > > >
> > > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c index
> > > > > > 4a188a942c38..2a64fdaed9a7 100644 ---
> > > > > > a/drivers/gpu/drm/mediatek/mtk_dsi.c +++
> > > > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -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;
> > > > > > @@ -474,42 +477,22 @@ static void
> > > > > > mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
> > > > > > 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;
> > > > > > -               }
> > > > > > +       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); --
> > > > > > 2.17.1
> > > > > >  
> > > >
> > > > Thanks,
> > > > Bilal  
> >  


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself
  2020-11-17 11:58           ` Bilal Wasim
@ 2020-11-17 12:01             ` Bilal Wasim
  0 siblings, 0 replies; 8+ messages in thread
From: Bilal Wasim @ 2020-11-17 12:01 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: Jitao Shi, Philipp Zabel, David Airlie, Daniel Vetter,
	linux-kernel, DRI Development,
	moderated list:ARM/Mediatek SoC support, CK Hu

On Tue, 17 Nov 2020 16:58:48 +0500
Bilal Wasim <bilalwasim676@gmail.com> wrote:

> Hi CK,
> 
> On Tue, 17 Nov 2020 00:43:44 +0800
> Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
> 
> > Hi, Bilal:
> > 
> > Bilal Wasim <bilalwasim676@gmail.com> 於 2020年11月16日 週一
> > 下午7:53寫道:  
> > >
> > > Hi CK,
> > >
> > > On Mon, 16 Nov 2020 07:12:55 +0800
> > > Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
> > >    
> > > > Hi, Bilal:
> > > >
> > > > Bilal Wasim <bilalwasim676@gmail.com> 於 2020年11月16日 週一
> > > > 上午3:25寫道:    
> > > > >
> > > > > Hi CK,
> > > > >
> > > > > On Sun, 15 Nov 2020 08:53:24 +0800
> > > > > Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
> > > > >    
> > > > > > Hi, Bilal:
> > > > > >
> > > > > > Please help to test this patch on your Chromebook elm,
> > > > > > thanks.
> > > > > >
> > > > > > Regards,
> > > > > > Chun-Kuang Hu    
> > > > >
> > > > > Just tried this patch on the Chromebook Elm, and it doesn't
> > > > > work. The HDMI screen remains black, though the rest of the
> > > > > system keeps on operating normally.    
> > > >
> > > > Could you print this information, so I could find out the
> > > > solution for both small hbp and elm.
> > > >
> > > > vm->hfront_porch, vm->hback_porch, dsi_tmp_buf_bpp,
> > > > data_phy_cycles_byte, and the final horizontal_frontporch_byte,
> > > > horizontal_backporch_byte.    
> > >
> > > Here are the values I got,
> > >
> > > [    2.506400] [drm] vm->hfront_porch: 48
> > > [    2.506402] [drm] vm->hback_porch: 200
> > > [    2.506404] [drm] dsi_tmp_buf_bpp: 3
> > > [    2.506406] [drm] data_phy_cycles_byte: 180
> > > [    2.506408] [drm] horizontal_frontporch_byte: 110
> > > [    2.506409] [drm] horizontal_backporch_byte: 455
> > >
> > > Please let me know if I can help debug this in any other way.
> > >    
> > 
> > How about this patch [1] ?
> > 
> > [1]
> > https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2536217/2
> >  
> 
> This patch works, though it doesn't apply cleanly on 5.9-rc3 (had to
> manually patch the mtk_dsi.c file). 
> 

Just to clarify: I tested with 5.10-rc3, not 5.9-rc3. Apologies for the
typo.

Thanks, 
Bilal

> Here are the various variable values, if you're interested. 
> 
> [    2.453292] [drm] vm->hfront_porch: 48
> [    2.453293] [drm] vm->hback_porch: 200
> [    2.453295] [drm] dsi_tmp_buf_bpp: 3
> [    2.453296] [drm] data_phy_cycles_byte: 192
> [    2.453298] [drm] horizontal_frontporch_byte: 107
> [    2.453299] [drm] horizontal_backporch_byte: 436
> 
> Thanks, 
> Bilal
> 
> >   
> > > Thanks,
> > > Bilal
> > >    
> > > >
> > > > Regards,
> > > > Chun-Kuang.
> > > >    
> > > > >    
> > > > > >
> > > > > > Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2020年11月15日
> > > > > > 週日上午8:14寫道:    
> > > > > > >
> > > > > > > From: CK Hu <ck.hu@mediatek.com>
> > > > > > >
> > > > > > > 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.
> > > > > > >
> > > > > > > Fixes: 35bf948f1edb ("drm/mediatek: dsi: Fix scrolling of
> > > > > > > panel with small hfp or hbp")
> > > > > > >
> > > > > > > Signed-off-by: CK Hu <ck.hu@mediatek.com>
> > > > > > > Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> > > > > > > ---
> > > > > > >  drivers/gpu/drm/mediatek/mtk_dsi.c | 53
> > > > > > > ++++++++++-------------------- 1 file changed, 18
> > > > > > > insertions(+), 35 deletions(-)
> > > > > > >
> > > > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c
> > > > > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c index
> > > > > > > 4a188a942c38..2a64fdaed9a7 100644 ---
> > > > > > > a/drivers/gpu/drm/mediatek/mtk_dsi.c +++
> > > > > > > b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -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;
> > > > > > > @@ -474,42 +477,22 @@ static void
> > > > > > > mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
> > > > > > > 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;
> > > > > > > -               }
> > > > > > > +       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); --
> > > > > > > 2.17.1
> > > > > > >    
> > > > >
> > > > > Thanks,
> > > > > Bilal    
> > >    
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-17 12:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-15  0:14 [PATCH] drm/mediatek: dsi: Calculate horizontal_backporch_byte by itself Chun-Kuang Hu
2020-11-15  0:53 ` Chun-Kuang Hu
2020-11-15 19:25   ` Bilal Wasim
2020-11-15 23:12     ` Chun-Kuang Hu
2020-11-16 11:53       ` Bilal Wasim
2020-11-16 16:43         ` Chun-Kuang Hu
2020-11-17 11:58           ` Bilal Wasim
2020-11-17 12:01             ` Bilal Wasim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).