diff options
author | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-08-07 16:36:25 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-01-11 17:18:47 +0300 |
commit | 86e2662071d6f26704bb290317746149ce07be7a (patch) | |
tree | dc501c1fde47a4f21d98c506cee2d47df79fdcd9 /drivers/media/media-entity.c | |
parent | 3c0e266fba5897c02c4bd23521a3271d338650ad (diff) | |
download | linux-86e2662071d6f26704bb290317746149ce07be7a.tar.xz |
[media] media: add support to link interfaces and entities
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.
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/media-entity.c')
-rw-r--r-- | drivers/media/media-entity.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index e22954d2acbd..55cafb016fe8 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -857,6 +857,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; @@ -874,3 +875,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); +} +EXPORT_SYMBOL_GPL(media_remove_intf_link); |