From patchwork Tue Dec 15 12:19:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 67603 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBFCItEp018254 for ; Tue, 15 Dec 2009 12:20:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760119AbZLOMUW (ORCPT ); Tue, 15 Dec 2009 07:20:22 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760118AbZLOMUV (ORCPT ); Tue, 15 Dec 2009 07:20:21 -0500 Received: from smtp.nokia.com ([192.100.122.233]:32497 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753777AbZLOMUR (ORCPT ); Tue, 15 Dec 2009 07:20:17 -0500 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBFCJf4D029831; Tue, 15 Dec 2009 14:19:59 +0200 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 15 Dec 2009 14:19:58 +0200 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 15 Dec 2009 14:19:58 +0200 Received: from maxwell.research.nokia.com (maxwell.research.nokia.com [172.21.50.162]) by mgw-sa02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBFCJuPH022435; Tue, 15 Dec 2009 14:19:56 +0200 Received: from lanttu (unknown [192.168.239.74]) by maxwell.research.nokia.com (Postfix) with ESMTPS id CD81A7010B; Tue, 15 Dec 2009 14:19:55 +0200 (EET) Received: from sakke by lanttu with local (Exim 4.69) (envelope-from ) id 1NKWNc-0003kb-TA; Tue, 15 Dec 2009 14:19:52 +0200 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, hverkuil@xs4all.nl, gururaj.nagendra@intel.com, mchehab@infradead.org, mkrufky@linuxtv.org, dheitmueller@kernellabs.com, iivanov@mm-sol.com, vimarsh.zutshi@nokia.com Subject: [RFC 3/4] V4L: Events: Support event handling in do_ioctl Date: Tue, 15 Dec 2009 14:19:50 +0200 Message-Id: <1260879591-14376-3-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1260879591-14376-2-git-send-email-sakari.ailus@maxwell.research.nokia.com> References: <4B277D2A.7050201@maxwell.research.nokia.com> <1260879591-14376-1-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1260879591-14376-2-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-OriginalArrivalTime: 15 Dec 2009 12:19:58.0053 (UTC) FILETIME=[EAB58150:01CA7D80] X-Nokia-AV: Clean Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index bfc4696..067ab3a 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(file, ev); + if (ret < 0) { + dbgarg(cmd, "no pending events?"); + break; + } + dbgarg(cmd, + "count=%d, type=0x%8.8x, sequence=%d, " + "timestamp=%d.%9.9lu ", + ev->count, ev->type, ev->sequence, + (int)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(file, 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(file, 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..77a71cc 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -239,6 +239,13 @@ struct v4l2_ioctl_ops { int (*vidioc_enum_frameintervals) (struct file *file, void *fh, struct v4l2_frmivalenum *fival); + int (*vidioc_dqevent) (struct file *file, + struct v4l2_event *ev); + int (*vidioc_subscribe_event) (struct file *file, + struct v4l2_event_subscription *sub); + int (*vidioc_unsubscribe_event) (struct file *file, + struct v4l2_event_subscription *sub); + /* For other private ioctls */ long (*vidioc_default) (struct file *file, void *fh, int cmd, void *arg);