media: imx: add capture compose rectangle
authorPhilipp Zabel <p.zabel@pengutronix.de>
Thu, 17 Jan 2019 15:51:52 +0000 (13:51 -0200)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 21 Jan 2019 17:48:40 +0000 (15:48 -0200)
Allowing to compose captured images into larger memory buffers
will let us lift alignment restrictions on CSI crop width.

For now all compose rectangles are identical to the complete
frame width / height. This will be changed in the next patches.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/staging/media/imx/imx-ic-prpencvf.c
drivers/staging/media/imx/imx-media-capture.c
drivers/staging/media/imx/imx-media-csi.c
drivers/staging/media/imx/imx-media-vdic.c
drivers/staging/media/imx/imx-media.h

index 33ada6612fee2e76f6e949f7c662a2511bd4bf1f..c7855fbc449d1bbb403c3c42891514fcc6d3b9b3 100644 (file)
@@ -371,8 +371,7 @@ static int prp_setup_channel(struct prp_priv *priv,
 
        memset(&image, 0, sizeof(image));
        image.pix = vdev->fmt.fmt.pix;
-       image.rect.width = image.pix.width;
-       image.rect.height = image.pix.height;
+       image.rect = vdev->compose;
 
        /*
         * If the field type at capture interface is interlaced, and
index 01ec9443de550200abcadbef9df5f0caa17395fd..8b8ef4a117745316205aea4cf5b01a9d4e35e25a 100644 (file)
@@ -276,6 +276,10 @@ static int capture_s_fmt_vid_cap(struct file *file, void *fh,
        priv->vdev.fmt.fmt.pix = f->fmt.pix;
        priv->vdev.cc = imx_media_find_format(f->fmt.pix.pixelformat,
                                              CS_SEL_ANY, true);
+       priv->vdev.compose.left = 0;
+       priv->vdev.compose.top = 0;
+       priv->vdev.compose.width = f->fmt.pix.width;
+       priv->vdev.compose.height = f->fmt.pix.height;
 
        return 0;
 }
@@ -304,6 +308,25 @@ static int capture_s_std(struct file *file, void *fh, v4l2_std_id std)
        return v4l2_subdev_call(priv->src_sd, video, s_std, std);
 }
 
+static int capture_g_selection(struct file *file, void *fh,
+                              struct v4l2_selection *s)
+{
+       struct capture_priv *priv = video_drvdata(file);
+
+       switch (s->target) {
+       case V4L2_SEL_TGT_COMPOSE:
+       case V4L2_SEL_TGT_COMPOSE_DEFAULT:
+       case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+       case V4L2_SEL_TGT_COMPOSE_PADDED:
+               s->r = priv->vdev.compose;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int capture_g_parm(struct file *file, void *fh,
                          struct v4l2_streamparm *a)
 {
@@ -364,6 +387,8 @@ static const struct v4l2_ioctl_ops capture_ioctl_ops = {
        .vidioc_g_std           = capture_g_std,
        .vidioc_s_std           = capture_s_std,
 
+       .vidioc_g_selection     = capture_g_selection,
+
        .vidioc_g_parm          = capture_g_parm,
        .vidioc_s_parm          = capture_s_parm,
 
@@ -701,6 +726,8 @@ int imx_media_capture_device_register(struct imx_media_video_dev *vdev)
        vdev->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt.fmt.pix,
                                      &fmt_src.format, NULL);
+       vdev->compose.width = fmt_src.format.width;
+       vdev->compose.height = fmt_src.format.height;
        vdev->cc = imx_media_find_format(vdev->fmt.fmt.pix.pixelformat,
                                         CS_SEL_ANY, false);
 
index 555aa45e02e36e7dae9b1cfcbaa9b84e4dd43aa6..39fad3bfa6ca3e422c9e64e238bafc78b61b5c15 100644 (file)
@@ -419,8 +419,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
 
        memset(&image, 0, sizeof(image));
        image.pix = vdev->fmt.fmt.pix;
-       image.rect.width = image.pix.width;
-       image.rect.height = image.pix.height;
+       image.rect = vdev->compose;
 
        csi_idmac_setup_vb2_buf(priv, phys);
 
index 4a890714193ef3ff68b6d9ca54f79cdc8e4b82c1..297951d98ab50c0bba5ffb7e57ece97edfcf8bb9 100644 (file)
@@ -255,10 +255,10 @@ static int setup_vdi_channel(struct vdic_priv *priv,
 
        memset(&image, 0, sizeof(image));
        image.pix = vdev->fmt.fmt.pix;
+       image.rect = vdev->compose;
        /* one field to VDIC channels */
        image.pix.height /= 2;
-       image.rect.width = image.pix.width;
-       image.rect.height = image.pix.height;
+       image.rect.height /= 2;
        image.phys0 = phys0;
        image.phys1 = phys1;
 
index bc7feb81937ceea79cc1fae19039149318a000f3..7a0e658753f062db72bb0847ed2ce4ae23f46e87 100644 (file)
@@ -80,6 +80,8 @@ struct imx_media_video_dev {
 
        /* the user format */
        struct v4l2_format fmt;
+       /* the compose rectangle */
+       struct v4l2_rect compose;
        const struct imx_media_pixfmt *cc;
 
        /* links this vdev to master list */