2 * Media controller test application
4 * Copyright (C) 2010 Ideas on board SPRL <laurent.pinchart@ideasonboard.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
23 #include <linux/media.h>
26 struct media_pad *source;
27 struct media_pad *sink;
28 struct media_link *twin;
34 struct media_entity *entity;
41 struct media_entity_desc info;
42 struct media_pad *pads;
43 struct media_link *links;
44 unsigned int max_links;
45 unsigned int num_links;
54 struct media_entity *entities;
55 unsigned int entities_count;
60 * @brief Open a media device.
61 * @param name - name (including path) of the device node.
62 * @param verbose - whether to print verbose information on the standard output.
64 * Open the media device referenced by @a name and enumerate entities, pads and
67 * @return A pointer to a newly allocated media_device structure instance on
68 * success and NULL on failure. The returned pointer must be freed with
69 * media_close when the device isn't needed anymore.
71 struct media_device *media_open(const char *name, int verbose);
74 * @brief Close a media device.
75 * @param media - device instance.
77 * Close the @a media device instance and free allocated resources. Access to the
78 * device instance is forbidden after this function returns.
80 void media_close(struct media_device *media);
83 * @brief Locate the pad at the other end of a link.
84 * @param pad - sink pad at one end of the link.
86 * Locate the source pad connected to @a pad through an enabled link. As only one
87 * link connected to a sink pad can be enabled at a time, the connected source
88 * pad is guaranteed to be unique.
90 * @return A pointer to the connected source pad, or NULL if all links connected
91 * to @a pad are disabled. Return NULL also if @a pad is not a sink pad.
93 struct media_pad *media_entity_remote_source(struct media_pad *pad);
96 * @brief Get the type of an entity.
97 * @param entity - the entity.
99 * @return The type of @a entity.
101 static inline unsigned int media_entity_type(struct media_entity *entity)
103 return entity->info.type & MEDIA_ENTITY_TYPE_MASK;
107 * @brief Find an entity by its name.
108 * @param media - media device.
109 * @param name - entity name.
110 * @param length - size of @a name.
112 * Search for an entity with a name equal to @a name.
114 * @return A pointer to the entity if found, or NULL otherwise.
116 struct media_entity *media_get_entity_by_name(struct media_device *media,
117 const char *name, size_t length);
120 * @brief Find an entity by its ID.
121 * @param media - media device.
122 * @param id - entity ID.
124 * Search for an entity with an ID equal to @a id.
126 * @return A pointer to the entity if found, or NULL otherwise.
128 struct media_entity *media_get_entity_by_id(struct media_device *media,
132 * @brief Configure a link.
133 * @param media - media device.
134 * @param source - source pad at the link origin.
135 * @param sink - sink pad at the link target.
136 * @param flags - configuration flags.
138 * Locate the link between @a source and @a sink, and configure it by applying
141 * Only the MEDIA_LINK_FLAG_ENABLED flag is writable.
143 * @return 0 on success, or a negative error code on failure.
145 int media_setup_link(struct media_device *media,
146 struct media_pad *source, struct media_pad *sink,
150 * @brief Reset all links to the disabled state.
151 * @param media - media device.
153 * Disable all links in the media device. This function is usually used after
154 * opening a media device to reset all links to a known state.
156 * @return 0 on success, or a negative error code on failure.
158 int media_reset_links(struct media_device *media);