From patchwork Tue Dec 22 16:43:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 69295 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBMGiJsH002018 for ; Tue, 22 Dec 2009 16:44:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754120AbZLVQnw (ORCPT ); Tue, 22 Dec 2009 11:43:52 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753726AbZLVQnf (ORCPT ); Tue, 22 Dec 2009 11:43:35 -0500 Received: from smtp.nokia.com ([192.100.105.134]:39889 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753766AbZLVQna (ORCPT ); Tue, 22 Dec 2009 11:43:30 -0500 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBMGh09q008683; Tue, 22 Dec 2009 10:43:26 -0600 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 18:43:13 +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); Tue, 22 Dec 2009 18:43:13 +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 nBMGhCGo006500; Tue, 22 Dec 2009 18:43:12 +0200 Received: from lanttu (lanttu.localdomain [192.168.239.4]) by maxwell.research.nokia.com (Postfix) with ESMTPS id 700777010D; Tue, 22 Dec 2009 18:43:12 +0200 (EET) Received: from sakke by lanttu with local (Exim 4.69) (envelope-from ) id 1NN7pI-0002Ss-0Z; Tue, 22 Dec 2009 18:43:12 +0200 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, iivanov@mm-sol.com, hverkuil@xs4all.nl, gururaj.nagendra@intel.com Subject: [RFC v2 3/7] V4L: Events: Support event handling in do_ioctl Date: Tue, 22 Dec 2009 18:43:07 +0200 Message-Id: <1261500191-9441-3-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1261500191-9441-2-git-send-email-sakari.ailus@maxwell.research.nokia.com> References: <4B30F713.8070004@maxwell.research.nokia.com> <1261500191-9441-1-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-2-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-OriginalArrivalTime: 22 Dec 2009 16:43:13.0602 (UTC) FILETIME=[DA7B4220:01CA8325] 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..6964bcc 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->private_data, 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(file->private_data, 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->private_data, 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..29dd64b 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);