]>
Commit | Line | Data |
---|---|---|
53e269c1 LP |
1 | /* |
2 | * Media entity | |
3 | * | |
4 | * Copyright (C) 2010 Nokia Corporation | |
5 | * | |
6 | * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | |
7 | * Sakari Ailus <sakari.ailus@iki.fi> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
22 | ||
23 | #ifndef _MEDIA_ENTITY_H | |
24 | #define _MEDIA_ENTITY_H | |
25 | ||
5c7b25b9 | 26 | #include <linux/bitops.h> |
0149a2e1 | 27 | #include <linux/kernel.h> |
53e269c1 | 28 | #include <linux/list.h> |
1651333b | 29 | #include <linux/media.h> |
53e269c1 | 30 | |
ec6e4c95 MCC |
31 | /* Enums used internally at the media controller to represent graphs */ |
32 | ||
33 | /** | |
34 | * enum media_gobj_type - type of a graph object | |
35 | * | |
bfab2aac | 36 | * @MEDIA_GRAPH_ENTITY: Identify a media entity |
18710dc6 | 37 | * @MEDIA_GRAPH_PAD: Identify a media pad |
6b6a4278 | 38 | * @MEDIA_GRAPH_LINK: Identify a media link |
27e543fa MCC |
39 | * @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via |
40 | * a device node | |
ec6e4c95 MCC |
41 | */ |
42 | enum media_gobj_type { | |
bfab2aac | 43 | MEDIA_GRAPH_ENTITY, |
18710dc6 | 44 | MEDIA_GRAPH_PAD, |
6b6a4278 | 45 | MEDIA_GRAPH_LINK, |
27e543fa | 46 | MEDIA_GRAPH_INTF_DEVNODE, |
ec6e4c95 MCC |
47 | }; |
48 | ||
49 | #define MEDIA_BITS_PER_TYPE 8 | |
50 | #define MEDIA_BITS_PER_LOCAL_ID (32 - MEDIA_BITS_PER_TYPE) | |
51 | #define MEDIA_LOCAL_ID_MASK GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 0) | |
52 | ||
53 | /* Structs to represent the objects that belong to a media graph */ | |
54 | ||
55 | /** | |
56 | * struct media_gobj - Define a graph object. | |
57 | * | |
c358e80d | 58 | * @mdev: Pointer to the struct media_device that owns the object |
ec6e4c95 MCC |
59 | * @id: Non-zero object ID identifier. The ID should be unique |
60 | * inside a media_device, as it is composed by | |
61 | * MEDIA_BITS_PER_TYPE to store the type plus | |
62 | * MEDIA_BITS_PER_LOCAL_ID to store a per-type ID | |
63 | * (called as "local ID"). | |
c358e80d | 64 | * @list: List entry stored in one of the per-type mdev object lists |
ec6e4c95 MCC |
65 | * |
66 | * All objects on the media graph should have this struct embedded | |
67 | */ | |
68 | struct media_gobj { | |
39a956c4 | 69 | struct media_device *mdev; |
ec6e4c95 | 70 | u32 id; |
05bfa9fa | 71 | struct list_head list; |
ec6e4c95 MCC |
72 | }; |
73 | ||
e02188c9 LP |
74 | struct media_pipeline { |
75 | }; | |
76 | ||
c358e80d MCC |
77 | /** |
78 | * struct media_link - A link object part of a media graph. | |
79 | * | |
80 | * @graph_obj: Embedded structure containing the media object common data | |
81 | * @list: Linked list associated with an entity or an interface that | |
82 | * owns the link. | |
83 | * @gobj0: Part of a union. Used to get the pointer for the first | |
84 | * graph_object of the link. | |
85 | * @source: Part of a union. Used only if the first object (gobj0) is | |
86 | * a pad. In that case, it represents the source pad. | |
87 | * @intf: Part of a union. Used only if the first object (gobj0) is | |
88 | * an interface. | |
89 | * @gobj1: Part of a union. Used to get the pointer for the second | |
90 | * graph_object of the link. | |
91 | * @source: Part of a union. Used only if the second object (gobj1) is | |
92 | * a pad. In that case, it represents the sink pad. | |
93 | * @entity: Part of a union. Used only if the second object (gobj1) is | |
94 | * an entity. | |
95 | * @reverse: Pointer to the link for the reverse direction of a pad to pad | |
96 | * link. | |
97 | * @flags: Link flags, as defined in uapi/media.h (MEDIA_LNK_FL_*) | |
39d1ebc6 | 98 | * @is_backlink: Indicate if the link is a backlink. |
c358e80d | 99 | */ |
53e269c1 | 100 | struct media_link { |
6b6a4278 | 101 | struct media_gobj graph_obj; |
57208e5e | 102 | struct list_head list; |
4b8a3c08 MCC |
103 | union { |
104 | struct media_gobj *gobj0; | |
105 | struct media_pad *source; | |
86e26620 | 106 | struct media_interface *intf; |
4b8a3c08 MCC |
107 | }; |
108 | union { | |
109 | struct media_gobj *gobj1; | |
110 | struct media_pad *sink; | |
86e26620 | 111 | struct media_entity *entity; |
4b8a3c08 | 112 | }; |
c358e80d MCC |
113 | struct media_link *reverse; |
114 | unsigned long flags; | |
39d1ebc6 | 115 | bool is_backlink; |
53e269c1 LP |
116 | }; |
117 | ||
c358e80d MCC |
118 | /** |
119 | * struct media_pad - A media pad graph object. | |
120 | * | |
121 | * @graph_obj: Embedded structure containing the media object common data | |
122 | * @entity: Entity this pad belongs to | |
123 | * @index: Pad index in the entity pads array, numbered from 0 to n | |
124 | * @flags: Pad flags, as defined in uapi/media.h (MEDIA_PAD_FL_*) | |
125 | */ | |
53e269c1 | 126 | struct media_pad { |
4b8a3c08 | 127 | struct media_gobj graph_obj; /* must be first field in struct */ |
c358e80d MCC |
128 | struct media_entity *entity; |
129 | u16 index; | |
130 | unsigned long flags; | |
53e269c1 LP |
131 | }; |
132 | ||
5a5394be LP |
133 | /** |
134 | * struct media_entity_operations - Media entity operations | |
135 | * @link_setup: Notify the entity of link changes. The operation can | |
136 | * return an error, in which case link setup will be | |
137 | * cancelled. Optional. | |
138 | * @link_validate: Return whether a link is valid from the entity point of | |
139 | * view. The media_entity_pipeline_start() function | |
140 | * validates all links by calling this operation. Optional. | |
141 | */ | |
97548ed4 LP |
142 | struct media_entity_operations { |
143 | int (*link_setup)(struct media_entity *entity, | |
144 | const struct media_pad *local, | |
145 | const struct media_pad *remote, u32 flags); | |
af88be38 | 146 | int (*link_validate)(struct media_link *link); |
97548ed4 LP |
147 | }; |
148 | ||
c358e80d MCC |
149 | /** |
150 | * struct media_entity - A media entity graph object. | |
151 | * | |
152 | * @graph_obj: Embedded structure containing the media object common data. | |
153 | * @name: Entity name. | |
0e576b76 MCC |
154 | * @function: Entity main function, as defined in uapi/media.h |
155 | * (MEDIA_ENT_F_*) | |
c358e80d | 156 | * @flags: Entity flags, as defined in uapi/media.h (MEDIA_ENT_FL_*) |
c358e80d MCC |
157 | * @num_pads: Number of sink and source pads. |
158 | * @num_links: Total number of links, forward and back, enabled and disabled. | |
159 | * @num_backlinks: Number of backlinks | |
160 | * @pads: Pads array with the size defined by @num_pads. | |
161 | * @links: List of data links. | |
162 | * @ops: Entity operations. | |
163 | * @stream_count: Stream count for the entity. | |
164 | * @use_count: Use count for the entity. | |
165 | * @pipe: Pipeline this entity belongs to. | |
166 | * @info: Union with devnode information. Kept just for backward | |
167 | * compatibility. | |
168 | * @major: Devnode major number (zero if not applicable). Kept just | |
169 | * for backward compatibility. | |
170 | * @minor: Devnode minor number (zero if not applicable). Kept just | |
171 | * for backward compatibility. | |
172 | * | |
173 | * NOTE: @stream_count and @use_count reference counts must never be | |
174 | * negative, but are signed integers on purpose: a simple WARN_ON(<0) check | |
175 | * can be used to detect reference count bugs that would make them negative. | |
176 | */ | |
53e269c1 | 177 | struct media_entity { |
4b8a3c08 | 178 | struct media_gobj graph_obj; /* must be first field in struct */ |
c358e80d | 179 | const char *name; |
0e576b76 | 180 | u32 function; |
c358e80d | 181 | unsigned long flags; |
53e269c1 | 182 | |
c358e80d MCC |
183 | u16 num_pads; |
184 | u16 num_links; | |
185 | u16 num_backlinks; | |
53e269c1 | 186 | |
c358e80d MCC |
187 | struct media_pad *pads; |
188 | struct list_head links; | |
53e269c1 | 189 | |
c358e80d | 190 | const struct media_entity_operations *ops; |
97548ed4 | 191 | |
503c3d82 LP |
192 | /* Reference counts must never be negative, but are signed integers on |
193 | * purpose: a simple WARN_ON(<0) check can be used to detect reference | |
194 | * count bugs that would make them negative. | |
195 | */ | |
c358e80d MCC |
196 | int stream_count; |
197 | int use_count; | |
503c3d82 | 198 | |
c358e80d | 199 | struct media_pipeline *pipe; |
e02188c9 | 200 | |
53e269c1 | 201 | union { |
53e269c1 LP |
202 | struct { |
203 | u32 major; | |
204 | u32 minor; | |
e31a0ba7 | 205 | } dev; |
fa5034c6 | 206 | } info; |
53e269c1 LP |
207 | }; |
208 | ||
27e543fa | 209 | /** |
c358e80d | 210 | * struct media_interface - A media interface graph object. |
27e543fa MCC |
211 | * |
212 | * @graph_obj: embedded graph object | |
86e26620 | 213 | * @links: List of links pointing to graph entities |
c358e80d | 214 | * @type: Type of the interface as defined in the |
27e543fa MCC |
215 | * uapi/media/media.h header, e. g. |
216 | * MEDIA_INTF_T_* | |
c358e80d | 217 | * @flags: Interface flags as defined in uapi/media/media.h |
27e543fa MCC |
218 | */ |
219 | struct media_interface { | |
220 | struct media_gobj graph_obj; | |
86e26620 | 221 | struct list_head links; |
27e543fa MCC |
222 | u32 type; |
223 | u32 flags; | |
224 | }; | |
225 | ||
226 | /** | |
c358e80d | 227 | * struct media_intf_devnode - A media interface via a device node. |
27e543fa MCC |
228 | * |
229 | * @intf: embedded interface object | |
230 | * @major: Major number of a device node | |
231 | * @minor: Minor number of a device node | |
232 | */ | |
233 | struct media_intf_devnode { | |
234 | struct media_interface intf; | |
c398bb64 MCC |
235 | |
236 | /* Should match the fields at media_v2_intf_devnode */ | |
27e543fa MCC |
237 | u32 major; |
238 | u32 minor; | |
239 | }; | |
240 | ||
fa762394 MCC |
241 | static inline u32 media_entity_id(struct media_entity *entity) |
242 | { | |
bfab2aac | 243 | return entity->graph_obj.id; |
fa762394 MCC |
244 | } |
245 | ||
ec6e4c95 MCC |
246 | static inline enum media_gobj_type media_type(struct media_gobj *gobj) |
247 | { | |
248 | return gobj->id >> MEDIA_BITS_PER_LOCAL_ID; | |
249 | } | |
250 | ||
251 | static inline u32 media_localid(struct media_gobj *gobj) | |
252 | { | |
253 | return gobj->id & MEDIA_LOCAL_ID_MASK; | |
254 | } | |
255 | ||
256 | static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id) | |
257 | { | |
258 | u32 id; | |
259 | ||
260 | id = type << MEDIA_BITS_PER_LOCAL_ID; | |
261 | id |= local_id & MEDIA_LOCAL_ID_MASK; | |
262 | ||
263 | return id; | |
264 | } | |
265 | ||
fa17b46a MCC |
266 | static inline bool is_media_entity_v4l2_io(struct media_entity *entity) |
267 | { | |
268 | if (!entity) | |
269 | return false; | |
270 | ||
0e576b76 | 271 | switch (entity->function) { |
4ca72efa MCC |
272 | case MEDIA_ENT_F_IO_V4L: |
273 | case MEDIA_ENT_F_IO_VBI: | |
274 | case MEDIA_ENT_F_IO_SWRADIO: | |
fa17b46a MCC |
275 | return true; |
276 | default: | |
277 | return false; | |
278 | } | |
279 | } | |
280 | ||
281 | static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity) | |
282 | { | |
283 | if (!entity) | |
284 | return false; | |
285 | ||
0e576b76 | 286 | switch (entity->function) { |
4ca72efa MCC |
287 | case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN: |
288 | case MEDIA_ENT_F_CAM_SENSOR: | |
289 | case MEDIA_ENT_F_FLASH: | |
290 | case MEDIA_ENT_F_LENS: | |
291 | case MEDIA_ENT_F_ATV_DECODER: | |
292 | case MEDIA_ENT_F_TUNER: | |
fa17b46a MCC |
293 | return true; |
294 | ||
295 | default: | |
296 | return false; | |
297 | } | |
298 | } | |
299 | ||
a5ccc48a | 300 | #define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 |
5c7b25b9 | 301 | #define MEDIA_ENTITY_ENUM_MAX_ID 64 |
a5ccc48a | 302 | |
ef69ee1b MCC |
303 | /* |
304 | * The number of pads can't be bigger than the number of entities, | |
305 | * as the worse-case scenario is to have one entity linked up to | |
306 | * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities. | |
307 | */ | |
308 | #define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1) | |
309 | ||
a5ccc48a SA |
310 | struct media_entity_graph { |
311 | struct { | |
312 | struct media_entity *entity; | |
57208e5e | 313 | struct list_head *link; |
a5ccc48a | 314 | } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH]; |
5c7b25b9 LP |
315 | |
316 | DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID); | |
a5ccc48a SA |
317 | int top; |
318 | }; | |
319 | ||
ec6e4c95 MCC |
320 | #define gobj_to_entity(gobj) \ |
321 | container_of(gobj, struct media_entity, graph_obj) | |
322 | ||
39a956c4 MCC |
323 | #define gobj_to_pad(gobj) \ |
324 | container_of(gobj, struct media_pad, graph_obj) | |
325 | ||
326 | #define gobj_to_link(gobj) \ | |
327 | container_of(gobj, struct media_link, graph_obj) | |
328 | ||
27e543fa MCC |
329 | #define gobj_to_link(gobj) \ |
330 | container_of(gobj, struct media_link, graph_obj) | |
331 | ||
332 | #define gobj_to_pad(gobj) \ | |
333 | container_of(gobj, struct media_pad, graph_obj) | |
334 | ||
335 | #define gobj_to_intf(gobj) \ | |
336 | container_of(gobj, struct media_interface, graph_obj) | |
337 | ||
338 | #define intf_to_devnode(intf) \ | |
339 | container_of(intf, struct media_intf_devnode, intf) | |
340 | ||
ec6e4c95 MCC |
341 | void media_gobj_init(struct media_device *mdev, |
342 | enum media_gobj_type type, | |
343 | struct media_gobj *gobj); | |
344 | void media_gobj_remove(struct media_gobj *gobj); | |
345 | ||
db7ee32a MCC |
346 | /** |
347 | * media_entity_pads_init() - Initialize the entity pads | |
348 | * | |
349 | * @entity: entity where the pads belong | |
350 | * @num_pads: number of pads to be initialized | |
351 | * @pads: pads array | |
352 | * | |
353 | * If no pads are needed, drivers could either directly fill | |
354 | * &media_entity->@num_pads with 0 and &media_entity->@pads with NULL or call | |
355 | * this function that will do the same. | |
356 | * | |
357 | * As the number of pads is known in advance, the pads array is not allocated | |
358 | * dynamically but is managed by the entity driver. Most drivers will embed the | |
359 | * pads array in a driver-specific structure, avoiding dynamic allocation. | |
360 | * | |
361 | * Drivers must set the direction of every pad in the pads array before calling | |
362 | * media_entity_pads_init(). The function will initialize the other pads fields. | |
363 | */ | |
ab22e77c | 364 | int media_entity_pads_init(struct media_entity *entity, u16 num_pads, |
57208e5e | 365 | struct media_pad *pads); |
f1fd3289 | 366 | |
db7ee32a MCC |
367 | /** |
368 | * media_entity_cleanup() - free resources associated with an entity | |
369 | * | |
370 | * @entity: entity where the pads belong | |
371 | * | |
372 | * This function must be called during the cleanup phase after unregistering | |
373 | * the entity (currently, it does nothing). | |
374 | */ | |
f1fd3289 | 375 | static inline void media_entity_cleanup(struct media_entity *entity) {}; |
e02188c9 | 376 | |
db7ee32a MCC |
377 | /** |
378 | * media_create_pad_link() - creates a link between two entities. | |
379 | * | |
380 | * @source: pointer to &media_entity of the source pad. | |
381 | * @source_pad: number of the source pad in the pads array | |
382 | * @sink: pointer to &media_entity of the sink pad. | |
383 | * @sink_pad: number of the sink pad in the pads array. | |
384 | * @flags: Link flags, as defined in include/uapi/linux/media.h. | |
385 | * | |
386 | * Valid values for flags: | |
387 | * A %MEDIA_LNK_FL_ENABLED flag indicates that the link is enabled and can be | |
388 | * used to transfer media data. When two or more links target a sink pad, | |
389 | * only one of them can be enabled at a time. | |
390 | * | |
391 | * A %MEDIA_LNK_FL_IMMUTABLE flag indicates that the link enabled state can't | |
392 | * be modified at runtime. If %MEDIA_LNK_FL_IMMUTABLE is set, then | |
393 | * %MEDIA_LNK_FL_ENABLED must also be set since an immutable link is | |
394 | * always enabled. | |
395 | * | |
396 | * NOTE: | |
397 | * | |
398 | * Before calling this function, media_entity_pads_init() and | |
399 | * media_device_register_entity() should be called previously for both ends. | |
400 | */ | |
77328043 MCC |
401 | __must_check int media_create_pad_link(struct media_entity *source, |
402 | u16 source_pad, struct media_entity *sink, | |
403 | u16 sink_pad, u32 flags); | |
7349cec1 | 404 | void __media_entity_remove_links(struct media_entity *entity); |
db7ee32a MCC |
405 | |
406 | /** | |
407 | * media_entity_remove_links() - remove all links associated with an entity | |
408 | * | |
409 | * @entity: pointer to &media_entity | |
410 | * | |
411 | * Note: this is called automatically when an entity is unregistered via | |
412 | * media_device_register_entity(). | |
413 | */ | |
7349cec1 SN |
414 | void media_entity_remove_links(struct media_entity *entity); |
415 | ||
97548ed4 | 416 | int __media_entity_setup_link(struct media_link *link, u32 flags); |
db7ee32a MCC |
417 | |
418 | /** | |
419 | * media_entity_setup_link() - changes the link flags properties in runtime | |
420 | * | |
421 | * @link: pointer to &media_link | |
422 | * @flags: the requested new link flags | |
423 | * | |
424 | * The only configurable property is the %MEDIA_LNK_FL_ENABLED link flag | |
425 | * flag to enable/disable a link. Links marked with the | |
426 | * %MEDIA_LNK_FL_IMMUTABLE link flag can not be enabled or disabled. | |
427 | * | |
428 | * When a link is enabled or disabled, the media framework calls the | |
429 | * link_setup operation for the two entities at the source and sink of the | |
430 | * link, in that order. If the second link_setup call fails, another | |
431 | * link_setup call is made on the first entity to restore the original link | |
432 | * flags. | |
433 | * | |
434 | * Media device drivers can be notified of link setup operations by setting the | |
435 | * media_device::link_notify pointer to a callback function. If provided, the | |
436 | * notification callback will be called before enabling and after disabling | |
437 | * links. | |
438 | * | |
439 | * Entity drivers must implement the link_setup operation if any of their links | |
440 | * is non-immutable. The operation must either configure the hardware or store | |
441 | * the configuration information to be applied later. | |
442 | * | |
443 | * Link configuration must not have any side effect on other links. If an | |
444 | * enabled link at a sink pad prevents another link at the same pad from | |
445 | * being enabled, the link_setup operation must return -EBUSY and can't | |
446 | * implicitly disable the first enabled link. | |
447 | * | |
448 | * NOTE: the valid values of the flags for the link is the same as described | |
449 | * on media_create_pad_link(), for pad to pad links or the same as described | |
450 | * on media_create_intf_link(), for interface to entity links. | |
451 | */ | |
97548ed4 LP |
452 | int media_entity_setup_link(struct media_link *link, u32 flags); |
453 | struct media_link *media_entity_find_link(struct media_pad *source, | |
454 | struct media_pad *sink); | |
1bddf1b3 | 455 | struct media_pad *media_entity_remote_pad(struct media_pad *pad); |
53e269c1 | 456 | |
503c3d82 LP |
457 | struct media_entity *media_entity_get(struct media_entity *entity); |
458 | void media_entity_put(struct media_entity *entity); | |
459 | ||
a5ccc48a SA |
460 | void media_entity_graph_walk_start(struct media_entity_graph *graph, |
461 | struct media_entity *entity); | |
462 | struct media_entity * | |
463 | media_entity_graph_walk_next(struct media_entity_graph *graph); | |
af88be38 SA |
464 | __must_check int media_entity_pipeline_start(struct media_entity *entity, |
465 | struct media_pipeline *pipe); | |
e02188c9 | 466 | void media_entity_pipeline_stop(struct media_entity *entity); |
a5ccc48a | 467 | |
db7ee32a MCC |
468 | /** |
469 | * media_devnode_create() - creates and initializes a device node interface | |
470 | * | |
471 | * @mdev: pointer to struct &media_device | |
472 | * @type: type of the interface, as given by MEDIA_INTF_T_* macros | |
473 | * as defined in the uapi/media/media.h header. | |
474 | * @flags: Interface flags as defined in uapi/media/media.h. | |
475 | * @major: Device node major number. | |
476 | * @minor: Device node minor number. | |
477 | * | |
478 | * Return: if succeeded, returns a pointer to the newly allocated | |
479 | * &media_intf_devnode pointer. | |
480 | */ | |
5e5387df MCC |
481 | struct media_intf_devnode * |
482 | __must_check media_devnode_create(struct media_device *mdev, | |
483 | u32 type, u32 flags, | |
0b3b72df | 484 | u32 major, u32 minor); |
db7ee32a MCC |
485 | /** |
486 | * media_devnode_remove() - removes a device node interface | |
487 | * | |
488 | * @devnode: pointer to &media_intf_devnode to be freed. | |
489 | * | |
490 | * When a device node interface is removed, all links to it are automatically | |
491 | * removed. | |
492 | */ | |
27e543fa | 493 | void media_devnode_remove(struct media_intf_devnode *devnode); |
5e5387df | 494 | struct media_link * |
db7ee32a MCC |
495 | |
496 | /** | |
497 | * media_create_intf_link() - creates a link between an entity and an interface | |
498 | * | |
499 | * @entity: pointer to %media_entity | |
500 | * @intf: pointer to %media_interface | |
501 | * @flags: Link flags, as defined in include/uapi/linux/media.h. | |
502 | * | |
503 | * | |
504 | * Valid values for flags: | |
505 | * The %MEDIA_LNK_FL_ENABLED flag indicates that the interface is connected to | |
506 | * the entity hardware. That's the default value for interfaces. An | |
507 | * interface may be disabled if the hardware is busy due to the usage | |
508 | * of some other interface that it is currently controlling the hardware. | |
509 | * A typical example is an hybrid TV device that handle only one type of | |
510 | * stream on a given time. So, when the digital TV is streaming, | |
511 | * the V4L2 interfaces won't be enabled, as such device is not able to | |
512 | * also stream analog TV or radio. | |
513 | * | |
514 | * Note: | |
515 | * | |
516 | * Before calling this function, media_devnode_create() should be called for | |
517 | * the interface and media_device_register_entity() should be called for the | |
518 | * interface that will be part of the link. | |
519 | */ | |
5e5387df MCC |
520 | __must_check media_create_intf_link(struct media_entity *entity, |
521 | struct media_interface *intf, | |
522 | u32 flags); | |
d47109fa | 523 | void __media_remove_intf_link(struct media_link *link); |
86e26620 | 524 | void media_remove_intf_link(struct media_link *link); |
7c4696a9 | 525 | void __media_remove_intf_links(struct media_interface *intf); |
db7ee32a MCC |
526 | /** |
527 | * media_remove_intf_links() - remove all links associated with an interface | |
528 | * | |
529 | * @intf: pointer to &media_interface | |
530 | * | |
531 | * Note: this is called automatically when an entity is unregistered via | |
532 | * media_device_register_entity() and by media_devnode_remove(). | |
533 | */ | |
7c4696a9 MCC |
534 | void media_remove_intf_links(struct media_interface *intf); |
535 | ||
86e26620 | 536 | |
97548ed4 LP |
537 | #define media_entity_call(entity, operation, args...) \ |
538 | (((entity)->ops && (entity)->ops->operation) ? \ | |
539 | (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) | |
540 | ||
53e269c1 | 541 | #endif |