media: v4l: subdev: Return routes set using S_ROUTING
authorSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 6 Sep 2023 10:51:04 +0000 (13:51 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 29 Apr 2024 12:56:37 +0000 (14:56 +0200)
Return the routes set using S_ROUTING back to the user. Also reflect this
in documentation.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Documentation/userspace-api/media/v4l/vidioc-subdev-g-routing.rst
drivers/media/v4l2-core/v4l2-subdev.c

index cbd9370006b698d3c40554a9aee8156fdcd6de8b..1cf795480602067da8168887165c5545c6e79177 100644 (file)
@@ -44,7 +44,8 @@ Drivers report their current routing tables using the
 ``VIDIOC_SUBDEV_G_ROUTING`` ioctl and application may enable or disable routes
 with the ``VIDIOC_SUBDEV_S_ROUTING`` ioctl, by adding or removing routes and
 setting or clearing flags of the ``flags`` field of a struct
-:c:type:`v4l2_subdev_route`.
+:c:type:`v4l2_subdev_route`. Similarly to ``VIDIOC_SUBDEV_G_ROUTING``, also
+``VIDIOC_SUBDEV_S_ROUTING`` returns the routes back to the user.
 
 All stream configurations are reset when ``VIDIOC_SUBDEV_S_ROUTING`` is called.
 This means that the userspace must reconfigure all stream formats and selections
@@ -153,10 +154,6 @@ On success 0 is returned, on error -1 and the ``errno`` variable is set
 appropriately. The generic error codes are described at the
 :ref:`Generic Error Codes <gen-errors>` chapter.
 
-ENOSPC
-   The application provided ``num_routes`` is not big enough to contain
-   all the available routes the subdevice exposes.
-
 EINVAL
    The sink or source pad identifiers reference a non-existing pad or reference
    pads of different types (ie. the sink_pad identifiers refers to a source
index b565f202df679ecde593ee36463145be7490559d..3d1ed8ab5229bc8026553cc9d71c22cfafedd97d 100644 (file)
@@ -1017,8 +1017,18 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
                krouting.len_routes = routing->len_routes;
                krouting.routes = routes;
 
-               return v4l2_subdev_call(sd, pad, set_routing, state,
+               rval = v4l2_subdev_call(sd, pad, set_routing, state,
                                        routing->which, &krouting);
+               if (rval < 0)
+                       return rval;
+
+               memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes,
+                      state->routing.routes,
+                      min(state->routing.num_routes, routing->len_routes) *
+                      sizeof(*state->routing.routes));
+               routing->num_routes = state->routing.num_routes;
+
+               return 0;
        }
 
        case VIDIOC_SUBDEV_G_CLIENT_CAP: {