diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2006-06-18 13:11:08 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-25 01:05:21 -0400 |
commit | 9cb2318b885d2039eeb3eb5394fa215046be058f (patch) | |
tree | 2289616dbbbd60ac93ce56e43c0eaec27bf65604 /drivers | |
parent | 0597691456cf3b08974d9949e4caa830e1d3c520 (diff) |
V4L/DVB (4190): Add helper functions for control processing to v4l2-common.
Control processing is often duplicated in the various drivers. Unfortunately,
simple things like the names of controls are often different between drivers,
even though it is the same controls. Adding in the new extended controls and
the need for having control helper functions became apparent.
Several functions have now been added to v4l2-common to do things like
filling the v4l2_queryctrl and v4l2_querymenu structs, to check for
valid control input and to move to the next control when enumerating
over all controls.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/v4l2-common.c | 507 |
1 files changed, 506 insertions, 1 deletions
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 2b2c0b3a16a..14e52347135 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -294,7 +294,10 @@ static const char *v4l2_ioctls[] = { | |||
294 | #if 1 | 294 | #if 1 |
295 | [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP", | 295 | [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP", |
296 | #endif | 296 | #endif |
297 | [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS" | 297 | [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS", |
298 | [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS", | ||
299 | [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS", | ||
300 | [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS" | ||
298 | }; | 301 | }; |
299 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | 302 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) |
300 | 303 | ||
@@ -511,6 +514,23 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg) | |||
511 | printk ("%s: id=%d, value=%d\n", s, p->id, p->value); | 514 | printk ("%s: id=%d, value=%d\n", s, p->id, p->value); |
512 | break; | 515 | break; |
513 | } | 516 | } |
517 | case VIDIOC_G_EXT_CTRLS: | ||
518 | case VIDIOC_S_EXT_CTRLS: | ||
519 | case VIDIOC_TRY_EXT_CTRLS: | ||
520 | { | ||
521 | struct v4l2_ext_controls *p = arg; | ||
522 | int i; | ||
523 | |||
524 | printk("%s: ctrl_class=%d, count=%d\n", s, p->ctrl_class, p->count); | ||
525 | for (i = 0; i < p->count; i++) { | ||
526 | struct v4l2_ext_control *c = &p->controls[i]; | ||
527 | if (cmd == VIDIOC_G_EXT_CTRLS) | ||
528 | printk("%s: id=%d\n", s, c->id); | ||
529 | else | ||
530 | printk("%s: id=%d, value=%d\n", s, c->id, c->value); | ||
531 | } | ||
532 | break; | ||
533 | } | ||
514 | case VIDIOC_G_CROP: | 534 | case VIDIOC_G_CROP: |
515 | case VIDIOC_S_CROP: | 535 | case VIDIOC_S_CROP: |
516 | { | 536 | { |
@@ -935,6 +955,484 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg) | |||
935 | 955 | ||
936 | /* ----------------------------------------------------------------- */ | 956 | /* ----------------------------------------------------------------- */ |
937 | 957 | ||
958 | /* Helper functions for control handling */ | ||
959 | |||
960 | /* Check for correctness of the ctrl's value based on the data from | ||
961 | struct v4l2_queryctrl and the available menu items. Note that | ||
962 | menu_items may be NULL, in that case it is ignored. */ | ||
963 | int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, | ||
964 | const char **menu_items) | ||
965 | { | ||
966 | if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED) | ||
967 | return -EINVAL; | ||
968 | if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED) | ||
969 | return -EBUSY; | ||
970 | if (qctrl->type == V4L2_CTRL_TYPE_BUTTON || | ||
971 | qctrl->type == V4L2_CTRL_TYPE_INTEGER64 || | ||
972 | qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) | ||
973 | return 0; | ||
974 | if (ctrl->value < qctrl->minimum || ctrl->value > qctrl->maximum) | ||
975 | return -ERANGE; | ||
976 | if (qctrl->type == V4L2_CTRL_TYPE_MENU && menu_items != NULL) { | ||
977 | if (menu_items[ctrl->value] == NULL || | ||
978 | menu_items[ctrl->value][0] == '\0') | ||
979 | return -EINVAL; | ||
980 | } | ||
981 | return 0; | ||
982 | } | ||
983 | |||
984 | /* Returns NULL or a character pointer array containing the menu for | ||
985 | the given control ID. The pointer array ends with a NULL pointer. | ||
986 | An empty string signifies a menu entry that is invalid. This allows | ||
987 | drivers to disable certain options if it is not supported. */ | ||
988 | const char **v4l2_ctrl_get_menu(u32 id) | ||
989 | { | ||
990 | static const char *mpeg_audio_sampling_freq[] = { | ||
991 | "44.1 kHz", | ||
992 | "48 kHz", | ||
993 | "32 kHz", | ||
994 | NULL | ||
995 | }; | ||
996 | static const char *mpeg_audio_encoding[] = { | ||
997 | "Layer I", | ||
998 | "Layer II", | ||
999 | "Layer III", | ||
1000 | NULL | ||
1001 | }; | ||
1002 | static const char *mpeg_audio_l1_bitrate[] = { | ||
1003 | "32 kbps", | ||
1004 | "64 kbps", | ||
1005 | "96 kbps", | ||
1006 | "128 kbps", | ||
1007 | "160 kbps", | ||
1008 | "192 kbps", | ||
1009 | "224 kbps", | ||
1010 | "256 kbps", | ||
1011 | "288 kbps", | ||
1012 | "320 kbps", | ||
1013 | "352 kbps", | ||
1014 | "384 kbps", | ||
1015 | "416 kbps", | ||
1016 | "448 kbps", | ||
1017 | NULL | ||
1018 | }; | ||
1019 | static const char *mpeg_audio_l2_bitrate[] = { | ||
1020 | "32 kbps", | ||
1021 | "48 kbps", | ||
1022 | "56 kbps", | ||
1023 | "64 kbps", | ||
1024 | "80 kbps", | ||
1025 | "96 kbps", | ||
1026 | "112 kbps", | ||
1027 | "128 kbps", | ||
1028 | "160 kbps", | ||
1029 | "192 kbps", | ||
1030 | "224 kbps", | ||
1031 | "256 kbps", | ||
1032 | "320 kbps", | ||
1033 | "384 kbps", | ||
1034 | NULL | ||
1035 | }; | ||
1036 | static const char *mpeg_audio_l3_bitrate[] = { | ||
1037 | "32 kbps", | ||
1038 | "40 kbps", | ||
1039 | "48 kbps", | ||
1040 | "56 kbps", | ||
1041 | "64 kbps", | ||
1042 | "80 kbps", | ||
1043 | "96 kbps", | ||
1044 | "112 kbps", | ||
1045 | "128 kbps", | ||
1046 | "160 kbps", | ||
1047 | "192 kbps", | ||
1048 | "224 kbps", | ||
1049 | "256 kbps", | ||
1050 | "320 kbps", | ||
1051 | NULL | ||
1052 | }; | ||
1053 | static const char *mpeg_audio_mode[] = { | ||
1054 | "Stereo", | ||
1055 | "Joint Stereo", | ||
1056 | "Dual", | ||
1057 | "Mono", | ||
1058 | NULL | ||
1059 | }; | ||
1060 | static const char *mpeg_audio_mode_extension[] = { | ||
1061 | "Bound 4", | ||
1062 | "Bound 8", | ||
1063 | "Bound 12", | ||
1064 | "Bound 16", | ||
1065 | NULL | ||
1066 | }; | ||
1067 | static const char *mpeg_audio_emphasis[] = { | ||
1068 | "No Emphasis", | ||
1069 | "50/15 us", | ||
1070 | "CCITT J17", | ||
1071 | NULL | ||
1072 | }; | ||
1073 | static const char *mpeg_audio_crc[] = { | ||
1074 | "No CRC", | ||
1075 | "16-bit CRC", | ||
1076 | NULL | ||
1077 | }; | ||
1078 | static const char *mpeg_video_encoding[] = { | ||
1079 | "MPEG-1", | ||
1080 | "MPEG-2", | ||
1081 | NULL | ||
1082 | }; | ||
1083 | static const char *mpeg_video_aspect[] = { | ||
1084 | "1x1", | ||
1085 | "4x3", | ||
1086 | "16x9", | ||
1087 | "2.21x1", | ||
1088 | NULL | ||
1089 | }; | ||
1090 | static const char *mpeg_video_bitrate_mode[] = { | ||
1091 | "Variable Bitrate", | ||
1092 | "Constant Bitrate", | ||
1093 | NULL | ||
1094 | }; | ||
1095 | static const char *mpeg_stream_type[] = { | ||
1096 | "MPEG-2 Program Stream", | ||
1097 | "MPEG-2 Transport Stream", | ||
1098 | "MPEG-1 System Stream", | ||
1099 | "MPEG-2 DVD-compatible Stream", | ||
1100 | "MPEG-1 VCD-compatible Stream", | ||
1101 | "MPEG-2 SVCD-compatible Stream", | ||
1102 | NULL | ||
1103 | }; | ||
1104 | |||
1105 | switch (id) { | ||
1106 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: | ||
1107 | return mpeg_audio_sampling_freq; | ||
1108 | case V4L2_CID_MPEG_AUDIO_ENCODING: | ||
1109 | return mpeg_audio_encoding; | ||
1110 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: | ||
1111 | return mpeg_audio_l1_bitrate; | ||
1112 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: | ||
1113 | return mpeg_audio_l2_bitrate; | ||
1114 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: | ||
1115 | return mpeg_audio_l3_bitrate; | ||
1116 | case V4L2_CID_MPEG_AUDIO_MODE: | ||
1117 | return mpeg_audio_mode; | ||
1118 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: | ||
1119 | return mpeg_audio_mode_extension; | ||
1120 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: | ||
1121 | return mpeg_audio_emphasis; | ||
1122 | case V4L2_CID_MPEG_AUDIO_CRC: | ||
1123 | return mpeg_audio_crc; | ||
1124 | case V4L2_CID_MPEG_VIDEO_ENCODING: | ||
1125 | return mpeg_video_encoding; | ||
1126 | case V4L2_CID_MPEG_VIDEO_ASPECT: | ||
1127 | return mpeg_video_aspect; | ||
1128 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: | ||
1129 | return mpeg_video_bitrate_mode; | ||
1130 | case V4L2_CID_MPEG_STREAM_TYPE: | ||
1131 | return mpeg_stream_type; | ||
1132 | default: | ||
1133 | return NULL; | ||
1134 | } | ||
1135 | } | ||
1136 | |||
1137 | /* Fill in a struct v4l2_queryctrl */ | ||
1138 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) | ||
1139 | { | ||
1140 | const char *name; | ||
1141 | |||
1142 | qctrl->flags = 0; | ||
1143 | switch (qctrl->id) { | ||
1144 | /* USER controls */ | ||
1145 | case V4L2_CID_USER_CLASS: name = "User Controls"; break; | ||
1146 | case V4L2_CID_AUDIO_VOLUME: name = "Volume"; break; | ||
1147 | case V4L2_CID_AUDIO_MUTE: name = "Mute"; break; | ||
1148 | case V4L2_CID_AUDIO_BALANCE: name = "Balance"; break; | ||
1149 | case V4L2_CID_AUDIO_BASS: name = "Bass"; break; | ||
1150 | case V4L2_CID_AUDIO_TREBLE: name = "Treble"; break; | ||
1151 | case V4L2_CID_AUDIO_LOUDNESS: name = "Loudness"; break; | ||
1152 | case V4L2_CID_BRIGHTNESS: name = "Brightness"; break; | ||
1153 | case V4L2_CID_CONTRAST: name = "Contrast"; break; | ||
1154 | case V4L2_CID_SATURATION: name = "Saturation"; break; | ||
1155 | case V4L2_CID_HUE: name = "Hue"; break; | ||
1156 | |||
1157 | /* MPEG controls */ | ||
1158 | case V4L2_CID_MPEG_CLASS: name = "MPEG Encoder Controls"; break; | ||
1159 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: name = "Audio Sampling Frequency"; break; | ||
1160 | case V4L2_CID_MPEG_AUDIO_ENCODING: name = "Audio Encoding Layer"; break; | ||
1161 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: name = "Audio Layer I Bitrate"; break; | ||
1162 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: name = "Audio Layer II Bitrate"; break; | ||
1163 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: name = "Audio Layer III Bitrate"; break; | ||
1164 | case V4L2_CID_MPEG_AUDIO_MODE: name = "Audio Stereo Mode"; break; | ||
1165 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: name = "Audio Stereo Mode Extension"; break; | ||
1166 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: name = "Audio Emphasis"; break; | ||
1167 | case V4L2_CID_MPEG_AUDIO_CRC: name = "Audio CRC"; break; | ||
1168 | case V4L2_CID_MPEG_VIDEO_ENCODING: name = "Video Encoding"; break; | ||
1169 | case V4L2_CID_MPEG_VIDEO_ASPECT: name = "Video Aspect"; break; | ||
1170 | case V4L2_CID_MPEG_VIDEO_B_FRAMES: name = "Video B Frames"; break; | ||
1171 | case V4L2_CID_MPEG_VIDEO_GOP_SIZE: name = "Video GOP Size"; break; | ||
1172 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: name = "Video GOP Closure"; break; | ||
1173 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: name = "Video Pulldown"; break; | ||
1174 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: name = "Video Bitrate Mode"; break; | ||
1175 | case V4L2_CID_MPEG_VIDEO_BITRATE: name = "Video Bitrate"; break; | ||
1176 | case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: name = "Video Peak Bitrate"; break; | ||
1177 | case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: name = "Video Temporal Decimation"; break; | ||
1178 | case V4L2_CID_MPEG_STREAM_TYPE: name = "Stream Type"; break; | ||
1179 | case V4L2_CID_MPEG_STREAM_PID_PMT: name = "Stream PMT Program ID"; break; | ||
1180 | case V4L2_CID_MPEG_STREAM_PID_AUDIO: name = "Stream Audio Program ID"; break; | ||
1181 | case V4L2_CID_MPEG_STREAM_PID_VIDEO: name = "Stream Video Program ID"; break; | ||
1182 | case V4L2_CID_MPEG_STREAM_PID_PCR: name = "Stream PCR Program ID"; break; | ||
1183 | case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: name = "Stream PES Audio ID"; break; | ||
1184 | case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: name = "Stream PES Video ID"; break; | ||
1185 | |||
1186 | default: | ||
1187 | return -EINVAL; | ||
1188 | } | ||
1189 | switch (qctrl->id) { | ||
1190 | case V4L2_CID_AUDIO_MUTE: | ||
1191 | case V4L2_CID_AUDIO_LOUDNESS: | ||
1192 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: | ||
1193 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: | ||
1194 | qctrl->type = V4L2_CTRL_TYPE_BOOLEAN; | ||
1195 | min = 0; | ||
1196 | max = step = 1; | ||
1197 | break; | ||
1198 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: | ||
1199 | case V4L2_CID_MPEG_AUDIO_ENCODING: | ||
1200 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: | ||
1201 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: | ||
1202 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: | ||
1203 | case V4L2_CID_MPEG_AUDIO_MODE: | ||
1204 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: | ||
1205 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: | ||
1206 | case V4L2_CID_MPEG_AUDIO_CRC: | ||
1207 | case V4L2_CID_MPEG_VIDEO_ENCODING: | ||
1208 | case V4L2_CID_MPEG_VIDEO_ASPECT: | ||
1209 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: | ||
1210 | case V4L2_CID_MPEG_STREAM_TYPE: | ||
1211 | qctrl->type = V4L2_CTRL_TYPE_MENU; | ||
1212 | step = 1; | ||
1213 | break; | ||
1214 | case V4L2_CID_USER_CLASS: | ||
1215 | case V4L2_CID_MPEG_CLASS: | ||
1216 | qctrl->type = V4L2_CTRL_TYPE_CTRL_CLASS; | ||
1217 | qctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; | ||
1218 | min = max = step = def = 0; | ||
1219 | break; | ||
1220 | default: | ||
1221 | qctrl->type = V4L2_CTRL_TYPE_INTEGER; | ||
1222 | break; | ||
1223 | } | ||
1224 | switch (qctrl->id) { | ||
1225 | case V4L2_CID_MPEG_AUDIO_ENCODING: | ||
1226 | case V4L2_CID_MPEG_AUDIO_MODE: | ||
1227 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: | ||
1228 | case V4L2_CID_MPEG_VIDEO_B_FRAMES: | ||
1229 | case V4L2_CID_MPEG_STREAM_TYPE: | ||
1230 | qctrl->flags |= V4L2_CTRL_FLAG_UPDATE; | ||
1231 | break; | ||
1232 | case V4L2_CID_AUDIO_VOLUME: | ||
1233 | case V4L2_CID_AUDIO_BALANCE: | ||
1234 | case V4L2_CID_AUDIO_BASS: | ||
1235 | case V4L2_CID_AUDIO_TREBLE: | ||
1236 | case V4L2_CID_BRIGHTNESS: | ||
1237 | case V4L2_CID_CONTRAST: | ||
1238 | case V4L2_CID_SATURATION: | ||
1239 | case V4L2_CID_HUE: | ||
1240 | qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; | ||
1241 | break; | ||
1242 | } | ||
1243 | qctrl->minimum = min; | ||
1244 | qctrl->maximum = max; | ||
1245 | qctrl->step = step; | ||
1246 | qctrl->default_value = def; | ||
1247 | qctrl->reserved[0] = qctrl->reserved[1] = 0; | ||
1248 | snprintf(qctrl->name, sizeof(qctrl->name), name); | ||
1249 | return 0; | ||
1250 | } | ||
1251 | |||
1252 | /* Fill in a struct v4l2_queryctrl with standard values based on | ||
1253 | the control ID. */ | ||
1254 | int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl) | ||
1255 | { | ||
1256 | switch (qctrl->id) { | ||
1257 | /* USER controls */ | ||
1258 | case V4L2_CID_USER_CLASS: | ||
1259 | case V4L2_CID_MPEG_CLASS: | ||
1260 | return v4l2_ctrl_query_fill(qctrl, 0, 0, 0, 0); | ||
1261 | case V4L2_CID_AUDIO_VOLUME: | ||
1262 | return v4l2_ctrl_query_fill(qctrl, 0, 65535, 65535 / 100, 58880); | ||
1263 | case V4L2_CID_AUDIO_MUTE: | ||
1264 | case V4L2_CID_AUDIO_LOUDNESS: | ||
1265 | return v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 0); | ||
1266 | case V4L2_CID_AUDIO_BALANCE: | ||
1267 | case V4L2_CID_AUDIO_BASS: | ||
1268 | case V4L2_CID_AUDIO_TREBLE: | ||
1269 | return v4l2_ctrl_query_fill(qctrl, 0, 65535, 65535 / 100, 32768); | ||
1270 | case V4L2_CID_BRIGHTNESS: | ||
1271 | return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 128); | ||
1272 | case V4L2_CID_CONTRAST: | ||
1273 | case V4L2_CID_SATURATION: | ||
1274 | return v4l2_ctrl_query_fill(qctrl, 0, 127, 1, 64); | ||
1275 | case V4L2_CID_HUE: | ||
1276 | return v4l2_ctrl_query_fill(qctrl, -128, 127, 1, 0); | ||
1277 | |||
1278 | /* MPEG controls */ | ||
1279 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: | ||
1280 | return v4l2_ctrl_query_fill(qctrl, | ||
1281 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100, | ||
1282 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000, 1, | ||
1283 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000); | ||
1284 | case V4L2_CID_MPEG_AUDIO_ENCODING: | ||
1285 | return v4l2_ctrl_query_fill(qctrl, | ||
1286 | V4L2_MPEG_AUDIO_ENCODING_LAYER_1, | ||
1287 | V4L2_MPEG_AUDIO_ENCODING_LAYER_3, 1, | ||
1288 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2); | ||
1289 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: | ||
1290 | return v4l2_ctrl_query_fill(qctrl, | ||
1291 | V4L2_MPEG_AUDIO_L1_BITRATE_32K, | ||
1292 | V4L2_MPEG_AUDIO_L1_BITRATE_448K, 1, | ||
1293 | V4L2_MPEG_AUDIO_L1_BITRATE_256K); | ||
1294 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: | ||
1295 | return v4l2_ctrl_query_fill(qctrl, | ||
1296 | V4L2_MPEG_AUDIO_L2_BITRATE_32K, | ||
1297 | V4L2_MPEG_AUDIO_L2_BITRATE_384K, 1, | ||
1298 | V4L2_MPEG_AUDIO_L2_BITRATE_224K); | ||
1299 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: | ||
1300 | return v4l2_ctrl_query_fill(qctrl, | ||
1301 | V4L2_MPEG_AUDIO_L3_BITRATE_32K, | ||
1302 | V4L2_MPEG_AUDIO_L3_BITRATE_320K, 1, | ||
1303 | V4L2_MPEG_AUDIO_L3_BITRATE_192K); | ||
1304 | case V4L2_CID_MPEG_AUDIO_MODE: | ||
1305 | return v4l2_ctrl_query_fill(qctrl, | ||
1306 | V4L2_MPEG_AUDIO_MODE_STEREO, | ||
1307 | V4L2_MPEG_AUDIO_MODE_MONO, 1, | ||
1308 | V4L2_MPEG_AUDIO_MODE_STEREO); | ||
1309 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: | ||
1310 | return v4l2_ctrl_query_fill(qctrl, | ||
1311 | V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4, | ||
1312 | V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16, 1, | ||
1313 | V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4); | ||
1314 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: | ||
1315 | return v4l2_ctrl_query_fill(qctrl, | ||
1316 | V4L2_MPEG_AUDIO_EMPHASIS_NONE, | ||
1317 | V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17, 1, | ||
1318 | V4L2_MPEG_AUDIO_EMPHASIS_NONE); | ||
1319 | case V4L2_CID_MPEG_AUDIO_CRC: | ||
1320 | return v4l2_ctrl_query_fill(qctrl, | ||
1321 | V4L2_MPEG_AUDIO_CRC_NONE, | ||
1322 | V4L2_MPEG_AUDIO_CRC_CRC16, 1, | ||
1323 | V4L2_MPEG_AUDIO_CRC_NONE); | ||
1324 | case V4L2_CID_MPEG_VIDEO_ENCODING: | ||
1325 | return v4l2_ctrl_query_fill(qctrl, | ||
1326 | V4L2_MPEG_VIDEO_ENCODING_MPEG_1, | ||
1327 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2, 1, | ||
1328 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2); | ||
1329 | case V4L2_CID_MPEG_VIDEO_ASPECT: | ||
1330 | return v4l2_ctrl_query_fill(qctrl, | ||
1331 | V4L2_MPEG_VIDEO_ASPECT_1x1, | ||
1332 | V4L2_MPEG_VIDEO_ASPECT_221x100, 1, | ||
1333 | V4L2_MPEG_VIDEO_ASPECT_4x3); | ||
1334 | case V4L2_CID_MPEG_VIDEO_B_FRAMES: | ||
1335 | return v4l2_ctrl_query_fill(qctrl, 0, 33, 1, 2); | ||
1336 | case V4L2_CID_MPEG_VIDEO_GOP_SIZE: | ||
1337 | return v4l2_ctrl_query_fill(qctrl, 1, 34, 1, 12); | ||
1338 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: | ||
1339 | return v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 1); | ||
1340 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: | ||
1341 | return v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 0); | ||
1342 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: | ||
1343 | return v4l2_ctrl_query_fill(qctrl, | ||
1344 | V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, | ||
1345 | V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, 1, | ||
1346 | V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); | ||
1347 | case V4L2_CID_MPEG_VIDEO_BITRATE: | ||
1348 | return v4l2_ctrl_query_fill(qctrl, 0, 27000000, 1, 6000000); | ||
1349 | case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: | ||
1350 | return v4l2_ctrl_query_fill(qctrl, 0, 27000000, 1, 8000000); | ||
1351 | case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: | ||
1352 | return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 0); | ||
1353 | case V4L2_CID_MPEG_STREAM_TYPE: | ||
1354 | return v4l2_ctrl_query_fill(qctrl, | ||
1355 | V4L2_MPEG_STREAM_TYPE_MPEG2_PS, | ||
1356 | V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD, 1, | ||
1357 | V4L2_MPEG_STREAM_TYPE_MPEG2_PS); | ||
1358 | case V4L2_CID_MPEG_STREAM_PID_PMT: | ||
1359 | return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 16); | ||
1360 | case V4L2_CID_MPEG_STREAM_PID_AUDIO: | ||
1361 | return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 260); | ||
1362 | case V4L2_CID_MPEG_STREAM_PID_VIDEO: | ||
1363 | return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 256); | ||
1364 | case V4L2_CID_MPEG_STREAM_PID_PCR: | ||
1365 | return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 259); | ||
1366 | case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: | ||
1367 | return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 0); | ||
1368 | case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: | ||
1369 | return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 0); | ||
1370 | default: | ||
1371 | return -EINVAL; | ||
1372 | } | ||
1373 | } | ||
1374 | |||
1375 | /* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and | ||
1376 | the menu. The qctrl pointer may be NULL, in which case it is ignored. */ | ||
1377 | int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qctrl, | ||
1378 | const char **menu_items) | ||
1379 | { | ||
1380 | int i; | ||
1381 | |||
1382 | if (menu_items == NULL || | ||
1383 | (qctrl && (qmenu->index < qctrl->minimum || qmenu->index > qctrl->maximum))) | ||
1384 | return -EINVAL; | ||
1385 | for (i = 0; i < qmenu->index && menu_items[i]; i++) ; | ||
1386 | if (menu_items[i] == NULL || menu_items[i][0] == '\0') | ||
1387 | return -EINVAL; | ||
1388 | snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]); | ||
1389 | qmenu->reserved = 0; | ||
1390 | return 0; | ||
1391 | } | ||
1392 | |||
1393 | /* ctrl_classes points to an array of u32 pointers, the last element is | ||
1394 | a NULL pointer. Each u32 array is a 0-terminated array of control IDs. | ||
1395 | Each array must be sorted low to high and belong to the same control | ||
1396 | class. The array of u32 pointer must also be sorted, from low class IDs | ||
1397 | to high class IDs. | ||
1398 | |||
1399 | This function returns the first ID that follows after the given ID. | ||
1400 | When no more controls are available 0 is returned. */ | ||
1401 | u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id) | ||
1402 | { | ||
1403 | u32 ctrl_class; | ||
1404 | const u32 *pctrl; | ||
1405 | |||
1406 | /* if no query is desired, then just return the control ID */ | ||
1407 | if ((id & V4L2_CTRL_FLAG_NEXT_CTRL) == 0) | ||
1408 | return id; | ||
1409 | if (ctrl_classes == NULL) | ||
1410 | return 0; | ||
1411 | id &= V4L2_CTRL_ID_MASK; | ||
1412 | ctrl_class = V4L2_CTRL_ID2CLASS(id); | ||
1413 | id++; /* select next control */ | ||
1414 | /* find first class that matches (or is greater than) the class of | ||
1415 | the ID */ | ||
1416 | while (*ctrl_classes && V4L2_CTRL_ID2CLASS(**ctrl_classes) < ctrl_class) | ||
1417 | ctrl_classes++; | ||
1418 | /* no more classes */ | ||
1419 | if (*ctrl_classes == NULL) | ||
1420 | return 0; | ||
1421 | pctrl = *ctrl_classes; | ||
1422 | /* find first ctrl within the class that is >= ID */ | ||
1423 | while (*pctrl && *pctrl < id) pctrl++; | ||
1424 | if (*pctrl) | ||
1425 | return *pctrl; | ||
1426 | /* we are at the end of the controls of the current class. */ | ||
1427 | /* continue with next class if available */ | ||
1428 | ctrl_classes++; | ||
1429 | if (*ctrl_classes == NULL) | ||
1430 | return 0; | ||
1431 | return **ctrl_classes; | ||
1432 | } | ||
1433 | |||
1434 | /* ----------------------------------------------------------------- */ | ||
1435 | |||
938 | EXPORT_SYMBOL(v4l2_video_std_construct); | 1436 | EXPORT_SYMBOL(v4l2_video_std_construct); |
939 | 1437 | ||
940 | EXPORT_SYMBOL(v4l2_prio_init); | 1438 | EXPORT_SYMBOL(v4l2_prio_init); |
@@ -949,6 +1447,13 @@ EXPORT_SYMBOL(v4l2_type_names); | |||
949 | EXPORT_SYMBOL(v4l_printk_ioctl); | 1447 | EXPORT_SYMBOL(v4l_printk_ioctl); |
950 | EXPORT_SYMBOL(v4l_printk_ioctl_arg); | 1448 | EXPORT_SYMBOL(v4l_printk_ioctl_arg); |
951 | 1449 | ||
1450 | EXPORT_SYMBOL(v4l2_ctrl_next); | ||
1451 | EXPORT_SYMBOL(v4l2_ctrl_check); | ||
1452 | EXPORT_SYMBOL(v4l2_ctrl_get_menu); | ||
1453 | EXPORT_SYMBOL(v4l2_ctrl_query_menu); | ||
1454 | EXPORT_SYMBOL(v4l2_ctrl_query_fill); | ||
1455 | EXPORT_SYMBOL(v4l2_ctrl_query_fill_std); | ||
1456 | |||
952 | /* | 1457 | /* |
953 | * Local variables: | 1458 | * Local variables: |
954 | * c-basic-offset: 8 | 1459 | * c-basic-offset: 8 |