aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/common/cx2341x.c29
-rw-r--r--drivers/media/v4l2-core/v4l2-common.c30
-rw-r--r--include/media/v4l2-common.h4
3 files changed, 30 insertions, 33 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{
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index 849320932657..5b808500e7e7 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -80,36 +80,6 @@ MODULE_LICENSE("GPL");
80 80
81/* Helper functions for control handling */ 81/* Helper functions for control handling */
82 82
83/* Check for correctness of the ctrl's value based on the data from
84 struct v4l2_queryctrl and the available menu items. Note that
85 menu_items may be NULL, in that case it is ignored. */
86int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
87 const char * const *menu_items)
88{
89 if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED)
90 return -EINVAL;
91 if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED)
92 return -EBUSY;
93 if (qctrl->type == V4L2_CTRL_TYPE_STRING)
94 return 0;
95 if (qctrl->type == V4L2_CTRL_TYPE_BUTTON ||
96 qctrl->type == V4L2_CTRL_TYPE_INTEGER64 ||
97 qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS)
98 return 0;
99 if (ctrl->value < qctrl->minimum || ctrl->value > qctrl->maximum)
100 return -ERANGE;
101 if (qctrl->type == V4L2_CTRL_TYPE_MENU && menu_items != NULL) {
102 if (menu_items[ctrl->value] == NULL ||
103 menu_items[ctrl->value][0] == '\0')
104 return -EINVAL;
105 }
106 if (qctrl->type == V4L2_CTRL_TYPE_BITMASK &&
107 (ctrl->value & ~qctrl->maximum))
108 return -ERANGE;
109 return 0;
110}
111EXPORT_SYMBOL(v4l2_ctrl_check);
112
113/* Fill in a struct v4l2_queryctrl */ 83/* Fill in a struct v4l2_queryctrl */
114int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 _min, s32 _max, s32 _step, s32 _def) 84int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 _min, s32 _max, s32 _step, s32 _def)
115{ 85{
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index c69d91d32e59..1cc0c5ba16b3 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -80,10 +80,8 @@
80 80
81/* ------------------------------------------------------------------------- */ 81/* ------------------------------------------------------------------------- */
82 82
83/* Control helper functions */ 83/* Control helper function */
84 84
85int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
86 const char * const *menu_items);
87int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def); 85int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def);
88 86
89/* ------------------------------------------------------------------------- */ 87/* ------------------------------------------------------------------------- */