media: imx: add capture compose rectangle

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>
This commit is contained in:
Philipp Zabel 2019-01-17 13:51:52 -02:00 committed by Mauro Carvalho Chehab
parent cd9f125cfa
commit 439d8186fb
5 changed files with 33 additions and 6 deletions

View 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

View 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);

View 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);

View 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;

View 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 */