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 33ada66..c7855fb 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 01ec944..8b8ef4a 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 555aa45..39fad3b 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 4a89071..297951d 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 bc7feb8..7a0e658 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 */