Message ID | 1471011205-17487-1-git-send-email-tiffany.lin@mediatek.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Tiffany, [auto build test WARNING on linuxtv-media/master] [also build test WARNING on v4.8-rc1 next-20160812] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Tiffany-Lin/vcodec-mediatek-Add-g-s_selection-support-for-V4L2-Encoder/20160812-221617 base: git://linuxtv.org/media_tree.git master config: mips-allyesconfig (attached as .config) compiler: mips-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609 reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=mips All warnings (new ones prefixed by >>): drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c: In function 'vidioc_venc_s_selection': >> drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c:673:6: warning: unused variable 'err' [-Wunused-variable] int err; ^ vim +/err +673 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c 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 int err; 674 675 if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) 676 return -EINVAL; 677 678 q_data = mtk_venc_get_q_data(ctx, s->type); 679 if (!q_data) 680 return -EINVAL; 681 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c index 3ed3f2d..0a895e0 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c @@ -631,6 +631,70 @@ 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; + int err; + + 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 +753,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,
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> --- v5: - remove visible_height change to a separate patch v4: - do not return -ERANGE and just select a rectangle that works with the hardware and is closest to the requested rectangle - refine v3 note about remove visible_height modification in s_fmt_out v3: - add v4l2_s_selection to check constraint flags - remove visible_height modification in s_fmt_out, it will make v4l2-compliance test Cropping fail becuase visible_height larger than coded_height. --- drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+)