From patchwork Sun Feb 7 18:40:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 77627 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o17IdpSO006561 for ; Sun, 7 Feb 2010 18:39:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932809Ab0BGSju (ORCPT ); Sun, 7 Feb 2010 13:39:50 -0500 Received: from smtp.nokia.com ([192.100.122.233]:52379 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932674Ab0BGSjt (ORCPT ); Sun, 7 Feb 2010 13:39:49 -0500 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o17Idicv002870; Sun, 7 Feb 2010 20:39:46 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 7 Feb 2010 20:39:45 +0200 Received: from mgw-sa01.ext.nokia.com ([147.243.1.47]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Sun, 7 Feb 2010 20:39:44 +0200 Received: from maxwell.research.nokia.com (maxwell.research.nokia.com [172.21.50.162]) by mgw-sa01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o17Idh0E007755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 7 Feb 2010 20:39:43 +0200 Received: from lanttu (unknown [192.168.239.74]) by maxwell.research.nokia.com (Postfix) with ESMTPS id 305D37010B; Sun, 7 Feb 2010 20:39:43 +0200 (EET) Received: from sakke by lanttu with local (Exim 4.69) (envelope-from ) id 1NeC3s-00085w-P7; Sun, 07 Feb 2010 20:40:48 +0200 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, iivanov@mm-sol.com, gururaj.nagendra@intel.com, david.cohen@nokia.com, Sakari Ailus Subject: [PATCH v2 3/7] V4L: Events: Support event handling in do_ioctl Date: Sun, 7 Feb 2010 20:40:43 +0200 Message-Id: <1265568047-31073-3-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <4B6F0922.9070206@maxwell.research.nokia.com> References: <4B6F0922.9070206@maxwell.research.nokia.com> X-OriginalArrivalTime: 07 Feb 2010 18:39:44.0631 (UTC) FILETIME=[EADFE070:01CAA824] X-Nokia-AV: Clean 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 (demeter.kernel.org [140.211.167.41]); Sun, 07 Feb 2010 18:39:51 +0000 (UTC) diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index b888ad1..68253d6 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile @@ -11,7 +11,7 @@ stkwebcam-objs := stk-webcam.o stk-sensor.o omap2cam-objs := omap24xxcam.o omap24xxcam-dma.o videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-subdev.o \ - v4l2-fh.o + v4l2-fh.o v4l2-event.o # V4L2 core modules diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index bfc4696..a6d6e73 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -1797,7 +1797,55 @@ static long __video_do_ioctl(struct file *file, } break; } + case VIDIOC_DQEVENT: + { + struct v4l2_event *ev = arg; + + if (!ops->vidioc_dqevent) + break; + + ret = ops->vidioc_dqevent(fh, ev); + if (ret < 0) { + dbgarg(cmd, "no pending events?"); + break; + } + dbgarg(cmd, + "count=%d, type=0x%8.8x, sequence=%d, " + "timestamp=%lu.%9.9lu ", + ev->count, ev->type, ev->sequence, + ev->timestamp.tv_sec, ev->timestamp.tv_nsec); + break; + } + case VIDIOC_SUBSCRIBE_EVENT: + { + struct v4l2_event_subscription *sub = arg; + if (!ops->vidioc_subscribe_event) + break; + + ret = ops->vidioc_subscribe_event(fh, sub); + if (ret < 0) { + dbgarg(cmd, "failed, ret=%ld", ret); + break; + } + dbgarg(cmd, "type=0x%8.8x", sub->type); + break; + } + case VIDIOC_UNSUBSCRIBE_EVENT: + { + struct v4l2_event_subscription *sub = arg; + + if (!ops->vidioc_unsubscribe_event) + break; + + ret = ops->vidioc_unsubscribe_event(fh, sub); + if (ret < 0) { + dbgarg(cmd, "failed, ret=%ld", ret); + break; + } + dbgarg(cmd, "type=0x%8.8x", sub->type); + break; + } default: { if (!ops->vidioc_default) diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index 7a4529d..6d6a2a3 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -21,6 +21,8 @@ #include #endif +struct v4l2_fh; + struct v4l2_ioctl_ops { /* ioctl callbacks */ @@ -239,6 +241,13 @@ struct v4l2_ioctl_ops { int (*vidioc_enum_frameintervals) (struct file *file, void *fh, struct v4l2_frmivalenum *fival); + int (*vidioc_dqevent) (struct v4l2_fh *fh, + struct v4l2_event *ev); + int (*vidioc_subscribe_event) (struct v4l2_fh *fh, + struct v4l2_event_subscription *sub); + int (*vidioc_unsubscribe_event)(struct v4l2_fh *fh, + struct v4l2_event_subscription *sub); + /* For other private ioctls */ long (*vidioc_default) (struct file *file, void *fh, int cmd, void *arg);