public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [media-ctl PATCH 1/1] libmediactl: Implement MEDIA_ENT_ID_FLAG_NEXT in media_get_entity_by_id()
@ 2012-01-14 19:33 Sakari Ailus
  2012-01-15 13:44 ` Laurent Pinchart
  0 siblings, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2012-01-14 19:33 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
---
 src/mediactl.c |    9 +++++++--
 src/mediactl.h |    4 +++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/mediactl.c b/src/mediactl.c
index 5b8c587..f62fcdf 100644
--- a/src/mediactl.c
+++ b/src/mediactl.c
@@ -81,8 +81,13 @@ struct media_entity *media_get_entity_by_id(struct media_device *media,
 	for (i = 0; i < media->entities_count; ++i) {
 		struct media_entity *entity = &media->entities[i];
 
-		if (entity->info.id == id)
-			return entity;
+		if (!(id & MEDIA_ENT_ID_FLAG_NEXT)) {
+			if (entity->info.id == id)
+				return entity;
+		} else {
+			if (entity->info.id >= (id & ~MEDIA_ENT_ID_FLAG_NEXT)
+				return entity;
+		}
 	}
 
 	return NULL;
diff --git a/src/mediactl.h b/src/mediactl.h
index 1b47b7e..4d3892e 100644
--- a/src/mediactl.h
+++ b/src/mediactl.h
@@ -164,7 +164,9 @@ struct media_entity *media_get_entity_by_name(struct media_device *media,
  * @param media - media device.
  * @param id - entity ID.
  *
- * Search for an entity with an ID equal to @a id.
+ * Search for an entity with an ID equal to @a id. If id flag
+ * MEDIA_ENT_ID_FLAG_NEXT is present, an entity with ID greater or equal to
+ * @a id will be returned.
  *
  * @return A pointer to the entity if found, or NULL otherwise.
  */
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-15 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-14 19:33 [media-ctl PATCH 1/1] libmediactl: Implement MEDIA_ENT_ID_FLAG_NEXT in media_get_entity_by_id() Sakari Ailus
2012-01-15 13:44 ` Laurent Pinchart
2012-01-15 15:40   ` Sakari Ailus
2012-01-15 17:31     ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox