media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
list_add_tail(&entity->list, &mdev->entities);
+ /*
+ * Initialize objects at the links
+ * in the case where links got created before entity register
+ */
+ for (i = 0; i < entity->num_links; i++)
+ media_gobj_init(mdev, MEDIA_GRAPH_LINK,
+ &entity->links[i].graph_obj);
/* Initialize objects at the pads */
for (i = 0; i < entity->num_pads; i++)
media_gobj_init(mdev, MEDIA_GRAPH_PAD,
return;
spin_lock(&mdev->lock);
+ for (i = 0; i < entity->num_links; i++)
+ media_gobj_remove(&entity->links[i].graph_obj);
for (i = 0; i < entity->num_pads; i++)
media_gobj_remove(&entity->pads[i].graph_obj);
media_gobj_remove(&entity->graph_obj);
case MEDIA_GRAPH_PAD:
gobj->id = media_gobj_gen_id(type, ++mdev->pad_id);
break;
+ case MEDIA_GRAPH_LINK:
+ gobj->id = media_gobj_gen_id(type, ++mdev->link_id);
+ break;
}
}
link->sink = &sink->pads[sink_pad];
link->flags = flags;
+ /* Initialize graph object embedded at the new link */
+ media_gobj_init(source->parent, MEDIA_GRAPH_LINK, &link->graph_obj);
+
/* Create the backlink. Backlinks are used to help graph traversal and
* are not reported to userspace.
*/
backlink->sink = &sink->pads[sink_pad];
backlink->flags = flags;
+ /* Initialize graph object embedded at the new link */
+ media_gobj_init(sink->parent, MEDIA_GRAPH_LINK, &backlink->graph_obj);
+
link->reverse = backlink;
backlink->reverse = link;
* @driver_version: Device driver version
* @entity_id: Unique ID used on the last entity registered
* @pad_id: Unique ID used on the last pad registered
+ * @link_id: Unique ID used on the last link registered
* @entities: List of registered entities
* @lock: Entities list lock
* @graph_mutex: Entities graph operation lock
u32 entity_id;
u32 pad_id;
+ u32 link_id;
struct list_head entities;
*
* @MEDIA_GRAPH_ENTITY: Identify a media entity
* @MEDIA_GRAPH_PAD: Identify a media pad
+ * @MEDIA_GRAPH_LINK: Identify a media link
*/
enum media_gobj_type {
MEDIA_GRAPH_ENTITY,
MEDIA_GRAPH_PAD,
+ MEDIA_GRAPH_LINK,
};
#define MEDIA_BITS_PER_TYPE 8
};
struct media_link {
+ struct media_gobj graph_obj;
struct media_pad *source; /* Source pad */
struct media_pad *sink; /* Sink pad */
struct media_link *reverse; /* Link in the reverse direction */