diff options
Diffstat (limited to 'drivers/media/video/saa7134/saa6752hs.c')
-rw-r--r-- | drivers/media/video/saa7134/saa6752hs.c | 105 |
1 files changed, 103 insertions, 2 deletions
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 002e70a33a4f..707be175509d 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/crc32.h> | 14 | #include <linux/crc32.h> |
15 | 15 | ||
16 | |||
17 | #define MPEG_VIDEO_TARGET_BITRATE_MAX 27000 | 16 | #define MPEG_VIDEO_TARGET_BITRATE_MAX 27000 |
18 | #define MPEG_VIDEO_MAX_BITRATE_MAX 27000 | 17 | #define MPEG_VIDEO_MAX_BITRATE_MAX 27000 |
19 | #define MPEG_TOTAL_TARGET_BITRATE_MAX 27000 | 18 | #define MPEG_TOTAL_TARGET_BITRATE_MAX 27000 |
@@ -21,6 +20,7 @@ | |||
21 | 20 | ||
22 | /* Addresses to scan */ | 21 | /* Addresses to scan */ |
23 | static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; | 22 | static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; |
23 | |||
24 | I2C_CLIENT_INSMOD; | 24 | I2C_CLIENT_INSMOD; |
25 | 25 | ||
26 | MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); | 26 | MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); |
@@ -448,6 +448,104 @@ static int handle_ctrl(struct saa6752hs_mpeg_params *params, | |||
448 | return 0; | 448 | return 0; |
449 | } | 449 | } |
450 | 450 | ||
451 | static int saa6752hs_qctrl(struct saa6752hs_mpeg_params *params, | ||
452 | struct v4l2_queryctrl *qctrl) | ||
453 | { | ||
454 | int err; | ||
455 | |||
456 | switch (qctrl->id) { | ||
457 | case V4L2_CID_MPEG_AUDIO_ENCODING: | ||
458 | return v4l2_ctrl_query_fill(qctrl, | ||
459 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2, | ||
460 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2, 1, | ||
461 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2); | ||
462 | |||
463 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: | ||
464 | return v4l2_ctrl_query_fill(qctrl, | ||
465 | V4L2_MPEG_AUDIO_L2_BITRATE_256K, | ||
466 | V4L2_MPEG_AUDIO_L2_BITRATE_384K, 1, | ||
467 | V4L2_MPEG_AUDIO_L2_BITRATE_256K); | ||
468 | |||
469 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: | ||
470 | return v4l2_ctrl_query_fill(qctrl, | ||
471 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000, | ||
472 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000, 1, | ||
473 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000); | ||
474 | |||
475 | case V4L2_CID_MPEG_VIDEO_ENCODING: | ||
476 | return v4l2_ctrl_query_fill(qctrl, | ||
477 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2, | ||
478 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2, 1, | ||
479 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2); | ||
480 | |||
481 | case V4L2_CID_MPEG_VIDEO_ASPECT: | ||
482 | return v4l2_ctrl_query_fill(qctrl, | ||
483 | V4L2_MPEG_VIDEO_ASPECT_4x3, | ||
484 | V4L2_MPEG_VIDEO_ASPECT_16x9, 1, | ||
485 | V4L2_MPEG_VIDEO_ASPECT_4x3); | ||
486 | |||
487 | case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: | ||
488 | err = v4l2_ctrl_query_fill_std(qctrl); | ||
489 | if (err == 0 && | ||
490 | params->vi_bitrate_mode == | ||
491 | V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) | ||
492 | qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; | ||
493 | return err; | ||
494 | |||
495 | case V4L2_CID_MPEG_STREAM_TYPE: | ||
496 | return v4l2_ctrl_query_fill(qctrl, | ||
497 | V4L2_MPEG_STREAM_TYPE_MPEG2_TS, | ||
498 | V4L2_MPEG_STREAM_TYPE_MPEG2_TS, 1, | ||
499 | V4L2_MPEG_STREAM_TYPE_MPEG2_TS); | ||
500 | |||
501 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: | ||
502 | case V4L2_CID_MPEG_VIDEO_BITRATE: | ||
503 | case V4L2_CID_MPEG_STREAM_PID_PMT: | ||
504 | case V4L2_CID_MPEG_STREAM_PID_AUDIO: | ||
505 | case V4L2_CID_MPEG_STREAM_PID_VIDEO: | ||
506 | case V4L2_CID_MPEG_STREAM_PID_PCR: | ||
507 | return v4l2_ctrl_query_fill_std(qctrl); | ||
508 | |||
509 | default: | ||
510 | break; | ||
511 | } | ||
512 | return -EINVAL; | ||
513 | } | ||
514 | |||
515 | static int saa6752hs_qmenu(struct saa6752hs_mpeg_params *params, | ||
516 | struct v4l2_querymenu *qmenu) | ||
517 | { | ||
518 | static const char *mpeg_audio_l2_bitrate[] = { | ||
519 | "", | ||
520 | "", | ||
521 | "", | ||
522 | "", | ||
523 | "", | ||
524 | "", | ||
525 | "", | ||
526 | "", | ||
527 | "", | ||
528 | "", | ||
529 | "", | ||
530 | "256 kbps", | ||
531 | "", | ||
532 | "384 kbps", | ||
533 | NULL | ||
534 | }; | ||
535 | struct v4l2_queryctrl qctrl; | ||
536 | int err; | ||
537 | |||
538 | qctrl.id = qmenu->id; | ||
539 | err = saa6752hs_qctrl(params, &qctrl); | ||
540 | if (err) | ||
541 | return err; | ||
542 | if (qmenu->id == V4L2_CID_MPEG_AUDIO_L2_BITRATE) | ||
543 | return v4l2_ctrl_query_menu(qmenu, &qctrl, | ||
544 | mpeg_audio_l2_bitrate); | ||
545 | return v4l2_ctrl_query_menu(qmenu, &qctrl, | ||
546 | v4l2_ctrl_get_menu(qmenu->id)); | ||
547 | } | ||
548 | |||
451 | static int saa6752hs_init(struct i2c_client* client) | 549 | static int saa6752hs_init(struct i2c_client* client) |
452 | { | 550 | { |
453 | unsigned char buf[9], buf2[4]; | 551 | unsigned char buf[9], buf2[4]; |
@@ -609,7 +707,6 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind) | |||
609 | i2c_attach_client(&h->client); | 707 | i2c_attach_client(&h->client); |
610 | 708 | ||
611 | v4l_info(&h->client,"saa6752hs: chip found @ 0x%x\n", addr<<1); | 709 | v4l_info(&h->client,"saa6752hs: chip found @ 0x%x\n", addr<<1); |
612 | |||
613 | return 0; | 710 | return 0; |
614 | } | 711 | } |
615 | 712 | ||
@@ -662,6 +759,10 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
662 | } | 759 | } |
663 | h->params = params; | 760 | h->params = params; |
664 | break; | 761 | break; |
762 | case VIDIOC_QUERYCTRL: | ||
763 | return saa6752hs_qctrl(&h->params, arg); | ||
764 | case VIDIOC_QUERYMENU: | ||
765 | return saa6752hs_qmenu(&h->params, arg); | ||
665 | case VIDIOC_G_FMT: | 766 | case VIDIOC_G_FMT: |
666 | { | 767 | { |
667 | struct v4l2_format *f = arg; | 768 | struct v4l2_format *f = arg; |