]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/media/media-entity.h
[media] v4l2-device: fix a missing error code
[mirror_ubuntu-bionic-kernel.git] / include / media / media-entity.h
CommitLineData
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 */
42enum 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 */
68struct media_gobj {
39a956c4 69 struct media_device *mdev;
ec6e4c95 70 u32 id;
05bfa9fa 71 struct list_head list;
ec6e4c95
MCC
72};
73
e02188c9
LP
74struct 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 100struct 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 126struct 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
142struct 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 177struct 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 */
219struct 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 */
233struct 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
60266185
MCC
241/**
242 * media_entity_id() - return the media entity graph object id
243 *
244 * @entity: pointer to entity
245 */
fa762394
MCC
246static inline u32 media_entity_id(struct media_entity *entity)
247{
bfab2aac 248 return entity->graph_obj.id;
fa762394
MCC
249}
250
60266185
MCC
251/**
252 * media_type() - return the media object type
253 *
254 * @gobj: pointer to the media graph object
255 */
ec6e4c95
MCC
256static inline enum media_gobj_type media_type(struct media_gobj *gobj)
257{
258 return gobj->id >> MEDIA_BITS_PER_LOCAL_ID;
259}
260
261static inline u32 media_localid(struct media_gobj *gobj)
262{
263 return gobj->id & MEDIA_LOCAL_ID_MASK;
264}
265
266static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id)
267{
268 u32 id;
269
270 id = type << MEDIA_BITS_PER_LOCAL_ID;
271 id |= local_id & MEDIA_LOCAL_ID_MASK;
272
273 return id;
274}
275
60266185
MCC
276/**
277 * is_media_entity_v4l2_io() - identify if the entity main function
278 * is a V4L2 I/O
279 *
280 * @entity: pointer to entity
281 *
282 * Return: true if the entity main function is one of the V4L2 I/O types
283 * (video, VBI or SDR radio); false otherwise.
284 */
fa17b46a
MCC
285static inline bool is_media_entity_v4l2_io(struct media_entity *entity)
286{
287 if (!entity)
288 return false;
289
0e576b76 290 switch (entity->function) {
4ca72efa
MCC
291 case MEDIA_ENT_F_IO_V4L:
292 case MEDIA_ENT_F_IO_VBI:
293 case MEDIA_ENT_F_IO_SWRADIO:
fa17b46a
MCC
294 return true;
295 default:
296 return false;
297 }
298}
299
60266185
MCC
300/**
301 * is_media_entity_v4l2_subdev - return true if the entity main function is
302 * associated with the V4L2 API subdev usage
303 *
304 * @entity: pointer to entity
305 *
306 * This is an ancillary function used by subdev-based V4L2 drivers.
307 * It checks if the entity function is one of functions used by a V4L2 subdev,
308 * e. g. camera-relatef functions, analog TV decoder, TV tuner, V4L2 DSPs.
309 */
fa17b46a
MCC
310static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity)
311{
312 if (!entity)
313 return false;
314
0e576b76 315 switch (entity->function) {
4ca72efa
MCC
316 case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
317 case MEDIA_ENT_F_CAM_SENSOR:
318 case MEDIA_ENT_F_FLASH:
319 case MEDIA_ENT_F_LENS:
320 case MEDIA_ENT_F_ATV_DECODER:
321 case MEDIA_ENT_F_TUNER:
fa17b46a
MCC
322 return true;
323
324 default:
325 return false;
326 }
327}
328
a5ccc48a 329#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16
5c7b25b9 330#define MEDIA_ENTITY_ENUM_MAX_ID 64
a5ccc48a 331
ef69ee1b
MCC
332/*
333 * The number of pads can't be bigger than the number of entities,
334 * as the worse-case scenario is to have one entity linked up to
335 * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities.
336 */
337#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1)
338
a5ccc48a
SA
339struct media_entity_graph {
340 struct {
341 struct media_entity *entity;
57208e5e 342 struct list_head *link;
a5ccc48a 343 } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH];
5c7b25b9
LP
344
345 DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID);
a5ccc48a
SA
346 int top;
347};
348
ec6e4c95
MCC
349#define gobj_to_entity(gobj) \
350 container_of(gobj, struct media_entity, graph_obj)
351
39a956c4
MCC
352#define gobj_to_pad(gobj) \
353 container_of(gobj, struct media_pad, graph_obj)
354
355#define gobj_to_link(gobj) \
356 container_of(gobj, struct media_link, graph_obj)
357
27e543fa
MCC
358#define gobj_to_link(gobj) \
359 container_of(gobj, struct media_link, graph_obj)
360
361#define gobj_to_pad(gobj) \
362 container_of(gobj, struct media_pad, graph_obj)
363
364#define gobj_to_intf(gobj) \
365 container_of(gobj, struct media_interface, graph_obj)
366
367#define intf_to_devnode(intf) \
368 container_of(intf, struct media_intf_devnode, intf)
369
1fc25d30
MCC
370/**
371 * media_gobj_create - Initialize a graph object
372 *
373 * @mdev: Pointer to the media_device that contains the object
374 * @type: Type of the object
375 * @gobj: Pointer to the graph object
376 *
377 * This routine initializes the embedded struct media_gobj inside a
378 * media graph object. It is called automatically if media_*_create()
379 * calls are used. However, if the object (entity, link, pad, interface)
380 * is embedded on some other object, this function should be called before
381 * registering the object at the media controller.
382 */
c350ef83 383void media_gobj_create(struct media_device *mdev,
ec6e4c95
MCC
384 enum media_gobj_type type,
385 struct media_gobj *gobj);
1fc25d30
MCC
386
387/**
388 * media_gobj_destroy - Stop using a graph object on a media device
389 *
390 * @gobj: Pointer to the graph object
391 *
392 * This should be called by all routines like media_device_unregister()
393 * that remove/destroy media graph objects.
394 */
c350ef83 395void media_gobj_destroy(struct media_gobj *gobj);
ec6e4c95 396
db7ee32a
MCC
397/**
398 * media_entity_pads_init() - Initialize the entity pads
399 *
400 * @entity: entity where the pads belong
1fc25d30
MCC
401 * @num_pads: total number of sink and source pads
402 * @pads: Array of @num_pads pads.
403 *
404 * The pads array is managed by the entity driver and passed to
405 * media_entity_pads_init() where its pointer will be stored in the entity
406 * structure.
db7ee32a
MCC
407 *
408 * If no pads are needed, drivers could either directly fill
409 * &media_entity->@num_pads with 0 and &media_entity->@pads with NULL or call
410 * this function that will do the same.
411 *
412 * As the number of pads is known in advance, the pads array is not allocated
413 * dynamically but is managed by the entity driver. Most drivers will embed the
414 * pads array in a driver-specific structure, avoiding dynamic allocation.
415 *
416 * Drivers must set the direction of every pad in the pads array before calling
417 * media_entity_pads_init(). The function will initialize the other pads fields.
418 */
ab22e77c 419int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
57208e5e 420 struct media_pad *pads);
f1fd3289 421
db7ee32a
MCC
422/**
423 * media_entity_cleanup() - free resources associated with an entity
424 *
425 * @entity: entity where the pads belong
426 *
427 * This function must be called during the cleanup phase after unregistering
428 * the entity (currently, it does nothing).
429 */
f1fd3289 430static inline void media_entity_cleanup(struct media_entity *entity) {};
e02188c9 431
db7ee32a
MCC
432/**
433 * media_create_pad_link() - creates a link between two entities.
434 *
435 * @source: pointer to &media_entity of the source pad.
436 * @source_pad: number of the source pad in the pads array
437 * @sink: pointer to &media_entity of the sink pad.
438 * @sink_pad: number of the sink pad in the pads array.
439 * @flags: Link flags, as defined in include/uapi/linux/media.h.
440 *
441 * Valid values for flags:
442 * A %MEDIA_LNK_FL_ENABLED flag indicates that the link is enabled and can be
443 * used to transfer media data. When two or more links target a sink pad,
444 * only one of them can be enabled at a time.
445 *
446 * A %MEDIA_LNK_FL_IMMUTABLE flag indicates that the link enabled state can't
447 * be modified at runtime. If %MEDIA_LNK_FL_IMMUTABLE is set, then
448 * %MEDIA_LNK_FL_ENABLED must also be set since an immutable link is
449 * always enabled.
450 *
451 * NOTE:
452 *
453 * Before calling this function, media_entity_pads_init() and
454 * media_device_register_entity() should be called previously for both ends.
455 */
77328043
MCC
456__must_check int media_create_pad_link(struct media_entity *source,
457 u16 source_pad, struct media_entity *sink,
458 u16 sink_pad, u32 flags);
7349cec1 459void __media_entity_remove_links(struct media_entity *entity);
db7ee32a
MCC
460
461/**
462 * media_entity_remove_links() - remove all links associated with an entity
463 *
464 * @entity: pointer to &media_entity
465 *
466 * Note: this is called automatically when an entity is unregistered via
467 * media_device_register_entity().
468 */
7349cec1
SN
469void media_entity_remove_links(struct media_entity *entity);
470
1fc25d30
MCC
471/**
472 * __media_entity_setup_link - Configure a media link without locking
473 * @link: The link being configured
474 * @flags: Link configuration flags
475 *
476 * The bulk of link setup is handled by the two entities connected through the
477 * link. This function notifies both entities of the link configuration change.
478 *
479 * If the link is immutable or if the current and new configuration are
480 * identical, return immediately.
481 *
482 * The user is expected to hold link->source->parent->mutex. If not,
483 * media_entity_setup_link() should be used instead.
484 */
97548ed4 485int __media_entity_setup_link(struct media_link *link, u32 flags);
db7ee32a
MCC
486
487/**
488 * media_entity_setup_link() - changes the link flags properties in runtime
489 *
490 * @link: pointer to &media_link
491 * @flags: the requested new link flags
492 *
493 * The only configurable property is the %MEDIA_LNK_FL_ENABLED link flag
494 * flag to enable/disable a link. Links marked with the
495 * %MEDIA_LNK_FL_IMMUTABLE link flag can not be enabled or disabled.
496 *
497 * When a link is enabled or disabled, the media framework calls the
498 * link_setup operation for the two entities at the source and sink of the
499 * link, in that order. If the second link_setup call fails, another
500 * link_setup call is made on the first entity to restore the original link
501 * flags.
502 *
503 * Media device drivers can be notified of link setup operations by setting the
504 * media_device::link_notify pointer to a callback function. If provided, the
505 * notification callback will be called before enabling and after disabling
506 * links.
507 *
508 * Entity drivers must implement the link_setup operation if any of their links
509 * is non-immutable. The operation must either configure the hardware or store
510 * the configuration information to be applied later.
511 *
512 * Link configuration must not have any side effect on other links. If an
513 * enabled link at a sink pad prevents another link at the same pad from
514 * being enabled, the link_setup operation must return -EBUSY and can't
515 * implicitly disable the first enabled link.
516 *
517 * NOTE: the valid values of the flags for the link is the same as described
518 * on media_create_pad_link(), for pad to pad links or the same as described
519 * on media_create_intf_link(), for interface to entity links.
520 */
97548ed4 521int media_entity_setup_link(struct media_link *link, u32 flags);
1fc25d30
MCC
522
523/**
524 * media_entity_find_link - Find a link between two pads
525 * @source: Source pad
526 * @sink: Sink pad
527 *
528 * Return a pointer to the link between the two entities. If no such link
529 * exists, return NULL.
530 */
97548ed4
LP
531struct media_link *media_entity_find_link(struct media_pad *source,
532 struct media_pad *sink);
1fc25d30
MCC
533
534/**
535 * media_entity_remote_pad - Find the pad at the remote end of a link
536 * @pad: Pad at the local end of the link
537 *
538 * Search for a remote pad connected to the given pad by iterating over all
539 * links originating or terminating at that pad until an enabled link is found.
540 *
541 * Return a pointer to the pad at the remote end of the first found enabled
542 * link, or NULL if no enabled link has been found.
543 */
1bddf1b3 544struct media_pad *media_entity_remote_pad(struct media_pad *pad);
53e269c1 545
1fc25d30
MCC
546/**
547 * media_entity_get - Get a reference to the parent module
548 *
549 * @entity: The entity
550 *
551 * Get a reference to the parent media device module.
552 *
553 * The function will return immediately if @entity is NULL.
554 *
555 * Return a pointer to the entity on success or NULL on failure.
556 */
503c3d82 557struct media_entity *media_entity_get(struct media_entity *entity);
1fc25d30
MCC
558
559/**
560 * media_entity_put - Release the reference to the parent module
561 *
562 * @entity: The entity
563 *
564 * Release the reference count acquired by media_entity_get().
565 *
566 * The function will return immediately if @entity is NULL.
567 */
503c3d82
LP
568void media_entity_put(struct media_entity *entity);
569
1fc25d30
MCC
570/**
571 * media_entity_graph_walk_start - Start walking the media graph at a given entity
572 * @graph: Media graph structure that will be used to walk the graph
573 * @entity: Starting entity
574 *
575 * This function initializes the graph traversal structure to walk the entities
576 * graph starting at the given entity. The traversal structure must not be
577 * modified by the caller during graph traversal. When done the structure can
578 * safely be freed.
579 */
a5ccc48a
SA
580void media_entity_graph_walk_start(struct media_entity_graph *graph,
581 struct media_entity *entity);
1fc25d30
MCC
582
583/**
584 * media_entity_graph_walk_next - Get the next entity in the graph
585 * @graph: Media graph structure
586 *
587 * Perform a depth-first traversal of the given media entities graph.
588 *
589 * The graph structure must have been previously initialized with a call to
590 * media_entity_graph_walk_start().
591 *
592 * Return the next entity in the graph or NULL if the whole graph have been
593 * traversed.
594 */
a5ccc48a
SA
595struct media_entity *
596media_entity_graph_walk_next(struct media_entity_graph *graph);
1fc25d30
MCC
597
598/**
599 * media_entity_pipeline_start - Mark a pipeline as streaming
600 * @entity: Starting entity
601 * @pipe: Media pipeline to be assigned to all entities in the pipeline.
602 *
603 * Mark all entities connected to a given entity through enabled links, either
604 * directly or indirectly, as streaming. The given pipeline object is assigned to
605 * every entity in the pipeline and stored in the media_entity pipe field.
606 *
607 * Calls to this function can be nested, in which case the same number of
608 * media_entity_pipeline_stop() calls will be required to stop streaming. The
609 * pipeline pointer must be identical for all nested calls to
610 * media_entity_pipeline_start().
611 */
af88be38
SA
612__must_check int media_entity_pipeline_start(struct media_entity *entity,
613 struct media_pipeline *pipe);
1fc25d30
MCC
614
615/**
616 * media_entity_pipeline_stop - Mark a pipeline as not streaming
617 * @entity: Starting entity
618 *
619 * Mark all entities connected to a given entity through enabled links, either
620 * directly or indirectly, as not streaming. The media_entity pipe field is
621 * reset to NULL.
622 *
623 * If multiple calls to media_entity_pipeline_start() have been made, the same
624 * number of calls to this function are required to mark the pipeline as not
625 * streaming.
626 */
e02188c9 627void media_entity_pipeline_stop(struct media_entity *entity);
a5ccc48a 628
db7ee32a
MCC
629/**
630 * media_devnode_create() - creates and initializes a device node interface
631 *
632 * @mdev: pointer to struct &media_device
633 * @type: type of the interface, as given by MEDIA_INTF_T_* macros
634 * as defined in the uapi/media/media.h header.
635 * @flags: Interface flags as defined in uapi/media/media.h.
636 * @major: Device node major number.
637 * @minor: Device node minor number.
638 *
639 * Return: if succeeded, returns a pointer to the newly allocated
640 * &media_intf_devnode pointer.
641 */
5e5387df
MCC
642struct media_intf_devnode *
643__must_check media_devnode_create(struct media_device *mdev,
644 u32 type, u32 flags,
0b3b72df 645 u32 major, u32 minor);
db7ee32a
MCC
646/**
647 * media_devnode_remove() - removes a device node interface
648 *
649 * @devnode: pointer to &media_intf_devnode to be freed.
650 *
651 * When a device node interface is removed, all links to it are automatically
652 * removed.
653 */
27e543fa 654void media_devnode_remove(struct media_intf_devnode *devnode);
5e5387df 655struct media_link *
db7ee32a
MCC
656
657/**
658 * media_create_intf_link() - creates a link between an entity and an interface
659 *
660 * @entity: pointer to %media_entity
661 * @intf: pointer to %media_interface
662 * @flags: Link flags, as defined in include/uapi/linux/media.h.
663 *
664 *
665 * Valid values for flags:
666 * The %MEDIA_LNK_FL_ENABLED flag indicates that the interface is connected to
667 * the entity hardware. That's the default value for interfaces. An
668 * interface may be disabled if the hardware is busy due to the usage
669 * of some other interface that it is currently controlling the hardware.
670 * A typical example is an hybrid TV device that handle only one type of
671 * stream on a given time. So, when the digital TV is streaming,
672 * the V4L2 interfaces won't be enabled, as such device is not able to
673 * also stream analog TV or radio.
674 *
675 * Note:
676 *
677 * Before calling this function, media_devnode_create() should be called for
678 * the interface and media_device_register_entity() should be called for the
679 * interface that will be part of the link.
680 */
5e5387df
MCC
681__must_check media_create_intf_link(struct media_entity *entity,
682 struct media_interface *intf,
683 u32 flags);
60266185
MCC
684/**
685 * __media_remove_intf_link() - remove a single interface link
686 *
687 * @link: pointer to &media_link.
688 *
689 * Note: this is an unlocked version of media_remove_intf_link()
690 */
d47109fa 691void __media_remove_intf_link(struct media_link *link);
60266185
MCC
692
693/**
694 * media_remove_intf_link() - remove a single interface link
695 *
696 * @link: pointer to &media_link.
697 *
698 * Note: prefer to use this one, instead of __media_remove_intf_link()
699 */
86e26620 700void media_remove_intf_link(struct media_link *link);
60266185
MCC
701
702/**
703 * __media_remove_intf_links() - remove all links associated with an interface
704 *
705 * @intf: pointer to &media_interface
706 *
707 * Note: this is an unlocked version of media_remove_intf_links().
708 */
7c4696a9 709void __media_remove_intf_links(struct media_interface *intf);
db7ee32a
MCC
710/**
711 * media_remove_intf_links() - remove all links associated with an interface
712 *
713 * @intf: pointer to &media_interface
714 *
60266185
MCC
715 * Notes:
716 *
717 * this is called automatically when an entity is unregistered via
db7ee32a 718 * media_device_register_entity() and by media_devnode_remove().
60266185
MCC
719 *
720 * Prefer to use this one, instead of __media_remove_intf_links().
db7ee32a 721 */
7c4696a9
MCC
722void media_remove_intf_links(struct media_interface *intf);
723
86e26620 724
97548ed4
LP
725#define media_entity_call(entity, operation, args...) \
726 (((entity)->ops && (entity)->ops->operation) ? \
727 (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD)
728
53e269c1 729#endif