From: Hans Verkuil <hans.verkuil@xxxxxxxxx> Signed-off-by: Hans Verkuil <hans.verkuil@xxxxxxxxx> --- drivers/media/v4l2-core/v4l2-ctrls.c | 42 ++++++++++++++++++++++++++++++++++++ include/media/v4l2-ctrls.h | 1 + 2 files changed, 43 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 93c51cc..43fb3c2 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -3566,6 +3566,48 @@ unlock: } EXPORT_SYMBOL(v4l2_ctrl_apply_request); +int v4l2_ctrl_delete_request(struct v4l2_ctrl_handler *hdl, unsigned request) +{ + struct v4l2_ctrl_ref *ref; + unsigned i; + + if (hdl == NULL || request == 0) + return -EINVAL; + + mutex_lock(hdl->lock); + + list_for_each_entry(ref, &hdl->ctrl_refs, node) { + struct v4l2_ctrl *master; + + if (ref->ctrl->max_reqs == 0) + continue; + master = ref->ctrl->cluster[0]; + if (ref->ctrl != master) + continue; + if (master->handler != hdl) + v4l2_ctrl_lock(master); + for (i = 0; i < master->ncontrols; i++) { + struct v4l2_ctrl *ctrl = master->cluster[i]; + struct v4l2_ctrl_req *req; + + if (ctrl == NULL || ctrl->request_lists == NULL) + continue; + + if (request == 0) { + free_requests(ctrl); + continue; + } + req = get_request(ctrl, request); + if (req) + del_request(ctrl, req); + } + if (master->handler != hdl) + v4l2_ctrl_unlock(master); + } + return 0; +} +EXPORT_SYMBOL(v4l2_ctrl_delete_request); + void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv) { if (ctrl == NULL) diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 2d188a2..324db6d 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -810,6 +810,7 @@ static inline void v4l2_ctrl_s_max_reqs(struct v4l2_ctrl *ctrl, u16 max_reqs) } int v4l2_ctrl_apply_request(struct v4l2_ctrl_handler *hdl, unsigned request); +int v4l2_ctrl_delete_request(struct v4l2_ctrl_handler *hdl, unsigned request); /* Internal helper functions that deal with control events. */ extern const struct v4l2_subscribed_event_ops v4l2_ctrl_sub_ev_ops; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html