aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/common
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-11-23 07:39:55 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-25 05:25:36 -0500
commit4daee77976718b3e8136e37872d7ad5c36754e25 (patch)
treee8376779c8f56390180d5d27256920be2fb8b7ed /drivers/media/common
parent79fbc209f11b82d8cad37e20da71851fdceecfbd (diff)
[media] v4l2-common: move v4l2_ctrl_check to cx2341x
The v4l2_ctrl_check() helper function is now only used in cx2341x. Move it there and make it static. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/common')
-rw-r--r--drivers/media/common/cx2341x.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/media/common/cx2341x.c b/drivers/media/common/cx2341x.c
index be763150b8aa..c07b9db51b05 100644
--- a/drivers/media/common/cx2341x.c
+++ b/drivers/media/common/cx2341x.c
@@ -931,6 +931,35 @@ static void cx2341x_calc_audio_properties(struct cx2341x_mpeg_params *params)
931 } 931 }
932} 932}
933 933
934/* Check for correctness of the ctrl's value based on the data from
935 struct v4l2_queryctrl and the available menu items. Note that
936 menu_items may be NULL, in that case it is ignored. */
937static int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
938 const char * const *menu_items)
939{
940 if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED)
941 return -EINVAL;
942 if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED)
943 return -EBUSY;
944 if (qctrl->type == V4L2_CTRL_TYPE_STRING)
945 return 0;
946 if (qctrl->type == V4L2_CTRL_TYPE_BUTTON ||
947 qctrl->type == V4L2_CTRL_TYPE_INTEGER64 ||
948 qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS)
949 return 0;
950 if (ctrl->value < qctrl->minimum || ctrl->value > qctrl->maximum)
951 return -ERANGE;
952 if (qctrl->type == V4L2_CTRL_TYPE_MENU && menu_items != NULL) {
953 if (menu_items[ctrl->value] == NULL ||
954 menu_items[ctrl->value][0] == '\0')
955 return -EINVAL;
956 }
957 if (qctrl->type == V4L2_CTRL_TYPE_BITMASK &&
958 (ctrl->value & ~qctrl->maximum))
959 return -ERANGE;
960 return 0;
961}
962
934int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy, 963int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy,
935 struct v4l2_ext_controls *ctrls, unsigned int cmd) 964 struct v4l2_ext_controls *ctrls, unsigned int cmd)
936{ 965{