MLK-15110-19 gpu: imx: dpu: fetchdecode: Fixup stride when we use prefetch
authorLiu Ying <victor.liu@nxp.com>
Wed, 28 Jun 2017 07:55:24 +0000 (15:55 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Tue, 20 Mar 2018 19:50:52 +0000 (14:50 -0500)
When we use prefetch, we use DPR and PRG to do frame input cropping.  Thus,
the stride of fetchdecode is the stride of cropped frame, which means the
value of the stride is cropped_width * bytes_per_pixel.  Also, to address
TKT339017, when we use prefetch engine for fetchdecode, we need to round
the frame stride up to the fetchdecode burst size, i.e., burst length
multiplies 8 bytes.  According to TKT343664, the buffer base address has
to align to burst size, so we'll pick an appropriate burst size value in
fetchdecode_source_stride().

Signed-off-by: Liu Ying <victor.liu@nxp.com>
drivers/gpu/drm/imx/dpu/dpu-plane.c
drivers/gpu/imx/dpu/dpu-fetchdecode.c
include/video/dpu.h

index b210d12..fd709cf 100644 (file)
@@ -356,7 +356,8 @@ static void dpu_plane_atomic_update(struct drm_plane *plane,
        }
 
        fetchdecode_source_bpp(fd, bpp);
-       fetchdecode_source_stride(fd, fb->pitches[0]);
+       fetchdecode_source_stride(fd, src_w, bpp, fb->pitches[0],
+                                 drm_plane_state_to_baseaddr(state), false);
        fetchdecode_src_buf_dimensions(fd, src_w, src_h);
        fetchdecode_set_fmt(fd, fb->pixel_format);
        fetchdecode_source_buffer_enable(fd);
index 322a991..e8d4ec8 100644 (file)
@@ -269,10 +269,29 @@ void fetchdecode_source_bpp(struct dpu_fetchdecode *fd, int bpp)
 }
 EXPORT_SYMBOL_GPL(fetchdecode_source_bpp);
 
-void fetchdecode_source_stride(struct dpu_fetchdecode *fd, int stride)
+void fetchdecode_source_stride(struct dpu_fetchdecode *fd, unsigned int width,
+                              int bpp, unsigned int stride,
+                              dma_addr_t baddr, bool use_prefetch)
 {
+       unsigned int burst_size;
        u32 val;
 
+       if (use_prefetch) {
+               /*
+                * address TKT343664:
+                * fetch unit base address has to align to burst size
+                */
+               burst_size = 1 << (ffs(baddr) - 1);
+               burst_size = min(burst_size, 128U);
+
+               stride = width * (bpp >> 3);
+               /*
+                * address TKT339017:
+                * fixup for burst size vs stride mismatch
+                */
+               stride = round_up(stride, burst_size);
+       }
+
        mutex_lock(&fd->mutex);
        val = dpu_fd_read(fd, SOURCEBUFFERATTRIBUTES0);
        val &= ~0xffff;
index ddec9c5..36e6235 100644 (file)
@@ -476,7 +476,9 @@ void fetchdecode_set_burstlength(struct dpu_fetchdecode *fd, dma_addr_t baddr,
                                 bool use_prefetch);
 void fetchdecode_baseaddress(struct dpu_fetchdecode *fd, dma_addr_t paddr);
 void fetchdecode_source_bpp(struct dpu_fetchdecode *fd, int bpp);
-void fetchdecode_source_stride(struct dpu_fetchdecode *fd, int stride);
+void fetchdecode_source_stride(struct dpu_fetchdecode *fd, unsigned int width,
+                              int bpp, unsigned int stride,
+                              dma_addr_t baddr, bool use_prefetch);
 void fetchdecode_src_buf_dimensions(struct dpu_fetchdecode *fd, unsigned int w,
                                    unsigned int h);
 void fetchdecode_set_fmt(struct dpu_fetchdecode *fd, u32 fmt);