diff options
Diffstat (limited to 'drivers/media/video/v4l2-ctrls.c')
-rw-r--r-- | drivers/media/video/v4l2-ctrls.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 91b197819fc..ae544d870d7 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c | |||
@@ -2424,9 +2424,13 @@ int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val) | |||
2424 | } | 2424 | } |
2425 | EXPORT_SYMBOL(v4l2_ctrl_s_ctrl); | 2425 | EXPORT_SYMBOL(v4l2_ctrl_s_ctrl); |
2426 | 2426 | ||
2427 | void v4l2_ctrl_add_event(struct v4l2_ctrl *ctrl, | 2427 | static int v4l2_ctrl_add_event(struct v4l2_subscribed_event *sev) |
2428 | struct v4l2_subscribed_event *sev) | ||
2429 | { | 2428 | { |
2429 | struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); | ||
2430 | |||
2431 | if (ctrl == NULL) | ||
2432 | return -EINVAL; | ||
2433 | |||
2430 | v4l2_ctrl_lock(ctrl); | 2434 | v4l2_ctrl_lock(ctrl); |
2431 | list_add_tail(&sev->node, &ctrl->ev_subs); | 2435 | list_add_tail(&sev->node, &ctrl->ev_subs); |
2432 | if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS && | 2436 | if (ctrl->type != V4L2_CTRL_TYPE_CTRL_CLASS && |
@@ -2440,17 +2444,40 @@ void v4l2_ctrl_add_event(struct v4l2_ctrl *ctrl, | |||
2440 | v4l2_event_queue_fh(sev->fh, &ev); | 2444 | v4l2_event_queue_fh(sev->fh, &ev); |
2441 | } | 2445 | } |
2442 | v4l2_ctrl_unlock(ctrl); | 2446 | v4l2_ctrl_unlock(ctrl); |
2447 | return 0; | ||
2443 | } | 2448 | } |
2444 | EXPORT_SYMBOL(v4l2_ctrl_add_event); | ||
2445 | 2449 | ||
2446 | void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl, | 2450 | static void v4l2_ctrl_del_event(struct v4l2_subscribed_event *sev) |
2447 | struct v4l2_subscribed_event *sev) | ||
2448 | { | 2451 | { |
2452 | struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id); | ||
2453 | |||
2449 | v4l2_ctrl_lock(ctrl); | 2454 | v4l2_ctrl_lock(ctrl); |
2450 | list_del(&sev->node); | 2455 | list_del(&sev->node); |
2451 | v4l2_ctrl_unlock(ctrl); | 2456 | v4l2_ctrl_unlock(ctrl); |
2452 | } | 2457 | } |
2453 | EXPORT_SYMBOL(v4l2_ctrl_del_event); | 2458 | |
2459 | void v4l2_ctrl_replace(struct v4l2_event *old, const struct v4l2_event *new) | ||
2460 | { | ||
2461 | u32 old_changes = old->u.ctrl.changes; | ||
2462 | |||
2463 | old->u.ctrl = new->u.ctrl; | ||
2464 | old->u.ctrl.changes |= old_changes; | ||
2465 | } | ||
2466 | EXPORT_SYMBOL(v4l2_ctrl_replace); | ||
2467 | |||
2468 | void v4l2_ctrl_merge(const struct v4l2_event *old, struct v4l2_event *new) | ||
2469 | { | ||
2470 | new->u.ctrl.changes |= old->u.ctrl.changes; | ||
2471 | } | ||
2472 | EXPORT_SYMBOL(v4l2_ctrl_merge); | ||
2473 | |||
2474 | const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops = { | ||
2475 | .add = v4l2_ctrl_add_event, | ||
2476 | .del = v4l2_ctrl_del_event, | ||
2477 | .replace = v4l2_ctrl_replace, | ||
2478 | .merge = v4l2_ctrl_merge, | ||
2479 | }; | ||
2480 | EXPORT_SYMBOL(v4l2_ctrl_sub_ev_ops); | ||
2454 | 2481 | ||
2455 | int v4l2_ctrl_log_status(struct file *file, void *fh) | 2482 | int v4l2_ctrl_log_status(struct file *file, void *fh) |
2456 | { | 2483 | { |
@@ -2468,7 +2495,7 @@ int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh, | |||
2468 | struct v4l2_event_subscription *sub) | 2495 | struct v4l2_event_subscription *sub) |
2469 | { | 2496 | { |
2470 | if (sub->type == V4L2_EVENT_CTRL) | 2497 | if (sub->type == V4L2_EVENT_CTRL) |
2471 | return v4l2_event_subscribe(fh, sub, 0, NULL); | 2498 | return v4l2_event_subscribe(fh, sub, 0, &v4l2_ctrl_sub_ev_ops); |
2472 | return -EINVAL; | 2499 | return -EINVAL; |
2473 | } | 2500 | } |
2474 | EXPORT_SYMBOL(v4l2_ctrl_subscribe_event); | 2501 | EXPORT_SYMBOL(v4l2_ctrl_subscribe_event); |