aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/msp3400-driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/msp3400-driver.c')
-rw-r--r--drivers/media/video/msp3400-driver.c142
1 files changed, 14 insertions, 128 deletions
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 4d7a91852117..9e8e06cfe5c6 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -366,29 +366,6 @@ int msp_sleep(struct msp_state *state, int timeout)
366} 366}
367 367
368/* ------------------------------------------------------------------------ */ 368/* ------------------------------------------------------------------------ */
369#ifdef CONFIG_VIDEO_ALLOW_V4L1
370static int msp_mode_v4l2_to_v4l1(int rxsubchans, int audmode)
371{
372 if (rxsubchans == V4L2_TUNER_SUB_MONO)
373 return VIDEO_SOUND_MONO;
374 if (rxsubchans == V4L2_TUNER_SUB_STEREO)
375 return VIDEO_SOUND_STEREO;
376 if (audmode == V4L2_TUNER_MODE_LANG2)
377 return VIDEO_SOUND_LANG2;
378 return VIDEO_SOUND_LANG1;
379}
380
381static int msp_mode_v4l1_to_v4l2(int mode)
382{
383 if (mode & VIDEO_SOUND_STEREO)
384 return V4L2_TUNER_MODE_STEREO;
385 if (mode & VIDEO_SOUND_LANG2)
386 return V4L2_TUNER_MODE_LANG2;
387 if (mode & VIDEO_SOUND_LANG1)
388 return V4L2_TUNER_MODE_LANG1;
389 return V4L2_TUNER_MODE_MONO;
390}
391#endif
392 369
393static int msp_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) 370static int msp_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
394{ 371{
@@ -482,96 +459,6 @@ static int msp_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
482 return 0; 459 return 0;
483} 460}
484 461
485#ifdef CONFIG_VIDEO_ALLOW_V4L1
486static long msp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
487{
488 struct msp_state *state = to_state(sd);
489 struct i2c_client *client = v4l2_get_subdevdata(sd);
490
491 switch (cmd) {
492 /* --- v4l ioctls --- */
493 /* take care: bttv does userspace copying, we'll get a
494 kernel pointer here... */
495 case VIDIOCGAUDIO:
496 {
497 struct video_audio *va = arg;
498
499 va->flags |= VIDEO_AUDIO_VOLUME | VIDEO_AUDIO_MUTABLE;
500 if (state->has_sound_processing)
501 va->flags |= VIDEO_AUDIO_BALANCE |
502 VIDEO_AUDIO_BASS |
503 VIDEO_AUDIO_TREBLE;
504 if (state->muted)
505 va->flags |= VIDEO_AUDIO_MUTE;
506 va->volume = state->volume;
507 va->balance = state->volume ? state->balance : 32768;
508 va->bass = state->bass;
509 va->treble = state->treble;
510
511 if (state->radio)
512 break;
513 if (state->opmode == OPMODE_AUTOSELECT)
514 msp_detect_stereo(client);
515 va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans, state->audmode);
516 break;
517 }
518
519 case VIDIOCSAUDIO:
520 {
521 struct video_audio *va = arg;
522
523 state->muted = (va->flags & VIDEO_AUDIO_MUTE);
524 state->volume = va->volume;
525 state->balance = va->balance;
526 state->bass = va->bass;
527 state->treble = va->treble;
528 msp_set_audio(client);
529
530 if (va->mode != 0 && state->radio == 0 &&
531 state->audmode != msp_mode_v4l1_to_v4l2(va->mode)) {
532 state->audmode = msp_mode_v4l1_to_v4l2(va->mode);
533 msp_set_audmode(client);
534 }
535 break;
536 }
537
538 case VIDIOCSCHAN:
539 {
540 struct video_channel *vc = arg;
541 int update = 0;
542 v4l2_std_id std;
543
544 if (state->radio)
545 update = 1;
546 state->radio = 0;
547 if (vc->norm == VIDEO_MODE_PAL)
548 std = V4L2_STD_PAL;
549 else if (vc->norm == VIDEO_MODE_SECAM)
550 std = V4L2_STD_SECAM;
551 else
552 std = V4L2_STD_NTSC;
553 if (std != state->v4l2_std) {
554 state->v4l2_std = std;
555 update = 1;
556 }
557 if (update)
558 msp_wake_thread(client);
559 break;
560 }
561
562 case VIDIOCSFREQ:
563 {
564 /* new channel -- kick audio carrier scan */
565 msp_wake_thread(client);
566 break;
567 }
568 default:
569 return -ENOIOCTLCMD;
570 }
571 return 0;
572}
573#endif
574
575/* --- v4l2 ioctls --- */ 462/* --- v4l2 ioctls --- */
576static int msp_s_radio(struct v4l2_subdev *sd) 463static int msp_s_radio(struct v4l2_subdev *sd)
577{ 464{
@@ -713,22 +600,24 @@ static int msp_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
713 struct msp_state *state = to_state(sd); 600 struct msp_state *state = to_state(sd);
714 601
715 switch (qc->id) { 602 switch (qc->id) {
716 case V4L2_CID_AUDIO_VOLUME: 603 case V4L2_CID_AUDIO_VOLUME:
717 case V4L2_CID_AUDIO_MUTE: 604 return v4l2_ctrl_query_fill(qc, 0, 65535, 65535 / 100, 58880);
718 return v4l2_ctrl_query_fill_std(qc); 605 case V4L2_CID_AUDIO_MUTE:
719 default: 606 return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0);
720 break; 607 default:
608 break;
721 } 609 }
722 if (!state->has_sound_processing) 610 if (!state->has_sound_processing)
723 return -EINVAL; 611 return -EINVAL;
724 switch (qc->id) { 612 switch (qc->id) {
725 case V4L2_CID_AUDIO_LOUDNESS: 613 case V4L2_CID_AUDIO_LOUDNESS:
726 case V4L2_CID_AUDIO_BALANCE: 614 return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0);
727 case V4L2_CID_AUDIO_BASS: 615 case V4L2_CID_AUDIO_BALANCE:
728 case V4L2_CID_AUDIO_TREBLE: 616 case V4L2_CID_AUDIO_BASS:
729 return v4l2_ctrl_query_fill_std(qc); 617 case V4L2_CID_AUDIO_TREBLE:
730 default: 618 return v4l2_ctrl_query_fill(qc, 0, 65535, 65535 / 100, 32768);
731 return -EINVAL; 619 default:
620 return -EINVAL;
732 } 621 }
733 return 0; 622 return 0;
734} 623}
@@ -820,9 +709,6 @@ static const struct v4l2_subdev_core_ops msp_core_ops = {
820 .g_ctrl = msp_g_ctrl, 709 .g_ctrl = msp_g_ctrl,
821 .s_ctrl = msp_s_ctrl, 710 .s_ctrl = msp_s_ctrl,
822 .queryctrl = msp_queryctrl, 711 .queryctrl = msp_queryctrl,
823#ifdef CONFIG_VIDEO_ALLOW_V4L1
824 .ioctl = msp_ioctl,
825#endif
826}; 712};
827 713
828static const struct v4l2_subdev_tuner_ops msp_tuner_ops = { 714static const struct v4l2_subdev_tuner_ops msp_tuner_ops = {