diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2011-05-25 05:04:58 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 16:53:16 -0400 |
commit | 54c911eb919b44b178bda67564f274197872bd04 (patch) | |
tree | a0425adc781440d841a0f44fe3d08b09af419919 /drivers/media/video/v4l2-ctrls.c | |
parent | c20eb18ce1db6792db69f0574f7e955e9f92a213 (diff) |
[media] v4l2-ctrls: introduce call_op define
Add the call_op define to safely call the control ops. This also allows
for controls without any ops such as the 'control class' controls.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-ctrls.c')
-rw-r--r-- | drivers/media/video/v4l2-ctrls.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 2412f08527aa..3f2a0c5a1c3a 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c | |||
@@ -25,6 +25,9 @@ | |||
25 | #include <media/v4l2-ctrls.h> | 25 | #include <media/v4l2-ctrls.h> |
26 | #include <media/v4l2-dev.h> | 26 | #include <media/v4l2-dev.h> |
27 | 27 | ||
28 | #define call_op(master, op) \ | ||
29 | ((master->ops && master->ops->op) ? master->ops->op(master) : 0) | ||
30 | |||
28 | /* Internal temporary helper struct, one for each v4l2_ext_control */ | 31 | /* Internal temporary helper struct, one for each v4l2_ext_control */ |
29 | struct ctrl_helper { | 32 | struct ctrl_helper { |
30 | /* The control corresponding to the v4l2_ext_control ID field. */ | 33 | /* The control corresponding to the v4l2_ext_control ID field. */ |
@@ -1291,7 +1294,7 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl) | |||
1291 | if (ctrl->type == V4L2_CTRL_TYPE_BUTTON || | 1294 | if (ctrl->type == V4L2_CTRL_TYPE_BUTTON || |
1292 | (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) | 1295 | (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)) |
1293 | continue; | 1296 | continue; |
1294 | ret = master->ops->s_ctrl(master); | 1297 | ret = call_op(master, s_ctrl); |
1295 | if (ret) | 1298 | if (ret) |
1296 | break; | 1299 | break; |
1297 | for (i = 0; i < master->ncontrols; i++) | 1300 | for (i = 0; i < master->ncontrols; i++) |
@@ -1568,8 +1571,8 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls *cs | |||
1568 | 1571 | ||
1569 | v4l2_ctrl_lock(master); | 1572 | v4l2_ctrl_lock(master); |
1570 | /* g_volatile_ctrl will update the current control values */ | 1573 | /* g_volatile_ctrl will update the current control values */ |
1571 | if (ctrl->is_volatile && master->ops->g_volatile_ctrl) | 1574 | if (ctrl->is_volatile) |
1572 | ret = master->ops->g_volatile_ctrl(master); | 1575 | ret = call_op(master, g_volatile_ctrl); |
1573 | /* If OK, then copy the current control values to the caller */ | 1576 | /* If OK, then copy the current control values to the caller */ |
1574 | if (!ret) | 1577 | if (!ret) |
1575 | ret = cluster_walk(i, cs, helpers, cur_to_user); | 1578 | ret = cluster_walk(i, cs, helpers, cur_to_user); |
@@ -1600,8 +1603,8 @@ static int get_ctrl(struct v4l2_ctrl *ctrl, s32 *val) | |||
1600 | 1603 | ||
1601 | v4l2_ctrl_lock(master); | 1604 | v4l2_ctrl_lock(master); |
1602 | /* g_volatile_ctrl will update the current control values */ | 1605 | /* g_volatile_ctrl will update the current control values */ |
1603 | if (ctrl->is_volatile && master->ops->g_volatile_ctrl) | 1606 | if (ctrl->is_volatile) |
1604 | ret = master->ops->g_volatile_ctrl(master); | 1607 | ret = call_op(master, g_volatile_ctrl); |
1605 | *val = ctrl->cur.val; | 1608 | *val = ctrl->cur.val; |
1606 | v4l2_ctrl_unlock(master); | 1609 | v4l2_ctrl_unlock(master); |
1607 | return ret; | 1610 | return ret; |
@@ -1675,12 +1678,12 @@ static int try_or_set_control_cluster(struct v4l2_ctrl *master, bool set) | |||
1675 | /* For larger clusters you have to call try_ctrl again to | 1678 | /* For larger clusters you have to call try_ctrl again to |
1676 | verify that the controls are still valid after the | 1679 | verify that the controls are still valid after the |
1677 | 'cur_to_new' above. */ | 1680 | 'cur_to_new' above. */ |
1678 | if (!ret && master->ops->try_ctrl && try) | 1681 | if (!ret && try) |
1679 | ret = master->ops->try_ctrl(master); | 1682 | ret = call_op(master, try_ctrl); |
1680 | 1683 | ||
1681 | /* Don't set if there is no change */ | 1684 | /* Don't set if there is no change */ |
1682 | if (!ret && set && cluster_changed(master)) { | 1685 | if (!ret && set && cluster_changed(master)) { |
1683 | ret = master->ops->s_ctrl(master); | 1686 | ret = call_op(master, s_ctrl); |
1684 | /* If OK, then make the new values permanent. */ | 1687 | /* If OK, then make the new values permanent. */ |
1685 | if (!ret) | 1688 | if (!ret) |
1686 | for (i = 0; i < master->ncontrols; i++) | 1689 | for (i = 0; i < master->ncontrols; i++) |