From patchwork Fri Sep 28 07:48:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 14710 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1THVJI-0002Pz-LV for patchwork@linuxtv.org; Fri, 28 Sep 2012 09:48:32 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-2) with esmtp for id 1THVJI-0001jz-G9; Fri, 28 Sep 2012 09:48:32 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756641Ab2I1Hs2 (ORCPT ); Fri, 28 Sep 2012 03:48:28 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:50863 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755942Ab2I1HsZ (ORCPT ); Fri, 28 Sep 2012 03:48:25 -0400 Received: by weyt9 with SMTP id t9so1147226wey.19 for ; Fri, 28 Sep 2012 00:48:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=IecV+EM52Dr/02285D0Ai2DpF6qE4t3fJ+DbcL7+nOw=; b=JS9Sko1YZF/GNeiVFni2AvhLzJ1YDfVkYvqlKF7SEuVRiVxNjyL16i0O6ZYLJN5m14 8OD9KqJ/HVfdk0Lcpqj8RNkkrRvI+B46rLu1QcYtgcMJsGuN/OgPo8TbjkAVOUE93jH6 6eTO3EKXn9Wmkslrz/8crMURUhNeUMBkpNXyhJYOcV61Wg/xPS4xO2UVE403OZCMOYYE +09ROqTmQCqbJmbfuiptceQdPmdSRl2HD59dLQ6z2Sbp3KuQS4YE7WEMGxADdedrhNg3 iVNTT7Ms4fwSrHfD5+tuN7IN0ijA0eqgTw9FWfIb2quQXHDphg8tiLlmim05h2+Bmz7s oWrQ== Received: by 10.216.227.133 with SMTP id d5mr3122078weq.194.1348818504227; Fri, 28 Sep 2012 00:48:24 -0700 (PDT) Received: from piscis.vsilicon.net (122.251.106.212.dynamic.jazztel.es. [212.106.251.122]) by mx.google.com with ESMTPS id dm3sm17835050wib.3.2012.09.28.00.48.22 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Sep 2012 00:48:23 -0700 (PDT) From: Javier Martin To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, hverkuil@xs4all.nl, rusty@rustcorp.com.au, dsd@laptop.org, mchehab@infradead.org, corbet@lwn.net, hdegoede@redhat.com, Javier Martin Subject: [PATCH 2/3] mcam-core: implement the control framework. Date: Fri, 28 Sep 2012 09:48:02 +0200 Message-Id: <1348818483-3964-3-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348818483-3964-1-git-send-email-javier.martin@vista-silicon.com> References: <1348818483-3964-1-git-send-email-javier.martin@vista-silicon.com> X-Gm-Message-State: ALoCoQlEhVEPFAaF08Jh9hunC2l09vHrr/Df1SyFlM+44PIWD+X3T2MXbtzRKgrknBun8DlD27s7 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.9.28.73916 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_4000_4999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Signed-off-by: Hans Verkuil Signed-off-by: Javier Martin --- drivers/media/platform/marvell-ccic/mcam-core.c | 54 ++++------------------- drivers/media/platform/marvell-ccic/mcam-core.h | 2 + 2 files changed, 11 insertions(+), 45 deletions(-) diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index ce2b7b4..568f8a5 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -1232,47 +1233,6 @@ static int mcam_vidioc_dqbuf(struct file *filp, void *priv, return ret; } - - -static int mcam_vidioc_queryctrl(struct file *filp, void *priv, - struct v4l2_queryctrl *qc) -{ - struct mcam_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 mcam_vidioc_g_ctrl(struct file *filp, void *priv, - struct v4l2_control *ctrl) -{ - struct mcam_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 mcam_vidioc_s_ctrl(struct file *filp, void *priv, - struct v4l2_control *ctrl) -{ - struct mcam_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 mcam_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { @@ -1520,9 +1480,6 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = { .vidioc_dqbuf = mcam_vidioc_dqbuf, .vidioc_streamon = mcam_vidioc_streamon, .vidioc_streamoff = mcam_vidioc_streamoff, - .vidioc_queryctrl = mcam_vidioc_queryctrl, - .vidioc_g_ctrl = mcam_vidioc_g_ctrl, - .vidioc_s_ctrl = mcam_vidioc_s_ctrl, .vidioc_g_parm = mcam_vidioc_g_parm, .vidioc_s_parm = mcam_vidioc_s_parm, .vidioc_enum_framesizes = mcam_vidioc_enum_framesizes, @@ -1786,14 +1743,19 @@ int mccic_register(struct mcam_camera *cam) /* * Get the v4l2 setup done. */ + ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10); + if (ret) + goto out_unregister; + cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler; + mutex_lock(&cam->s_mutex); cam->vdev = mcam_v4l_template; cam->vdev.debug = 0; 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; - video_set_drvdata(&cam->vdev, cam); /* * If so requested, try to get our DMA buffers now. @@ -1805,6 +1767,7 @@ int mccic_register(struct mcam_camera *cam) } out: + v4l2_ctrl_handler_free(&cam->ctrl_handler); mutex_unlock(&cam->s_mutex); return ret; out_unregister: @@ -1829,6 +1792,7 @@ void mccic_shutdown(struct mcam_camera *cam) if (cam->buffer_mode == B_vmalloc) mcam_free_dma_bufs(cam); video_unregister_device(&cam->vdev); + v4l2_ctrl_handler_free(&cam->ctrl_handler); v4l2_device_unregister(&cam->v4l2_dev); } diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h index bd6acba..f7c34ab 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.h +++ b/drivers/media/platform/marvell-ccic/mcam-core.h @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -104,6 +105,7 @@ struct mcam_camera { * should not be touched by the platform code. */ struct v4l2_device v4l2_dev; + struct v4l2_ctrl_handler ctrl_handler; enum mcam_state state; unsigned long flags; /* Buffer status, mainly (dev_lock) */ int users; /* How many open FDs */