switch (media_type(gobj)) {
case MEDIA_GRAPH_ENTITY:
dev_dbg(gobj->mdev->dev,
- "%s: id 0x%08x entity#%d: '%s'\n",
- event_name, gobj->id, media_localid(gobj),
+ "%s id %u: entity '%s'\n",
+ event_name, media_id(gobj),
gobj_to_entity(gobj)->name);
break;
case MEDIA_GRAPH_LINK:
struct media_link *link = gobj_to_link(gobj);
dev_dbg(gobj->mdev->dev,
- "%s: id 0x%08x link#%d: %s#%d ==> %s#%d\n",
- event_name, gobj->id, media_localid(gobj),
-
- gobj_type(media_type(link->gobj0)),
- media_localid(link->gobj0),
-
- gobj_type(media_type(link->gobj1)),
- media_localid(link->gobj1));
+ "%s id %u: %s link id %u ==> id %u\n",
+ event_name, media_id(gobj),
+ media_type(link->gobj0) == MEDIA_GRAPH_PAD ?
+ "data" : "interface",
+ media_id(link->gobj0),
+ media_id(link->gobj1));
break;
}
case MEDIA_GRAPH_PAD:
struct media_pad *pad = gobj_to_pad(gobj);
dev_dbg(gobj->mdev->dev,
- "%s: id 0x%08x %s%spad#%d: '%s':%d\n",
- event_name, gobj->id,
- pad->flags & MEDIA_PAD_FL_SINK ? " sink " : "",
+ "%s id %u: %s%spad '%s':%d\n",
+ event_name, media_id(gobj),
+ pad->flags & MEDIA_PAD_FL_SINK ? "sink " : "",
pad->flags & MEDIA_PAD_FL_SOURCE ? "source " : "",
- media_localid(gobj),
pad->entity->name, pad->index);
break;
}
struct media_intf_devnode *devnode = intf_to_devnode(intf);
dev_dbg(gobj->mdev->dev,
- "%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n",
- event_name, gobj->id, media_localid(gobj),
+ "%s id %u: intf_devnode %s - major: %d, minor: %d\n",
+ event_name, media_id(gobj),
intf_type(intf),
devnode->major, devnode->minor);
break;
gobj->mdev = mdev;
/* Create a per-type unique object ID */
+ gobj->id = media_gobj_gen_id(type, ++mdev->id);
+
switch (type) {
case MEDIA_GRAPH_ENTITY:
- gobj->id = media_gobj_gen_id(type, ++mdev->entity_id);
list_add_tail(&gobj->list, &mdev->entities);
break;
case MEDIA_GRAPH_PAD:
- gobj->id = media_gobj_gen_id(type, ++mdev->pad_id);
list_add_tail(&gobj->list, &mdev->pads);
break;
case MEDIA_GRAPH_LINK:
- gobj->id = media_gobj_gen_id(type, ++mdev->link_id);
list_add_tail(&gobj->list, &mdev->links);
break;
case MEDIA_GRAPH_INTF_DEVNODE:
- gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id);
list_add_tail(&gobj->list, &mdev->interfaces);
break;
}
* @driver_version: Device driver version
* @topology_version: Monotonic counter for storing the version of the graph
* topology. Should be incremented each time the topology changes.
- * @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
- * @intf_devnode_id: Unique ID used on the last interface devnode registered
+ * @id: Unique ID used on the last registered graph object
* @entity_internal_idx: Unique internal entity ID used by the graph traversal
* algorithms
* @entity_internal_idx_max: Allocated internal entity indices
u32 topology_version;
- u32 entity_id;
- u32 pad_id;
- u32 link_id;
- u32 intf_devnode_id;
+ u32 id;
struct ida entity_internal_idx;
int entity_internal_idx_max;
};
#define MEDIA_BITS_PER_TYPE 8
-#define MEDIA_BITS_PER_LOCAL_ID (32 - MEDIA_BITS_PER_TYPE)
-#define MEDIA_LOCAL_ID_MASK GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 0)
+#define MEDIA_BITS_PER_ID (32 - MEDIA_BITS_PER_TYPE)
+#define MEDIA_ID_MASK GENMASK_ULL(MEDIA_BITS_PER_ID - 1, 0)
/* Structs to represent the objects that belong to a media graph */
* @mdev: Pointer to the struct media_device that owns the object
* @id: Non-zero object ID identifier. The ID should be unique
* inside a media_device, as it is composed by
- * MEDIA_BITS_PER_TYPE to store the type plus
- * MEDIA_BITS_PER_LOCAL_ID to store a per-type ID
- * (called as "local ID").
+ * %MEDIA_BITS_PER_TYPE to store the type plus
+ * %MEDIA_BITS_PER_ID to store the ID
* @list: List entry stored in one of the per-type mdev object lists
*
* All objects on the media graph should have this struct embedded
*/
static inline enum media_gobj_type media_type(struct media_gobj *gobj)
{
- return gobj->id >> MEDIA_BITS_PER_LOCAL_ID;
+ return gobj->id >> MEDIA_BITS_PER_ID;
}
-static inline u32 media_localid(struct media_gobj *gobj)
+static inline u32 media_id(struct media_gobj *gobj)
{
- return gobj->id & MEDIA_LOCAL_ID_MASK;
+ return gobj->id & MEDIA_ID_MASK;
}
-static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id)
+static inline u32 media_gobj_gen_id(enum media_gobj_type type, u64 local_id)
{
u32 id;
- id = type << MEDIA_BITS_PER_LOCAL_ID;
- id |= local_id & MEDIA_LOCAL_ID_MASK;
+ id = type << MEDIA_BITS_PER_ID;
+ id |= local_id & MEDIA_ID_MASK;
return id;
}