OSDN Git Service

media: atomisp: implement enum framesize/frameinterval
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 11 Nov 2021 11:04:31 +0000 (11:04 +0000)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 16 Nov 2021 14:37:09 +0000 (14:37 +0000)
Add logic to enumerate sensor's frame size and interval.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_ioctl.c

index 2fb64d5..b2d3b83 100644 (file)
@@ -766,6 +766,57 @@ error:
        return ret;
 }
 
+static int atomisp_enum_framesizes(struct file *file, void *priv,
+                                  struct v4l2_frmsizeenum *fsize)
+{
+       struct video_device *vdev = video_devdata(file);
+       struct atomisp_device *isp = video_get_drvdata(vdev);
+       struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
+       struct v4l2_subdev_frame_size_enum fse = {
+               .index = fsize->index,
+               .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+       };
+       int ret;
+
+       ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
+                              pad, enum_frame_size, NULL, &fse);
+       if (ret)
+               return ret;
+
+       fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+       fsize->discrete.width = fse.max_width - pad_w;
+       fsize->discrete.height = fse.max_height - pad_h;
+
+       return 0;
+}
+
+static int atomisp_enum_frameintervals(struct file *file, void *priv,
+                                      struct v4l2_frmivalenum *fival)
+{
+       struct video_device *vdev = video_devdata(file);
+       struct atomisp_device *isp = video_get_drvdata(vdev);
+       struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
+       struct v4l2_subdev_frame_interval_enum fie = {
+               .code   = atomisp_in_fmt_conv[0].code,
+               .index = fival->index,
+               .width = fival->width,
+               .height = fival->height,
+               .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+       };
+       int ret;
+
+       ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
+                              pad, enum_frame_interval, NULL,
+                              &fie);
+       if (ret)
+               return ret;
+
+       fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+       fival->discrete = fie.interval;
+
+       return ret;
+}
+
 static int atomisp_enum_fmt_cap(struct file *file, void *fh,
                                struct v4l2_fmtdesc *f)
 {
@@ -3214,6 +3265,8 @@ const struct v4l2_ioctl_ops atomisp_ioctl_ops = {
        .vidioc_g_ctrl = atomisp_g_ctrl,
        .vidioc_s_ext_ctrls = atomisp_s_ext_ctrls,
        .vidioc_g_ext_ctrls = atomisp_g_ext_ctrls,
+       .vidioc_enum_framesizes   = atomisp_enum_framesizes,
+       .vidioc_enum_frameintervals = atomisp_enum_frameintervals,
        .vidioc_enum_fmt_vid_cap = atomisp_enum_fmt_cap,
        .vidioc_try_fmt_vid_cap = atomisp_try_fmt_cap,
        .vidioc_g_fmt_vid_cap = atomisp_g_fmt_cap,