diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/media-framework.txt | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Documentation/media-framework.txt b/Documentation/media-framework.txt index 0257bad2a104..ab17f33ddedc 100644 --- a/Documentation/media-framework.txt +++ b/Documentation/media-framework.txt | |||
@@ -216,3 +216,45 @@ Links have flags that describe the link capabilities and state. | |||
216 | modified at runtime. If MEDIA_LNK_FL_IMMUTABLE is set, then | 216 | modified at runtime. If MEDIA_LNK_FL_IMMUTABLE is set, then |
217 | MEDIA_LNK_FL_ENABLED must also be set since an immutable link is always | 217 | MEDIA_LNK_FL_ENABLED must also be set since an immutable link is always |
218 | enabled. | 218 | enabled. |
219 | |||
220 | |||
221 | Graph traversal | ||
222 | --------------- | ||
223 | |||
224 | The media framework provides APIs to iterate over entities in a graph. | ||
225 | |||
226 | To iterate over all entities belonging to a media device, drivers can use the | ||
227 | media_device_for_each_entity macro, defined in include/media/media-device.h. | ||
228 | |||
229 | struct media_entity *entity; | ||
230 | |||
231 | media_device_for_each_entity(entity, mdev) { | ||
232 | /* entity will point to each entity in turn */ | ||
233 | ... | ||
234 | } | ||
235 | |||
236 | Drivers might also need to iterate over all entities in a graph that can be | ||
237 | reached only through enabled links starting at a given entity. The media | ||
238 | framework provides a depth-first graph traversal API for that purpose. | ||
239 | |||
240 | Note that graphs with cycles (whether directed or undirected) are *NOT* | ||
241 | supported by the graph traversal API. To prevent infinite loops, the graph | ||
242 | traversal code limits the maximum depth to MEDIA_ENTITY_ENUM_MAX_DEPTH, | ||
243 | currently defined as 16. | ||
244 | |||
245 | Drivers initiate a graph traversal by calling | ||
246 | |||
247 | media_entity_graph_walk_start(struct media_entity_graph *graph, | ||
248 | struct media_entity *entity); | ||
249 | |||
250 | The graph structure, provided by the caller, is initialized to start graph | ||
251 | traversal at the given entity. | ||
252 | |||
253 | Drivers can then retrieve the next entity by calling | ||
254 | |||
255 | media_entity_graph_walk_next(struct media_entity_graph *graph); | ||
256 | |||
257 | When the graph traversal is complete the function will return NULL. | ||
258 | |||
259 | Graph traversal can be interrupted at any moment. No cleanup function call is | ||
260 | required and the graph structure can be freed normally. | ||