diff options
Diffstat (limited to 'drivers/media/video/v4l2-ctrls.c')
-rw-r--r-- | drivers/media/video/v4l2-ctrls.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index 9d2502cd03ff..8f81efcfcf56 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c | |||
@@ -38,15 +38,15 @@ struct ctrl_helper { | |||
38 | the given control ID. The pointer array ends with a NULL pointer. | 38 | the given control ID. The pointer array ends with a NULL pointer. |
39 | An empty string signifies a menu entry that is invalid. This allows | 39 | An empty string signifies a menu entry that is invalid. This allows |
40 | drivers to disable certain options if it is not supported. */ | 40 | drivers to disable certain options if it is not supported. */ |
41 | const char **v4l2_ctrl_get_menu(u32 id) | 41 | const char * const *v4l2_ctrl_get_menu(u32 id) |
42 | { | 42 | { |
43 | static const char *mpeg_audio_sampling_freq[] = { | 43 | static const char * const mpeg_audio_sampling_freq[] = { |
44 | "44.1 kHz", | 44 | "44.1 kHz", |
45 | "48 kHz", | 45 | "48 kHz", |
46 | "32 kHz", | 46 | "32 kHz", |
47 | NULL | 47 | NULL |
48 | }; | 48 | }; |
49 | static const char *mpeg_audio_encoding[] = { | 49 | static const char * const mpeg_audio_encoding[] = { |
50 | "MPEG-1/2 Layer I", | 50 | "MPEG-1/2 Layer I", |
51 | "MPEG-1/2 Layer II", | 51 | "MPEG-1/2 Layer II", |
52 | "MPEG-1/2 Layer III", | 52 | "MPEG-1/2 Layer III", |
@@ -54,7 +54,7 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
54 | "AC-3", | 54 | "AC-3", |
55 | NULL | 55 | NULL |
56 | }; | 56 | }; |
57 | static const char *mpeg_audio_l1_bitrate[] = { | 57 | static const char * const mpeg_audio_l1_bitrate[] = { |
58 | "32 kbps", | 58 | "32 kbps", |
59 | "64 kbps", | 59 | "64 kbps", |
60 | "96 kbps", | 60 | "96 kbps", |
@@ -71,7 +71,7 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
71 | "448 kbps", | 71 | "448 kbps", |
72 | NULL | 72 | NULL |
73 | }; | 73 | }; |
74 | static const char *mpeg_audio_l2_bitrate[] = { | 74 | static const char * const mpeg_audio_l2_bitrate[] = { |
75 | "32 kbps", | 75 | "32 kbps", |
76 | "48 kbps", | 76 | "48 kbps", |
77 | "56 kbps", | 77 | "56 kbps", |
@@ -88,7 +88,7 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
88 | "384 kbps", | 88 | "384 kbps", |
89 | NULL | 89 | NULL |
90 | }; | 90 | }; |
91 | static const char *mpeg_audio_l3_bitrate[] = { | 91 | static const char * const mpeg_audio_l3_bitrate[] = { |
92 | "32 kbps", | 92 | "32 kbps", |
93 | "40 kbps", | 93 | "40 kbps", |
94 | "48 kbps", | 94 | "48 kbps", |
@@ -105,7 +105,7 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
105 | "320 kbps", | 105 | "320 kbps", |
106 | NULL | 106 | NULL |
107 | }; | 107 | }; |
108 | static const char *mpeg_audio_ac3_bitrate[] = { | 108 | static const char * const mpeg_audio_ac3_bitrate[] = { |
109 | "32 kbps", | 109 | "32 kbps", |
110 | "40 kbps", | 110 | "40 kbps", |
111 | "48 kbps", | 111 | "48 kbps", |
@@ -127,50 +127,50 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
127 | "640 kbps", | 127 | "640 kbps", |
128 | NULL | 128 | NULL |
129 | }; | 129 | }; |
130 | static const char *mpeg_audio_mode[] = { | 130 | static const char * const mpeg_audio_mode[] = { |
131 | "Stereo", | 131 | "Stereo", |
132 | "Joint Stereo", | 132 | "Joint Stereo", |
133 | "Dual", | 133 | "Dual", |
134 | "Mono", | 134 | "Mono", |
135 | NULL | 135 | NULL |
136 | }; | 136 | }; |
137 | static const char *mpeg_audio_mode_extension[] = { | 137 | static const char * const mpeg_audio_mode_extension[] = { |
138 | "Bound 4", | 138 | "Bound 4", |
139 | "Bound 8", | 139 | "Bound 8", |
140 | "Bound 12", | 140 | "Bound 12", |
141 | "Bound 16", | 141 | "Bound 16", |
142 | NULL | 142 | NULL |
143 | }; | 143 | }; |
144 | static const char *mpeg_audio_emphasis[] = { | 144 | static const char * const mpeg_audio_emphasis[] = { |
145 | "No Emphasis", | 145 | "No Emphasis", |
146 | "50/15 us", | 146 | "50/15 us", |
147 | "CCITT J17", | 147 | "CCITT J17", |
148 | NULL | 148 | NULL |
149 | }; | 149 | }; |
150 | static const char *mpeg_audio_crc[] = { | 150 | static const char * const mpeg_audio_crc[] = { |
151 | "No CRC", | 151 | "No CRC", |
152 | "16-bit CRC", | 152 | "16-bit CRC", |
153 | NULL | 153 | NULL |
154 | }; | 154 | }; |
155 | static const char *mpeg_video_encoding[] = { | 155 | static const char * const mpeg_video_encoding[] = { |
156 | "MPEG-1", | 156 | "MPEG-1", |
157 | "MPEG-2", | 157 | "MPEG-2", |
158 | "MPEG-4 AVC", | 158 | "MPEG-4 AVC", |
159 | NULL | 159 | NULL |
160 | }; | 160 | }; |
161 | static const char *mpeg_video_aspect[] = { | 161 | static const char * const mpeg_video_aspect[] = { |
162 | "1x1", | 162 | "1x1", |
163 | "4x3", | 163 | "4x3", |
164 | "16x9", | 164 | "16x9", |
165 | "2.21x1", | 165 | "2.21x1", |
166 | NULL | 166 | NULL |
167 | }; | 167 | }; |
168 | static const char *mpeg_video_bitrate_mode[] = { | 168 | static const char * const mpeg_video_bitrate_mode[] = { |
169 | "Variable Bitrate", | 169 | "Variable Bitrate", |
170 | "Constant Bitrate", | 170 | "Constant Bitrate", |
171 | NULL | 171 | NULL |
172 | }; | 172 | }; |
173 | static const char *mpeg_stream_type[] = { | 173 | static const char * const mpeg_stream_type[] = { |
174 | "MPEG-2 Program Stream", | 174 | "MPEG-2 Program Stream", |
175 | "MPEG-2 Transport Stream", | 175 | "MPEG-2 Transport Stream", |
176 | "MPEG-1 System Stream", | 176 | "MPEG-1 System Stream", |
@@ -179,25 +179,25 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
179 | "MPEG-2 SVCD-compatible Stream", | 179 | "MPEG-2 SVCD-compatible Stream", |
180 | NULL | 180 | NULL |
181 | }; | 181 | }; |
182 | static const char *mpeg_stream_vbi_fmt[] = { | 182 | static const char * const mpeg_stream_vbi_fmt[] = { |
183 | "No VBI", | 183 | "No VBI", |
184 | "Private packet, IVTV format", | 184 | "Private packet, IVTV format", |
185 | NULL | 185 | NULL |
186 | }; | 186 | }; |
187 | static const char *camera_power_line_frequency[] = { | 187 | static const char * const camera_power_line_frequency[] = { |
188 | "Disabled", | 188 | "Disabled", |
189 | "50 Hz", | 189 | "50 Hz", |
190 | "60 Hz", | 190 | "60 Hz", |
191 | NULL | 191 | NULL |
192 | }; | 192 | }; |
193 | static const char *camera_exposure_auto[] = { | 193 | static const char * const camera_exposure_auto[] = { |
194 | "Auto Mode", | 194 | "Auto Mode", |
195 | "Manual Mode", | 195 | "Manual Mode", |
196 | "Shutter Priority Mode", | 196 | "Shutter Priority Mode", |
197 | "Aperture Priority Mode", | 197 | "Aperture Priority Mode", |
198 | NULL | 198 | NULL |
199 | }; | 199 | }; |
200 | static const char *colorfx[] = { | 200 | static const char * const colorfx[] = { |
201 | "None", | 201 | "None", |
202 | "Black & White", | 202 | "Black & White", |
203 | "Sepia", | 203 | "Sepia", |
@@ -210,7 +210,7 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
210 | "Vivid", | 210 | "Vivid", |
211 | NULL | 211 | NULL |
212 | }; | 212 | }; |
213 | static const char *tune_preemphasis[] = { | 213 | static const char * const tune_preemphasis[] = { |
214 | "No preemphasis", | 214 | "No preemphasis", |
215 | "50 useconds", | 215 | "50 useconds", |
216 | "75 useconds", | 216 | "75 useconds", |
@@ -952,7 +952,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, | |||
952 | const struct v4l2_ctrl_ops *ops, | 952 | const struct v4l2_ctrl_ops *ops, |
953 | u32 id, const char *name, enum v4l2_ctrl_type type, | 953 | u32 id, const char *name, enum v4l2_ctrl_type type, |
954 | s32 min, s32 max, u32 step, s32 def, | 954 | s32 min, s32 max, u32 step, s32 def, |
955 | u32 flags, const char **qmenu, void *priv) | 955 | u32 flags, const char * const *qmenu, void *priv) |
956 | { | 956 | { |
957 | struct v4l2_ctrl *ctrl; | 957 | struct v4l2_ctrl *ctrl; |
958 | unsigned sz_extra = 0; | 958 | unsigned sz_extra = 0; |
@@ -962,13 +962,20 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, | |||
962 | 962 | ||
963 | /* Sanity checks */ | 963 | /* Sanity checks */ |
964 | if (id == 0 || name == NULL || id >= V4L2_CID_PRIVATE_BASE || | 964 | if (id == 0 || name == NULL || id >= V4L2_CID_PRIVATE_BASE || |
965 | def < min || def > max || max < min || | 965 | max < min || |
966 | (type == V4L2_CTRL_TYPE_INTEGER && step == 0) || | 966 | (type == V4L2_CTRL_TYPE_INTEGER && step == 0) || |
967 | (type == V4L2_CTRL_TYPE_MENU && qmenu == NULL) || | 967 | (type == V4L2_CTRL_TYPE_MENU && qmenu == NULL) || |
968 | (type == V4L2_CTRL_TYPE_STRING && max == 0)) { | 968 | (type == V4L2_CTRL_TYPE_STRING && max == 0)) { |
969 | handler_set_err(hdl, -ERANGE); | 969 | handler_set_err(hdl, -ERANGE); |
970 | return NULL; | 970 | return NULL; |
971 | } | 971 | } |
972 | if ((type == V4L2_CTRL_TYPE_INTEGER || | ||
973 | type == V4L2_CTRL_TYPE_MENU || | ||
974 | type == V4L2_CTRL_TYPE_BOOLEAN) && | ||
975 | (def < min || def > max)) { | ||
976 | handler_set_err(hdl, -ERANGE); | ||
977 | return NULL; | ||
978 | } | ||
972 | 979 | ||
973 | if (type == V4L2_CTRL_TYPE_BUTTON) | 980 | if (type == V4L2_CTRL_TYPE_BUTTON) |
974 | flags |= V4L2_CTRL_FLAG_WRITE_ONLY; | 981 | flags |= V4L2_CTRL_FLAG_WRITE_ONLY; |
@@ -1019,7 +1026,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl, | |||
1019 | bool is_menu; | 1026 | bool is_menu; |
1020 | struct v4l2_ctrl *ctrl; | 1027 | struct v4l2_ctrl *ctrl; |
1021 | const char *name = cfg->name; | 1028 | const char *name = cfg->name; |
1022 | const char **qmenu = cfg->qmenu; | 1029 | const char * const *qmenu = cfg->qmenu; |
1023 | enum v4l2_ctrl_type type = cfg->type; | 1030 | enum v4l2_ctrl_type type = cfg->type; |
1024 | u32 flags = cfg->flags; | 1031 | u32 flags = cfg->flags; |
1025 | s32 min = cfg->min; | 1032 | s32 min = cfg->min; |
@@ -1075,7 +1082,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, | |||
1075 | const struct v4l2_ctrl_ops *ops, | 1082 | const struct v4l2_ctrl_ops *ops, |
1076 | u32 id, s32 max, s32 mask, s32 def) | 1083 | u32 id, s32 max, s32 mask, s32 def) |
1077 | { | 1084 | { |
1078 | const char **qmenu = v4l2_ctrl_get_menu(id); | 1085 | const char * const *qmenu = v4l2_ctrl_get_menu(id); |
1079 | const char *name; | 1086 | const char *name; |
1080 | enum v4l2_ctrl_type type; | 1087 | enum v4l2_ctrl_type type; |
1081 | s32 min; | 1088 | s32 min; |