Commit 3a549bee authored by Tiffany Lin's avatar Tiffany Lin Committed by Mauro Carvalho Chehab

[media] vcodec: mediatek: Add g/s_selection support for V4L2 Encoder

This patch add g/s_selection for MT8173 V4L2 Encoder.
Only output queue support g/s_selection to configure crop.
The top/left of active rectangle should always be (0,0)
Signed-off-by: default avatarTiffany Lin <tiffany.lin@mediatek.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 43c784aa
......@@ -631,6 +631,69 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
return vidioc_try_fmt(f, fmt);
}
static int vidioc_venc_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
struct mtk_q_data *q_data;
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
return -EINVAL;
q_data = mtk_venc_get_q_data(ctx, s->type);
if (!q_data)
return -EINVAL;
switch (s->target) {
case V4L2_SEL_TGT_CROP_DEFAULT:
case V4L2_SEL_TGT_CROP_BOUNDS:
s->r.top = 0;
s->r.left = 0;
s->r.width = q_data->coded_width;
s->r.height = q_data->coded_height;
break;
case V4L2_SEL_TGT_CROP:
s->r.top = 0;
s->r.left = 0;
s->r.width = q_data->visible_width;
s->r.height = q_data->visible_height;
break;
default:
return -EINVAL;
}
return 0;
}
static int vidioc_venc_s_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
struct mtk_q_data *q_data;
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
return -EINVAL;
q_data = mtk_venc_get_q_data(ctx, s->type);
if (!q_data)
return -EINVAL;
switch (s->target) {
case V4L2_SEL_TGT_CROP:
/* Only support crop from (0,0) */
s->r.top = 0;
s->r.left = 0;
s->r.width = min(s->r.width, q_data->coded_width);
s->r.height = min(s->r.height, q_data->coded_height);
q_data->visible_width = s->r.width;
q_data->visible_height = s->r.height;
break;
default:
return -EINVAL;
}
return 0;
}
static int vidioc_venc_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
......@@ -689,6 +752,9 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = {
.vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs,
.vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
.vidioc_g_selection = vidioc_venc_g_selection,
.vidioc_s_selection = vidioc_venc_s_selection,
};
static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment