From: Daniel Scally <djrscally@gmail.com>
To: linux-media@vger.kernel.org
Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com,
hanlinchen@chromium.org, tfiga@chromium.org, hdegoede@redhat.com,
kieran.bingham@ideasonboard.com
Subject: [RFC PATCH 1/2] media: entity: Add support for ancillary links
Date: Fri, 26 Nov 2021 00:16:02 +0000 [thread overview]
Message-ID: <20211126001603.41148-2-djrscally@gmail.com> (raw)
In-Reply-To: <20211126001603.41148-1-djrscally@gmail.com>
To describe in the kernel the connection between devices and their
supporting peripherals (for example, a camera sensor and the vcm
driving the focusing lens for it), add a new type of media link
which connects two instances of struct media_entity.
Signed-off-by: Daniel Scally <djrscally@gmail.com>
---
I was tempted to 'fix' the spaces between # and define in
include/uapi/linux/media.h but eventually decided they were probably deliberate
but if that's not true I'd fix those too.
drivers/media/mc/mc-entity.c | 30 ++++++++++++++++++++++++++++++
include/media/media-entity.h | 30 ++++++++++++++++++++++++++++++
include/uapi/linux/media.h | 1 +
3 files changed, 61 insertions(+)
diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index f40f41977142..9c18b974e117 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -1032,3 +1032,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->primary = primary;
+ link->ancillary = ancillary;
+ 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);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index fea489f03d57..400b864857ee 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -119,12 +119,16 @@ struct media_pipeline {
* a pad. In that case, it represents the source pad.
* @intf: Part of a union. Used only if the first object (gobj0) is
* an interface.
+ * @primary: Part of a union. Used only if the first object (gobj0) is
+ * an entity and the link type is MEDIA_LNK_FL_ANCILLARY_LINK.
* @gobj1: Part of a union. Used to get the pointer for the second
* graph_object of the link.
* @sink: Part of a union. Used only if the second object (gobj1) is
* a pad. In that case, it represents the sink pad.
* @entity: Part of a union. Used only if the second object (gobj1) is
* an entity.
+ * @ancillary: Part of a union. Used only if the second object (gobj1) is
+ * an entity and the link type is MEDIA_LNK_FL_ANCILLARY_LINK.
* @reverse: Pointer to the link for the reverse direction of a pad to pad
* link.
* @flags: Link flags, as defined in uapi/media.h (MEDIA_LNK_FL_*)
@@ -137,11 +141,13 @@ struct media_link {
struct media_gobj *gobj0;
struct media_pad *source;
struct media_interface *intf;
+ struct media_entity *primary;
};
union {
struct media_gobj *gobj1;
struct media_pad *sink;
struct media_entity *entity;
+ struct media_entity *ancillary;
};
struct media_link *reverse;
unsigned long flags;
@@ -1104,6 +1110,30 @@ 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.
+ */
+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)
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 200fa8462b90..afbae7213d35 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -226,6 +226,7 @@ struct media_pad_desc {
#define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
# define MEDIA_LNK_FL_DATA_LINK (0 << 28)
# define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
+# define MEDIA_LNK_FL_ANCILLARY_LINK (2 << 28)
struct media_link_desc {
struct media_pad_desc source;
--
2.25.1
next prev parent reply other threads:[~2021-11-26 0:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-26 0:16 [RFC PATCH 0/2] Introduce ancillary links Daniel Scally
2021-11-26 0:16 ` Daniel Scally [this message]
2021-11-26 2:56 ` [RFC PATCH 1/2] media: entity: Add support for " Laurent Pinchart
2021-11-26 7:58 ` Daniel Scally
2021-11-26 0:16 ` [RFC PATCH 2/2] media: v4l2-async: Create links during v4l2_async_match_notify() Daniel Scally
2021-11-26 2:59 ` [RFC PATCH 0/2] Introduce ancillary links Laurent Pinchart
2021-11-26 7:58 ` Daniel Scally
2021-11-26 9:41 ` Hans de Goede
2021-11-26 9:46 ` Daniel Scally
2021-11-26 9:53 ` Kate Hsuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211126001603.41148-2-djrscally@gmail.com \
--to=djrscally@gmail.com \
--cc=hanlinchen@chromium.org \
--cc=hdegoede@redhat.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tfiga@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox