From patchwork Sat Jan 8 11:01:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 465601 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 p08IFLMm030341 for ; Sat, 8 Jan 2011 18:15:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751964Ab1AHLCN (ORCPT ); Sat, 8 Jan 2011 06:02:13 -0500 Received: from smtp-vbr18.xs4all.nl ([194.109.24.38]:1436 "EHLO smtp-vbr18.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751628Ab1AHLCF (ORCPT ); Sat, 8 Jan 2011 06:02:05 -0500 Received: from localhost.localdomain (43.80-203-71.nextgentel.com [80.203.71.43]) (authenticated bits=0) by smtp-vbr18.xs4all.nl (8.13.8/8.13.8) with ESMTP id p08B1oMj099687 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 8 Jan 2011 12:02:02 +0100 (CET) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Jonathan Corbet , Laurent Pinchart Subject: [RFCv2 PATCH 5/5] cafe_ccic: implement the control framework. Date: Sat, 8 Jan 2011 12:01:48 +0100 Message-Id: X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1294484508-14820-1-git-send-email-hverkuil@xs4all.nl> References: <1294484508-14820-1-git-send-email-hverkuil@xs4all.nl> In-Reply-To: References: X-Virus-Scanned: by XS4ALL Virus Scanner 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.6 (demeter1.kernel.org [140.211.167.41]); Sat, 08 Jan 2011 18:15:23 +0000 (UTC) diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c index 7488b47..44ec342 100644 --- a/drivers/media/video/cafe_ccic.c +++ b/drivers/media/video/cafe_ccic.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -145,6 +146,7 @@ struct cafe_sio_buffer { struct cafe_camera { struct v4l2_device v4l2_dev; + struct v4l2_ctrl_handler ctrl_handler; enum cafe_state state; unsigned long flags; /* Buffer status, mainly (dev_lock) */ int users; /* How many open FDs */ @@ -1466,48 +1468,6 @@ static unsigned int cafe_v4l_poll(struct file *filp, -static int cafe_vidioc_queryctrl(struct file *filp, void *priv, - struct v4l2_queryctrl *qc) -{ - struct cafe_camera *cam = priv; - int ret; - - mutex_lock(&cam->s_mutex); - ret = sensor_call(cam, core, queryctrl, qc); - mutex_unlock(&cam->s_mutex); - return ret; -} - - -static int cafe_vidioc_g_ctrl(struct file *filp, void *priv, - struct v4l2_control *ctrl) -{ - struct cafe_camera *cam = priv; - int ret; - - mutex_lock(&cam->s_mutex); - ret = sensor_call(cam, core, g_ctrl, ctrl); - mutex_unlock(&cam->s_mutex); - return ret; -} - - -static int cafe_vidioc_s_ctrl(struct file *filp, void *priv, - struct v4l2_control *ctrl) -{ - struct cafe_camera *cam = priv; - int ret; - - mutex_lock(&cam->s_mutex); - ret = sensor_call(cam, core, s_ctrl, ctrl); - mutex_unlock(&cam->s_mutex); - return ret; -} - - - - - static int cafe_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { @@ -1792,9 +1752,6 @@ static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = { .vidioc_dqbuf = cafe_vidioc_dqbuf, .vidioc_streamon = cafe_vidioc_streamon, .vidioc_streamoff = cafe_vidioc_streamoff, - .vidioc_queryctrl = cafe_vidioc_queryctrl, - .vidioc_g_ctrl = cafe_vidioc_g_ctrl, - .vidioc_s_ctrl = cafe_vidioc_s_ctrl, .vidioc_g_parm = cafe_vidioc_g_parm, .vidioc_s_parm = cafe_vidioc_s_parm, .vidioc_enum_framesizes = cafe_vidioc_enum_framesizes, @@ -2031,6 +1988,10 @@ static int cafe_pci_probe(struct pci_dev *pdev, INIT_LIST_HEAD(&cam->sb_avail); INIT_LIST_HEAD(&cam->sb_full); tasklet_init(&cam->s_tasklet, cafe_frame_tasklet, (unsigned long) cam); + ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10); + if (ret) + goto out_unreg; + cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler; /* * Get set up on the PCI bus. */ @@ -2087,10 +2048,10 @@ static int cafe_pci_probe(struct pci_dev *pdev, cam->vdev.debug = 0; /* cam->vdev.debug = V4L2_DEBUG_IOCTL_ARG;*/ cam->vdev.v4l2_dev = &cam->v4l2_dev; + video_set_drvdata(&cam->vdev, cam); ret = video_register_device(&cam->vdev, VFL_TYPE_GRABBER, -1); if (ret) goto out_unlock; - video_set_drvdata(&cam->vdev, cam); /* * If so requested, try to get our DMA buffers now. @@ -2113,9 +2074,10 @@ out_freeirq: free_irq(pdev->irq, cam); out_iounmap: pci_iounmap(pdev, cam->regs); -out_free: - v4l2_device_unregister(&cam->v4l2_dev); out_unreg: + v4l2_ctrl_handler_free(&cam->ctrl_handler); + v4l2_device_unregister(&cam->v4l2_dev); +out_free: kfree(cam); out: return ret; @@ -2154,6 +2116,7 @@ static void cafe_pci_remove(struct pci_dev *pdev) if (cam->users > 0) cam_warn(cam, "Removing a device with users!\n"); cafe_shutdown(cam); + v4l2_ctrl_handler_free(&cam->ctrl_handler); v4l2_device_unregister(&cam->v4l2_dev); kfree(cam); /* No unlock - it no longer exists */