From patchwork Fri Sep 24 17:17:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 206942 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8OISSA2016693 for ; Fri, 24 Sep 2010 18:28:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757379Ab0IXS2Z (ORCPT ); Fri, 24 Sep 2010 14:28:25 -0400 Received: from queueout02-winn.ispmail.ntl.com ([81.103.221.56]:63822 "EHLO queueout02-winn.ispmail.ntl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757297Ab0IXS2Y (ORCPT ); Fri, 24 Sep 2010 14:28:24 -0400 Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20100924171731.MSCY3075.mtaout03-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com>; Fri, 24 Sep 2010 18:17:31 +0100 Received: from zog.reactivated.net ([86.14.215.141]) by aamtaout01-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20100924171731.ZZII16999.aamtaout01-winn.ispmail.ntl.com@zog.reactivated.net>; Fri, 24 Sep 2010 18:17:31 +0100 Received: by zog.reactivated.net (Postfix, from userid 1000) id 351469D401C; Fri, 24 Sep 2010 18:17:29 +0100 (BST) From: Daniel Drake To: mchehab@infradead.org Cc: linux-media@vger.kernel.org Cc: corbet@lwn.net Subject: [PATCH 2/4] ov7670: implement VIDIOC_ENUM_FRAMEINTERVALS Message-Id: <20100924171729.351469D401C@zog.reactivated.net> Date: Fri, 24 Sep 2010 18:17:29 +0100 (BST) X-Cloudmark-Analysis: v=1.1 cv=DhNl2YeytwJssBBGe49HJX82LNDFEEVkpVB34RXKaPo= c=1 sm=0 a=F3r0a3_iygEA:10 a=07d9gI8wAAAA:8 a=Op-mwl0xAAAA:8 a=tMOB236v5cG_6y4KpGgA:9 a=MCs42Ttfzul6aZRwZRvePcYz4KgA:4 a=6fZZb_PjwVMA:10 a=d4CUUju0HPYA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 24 Sep 2010 18:28:28 +0000 (UTC) diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c index 91c886a..f551f63 100644 --- a/drivers/media/video/ov7670.c +++ b/drivers/media/video/ov7670.c @@ -896,14 +896,28 @@ static int ov7670_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms) } - /* - * Code for dealing with controls. + * Frame intervals. Since frame rates are controlled with the clock + * divider, we can only do 30/n for integer n values. So no continuous + * or stepwise options. Here we just pick a handful of logical values. */ +static int ov7670_frame_rates[] = { 30, 15, 10, 5, 1 }; +static int ov7670_enum_frameintervals(struct v4l2_subdev *sd, + struct v4l2_frmivalenum *interval) +{ + if (interval->index >= ARRAY_SIZE(ov7670_frame_rates)) + return -EINVAL; + interval->type = V4L2_FRMIVAL_TYPE_DISCRETE; + interval->discrete.numerator = 1; + interval->discrete.denominator = ov7670_frame_rates[interval->index]; + return 0; +} - +/* + * Code for dealing with controls. + */ static int ov7670_store_cmatrix(struct v4l2_subdev *sd, int matrix[CMATRIX_LEN]) @@ -1447,6 +1461,7 @@ static const struct v4l2_subdev_video_ops ov7670_video_ops = { .s_fmt = ov7670_s_fmt, .s_parm = ov7670_s_parm, .g_parm = ov7670_g_parm, + .enum_frameintervals = ov7670_enum_frameintervals, }; static const struct v4l2_subdev_ops ov7670_ops = {