]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ti-linux-kernel/ti-linux-kernel-next.git/commitdiff
drm/omap: omap_wb_m2m: add cropping parameter support
authorBenoit Parrot <bparrot@ti.com>
Fri, 19 Oct 2018 19:55:07 +0000 (14:55 -0500)
committerBenoit Parrot <bparrot@ti.com>
Tue, 23 Oct 2018 21:01:26 +0000 (16:01 -0500)
Implement support for cropping functionality.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
drivers/gpu/drm/omapdrm/omap_wb_m2m.c

index 1fadb5bf466ac1b07241ebf0cd3fc0298dc378a2..851e87cf6f3f5c03949346f821a66e225233bc47 100644 (file)
@@ -142,6 +142,8 @@ static void device_run(void *priv)
        struct omap_overlay_info src_info = { 0 };
        struct omap_dss_writeback_info wb_info = { 0 };
        struct v4l2_pix_format_mplane *spix, *dpix;
+       struct v4l2_rect *srect, *drect;
+       u32 stride, depth;
        bool ok;
 
        src_vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
@@ -168,6 +170,7 @@ static void device_run(void *priv)
                return;
        }
 
+       srect = &s_q_data->c_rect;
        spix = &s_q_data->format.fmt.pix_mp;
        src_dma_addr[0] = vb2_dma_contig_plane_dma_addr(s_vb, 0);
        if (spix->num_planes == 2)
@@ -182,6 +185,7 @@ static void device_run(void *priv)
                return;
        }
 
+       drect = &d_q_data->c_rect;
        dpix = &d_q_data->format.fmt.pix_mp;
        dst_dma_addr[0] = vb2_dma_contig_plane_dma_addr(d_vb, 0);
        if (dpix->num_planes == 2)
@@ -200,16 +204,32 @@ static void device_run(void *priv)
        src_info.paddr = (u32)src_dma_addr[0];
        src_info.p_uv_addr = (u32)src_dma_addr[1];
 
+       /* update addr based on cropping window */
+       stride = spix->plane_fmt[0].bytesperline;
+       depth = s_q_data->fmt->depth[0];
+       src_info.paddr += srect->top * stride + (srect->left * depth / 8);
+
+       if (src_info.p_uv_addr) {
+               u32 top = srect->top;
+
+               if (spix->pixelformat == V4L2_PIX_FMT_NV12 ||
+                   spix->pixelformat == V4L2_PIX_FMT_NV12M) {
+                       top >>= 1;
+                       depth = 8;
+               }
+               src_info.p_uv_addr += top * stride + (srect->left * depth / 8);
+       }
+
        src_info.screen_width = spix->plane_fmt[0].bytesperline /
                                (s_q_data->fmt->depth[0] / 8);
 
-       src_info.width = spix->width;
-       src_info.height = spix->height;
+       src_info.width = srect->width;
+       src_info.height = srect->height;
 
        src_info.pos_x = 0;
        src_info.pos_y = 0;
-       src_info.out_width = spix->width;
-       src_info.out_height = spix->height;
+       src_info.out_width = srect->width;
+       src_info.out_height = srect->height;
 
        src_info.fourcc = omap_wb_fourcc_v4l2_to_drm(spix->pixelformat);
        src_info.global_alpha = 0xff;
@@ -228,8 +248,24 @@ static void device_run(void *priv)
        wb_info.buf_width = dpix->plane_fmt[0].bytesperline /
                            (d_q_data->fmt->depth[0] / 8);
 
-       wb_info.width = dpix->width;
-       wb_info.height = dpix->height;
+       /* update addr based on compose window */
+       stride = dpix->plane_fmt[0].bytesperline;
+       depth = d_q_data->fmt->depth[0];
+       wb_info.paddr += drect->top * stride + (drect->left * depth / 8);
+
+       if (wb_info.p_uv_addr) {
+               u32 top = drect->top;
+
+               if (dpix->pixelformat == V4L2_PIX_FMT_NV12 ||
+                   dpix->pixelformat == V4L2_PIX_FMT_NV12M) {
+                       top >>= 1;
+                       depth = 8;
+               }
+               wb_info.p_uv_addr += top * stride + (drect->left * depth / 8);
+       }
+
+       wb_info.width = drect->width;
+       wb_info.height = drect->height;
        wb_info.fourcc = omap_wb_fourcc_v4l2_to_drm(dpix->pixelformat);
        wb_info.pre_mult_alpha = 1;
 
@@ -686,7 +722,8 @@ static int wbm2m_s_selection(struct file *file, void *fh,
            (q_data->c_rect.width == sel.r.width) &&
            (q_data->c_rect.height == sel.r.height)) {
                log_dbg(ctx->dev,
-                       "requested crop/compose values are already set\n");
+                       "type: %d, requested crop/compose values are already set\n",
+                       sel.type);
                return 0;
        }