media: v4l: subdev: Add trivial set_routing support

Add trivial S_ROUTING IOCTL support for drivers where routing is static.
Essentially this means returning the same information G_ROUTING call would
have done.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Julien Massot <julien.massot@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Sakari Ailus 2023-08-31 15:40:07 +03:00 committed by Hans Verkuil
parent 91e99e5a0b
commit 1bfef49741

View File

@ -1013,6 +1013,20 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
return -EINVAL;
}
/*
* If the driver doesn't support setting routing, just return
* the routing table.
*/
if (!v4l2_subdev_has_op(sd, pad, set_routing)) {
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;
}
krouting.num_routes = routing->num_routes;
krouting.len_routes = routing->len_routes;
krouting.routes = routes;