From patchwork Fri Sep 11 10:09:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 7159161 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6F9BC9F39B for ; Fri, 11 Sep 2015 10:11:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 833632082D for ; Fri, 11 Sep 2015 10:11:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 812322082A for ; Fri, 11 Sep 2015 10:11:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751532AbbIKKLU (ORCPT ); Fri, 11 Sep 2015 06:11:20 -0400 Received: from mga03.intel.com ([134.134.136.65]:56629 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752143AbbIKKLS (ORCPT ); Fri, 11 Sep 2015 06:11:18 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 11 Sep 2015 03:11:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,511,1437462000"; d="scan'208";a="766949555" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga001.jf.intel.com with ESMTP; 11 Sep 2015 03:11:01 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id A8FA520F8F; Fri, 11 Sep 2015 13:11:00 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id 90775201F1; Fri, 11 Sep 2015 13:09:23 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, javier@osg.samsung.com, mchehab@osg.samsung.com, hverkuil@xs4all.nl Subject: [RFC 3/9] media: Add an API to manage entity enumerations Date: Fri, 11 Sep 2015 13:09:06 +0300 Message-Id: <1441966152-28444-4-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.1.0.231.g7484e3b In-Reply-To: <1441966152-28444-1-git-send-email-sakari.ailus@linux.intel.com> References: <1441966152-28444-1-git-send-email-sakari.ailus@linux.intel.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is useful in e.g. knowing whether certain operations have already been performed for an entity. The users include the framework itself (for graph walking) and a number of drivers. Signed-off-by: Sakari Ailus --- include/media/media-entity.h | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 2c56027..17ec205 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -23,7 +23,7 @@ #ifndef _MEDIA_ENTITY_H #define _MEDIA_ENTITY_H -#include +#include #include #include #include @@ -309,6 +309,49 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity) #define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 #define MEDIA_ENTITY_MAX_LOW_ID 64 +#define DECLARE_MEDIA_ENTITY_ENUM(name) \ + DECLARE_BITMAP(name, MEDIA_ENTITY_MAX_LOW_ID) + +static inline void media_entity_enum_init(unsigned long *e) +{ + bitmap_zero(e, MEDIA_ENTITY_MAX_LOW_ID); +} + +static inline void media_entity_enum_set(unsigned long *e, + struct media_entity *entity) +{ + __set_bit(entity->low_id, e); +} + +static inline void media_entity_enum_clear(unsigned long *e, + struct media_entity *entity) +{ + __clear_bit(entity->low_id, e); +} + +static inline bool media_entity_enum_test(unsigned long *e, + struct media_entity *entity) +{ + return test_bit(entity->low_id, e); +} + +static inline bool media_entity_enum_test_and_set(unsigned long *e, + struct media_entity *entity) +{ + return __test_and_set_bit(entity->low_id, e); +} + +static inline bool media_entity_enum_empty(unsigned long *e) +{ + return bitmap_empty(e, MEDIA_ENTITY_MAX_LOW_ID); +} + +static inline bool media_entity_enum_intersects(unsigned long *e, + unsigned long *f) +{ + return bitmap_intersects(e, f, MEDIA_ENTITY_MAX_LOW_ID); +} + struct media_entity_graph { struct { struct media_entity *entity;