[media] v4l2-ctrls: add a notify callback
Sometimes platform/bridge drivers need to be notified when a control from a sub-device changes value. In order to support this a notify callback was added. [dheitmueller@kernellabs.com: fix merge conflict in v4l2-ctrls.c] Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:

committed by
Mauro Carvalho Chehab

parent
20deebfe17
commit
8ac7a9493a
@@ -1204,6 +1204,8 @@ static void new_to_cur(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl,
|
||||
send_event(fh, ctrl,
|
||||
(changed ? V4L2_EVENT_CTRL_CH_VALUE : 0) |
|
||||
(update_inactive ? V4L2_EVENT_CTRL_CH_FLAGS : 0));
|
||||
if (ctrl->call_notify && changed && ctrl->handler->notify)
|
||||
ctrl->handler->notify(ctrl, ctrl->handler->notify_priv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2725,6 +2727,22 @@ int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val)
|
||||
}
|
||||
EXPORT_SYMBOL(v4l2_ctrl_s_ctrl_int64);
|
||||
|
||||
void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void *priv)
|
||||
{
|
||||
if (ctrl == NULL)
|
||||
return;
|
||||
if (notify == NULL) {
|
||||
ctrl->call_notify = 0;
|
||||
return;
|
||||
}
|
||||
if (WARN_ON(ctrl->handler->notify && ctrl->handler->notify != notify))
|
||||
return;
|
||||
ctrl->handler->notify = notify;
|
||||
ctrl->handler->notify_priv = priv;
|
||||
ctrl->call_notify = 1;
|
||||
}
|
||||
EXPORT_SYMBOL(v4l2_ctrl_notify);
|
||||
|
||||
static int v4l2_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned elems)
|
||||
{
|
||||
struct v4l2_ctrl *ctrl = v4l2_ctrl_find(sev->fh->ctrl_handler, sev->id);
|
||||
|
Reference in New Issue
Block a user