From patchwork Sun Feb 7 18:40:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 2647 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Sun, 07 Feb 2010 18:40:27 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.6) for (single-drop); Sun, 07 Feb 2010 20:37:43 -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 1NeC3X-0005CR-AD; Sun, 07 Feb 2010 18:40:27 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933049Ab0BGSkA (ORCPT + 1 other); Sun, 7 Feb 2010 13:40:00 -0500 Received: from smtp.nokia.com ([192.100.122.233]:52395 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932957Ab0BGSj5 (ORCPT ); Sun, 7 Feb 2010 13:39:57 -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 o17Idpku003179; Sun, 7 Feb 2010 20:39:54 +0200 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 7 Feb 2010 20:39:52 +0200 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Sun, 7 Feb 2010 20:39:51 +0200 Received: from maxwell.research.nokia.com (maxwell.research.nokia.com [172.21.50.162]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o17IdjZG030019 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 7 Feb 2010 20:39:46 +0200 Received: from lanttu (unknown [192.168.239.74]) by maxwell.research.nokia.com (Postfix) with ESMTPS id C7AC97010E; Sun, 7 Feb 2010 20:39:44 +0200 (EET) Received: from sakke by lanttu with local (Exim 4.69) (envelope-from ) id 1NeC3u-000867-Hj; Sun, 07 Feb 2010 20:40: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, Sakari Ailus Subject: [PATCH v2 7/7] V4L: Events: Support all events Date: Sun, 7 Feb 2010 20:40:47 +0200 Message-Id: <1265568047-31073-7-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:51.0722 (UTC) FILETIME=[EF19E0A0:01CAA824] 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 cd744d0..131bab7 100644 --- a/drivers/media/video/v4l2-event.c +++ b/drivers/media/video/v4l2-event.c @@ -133,6 +133,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; @@ -212,6 +220,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; } @@ -252,7 +262,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->fhs.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 /*