bcm27xx: switch to kernel v6.1
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-5.15 / 950-0770-media-entity-Add-support-for-ancillary-links.patch
1 From f07c6a12bf8b432e70d312ab60b0a07197fa8162 Mon Sep 17 00:00:00 2001
2 From: Daniel Scally <djrscally@gmail.com>
3 Date: Wed, 2 Mar 2022 22:03:03 +0000
4 Subject: [PATCH] media: entity: Add support for ancillary links
5
6 Add functions to create ancillary links, so that they don't need to
7 be manually created by users.
8
9 Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10 Signed-off-by: Daniel Scally <djrscally@gmail.com>
11 ---
12 drivers/media/mc/mc-entity.c | 22 ++++++++++++++++++++++
13 include/media/media-entity.h | 19 +++++++++++++++++++
14 2 files changed, 41 insertions(+)
15
16 --- a/drivers/media/mc/mc-entity.c
17 +++ b/drivers/media/mc/mc-entity.c
18 @@ -1050,3 +1050,25 @@ void media_remove_intf_links(struct medi
19 mutex_unlock(&mdev->graph_mutex);
20 }
21 EXPORT_SYMBOL_GPL(media_remove_intf_links);
22 +
23 +struct media_link *media_create_ancillary_link(struct media_entity *primary,
24 + struct media_entity *ancillary)
25 +{
26 + struct media_link *link;
27 +
28 + link = media_add_link(&primary->links);
29 + if (!link)
30 + return ERR_PTR(-ENOMEM);
31 +
32 + link->gobj0 = &primary->graph_obj;
33 + link->gobj1 = &ancillary->graph_obj;
34 + link->flags = MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED |
35 + MEDIA_LNK_FL_ANCILLARY_LINK;
36 +
37 + /* Initialize graph object embedded in the new link */
38 + media_gobj_create(primary->graph_obj.mdev, MEDIA_GRAPH_LINK,
39 + &link->graph_obj);
40 +
41 + return link;
42 +}
43 +EXPORT_SYMBOL_GPL(media_create_ancillary_link);
44 --- a/include/media/media-entity.h
45 +++ b/include/media/media-entity.h
46 @@ -1107,4 +1107,23 @@ void media_remove_intf_links(struct medi
47 (((entity)->ops && (entity)->ops->operation) ? \
48 (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
49
50 +/**
51 + * media_create_ancillary_link() - create an ancillary link between two
52 + * instances of &media_entity
53 + *
54 + * @primary: pointer to the primary &media_entity
55 + * @ancillary: pointer to the ancillary &media_entity
56 + *
57 + * Create an ancillary link between two entities, indicating that they
58 + * represent two connected pieces of hardware that form a single logical unit.
59 + * A typical example is a camera lens controller being linked to the sensor that
60 + * it is supporting.
61 + *
62 + * The function sets both MEDIA_LNK_FL_ENABLED and MEDIA_LNK_FL_IMMUTABLE for
63 + * the new link.
64 + */
65 +struct media_link *
66 +media_create_ancillary_link(struct media_entity *primary,
67 + struct media_entity *ancillary);
68 +
69 #endif