aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/msp3400-kthreads.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/msp3400-kthreads.c')
-rw-r--r--drivers/media/video/msp3400-kthreads.c62
1 files changed, 27 insertions, 35 deletions
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index 926095c6d826..b41ee9afbd96 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -383,7 +383,7 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
383 if (val > 32767) 383 if (val > 32767)
384 val -= 65536; 384 val -= 65536;
385 v4l_dbg(2, msp_debug, client, "stereo detect register: %d\n", val); 385 v4l_dbg(2, msp_debug, client, "stereo detect register: %d\n", val);
386 if (val > 4096) { 386 if (val > 8192) {
387 rxsubchans = V4L2_TUNER_SUB_STEREO; 387 rxsubchans = V4L2_TUNER_SUB_STEREO;
388 } else if (val < -4096) { 388 } else if (val < -4096) {
389 rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; 389 rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
@@ -480,12 +480,14 @@ int msp3400c_thread(void *data)
480 if (state->radio || MSP_MODE_EXTERN == state->mode) { 480 if (state->radio || MSP_MODE_EXTERN == state->mode) {
481 /* no carrier scan, just unmute */ 481 /* no carrier scan, just unmute */
482 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n"); 482 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
483 state->scan_in_progress = 0;
483 msp_set_audio(client); 484 msp_set_audio(client);
484 continue; 485 continue;
485 } 486 }
486 487
487 /* put into sane state (and mute) */ 488 /* mute audio */
488 msp_reset(client); 489 state->scan_in_progress = 1;
490 msp_set_audio(client);
489 491
490 msp3400c_set_mode(client, MSP_MODE_AM_DETECT); 492 msp3400c_set_mode(client, MSP_MODE_AM_DETECT);
491 val1 = val2 = 0; 493 val1 = val2 = 0;
@@ -493,7 +495,7 @@ int msp3400c_thread(void *data)
493 state->watch_stereo = 0; 495 state->watch_stereo = 0;
494 state->nicam_on = 0; 496 state->nicam_on = 0;
495 497
496 /* some time for the tuner to sync */ 498 /* wait for tuner to settle down after a channel change */
497 if (msp_sleep(state, 200)) 499 if (msp_sleep(state, 200))
498 goto restart; 500 goto restart;
499 501
@@ -608,28 +610,26 @@ int msp3400c_thread(void *data)
608 no_second: 610 no_second:
609 state->second = msp3400c_carrier_detect_main[max1].cdo; 611 state->second = msp3400c_carrier_detect_main[max1].cdo;
610 msp3400c_set_mode(client, MSP_MODE_FM_TERRA); 612 msp3400c_set_mode(client, MSP_MODE_FM_TERRA);
611 state->rxsubchans = V4L2_TUNER_SUB_MONO;
612 break; 613 break;
613 } 614 }
614 msp3400c_set_carrier(client, state->second, state->main); 615 msp3400c_set_carrier(client, state->second, state->main);
615 616
616 /* unmute, restore misc registers */ 617 /* unmute */
617 msp_set_audio(client); 618 state->scan_in_progress = 0;
618
619 msp_write_dsp(client, 0x13, state->acb);
620 msp3400c_set_audmode(client); 619 msp3400c_set_audmode(client);
620 msp_set_audio(client);
621 621
622 if (msp_debug) 622 if (msp_debug)
623 msp3400c_print_mode(client); 623 msp3400c_print_mode(client);
624 624
625 /* monitor tv audio mode, the first time don't wait 625 /* monitor tv audio mode, the first time don't wait
626 so long to get a quick stereo/bilingual result */ 626 so long to get a quick stereo/bilingual result */
627 count = 20; 627 count = 3;
628 while (state->watch_stereo) { 628 while (state->watch_stereo) {
629 watch_stereo(client); 629 if (msp_sleep(state, count ? 1000 : 5000))
630 if (msp_sleep(state, count ? 200 : 5000))
631 goto restart; 630 goto restart;
632 if (count) count--; 631 if (count) count--;
632 watch_stereo(client);
633 } 633 }
634 } 634 }
635 v4l_dbg(1, msp_debug, client, "thread: exit\n"); 635 v4l_dbg(1, msp_debug, client, "thread: exit\n");
@@ -659,16 +659,14 @@ int msp3410d_thread(void *data)
659 if (state->mode == MSP_MODE_EXTERN) { 659 if (state->mode == MSP_MODE_EXTERN) {
660 /* no carrier scan needed, just unmute */ 660 /* no carrier scan needed, just unmute */
661 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n"); 661 v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
662 state->scan_in_progress = 0;
662 msp_set_audio(client); 663 msp_set_audio(client);
663 continue; 664 continue;
664 } 665 }
665 666
666 /* put into sane state (and mute) */ 667 /* mute audio */
667 msp_reset(client); 668 state->scan_in_progress = 1;
668 669 msp_set_audio(client);
669 /* some time for the tuner to sync */
670 if (msp_sleep(state,200))
671 goto restart;
672 670
673 /* start autodetect. Note: autodetect is not supported for 671 /* start autodetect. Note: autodetect is not supported for
674 NTSC-M and radio, hence we force the standard in those cases. */ 672 NTSC-M and radio, hence we force the standard in those cases. */
@@ -679,6 +677,10 @@ int msp3410d_thread(void *data)
679 state->watch_stereo = 0; 677 state->watch_stereo = 0;
680 state->nicam_on = 0; 678 state->nicam_on = 0;
681 679
680 /* wait for tuner to settle down after a channel change */
681 if (msp_sleep(state, 200))
682 goto restart;
683
682 if (msp_debug) 684 if (msp_debug)
683 v4l_dbg(2, msp_debug, client, "setting standard: %s (0x%04x)\n", 685 v4l_dbg(2, msp_debug, client, "setting standard: %s (0x%04x)\n",
684 msp_standard_std_name(std), std); 686 msp_standard_std_name(std), std);
@@ -708,6 +710,7 @@ int msp3410d_thread(void *data)
708 state->main = msp_stdlist[i].main; 710 state->main = msp_stdlist[i].main;
709 state->second = msp_stdlist[i].second; 711 state->second = msp_stdlist[i].second;
710 state->std = val; 712 state->std = val;
713 state->rxsubchans = V4L2_TUNER_SUB_MONO;
711 714
712 if (msp_amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) && 715 if (msp_amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) &&
713 (val != 0x0009)) { 716 (val != 0x0009)) {
@@ -729,20 +732,17 @@ int msp3410d_thread(void *data)
729 else 732 else
730 state->mode = MSP_MODE_FM_NICAM1; 733 state->mode = MSP_MODE_FM_NICAM1;
731 /* just turn on stereo */ 734 /* just turn on stereo */
732 state->rxsubchans = V4L2_TUNER_SUB_STEREO;
733 state->nicam_on = 1; 735 state->nicam_on = 1;
734 state->watch_stereo = 1; 736 state->watch_stereo = 1;
735 break; 737 break;
736 case 0x0009: 738 case 0x0009:
737 state->mode = MSP_MODE_AM_NICAM; 739 state->mode = MSP_MODE_AM_NICAM;
738 state->rxsubchans = V4L2_TUNER_SUB_MONO;
739 state->nicam_on = 1; 740 state->nicam_on = 1;
740 state->watch_stereo = 1; 741 state->watch_stereo = 1;
741 break; 742 break;
742 case 0x0020: /* BTSC */ 743 case 0x0020: /* BTSC */
743 /* The pre-'G' models only have BTSC-mono */ 744 /* The pre-'G' models only have BTSC-mono */
744 state->mode = MSP_MODE_BTSC; 745 state->mode = MSP_MODE_BTSC;
745 state->rxsubchans = V4L2_TUNER_SUB_MONO;
746 break; 746 break;
747 case 0x0040: /* FM radio */ 747 case 0x0040: /* FM radio */
748 state->mode = MSP_MODE_FM_RADIO; 748 state->mode = MSP_MODE_FM_RADIO;
@@ -752,15 +752,12 @@ int msp3410d_thread(void *data)
752 msp3400c_set_mode(client, MSP_MODE_FM_RADIO); 752 msp3400c_set_mode(client, MSP_MODE_FM_RADIO);
753 msp3400c_set_carrier(client, MSP_CARRIER(10.7), 753 msp3400c_set_carrier(client, MSP_CARRIER(10.7),
754 MSP_CARRIER(10.7)); 754 MSP_CARRIER(10.7));
755 /* scart routing (this doesn't belong here I think) */
756 msp_set_scart(client,SCART_IN2,0);
757 break; 755 break;
758 case 0x0002: 756 case 0x0002:
759 case 0x0003: 757 case 0x0003:
760 case 0x0004: 758 case 0x0004:
761 case 0x0005: 759 case 0x0005:
762 state->mode = MSP_MODE_FM_TERRA; 760 state->mode = MSP_MODE_FM_TERRA;
763 state->rxsubchans = V4L2_TUNER_SUB_MONO;
764 state->watch_stereo = 1; 761 state->watch_stereo = 1;
765 break; 762 break;
766 } 763 }
@@ -774,20 +771,19 @@ int msp3410d_thread(void *data)
774 if (state->has_i2s_conf) 771 if (state->has_i2s_conf)
775 msp_write_dem(client, 0x40, state->i2s_mode); 772 msp_write_dem(client, 0x40, state->i2s_mode);
776 773
777 /* unmute, restore misc registers */ 774 /* unmute */
778 msp_set_audio(client);
779
780 msp_write_dsp(client, 0x13, state->acb);
781 msp3400c_set_audmode(client); 775 msp3400c_set_audmode(client);
776 state->scan_in_progress = 0;
777 msp_set_audio(client);
782 778
783 /* monitor tv audio mode, the first time don't wait 779 /* monitor tv audio mode, the first time don't wait
784 so long to get a quick stereo/bilingual result */ 780 so long to get a quick stereo/bilingual result */
785 count = 20; 781 count = 3;
786 while (state->watch_stereo) { 782 while (state->watch_stereo) {
787 watch_stereo(client); 783 if (msp_sleep(state, count ? 1000 : 5000))
788 if (msp_sleep(state, count ? 200 : 5000))
789 goto restart; 784 goto restart;
790 if (count) count--; 785 if (count) count--;
786 watch_stereo(client);
791 } 787 }
792 } 788 }
793 v4l_dbg(1, msp_debug, client, "thread: exit\n"); 789 v4l_dbg(1, msp_debug, client, "thread: exit\n");
@@ -902,10 +898,6 @@ static void msp34xxg_reset(struct i2c_client *client)
902 898
903 msp_reset(client); 899 msp_reset(client);
904 900
905 /* make sure that input/output is muted (paranoid mode) */
906 /* ACB, mute DSP input, mute SCART 1 */
907 msp_write_dsp(client, 0x13, 0x0f20);
908
909 if (state->has_i2s_conf) 901 if (state->has_i2s_conf)
910 msp_write_dem(client, 0x40, state->i2s_mode); 902 msp_write_dem(client, 0x40, state->i2s_mode);
911 903