vidioc-subdev-g-routing.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2. .. c:namespace:: V4L
  3. .. _VIDIOC_SUBDEV_G_ROUTING:
  4. ******************************************************
  5. ioctl VIDIOC_SUBDEV_G_ROUTING, VIDIOC_SUBDEV_S_ROUTING
  6. ******************************************************
  7. Name
  8. ====
  9. VIDIOC_SUBDEV_G_ROUTING - VIDIOC_SUBDEV_S_ROUTING - Get or set routing between streams of media pads in a media entity.
  10. Synopsis
  11. ========
  12. .. c:macro:: VIDIOC_SUBDEV_G_ROUTING
  13. ``int ioctl(int fd, VIDIOC_SUBDEV_G_ROUTING, struct v4l2_subdev_routing *argp)``
  14. .. c:macro:: VIDIOC_SUBDEV_S_ROUTING
  15. ``int ioctl(int fd, VIDIOC_SUBDEV_S_ROUTING, struct v4l2_subdev_routing *argp)``
  16. Arguments
  17. =========
  18. ``fd``
  19. File descriptor returned by :ref:`open() <func-open>`.
  20. ``argp``
  21. Pointer to struct :c:type:`v4l2_subdev_routing`.
  22. Description
  23. ===========
  24. These ioctls are used to get and set the routing in a media entity.
  25. The routing configuration determines the flows of data inside an entity.
  26. Drivers report their current routing tables using the
  27. ``VIDIOC_SUBDEV_G_ROUTING`` ioctl and application may enable or disable routes
  28. with the ``VIDIOC_SUBDEV_S_ROUTING`` ioctl, by adding or removing routes and
  29. setting or clearing flags of the ``flags`` field of a struct
  30. :c:type:`v4l2_subdev_route`. Similarly to ``VIDIOC_SUBDEV_G_ROUTING``, also
  31. ``VIDIOC_SUBDEV_S_ROUTING`` returns the routes back to the user.
  32. All stream configurations are reset when ``VIDIOC_SUBDEV_S_ROUTING`` is called.
  33. This means that the userspace must reconfigure all stream formats and selections
  34. after calling the ioctl with e.g. ``VIDIOC_SUBDEV_S_FMT``.
  35. Only subdevices which have both sink and source pads can support routing.
  36. The ``len_routes`` field indicates the number of routes that can fit in the
  37. ``routes`` array allocated by userspace. It is set by applications for both
  38. ioctls to indicate how many routes the kernel can return, and is never modified
  39. by the kernel.
  40. The ``num_routes`` field indicates the number of routes in the routing
  41. table. For ``VIDIOC_SUBDEV_S_ROUTING``, it is set by userspace to the number of
  42. routes that the application stored in the ``routes`` array. For both ioctls, it
  43. is returned by the kernel and indicates how many routes are stored in the
  44. subdevice routing table. This may be smaller or larger than the value of
  45. ``num_routes`` set by the application for ``VIDIOC_SUBDEV_S_ROUTING``, as
  46. drivers may adjust the requested routing table.
  47. The kernel can return a ``num_routes`` value larger than ``len_routes`` from
  48. both ioctls. This indicates thare are more routes in the routing table than fits
  49. the ``routes`` array. In this case, the ``routes`` array is filled by the kernel
  50. with the first ``len_routes`` entries of the subdevice routing table. This is
  51. not considered to be an error, and the ioctl call succeeds. If the applications
  52. wants to retrieve the missing routes, it can issue a new
  53. ``VIDIOC_SUBDEV_G_ROUTING`` call with a large enough ``routes`` array.
  54. ``VIDIOC_SUBDEV_S_ROUTING`` may return more routes than the user provided in
  55. ``num_routes`` field due to e.g. hardware properties.
  56. .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
  57. .. c:type:: v4l2_subdev_routing
  58. .. flat-table:: struct v4l2_subdev_routing
  59. :header-rows: 0
  60. :stub-columns: 0
  61. :widths: 1 1 2
  62. * - __u32
  63. - ``which``
  64. - Routing table to be accessed, from enum
  65. :ref:`v4l2_subdev_format_whence <v4l2-subdev-format-whence>`.
  66. * - __u32
  67. - ``len_routes``
  68. - The length of the array (as in memory reserved for the array)
  69. * - struct :c:type:`v4l2_subdev_route`
  70. - ``routes[]``
  71. - Array of struct :c:type:`v4l2_subdev_route` entries
  72. * - __u32
  73. - ``num_routes``
  74. - Number of entries of the routes array
  75. * - __u32
  76. - ``reserved``\ [11]
  77. - Reserved for future extensions. Applications and drivers must set
  78. the array to zero.
  79. .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
  80. .. c:type:: v4l2_subdev_route
  81. .. flat-table:: struct v4l2_subdev_route
  82. :header-rows: 0
  83. :stub-columns: 0
  84. :widths: 1 1 2
  85. * - __u32
  86. - ``sink_pad``
  87. - Sink pad number.
  88. * - __u32
  89. - ``sink_stream``
  90. - Sink pad stream number.
  91. * - __u32
  92. - ``source_pad``
  93. - Source pad number.
  94. * - __u32
  95. - ``source_stream``
  96. - Source pad stream number.
  97. * - __u32
  98. - ``flags``
  99. - Route enable/disable flags
  100. :ref:`v4l2_subdev_routing_flags <v4l2-subdev-routing-flags>`.
  101. * - __u32
  102. - ``reserved``\ [5]
  103. - Reserved for future extensions. Applications and drivers must set
  104. the array to zero.
  105. .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
  106. .. _v4l2-subdev-routing-flags:
  107. .. flat-table:: enum v4l2_subdev_routing_flags
  108. :header-rows: 0
  109. :stub-columns: 0
  110. :widths: 3 1 4
  111. * - V4L2_SUBDEV_ROUTE_FL_ACTIVE
  112. - 0x0001
  113. - The route is enabled. Set by applications.
  114. Return Value
  115. ============
  116. On success 0 is returned, on error -1 and the ``errno`` variable is set
  117. appropriately. The generic error codes are described at the
  118. :ref:`Generic Error Codes <gen-errors>` chapter.
  119. EINVAL
  120. The sink or source pad identifiers reference a non-existing pad or reference
  121. pads of different types (ie. the sink_pad identifiers refers to a source
  122. pad), the ``which`` field has an unsupported value, or, for
  123. ``VIDIOC_SUBDEV_S_ROUTING``, the num_routes field set by the application is
  124. larger than the len_routes field value.
  125. ENXIO
  126. The application requested routes cannot be created or the state of
  127. the specified routes cannot be modified. Only returned for
  128. ``VIDIOC_SUBDEV_S_ROUTING``.
  129. E2BIG
  130. The application provided ``num_routes`` for ``VIDIOC_SUBDEV_S_ROUTING`` is
  131. larger than the number of routes the driver can handle.