aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-ctrls.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/v4l2-ctrls.c')
-rw-r--r--drivers/media/video/v4l2-ctrls.c91
1 files changed, 86 insertions, 5 deletions
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index cccd42be718a..18015c0a8d31 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -175,6 +175,15 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
175 "16-bit CRC", 175 "16-bit CRC",
176 NULL 176 NULL
177 }; 177 };
178 static const char * const mpeg_audio_dec_playback[] = {
179 "Auto",
180 "Stereo",
181 "Left",
182 "Right",
183 "Mono",
184 "Swapped Stereo",
185 NULL
186 };
178 static const char * const mpeg_video_encoding[] = { 187 static const char * const mpeg_video_encoding[] = {
179 "MPEG-1", 188 "MPEG-1",
180 "MPEG-2", 189 "MPEG-2",
@@ -236,8 +245,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
236 }; 245 };
237 static const char * const tune_preemphasis[] = { 246 static const char * const tune_preemphasis[] = {
238 "No Preemphasis", 247 "No Preemphasis",
239 "50 useconds", 248 "50 Microseconds",
240 "75 useconds", 249 "75 Microseconds",
241 NULL, 250 NULL,
242 }; 251 };
243 static const char * const header_mode[] = { 252 static const char * const header_mode[] = {
@@ -334,7 +343,7 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
334 }; 343 };
335 static const char * const mpeg4_profile[] = { 344 static const char * const mpeg4_profile[] = {
336 "Simple", 345 "Simple",
337 "Adcanved Simple", 346 "Advanced Simple",
338 "Core", 347 "Core",
339 "Simple Scalable", 348 "Simple Scalable",
340 "Advanced Coding Efficency", 349 "Advanced Coding Efficency",
@@ -353,6 +362,16 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
353 NULL, 362 NULL,
354 }; 363 };
355 364
365 static const char * const jpeg_chroma_subsampling[] = {
366 "4:4:4",
367 "4:2:2",
368 "4:2:0",
369 "4:1:1",
370 "4:1:0",
371 "Gray",
372 NULL,
373 };
374
356 switch (id) { 375 switch (id) {
357 case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: 376 case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
358 return mpeg_audio_sampling_freq; 377 return mpeg_audio_sampling_freq;
@@ -374,6 +393,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
374 return mpeg_audio_emphasis; 393 return mpeg_audio_emphasis;
375 case V4L2_CID_MPEG_AUDIO_CRC: 394 case V4L2_CID_MPEG_AUDIO_CRC:
376 return mpeg_audio_crc; 395 return mpeg_audio_crc;
396 case V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK:
397 case V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK:
398 return mpeg_audio_dec_playback;
377 case V4L2_CID_MPEG_VIDEO_ENCODING: 399 case V4L2_CID_MPEG_VIDEO_ENCODING:
378 return mpeg_video_encoding; 400 return mpeg_video_encoding;
379 case V4L2_CID_MPEG_VIDEO_ASPECT: 401 case V4L2_CID_MPEG_VIDEO_ASPECT:
@@ -414,6 +436,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
414 return mpeg_mpeg4_level; 436 return mpeg_mpeg4_level;
415 case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: 437 case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
416 return mpeg4_profile; 438 return mpeg4_profile;
439 case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
440 return jpeg_chroma_subsampling;
441
417 default: 442 default:
418 return NULL; 443 return NULL;
419 } 444 }
@@ -492,6 +517,8 @@ const char *v4l2_ctrl_get_name(u32 id)
492 case V4L2_CID_MPEG_AUDIO_MUTE: return "Audio Mute"; 517 case V4L2_CID_MPEG_AUDIO_MUTE: return "Audio Mute";
493 case V4L2_CID_MPEG_AUDIO_AAC_BITRATE: return "Audio AAC Bitrate"; 518 case V4L2_CID_MPEG_AUDIO_AAC_BITRATE: return "Audio AAC Bitrate";
494 case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: return "Audio AC-3 Bitrate"; 519 case V4L2_CID_MPEG_AUDIO_AC3_BITRATE: return "Audio AC-3 Bitrate";
520 case V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK: return "Audio Playback";
521 case V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK: return "Audio Multilingual Playback";
495 case V4L2_CID_MPEG_VIDEO_ENCODING: return "Video Encoding"; 522 case V4L2_CID_MPEG_VIDEO_ENCODING: return "Video Encoding";
496 case V4L2_CID_MPEG_VIDEO_ASPECT: return "Video Aspect"; 523 case V4L2_CID_MPEG_VIDEO_ASPECT: return "Video Aspect";
497 case V4L2_CID_MPEG_VIDEO_B_FRAMES: return "Video B Frames"; 524 case V4L2_CID_MPEG_VIDEO_B_FRAMES: return "Video B Frames";
@@ -546,6 +573,8 @@ const char *v4l2_ctrl_get_name(u32 id)
546 case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB: return "Number of MBs in a Slice"; 573 case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB: return "Number of MBs in a Slice";
547 case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: return "Slice Partitioning Method"; 574 case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: return "Slice Partitioning Method";
548 case V4L2_CID_MPEG_VIDEO_VBV_SIZE: return "VBV Buffer Size"; 575 case V4L2_CID_MPEG_VIDEO_VBV_SIZE: return "VBV Buffer Size";
576 case V4L2_CID_MPEG_VIDEO_DEC_PTS: return "Video Decoder PTS";
577 case V4L2_CID_MPEG_VIDEO_DEC_FRAME: return "Video Decoder Frame Count";
549 578
550 /* CAMERA controls */ 579 /* CAMERA controls */
551 /* Keep the order of the 'case's the same as in videodev2.h! */ 580 /* Keep the order of the 'case's the same as in videodev2.h! */
@@ -607,6 +636,14 @@ const char *v4l2_ctrl_get_name(u32 id)
607 case V4L2_CID_FLASH_CHARGE: return "Charge"; 636 case V4L2_CID_FLASH_CHARGE: return "Charge";
608 case V4L2_CID_FLASH_READY: return "Ready to Strobe"; 637 case V4L2_CID_FLASH_READY: return "Ready to Strobe";
609 638
639 /* JPEG encoder controls */
640 /* Keep the order of the 'case's the same as in videodev2.h! */
641 case V4L2_CID_JPEG_CLASS: return "JPEG Compression Controls";
642 case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: return "Chroma Subsampling";
643 case V4L2_CID_JPEG_RESTART_INTERVAL: return "Restart Interval";
644 case V4L2_CID_JPEG_COMPRESSION_QUALITY: return "Compression Quality";
645 case V4L2_CID_JPEG_ACTIVE_MARKER: return "Active Markers";
646
610 default: 647 default:
611 return NULL; 648 return NULL;
612 } 649 }
@@ -674,6 +711,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
674 case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: 711 case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION:
675 case V4L2_CID_MPEG_AUDIO_EMPHASIS: 712 case V4L2_CID_MPEG_AUDIO_EMPHASIS:
676 case V4L2_CID_MPEG_AUDIO_CRC: 713 case V4L2_CID_MPEG_AUDIO_CRC:
714 case V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK:
715 case V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK:
677 case V4L2_CID_MPEG_VIDEO_ENCODING: 716 case V4L2_CID_MPEG_VIDEO_ENCODING:
678 case V4L2_CID_MPEG_VIDEO_ASPECT: 717 case V4L2_CID_MPEG_VIDEO_ASPECT:
679 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: 718 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
@@ -693,6 +732,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
693 case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC: 732 case V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC:
694 case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL: 733 case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
695 case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: 734 case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
735 case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
696 *type = V4L2_CTRL_TYPE_MENU; 736 *type = V4L2_CTRL_TYPE_MENU;
697 break; 737 break;
698 case V4L2_CID_RDS_TX_PS_NAME: 738 case V4L2_CID_RDS_TX_PS_NAME:
@@ -704,6 +744,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
704 case V4L2_CID_MPEG_CLASS: 744 case V4L2_CID_MPEG_CLASS:
705 case V4L2_CID_FM_TX_CLASS: 745 case V4L2_CID_FM_TX_CLASS:
706 case V4L2_CID_FLASH_CLASS: 746 case V4L2_CID_FLASH_CLASS:
747 case V4L2_CID_JPEG_CLASS:
707 *type = V4L2_CTRL_TYPE_CTRL_CLASS; 748 *type = V4L2_CTRL_TYPE_CTRL_CLASS;
708 /* You can neither read not write these */ 749 /* You can neither read not write these */
709 *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY; 750 *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
@@ -717,6 +758,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
717 *max = 0xFFFFFF; 758 *max = 0xFFFFFF;
718 break; 759 break;
719 case V4L2_CID_FLASH_FAULT: 760 case V4L2_CID_FLASH_FAULT:
761 case V4L2_CID_JPEG_ACTIVE_MARKER:
720 *type = V4L2_CTRL_TYPE_BITMASK; 762 *type = V4L2_CTRL_TYPE_BITMASK;
721 break; 763 break;
722 case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE: 764 case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
@@ -724,6 +766,11 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
724 *type = V4L2_CTRL_TYPE_INTEGER; 766 *type = V4L2_CTRL_TYPE_INTEGER;
725 *flags |= V4L2_CTRL_FLAG_READ_ONLY; 767 *flags |= V4L2_CTRL_FLAG_READ_ONLY;
726 break; 768 break;
769 case V4L2_CID_MPEG_VIDEO_DEC_FRAME:
770 case V4L2_CID_MPEG_VIDEO_DEC_PTS:
771 *type = V4L2_CTRL_TYPE_INTEGER64;
772 *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_VOLATILE;
773 break;
727 default: 774 default:
728 *type = V4L2_CTRL_TYPE_INTEGER; 775 *type = V4L2_CTRL_TYPE_INTEGER;
729 break; 776 break;
@@ -1470,7 +1517,7 @@ EXPORT_SYMBOL(v4l2_ctrl_add_ctrl);
1470int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl, 1517int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
1471 struct v4l2_ctrl_handler *add) 1518 struct v4l2_ctrl_handler *add)
1472{ 1519{
1473 struct v4l2_ctrl *ctrl; 1520 struct v4l2_ctrl_ref *ref;
1474 int ret = 0; 1521 int ret = 0;
1475 1522
1476 /* Do nothing if either handler is NULL or if they are the same */ 1523 /* Do nothing if either handler is NULL or if they are the same */
@@ -1479,7 +1526,9 @@ int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
1479 if (hdl->error) 1526 if (hdl->error)
1480 return hdl->error; 1527 return hdl->error;
1481 mutex_lock(&add->lock); 1528 mutex_lock(&add->lock);
1482 list_for_each_entry(ctrl, &add->ctrls, node) { 1529 list_for_each_entry(ref, &add->ctrl_refs, node) {
1530 struct v4l2_ctrl *ctrl = ref->ctrl;
1531
1483 /* Skip handler-private controls. */ 1532 /* Skip handler-private controls. */
1484 if (ctrl->is_private) 1533 if (ctrl->is_private)
1485 continue; 1534 continue;
@@ -2359,3 +2408,35 @@ void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl,
2359 v4l2_ctrl_unlock(ctrl); 2408 v4l2_ctrl_unlock(ctrl);
2360} 2409}
2361EXPORT_SYMBOL(v4l2_ctrl_del_event); 2410EXPORT_SYMBOL(v4l2_ctrl_del_event);
2411
2412int v4l2_ctrl_log_status(struct file *file, void *fh)
2413{
2414 struct video_device *vfd = video_devdata(file);
2415 struct v4l2_fh *vfh = file->private_data;
2416
2417 if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) && vfd->v4l2_dev)
2418 v4l2_ctrl_handler_log_status(vfh->ctrl_handler,
2419 vfd->v4l2_dev->name);
2420 return 0;
2421}
2422EXPORT_SYMBOL(v4l2_ctrl_log_status);
2423
2424int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh,
2425 struct v4l2_event_subscription *sub)
2426{
2427 if (sub->type == V4L2_EVENT_CTRL)
2428 return v4l2_event_subscribe(fh, sub, 0);
2429 return -EINVAL;
2430}
2431EXPORT_SYMBOL(v4l2_ctrl_subscribe_event);
2432
2433unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait)
2434{
2435 struct v4l2_fh *fh = file->private_data;
2436
2437 if (v4l2_event_pending(fh))
2438 return POLLPRI;
2439 poll_wait(file, &fh->wait, wait);
2440 return 0;
2441}
2442EXPORT_SYMBOL(v4l2_ctrl_poll);