Thomas Gleixner | 1802d0b | 2019-05-27 08:55:21 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 2 | /* |
| 3 | * Media entity |
| 4 | * |
| 5 | * Copyright (C) 2010 Nokia Corporation |
| 6 | * |
| 7 | * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> |
| 8 | * Sakari Ailus <sakari.ailus@iki.fi> |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef _MEDIA_ENTITY_H |
| 12 | #define _MEDIA_ENTITY_H |
| 13 | |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 14 | #include <linux/bitmap.h> |
Philipp Zabel | 2899d35 | 2016-02-15 09:08:06 -0200 | [diff] [blame] | 15 | #include <linux/bug.h> |
Niklas Söderlund | ae45cd5 | 2017-06-15 06:17:25 -0300 | [diff] [blame] | 16 | #include <linux/fwnode.h> |
Sakari Ailus | 0149a2e | 2013-12-13 08:58:37 -0300 | [diff] [blame] | 17 | #include <linux/kernel.h> |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 18 | #include <linux/list.h> |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 19 | #include <linux/media.h> |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 20 | |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 21 | /* Enums used internally at the media controller to represent graphs */ |
| 22 | |
| 23 | /** |
| 24 | * enum media_gobj_type - type of a graph object |
| 25 | * |
Mauro Carvalho Chehab | bfab2aac | 2015-08-14 12:47:48 -0300 | [diff] [blame] | 26 | * @MEDIA_GRAPH_ENTITY: Identify a media entity |
Mauro Carvalho Chehab | 18710dc | 2015-08-14 12:50:08 -0300 | [diff] [blame] | 27 | * @MEDIA_GRAPH_PAD: Identify a media pad |
Mauro Carvalho Chehab | 6b6a427 | 2015-08-14 12:54:36 -0300 | [diff] [blame] | 28 | * @MEDIA_GRAPH_LINK: Identify a media link |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 29 | * @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via |
| 30 | * a device node |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 31 | */ |
| 32 | enum media_gobj_type { |
Mauro Carvalho Chehab | bfab2aac | 2015-08-14 12:47:48 -0300 | [diff] [blame] | 33 | MEDIA_GRAPH_ENTITY, |
Mauro Carvalho Chehab | 18710dc | 2015-08-14 12:50:08 -0300 | [diff] [blame] | 34 | MEDIA_GRAPH_PAD, |
Mauro Carvalho Chehab | 6b6a427 | 2015-08-14 12:54:36 -0300 | [diff] [blame] | 35 | MEDIA_GRAPH_LINK, |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 36 | MEDIA_GRAPH_INTF_DEVNODE, |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | #define MEDIA_BITS_PER_TYPE 8 |
Mauro Carvalho Chehab | 05b3b77 | 2015-12-16 14:28:01 -0200 | [diff] [blame] | 40 | #define MEDIA_BITS_PER_ID (32 - MEDIA_BITS_PER_TYPE) |
| 41 | #define MEDIA_ID_MASK GENMASK_ULL(MEDIA_BITS_PER_ID - 1, 0) |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 42 | |
| 43 | /* Structs to represent the objects that belong to a media graph */ |
| 44 | |
| 45 | /** |
| 46 | * struct media_gobj - Define a graph object. |
| 47 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 48 | * @mdev: Pointer to the struct &media_device that owns the object |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 49 | * @id: Non-zero object ID identifier. The ID should be unique |
| 50 | * inside a media_device, as it is composed by |
Mauro Carvalho Chehab | 05b3b77 | 2015-12-16 14:28:01 -0200 | [diff] [blame] | 51 | * %MEDIA_BITS_PER_TYPE to store the type plus |
| 52 | * %MEDIA_BITS_PER_ID to store the ID |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 53 | * @list: List entry stored in one of the per-type mdev object lists |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 54 | * |
| 55 | * All objects on the media graph should have this struct embedded |
| 56 | */ |
| 57 | struct media_gobj { |
Mauro Carvalho Chehab | 39a956c | 2015-08-13 14:42:42 -0300 | [diff] [blame] | 58 | struct media_device *mdev; |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 59 | u32 id; |
Mauro Carvalho Chehab | 05bfa9f | 2015-08-23 07:51:33 -0300 | [diff] [blame] | 60 | struct list_head list; |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 61 | }; |
| 62 | |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 63 | #define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 64 | |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 65 | /** |
| 66 | * struct media_entity_enum - An enumeration of media entities. |
| 67 | * |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 68 | * @bmap: Bit map in which each bit represents one entity at struct |
| 69 | * media_entity->internal_idx. |
| 70 | * @idx_max: Number of bits in bmap |
| 71 | */ |
| 72 | struct media_entity_enum { |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 73 | unsigned long *bmap; |
| 74 | int idx_max; |
| 75 | }; |
| 76 | |
Sakari Ailus | 434257f | 2015-12-16 11:32:20 -0200 | [diff] [blame] | 77 | /** |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 78 | * struct media_graph - Media graph traversal state |
Sakari Ailus | 434257f | 2015-12-16 11:32:20 -0200 | [diff] [blame] | 79 | * |
| 80 | * @stack: Graph traversal stack; the stack contains information |
| 81 | * on the path the media entities to be walked and the |
| 82 | * links through which they were reached. |
Mauro Carvalho Chehab | bd945e4 | 2017-09-27 15:54:43 -0400 | [diff] [blame] | 83 | * @stack.entity: pointer to &struct media_entity at the graph. |
| 84 | * @stack.link: pointer to &struct list_head. |
Sakari Ailus | 29d8da0 | 2015-12-16 11:32:28 -0200 | [diff] [blame] | 85 | * @ent_enum: Visited entities |
Sakari Ailus | 434257f | 2015-12-16 11:32:20 -0200 | [diff] [blame] | 86 | * @top: The top of the stack |
| 87 | */ |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 88 | struct media_graph { |
Sakari Ailus | 82c6829 | 2015-12-16 11:32:19 -0200 | [diff] [blame] | 89 | struct { |
| 90 | struct media_entity *entity; |
| 91 | struct list_head *link; |
| 92 | } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH]; |
| 93 | |
Sakari Ailus | 29d8da0 | 2015-12-16 11:32:28 -0200 | [diff] [blame] | 94 | struct media_entity_enum ent_enum; |
Sakari Ailus | 82c6829 | 2015-12-16 11:32:19 -0200 | [diff] [blame] | 95 | int top; |
| 96 | }; |
| 97 | |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 98 | /** |
Sakari Ailus | 5dd8775 | 2015-12-16 11:32:21 -0200 | [diff] [blame] | 99 | * struct media_pipeline - Media pipeline related information |
| 100 | * |
Sakari Ailus | 74a41330 | 2015-12-16 11:32:29 -0200 | [diff] [blame] | 101 | * @streaming_count: Streaming start count - streaming stop count |
| 102 | * @graph: Media graph walk during pipeline start / stop |
Sakari Ailus | 5dd8775 | 2015-12-16 11:32:21 -0200 | [diff] [blame] | 103 | */ |
Laurent Pinchart | e02188c | 2010-08-25 09:00:41 -0300 | [diff] [blame] | 104 | struct media_pipeline { |
Sakari Ailus | 74a41330 | 2015-12-16 11:32:29 -0200 | [diff] [blame] | 105 | int streaming_count; |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 106 | struct media_graph graph; |
Laurent Pinchart | e02188c | 2010-08-25 09:00:41 -0300 | [diff] [blame] | 107 | }; |
| 108 | |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 109 | /** |
| 110 | * struct media_link - A link object part of a media graph. |
| 111 | * |
| 112 | * @graph_obj: Embedded structure containing the media object common data |
| 113 | * @list: Linked list associated with an entity or an interface that |
| 114 | * owns the link. |
| 115 | * @gobj0: Part of a union. Used to get the pointer for the first |
| 116 | * graph_object of the link. |
| 117 | * @source: Part of a union. Used only if the first object (gobj0) is |
| 118 | * a pad. In that case, it represents the source pad. |
| 119 | * @intf: Part of a union. Used only if the first object (gobj0) is |
| 120 | * an interface. |
| 121 | * @gobj1: Part of a union. Used to get the pointer for the second |
| 122 | * graph_object of the link. |
Mauro Carvalho Chehab | e383ce0 | 2016-09-22 07:59:03 -0300 | [diff] [blame] | 123 | * @sink: Part of a union. Used only if the second object (gobj1) is |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 124 | * a pad. In that case, it represents the sink pad. |
| 125 | * @entity: Part of a union. Used only if the second object (gobj1) is |
| 126 | * an entity. |
| 127 | * @reverse: Pointer to the link for the reverse direction of a pad to pad |
| 128 | * link. |
| 129 | * @flags: Link flags, as defined in uapi/media.h (MEDIA_LNK_FL_*) |
Mauro Carvalho Chehab | 39d1ebc6 | 2015-08-30 09:53:57 -0300 | [diff] [blame] | 130 | * @is_backlink: Indicate if the link is a backlink. |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 131 | */ |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 132 | struct media_link { |
Mauro Carvalho Chehab | 6b6a427 | 2015-08-14 12:54:36 -0300 | [diff] [blame] | 133 | struct media_gobj graph_obj; |
Mauro Carvalho Chehab | 57208e5 | 2015-08-07 06:55:40 -0300 | [diff] [blame] | 134 | struct list_head list; |
Mauro Carvalho Chehab | 4b8a3c0 | 2015-08-20 09:10:07 -0300 | [diff] [blame] | 135 | union { |
| 136 | struct media_gobj *gobj0; |
| 137 | struct media_pad *source; |
Mauro Carvalho Chehab | 86e2662 | 2015-08-07 10:36:25 -0300 | [diff] [blame] | 138 | struct media_interface *intf; |
Mauro Carvalho Chehab | 4b8a3c0 | 2015-08-20 09:10:07 -0300 | [diff] [blame] | 139 | }; |
| 140 | union { |
| 141 | struct media_gobj *gobj1; |
| 142 | struct media_pad *sink; |
Mauro Carvalho Chehab | 86e2662 | 2015-08-07 10:36:25 -0300 | [diff] [blame] | 143 | struct media_entity *entity; |
Mauro Carvalho Chehab | 4b8a3c0 | 2015-08-20 09:10:07 -0300 | [diff] [blame] | 144 | }; |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 145 | struct media_link *reverse; |
| 146 | unsigned long flags; |
Mauro Carvalho Chehab | 39d1ebc6 | 2015-08-30 09:53:57 -0300 | [diff] [blame] | 147 | bool is_backlink; |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 148 | }; |
| 149 | |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 150 | /** |
Mauro Carvalho Chehab | c1a37dd | 2018-07-31 08:03:48 -0400 | [diff] [blame] | 151 | * enum media_pad_signal_type - type of the signal inside a media pad |
| 152 | * |
| 153 | * @PAD_SIGNAL_DEFAULT: |
| 154 | * Default signal. Use this when all inputs or all outputs are |
| 155 | * uniquely identified by the pad number. |
| 156 | * @PAD_SIGNAL_ANALOG: |
| 157 | * The pad contains an analog signal. It can be Radio Frequency, |
Bhaskar Chowdhury | 45cdd2a | 2021-03-24 14:21:00 +0100 | [diff] [blame] | 158 | * Intermediate Frequency, a baseband signal or sub-carriers. |
Mauro Carvalho Chehab | c1a37dd | 2018-07-31 08:03:48 -0400 | [diff] [blame] | 159 | * Tuner inputs, IF-PLL demodulators, composite and s-video signals |
| 160 | * should use it. |
| 161 | * @PAD_SIGNAL_DV: |
| 162 | * Contains a digital video signal, with can be a bitstream of samples |
| 163 | * taken from an analog TV video source. On such case, it usually |
| 164 | * contains the VBI data on it. |
| 165 | * @PAD_SIGNAL_AUDIO: |
| 166 | * Contains an Intermediate Frequency analog signal from an audio |
| 167 | * sub-carrier or an audio bitstream. IF signals are provided by tuners |
| 168 | * and consumed by audio AM/FM decoders. Bitstream audio is provided by |
| 169 | * an audio decoder. |
| 170 | */ |
| 171 | enum media_pad_signal_type { |
| 172 | PAD_SIGNAL_DEFAULT = 0, |
| 173 | PAD_SIGNAL_ANALOG, |
| 174 | PAD_SIGNAL_DV, |
| 175 | PAD_SIGNAL_AUDIO, |
| 176 | }; |
| 177 | |
| 178 | /** |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 179 | * struct media_pad - A media pad graph object. |
| 180 | * |
| 181 | * @graph_obj: Embedded structure containing the media object common data |
| 182 | * @entity: Entity this pad belongs to |
| 183 | * @index: Pad index in the entity pads array, numbered from 0 to n |
Mauro Carvalho Chehab | c1a37dd | 2018-07-31 08:03:48 -0400 | [diff] [blame] | 184 | * @sig_type: Type of the signal inside a media pad |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 185 | * @flags: Pad flags, as defined in |
| 186 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 187 | * (seek for ``MEDIA_PAD_FL_*``) |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 188 | */ |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 189 | struct media_pad { |
Mauro Carvalho Chehab | 4b8a3c0 | 2015-08-20 09:10:07 -0300 | [diff] [blame] | 190 | struct media_gobj graph_obj; /* must be first field in struct */ |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 191 | struct media_entity *entity; |
| 192 | u16 index; |
Mauro Carvalho Chehab | c1a37dd | 2018-07-31 08:03:48 -0400 | [diff] [blame] | 193 | enum media_pad_signal_type sig_type; |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 194 | unsigned long flags; |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 195 | }; |
| 196 | |
Laurent Pinchart | 5a5394b | 2014-03-26 00:01:44 -0300 | [diff] [blame] | 197 | /** |
| 198 | * struct media_entity_operations - Media entity operations |
Niklas Söderlund | ae45cd5 | 2017-06-15 06:17:25 -0300 | [diff] [blame] | 199 | * @get_fwnode_pad: Return the pad number based on a fwnode endpoint or |
| 200 | * a negative value on error. This operation can be used |
| 201 | * to map a fwnode to a media pad number. Optional. |
Laurent Pinchart | 5a5394b | 2014-03-26 00:01:44 -0300 | [diff] [blame] | 202 | * @link_setup: Notify the entity of link changes. The operation can |
| 203 | * return an error, in which case link setup will be |
| 204 | * cancelled. Optional. |
| 205 | * @link_validate: Return whether a link is valid from the entity point of |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 206 | * view. The media_pipeline_start() function |
Laurent Pinchart | 5a5394b | 2014-03-26 00:01:44 -0300 | [diff] [blame] | 207 | * validates all links by calling this operation. Optional. |
Mauro Carvalho Chehab | 5ed470f | 2016-04-06 10:55:25 -0300 | [diff] [blame] | 208 | * |
Mauro Carvalho Chehab | 5b8700e | 2016-07-20 09:22:38 -0300 | [diff] [blame] | 209 | * .. note:: |
| 210 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 211 | * Those these callbacks are called with struct &media_device.graph_mutex |
Mauro Carvalho Chehab | 5b8700e | 2016-07-20 09:22:38 -0300 | [diff] [blame] | 212 | * mutex held. |
Laurent Pinchart | 5a5394b | 2014-03-26 00:01:44 -0300 | [diff] [blame] | 213 | */ |
Laurent Pinchart | 97548ed | 2009-12-09 08:40:03 -0300 | [diff] [blame] | 214 | struct media_entity_operations { |
Steve Longerbeam | 70d4a9e | 2020-05-01 19:15:35 +0200 | [diff] [blame] | 215 | int (*get_fwnode_pad)(struct media_entity *entity, |
| 216 | struct fwnode_endpoint *endpoint); |
Laurent Pinchart | 97548ed | 2009-12-09 08:40:03 -0300 | [diff] [blame] | 217 | int (*link_setup)(struct media_entity *entity, |
| 218 | const struct media_pad *local, |
| 219 | const struct media_pad *remote, u32 flags); |
Sakari Ailus | af88be3 | 2012-01-11 06:25:15 -0300 | [diff] [blame] | 220 | int (*link_validate)(struct media_link *link); |
Laurent Pinchart | 97548ed | 2009-12-09 08:40:03 -0300 | [diff] [blame] | 221 | }; |
| 222 | |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 223 | /** |
Laurent Pinchart | b76a2a8 | 2016-02-29 08:45:44 -0300 | [diff] [blame] | 224 | * enum media_entity_type - Media entity type |
| 225 | * |
| 226 | * @MEDIA_ENTITY_TYPE_BASE: |
| 227 | * The entity isn't embedded in another subsystem structure. |
| 228 | * @MEDIA_ENTITY_TYPE_VIDEO_DEVICE: |
| 229 | * The entity is embedded in a struct video_device instance. |
| 230 | * @MEDIA_ENTITY_TYPE_V4L2_SUBDEV: |
| 231 | * The entity is embedded in a struct v4l2_subdev instance. |
| 232 | * |
| 233 | * Media entity objects are often not instantiated directly, but the media |
| 234 | * entity structure is inherited by (through embedding) other subsystem-specific |
| 235 | * structures. The media entity type identifies the type of the subclass |
| 236 | * structure that implements a media entity instance. |
| 237 | * |
| 238 | * This allows runtime type identification of media entities and safe casting to |
| 239 | * the correct object type. For instance, a media entity structure instance |
| 240 | * embedded in a v4l2_subdev structure instance will have the type |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 241 | * %MEDIA_ENTITY_TYPE_V4L2_SUBDEV and can safely be cast to a &v4l2_subdev |
Laurent Pinchart | b76a2a8 | 2016-02-29 08:45:44 -0300 | [diff] [blame] | 242 | * structure using the container_of() macro. |
| 243 | */ |
| 244 | enum media_entity_type { |
| 245 | MEDIA_ENTITY_TYPE_BASE, |
| 246 | MEDIA_ENTITY_TYPE_VIDEO_DEVICE, |
| 247 | MEDIA_ENTITY_TYPE_V4L2_SUBDEV, |
| 248 | }; |
| 249 | |
| 250 | /** |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 251 | * struct media_entity - A media entity graph object. |
| 252 | * |
| 253 | * @graph_obj: Embedded structure containing the media object common data. |
| 254 | * @name: Entity name. |
Laurent Pinchart | b76a2a8 | 2016-02-29 08:45:44 -0300 | [diff] [blame] | 255 | * @obj_type: Type of the object that implements the media_entity. |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 256 | * @function: Entity main function, as defined in |
| 257 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 258 | * (seek for ``MEDIA_ENT_F_*``) |
| 259 | * @flags: Entity flags, as defined in |
| 260 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 261 | * (seek for ``MEDIA_ENT_FL_*``) |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 262 | * @num_pads: Number of sink and source pads. |
| 263 | * @num_links: Total number of links, forward and back, enabled and disabled. |
| 264 | * @num_backlinks: Number of backlinks |
Sakari Ailus | 665faa9 | 2015-12-16 11:32:17 -0200 | [diff] [blame] | 265 | * @internal_idx: An unique internal entity specific number. The numbers are |
| 266 | * re-used if entities are unregistered or registered again. |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 267 | * @pads: Pads array with the size defined by @num_pads. |
| 268 | * @links: List of data links. |
| 269 | * @ops: Entity operations. |
| 270 | * @stream_count: Stream count for the entity. |
| 271 | * @use_count: Use count for the entity. |
| 272 | * @pipe: Pipeline this entity belongs to. |
| 273 | * @info: Union with devnode information. Kept just for backward |
| 274 | * compatibility. |
Mauro Carvalho Chehab | bd945e4 | 2017-09-27 15:54:43 -0400 | [diff] [blame] | 275 | * @info.dev: Contains device major and minor info. |
| 276 | * @info.dev.major: device node major, if the device is a devnode. |
| 277 | * @info.dev.minor: device node minor, if the device is a devnode. |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 278 | * @major: Devnode major number (zero if not applicable). Kept just |
| 279 | * for backward compatibility. |
| 280 | * @minor: Devnode minor number (zero if not applicable). Kept just |
| 281 | * for backward compatibility. |
| 282 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 283 | * .. note:: |
| 284 | * |
| 285 | * @stream_count and @use_count reference counts must never be |
| 286 | * negative, but are signed integers on purpose: a simple ``WARN_ON(<0)`` |
| 287 | * check can be used to detect reference count bugs that would make them |
| 288 | * negative. |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 289 | */ |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 290 | struct media_entity { |
Mauro Carvalho Chehab | 4b8a3c0 | 2015-08-20 09:10:07 -0300 | [diff] [blame] | 291 | struct media_gobj graph_obj; /* must be first field in struct */ |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 292 | const char *name; |
Laurent Pinchart | b76a2a8 | 2016-02-29 08:45:44 -0300 | [diff] [blame] | 293 | enum media_entity_type obj_type; |
Mauro Carvalho Chehab | 0e576b7 | 2015-09-06 09:33:39 -0300 | [diff] [blame] | 294 | u32 function; |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 295 | unsigned long flags; |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 296 | |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 297 | u16 num_pads; |
| 298 | u16 num_links; |
| 299 | u16 num_backlinks; |
Sakari Ailus | 665faa9 | 2015-12-16 11:32:17 -0200 | [diff] [blame] | 300 | int internal_idx; |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 301 | |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 302 | struct media_pad *pads; |
| 303 | struct list_head links; |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 304 | |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 305 | const struct media_entity_operations *ops; |
Laurent Pinchart | 97548ed | 2009-12-09 08:40:03 -0300 | [diff] [blame] | 306 | |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 307 | int stream_count; |
| 308 | int use_count; |
Laurent Pinchart | 503c3d82 | 2010-03-07 15:04:59 -0300 | [diff] [blame] | 309 | |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 310 | struct media_pipeline *pipe; |
Laurent Pinchart | e02188c | 2010-08-25 09:00:41 -0300 | [diff] [blame] | 311 | |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 312 | union { |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 313 | struct { |
| 314 | u32 major; |
| 315 | u32 minor; |
Mauro Carvalho Chehab | e31a0ba | 2015-01-02 12:18:23 -0300 | [diff] [blame] | 316 | } dev; |
Clemens Ladisch | fa5034c | 2011-11-05 18:42:01 -0300 | [diff] [blame] | 317 | } info; |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 318 | }; |
| 319 | |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 320 | /** |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 321 | * struct media_interface - A media interface graph object. |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 322 | * |
| 323 | * @graph_obj: embedded graph object |
Mauro Carvalho Chehab | 86e2662 | 2015-08-07 10:36:25 -0300 | [diff] [blame] | 324 | * @links: List of links pointing to graph entities |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 325 | * @type: Type of the interface as defined in |
| 326 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 327 | * (seek for ``MEDIA_INTF_T_*``) |
| 328 | * @flags: Interface flags as defined in |
| 329 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 330 | * (seek for ``MEDIA_INTF_FL_*``) |
| 331 | * |
| 332 | * .. note:: |
| 333 | * |
| 334 | * Currently, no flags for &media_interface is defined. |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 335 | */ |
| 336 | struct media_interface { |
| 337 | struct media_gobj graph_obj; |
Mauro Carvalho Chehab | 86e2662 | 2015-08-07 10:36:25 -0300 | [diff] [blame] | 338 | struct list_head links; |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 339 | u32 type; |
| 340 | u32 flags; |
| 341 | }; |
| 342 | |
| 343 | /** |
Mauro Carvalho Chehab | c358e80 | 2015-08-29 23:43:03 -0300 | [diff] [blame] | 344 | * struct media_intf_devnode - A media interface via a device node. |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 345 | * |
| 346 | * @intf: embedded interface object |
| 347 | * @major: Major number of a device node |
| 348 | * @minor: Minor number of a device node |
| 349 | */ |
| 350 | struct media_intf_devnode { |
| 351 | struct media_interface intf; |
Mauro Carvalho Chehab | c398bb6 | 2015-08-23 08:28:21 -0300 | [diff] [blame] | 352 | |
| 353 | /* Should match the fields at media_v2_intf_devnode */ |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 354 | u32 major; |
| 355 | u32 minor; |
| 356 | }; |
| 357 | |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 358 | /** |
| 359 | * media_entity_id() - return the media entity graph object id |
| 360 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 361 | * @entity: pointer to &media_entity |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 362 | */ |
Mauro Carvalho Chehab | fa76239 | 2015-08-14 10:42:05 -0300 | [diff] [blame] | 363 | static inline u32 media_entity_id(struct media_entity *entity) |
| 364 | { |
Mauro Carvalho Chehab | bfab2aac | 2015-08-14 12:47:48 -0300 | [diff] [blame] | 365 | return entity->graph_obj.id; |
Mauro Carvalho Chehab | fa76239 | 2015-08-14 10:42:05 -0300 | [diff] [blame] | 366 | } |
| 367 | |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 368 | /** |
| 369 | * media_type() - return the media object type |
| 370 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 371 | * @gobj: Pointer to the struct &media_gobj graph object |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 372 | */ |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 373 | static inline enum media_gobj_type media_type(struct media_gobj *gobj) |
| 374 | { |
Mauro Carvalho Chehab | 05b3b77 | 2015-12-16 14:28:01 -0200 | [diff] [blame] | 375 | return gobj->id >> MEDIA_BITS_PER_ID; |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 376 | } |
| 377 | |
Mauro Carvalho Chehab | 630c0e8 | 2015-12-16 15:15:18 -0200 | [diff] [blame] | 378 | /** |
| 379 | * media_id() - return the media object ID |
| 380 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 381 | * @gobj: Pointer to the struct &media_gobj graph object |
Mauro Carvalho Chehab | 630c0e8 | 2015-12-16 15:15:18 -0200 | [diff] [blame] | 382 | */ |
Mauro Carvalho Chehab | 05b3b77 | 2015-12-16 14:28:01 -0200 | [diff] [blame] | 383 | static inline u32 media_id(struct media_gobj *gobj) |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 384 | { |
Mauro Carvalho Chehab | 05b3b77 | 2015-12-16 14:28:01 -0200 | [diff] [blame] | 385 | return gobj->id & MEDIA_ID_MASK; |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 386 | } |
| 387 | |
Mauro Carvalho Chehab | 630c0e8 | 2015-12-16 15:15:18 -0200 | [diff] [blame] | 388 | /** |
| 389 | * media_gobj_gen_id() - encapsulates type and ID on at the object ID |
| 390 | * |
| 391 | * @type: object type as define at enum &media_gobj_type. |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 392 | * @local_id: next ID, from struct &media_device.id. |
Mauro Carvalho Chehab | 630c0e8 | 2015-12-16 15:15:18 -0200 | [diff] [blame] | 393 | */ |
Mauro Carvalho Chehab | 05b3b77 | 2015-12-16 14:28:01 -0200 | [diff] [blame] | 394 | static inline u32 media_gobj_gen_id(enum media_gobj_type type, u64 local_id) |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 395 | { |
| 396 | u32 id; |
| 397 | |
Mauro Carvalho Chehab | 05b3b77 | 2015-12-16 14:28:01 -0200 | [diff] [blame] | 398 | id = type << MEDIA_BITS_PER_ID; |
| 399 | id |= local_id & MEDIA_ID_MASK; |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 400 | |
| 401 | return id; |
| 402 | } |
| 403 | |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 404 | /** |
Laurent Pinchart | 45b4687 | 2016-02-29 08:45:45 -0300 | [diff] [blame] | 405 | * is_media_entity_v4l2_video_device() - Check if the entity is a video_device |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 406 | * @entity: pointer to entity |
| 407 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 408 | * Return: %true if the entity is an instance of a video_device object and can |
Laurent Pinchart | b76a2a8 | 2016-02-29 08:45:44 -0300 | [diff] [blame] | 409 | * safely be cast to a struct video_device using the container_of() macro, or |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 410 | * %false otherwise. |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 411 | */ |
Laurent Pinchart | 45b4687 | 2016-02-29 08:45:45 -0300 | [diff] [blame] | 412 | static inline bool is_media_entity_v4l2_video_device(struct media_entity *entity) |
Mauro Carvalho Chehab | fa17b46 | 2015-08-21 12:17:40 -0300 | [diff] [blame] | 413 | { |
Laurent Pinchart | b76a2a8 | 2016-02-29 08:45:44 -0300 | [diff] [blame] | 414 | return entity && entity->obj_type == MEDIA_ENTITY_TYPE_VIDEO_DEVICE; |
Mauro Carvalho Chehab | fa17b46 | 2015-08-21 12:17:40 -0300 | [diff] [blame] | 415 | } |
| 416 | |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 417 | /** |
Laurent Pinchart | b76a2a8 | 2016-02-29 08:45:44 -0300 | [diff] [blame] | 418 | * is_media_entity_v4l2_subdev() - Check if the entity is a v4l2_subdev |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 419 | * @entity: pointer to entity |
| 420 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 421 | * Return: %true if the entity is an instance of a &v4l2_subdev object and can |
| 422 | * safely be cast to a struct &v4l2_subdev using the container_of() macro, or |
| 423 | * %false otherwise. |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 424 | */ |
Mauro Carvalho Chehab | fa17b46 | 2015-08-21 12:17:40 -0300 | [diff] [blame] | 425 | static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity) |
| 426 | { |
Laurent Pinchart | b76a2a8 | 2016-02-29 08:45:44 -0300 | [diff] [blame] | 427 | return entity && entity->obj_type == MEDIA_ENTITY_TYPE_V4L2_SUBDEV; |
Mauro Carvalho Chehab | fa17b46 | 2015-08-21 12:17:40 -0300 | [diff] [blame] | 428 | } |
| 429 | |
Mauro Carvalho Chehab | 9277799 | 2015-12-16 13:53:04 -0200 | [diff] [blame] | 430 | /** |
| 431 | * __media_entity_enum_init - Initialise an entity enumeration |
| 432 | * |
| 433 | * @ent_enum: Entity enumeration to be initialised |
| 434 | * @idx_max: Maximum number of entities in the enumeration |
| 435 | * |
| 436 | * Return: Returns zero on success or a negative error code. |
| 437 | */ |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 438 | __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, |
| 439 | int idx_max); |
Mauro Carvalho Chehab | 9277799 | 2015-12-16 13:53:04 -0200 | [diff] [blame] | 440 | |
| 441 | /** |
| 442 | * media_entity_enum_cleanup - Release resources of an entity enumeration |
| 443 | * |
| 444 | * @ent_enum: Entity enumeration to be released |
| 445 | */ |
| 446 | void media_entity_enum_cleanup(struct media_entity_enum *ent_enum); |
Sakari Ailus | a5ccc48 | 2010-03-07 16:14:14 -0300 | [diff] [blame] | 447 | |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 448 | /** |
| 449 | * media_entity_enum_zero - Clear the entire enum |
| 450 | * |
Mauro Carvalho Chehab | 03e4933 | 2015-12-16 13:58:31 -0200 | [diff] [blame] | 451 | * @ent_enum: Entity enumeration to be cleared |
Mauro Carvalho Chehab | ef69ee1 | 2015-10-01 18:07:53 -0300 | [diff] [blame] | 452 | */ |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 453 | static inline void media_entity_enum_zero(struct media_entity_enum *ent_enum) |
| 454 | { |
| 455 | bitmap_zero(ent_enum->bmap, ent_enum->idx_max); |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * media_entity_enum_set - Mark a single entity in the enum |
| 460 | * |
Mauro Carvalho Chehab | 03e4933 | 2015-12-16 13:58:31 -0200 | [diff] [blame] | 461 | * @ent_enum: Entity enumeration |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 462 | * @entity: Entity to be marked |
| 463 | */ |
| 464 | static inline void media_entity_enum_set(struct media_entity_enum *ent_enum, |
| 465 | struct media_entity *entity) |
| 466 | { |
| 467 | if (WARN_ON(entity->internal_idx >= ent_enum->idx_max)) |
| 468 | return; |
| 469 | |
| 470 | __set_bit(entity->internal_idx, ent_enum->bmap); |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * media_entity_enum_clear - Unmark a single entity in the enum |
| 475 | * |
Mauro Carvalho Chehab | 03e4933 | 2015-12-16 13:58:31 -0200 | [diff] [blame] | 476 | * @ent_enum: Entity enumeration |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 477 | * @entity: Entity to be unmarked |
| 478 | */ |
| 479 | static inline void media_entity_enum_clear(struct media_entity_enum *ent_enum, |
| 480 | struct media_entity *entity) |
| 481 | { |
| 482 | if (WARN_ON(entity->internal_idx >= ent_enum->idx_max)) |
| 483 | return; |
| 484 | |
| 485 | __clear_bit(entity->internal_idx, ent_enum->bmap); |
| 486 | } |
| 487 | |
| 488 | /** |
| 489 | * media_entity_enum_test - Test whether the entity is marked |
| 490 | * |
Mauro Carvalho Chehab | 03e4933 | 2015-12-16 13:58:31 -0200 | [diff] [blame] | 491 | * @ent_enum: Entity enumeration |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 492 | * @entity: Entity to be tested |
| 493 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 494 | * Returns %true if the entity was marked. |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 495 | */ |
| 496 | static inline bool media_entity_enum_test(struct media_entity_enum *ent_enum, |
| 497 | struct media_entity *entity) |
| 498 | { |
| 499 | if (WARN_ON(entity->internal_idx >= ent_enum->idx_max)) |
| 500 | return true; |
| 501 | |
| 502 | return test_bit(entity->internal_idx, ent_enum->bmap); |
| 503 | } |
| 504 | |
| 505 | /** |
Mauro Carvalho Chehab | e383ce0 | 2016-09-22 07:59:03 -0300 | [diff] [blame] | 506 | * media_entity_enum_test_and_set - Test whether the entity is marked, |
| 507 | * and mark it |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 508 | * |
Mauro Carvalho Chehab | 03e4933 | 2015-12-16 13:58:31 -0200 | [diff] [blame] | 509 | * @ent_enum: Entity enumeration |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 510 | * @entity: Entity to be tested |
| 511 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 512 | * Returns %true if the entity was marked, and mark it before doing so. |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 513 | */ |
Mauro Carvalho Chehab | 03e4933 | 2015-12-16 13:58:31 -0200 | [diff] [blame] | 514 | static inline bool |
| 515 | media_entity_enum_test_and_set(struct media_entity_enum *ent_enum, |
| 516 | struct media_entity *entity) |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 517 | { |
| 518 | if (WARN_ON(entity->internal_idx >= ent_enum->idx_max)) |
| 519 | return true; |
| 520 | |
| 521 | return __test_and_set_bit(entity->internal_idx, ent_enum->bmap); |
| 522 | } |
| 523 | |
| 524 | /** |
Mauro Carvalho Chehab | 03e4933 | 2015-12-16 13:58:31 -0200 | [diff] [blame] | 525 | * media_entity_enum_empty - Test whether the entire enum is empty |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 526 | * |
Mauro Carvalho Chehab | 03e4933 | 2015-12-16 13:58:31 -0200 | [diff] [blame] | 527 | * @ent_enum: Entity enumeration |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 528 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 529 | * Return: %true if the entity was empty. |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 530 | */ |
| 531 | static inline bool media_entity_enum_empty(struct media_entity_enum *ent_enum) |
| 532 | { |
| 533 | return bitmap_empty(ent_enum->bmap, ent_enum->idx_max); |
| 534 | } |
| 535 | |
| 536 | /** |
| 537 | * media_entity_enum_intersects - Test whether two enums intersect |
| 538 | * |
Mauro Carvalho Chehab | 03e4933 | 2015-12-16 13:58:31 -0200 | [diff] [blame] | 539 | * @ent_enum1: First entity enumeration |
| 540 | * @ent_enum2: Second entity enumeration |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 541 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 542 | * Return: %true if entity enumerations @ent_enum1 and @ent_enum2 intersect, |
| 543 | * otherwise %false. |
Sakari Ailus | c8d54cd | 2015-12-16 11:44:32 -0200 | [diff] [blame] | 544 | */ |
| 545 | static inline bool media_entity_enum_intersects( |
| 546 | struct media_entity_enum *ent_enum1, |
| 547 | struct media_entity_enum *ent_enum2) |
| 548 | { |
| 549 | WARN_ON(ent_enum1->idx_max != ent_enum2->idx_max); |
| 550 | |
| 551 | return bitmap_intersects(ent_enum1->bmap, ent_enum2->bmap, |
| 552 | min(ent_enum1->idx_max, ent_enum2->idx_max)); |
| 553 | } |
Mauro Carvalho Chehab | ef69ee1 | 2015-10-01 18:07:53 -0300 | [diff] [blame] | 554 | |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 555 | /** |
| 556 | * gobj_to_entity - returns the struct &media_entity pointer from the |
| 557 | * @gobj contained on it. |
| 558 | * |
| 559 | * @gobj: Pointer to the struct &media_gobj graph object |
| 560 | */ |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 561 | #define gobj_to_entity(gobj) \ |
| 562 | container_of(gobj, struct media_entity, graph_obj) |
| 563 | |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 564 | /** |
Mauro Carvalho Chehab | e383ce0 | 2016-09-22 07:59:03 -0300 | [diff] [blame] | 565 | * gobj_to_pad - returns the struct &media_pad pointer from the |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 566 | * @gobj contained on it. |
| 567 | * |
| 568 | * @gobj: Pointer to the struct &media_gobj graph object |
| 569 | */ |
Mauro Carvalho Chehab | 39a956c | 2015-08-13 14:42:42 -0300 | [diff] [blame] | 570 | #define gobj_to_pad(gobj) \ |
| 571 | container_of(gobj, struct media_pad, graph_obj) |
| 572 | |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 573 | /** |
Mauro Carvalho Chehab | e383ce0 | 2016-09-22 07:59:03 -0300 | [diff] [blame] | 574 | * gobj_to_link - returns the struct &media_link pointer from the |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 575 | * @gobj contained on it. |
| 576 | * |
| 577 | * @gobj: Pointer to the struct &media_gobj graph object |
| 578 | */ |
Mauro Carvalho Chehab | 39a956c | 2015-08-13 14:42:42 -0300 | [diff] [blame] | 579 | #define gobj_to_link(gobj) \ |
| 580 | container_of(gobj, struct media_link, graph_obj) |
| 581 | |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 582 | /** |
Mauro Carvalho Chehab | e383ce0 | 2016-09-22 07:59:03 -0300 | [diff] [blame] | 583 | * gobj_to_intf - returns the struct &media_interface pointer from the |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 584 | * @gobj contained on it. |
| 585 | * |
| 586 | * @gobj: Pointer to the struct &media_gobj graph object |
| 587 | */ |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 588 | #define gobj_to_intf(gobj) \ |
| 589 | container_of(gobj, struct media_interface, graph_obj) |
| 590 | |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 591 | /** |
Mauro Carvalho Chehab | e383ce0 | 2016-09-22 07:59:03 -0300 | [diff] [blame] | 592 | * intf_to_devnode - returns the struct media_intf_devnode pointer from the |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 593 | * @intf contained on it. |
| 594 | * |
| 595 | * @intf: Pointer to struct &media_intf_devnode |
| 596 | */ |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 597 | #define intf_to_devnode(intf) \ |
| 598 | container_of(intf, struct media_intf_devnode, intf) |
| 599 | |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 600 | /** |
| 601 | * media_gobj_create - Initialize a graph object |
| 602 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 603 | * @mdev: Pointer to the &media_device that contains the object |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 604 | * @type: Type of the object |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 605 | * @gobj: Pointer to the struct &media_gobj graph object |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 606 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 607 | * This routine initializes the embedded struct &media_gobj inside a |
| 608 | * media graph object. It is called automatically if ``media_*_create`` |
| 609 | * function calls are used. However, if the object (entity, link, pad, |
| 610 | * interface) is embedded on some other object, this function should be |
| 611 | * called before registering the object at the media controller. |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 612 | */ |
Mauro Carvalho Chehab | c350ef8 | 2015-12-11 11:55:40 -0200 | [diff] [blame] | 613 | void media_gobj_create(struct media_device *mdev, |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 614 | enum media_gobj_type type, |
| 615 | struct media_gobj *gobj); |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 616 | |
| 617 | /** |
| 618 | * media_gobj_destroy - Stop using a graph object on a media device |
| 619 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 620 | * @gobj: Pointer to the struct &media_gobj graph object |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 621 | * |
| 622 | * This should be called by all routines like media_device_unregister() |
| 623 | * that remove/destroy media graph objects. |
| 624 | */ |
Mauro Carvalho Chehab | c350ef8 | 2015-12-11 11:55:40 -0200 | [diff] [blame] | 625 | void media_gobj_destroy(struct media_gobj *gobj); |
Mauro Carvalho Chehab | ec6e4c9 | 2015-08-25 10:28:36 -0300 | [diff] [blame] | 626 | |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 627 | /** |
| 628 | * media_entity_pads_init() - Initialize the entity pads |
| 629 | * |
| 630 | * @entity: entity where the pads belong |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 631 | * @num_pads: total number of sink and source pads |
| 632 | * @pads: Array of @num_pads pads. |
| 633 | * |
| 634 | * The pads array is managed by the entity driver and passed to |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 635 | * media_entity_pads_init() where its pointer will be stored in the |
| 636 | * &media_entity structure. |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 637 | * |
| 638 | * If no pads are needed, drivers could either directly fill |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 639 | * &media_entity->num_pads with 0 and &media_entity->pads with %NULL or call |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 640 | * this function that will do the same. |
| 641 | * |
| 642 | * As the number of pads is known in advance, the pads array is not allocated |
| 643 | * dynamically but is managed by the entity driver. Most drivers will embed the |
| 644 | * pads array in a driver-specific structure, avoiding dynamic allocation. |
| 645 | * |
| 646 | * Drivers must set the direction of every pad in the pads array before calling |
| 647 | * media_entity_pads_init(). The function will initialize the other pads fields. |
| 648 | */ |
Mauro Carvalho Chehab | ab22e77 | 2015-12-11 07:44:40 -0200 | [diff] [blame] | 649 | int media_entity_pads_init(struct media_entity *entity, u16 num_pads, |
Mauro Carvalho Chehab | 57208e5 | 2015-08-07 06:55:40 -0300 | [diff] [blame] | 650 | struct media_pad *pads); |
Mauro Carvalho Chehab | f1fd328 | 2015-12-11 09:13:23 -0200 | [diff] [blame] | 651 | |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 652 | /** |
| 653 | * media_entity_cleanup() - free resources associated with an entity |
| 654 | * |
| 655 | * @entity: entity where the pads belong |
| 656 | * |
| 657 | * This function must be called during the cleanup phase after unregistering |
| 658 | * the entity (currently, it does nothing). |
| 659 | */ |
Sakari Ailus | 3580112 | 2018-01-09 05:20:34 -0500 | [diff] [blame] | 660 | #if IS_ENABLED(CONFIG_MEDIA_CONTROLLER) |
| 661 | static inline void media_entity_cleanup(struct media_entity *entity) {} |
| 662 | #else |
| 663 | #define media_entity_cleanup(entity) do { } while (false) |
| 664 | #endif |
Laurent Pinchart | e02188c | 2010-08-25 09:00:41 -0300 | [diff] [blame] | 665 | |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 666 | /** |
Mauro Carvalho Chehab | 9d6d20e | 2018-07-31 09:22:40 -0400 | [diff] [blame] | 667 | * media_get_pad_index() - retrieves a pad index from an entity |
| 668 | * |
| 669 | * @entity: entity where the pads belong |
| 670 | * @is_sink: true if the pad is a sink, false if it is a source |
| 671 | * @sig_type: type of signal of the pad to be search |
| 672 | * |
| 673 | * This helper function finds the first pad index inside an entity that |
| 674 | * satisfies both @is_sink and @sig_type conditions. |
| 675 | * |
| 676 | * Return: |
| 677 | * |
| 678 | * On success, return the pad number. If the pad was not found or the media |
| 679 | * entity is a NULL pointer, return -EINVAL. |
| 680 | */ |
| 681 | int media_get_pad_index(struct media_entity *entity, bool is_sink, |
| 682 | enum media_pad_signal_type sig_type); |
| 683 | |
| 684 | /** |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 685 | * media_create_pad_link() - creates a link between two entities. |
| 686 | * |
| 687 | * @source: pointer to &media_entity of the source pad. |
| 688 | * @source_pad: number of the source pad in the pads array |
| 689 | * @sink: pointer to &media_entity of the sink pad. |
| 690 | * @sink_pad: number of the sink pad in the pads array. |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 691 | * @flags: Link flags, as defined in |
| 692 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 693 | * ( seek for ``MEDIA_LNK_FL_*``) |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 694 | * |
| 695 | * Valid values for flags: |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 696 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 697 | * %MEDIA_LNK_FL_ENABLED |
| 698 | * Indicates that the link is enabled and can be used to transfer media data. |
| 699 | * When two or more links target a sink pad, only one of them can be |
| 700 | * enabled at a time. |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 701 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 702 | * %MEDIA_LNK_FL_IMMUTABLE |
| 703 | * Indicates that the link enabled state can't be modified at runtime. If |
| 704 | * %MEDIA_LNK_FL_IMMUTABLE is set, then %MEDIA_LNK_FL_ENABLED must also be |
| 705 | * set, since an immutable link is always enabled. |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 706 | * |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 707 | * .. note:: |
| 708 | * |
| 709 | * Before calling this function, media_entity_pads_init() and |
| 710 | * media_device_register_entity() should be called previously for both ends. |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 711 | */ |
Mauro Carvalho Chehab | 7732804 | 2015-09-04 16:08:24 -0300 | [diff] [blame] | 712 | __must_check int media_create_pad_link(struct media_entity *source, |
| 713 | u16 source_pad, struct media_entity *sink, |
| 714 | u16 sink_pad, u32 flags); |
Mauro Carvalho Chehab | b01cc9c | 2015-12-30 09:45:48 -0200 | [diff] [blame] | 715 | |
| 716 | /** |
| 717 | * media_create_pad_links() - creates a link between two entities. |
| 718 | * |
| 719 | * @mdev: Pointer to the media_device that contains the object |
| 720 | * @source_function: Function of the source entities. Used only if @source is |
| 721 | * NULL. |
| 722 | * @source: pointer to &media_entity of the source pad. If NULL, it will use |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 723 | * all entities that matches the @sink_function. |
Mauro Carvalho Chehab | b01cc9c | 2015-12-30 09:45:48 -0200 | [diff] [blame] | 724 | * @source_pad: number of the source pad in the pads array |
| 725 | * @sink_function: Function of the sink entities. Used only if @sink is NULL. |
| 726 | * @sink: pointer to &media_entity of the sink pad. If NULL, it will use |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 727 | * all entities that matches the @sink_function. |
Mauro Carvalho Chehab | b01cc9c | 2015-12-30 09:45:48 -0200 | [diff] [blame] | 728 | * @sink_pad: number of the sink pad in the pads array. |
| 729 | * @flags: Link flags, as defined in include/uapi/linux/media.h. |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 730 | * @allow_both_undefined: if %true, then both @source and @sink can be NULL. |
Mauro Carvalho Chehab | b01cc9c | 2015-12-30 09:45:48 -0200 | [diff] [blame] | 731 | * In such case, it will create a crossbar between all entities that |
| 732 | * matches @source_function to all entities that matches @sink_function. |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 733 | * If %false, it will return 0 and won't create any link if both @source |
Mauro Carvalho Chehab | b01cc9c | 2015-12-30 09:45:48 -0200 | [diff] [blame] | 734 | * and @sink are NULL. |
| 735 | * |
| 736 | * Valid values for flags: |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 737 | * |
Mauro Carvalho Chehab | b01cc9c | 2015-12-30 09:45:48 -0200 | [diff] [blame] | 738 | * A %MEDIA_LNK_FL_ENABLED flag indicates that the link is enabled and can be |
| 739 | * used to transfer media data. If multiple links are created and this |
| 740 | * flag is passed as an argument, only the first created link will have |
| 741 | * this flag. |
| 742 | * |
| 743 | * A %MEDIA_LNK_FL_IMMUTABLE flag indicates that the link enabled state can't |
| 744 | * be modified at runtime. If %MEDIA_LNK_FL_IMMUTABLE is set, then |
| 745 | * %MEDIA_LNK_FL_ENABLED must also be set since an immutable link is |
| 746 | * always enabled. |
| 747 | * |
| 748 | * It is common for some devices to have multiple source and/or sink entities |
| 749 | * of the same type that should be linked. While media_create_pad_link() |
| 750 | * creates link by link, this function is meant to allow 1:n, n:1 and even |
| 751 | * cross-bar (n:n) links. |
| 752 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 753 | * .. note:: |
| 754 | * |
| 755 | * Before calling this function, media_entity_pads_init() and |
| 756 | * media_device_register_entity() should be called previously for the |
| 757 | * entities to be linked. |
Mauro Carvalho Chehab | b01cc9c | 2015-12-30 09:45:48 -0200 | [diff] [blame] | 758 | */ |
| 759 | int media_create_pad_links(const struct media_device *mdev, |
| 760 | const u32 source_function, |
| 761 | struct media_entity *source, |
| 762 | const u16 source_pad, |
| 763 | const u32 sink_function, |
| 764 | struct media_entity *sink, |
| 765 | const u16 sink_pad, |
| 766 | u32 flags, |
| 767 | const bool allow_both_undefined); |
| 768 | |
Sylwester Nawrocki | 7349cec | 2013-05-09 08:29:32 -0300 | [diff] [blame] | 769 | void __media_entity_remove_links(struct media_entity *entity); |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 770 | |
| 771 | /** |
| 772 | * media_entity_remove_links() - remove all links associated with an entity |
| 773 | * |
| 774 | * @entity: pointer to &media_entity |
| 775 | * |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 776 | * .. note:: |
| 777 | * |
| 778 | * This is called automatically when an entity is unregistered via |
| 779 | * media_device_register_entity(). |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 780 | */ |
Sylwester Nawrocki | 7349cec | 2013-05-09 08:29:32 -0300 | [diff] [blame] | 781 | void media_entity_remove_links(struct media_entity *entity); |
| 782 | |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 783 | /** |
| 784 | * __media_entity_setup_link - Configure a media link without locking |
| 785 | * @link: The link being configured |
| 786 | * @flags: Link configuration flags |
| 787 | * |
| 788 | * The bulk of link setup is handled by the two entities connected through the |
| 789 | * link. This function notifies both entities of the link configuration change. |
| 790 | * |
| 791 | * If the link is immutable or if the current and new configuration are |
| 792 | * identical, return immediately. |
| 793 | * |
| 794 | * The user is expected to hold link->source->parent->mutex. If not, |
| 795 | * media_entity_setup_link() should be used instead. |
| 796 | */ |
Laurent Pinchart | 97548ed | 2009-12-09 08:40:03 -0300 | [diff] [blame] | 797 | int __media_entity_setup_link(struct media_link *link, u32 flags); |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 798 | |
| 799 | /** |
| 800 | * media_entity_setup_link() - changes the link flags properties in runtime |
| 801 | * |
| 802 | * @link: pointer to &media_link |
| 803 | * @flags: the requested new link flags |
| 804 | * |
| 805 | * The only configurable property is the %MEDIA_LNK_FL_ENABLED link flag |
Randy Dunlap | 91bbbf2 | 2020-07-15 00:05:52 +0200 | [diff] [blame] | 806 | * to enable/disable a link. Links marked with the |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 807 | * %MEDIA_LNK_FL_IMMUTABLE link flag can not be enabled or disabled. |
| 808 | * |
| 809 | * When a link is enabled or disabled, the media framework calls the |
| 810 | * link_setup operation for the two entities at the source and sink of the |
| 811 | * link, in that order. If the second link_setup call fails, another |
| 812 | * link_setup call is made on the first entity to restore the original link |
| 813 | * flags. |
| 814 | * |
| 815 | * Media device drivers can be notified of link setup operations by setting the |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 816 | * &media_device.link_notify pointer to a callback function. If provided, the |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 817 | * notification callback will be called before enabling and after disabling |
| 818 | * links. |
| 819 | * |
| 820 | * Entity drivers must implement the link_setup operation if any of their links |
| 821 | * is non-immutable. The operation must either configure the hardware or store |
| 822 | * the configuration information to be applied later. |
| 823 | * |
| 824 | * Link configuration must not have any side effect on other links. If an |
| 825 | * enabled link at a sink pad prevents another link at the same pad from |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 826 | * being enabled, the link_setup operation must return %-EBUSY and can't |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 827 | * implicitly disable the first enabled link. |
| 828 | * |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 829 | * .. note:: |
| 830 | * |
| 831 | * The valid values of the flags for the link is the same as described |
| 832 | * on media_create_pad_link(), for pad to pad links or the same as described |
| 833 | * on media_create_intf_link(), for interface to entity links. |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 834 | */ |
Laurent Pinchart | 97548ed | 2009-12-09 08:40:03 -0300 | [diff] [blame] | 835 | int media_entity_setup_link(struct media_link *link, u32 flags); |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 836 | |
| 837 | /** |
| 838 | * media_entity_find_link - Find a link between two pads |
| 839 | * @source: Source pad |
| 840 | * @sink: Sink pad |
| 841 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 842 | * Return: returns a pointer to the link between the two entities. If no |
| 843 | * such link exists, return %NULL. |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 844 | */ |
Laurent Pinchart | 97548ed | 2009-12-09 08:40:03 -0300 | [diff] [blame] | 845 | struct media_link *media_entity_find_link(struct media_pad *source, |
| 846 | struct media_pad *sink); |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 847 | |
| 848 | /** |
| 849 | * media_entity_remote_pad - Find the pad at the remote end of a link |
| 850 | * @pad: Pad at the local end of the link |
| 851 | * |
| 852 | * Search for a remote pad connected to the given pad by iterating over all |
| 853 | * links originating or terminating at that pad until an enabled link is found. |
| 854 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 855 | * Return: returns a pointer to the pad at the remote end of the first found |
| 856 | * enabled link, or %NULL if no enabled link has been found. |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 857 | */ |
Todor Tomov | 6538b02 | 2017-07-03 08:08:11 -0400 | [diff] [blame] | 858 | struct media_pad *media_entity_remote_pad(const struct media_pad *pad); |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 859 | |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 860 | /** |
Niklas Söderlund | d295c6a | 2017-06-15 06:17:26 -0300 | [diff] [blame] | 861 | * media_entity_get_fwnode_pad - Get pad number from fwnode |
| 862 | * |
| 863 | * @entity: The entity |
| 864 | * @fwnode: Pointer to the fwnode_handle which should be used to find the pad |
| 865 | * @direction_flags: Expected direction of the pad, as defined in |
| 866 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 867 | * (seek for ``MEDIA_PAD_FL_*``) |
| 868 | * |
| 869 | * This function can be used to resolve the media pad number from |
| 870 | * a fwnode. This is useful for devices which use more complex |
| 871 | * mappings of media pads. |
| 872 | * |
Niklas Söderlund | f0a3fa2 | 2018-04-08 12:11:52 -0400 | [diff] [blame] | 873 | * If the entity does not implement the get_fwnode_pad() operation |
Niklas Söderlund | d295c6a | 2017-06-15 06:17:26 -0300 | [diff] [blame] | 874 | * then this function searches the entity for the first pad that |
| 875 | * matches the @direction_flags. |
| 876 | * |
| 877 | * Return: returns the pad number on success or a negative error code. |
| 878 | */ |
| 879 | int media_entity_get_fwnode_pad(struct media_entity *entity, |
| 880 | struct fwnode_handle *fwnode, |
| 881 | unsigned long direction_flags); |
| 882 | |
| 883 | /** |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 884 | * media_graph_walk_init - Allocate resources used by graph walk. |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 885 | * |
| 886 | * @graph: Media graph structure that will be used to walk the graph |
| 887 | * @mdev: Pointer to the &media_device that contains the object |
Sakari Ailus | 4ebddb7 | 2021-03-12 10:05:44 +0100 | [diff] [blame] | 888 | * |
| 889 | * The caller is required to hold the media_device graph_mutex during the graph |
| 890 | * walk until the graph state is released. |
| 891 | * |
| 892 | * Returns zero on success or a negative error code otherwise. |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 893 | */ |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 894 | __must_check int media_graph_walk_init( |
| 895 | struct media_graph *graph, struct media_device *mdev); |
Mauro Carvalho Chehab | aa360d3 | 2015-12-16 13:56:14 -0200 | [diff] [blame] | 896 | |
| 897 | /** |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 898 | * media_graph_walk_cleanup - Release resources used by graph walk. |
Mauro Carvalho Chehab | aa360d3 | 2015-12-16 13:56:14 -0200 | [diff] [blame] | 899 | * |
| 900 | * @graph: Media graph structure that will be used to walk the graph |
| 901 | */ |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 902 | void media_graph_walk_cleanup(struct media_graph *graph); |
Sakari Ailus | e03d220 | 2015-12-16 11:32:22 -0200 | [diff] [blame] | 903 | |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 904 | /** |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 905 | * media_graph_walk_start - Start walking the media graph at a |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 906 | * given entity |
| 907 | * |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 908 | * @graph: Media graph structure that will be used to walk the graph |
| 909 | * @entity: Starting entity |
| 910 | * |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 911 | * Before using this function, media_graph_walk_init() must be |
Sakari Ailus | e03d220 | 2015-12-16 11:32:22 -0200 | [diff] [blame] | 912 | * used to allocate resources used for walking the graph. This |
| 913 | * function initializes the graph traversal structure to walk the |
| 914 | * entities graph starting at the given entity. The traversal |
| 915 | * structure must not be modified by the caller during graph |
| 916 | * traversal. After the graph walk, the resources must be released |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 917 | * using media_graph_walk_cleanup(). |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 918 | */ |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 919 | void media_graph_walk_start(struct media_graph *graph, |
| 920 | struct media_entity *entity); |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 921 | |
| 922 | /** |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 923 | * media_graph_walk_next - Get the next entity in the graph |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 924 | * @graph: Media graph structure |
| 925 | * |
| 926 | * Perform a depth-first traversal of the given media entities graph. |
| 927 | * |
| 928 | * The graph structure must have been previously initialized with a call to |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 929 | * media_graph_walk_start(). |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 930 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 931 | * Return: returns the next entity in the graph or %NULL if the whole graph |
| 932 | * have been traversed. |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 933 | */ |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 934 | struct media_entity *media_graph_walk_next(struct media_graph *graph); |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 935 | |
| 936 | /** |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 937 | * media_pipeline_start - Mark a pipeline as streaming |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 938 | * @entity: Starting entity |
| 939 | * @pipe: Media pipeline to be assigned to all entities in the pipeline. |
| 940 | * |
| 941 | * Mark all entities connected to a given entity through enabled links, either |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 942 | * directly or indirectly, as streaming. The given pipeline object is assigned |
| 943 | * to every entity in the pipeline and stored in the media_entity pipe field. |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 944 | * |
| 945 | * Calls to this function can be nested, in which case the same number of |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 946 | * media_pipeline_stop() calls will be required to stop streaming. The |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 947 | * pipeline pointer must be identical for all nested calls to |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 948 | * media_pipeline_start(). |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 949 | */ |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 950 | __must_check int media_pipeline_start(struct media_entity *entity, |
| 951 | struct media_pipeline *pipe); |
Shuah Khan | fb49f20 | 2016-02-11 21:41:24 -0200 | [diff] [blame] | 952 | /** |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 953 | * __media_pipeline_start - Mark a pipeline as streaming |
Shuah Khan | fb49f20 | 2016-02-11 21:41:24 -0200 | [diff] [blame] | 954 | * |
| 955 | * @entity: Starting entity |
| 956 | * @pipe: Media pipeline to be assigned to all entities in the pipeline. |
| 957 | * |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 958 | * ..note:: This is the non-locking version of media_pipeline_start() |
Shuah Khan | fb49f20 | 2016-02-11 21:41:24 -0200 | [diff] [blame] | 959 | */ |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 960 | __must_check int __media_pipeline_start(struct media_entity *entity, |
| 961 | struct media_pipeline *pipe); |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 962 | |
| 963 | /** |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 964 | * media_pipeline_stop - Mark a pipeline as not streaming |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 965 | * @entity: Starting entity |
| 966 | * |
| 967 | * Mark all entities connected to a given entity through enabled links, either |
| 968 | * directly or indirectly, as not streaming. The media_entity pipe field is |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 969 | * reset to %NULL. |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 970 | * |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 971 | * If multiple calls to media_pipeline_start() have been made, the same |
Mauro Carvalho Chehab | 1fc25d3 | 2015-12-11 12:14:58 -0200 | [diff] [blame] | 972 | * number of calls to this function are required to mark the pipeline as not |
| 973 | * streaming. |
| 974 | */ |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 975 | void media_pipeline_stop(struct media_entity *entity); |
Sakari Ailus | a5ccc48 | 2010-03-07 16:14:14 -0300 | [diff] [blame] | 976 | |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 977 | /** |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 978 | * __media_pipeline_stop - Mark a pipeline as not streaming |
Shuah Khan | fb49f20 | 2016-02-11 21:41:24 -0200 | [diff] [blame] | 979 | * |
| 980 | * @entity: Starting entity |
| 981 | * |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 982 | * .. note:: This is the non-locking version of media_pipeline_stop() |
Shuah Khan | fb49f20 | 2016-02-11 21:41:24 -0200 | [diff] [blame] | 983 | */ |
Sakari Ailus | 20b8522 | 2016-11-21 14:48:30 -0200 | [diff] [blame] | 984 | void __media_pipeline_stop(struct media_entity *entity); |
Shuah Khan | fb49f20 | 2016-02-11 21:41:24 -0200 | [diff] [blame] | 985 | |
| 986 | /** |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 987 | * media_devnode_create() - creates and initializes a device node interface |
| 988 | * |
| 989 | * @mdev: pointer to struct &media_device |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 990 | * @type: type of the interface, as given by |
| 991 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 992 | * ( seek for ``MEDIA_INTF_T_*``) macros. |
| 993 | * @flags: Interface flags, as defined in |
| 994 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 995 | * ( seek for ``MEDIA_INTF_FL_*``) |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 996 | * @major: Device node major number. |
| 997 | * @minor: Device node minor number. |
| 998 | * |
| 999 | * Return: if succeeded, returns a pointer to the newly allocated |
| 1000 | * &media_intf_devnode pointer. |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 1001 | * |
| 1002 | * .. note:: |
| 1003 | * |
| 1004 | * Currently, no flags for &media_interface is defined. |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 1005 | */ |
Mauro Carvalho Chehab | 5e5387d | 2015-09-04 15:34:19 -0300 | [diff] [blame] | 1006 | struct media_intf_devnode * |
| 1007 | __must_check media_devnode_create(struct media_device *mdev, |
| 1008 | u32 type, u32 flags, |
Mauro Carvalho Chehab | 0b3b72df9 | 2015-09-09 08:19:25 -0300 | [diff] [blame] | 1009 | u32 major, u32 minor); |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 1010 | /** |
| 1011 | * media_devnode_remove() - removes a device node interface |
| 1012 | * |
| 1013 | * @devnode: pointer to &media_intf_devnode to be freed. |
| 1014 | * |
| 1015 | * When a device node interface is removed, all links to it are automatically |
| 1016 | * removed. |
| 1017 | */ |
Mauro Carvalho Chehab | 27e543f | 2015-08-20 09:07:34 -0300 | [diff] [blame] | 1018 | void media_devnode_remove(struct media_intf_devnode *devnode); |
Mauro Carvalho Chehab | 5e5387d | 2015-09-04 15:34:19 -0300 | [diff] [blame] | 1019 | struct media_link * |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 1020 | |
| 1021 | /** |
| 1022 | * media_create_intf_link() - creates a link between an entity and an interface |
| 1023 | * |
| 1024 | * @entity: pointer to %media_entity |
| 1025 | * @intf: pointer to %media_interface |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 1026 | * @flags: Link flags, as defined in |
| 1027 | * :ref:`include/uapi/linux/media.h <media_header>` |
| 1028 | * ( seek for ``MEDIA_LNK_FL_*``) |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 1029 | * |
| 1030 | * |
| 1031 | * Valid values for flags: |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 1032 | * |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 1033 | * %MEDIA_LNK_FL_ENABLED |
| 1034 | * Indicates that the interface is connected to the entity hardware. |
| 1035 | * That's the default value for interfaces. An interface may be disabled if |
| 1036 | * the hardware is busy due to the usage of some other interface that it is |
| 1037 | * currently controlling the hardware. |
| 1038 | * |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 1039 | * A typical example is an hybrid TV device that handle only one type of |
| 1040 | * stream on a given time. So, when the digital TV is streaming, |
| 1041 | * the V4L2 interfaces won't be enabled, as such device is not able to |
| 1042 | * also stream analog TV or radio. |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 1043 | * |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 1044 | * .. note:: |
| 1045 | * |
| 1046 | * Before calling this function, media_devnode_create() should be called for |
| 1047 | * the interface and media_device_register_entity() should be called for the |
| 1048 | * interface that will be part of the link. |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 1049 | */ |
Mauro Carvalho Chehab | 5e5387d | 2015-09-04 15:34:19 -0300 | [diff] [blame] | 1050 | __must_check media_create_intf_link(struct media_entity *entity, |
| 1051 | struct media_interface *intf, |
| 1052 | u32 flags); |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 1053 | /** |
| 1054 | * __media_remove_intf_link() - remove a single interface link |
| 1055 | * |
| 1056 | * @link: pointer to &media_link. |
| 1057 | * |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 1058 | * .. note:: This is an unlocked version of media_remove_intf_link() |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 1059 | */ |
Mauro Carvalho Chehab | d47109f | 2015-08-29 21:23:44 -0300 | [diff] [blame] | 1060 | void __media_remove_intf_link(struct media_link *link); |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 1061 | |
| 1062 | /** |
| 1063 | * media_remove_intf_link() - remove a single interface link |
| 1064 | * |
| 1065 | * @link: pointer to &media_link. |
| 1066 | * |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 1067 | * .. note:: Prefer to use this one, instead of __media_remove_intf_link() |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 1068 | */ |
Mauro Carvalho Chehab | 86e2662 | 2015-08-07 10:36:25 -0300 | [diff] [blame] | 1069 | void media_remove_intf_link(struct media_link *link); |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 1070 | |
| 1071 | /** |
| 1072 | * __media_remove_intf_links() - remove all links associated with an interface |
| 1073 | * |
| 1074 | * @intf: pointer to &media_interface |
| 1075 | * |
Mauro Carvalho Chehab | 74604b7 | 2016-07-17 09:18:03 -0300 | [diff] [blame] | 1076 | * .. note:: This is an unlocked version of media_remove_intf_links(). |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 1077 | */ |
Mauro Carvalho Chehab | 7c4696a | 2015-08-24 08:46:46 -0300 | [diff] [blame] | 1078 | void __media_remove_intf_links(struct media_interface *intf); |
Mauro Carvalho Chehab | 9277799 | 2015-12-16 13:53:04 -0200 | [diff] [blame] | 1079 | |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 1080 | /** |
| 1081 | * media_remove_intf_links() - remove all links associated with an interface |
| 1082 | * |
| 1083 | * @intf: pointer to &media_interface |
| 1084 | * |
Mauro Carvalho Chehab | f58cad2 | 2016-07-20 11:15:31 -0300 | [diff] [blame] | 1085 | * .. note:: |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 1086 | * |
Mauro Carvalho Chehab | f58cad2 | 2016-07-20 11:15:31 -0300 | [diff] [blame] | 1087 | * #) This is called automatically when an entity is unregistered via |
| 1088 | * media_device_register_entity() and by media_devnode_remove(). |
Mauro Carvalho Chehab | 6026618 | 2015-12-13 08:20:46 -0200 | [diff] [blame] | 1089 | * |
Mauro Carvalho Chehab | f58cad2 | 2016-07-20 11:15:31 -0300 | [diff] [blame] | 1090 | * #) Prefer to use this one, instead of __media_remove_intf_links(). |
Mauro Carvalho Chehab | db7ee32 | 2015-12-11 11:06:08 -0200 | [diff] [blame] | 1091 | */ |
Mauro Carvalho Chehab | 7c4696a | 2015-08-24 08:46:46 -0300 | [diff] [blame] | 1092 | void media_remove_intf_links(struct media_interface *intf); |
| 1093 | |
Mauro Carvalho Chehab | 48a7c4b | 2016-08-29 16:09:11 -0300 | [diff] [blame] | 1094 | /** |
| 1095 | * media_entity_call - Calls a struct media_entity_operations operation on |
| 1096 | * an entity |
| 1097 | * |
| 1098 | * @entity: entity where the @operation will be called |
| 1099 | * @operation: type of the operation. Should be the name of a member of |
| 1100 | * struct &media_entity_operations. |
| 1101 | * |
| 1102 | * This helper function will check if @operation is not %NULL. On such case, |
| 1103 | * it will issue a call to @operation\(@entity, @args\). |
| 1104 | */ |
| 1105 | |
Laurent Pinchart | 97548ed | 2009-12-09 08:40:03 -0300 | [diff] [blame] | 1106 | #define media_entity_call(entity, operation, args...) \ |
| 1107 | (((entity)->ops && (entity)->ops->operation) ? \ |
| 1108 | (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) |
| 1109 | |
Laurent Pinchart | 53e269c | 2009-12-09 08:40:00 -0300 | [diff] [blame] | 1110 | #endif |