Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: Documentation: mc: Replace deprecated graph walk API

The graph walk API has been deprecated in commit eac564de0915 ("media:
mc: entity: Add entity iterator for media_pipeline") in favour of
pipelien iterators, but the MC documentation hasn't been updated
accordingly. It still documents the deprecated API as the only option.
Fix it by dropping the deprecated function, and documenting the new API.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/20240822212445.2037-5-laurent.pinchart+renesas@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

authored by

Laurent Pinchart and committed by
Laurent Pinchart
6c573f25 4ec2caab

+41 -26
+41 -26
Documentation/driver-api/media/mc-core.rst
··· 144 144 Graph traversal 145 145 ^^^^^^^^^^^^^^^ 146 146 147 - The media framework provides APIs to iterate over entities in a graph. 147 + The media framework provides APIs to traverse media graphs, locating connected 148 + entities and links. 148 149 149 150 To iterate over all entities belonging to a media device, drivers can use 150 151 the media_device_for_each_entity macro, defined in ··· 159 158 // entity will point to each entity in turn 160 159 ... 161 160 } 162 - 163 - Drivers might also need to iterate over all entities in a graph that can be 164 - reached only through enabled links starting at a given entity. The media 165 - framework provides a depth-first graph traversal API for that purpose. 166 - 167 - .. note:: 168 - 169 - Graphs with cycles (whether directed or undirected) are **NOT** 170 - supported by the graph traversal API. To prevent infinite loops, the graph 171 - traversal code limits the maximum depth to ``MEDIA_ENTITY_ENUM_MAX_DEPTH``, 172 - currently defined as 16. 173 - 174 - Drivers initiate a graph traversal by calling 175 - :c:func:`media_graph_walk_start()` 176 - 177 - The graph structure, provided by the caller, is initialized to start graph 178 - traversal at the given entity. 179 - 180 - Drivers can then retrieve the next entity by calling 181 - :c:func:`media_graph_walk_next()` 182 - 183 - When the graph traversal is complete the function will return ``NULL``. 184 - 185 - Graph traversal can be interrupted at any moment. No cleanup function call 186 - is required and the graph structure can be freed normally. 187 161 188 162 Helper functions can be used to find a link between two given pads, or a pad 189 163 connected to another pad through an enabled link ··· 251 275 Subsystems should facilitate link validation by providing subsystem specific 252 276 helper functions to provide easy access for commonly needed information, and 253 277 in the end provide a way to use driver-specific callbacks. 278 + 279 + Pipeline traversal 280 + ^^^^^^^^^^^^^^^^^^ 281 + 282 + Once a pipeline has been constructed with :c:func:`media_pipeline_start()`, 283 + drivers can iterate over entities or pads in the pipeline with the 284 + :c:macro:´media_pipeline_for_each_entity` and 285 + :c:macro:´media_pipeline_for_each_pad` macros. Iterating over pads is 286 + straightforward: 287 + 288 + .. code-block:: c 289 + 290 + media_pipeline_pad_iter iter; 291 + struct media_pad *pad; 292 + 293 + media_pipeline_for_each_pad(pipe, &iter, pad) { 294 + /* 'pad' will point to each pad in turn */ 295 + ... 296 + } 297 + 298 + To iterate over entities, the iterator needs to be initialized and cleaned up 299 + as an additional steps: 300 + 301 + .. code-block:: c 302 + 303 + media_pipeline_entity_iter iter; 304 + struct media_entity *entity; 305 + int ret; 306 + 307 + ret = media_pipeline_entity_iter_init(pipe, &iter); 308 + if (ret) 309 + ...; 310 + 311 + media_pipeline_for_each_entity(pipe, &iter, entity) { 312 + /* 'entity' will point to each entity in turn */ 313 + ... 314 + } 315 + 316 + media_pipeline_entity_iter_cleanup(&iter); 254 317 255 318 Media Controller Device Allocator API 256 319 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^