From patchwork Tue Dec 1 15:39:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 2226 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Tue, 01 Dec 2009 15:40:32 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.6) for (single-drop); Tue, 01 Dec 2009 13:40:37 -0200 (BRST) Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NFUq7-0004aX-Ti; Tue, 01 Dec 2009 15:40:32 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753570AbZLAPkX (ORCPT + 1 other); Tue, 1 Dec 2009 10:40:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751944AbZLAPkX (ORCPT ); Tue, 1 Dec 2009 10:40:23 -0500 Received: from smtp-out113.alice.it ([85.37.17.113]:2438 "EHLO smtp-out113.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752753AbZLAPkX (ORCPT ); Tue, 1 Dec 2009 10:40:23 -0500 Received: from fbcmmo06.fbc.local ([192.168.184.137]) by smtp-out113.alice.it with Microsoft SMTPSVC(6.0.3790.3959); Tue, 1 Dec 2009 16:40:26 +0100 Received: from FBCMCL01B06.fbc.local ([192.168.69.87]) by fbcmmo06.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Tue, 1 Dec 2009 16:40:25 +0100 Received: from badebec ([87.3.192.22]) by FBCMCL01B06.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Tue, 1 Dec 2009 16:40:24 +0100 Received: by badebec with local (Exim 4.69) (envelope-from ) id 1NFUph-0002k9-FI; Tue, 01 Dec 2009 16:40:05 +0100 From: Antonio Ospite To: linux-media@vger.kernel.org Cc: Antonio Ospite , Jean-Francois Moine , Max Thrun , Hans de Goede Subject: [PATCH] gspca: implement vidioc_enum_frameintervals Date: Tue, 1 Dec 2009 16:39:31 +0100 Message-Id: <1259681971-10504-1-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.6.5.3 In-Reply-To: <20091117114147.09889427.ospite@studenti.unina.it> References: <20091117114147.09889427.ospite@studenti.unina.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE X-OriginalArrivalTime: 01 Dec 2009 15:40:25.0032 (UTC) FILETIME=[99905C80:01CA729C] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Some drivers support multiple frameintervals (framerates), make gspca able to enumerate them. Signed-off-by: Antonio Ospite --- Changes since the initial RFC version: - 'i' is now a __u32 and the variable 'index' has been dropped. - some more comments in gspca.h Thanks to Hans de Goede for the review. For now I am postponing the patch to ov534 which uses this one, because I am verifying what the actual framerates supported by the subdriver are. Thanks, Antonio Ospite -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -r 39c1be9a2ff8 -r ef8cca705478 linux/drivers/media/video/gspca/gspca.c --- a/linux/drivers/media/video/gspca/gspca.c Tue Dec 01 11:20:34 2009 +0100 +++ b/linux/drivers/media/video/gspca/gspca.c Tue Dec 01 13:15:39 2009 +0100 @@ -998,6 +998,34 @@ return -EINVAL; } +static int vidioc_enum_frameintervals(struct file *filp, void *priv, + struct v4l2_frmivalenum *fival) +{ + struct gspca_dev *gspca_dev = priv; + int mode = wxh_to_mode(gspca_dev, fival->width, fival->height); + __u32 i; + + if (gspca_dev->cam.mode_framerates == NULL || + gspca_dev->cam.mode_framerates[mode].nrates == 0) + return -EINVAL; + + if (fival->pixel_format != + gspca_dev->cam.cam_mode[mode].pixelformat) + return -EINVAL; + + for (i = 0; i < gspca_dev->cam.mode_framerates[mode].nrates; i++) { + if (fival->index == i) { + fival->type = V4L2_FRMSIZE_TYPE_DISCRETE; + fival->discrete.numerator = 1; + fival->discrete.denominator = + gspca_dev->cam.mode_framerates[mode].rates[i]; + return 0; + } + } + + return -EINVAL; +} + static void gspca_release(struct video_device *vfd) { struct gspca_dev *gspca_dev = container_of(vfd, struct gspca_dev, vdev); @@ -1990,6 +2018,7 @@ .vidioc_g_parm = vidioc_g_parm, .vidioc_s_parm = vidioc_s_parm, .vidioc_enum_framesizes = vidioc_enum_framesizes, + .vidioc_enum_frameintervals = vidioc_enum_frameintervals, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = vidioc_g_register, .vidioc_s_register = vidioc_s_register, diff -r 39c1be9a2ff8 -r ef8cca705478 linux/drivers/media/video/gspca/gspca.h --- a/linux/drivers/media/video/gspca/gspca.h Tue Dec 01 11:20:34 2009 +0100 +++ b/linux/drivers/media/video/gspca/gspca.h Tue Dec 01 13:15:39 2009 +0100 @@ -45,11 +45,20 @@ /* image transfers */ #define MAX_NURBS 4 /* max number of URBs */ + +/* used to list framerates supported by a camera mode (resolution) */ +struct framerates { + int *rates; + int nrates; +}; + /* device information - set at probe time */ struct cam { int bulk_size; /* buffer size when image transfer by bulk */ const struct v4l2_pix_format *cam_mode; /* size nmodes */ char nmodes; + const struct framerates *mode_framerates; /* must have size nmode, + * just like cam_mode */ __u8 bulk_nurbs; /* number of URBs in bulk mode * - cannot be > MAX_NURBS * - when 0 and bulk_size != 0 means