diff options
author | Sakari Ailus <sakari.ailus@iki.fi> | 2012-01-14 21:33:36 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-05-05 14:34:18 +0200 |
commit | 888b03b281397f2569af50b33d3a7de3c93e0fd9 (patch) | |
tree | 84a27ef024b9cb0cacb31d8454e66e32aa6ad4b8 /src/mediactl.c | |
parent | edad96b36f85dad7f681a7938b50b4619d11ed50 (diff) |
libmediactl: Implement MEDIA_ENT_ID_FLAG_NEXT in media_get_entity_by_id()
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
[laurent.pinchart@ideasonboard Clarify documentation]
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/mediactl.c')
-rw-r--r-- | src/mediactl.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mediactl.c b/src/mediactl.c index bc6a713..14cff30 100644 --- a/src/mediactl.c +++ b/src/mediactl.c @@ -26,6 +26,7 @@ #include <sys/types.h> #include <unistd.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -83,12 +84,16 @@ struct media_entity *media_get_entity_by_name(struct media_device *media, struct media_entity *media_get_entity_by_id(struct media_device *media, __u32 id) { + bool next = id & MEDIA_ENT_ID_FLAG_NEXT; unsigned int i; + id &= ~MEDIA_ENT_ID_FLAG_NEXT; + for (i = 0; i < media->entities_count; ++i) { struct media_entity *entity = &media->entities[i]; - if (entity->info.id == id) + if ((entity->info.id == id && !next) || + (entity->info.id > id && next)) return entity; } |