Skip to content

Commit 5d00619

Browse files
djrscallypopcornmix
authored andcommitted
media: entity: Add support for ancillary links
Add functions to create ancillary links, so that they don't need to be manually created by users. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Daniel Scally <djrscally@gmail.com>
1 parent f10da41 commit 5d00619

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎drivers/media/mc/mc-entity.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,3 +1050,25 @@ void media_remove_intf_links(struct media_interface *intf)
10501050
mutex_unlock(&mdev->graph_mutex);
10511051
}
10521052
EXPORT_SYMBOL_GPL(media_remove_intf_links);
1053+
1054+
struct media_link *media_create_ancillary_link(struct media_entity *primary,
1055+
struct media_entity *ancillary)
1056+
{
1057+
struct media_link *link;
1058+
1059+
link = media_add_link(&primary->links);
1060+
if (!link)
1061+
return ERR_PTR(-ENOMEM);
1062+
1063+
link->gobj0 = &primary->graph_obj;
1064+
link->gobj1 = &ancillary->graph_obj;
1065+
link->flags = MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED |
1066+
MEDIA_LNK_FL_ANCILLARY_LINK;
1067+
1068+
/* Initialize graph object embedded in the new link */
1069+
media_gobj_create(primary->graph_obj.mdev, MEDIA_GRAPH_LINK,
1070+
&link->graph_obj);
1071+
1072+
return link;
1073+
}
1074+
EXPORT_SYMBOL_GPL(media_create_ancillary_link);

‎include/media/media-entity.h‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,4 +1108,23 @@ void media_remove_intf_links(struct media_interface *intf);
11081108
(((entity)->ops && (entity)->ops->operation) ? \
11091109
(entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
11101110

1111+
/**
1112+
* media_create_ancillary_link() - create an ancillary link between two
1113+
* instances of &media_entity
1114+
*
1115+
* @primary: pointer to the primary &media_entity
1116+
* @ancillary: pointer to the ancillary &media_entity
1117+
*
1118+
* Create an ancillary link between two entities, indicating that they
1119+
* represent two connected pieces of hardware that form a single logical unit.
1120+
* A typical example is a camera lens controller being linked to the sensor that
1121+
* it is supporting.
1122+
*
1123+
* The function sets both MEDIA_LNK_FL_ENABLED and MEDIA_LNK_FL_IMMUTABLE for
1124+
* the new link.
1125+
*/
1126+
struct media_link *
1127+
media_create_ancillary_link(struct media_entity *primary,
1128+
struct media_entity *ancillary);
1129+
11111130
#endif

0 commit comments

Comments
 (0)