@@ -23,7 +23,7 @@
#ifndef _MEDIA_ENTITY_H
#define _MEDIA_ENTITY_H
-#include <linux/bitops.h>
+#include <linux/bitmap.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/media.h>
@@ -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;
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 <sakari.ailus@linux.intel.com> --- include/media/media-entity.h | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)