From e5781c9c9334731651936b84a67a241077a18432 Mon Sep 17 00:00:00 2001 From: Tuukka Toivonen Date: Wed, 13 Jun 2012 14:39:52 +0300 Subject: [PATCH] ov8830: implement VIDIOC_G_PARM for getting stream parameters 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 Reviewed-on: http://android.intel.com:8080/52730 Reviewed-by: Laakso, Antti Reviewed-by: Cohen, David A Reviewed-by: Kontola, Kalervo Reviewed-by: Koski, Anttu Tested-by: Koski, Anttu Reviewed-by: buildbot Tested-by: buildbot --- drivers/media/video/ov8830.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/media/video/ov8830.c b/drivers/media/video/ov8830.c index 4a91fe1..5955679 100644 --- a/drivers/media/video/ov8830.c +++ b/drivers/media/video/ov8830.c @@ -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, }; -- 2.7.4