diff mbox series

[v8,7/8] drm/sun4i: sun6i_mipi_dsi: Refactor vertical video start delay

Message ID 20190214192544.7314-8-jagan@amarulasolutions.com (mailing list archive)
State New, archived
Headers show
Series drm/sun4i: sun6i_mipi_dsi: Random fixes | expand

Commit Message

Jagan Teki Feb. 14, 2019, 7:25 p.m. UTC
Vertical video start delay is computed by excluding vertical porch
value from total vertical timings, but the current driver excluding
vertical porch along with vertical sync values from total vertical
timings resulting wrong start delay.

This patch trying to update the video start delay by subtracting
vertical porch from vertical total, on the other hand it added 1
extra start_delay line for TCON based on the Allwinner BSP reference.

BSP code form BPI-M64-bsp is computing video start delay as
(from linux-sunxi/
drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c)

u32 vfp = panel->lcd_vt - panel->lcd_y - panel->lcd_vbp;
=> (panel->lcd_vt) - panel->lcd_y - (panel->lcd_vbp)
=> (timmings->ver_front_porch + panel->lcd_vbp + panel->lcd_y)
   - panel->lcd_y - (panel->lcd_vbp)
=> timmings->ver_front_porch + panel->lcd_vbp + panel->lcd_y
  			     - panel->lcd_y - panel->lcd_vbp
=> timmings->ver_front_porch

So, update the start delay computation accordingly.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Jagan Teki Feb. 15, 2019, 7:37 p.m. UTC | #1
On Fri, Feb 15, 2019 at 12:56 AM Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> Vertical video start delay is computed by excluding vertical porch
> value from total vertical timings, but the current driver excluding
> vertical porch along with vertical sync values from total vertical
> timings resulting wrong start delay.
>
> This patch trying to update the video start delay by subtracting
> vertical porch from vertical total, on the other hand it added 1
> extra start_delay line for TCON based on the Allwinner BSP reference.
>
> BSP code form BPI-M64-bsp is computing video start delay as
> (from linux-sunxi/
> drivers/video/sunxi/disp2/disp/de/lowlevel_sun50iw1/de_dsi.c)
>
> u32 vfp = panel->lcd_vt - panel->lcd_y - panel->lcd_vbp;
> => (panel->lcd_vt) - panel->lcd_y - (panel->lcd_vbp)
> => (timmings->ver_front_porch + panel->lcd_vbp + panel->lcd_y)
>    - panel->lcd_y - (panel->lcd_vbp)
> => timmings->ver_front_porch + panel->lcd_vbp + panel->lcd_y
>                              - panel->lcd_y - panel->lcd_vbp
> => timmings->ver_front_porch
>
> So, update the start delay computation accordingly.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> index a08dfdcbe9e8..31cf9c58e98d 100644
> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> @@ -358,7 +358,24 @@ static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi,
>  static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi,
>                                            struct drm_display_mode *mode)
>  {
> -       return mode->vtotal - (mode->vsync_end - mode->vdisplay) + 1;
> +       u32 vfp, start_delay;
> +
> +       /* vertical front porch */
> +       vfp = mode->vsync_start - mode->vdisplay;
> +
> +       /* start_delay = vertical total - vertical front porch */
> +       start_delay = mode->vtotal - vfp;
> +
> +       /* add extra 1 delay line for TCON, as per Allwinner BSP */
> +       start_delay = 1;

This has to be += 1;

Typo change while re-basing, I will fix this in next version.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
index a08dfdcbe9e8..31cf9c58e98d 100644
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
@@ -358,7 +358,24 @@  static void sun6i_dsi_inst_init(struct sun6i_dsi *dsi,
 static u16 sun6i_dsi_get_video_start_delay(struct sun6i_dsi *dsi,
 					   struct drm_display_mode *mode)
 {
-	return mode->vtotal - (mode->vsync_end - mode->vdisplay) + 1;
+	u32 vfp, start_delay;
+
+	/* vertical front porch */
+	vfp = mode->vsync_start - mode->vdisplay;
+
+	/* start_delay = vertical total - vertical front porch */
+	start_delay = mode->vtotal - vfp;
+
+	/* add extra 1 delay line for TCON, as per Allwinner BSP */
+	start_delay = 1;
+
+	if (start_delay > mode->vtotal)
+		start_delay -= mode->vtotal;
+
+	if (!start_delay)
+		start_delay = 1;
+
+	return start_delay;
 }
 
 static void sun6i_dsi_setup_burst(struct sun6i_dsi *dsi,