[media] v4l: vsp1: Disable cropping on WPF sink pad
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Mon, 12 Sep 2016 01:41:06 +0000 (22:41 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 19 Sep 2016 17:55:40 +0000 (14:55 -0300)
Cropping on the WPF sink pad restricts the left and top coordinates to
0-255. The same result can be obtained by cropping on the RPF without
any such restriction, this feature isn't useful. Disable it.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/vsp1/vsp1_rwpf.c
drivers/media/platform/vsp1/vsp1_wpf.c

index 8cb87e9..a3ace8d 100644 (file)
@@ -66,7 +66,6 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
        struct vsp1_rwpf *rwpf = to_rwpf(subdev);
        struct v4l2_subdev_pad_config *config;
        struct v4l2_mbus_framefmt *format;
-       struct v4l2_rect *crop;
        int ret = 0;
 
        mutex_lock(&rwpf->entity.lock);
@@ -103,12 +102,16 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
 
        fmt->format = *format;
 
-       /* Update the sink crop rectangle. */
-       crop = vsp1_rwpf_get_crop(rwpf, config);
-       crop->left = 0;
-       crop->top = 0;
-       crop->width = fmt->format.width;
-       crop->height = fmt->format.height;
+       if (rwpf->entity.type == VSP1_ENTITY_RPF) {
+               struct v4l2_rect *crop;
+
+               /* Update the sink crop rectangle. */
+               crop = vsp1_rwpf_get_crop(rwpf, config);
+               crop->left = 0;
+               crop->top = 0;
+               crop->width = fmt->format.width;
+               crop->height = fmt->format.height;
+       }
 
        /* Propagate the format to the source pad. */
        format = vsp1_entity_get_pad_format(&rwpf->entity, config,
@@ -129,8 +132,10 @@ static int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
        struct v4l2_mbus_framefmt *format;
        int ret = 0;
 
-       /* Cropping is implemented on the sink pad. */
-       if (sel->pad != RWPF_PAD_SINK)
+       /* Cropping is only supported on the RPF and is implemented on the sink
+        * pad.
+        */
+       if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK)
                return -EINVAL;
 
        mutex_lock(&rwpf->entity.lock);
@@ -175,8 +180,10 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
        struct v4l2_rect *crop;
        int ret = 0;
 
-       /* Cropping is implemented on the sink pad. */
-       if (sel->pad != RWPF_PAD_SINK)
+       /* Cropping is only supported on the RPF and is implemented on the sink
+        * pad.
+        */
+       if (rwpf->entity.type == VSP1_ENTITY_WPF || sel->pad != RWPF_PAD_SINK)
                return -EINVAL;
 
        if (sel->target != V4L2_SEL_TGT_CROP)
@@ -190,9 +197,7 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
                goto done;
        }
 
-       /* Make sure the crop rectangle is entirely contained in the image. The
-        * WPF top and left offsets are limited to 255.
-        */
+       /* Make sure the crop rectangle is entirely contained in the image. */
        format = vsp1_entity_get_pad_format(&rwpf->entity, config,
                                            RWPF_PAD_SINK);
 
@@ -208,10 +213,6 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
 
        sel->r.left = min_t(unsigned int, sel->r.left, format->width - 2);
        sel->r.top = min_t(unsigned int, sel->r.top, format->height - 2);
-       if (rwpf->entity.type == VSP1_ENTITY_WPF) {
-               sel->r.left = min_t(unsigned int, sel->r.left, 255);
-               sel->r.top = min_t(unsigned int, sel->r.top, 255);
-       }
        sel->r.width = min_t(unsigned int, sel->r.width,
                             format->width - sel->r.left);
        sel->r.height = min_t(unsigned int, sel->r.height,
index 748f5af..f3a5931 100644 (file)
@@ -212,7 +212,6 @@ static void wpf_configure(struct vsp1_entity *entity,
        struct vsp1_device *vsp1 = wpf->entity.vsp1;
        const struct v4l2_mbus_framefmt *source_format;
        const struct v4l2_mbus_framefmt *sink_format;
-       const struct v4l2_rect *crop;
        unsigned int i;
        u32 outfmt = 0;
        u32 srcrpf = 0;
@@ -237,16 +236,6 @@ static void wpf_configure(struct vsp1_entity *entity,
                return;
        }
 
-       /* Cropping */
-       crop = vsp1_rwpf_get_crop(wpf, wpf->entity.config);
-
-       vsp1_wpf_write(wpf, dl, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN |
-                      (crop->left << VI6_WPF_SZCLIP_OFST_SHIFT) |
-                      (crop->width << VI6_WPF_SZCLIP_SIZE_SHIFT));
-       vsp1_wpf_write(wpf, dl, VI6_WPF_VSZCLIP, VI6_WPF_SZCLIP_EN |
-                      (crop->top << VI6_WPF_SZCLIP_OFST_SHIFT) |
-                      (crop->height << VI6_WPF_SZCLIP_SIZE_SHIFT));
-
        /* Format */
        sink_format = vsp1_entity_get_pad_format(&wpf->entity,
                                                 wpf->entity.config,
@@ -255,6 +244,13 @@ static void wpf_configure(struct vsp1_entity *entity,
                                                   wpf->entity.config,
                                                   RWPF_PAD_SOURCE);
 
+       vsp1_wpf_write(wpf, dl, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN |
+                      (0 << VI6_WPF_SZCLIP_OFST_SHIFT) |
+                      (source_format->width << VI6_WPF_SZCLIP_SIZE_SHIFT));
+       vsp1_wpf_write(wpf, dl, VI6_WPF_VSZCLIP, VI6_WPF_SZCLIP_EN |
+                      (0 << VI6_WPF_SZCLIP_OFST_SHIFT) |
+                      (source_format->height << VI6_WPF_SZCLIP_SIZE_SHIFT));
+
        if (!pipe->lif) {
                const struct v4l2_pix_format_mplane *format = &wpf->format;
                const struct vsp1_format_info *fmtinfo = wpf->fmtinfo;