diff options
Diffstat (limited to 'drivers/media/video/v4l2-common.c')
-rw-r--r-- | drivers/media/video/v4l2-common.c | 183 |
1 files changed, 127 insertions, 56 deletions
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 88ca13104417..20c3be8617ea 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -187,9 +187,11 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
187 | NULL | 187 | NULL |
188 | }; | 188 | }; |
189 | static const char *mpeg_audio_encoding[] = { | 189 | static const char *mpeg_audio_encoding[] = { |
190 | "Layer I", | 190 | "MPEG-1/2 Layer I", |
191 | "Layer II", | 191 | "MPEG-1/2 Layer II", |
192 | "Layer III", | 192 | "MPEG-1/2 Layer III", |
193 | "MPEG-2/4 AAC", | ||
194 | "AC-3", | ||
193 | NULL | 195 | NULL |
194 | }; | 196 | }; |
195 | static const char *mpeg_audio_l1_bitrate[] = { | 197 | static const char *mpeg_audio_l1_bitrate[] = { |
@@ -243,6 +245,28 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
243 | "320 kbps", | 245 | "320 kbps", |
244 | NULL | 246 | NULL |
245 | }; | 247 | }; |
248 | static const char *mpeg_audio_ac3_bitrate[] = { | ||
249 | "32 kbps", | ||
250 | "40 kbps", | ||
251 | "48 kbps", | ||
252 | "56 kbps", | ||
253 | "64 kbps", | ||
254 | "80 kbps", | ||
255 | "96 kbps", | ||
256 | "112 kbps", | ||
257 | "128 kbps", | ||
258 | "160 kbps", | ||
259 | "192 kbps", | ||
260 | "224 kbps", | ||
261 | "256 kbps", | ||
262 | "320 kbps", | ||
263 | "384 kbps", | ||
264 | "448 kbps", | ||
265 | "512 kbps", | ||
266 | "576 kbps", | ||
267 | "640 kbps", | ||
268 | NULL | ||
269 | }; | ||
246 | static const char *mpeg_audio_mode[] = { | 270 | static const char *mpeg_audio_mode[] = { |
247 | "Stereo", | 271 | "Stereo", |
248 | "Joint Stereo", | 272 | "Joint Stereo", |
@@ -271,6 +295,7 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
271 | static const char *mpeg_video_encoding[] = { | 295 | static const char *mpeg_video_encoding[] = { |
272 | "MPEG-1", | 296 | "MPEG-1", |
273 | "MPEG-2", | 297 | "MPEG-2", |
298 | "MPEG-4 AVC", | ||
274 | NULL | 299 | NULL |
275 | }; | 300 | }; |
276 | static const char *mpeg_video_aspect[] = { | 301 | static const char *mpeg_video_aspect[] = { |
@@ -311,6 +336,8 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
311 | return mpeg_audio_l2_bitrate; | 336 | return mpeg_audio_l2_bitrate; |
312 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: | 337 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: |
313 | return mpeg_audio_l3_bitrate; | 338 | return mpeg_audio_l3_bitrate; |
339 | case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: | ||
340 | return mpeg_audio_ac3_bitrate; | ||
314 | case V4L2_CID_MPEG_AUDIO_MODE: | 341 | case V4L2_CID_MPEG_AUDIO_MODE: |
315 | return mpeg_audio_mode; | 342 | return mpeg_audio_mode; |
316 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: | 343 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: |
@@ -335,62 +362,73 @@ const char **v4l2_ctrl_get_menu(u32 id) | |||
335 | } | 362 | } |
336 | EXPORT_SYMBOL(v4l2_ctrl_get_menu); | 363 | EXPORT_SYMBOL(v4l2_ctrl_get_menu); |
337 | 364 | ||
338 | /* Fill in a struct v4l2_queryctrl */ | 365 | /* Return the control name. */ |
339 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) | 366 | const char *v4l2_ctrl_get_name(u32 id) |
340 | { | 367 | { |
341 | const char *name; | 368 | switch (id) { |
342 | |||
343 | qctrl->flags = 0; | ||
344 | switch (qctrl->id) { | ||
345 | /* USER controls */ | 369 | /* USER controls */ |
346 | case V4L2_CID_USER_CLASS: name = "User Controls"; break; | 370 | case V4L2_CID_USER_CLASS: return "User Controls"; |
347 | case V4L2_CID_AUDIO_VOLUME: name = "Volume"; break; | 371 | case V4L2_CID_AUDIO_VOLUME: return "Volume"; |
348 | case V4L2_CID_AUDIO_MUTE: name = "Mute"; break; | 372 | case V4L2_CID_AUDIO_MUTE: return "Mute"; |
349 | case V4L2_CID_AUDIO_BALANCE: name = "Balance"; break; | 373 | case V4L2_CID_AUDIO_BALANCE: return "Balance"; |
350 | case V4L2_CID_AUDIO_BASS: name = "Bass"; break; | 374 | case V4L2_CID_AUDIO_BASS: return "Bass"; |
351 | case V4L2_CID_AUDIO_TREBLE: name = "Treble"; break; | 375 | case V4L2_CID_AUDIO_TREBLE: return "Treble"; |
352 | case V4L2_CID_AUDIO_LOUDNESS: name = "Loudness"; break; | 376 | case V4L2_CID_AUDIO_LOUDNESS: return "Loudness"; |
353 | case V4L2_CID_BRIGHTNESS: name = "Brightness"; break; | 377 | case V4L2_CID_BRIGHTNESS: return "Brightness"; |
354 | case V4L2_CID_CONTRAST: name = "Contrast"; break; | 378 | case V4L2_CID_CONTRAST: return "Contrast"; |
355 | case V4L2_CID_SATURATION: name = "Saturation"; break; | 379 | case V4L2_CID_SATURATION: return "Saturation"; |
356 | case V4L2_CID_HUE: name = "Hue"; break; | 380 | case V4L2_CID_HUE: return "Hue"; |
357 | 381 | ||
358 | /* MPEG controls */ | 382 | /* MPEG controls */ |
359 | case V4L2_CID_MPEG_CLASS: name = "MPEG Encoder Controls"; break; | 383 | case V4L2_CID_MPEG_CLASS: return "MPEG Encoder Controls"; |
360 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: name = "Audio Sampling Frequency"; break; | 384 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: return "Audio Sampling Frequency"; |
361 | case V4L2_CID_MPEG_AUDIO_ENCODING: name = "Audio Encoding Layer"; break; | 385 | case V4L2_CID_MPEG_AUDIO_ENCODING: return "Audio Encoding"; |
362 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: name = "Audio Layer I Bitrate"; break; | 386 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: return "Audio Layer I Bitrate"; |
363 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: name = "Audio Layer II Bitrate"; break; | 387 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: return "Audio Layer II Bitrate"; |
364 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: name = "Audio Layer III Bitrate"; break; | 388 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: return "Audio Layer III Bitrate"; |
365 | case V4L2_CID_MPEG_AUDIO_MODE: name = "Audio Stereo Mode"; break; | 389 | case V4L2_CID_MPEG_AUDIO_AAC_BITRATE: return "Audio AAC Bitrate"; |
366 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: name = "Audio Stereo Mode Extension"; break; | 390 | case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: return "Audio AC-3 Bitrate"; |
367 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: name = "Audio Emphasis"; break; | 391 | case V4L2_CID_MPEG_AUDIO_MODE: return "Audio Stereo Mode"; |
368 | case V4L2_CID_MPEG_AUDIO_CRC: name = "Audio CRC"; break; | 392 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: return "Audio Stereo Mode Extension"; |
369 | case V4L2_CID_MPEG_AUDIO_MUTE: name = "Audio Mute"; break; | 393 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: return "Audio Emphasis"; |
370 | case V4L2_CID_MPEG_VIDEO_ENCODING: name = "Video Encoding"; break; | 394 | case V4L2_CID_MPEG_AUDIO_CRC: return "Audio CRC"; |
371 | case V4L2_CID_MPEG_VIDEO_ASPECT: name = "Video Aspect"; break; | 395 | case V4L2_CID_MPEG_AUDIO_MUTE: return "Audio Mute"; |
372 | case V4L2_CID_MPEG_VIDEO_B_FRAMES: name = "Video B Frames"; break; | 396 | case V4L2_CID_MPEG_VIDEO_ENCODING: return "Video Encoding"; |
373 | case V4L2_CID_MPEG_VIDEO_GOP_SIZE: name = "Video GOP Size"; break; | 397 | case V4L2_CID_MPEG_VIDEO_ASPECT: return "Video Aspect"; |
374 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: name = "Video GOP Closure"; break; | 398 | case V4L2_CID_MPEG_VIDEO_B_FRAMES: return "Video B Frames"; |
375 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: name = "Video Pulldown"; break; | 399 | case V4L2_CID_MPEG_VIDEO_GOP_SIZE: return "Video GOP Size"; |
376 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: name = "Video Bitrate Mode"; break; | 400 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: return "Video GOP Closure"; |
377 | case V4L2_CID_MPEG_VIDEO_BITRATE: name = "Video Bitrate"; break; | 401 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: return "Video Pulldown"; |
378 | case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: name = "Video Peak Bitrate"; break; | 402 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: return "Video Bitrate Mode"; |
379 | case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: name = "Video Temporal Decimation"; break; | 403 | case V4L2_CID_MPEG_VIDEO_BITRATE: return "Video Bitrate"; |
380 | case V4L2_CID_MPEG_VIDEO_MUTE: name = "Video Mute"; break; | 404 | case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: return "Video Peak Bitrate"; |
381 | case V4L2_CID_MPEG_VIDEO_MUTE_YUV: name = "Video Mute YUV"; break; | 405 | case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: return "Video Temporal Decimation"; |
382 | case V4L2_CID_MPEG_STREAM_TYPE: name = "Stream Type"; break; | 406 | case V4L2_CID_MPEG_VIDEO_MUTE: return "Video Mute"; |
383 | case V4L2_CID_MPEG_STREAM_PID_PMT: name = "Stream PMT Program ID"; break; | 407 | case V4L2_CID_MPEG_VIDEO_MUTE_YUV: return "Video Mute YUV"; |
384 | case V4L2_CID_MPEG_STREAM_PID_AUDIO: name = "Stream Audio Program ID"; break; | 408 | case V4L2_CID_MPEG_STREAM_TYPE: return "Stream Type"; |
385 | case V4L2_CID_MPEG_STREAM_PID_VIDEO: name = "Stream Video Program ID"; break; | 409 | case V4L2_CID_MPEG_STREAM_PID_PMT: return "Stream PMT Program ID"; |
386 | case V4L2_CID_MPEG_STREAM_PID_PCR: name = "Stream PCR Program ID"; break; | 410 | case V4L2_CID_MPEG_STREAM_PID_AUDIO: return "Stream Audio Program ID"; |
387 | case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: name = "Stream PES Audio ID"; break; | 411 | case V4L2_CID_MPEG_STREAM_PID_VIDEO: return "Stream Video Program ID"; |
388 | case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: name = "Stream PES Video ID"; break; | 412 | case V4L2_CID_MPEG_STREAM_PID_PCR: return "Stream PCR Program ID"; |
389 | case V4L2_CID_MPEG_STREAM_VBI_FMT: name = "Stream VBI Format"; break; | 413 | case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: return "Stream PES Audio ID"; |
414 | case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: return "Stream PES Video ID"; | ||
415 | case V4L2_CID_MPEG_STREAM_VBI_FMT: return "Stream VBI Format"; | ||
390 | 416 | ||
391 | default: | 417 | default: |
392 | return -EINVAL; | 418 | return NULL; |
393 | } | 419 | } |
420 | } | ||
421 | EXPORT_SYMBOL(v4l2_ctrl_get_name); | ||
422 | |||
423 | /* Fill in a struct v4l2_queryctrl */ | ||
424 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) | ||
425 | { | ||
426 | const char *name = v4l2_ctrl_get_name(qctrl->id); | ||
427 | |||
428 | qctrl->flags = 0; | ||
429 | if (name == NULL) | ||
430 | return -EINVAL; | ||
431 | |||
394 | switch (qctrl->id) { | 432 | switch (qctrl->id) { |
395 | case V4L2_CID_AUDIO_MUTE: | 433 | case V4L2_CID_AUDIO_MUTE: |
396 | case V4L2_CID_AUDIO_LOUDNESS: | 434 | case V4L2_CID_AUDIO_LOUDNESS: |
@@ -407,6 +445,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste | |||
407 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: | 445 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: |
408 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: | 446 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: |
409 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: | 447 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: |
448 | case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: | ||
410 | case V4L2_CID_MPEG_AUDIO_MODE: | 449 | case V4L2_CID_MPEG_AUDIO_MODE: |
411 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: | 450 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: |
412 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: | 451 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: |
@@ -493,7 +532,7 @@ int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl) | |||
493 | case V4L2_CID_MPEG_AUDIO_ENCODING: | 532 | case V4L2_CID_MPEG_AUDIO_ENCODING: |
494 | return v4l2_ctrl_query_fill(qctrl, | 533 | return v4l2_ctrl_query_fill(qctrl, |
495 | V4L2_MPEG_AUDIO_ENCODING_LAYER_1, | 534 | V4L2_MPEG_AUDIO_ENCODING_LAYER_1, |
496 | V4L2_MPEG_AUDIO_ENCODING_LAYER_3, 1, | 535 | V4L2_MPEG_AUDIO_ENCODING_AC3, 1, |
497 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2); | 536 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2); |
498 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: | 537 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: |
499 | return v4l2_ctrl_query_fill(qctrl, | 538 | return v4l2_ctrl_query_fill(qctrl, |
@@ -510,6 +549,13 @@ int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl) | |||
510 | V4L2_MPEG_AUDIO_L3_BITRATE_32K, | 549 | V4L2_MPEG_AUDIO_L3_BITRATE_32K, |
511 | V4L2_MPEG_AUDIO_L3_BITRATE_320K, 1, | 550 | V4L2_MPEG_AUDIO_L3_BITRATE_320K, 1, |
512 | V4L2_MPEG_AUDIO_L3_BITRATE_192K); | 551 | V4L2_MPEG_AUDIO_L3_BITRATE_192K); |
552 | case V4L2_CID_MPEG_AUDIO_AAC_BITRATE: | ||
553 | return v4l2_ctrl_query_fill(qctrl, 0, 6400, 1, 3200000); | ||
554 | case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: | ||
555 | return v4l2_ctrl_query_fill(qctrl, | ||
556 | V4L2_MPEG_AUDIO_AC3_BITRATE_32K, | ||
557 | V4L2_MPEG_AUDIO_AC3_BITRATE_640K, 1, | ||
558 | V4L2_MPEG_AUDIO_AC3_BITRATE_384K); | ||
513 | case V4L2_CID_MPEG_AUDIO_MODE: | 559 | case V4L2_CID_MPEG_AUDIO_MODE: |
514 | return v4l2_ctrl_query_fill(qctrl, | 560 | return v4l2_ctrl_query_fill(qctrl, |
515 | V4L2_MPEG_AUDIO_MODE_STEREO, | 561 | V4L2_MPEG_AUDIO_MODE_STEREO, |
@@ -535,7 +581,7 @@ int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl) | |||
535 | case V4L2_CID_MPEG_VIDEO_ENCODING: | 581 | case V4L2_CID_MPEG_VIDEO_ENCODING: |
536 | return v4l2_ctrl_query_fill(qctrl, | 582 | return v4l2_ctrl_query_fill(qctrl, |
537 | V4L2_MPEG_VIDEO_ENCODING_MPEG_1, | 583 | V4L2_MPEG_VIDEO_ENCODING_MPEG_1, |
538 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2, 1, | 584 | V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC, 1, |
539 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2); | 585 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2); |
540 | case V4L2_CID_MPEG_VIDEO_ASPECT: | 586 | case V4L2_CID_MPEG_VIDEO_ASPECT: |
541 | return v4l2_ctrl_query_fill(qctrl, | 587 | return v4l2_ctrl_query_fill(qctrl, |
@@ -594,12 +640,17 @@ int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl) | |||
594 | EXPORT_SYMBOL(v4l2_ctrl_query_fill_std); | 640 | EXPORT_SYMBOL(v4l2_ctrl_query_fill_std); |
595 | 641 | ||
596 | /* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and | 642 | /* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and |
597 | the menu. The qctrl pointer may be NULL, in which case it is ignored. */ | 643 | the menu. The qctrl pointer may be NULL, in which case it is ignored. |
644 | If menu_items is NULL, then the menu items are retrieved using | ||
645 | v4l2_ctrl_get_menu. */ | ||
598 | int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qctrl, | 646 | int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qctrl, |
599 | const char **menu_items) | 647 | const char **menu_items) |
600 | { | 648 | { |
601 | int i; | 649 | int i; |
602 | 650 | ||
651 | qmenu->reserved = 0; | ||
652 | if (menu_items == NULL) | ||
653 | menu_items = v4l2_ctrl_get_menu(qmenu->id); | ||
603 | if (menu_items == NULL || | 654 | if (menu_items == NULL || |
604 | (qctrl && (qmenu->index < qctrl->minimum || qmenu->index > qctrl->maximum))) | 655 | (qctrl && (qmenu->index < qctrl->minimum || qmenu->index > qctrl->maximum))) |
605 | return -EINVAL; | 656 | return -EINVAL; |
@@ -607,11 +658,31 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qc | |||
607 | if (menu_items[i] == NULL || menu_items[i][0] == '\0') | 658 | if (menu_items[i] == NULL || menu_items[i][0] == '\0') |
608 | return -EINVAL; | 659 | return -EINVAL; |
609 | snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]); | 660 | snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]); |
610 | qmenu->reserved = 0; | ||
611 | return 0; | 661 | return 0; |
612 | } | 662 | } |
613 | EXPORT_SYMBOL(v4l2_ctrl_query_menu); | 663 | EXPORT_SYMBOL(v4l2_ctrl_query_menu); |
614 | 664 | ||
665 | /* Fill in a struct v4l2_querymenu based on the specified array of valid | ||
666 | menu items (terminated by V4L2_CTRL_MENU_IDS_END). | ||
667 | Use this if there are 'holes' in the list of valid menu items. */ | ||
668 | int v4l2_ctrl_query_menu_valid_items(struct v4l2_querymenu *qmenu, const u32 *ids) | ||
669 | { | ||
670 | const char **menu_items = v4l2_ctrl_get_menu(qmenu->id); | ||
671 | |||
672 | qmenu->reserved = 0; | ||
673 | if (menu_items == NULL || ids == NULL) | ||
674 | return -EINVAL; | ||
675 | while (*ids != V4L2_CTRL_MENU_IDS_END) { | ||
676 | if (*ids++ == qmenu->index) { | ||
677 | snprintf(qmenu->name, sizeof(qmenu->name), | ||
678 | menu_items[qmenu->index]); | ||
679 | return 0; | ||
680 | } | ||
681 | } | ||
682 | return -EINVAL; | ||
683 | } | ||
684 | EXPORT_SYMBOL(v4l2_ctrl_query_menu_valid_items); | ||
685 | |||
615 | /* ctrl_classes points to an array of u32 pointers, the last element is | 686 | /* ctrl_classes points to an array of u32 pointers, the last element is |
616 | a NULL pointer. Each u32 array is a 0-terminated array of control IDs. | 687 | a NULL pointer. Each u32 array is a 0-terminated array of control IDs. |
617 | Each array must be sorted low to high and belong to the same control | 688 | Each array must be sorted low to high and belong to the same control |