Hi Mauro,
On Mon, Oct 12, 2015 at 01:43:17PM -0300, Mauro Carvalho Chehab wrote:
Now that we have a new graph object called "interfaces", we need to be able to link them to the entities.
Add a linked list to the interfaces to allow them to be linked to the entities.
Change-Id: I3f46789a764b113c8acca7f0c87ef0eb6a0f265d Signed-off-by: Mauro Carvalho Chehab mchehab@osg.samsung.com Acked-by: Hans Verkuil hans.verkuil@cisco.com
drivers/media/media-entity.c | 38 ++++++++++++++++++++++++++++++++++++++ include/media/media-entity.h | 9 +++++++++ 2 files changed, 47 insertions(+)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index f9c6c2a81903..8e17272936c9 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -869,6 +869,7 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
intf->type = type; intf->flags = flags;
INIT_LIST_HEAD(&intf->links);
devnode->major = major; devnode->minor = minor;
@@ -886,3 +887,40 @@ void media_devnode_remove(struct media_intf_devnode *devnode) kfree(devnode); } EXPORT_SYMBOL_GPL(media_devnode_remove);
+struct media_link *media_create_intf_link(struct media_entity *entity,
struct media_interface *intf,
u32 flags)
+{
- struct media_link *link;
- link = media_add_link(&intf->links);
- if (link == NULL)
return NULL;
- link->intf = intf;
- link->entity = entity;
- link->flags = flags;
- /* Initialize graph object embedded at the new link */
- media_gobj_init(intf->graph_obj.mdev, MEDIA_GRAPH_LINK,
&link->graph_obj);
- return link;
+} +EXPORT_SYMBOL_GPL(media_create_intf_link);
+static void __media_remove_intf_link(struct media_link *link) +{
- media_gobj_remove(&link->graph_obj);
- kfree(link);
+}
+void media_remove_intf_link(struct media_link *link) +{
- mutex_lock(&link->graph_obj.mdev->graph_mutex);
- __media_remove_intf_link(link);
- mutex_unlock(&link->graph_obj.mdev->graph_mutex);
+}
I think create and remove do not match well as a function pair performing the opposite operations. Instead, I'd use one of these:
- create / destroy - init / cleanup - register / unregister etc.
Interface is often shortened as "iface", I think I'd favour that instead. Up to you.
+EXPORT_SYMBOL_GPL(media_remove_intf_link); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 6015e996f213..f67c01419268 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -78,10 +78,12 @@ struct media_link { union { struct media_gobj *gobj0; struct media_pad *source;
}; union { struct media_gobj *gobj1; struct media_pad *sink;struct media_interface *intf;
}; struct media_link *reverse; /* Link in the reverse direction */ unsigned long flags; /* Link flags (MEDIA_LNK_FL_*) */struct media_entity *entity;
@@ -154,6 +156,7 @@ struct media_entity {
- struct media_intf_devnode - Define a Kernel API interface
- @graph_obj: embedded graph object
- @links: List of links pointing to graph entities
- @type: Type of the interface as defined at the
uapi/media/media.h header, e. g.
MEDIA_INTF_T_*
@@ -161,6 +164,7 @@ struct media_entity { */ struct media_interface { struct media_gobj graph_obj;
- struct list_head links; u32 type; u32 flags;
}; @@ -283,6 +287,11 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, u32 major, u32 minor, gfp_t gfp_flags); void media_devnode_remove(struct media_intf_devnode *devnode); +struct media_link *media_create_intf_link(struct media_entity *entity,
struct media_interface *intf,
u32 flags);
+void media_remove_intf_link(struct media_link *link);
#define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)