Skip to content
Permalink
Browse files
media: entity: Add support for ancillary links
Add functions to create and destroy ancillary links, so that they
don't need to be manually created by users.

Signed-off-by: Daniel Scally <djrscally@gmail.com>
  • Loading branch information
djrscally authored and intel-lab-lkp committed Dec 13, 2021
1 parent 7f61ae9 commit 627c8446267d301ed36953f7e4fa616ab6cb771a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
@@ -1036,3 +1036,33 @@ void media_remove_intf_links(struct media_interface *intf)
mutex_unlock(&mdev->graph_mutex);
}
EXPORT_SYMBOL_GPL(media_remove_intf_links);

struct media_link *media_create_ancillary_link(struct media_entity *primary,
struct media_entity *ancillary,
u32 flags)
{
struct media_link *link;

link = media_add_link(&primary->links);
if (!link)
return ERR_PTR(-ENOMEM);

link->gobj0 = &primary->graph_obj;
link->gobj1 = &ancillary->graph_obj;
link->flags = flags | MEDIA_LNK_FL_ANCILLARY_LINK;

/* Initialize graph object embedded at the new link */
media_gobj_create(primary->graph_obj.mdev, MEDIA_GRAPH_LINK,
&link->graph_obj);

return link;
}
EXPORT_SYMBOL_GPL(media_create_ancillary_link);

void media_remove_ancillary_link(struct media_link *link)
{
list_del(&link->list);
media_gobj_destroy(&link->graph_obj);
kfree(link);
}
EXPORT_SYMBOL_GPL(media_remove_ancillary_link);
@@ -1104,6 +1104,35 @@ void media_remove_intf_links(struct media_interface *intf);
* it will issue a call to @operation\(@entity, @args\).
*/

/**
* media_create_ancillary_link() - creates a link between two entities
*
* @primary: pointer to the primary &media_entity
* @ancillary: pointer to the ancillary &media_entity
* @flags: Link flags, as defined in
* :ref:`include/uapi/linux/media.h <media_header>`
* ( seek for ``MEDIA_LNK_FL_*``)
*
*
* Valid values for flags:
*
* %MEDIA_LNK_FL_ENABLED
* Indicates that the two entities are connected pieces of hardware that form
* a single logical unit.
*
* A typical example is a camera lens being linked to the sensor that it is
* supporting.
*
* %MEDIA_LNK_FL_IMMUTABLE
* Indicates that the link enabled state can't be modified at runtime. If
* %MEDIA_LNK_FL_IMMUTABLE is set, then %MEDIA_LNK_FL_ENABLED must also be
* set, since an immutable link is always enabled.
*/
struct media_link *
media_create_ancillary_link(struct media_entity *primary,
struct media_entity *ancillary,
u32 flags);

#define media_entity_call(entity, operation, args...) \
(((entity)->ops && (entity)->ops->operation) ? \
(entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)

0 comments on commit 627c844

Please sign in to comment.