From: Hans Verkuil <hverkuil@xs4all.nl>
To: Archit Taneja <archit@ti.com>
Cc: k.debski@samsung.com, linux-media@vger.kernel.org,
linux-omap@vger.kernel.org
Subject: Re: [PATCH v3 07/14] v4l: ti-vpe: Add selection API in VPE driver
Date: Tue, 11 Mar 2014 13:21:25 +0100 [thread overview]
Message-ID: <531EFFC5.6040007@xs4all.nl> (raw)
In-Reply-To: <1394526833-24805-8-git-send-email-archit@ti.com>
Hi Archit,
A few small comments below...
On 03/11/14 09:33, Archit Taneja wrote:
> Add selection ioctl ops. For VPE, cropping makes sense only for the input to
> VPE(or V4L2_BUF_TYPE_VIDEO_OUTPUT/MPLANE buffers) and composing makes sense
> only for the output of VPE(or V4L2_BUF_TYPE_VIDEO_CAPTURE/MPLANE buffers).
>
> For the CAPTURE type, V4L2_SEL_TGT_COMPOSE results in VPE writing the output
> in a rectangle within the capture buffer. For the OUTPUT type, V4L2_SEL_TGT_CROP
> results in selecting a rectangle region within the source buffer.
>
> Setting the crop/compose rectangles should successfully result in
> re-configuration of registers which are affected when either source or
> destination dimensions change, set_srcdst_params() is called for this purpose.
>
> Signed-off-by: Archit Taneja <archit@ti.com>
> ---
> drivers/media/platform/ti-vpe/vpe.c | 141 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 141 insertions(+)
>
> diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
> index ece9b96..4abb85c 100644
> --- a/drivers/media/platform/ti-vpe/vpe.c
> +++ b/drivers/media/platform/ti-vpe/vpe.c
> @@ -410,8 +410,10 @@ static struct vpe_q_data *get_q_data(struct vpe_ctx *ctx,
> {
> switch (type) {
> case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
> + case V4L2_BUF_TYPE_VIDEO_OUTPUT:
> return &ctx->q_data[Q_DATA_SRC];
> case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
> + case V4L2_BUF_TYPE_VIDEO_CAPTURE:
> return &ctx->q_data[Q_DATA_DST];
> default:
> BUG();
> @@ -1587,6 +1589,142 @@ static int vpe_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
> return set_srcdst_params(ctx);
> }
>
> +static int __vpe_try_selection(struct vpe_ctx *ctx, struct v4l2_selection *s)
> +{
> + struct vpe_q_data *q_data;
> +
> + if ((s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
> + (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT))
> + return -EINVAL;
> +
> + q_data = get_q_data(ctx, s->type);
> + if (!q_data)
> + return -EINVAL;
> +
> + switch (s->target) {
> + case V4L2_SEL_TGT_COMPOSE:
> + /*
> + * COMPOSE target is only valid for capture buffer type, for
> + * output buffer type, assign existing crop parameters to the
> + * selection rectangle
> + */
> + if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
> + break;
Shouldn't this return -EINVAL?
> +
> + s->r = q_data->c_rect;
> + return 0;
> +
> + case V4L2_SEL_TGT_CROP:
> + /*
> + * CROP target is only valid for output buffer type, for capture
> + * buffer type, assign existing compose parameters to the
> + * selection rectangle
> + */
> + if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
> + break;
Ditto.
> +
> + s->r = q_data->c_rect;
> + return 0;
> +
> + /*
> + * bound and default crop/compose targets are invalid targets to
> + * try/set
> + */
> + default:
> + return -EINVAL;
> + }
> +
> + if (s->r.top < 0 || s->r.left < 0) {
> + vpe_err(ctx->dev, "negative values for top and left\n");
> + s->r.top = s->r.left = 0;
> + }
> +
> + v4l_bound_align_image(&s->r.width, MIN_W, q_data->width, 1,
> + &s->r.height, MIN_H, q_data->height, H_ALIGN, S_ALIGN);
> +
> + /* adjust left/top if cropping rectangle is out of bounds */
> + if (s->r.left + s->r.width > q_data->width)
> + s->r.left = q_data->width - s->r.width;
> + if (s->r.top + s->r.height > q_data->height)
> + s->r.top = q_data->height - s->r.height;
> +
> + return 0;
> +}
> +
> +static int vpe_g_selection(struct file *file, void *fh,
> + struct v4l2_selection *s)
> +{
> + struct vpe_ctx *ctx = file2ctx(file);
> + struct vpe_q_data *q_data;
> +
> + if ((s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
> + (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT))
> + return -EINVAL;
> +
> + q_data = get_q_data(ctx, s->type);
> + if (!q_data)
> + return -EINVAL;
> +
> + switch (s->target) {
> + /* return width and height from S_FMT of the respective buffer type */
> + case V4L2_SEL_TGT_COMPOSE_DEFAULT:
> + case V4L2_SEL_TGT_COMPOSE_BOUNDS:
> + case V4L2_SEL_TGT_CROP_BOUNDS:
> + case V4L2_SEL_TGT_CROP_DEFAULT:
> + s->r.left = 0;
> + s->r.top = 0;
> + s->r.width = q_data->width;
> + s->r.height = q_data->height;
The crop targets only make sense for type OUTPUT and the compose only for
type CAPTURE. Add some checks for that.
> + return 0;
> +
> + /*
> + * CROP target holds for the output buffer type, and COMPOSE target
> + * holds for the capture buffer type. We still return the c_rect params
> + * for both the target types.
> + */
> + case V4L2_SEL_TGT_COMPOSE:
> + case V4L2_SEL_TGT_CROP:
> + s->r.left = q_data->c_rect.left;
> + s->r.top = q_data->c_rect.top;
> + s->r.width = q_data->c_rect.width;
> + s->r.height = q_data->c_rect.height;
> + return 0;
> + }
> +
> + return -EINVAL;
> +}
> +
> +
> +static int vpe_s_selection(struct file *file, void *fh,
> + struct v4l2_selection *s)
> +{
> + struct vpe_ctx *ctx = file2ctx(file);
> + struct vpe_q_data *q_data;
> + struct v4l2_selection sel = *s;
> + int ret;
> +
> + ret = __vpe_try_selection(ctx, &sel);
> + if (ret)
> + return ret;
> +
> + q_data = get_q_data(ctx, sel.type);
> + if (!q_data)
> + return -EINVAL;
> +
> + if ((q_data->c_rect.left == sel.r.left) &&
> + (q_data->c_rect.top == sel.r.top) &&
> + (q_data->c_rect.width == sel.r.width) &&
> + (q_data->c_rect.height == sel.r.height)) {
> + vpe_dbg(ctx->dev,
> + "requested crop/compose values are already set\n");
> + return 0;
> + }
> +
> + q_data->c_rect = sel.r;
> +
> + return set_srcdst_params(ctx);
> +}
> +
> static int vpe_reqbufs(struct file *file, void *priv,
> struct v4l2_requestbuffers *reqbufs)
> {
> @@ -1674,6 +1812,9 @@ static const struct v4l2_ioctl_ops vpe_ioctl_ops = {
> .vidioc_try_fmt_vid_out_mplane = vpe_try_fmt,
> .vidioc_s_fmt_vid_out_mplane = vpe_s_fmt,
>
> + .vidioc_g_selection = vpe_g_selection,
> + .vidioc_s_selection = vpe_s_selection,
> +
> .vidioc_reqbufs = vpe_reqbufs,
> .vidioc_querybuf = vpe_querybuf,
>
>
next prev parent reply other threads:[~2014-03-11 12:22 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-03 7:33 [PATCH 0/7] v4l: ti-vpe: Some VPE fixes and enhancements Archit Taneja
2014-03-03 7:33 ` [PATCH 1/7] v4l: ti-vpe: Make sure in job_ready that we have the needed number of dst_bufs Archit Taneja
2014-03-03 7:33 ` [PATCH 2/7] v4l: ti-vpe: register video device only when firmware is loaded Archit Taneja
2014-03-03 7:33 ` [PATCH 3/7] v4l: ti-vpe: Use video_device_release_empty Archit Taneja
2014-03-03 7:33 ` [PATCH 4/7] v4l: ti-vpe: Allow DMABUF buffer type support Archit Taneja
2014-03-03 7:33 ` [PATCH 5/7] v4l: ti-vpe: Allow usage of smaller images Archit Taneja
2014-03-03 12:14 ` Kamil Debski
2014-03-03 12:41 ` Archit Taneja
2014-03-03 7:33 ` [PATCH 6/7] v4l: ti-vpe: Fix some params in VPE data descriptors Archit Taneja
2014-03-03 7:33 ` [PATCH 7/7] v4l: ti-vpe: Add crop support in VPE driver Archit Taneja
2014-03-03 7:50 ` Hans Verkuil
2014-03-03 8:26 ` Archit Taneja
2014-03-03 12:21 ` Kamil Debski
2014-03-03 12:36 ` Archit Taneja
2014-03-04 7:38 ` Archit Taneja
2014-03-04 7:43 ` Hans Verkuil
2014-03-04 8:26 ` Archit Taneja
2014-03-04 8:49 ` [PATCH v2 0/7] v4l: ti-vpe: Some VPE fixes and enhancements Archit Taneja
2014-03-04 8:49 ` [PATCH v2 1/7] v4l: ti-vpe: Make sure in job_ready that we have the needed number of dst_bufs Archit Taneja
2014-03-04 8:49 ` [PATCH v2 2/7] v4l: ti-vpe: register video device only when firmware is loaded Archit Taneja
2014-03-04 8:49 ` [PATCH v2 3/7] v4l: ti-vpe: Use video_device_release_empty Archit Taneja
2014-03-04 8:49 ` [PATCH v2 4/7] v4l: ti-vpe: Allow DMABUF buffer type support Archit Taneja
2014-03-04 8:49 ` [PATCH v2 5/7] v4l: ti-vpe: Allow usage of smaller images Archit Taneja
2014-03-04 8:49 ` [PATCH v2 6/7] v4l: ti-vpe: Fix some params in VPE data descriptors Archit Taneja
2014-03-04 8:49 ` [PATCH v2 7/7] v4l: ti-vpe: Add selection API in VPE driver Archit Taneja
2014-03-04 9:40 ` Hans Verkuil
2014-03-04 11:25 ` Archit Taneja
2014-03-04 11:35 ` Hans Verkuil
2014-03-07 11:50 ` Archit Taneja
2014-03-07 12:59 ` Hans Verkuil
2014-03-07 13:22 ` Archit Taneja
2014-03-07 13:32 ` Hans Verkuil
2014-03-07 13:47 ` Archit Taneja
2014-03-10 12:12 ` Archit Taneja
2014-03-10 12:33 ` Hans Verkuil
2014-03-04 13:28 ` Kamil Debski
2014-03-11 8:33 ` [PATCH v3 00/14] v4l: ti-vpe: Some VPE fixes and enhancements Archit Taneja
2014-03-11 8:33 ` [PATCH v3 01/14] v4l: ti-vpe: Make sure in job_ready that we have the needed number of dst_bufs Archit Taneja
2014-03-13 14:36 ` Kamil Debski
2014-03-11 8:33 ` [PATCH v3 02/14] v4l: ti-vpe: register video device only when firmware is loaded Archit Taneja
2014-03-13 11:48 ` Kamil Debski
2014-03-13 12:09 ` Archit Taneja
2014-03-13 14:29 ` Kamil Debski
2014-03-14 9:51 ` Archit Taneja
2014-03-11 8:33 ` [PATCH v3 03/14] v4l: ti-vpe: Use video_device_release_empty Archit Taneja
2014-03-11 12:02 ` Hans Verkuil
2014-03-11 8:33 ` [PATCH v3 04/14] v4l: ti-vpe: Allow DMABUF buffer type support Archit Taneja
2014-03-11 12:03 ` Hans Verkuil
2014-03-11 8:33 ` [PATCH v3 05/14] v4l: ti-vpe: Allow usage of smaller images Archit Taneja
2014-03-11 12:03 ` Hans Verkuil
2014-03-11 8:33 ` [PATCH v3 06/14] v4l: ti-vpe: Fix some params in VPE data descriptors Archit Taneja
2014-03-11 8:33 ` [PATCH v3 07/14] v4l: ti-vpe: Add selection API in VPE driver Archit Taneja
2014-03-11 12:21 ` Hans Verkuil [this message]
2014-03-11 12:46 ` Archit Taneja
2014-03-11 12:49 ` Hans Verkuil
2014-03-11 13:10 ` Archit Taneja
2014-03-11 8:33 ` [PATCH v3 08/14] v4l: ti-vpe: Rename csc memory resource name Archit Taneja
2014-03-11 8:33 ` [PATCH v3 09/14] v4l: ti-vpe: report correct capabilities in querycap Archit Taneja
2014-03-11 12:23 ` Hans Verkuil
2014-03-11 8:33 ` [PATCH v3 10/14] v4l: ti-vpe: Use correct bus_info name for the device " Archit Taneja
2014-03-11 12:23 ` Hans Verkuil
2014-03-11 8:33 ` [PATCH v3 11/14] v4l: ti-vpe: Fix initial configuration queue data Archit Taneja
2014-03-11 12:24 ` Hans Verkuil
2014-03-11 8:33 ` [PATCH v3 12/14] v4l: ti-vpe: zero out reserved fields in try_fmt Archit Taneja
2014-03-11 12:25 ` Hans Verkuil
2014-03-11 8:33 ` [PATCH v3 13/14] v4l: ti-vpe: Set correct field parameter for output and capture buffers Archit Taneja
2014-03-11 12:29 ` Hans Verkuil
2014-03-11 8:33 ` [PATCH v3 14/14] v4l: ti-vpe: retain v4l2_buffer flags for captured buffers Archit Taneja
2014-03-11 12:31 ` Hans Verkuil
2014-03-13 11:44 ` [PATCH v4 00/14] v4l: ti-vpe: Some VPE fixes and enhancements Archit Taneja
2014-03-13 11:44 ` [PATCH v4 01/14] v4l: ti-vpe: Make sure in job_ready that we have the needed number of dst_bufs Archit Taneja
2014-03-13 14:38 ` Kamil Debski
2014-03-13 11:44 ` [PATCH v4 02/14] v4l: ti-vpe: register video device only when firmware is loaded Archit Taneja
2014-03-13 11:44 ` [PATCH v4 03/14] v4l: ti-vpe: Use video_device_release_empty Archit Taneja
2014-03-13 11:44 ` [PATCH v4 04/14] v4l: ti-vpe: Allow DMABUF buffer type support Archit Taneja
2014-03-13 11:44 ` [PATCH v4 05/14] v4l: ti-vpe: Allow usage of smaller images Archit Taneja
2014-03-13 11:44 ` [PATCH v4 06/14] v4l: ti-vpe: Fix some params in VPE data descriptors Archit Taneja
2014-03-13 15:01 ` Kamil Debski
2014-03-13 11:44 ` [PATCH v4 07/14] v4l: ti-vpe: Add selection API in VPE driver Archit Taneja
2014-03-13 11:44 ` [PATCH v4 08/14] v4l: ti-vpe: Rename csc memory resource name Archit Taneja
2014-03-13 14:44 ` Kamil Debski
2014-03-14 6:18 ` Archit Taneja
2014-03-13 11:44 ` [PATCH v4 09/14] v4l: ti-vpe: report correct capabilities in querycap Archit Taneja
2014-03-13 11:44 ` [PATCH v4 10/14] v4l: ti-vpe: Use correct bus_info name for the device " Archit Taneja
2014-03-13 11:44 ` [PATCH v4 11/14] v4l: ti-vpe: Fix initial configuration queue data Archit Taneja
2014-03-13 11:44 ` [PATCH v4 12/14] v4l: ti-vpe: zero out reserved fields in try_fmt Archit Taneja
2014-03-13 11:44 ` [PATCH v4 13/14] v4l: ti-vpe: Set correct field parameter for output and capture buffers Archit Taneja
2014-03-13 11:44 ` [PATCH v4 14/14] v4l: ti-vpe: retain v4l2_buffer flags for captured buffers Archit Taneja
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=531EFFC5.6040007@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=archit@ti.com \
--cc=k.debski@samsung.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox