CHROMIUM: [media] rk3288-vpu: Implement VIDIOC_ENUM_FRAMESIZES
authorTomasz Figa <tfiga@chromium.org>
Mon, 27 Apr 2015 06:38:32 +0000 (15:38 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 30 Jun 2016 11:54:49 +0000 (19:54 +0800)
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 <tfiga@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/269867
Reviewed-by: Heng-ruey Hsu <henryhsu@google.com>
Change-Id: Ia23a89c2f380b16cc7ef8338d33946d62f8a68fe
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Yakir Yang <ykk@rock-chips.com>
drivers/media/platform/rk3288-vpu/rk3288_vpu_dec.c
drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c

index f7c3725ec0c821b89bc212f542c6565e709e467d..3d4aad957a1e4b2f7f5a0afb6810a4a0e951a332 100644 (file)
@@ -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,
index 00e6cacc00436f40764f77d1fa1b4e0b0307663f..c3234ddfb452e4fb051976effca214a5bbe2acd0 100644 (file)
@@ -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,