if (WARN_ON(mdev->dev == NULL || mdev->model[0] == 0))
return -EINVAL;
- mdev->entity_id = 1;
INIT_LIST_HEAD(&mdev->entities);
spin_lock_init(&mdev->lock);
mutex_init(&mdev->graph_mutex);
entity->parent = mdev;
spin_lock(&mdev->lock);
- if (entity->id == 0)
- entity->id = mdev->entity_id++;
- else
- mdev->entity_id = max(entity->id + 1, mdev->entity_id);
+ /* Initialize media_gobj embedded at the entity */
+ media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
list_add_tail(&entity->list, &mdev->entities);
spin_unlock(&mdev->lock);
return;
spin_lock(&mdev->lock);
+ media_gobj_remove(&entity->graph_obj);
list_del(&entity->list);
spin_unlock(&mdev->lock);
entity->parent = NULL;
enum media_gobj_type type,
struct media_gobj *gobj)
{
- /* For now, nothing to do */
+ /* Create a per-type unique object ID */
+ switch (type) {
+ case MEDIA_GRAPH_ENTITY:
+ gobj->id = media_gobj_gen_id(type, ++mdev->entity_id);
+ break;
+ }
}
/**
* @bus_info: Unique and stable device location identifier
* @hw_revision: Hardware device revision
* @driver_version: Device driver version
- * @entity_id: ID of the next entity to be registered
+ * @entity_id: Unique ID used on the last entity registered
* @entities: List of registered entities
* @lock: Entities list lock
* @graph_mutex: Entities graph operation lock
u32 driver_version;
u32 entity_id;
+
struct list_head entities;
/* Protects the entities list */
/**
* enum media_gobj_type - type of a graph object
*
+ * @MEDIA_GRAPH_ENTITY: Identify a media entity
*/
enum media_gobj_type {
- /* FIXME: add the types here, as we embed media_gobj */
- MEDIA_GRAPH_NONE
+ MEDIA_GRAPH_ENTITY,
};
#define MEDIA_BITS_PER_TYPE 8
};
struct media_entity {
+ struct media_gobj graph_obj;
struct list_head list;
struct media_device *parent; /* Media device this entity belongs to*/
- u32 id; /* Entity ID, unique in the parent media
- * device context */
const char *name; /* Entity name */
u32 type; /* Entity type (MEDIA_ENT_T_*) */
u32 revision; /* Entity revision, driver specific */
static inline u32 media_entity_id(struct media_entity *entity)
{
- return entity->id;
+ return entity->graph_obj.id;
}
static inline enum media_gobj_type media_type(struct media_gobj *gobj)