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