From patchwork Tue Feb 9 18:26:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 2665 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Tue, 09 Feb 2010 18:27:14 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.6) for (single-drop); Tue, 09 Feb 2010 16:30:32 -0200 (BRST) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Neunq-0003Bj-8T; Tue, 09 Feb 2010 18:27:14 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751107Ab0BIS1L (ORCPT + 1 other); Tue, 9 Feb 2010 13:27:11 -0500 Received: from smtp.nokia.com ([192.100.105.134]:55763 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751257Ab0BIS1J (ORCPT ); Tue, 9 Feb 2010 13:27:09 -0500 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o19IR29Y027811; Tue, 9 Feb 2010 12:27:06 -0600 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 9 Feb 2010 20:26:54 +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, 9 Feb 2010 20:26:54 +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 o19IQqol028873 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Feb 2010 20:26:52 +0200 Received: from lanttu (lanttu.localdomain [192.168.239.4]) by maxwell.research.nokia.com (Postfix) with ESMTPS id CC68B7010E; Tue, 9 Feb 2010 20:26:50 +0200 (EET) Received: from sakke by lanttu with local (Exim 4.69) (envelope-from ) id 1NeunS-0006IN-JY; Tue, 09 Feb 2010 20:26:50 +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 Subject: [PATCH v3 7/7] V4L: Events: Support all events Date: Tue, 9 Feb 2010 20:26:50 +0200 Message-Id: <1265740010-24144-7-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1265740010-24144-6-git-send-email-sakari.ailus@maxwell.research.nokia.com> References: <4B71A8DF.8070907@maxwell.research.nokia.com> <1265740010-24144-1-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1265740010-24144-2-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1265740010-24144-3-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1265740010-24144-4-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1265740010-24144-5-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1265740010-24144-6-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-OriginalArrivalTime: 09 Feb 2010 18:26:54.0067 (UTC) FILETIME=[7468A430:01CAA9B5] X-Nokia-AV: Clean Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add support for subscribing all events with a special id V4L2_EVENT_ALL. If V4L2_EVENT_ALL is subscribed, no other events may be subscribed. Otherwise V4L2_EVENT_ALL is considered just as any other event. Signed-off-by: Sakari Ailus --- drivers/media/video/v4l2-event.c | 13 ++++++++++++- include/linux/videodev2.h | 1 + 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c index 3a4065a..8d0bb48 100644 --- a/drivers/media/video/v4l2-event.c +++ b/drivers/media/video/v4l2-event.c @@ -137,6 +137,14 @@ static struct v4l2_subscribed_event *__v4l2_event_subscribed( struct v4l2_events *events = fh->events; struct v4l2_subscribed_event *sev; + if (list_empty(&events->subscribed)) + return NULL; + + sev = list_entry(events->subscribed.next, + struct v4l2_subscribed_event, list); + if (sev->type == V4L2_EVENT_ALL) + return sev; + list_for_each_entry(sev, &events->subscribed, list) { if (sev->type == type) return sev; @@ -216,6 +224,8 @@ int v4l2_event_subscribe(struct v4l2_fh *fh, /* Allow subscribing to valid events only. */ if (sub->type < V4L2_EVENT_PRIVATE_START) switch (sub->type) { + case V4L2_EVENT_ALL: + break; default: return -EINVAL; } @@ -256,7 +266,8 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh, sev = __v4l2_event_subscribed(fh, sub->type); - if (sev == NULL) { + if (sev == NULL || + (sub->type != V4L2_EVENT_ALL && sev->type == V4L2_EVENT_ALL)) { spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); return -EINVAL; } diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index a19ae89..9ae9a1c 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -1553,6 +1553,7 @@ struct v4l2_event_subscription { __u32 reserved[7]; }; +#define V4L2_EVENT_ALL 0 #define V4L2_EVENT_PRIVATE_START 0x08000000 /*