ov8830: implement VIDIOC_G_PARM for getting stream parameters
authorTuukka Toivonen <tuukka.toivonen@intel.com>
Wed, 13 Jun 2012 11:39:52 +0000 (14:39 +0300)
committerbuildbot <buildbot@intel.com>
Wed, 20 Jun 2012 13:50:20 +0000 (06:50 -0700)
BZ: 41720

Implement function to return struct v4l2_streamparm and call this
function from VIDIOC_S_PARM handler to fill the returned
structure. Also clear sensor mode parameters when streaming mode
is set. The sensor mode should be selected after the streaming mode
has been set.

Change-Id: I8fcac0925db91a9a691f5cb126e9fc992827bf2b
Signed-off-by: Tuukka Toivonen <tuukka.toivonen@intel.com>
Reviewed-on: http://android.intel.com:8080/52730
Reviewed-by: Laakso, Antti <antti.laakso@intel.com>
Reviewed-by: Cohen, David A <david.a.cohen@intel.com>
Reviewed-by: Kontola, Kalervo <kalervo.kontola@intel.com>
Reviewed-by: Koski, Anttu <anttu.koski@intel.com>
Tested-by: Koski, Anttu <anttu.koski@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/media/video/ov8830.c

index 4a91fe1..5955679 100644 (file)
@@ -2796,10 +2796,33 @@ ov8830_set_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
 }
 
 static int
+ov8830_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
+{
+       struct ov8830_device *dev = to_ov8830_sensor(sd);
+       int ret;
+
+       if (param->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+               return -EINVAL;
+
+       memset(param, 0, sizeof(*param));
+
+       param->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       param->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
+       param->parm.capture.capturemode = dev->run_mode;
+       param->parm.capture.timeperframe.numerator = 1;
+       param->parm.capture.timeperframe.denominator =
+                       ov8830_res[dev->fmt_idx].fps;
+       return ret;
+}
+
+static int
 ov8830_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
 {
        struct ov8830_device *dev = to_ov8830_sensor(sd);
 
+       if (param->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+               return -EINVAL;
+
        dev->run_mode = param->parm.capture.capturemode;
 
        switch (dev->run_mode) {
@@ -2815,7 +2838,16 @@ ov8830_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
                ov8830_res = ov8830_res_preview;
                N_RES = N_RES_PREVIEW;
        }
-       return 0;
+
+       /* Reset sensor mode */
+       dev->fmt_idx = 0;
+       dev->fps = ov8830_res[dev->fmt_idx].fps;
+       dev->pixels_per_line = ov8830_res[dev->fmt_idx].pixels_per_line;
+       dev->lines_per_frame = ov8830_res[dev->fmt_idx].lines_per_frame;
+       dev->exposure = 0;
+       dev->gain = 0;
+
+       return ov8830_g_parm(dev, param);
 }
 
 static int
@@ -2871,6 +2903,7 @@ static const struct v4l2_subdev_video_ops ov8830_video_ops = {
        .g_mbus_fmt = ov8830_g_mbus_fmt,
        .s_mbus_fmt = ov8830_s_mbus_fmt,
        .s_parm = ov8830_s_parm,
+       .g_parm = ov8830_g_parm,
        .g_frame_interval = ov8830_g_frame_interval,
 };