Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
[laurent.pinchart@ideasonboard Clarify documentation]
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct media_entity *media_get_entity_by_id(struct media_device *media,
__u32 id)
{
struct media_entity *media_get_entity_by_id(struct media_device *media,
__u32 id)
{
+ bool next = id & MEDIA_ENT_ID_FLAG_NEXT;
+ id &= ~MEDIA_ENT_ID_FLAG_NEXT;
+
for (i = 0; i < media->entities_count; ++i) {
struct media_entity *entity = &media->entities[i];
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))
* @param media - media device.
* @param id - entity ID.
*
* @param media - media device.
* @param id - entity ID.
*
- * Search for an entity with an ID equal to @a id.
+ * This function searches for an entity based on its ID using an exact match or
+ * next ID method based on the given @a id. If @a id is ORed with
+ * MEDIA_ENT_ID_FLAG_NEXT, the function will return the entity with the smallest
+ * ID larger than @a id. Otherwise it will return the entity with an ID equal to
+ * @a id.
*
* @return A pointer to the entity if found, or NULL otherwise.
*/
*
* @return A pointer to the entity if found, or NULL otherwise.
*/