diff options
Diffstat (limited to 'drivers/media/video/msp3400-kthreads.c')
-rw-r--r-- | drivers/media/video/msp3400-kthreads.c | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c index 14a425a6ff85..2b59b6847535 100644 --- a/drivers/media/video/msp3400-kthreads.c +++ b/drivers/media/video/msp3400-kthreads.c | |||
@@ -37,7 +37,7 @@ static struct { | |||
37 | int retval; | 37 | int retval; |
38 | int main, second; | 38 | int main, second; |
39 | char *name; | 39 | char *name; |
40 | } msp_modelist[] = { | 40 | } msp_stdlist[] = { |
41 | { 0x0000, 0, 0, "could not detect sound standard" }, | 41 | { 0x0000, 0, 0, "could not detect sound standard" }, |
42 | { 0x0001, 0, 0, "autodetect start" }, | 42 | { 0x0001, 0, 0, "autodetect start" }, |
43 | { 0x0002, MSP_CARRIER(4.5), MSP_CARRIER(4.72), "4.5/4.72 M Dual FM-Stereo" }, | 43 | { 0x0002, MSP_CARRIER(4.5), MSP_CARRIER(4.72), "4.5/4.72 M Dual FM-Stereo" }, |
@@ -144,13 +144,13 @@ static struct msp3400c_carrier_detect msp3400c_carrier_detect_65[] = { | |||
144 | 144 | ||
145 | /* ------------------------------------------------------------------------ */ | 145 | /* ------------------------------------------------------------------------ */ |
146 | 146 | ||
147 | const char *msp_standard_mode_name(int mode) | 147 | const char *msp_standard_std_name(int std) |
148 | { | 148 | { |
149 | int i; | 149 | int i; |
150 | 150 | ||
151 | for (i = 0; msp_modelist[i].name != NULL; i++) | 151 | for (i = 0; msp_stdlist[i].name != NULL; i++) |
152 | if (msp_modelist[i].retval == mode) | 152 | if (msp_stdlist[i].retval == std) |
153 | return msp_modelist[i].name; | 153 | return msp_stdlist[i].name; |
154 | return "unknown"; | 154 | return "unknown"; |
155 | } | 155 | } |
156 | 156 | ||
@@ -498,7 +498,7 @@ int msp3400c_thread(void *data) | |||
498 | cd = msp3400c_carrier_detect_main; | 498 | cd = msp3400c_carrier_detect_main; |
499 | count = ARRAY_SIZE(msp3400c_carrier_detect_main); | 499 | count = ARRAY_SIZE(msp3400c_carrier_detect_main); |
500 | 500 | ||
501 | if (amsound && (state->std & V4L2_STD_SECAM)) { | 501 | if (amsound && (state->v4l2_std & V4L2_STD_SECAM)) { |
502 | /* autodetect doesn't work well with AM ... */ | 502 | /* autodetect doesn't work well with AM ... */ |
503 | max1 = 3; | 503 | max1 = 3; |
504 | count = 0; | 504 | count = 0; |
@@ -535,7 +535,7 @@ int msp3400c_thread(void *data) | |||
535 | break; | 535 | break; |
536 | } | 536 | } |
537 | 537 | ||
538 | if (amsound && (state->std & V4L2_STD_SECAM)) { | 538 | if (amsound && (state->v4l2_std & V4L2_STD_SECAM)) { |
539 | /* autodetect doesn't work well with AM ... */ | 539 | /* autodetect doesn't work well with AM ... */ |
540 | cd = NULL; | 540 | cd = NULL; |
541 | count = 0; | 541 | count = 0; |
@@ -591,7 +591,7 @@ int msp3400c_thread(void *data) | |||
591 | state->nicam_on = 0; | 591 | state->nicam_on = 0; |
592 | msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); | 592 | msp3400c_setstereo(client, V4L2_TUNER_MODE_MONO); |
593 | state->watch_stereo = 1; | 593 | state->watch_stereo = 1; |
594 | } else if (max2 == 0 && (state->std & V4L2_STD_SECAM)) { | 594 | } else if (max2 == 0 && (state->v4l2_std & V4L2_STD_SECAM)) { |
595 | /* L NICAM or AM-mono */ | 595 | /* L NICAM or AM-mono */ |
596 | state->second = msp3400c_carrier_detect_65[max2].cdo; | 596 | state->second = msp3400c_carrier_detect_65[max2].cdo; |
597 | msp3400c_setmode(client, MSP_MODE_AM_NICAM); | 597 | msp3400c_setmode(client, MSP_MODE_AM_NICAM); |
@@ -676,22 +676,22 @@ int msp3410d_thread(void *data) | |||
676 | goto restart; | 676 | goto restart; |
677 | 677 | ||
678 | /* start autodetect */ | 678 | /* start autodetect */ |
679 | std = 1; | 679 | if (state->radio) |
680 | if (state->std & V4L2_STD_NTSC) | 680 | std = 0x40; |
681 | std = 0x20; | ||
682 | else | 681 | else |
683 | msp_write_dem(client, 0x20, std); | 682 | std = (state->v4l2_std & V4L2_STD_NTSC) ? 0x20 : 1; |
684 | state->watch_stereo = 0; | 683 | state->watch_stereo = 0; |
685 | 684 | ||
686 | if (debug) | 685 | if (debug) |
687 | v4l_dbg(1, client, "setting mode: %s (0x%04x)\n", | 686 | v4l_dbg(1, client, "setting standard: %s (0x%04x)\n", |
688 | msp_standard_mode_name(std), std); | 687 | msp_standard_std_name(std), std); |
689 | 688 | ||
690 | if (std != 1) { | 689 | if (std != 1) { |
691 | /* programmed some specific mode */ | 690 | /* programmed some specific mode */ |
692 | val = std; | 691 | val = std; |
693 | } else { | 692 | } else { |
694 | /* triggered autodetect */ | 693 | /* triggered autodetect */ |
694 | msp_write_dem(client, 0x20, std); | ||
695 | for (;;) { | 695 | for (;;) { |
696 | if (msp_sleep(state, 100)) | 696 | if (msp_sleep(state, 100)) |
697 | goto restart; | 697 | goto restart; |
@@ -703,19 +703,21 @@ int msp3410d_thread(void *data) | |||
703 | v4l_dbg(1, client, "detection still in progress\n"); | 703 | v4l_dbg(1, client, "detection still in progress\n"); |
704 | } | 704 | } |
705 | } | 705 | } |
706 | for (i = 0; msp_modelist[i].name != NULL; i++) | 706 | for (i = 0; msp_stdlist[i].name != NULL; i++) |
707 | if (msp_modelist[i].retval == val) | 707 | if (msp_stdlist[i].retval == val) |
708 | break; | 708 | break; |
709 | v4l_dbg(1, client, "current mode: %s (0x%04x)\n", | 709 | v4l_dbg(1, client, "current standard: %s (0x%04x)\n", |
710 | msp_standard_mode_name(val), val); | 710 | msp_standard_std_name(val), val); |
711 | state->main = msp_modelist[i].main; | 711 | state->main = msp_stdlist[i].main; |
712 | state->second = msp_modelist[i].second; | 712 | state->second = msp_stdlist[i].second; |
713 | 713 | state->std = val; | |
714 | if (amsound && (state->std & V4L2_STD_SECAM) && (val != 0x0009)) { | 714 | |
715 | if (amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) && | ||
716 | (val != 0x0009)) { | ||
715 | /* autodetection has failed, let backup */ | 717 | /* autodetection has failed, let backup */ |
716 | v4l_dbg(1, client, "autodetection failed," | 718 | v4l_dbg(1, client, "autodetection failed," |
717 | " switching to backup mode: %s (0x%04x)\n", | 719 | " switching to backup standard: %s (0x%04x)\n", |
718 | msp_modelist[8].name ? msp_modelist[8].name : "unknown",val); | 720 | msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val); |
719 | val = 0x0009; | 721 | val = 0x0009; |
720 | msp_write_dem(client, 0x20, val); | 722 | msp_write_dem(client, 0x20, val); |
721 | } | 723 | } |
@@ -762,7 +764,7 @@ int msp3410d_thread(void *data) | |||
762 | state->watch_stereo = 0; | 764 | state->watch_stereo = 0; |
763 | /* not needed in theory if we have radio, but | 765 | /* not needed in theory if we have radio, but |
764 | short programming enables carrier mute */ | 766 | short programming enables carrier mute */ |
765 | msp3400c_setmode(client,MSP_MODE_FM_RADIO); | 767 | msp3400c_setmode(client, MSP_MODE_FM_RADIO); |
766 | msp3400c_setcarrier(client, MSP_CARRIER(10.7), | 768 | msp3400c_setcarrier(client, MSP_CARRIER(10.7), |
767 | MSP_CARRIER(10.7)); | 769 | MSP_CARRIER(10.7)); |
768 | /* scart routing */ | 770 | /* scart routing */ |
@@ -775,7 +777,7 @@ int msp3410d_thread(void *data) | |||
775 | case 0x0003: | 777 | case 0x0003: |
776 | case 0x0004: | 778 | case 0x0004: |
777 | case 0x0005: | 779 | case 0x0005: |
778 | state->mode = MSP_MODE_FM_TERRA; | 780 | state->mode = MSP_MODE_FM_TERRA; |
779 | state->rxsubchans = V4L2_TUNER_SUB_MONO; | 781 | state->rxsubchans = V4L2_TUNER_SUB_MONO; |
780 | state->audmode = V4L2_TUNER_MODE_MONO; | 782 | state->audmode = V4L2_TUNER_MODE_MONO; |
781 | state->nicam_on = 0; | 783 | state->nicam_on = 0; |
@@ -786,7 +788,8 @@ int msp3410d_thread(void *data) | |||
786 | /* unmute, restore misc registers */ | 788 | /* unmute, restore misc registers */ |
787 | msp_set_audio(client); | 789 | msp_set_audio(client); |
788 | msp_write_dsp(client, 0x13, state->acb); | 790 | msp_write_dsp(client, 0x13, state->acb); |
789 | msp_write_dem(client, 0x40, state->i2s_mode); | 791 | if (state->has_i2s_conf) |
792 | msp_write_dem(client, 0x40, state->i2s_mode); | ||
790 | 793 | ||
791 | /* monitor tv audio mode */ | 794 | /* monitor tv audio mode */ |
792 | while (state->watch_stereo) { | 795 | while (state->watch_stereo) { |
@@ -857,14 +860,15 @@ static int msp34xxg_reset(struct i2c_client *client) | |||
857 | if (msp_write_dsp(client, 0x13, 0x0f20)) | 860 | if (msp_write_dsp(client, 0x13, 0x0f20)) |
858 | return -1; | 861 | return -1; |
859 | 862 | ||
860 | msp_write_dem(client, 0x40, state->i2s_mode); | 863 | if (state->has_i2s_conf) |
864 | msp_write_dem(client, 0x40, state->i2s_mode); | ||
861 | 865 | ||
862 | /* step-by-step initialisation, as described in the manual */ | 866 | /* step-by-step initialisation, as described in the manual */ |
863 | modus = msp_modus(client); | 867 | modus = msp_modus(client); |
864 | if (state->radio) | 868 | if (state->radio) |
865 | std = 0x40; | 869 | std = 0x40; |
866 | else | 870 | else |
867 | std = (state->std & V4L2_STD_NTSC) ? 0x20 : 1; | 871 | std = (state->v4l2_std & V4L2_STD_NTSC) ? 0x20 : 1; |
868 | modus &= ~0x03; /* STATUS_CHANGE = 0 */ | 872 | modus &= ~0x03; /* STATUS_CHANGE = 0 */ |
869 | modus |= 0x01; /* AUTOMATIC_SOUND_DETECTION = 1 */ | 873 | modus |= 0x01; /* AUTOMATIC_SOUND_DETECTION = 1 */ |
870 | if (msp_write_dem(client, 0x30, modus)) | 874 | if (msp_write_dem(client, 0x30, modus)) |
@@ -933,9 +937,9 @@ int msp34xxg_thread(void *data) | |||
933 | } | 937 | } |
934 | 938 | ||
935 | unmute: | 939 | unmute: |
936 | state->mode = std; | 940 | state->std = std; |
937 | v4l_dbg(1, client, "current mode: %s (0x%04x)\n", | 941 | v4l_dbg(1, client, "current standard: %s (0x%04x)\n", |
938 | msp_standard_mode_name(std), std); | 942 | msp_standard_std_name(std), std); |
939 | 943 | ||
940 | /* unmute: dispatch sound to scart output, set scart volume */ | 944 | /* unmute: dispatch sound to scart output, set scart volume */ |
941 | msp_set_audio(client); | 945 | msp_set_audio(client); |