diff options
author | Tiffany Lin <tiffany.lin@mediatek.com> | 2016-08-14 22:15:33 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-09-06 15:21:58 -0400 |
commit | 3a549beef9563c9a8f740dcdb002d18879ee91a6 (patch) | |
tree | 954facf3430ea091e74290f908bbc482546cab8c | |
parent | 43c784aab772e9527e2e369f6e1f6d6d1dd63866 (diff) |
[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: Tiffany Lin <tiffany.lin@mediatek.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c index 3ed3f2d31df5..b1f0acbae50b 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | |||
@@ -631,6 +631,69 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv, | |||
631 | return vidioc_try_fmt(f, fmt); | 631 | return vidioc_try_fmt(f, fmt); |
632 | } | 632 | } |
633 | 633 | ||
634 | static int vidioc_venc_g_selection(struct file *file, void *priv, | ||
635 | struct v4l2_selection *s) | ||
636 | { | ||
637 | struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv); | ||
638 | struct mtk_q_data *q_data; | ||
639 | |||
640 | if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) | ||
641 | return -EINVAL; | ||
642 | |||
643 | q_data = mtk_venc_get_q_data(ctx, s->type); | ||
644 | if (!q_data) | ||
645 | return -EINVAL; | ||
646 | |||
647 | switch (s->target) { | ||
648 | case V4L2_SEL_TGT_CROP_DEFAULT: | ||
649 | case V4L2_SEL_TGT_CROP_BOUNDS: | ||
650 | s->r.top = 0; | ||
651 | s->r.left = 0; | ||
652 | s->r.width = q_data->coded_width; | ||
653 | s->r.height = q_data->coded_height; | ||
654 | break; | ||
655 | case V4L2_SEL_TGT_CROP: | ||
656 | s->r.top = 0; | ||
657 | s->r.left = 0; | ||
658 | s->r.width = q_data->visible_width; | ||
659 | s->r.height = q_data->visible_height; | ||
660 | break; | ||
661 | default: | ||
662 | return -EINVAL; | ||
663 | } | ||
664 | |||
665 | return 0; | ||
666 | } | ||
667 | |||
668 | static int vidioc_venc_s_selection(struct file *file, void *priv, | ||
669 | struct v4l2_selection *s) | ||
670 | { | ||
671 | struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv); | ||
672 | struct mtk_q_data *q_data; | ||
673 | |||
674 | if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) | ||
675 | return -EINVAL; | ||
676 | |||
677 | q_data = mtk_venc_get_q_data(ctx, s->type); | ||
678 | if (!q_data) | ||
679 | return -EINVAL; | ||
680 | |||
681 | switch (s->target) { | ||
682 | case V4L2_SEL_TGT_CROP: | ||
683 | /* Only support crop from (0,0) */ | ||
684 | s->r.top = 0; | ||
685 | s->r.left = 0; | ||
686 | s->r.width = min(s->r.width, q_data->coded_width); | ||
687 | s->r.height = min(s->r.height, q_data->coded_height); | ||
688 | q_data->visible_width = s->r.width; | ||
689 | q_data->visible_height = s->r.height; | ||
690 | break; | ||
691 | default: | ||
692 | return -EINVAL; | ||
693 | } | ||
694 | return 0; | ||
695 | } | ||
696 | |||
634 | static int vidioc_venc_qbuf(struct file *file, void *priv, | 697 | static int vidioc_venc_qbuf(struct file *file, void *priv, |
635 | struct v4l2_buffer *buf) | 698 | struct v4l2_buffer *buf) |
636 | { | 699 | { |
@@ -689,6 +752,9 @@ const struct v4l2_ioctl_ops mtk_venc_ioctl_ops = { | |||
689 | 752 | ||
690 | .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, | 753 | .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, |
691 | .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, | 754 | .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf, |
755 | |||
756 | .vidioc_g_selection = vidioc_venc_g_selection, | ||
757 | .vidioc_s_selection = vidioc_venc_s_selection, | ||
692 | }; | 758 | }; |
693 | 759 | ||
694 | static int vb2ops_venc_queue_setup(struct vb2_queue *vq, | 760 | static int vb2ops_venc_queue_setup(struct vb2_queue *vq, |