From e168c156afdca6891beb92b6db73795ced2d8250 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Mon, 27 Apr 2015 15:38:32 +0900 Subject: [PATCH] CHROMIUM: [media] rk3288-vpu: Implement VIDIOC_ENUM_FRAMESIZES This patch adds implementations of VIDIOC_ENUM_FRAMESIZES for rk3288-vpu encoder and decoder devices. This IOCTL lets the userspace learn about frame size limits of the hardware. BUG=chromium:485409 TEST=vda/veatests, Chrome with crrev.com/1097913002. Signed-off-by: Tomasz Figa Reviewed-on: https://chromium-review.googlesource.com/269867 Reviewed-by: Heng-ruey Hsu Change-Id: Ia23a89c2f380b16cc7ef8338d33946d62f8a68fe Signed-off-by: Jeffy Chen Signed-off-by: Yakir Yang --- .../platform/rk3288-vpu/rk3288_vpu_dec.c | 32 +++++++++++++++++++ .../platform/rk3288-vpu/rk3288_vpu_enc.c | 32 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c b/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c index f7c3725ec0c8..3d4aad957a1e 100644 --- a/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c +++ b/drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c @@ -178,6 +178,37 @@ static int vidioc_querycap(struct file *file, void *priv, return 0; } +static int vidioc_enum_framesizes(struct file *file, void *prov, + struct v4l2_frmsizeenum *fsize) +{ + struct v4l2_frmsize_stepwise *s = &fsize->stepwise; + struct rk3288_vpu_fmt *fmt; + + if (fsize->index != 0) { + vpu_debug(0, "invalid frame size index (expected 0, got %d)\n", + fsize->index); + return -EINVAL; + } + + fmt = find_format(fsize->pixel_format, true); + if (!fmt) { + vpu_debug(0, "unsupported bitstream format (%08x)\n", + fsize->pixel_format); + return -EINVAL; + } + + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; + + s->min_width = RK3288_DEC_MIN_WIDTH; + s->max_width = RK3288_DEC_MAX_WIDTH; + s->step_width = MB_DIM; + s->min_height = RK3288_DEC_MIN_HEIGHT; + s->max_height = RK3288_DEC_MAX_HEIGHT; + s->step_height = MB_DIM; + + return 0; +} + static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool out) { struct rk3288_vpu_fmt *fmt; @@ -767,6 +798,7 @@ static const struct v4l2_ctrl_ops rk3288_vpu_dec_ctrl_ops = { static const struct v4l2_ioctl_ops rk3288_vpu_dec_ioctl_ops = { .vidioc_querycap = vidioc_querycap, + .vidioc_enum_framesizes = vidioc_enum_framesizes, .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt, diff --git a/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c b/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c index 00e6cacc0043..c3234ddfb452 100644 --- a/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c +++ b/drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c @@ -370,6 +370,37 @@ static int vidioc_querycap(struct file *file, void *priv, return 0; } +static int vidioc_enum_framesizes(struct file *file, void *prov, + struct v4l2_frmsizeenum *fsize) +{ + struct v4l2_frmsize_stepwise *s = &fsize->stepwise; + struct rk3288_vpu_fmt *fmt; + + if (fsize->index != 0) { + vpu_debug(0, "invalid frame size index (expected 0, got %d)\n", + fsize->index); + return -EINVAL; + } + + fmt = find_format(fsize->pixel_format, true); + if (!fmt) { + vpu_debug(0, "unsupported bitstream format (%08x)\n", + fsize->pixel_format); + return -EINVAL; + } + + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; + + s->min_width = RK3288_ENC_MIN_WIDTH; + s->max_width = RK3288_ENC_MAX_WIDTH; + s->step_width = MB_DIM; + s->min_height = RK3288_ENC_MIN_HEIGHT; + s->max_height = RK3288_ENC_MAX_HEIGHT; + s->step_height = MB_DIM; + + return 0; +} + static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool out) { struct rk3288_vpu_fmt *fmt; @@ -999,6 +1030,7 @@ out: static const struct v4l2_ioctl_ops rk3288_vpu_enc_ioctl_ops = { .vidioc_querycap = vidioc_querycap, + .vidioc_enum_framesizes = vidioc_enum_framesizes, .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap_mplane, .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out_mplane, .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt, -- 2.34.1