Hi,

On Mon, 2019-02-11 at 15:41 +0100, Maxime Ripard wrote:
> From: Konstantin Sudakov <k.suda...@integrasources.com>
> 
> The current driver doesn't support the DSI burst operation mode.
> 
> Let's add the needed quirks to make it work.
> 
> Signed-off-by: Konstantin Sudakov <k.suda...@integrasources.com>
> Signed-off-by: Maxime Ripard <maxime.rip...@bootlin.com>
> ---
>  drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 171 ++++++++++++++++++++------
>  1 file changed, 132 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c 
> b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> index e0288e7dc64e..4cb715dc9100 100644
> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c

[...]

> @@ -457,52 +531,71 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi 
> *dsi,
>       struct mipi_dsi_device *device = dsi->device;
>       unsigned int Bpp = mipi_dsi_pixel_format_to_bpp(device->format) / 8;
>       u16 hbp, hfp, hsa, hblk, vblk;
> +     u32 basic_ctl = 0;
>       size_t bytes;
>       u8 *buffer;
>  
>       /* Do all timing calculations up front to allocate buffer space */
>  
> -     /*
> -      * A sync period is composed of a blanking packet (4 bytes +
> -      * payload + 2 bytes) and a sync event packet (4 bytes). Its
> -      * minimal size is therefore 10 bytes
> -      */
> +     if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) {
> +             hsa = 0;
> +             hbp = 0;
> +             hfp = 0;
> +             hblk = mode->hdisplay * Bpp;
> +             vblk = 0;

It looks a bit strange to zero these variables here while basic_ctl is
initialized to zero when declared. I think it would be more consistent
to have these variables set to zero in the same fashion.

With that fixed:

Reviewed-by: Paul Kocialkowski <paul.kocialkow...@bootlin.com>

Cheers,

Paul

> +             basic_ctl = SUN6I_DSI_BASIC_CTL_VIDEO_BURST |
> +                         SUN6I_DSI_BASIC_CTL_HSA_HSE_DIS |
> +                         SUN6I_DSI_BASIC_CTL_HBP_DIS;
> +
> +             if (device->lanes == 4)
> +                     basic_ctl |= SUN6I_DSI_BASIC_CTL_TRAIL_FILL |
> +                                  SUN6I_DSI_BASIC_CTL_TRAIL_INV(0xc);
> +     } else {
> +             /*
> +              * A sync period is composed of a blanking packet (4
> +              * bytes + payload + 2 bytes) and a sync event packet
> +              * (4 bytes). Its minimal size is therefore 10 bytes
> +              */
>  #define HSA_PACKET_OVERHEAD  10
> -     hsa = max((unsigned int)HSA_PACKET_OVERHEAD,
> -               (mode->hsync_end - mode->hsync_start) * Bpp - 
> HSA_PACKET_OVERHEAD);
> -
> -     /*
> -      * The backporch is set using a blanking packet (4 bytes +
> -      * payload + 2 bytes). Its minimal size is therefore 6 bytes
> -      */
> +             hsa = max((unsigned int)HSA_PACKET_OVERHEAD,
> +                       (mode->hsync_end - mode->hsync_start) * Bpp - 
> HSA_PACKET_OVERHEAD);
> +
> +             /*
> +              * The backporch is set using a blanking packet (4
> +              * bytes + payload + 2 bytes). Its minimal size is
> +              * therefore 6 bytes
> +              */
>  #define HBP_PACKET_OVERHEAD  6
> -     hbp = max((unsigned int)HBP_PACKET_OVERHEAD,
> -               (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD);
> -
> -     /*
> -      * The frontporch is set using a blanking packet (4 bytes +
> -      * payload + 2 bytes). Its minimal size is therefore 6 bytes
> -      */
> +             hbp = max((unsigned int)HBP_PACKET_OVERHEAD,
> +                       (mode->htotal - mode->hsync_end) * Bpp - 
> HBP_PACKET_OVERHEAD);
> +
> +             /*
> +              * The frontporch is set using a blanking packet (4
> +              * bytes + payload + 2 bytes). Its minimal size is
> +              * therefore 6 bytes
> +              */
>  #define HFP_PACKET_OVERHEAD  6
> -     hfp = max((unsigned int)HFP_PACKET_OVERHEAD,
> -               (mode->hsync_start - mode->hdisplay) * Bpp - 
> HFP_PACKET_OVERHEAD);
> -
> -     /*
> -      * The blanking is set using a sync event (4 bytes) and a
> -      * blanking packet (4 bytes + payload + 2 bytes). Its minimal
> -      * size is therefore 10 bytes.
> -      */
> +             hfp = max((unsigned int)HFP_PACKET_OVERHEAD,
> +                       (mode->hsync_start - mode->hdisplay) * Bpp - 
> HFP_PACKET_OVERHEAD);
> +
> +             /*
> +              * The blanking is set using a sync event (4 bytes)
> +              * and a blanking packet (4 bytes + payload + 2
> +              * bytes). Its minimal size is therefore 10 bytes.
> +              */
>  #define HBLK_PACKET_OVERHEAD 10
> -     hblk = max((unsigned int)HBLK_PACKET_OVERHEAD,
> -                (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp 
> - HBLK_PACKET_OVERHEAD);
> -
> -     /*
> -      * And I'm not entirely sure what vblk is about. The driver in
> -      * Allwinner BSP is using a rather convoluted calculation
> -      * there only for 4 lanes. However, using 0 (the !4 lanes
> -      * case) even with a 4 lanes screen seems to work...
> -      */
> -     vblk = 0;
> +             hblk = max((unsigned int)HBLK_PACKET_OVERHEAD,
> +                        (mode->htotal - (mode->hsync_end - 
> mode->hsync_start)) * Bpp -
> +                        HBLK_PACKET_OVERHEAD);
> +
> +             /*
> +              * And I'm not entirely sure what vblk is about. The driver in
> +              * Allwinner BSP is using a rather convoluted calculation
> +              * there only for 4 lanes. However, using 0 (the !4 lanes
> +              * case) even with a 4 lanes screen seems to work...
> +              */
> +             vblk = 0;
> +     }
>  
>       /* How many bytes do we need to send all payloads? */
>       bytes = max_t(size_t, max(max(hfp, hblk), max(hsa, hbp)), vblk);
> @@ -510,7 +603,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
>       if (WARN_ON(!buffer))
>               return;
>  
> -     regmap_write(dsi->regs, SUN6I_DSI_BASIC_CTL_REG, 0);
> +     regmap_write(dsi->regs, SUN6I_DSI_BASIC_CTL_REG, basic_ctl);
>  
>       regmap_write(dsi->regs, SUN6I_DSI_SYNC_HSS_REG,
>                    sun6i_dsi_build_sync_pkt(MIPI_DSI_H_SYNC_START,
-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to