mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
media: v4l2-subdev: Refactor returning routes
Refactor returning the routes by adding a new function that essentially does a memcopy and sets the number of the routes in the routing table. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Michael Riesch <michael.riesch@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
This commit is contained in:
parent
ef56c563c4
commit
1155f8e0cc
|
|
@ -629,6 +629,18 @@ subdev_ioctl_get_state(struct v4l2_subdev *sd, struct v4l2_subdev_fh *subdev_fh,
|
|||
v4l2_subdev_get_unlocked_active_state(sd);
|
||||
}
|
||||
|
||||
static void v4l2_subdev_copy_routes(struct v4l2_subdev_routing *routing,
|
||||
const struct v4l2_subdev_state *state)
|
||||
{
|
||||
struct v4l2_subdev_route *routes =
|
||||
(struct v4l2_subdev_route *)(uintptr_t)routing->routes;
|
||||
u32 copy_routes = min(routing->len_routes, state->routing.num_routes);
|
||||
|
||||
memcpy(routes, state->routing.routes, sizeof(*routes) * copy_routes);
|
||||
|
||||
routing->num_routes = state->routing.num_routes;
|
||||
}
|
||||
|
||||
static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
|
||||
struct v4l2_subdev_state *state)
|
||||
{
|
||||
|
|
@ -1000,7 +1012,6 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
|
|||
|
||||
case VIDIOC_SUBDEV_G_ROUTING: {
|
||||
struct v4l2_subdev_routing *routing = arg;
|
||||
struct v4l2_subdev_krouting *krouting;
|
||||
|
||||
if (!v4l2_subdev_enable_streams_api)
|
||||
return -ENOIOCTLCMD;
|
||||
|
|
@ -1010,13 +1021,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
|
|||
|
||||
memset(routing->reserved, 0, sizeof(routing->reserved));
|
||||
|
||||
krouting = &state->routing;
|
||||
|
||||
memcpy((struct v4l2_subdev_route *)(uintptr_t)routing->routes,
|
||||
krouting->routes,
|
||||
min(krouting->num_routes, routing->len_routes) *
|
||||
sizeof(*krouting->routes));
|
||||
routing->num_routes = krouting->num_routes;
|
||||
v4l2_subdev_copy_routes(routing, state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1084,11 +1089,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
|
|||
* 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;
|
||||
v4l2_subdev_copy_routes(routing, state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1102,11 +1103,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
|
|||
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;
|
||||
v4l2_subdev_copy_routes(routing, state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user