]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: entity: Add support for ancillary links
authorDaniel Scally <djrscally@gmail.com>
Wed, 2 Mar 2022 22:03:03 +0000 (22:03 +0000)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sun, 24 Apr 2022 06:59:09 +0000 (07:59 +0100)
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>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/mc/mc-entity.c
include/media/media-entity.h

index 4b616b11d8e4c3f66bc320340c34b566d28fd86c..11f5207f73aa82588fc4db952e1d6f2fc8d6f366 100644 (file)
@@ -1029,3 +1029,25 @@ 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)
+{
+       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 = MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED |
+                     MEDIA_LNK_FL_ANCILLARY_LINK;
+
+       /* Initialize graph object embedded in 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);
index 742918962d46f2170cd60a4b4ba1c7817b8a090b..1d13b8939a1158572b1231d9ee51960d757fa313 100644 (file)
@@ -1121,4 +1121,23 @@ void media_remove_intf_links(struct media_interface *intf);
        (((entity)->ops && (entity)->ops->operation) ?                  \
         (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
 
+/**
+ * media_create_ancillary_link() - create an ancillary link between two
+ *                                instances of &media_entity
+ *
+ * @primary:   pointer to the primary &media_entity
+ * @ancillary: pointer to the ancillary &media_entity
+ *
+ * Create an ancillary link between two entities, indicating that they
+ * represent two connected pieces of hardware that form a single logical unit.
+ * A typical example is a camera lens controller being linked to the sensor that
+ * it is supporting.
+ *
+ * The function sets both MEDIA_LNK_FL_ENABLED and MEDIA_LNK_FL_IMMUTABLE for
+ * the new link.
+ */
+struct media_link *
+media_create_ancillary_link(struct media_entity *primary,
+                           struct media_entity *ancillary);
+
 #endif