diff options
Diffstat (limited to 'drivers/media/video/msp3400-driver.c')
-rw-r--r-- | drivers/media/video/msp3400-driver.c | 76 |
1 files changed, 18 insertions, 58 deletions
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c index 69ed369c2f48..11ea9765769c 100644 --- a/drivers/media/video/msp3400-driver.c +++ b/drivers/media/video/msp3400-driver.c | |||
@@ -411,9 +411,9 @@ static int msp_mode_v4l2_to_v4l1(int rxsubchans) | |||
411 | if (rxsubchans & V4L2_TUNER_SUB_STEREO) | 411 | if (rxsubchans & V4L2_TUNER_SUB_STEREO) |
412 | mode |= VIDEO_SOUND_STEREO; | 412 | mode |= VIDEO_SOUND_STEREO; |
413 | if (rxsubchans & V4L2_TUNER_SUB_LANG2) | 413 | if (rxsubchans & V4L2_TUNER_SUB_LANG2) |
414 | mode |= VIDEO_SOUND_LANG2; | 414 | mode |= VIDEO_SOUND_LANG2 | VIDEO_SOUND_STEREO; |
415 | if (rxsubchans & V4L2_TUNER_SUB_LANG1) | 415 | if (rxsubchans & V4L2_TUNER_SUB_LANG1) |
416 | mode |= VIDEO_SOUND_LANG1; | 416 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_STEREO; |
417 | if (mode == 0) | 417 | if (mode == 0) |
418 | mode |= VIDEO_SOUND_MONO; | 418 | mode |= VIDEO_SOUND_MONO; |
419 | return mode; | 419 | return mode; |
@@ -430,21 +430,6 @@ static int msp_mode_v4l1_to_v4l2(int mode) | |||
430 | return V4L2_TUNER_MODE_MONO; | 430 | return V4L2_TUNER_MODE_MONO; |
431 | } | 431 | } |
432 | 432 | ||
433 | static void msp_any_detect_stereo(struct i2c_client *client) | ||
434 | { | ||
435 | struct msp_state *state = i2c_get_clientdata(client); | ||
436 | |||
437 | switch (state->opmode) { | ||
438 | case OPMODE_MANUAL: | ||
439 | case OPMODE_AUTODETECT: | ||
440 | autodetect_stereo(client); | ||
441 | break; | ||
442 | case OPMODE_AUTOSELECT: | ||
443 | msp34xxg_detect_stereo(client); | ||
444 | break; | ||
445 | } | ||
446 | } | ||
447 | |||
448 | static struct v4l2_queryctrl msp_qctrl_std[] = { | 433 | static struct v4l2_queryctrl msp_qctrl_std[] = { |
449 | { | 434 | { |
450 | .id = V4L2_CID_AUDIO_VOLUME, | 435 | .id = V4L2_CID_AUDIO_VOLUME, |
@@ -506,22 +491,6 @@ static struct v4l2_queryctrl msp_qctrl_sound_processing[] = { | |||
506 | }; | 491 | }; |
507 | 492 | ||
508 | 493 | ||
509 | static void msp_any_set_audmode(struct i2c_client *client, int audmode) | ||
510 | { | ||
511 | struct msp_state *state = i2c_get_clientdata(client); | ||
512 | |||
513 | switch (state->opmode) { | ||
514 | case OPMODE_MANUAL: | ||
515 | case OPMODE_AUTODETECT: | ||
516 | state->watch_stereo = 0; | ||
517 | msp3400c_setstereo(client, audmode); | ||
518 | break; | ||
519 | case OPMODE_AUTOSELECT: | ||
520 | msp34xxg_set_audmode(client, audmode); | ||
521 | break; | ||
522 | } | ||
523 | } | ||
524 | |||
525 | static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) | 494 | static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) |
526 | { | 495 | { |
527 | struct msp_state *state = i2c_get_clientdata(client); | 496 | struct msp_state *state = i2c_get_clientdata(client); |
@@ -653,11 +622,10 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
653 | } | 622 | } |
654 | if (scart) { | 623 | if (scart) { |
655 | state->rxsubchans = V4L2_TUNER_SUB_STEREO; | 624 | state->rxsubchans = V4L2_TUNER_SUB_STEREO; |
656 | state->audmode = V4L2_TUNER_MODE_STEREO; | ||
657 | msp_set_scart(client, scart, 0); | 625 | msp_set_scart(client, scart, 0); |
658 | msp_write_dsp(client, 0x000d, 0x1900); | 626 | msp_write_dsp(client, 0x000d, 0x1900); |
659 | if (state->opmode != OPMODE_AUTOSELECT) | 627 | if (state->opmode != OPMODE_AUTOSELECT) |
660 | msp3400c_setstereo(client, state->audmode); | 628 | msp_set_audmode(client); |
661 | } | 629 | } |
662 | msp_wake_thread(client); | 630 | msp_wake_thread(client); |
663 | break; | 631 | break; |
@@ -671,8 +639,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
671 | switch (state->opmode) { | 639 | switch (state->opmode) { |
672 | case OPMODE_MANUAL: | 640 | case OPMODE_MANUAL: |
673 | /* set msp3400 to FM radio mode */ | 641 | /* set msp3400 to FM radio mode */ |
674 | msp3400c_setmode(client, MSP_MODE_FM_RADIO); | 642 | msp3400c_set_mode(client, MSP_MODE_FM_RADIO); |
675 | msp3400c_setcarrier(client, MSP_CARRIER(10.7), | 643 | msp3400c_set_carrier(client, MSP_CARRIER(10.7), |
676 | MSP_CARRIER(10.7)); | 644 | MSP_CARRIER(10.7)); |
677 | msp_set_audio(client); | 645 | msp_set_audio(client); |
678 | break; | 646 | break; |
@@ -706,7 +674,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
706 | if (state->radio) | 674 | if (state->radio) |
707 | break; | 675 | break; |
708 | if (state->opmode == OPMODE_AUTOSELECT) | 676 | if (state->opmode == OPMODE_AUTOSELECT) |
709 | msp_any_detect_stereo(client); | 677 | msp_detect_stereo(client); |
710 | va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans); | 678 | va->mode = msp_mode_v4l2_to_v4l1(state->rxsubchans); |
711 | break; | 679 | break; |
712 | } | 680 | } |
@@ -722,8 +690,9 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
722 | state->treble = va->treble; | 690 | state->treble = va->treble; |
723 | msp_set_audio(client); | 691 | msp_set_audio(client); |
724 | 692 | ||
725 | if (va->mode != 0 && state->radio == 0) | 693 | if (va->mode != 0 && state->radio == 0) { |
726 | msp_any_set_audmode(client, msp_mode_v4l1_to_v4l2(va->mode)); | 694 | state->audmode = msp_mode_v4l1_to_v4l2(va->mode); |
695 | } | ||
727 | break; | 696 | break; |
728 | } | 697 | } |
729 | 698 | ||
@@ -831,11 +800,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
831 | return -EINVAL; | 800 | return -EINVAL; |
832 | } | 801 | } |
833 | 802 | ||
834 | msp_any_detect_stereo(client); | 803 | a->capability = V4L2_AUDCAP_STEREO; |
835 | if (state->audmode == V4L2_TUNER_MODE_STEREO) { | 804 | a->mode = 0; /* TODO: add support for AVL */ |
836 | a->capability = V4L2_AUDCAP_STEREO; | ||
837 | } | ||
838 | |||
839 | break; | 805 | break; |
840 | } | 806 | } |
841 | 807 | ||
@@ -865,16 +831,10 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
865 | } | 831 | } |
866 | if (scart) { | 832 | if (scart) { |
867 | state->rxsubchans = V4L2_TUNER_SUB_STEREO; | 833 | state->rxsubchans = V4L2_TUNER_SUB_STEREO; |
868 | state->audmode = V4L2_TUNER_MODE_STEREO; | ||
869 | msp_set_scart(client, scart, 0); | 834 | msp_set_scart(client, scart, 0); |
870 | msp_write_dsp(client, 0x000d, 0x1900); | 835 | msp_write_dsp(client, 0x000d, 0x1900); |
871 | } | 836 | } |
872 | if (sarg->capability == V4L2_AUDCAP_STEREO) { | 837 | msp_set_audmode(client); |
873 | state->audmode = V4L2_TUNER_MODE_STEREO; | ||
874 | } else { | ||
875 | state->audmode &= ~V4L2_TUNER_MODE_STEREO; | ||
876 | } | ||
877 | msp_any_set_audmode(client, state->audmode); | ||
878 | msp_wake_thread(client); | 838 | msp_wake_thread(client); |
879 | break; | 839 | break; |
880 | } | 840 | } |
@@ -886,7 +846,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
886 | if (state->radio) | 846 | if (state->radio) |
887 | break; | 847 | break; |
888 | if (state->opmode == OPMODE_AUTOSELECT) | 848 | if (state->opmode == OPMODE_AUTOSELECT) |
889 | msp_any_detect_stereo(client); | 849 | msp_detect_stereo(client); |
890 | vt->audmode = state->audmode; | 850 | vt->audmode = state->audmode; |
891 | vt->rxsubchans = state->rxsubchans; | 851 | vt->rxsubchans = state->rxsubchans; |
892 | vt->capability = V4L2_TUNER_CAP_STEREO | | 852 | vt->capability = V4L2_TUNER_CAP_STEREO | |
@@ -898,11 +858,11 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
898 | { | 858 | { |
899 | struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; | 859 | struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; |
900 | 860 | ||
901 | if (state->radio) | 861 | if (state->radio) /* TODO: add mono/stereo support for radio */ |
902 | break; | 862 | break; |
863 | state->audmode = vt->audmode; | ||
903 | /* only set audmode */ | 864 | /* only set audmode */ |
904 | if (vt->audmode != -1 && vt->audmode != 0) | 865 | msp_set_audmode(client); |
905 | msp_any_set_audmode(client, vt->audmode); | ||
906 | break; | 866 | break; |
907 | } | 867 | } |
908 | 868 | ||
@@ -927,7 +887,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
927 | return -EINVAL; | 887 | return -EINVAL; |
928 | } | 888 | } |
929 | break; | 889 | break; |
930 | |||
931 | } | 890 | } |
932 | 891 | ||
933 | case VIDIOC_S_AUDOUT: | 892 | case VIDIOC_S_AUDOUT: |
@@ -993,7 +952,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
993 | const char *p; | 952 | const char *p; |
994 | 953 | ||
995 | if (state->opmode == OPMODE_AUTOSELECT) | 954 | if (state->opmode == OPMODE_AUTOSELECT) |
996 | msp_any_detect_stereo(client); | 955 | msp_detect_stereo(client); |
997 | v4l_info(client, "%s rev1 = 0x%04x rev2 = 0x%04x\n", | 956 | v4l_info(client, "%s rev1 = 0x%04x rev2 = 0x%04x\n", |
998 | client->name, state->rev1, state->rev2); | 957 | client->name, state->rev1, state->rev2); |
999 | v4l_info(client, "Audio: volume %d%s\n", | 958 | v4l_info(client, "Audio: volume %d%s\n", |
@@ -1094,6 +1053,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) | |||
1094 | 1053 | ||
1095 | memset(state, 0, sizeof(*state)); | 1054 | memset(state, 0, sizeof(*state)); |
1096 | state->v4l2_std = V4L2_STD_NTSC; | 1055 | state->v4l2_std = V4L2_STD_NTSC; |
1056 | state->audmode = V4L2_TUNER_MODE_LANG1; | ||
1097 | state->volume = 58880; /* 0db gain */ | 1057 | state->volume = 58880; /* 0db gain */ |
1098 | state->balance = 32768; /* 0db gain */ | 1058 | state->balance = 32768; /* 0db gain */ |
1099 | state->bass = 32768; | 1059 | state->bass = 32768; |