aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c13
-rw-r--r--drivers/media/video/msp3400-driver.c32
-rw-r--r--drivers/media/video/msp3400-driver.h1
-rw-r--r--drivers/media/video/msp3400-kthreads.c62
-rw-r--r--drivers/media/video/tuner-core.c8
-rw-r--r--drivers/media/video/v4l2-common.c8
6 files changed, 65 insertions, 59 deletions
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 7913e2ec7a5b..692dc69f691d 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -1025,7 +1025,6 @@ i2c_vidiocschan(struct bttv *btv)
1025{ 1025{
1026 v4l2_std_id std = bttv_tvnorms[btv->tvnorm].v4l2_id; 1026 v4l2_std_id std = bttv_tvnorms[btv->tvnorm].v4l2_id;
1027 1027
1028 bttv_call_i2c_clients(btv, VIDIOC_S_INPUT, &btv->input);
1029 bttv_call_i2c_clients(btv, VIDIOC_S_STD, &std); 1028 bttv_call_i2c_clients(btv, VIDIOC_S_STD, &std);
1030 if (btv->c.type == BTTV_BOARD_VOODOOTV_FM) 1029 if (btv->c.type == BTTV_BOARD_VOODOOTV_FM)
1031 bttv_tda9880_setnorm(btv,btv->tvnorm); 1030 bttv_tda9880_setnorm(btv,btv->tvnorm);
@@ -1603,12 +1602,16 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1603 } 1602 }
1604 case VIDIOCSFREQ: 1603 case VIDIOCSFREQ:
1605 { 1604 {
1606 unsigned long *freq = arg; 1605 struct v4l2_frequency freq;
1606
1607 memset(&freq, 0, sizeof(freq));
1608 freq.frequency = *(unsigned long *)arg;
1607 mutex_lock(&btv->lock); 1609 mutex_lock(&btv->lock);
1608 btv->freq=*freq; 1610 freq.type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1609 bttv_call_i2c_clients(btv,VIDIOCSFREQ,freq); 1611 btv->freq = *(unsigned long *)arg;
1612 bttv_call_i2c_clients(btv,VIDIOC_S_FREQUENCY,&freq);
1610 if (btv->has_matchbox && btv->radio_user) 1613 if (btv->has_matchbox && btv->radio_user)
1611 tea5757_set_freq(btv,*freq); 1614 tea5757_set_freq(btv,*(unsigned long *)arg);
1612 mutex_unlock(&btv->lock); 1615 mutex_unlock(&btv->lock);
1613 return 0; 1616 return 0;
1614 } 1617 }
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 027c3d35eaa5..a82a26aa1e48 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -288,17 +288,19 @@ void msp_set_audio(struct i2c_client *client)
288 struct msp_state *state = i2c_get_clientdata(client); 288 struct msp_state *state = i2c_get_clientdata(client);
289 int bal = 0, bass, treble, loudness; 289 int bal = 0, bass, treble, loudness;
290 int val = 0; 290 int val = 0;
291 int reallymuted = state->muted | state->scan_in_progress;
291 292
292 if (!state->muted) 293 if (!reallymuted)
293 val = (state->volume * 0x7f / 65535) << 8; 294 val = (state->volume * 0x7f / 65535) << 8;
294 295
295 v4l_dbg(1, msp_debug, client, "mute=%s volume=%d\n", 296 v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n",
296 state->muted ? "on" : "off", state->volume); 297 state->muted ? "on" : "off", state->scan_in_progress ? "yes" : "no",
298 state->volume);
297 299
298 msp_write_dsp(client, 0x0000, val); 300 msp_write_dsp(client, 0x0000, val);
299 msp_write_dsp(client, 0x0007, state->muted ? 0x1 : (val | 0x1)); 301 msp_write_dsp(client, 0x0007, reallymuted ? 0x1 : (val | 0x1));
300 if (state->has_scart2_out_volume) 302 if (state->has_scart2_out_volume)
301 msp_write_dsp(client, 0x0040, state->muted ? 0x1 : (val | 0x1)); 303 msp_write_dsp(client, 0x0040, reallymuted ? 0x1 : (val | 0x1));
302 if (state->has_headphones) 304 if (state->has_headphones)
303 msp_write_dsp(client, 0x0006, val); 305 msp_write_dsp(client, 0x0006, val);
304 if (!state->has_sound_processing) 306 if (!state->has_sound_processing)
@@ -671,21 +673,23 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
671 int sc_in = rt->input & 0x7; 673 int sc_in = rt->input & 0x7;
672 int sc1_out = rt->output & 0xf; 674 int sc1_out = rt->output & 0xf;
673 int sc2_out = (rt->output >> 4) & 0xf; 675 int sc2_out = (rt->output >> 4) & 0xf;
674 u16 val; 676 u16 val, reg;
675 677
678 if (state->routing.input == rt->input &&
679 state->routing.output == rt->output)
680 break;
676 state->routing = *rt; 681 state->routing = *rt;
677 if (state->opmode == OPMODE_AUTOSELECT) {
678 val = msp_read_dem(client, 0x30) & ~0x100;
679 msp_write_dem(client, 0x30, val | (tuner ? 0x100 : 0));
680 } else {
681 val = msp_read_dem(client, 0xbb) & ~0x100;
682 msp_write_dem(client, 0xbb, val | (tuner ? 0x100 : 0));
683 }
684 msp_set_scart(client, sc_in, 0); 682 msp_set_scart(client, sc_in, 0);
685 msp_set_scart(client, sc1_out, 1); 683 msp_set_scart(client, sc1_out, 1);
686 msp_set_scart(client, sc2_out, 2); 684 msp_set_scart(client, sc2_out, 2);
687 msp_set_audmode(client); 685 msp_set_audmode(client);
688 msp_wake_thread(client); 686 reg = (state->opmode == OPMODE_AUTOSELECT) ? 0x30 : 0xbb;
687 val = msp_read_dem(client, reg);
688 if (tuner != ((val >> 8) & 1)) {
689 msp_write_dem(client, reg, (val & ~0x100) | (tuner << 8));
690 /* wake thread when a new tuner input is chosen */
691 msp_wake_thread(client);
692 }
689 break; 693 break;
690 } 694 }
691 695
diff --git a/drivers/media/video/msp3400-driver.h b/drivers/media/video/msp3400-driver.h
index b5834938df7d..4e451049013d 100644
--- a/drivers/media/video/msp3400-driver.h
+++ b/drivers/media/video/msp3400-driver.h
@@ -85,6 +85,7 @@ struct msp_state {
85 int volume, muted; 85 int volume, muted;
86 int balance, loudness; 86 int balance, loudness;
87 int bass, treble; 87 int bass, treble;
88 int scan_in_progress;
88 89
89 /* thread */ 90 /* thread */
90 struct task_struct *kthread; 91 struct task_struct *kthread;
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
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index bbcb281cc391..d68137f2eb8c 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -558,10 +558,10 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode,
558 558
559static inline int check_v4l2(struct tuner *t) 559static inline int check_v4l2(struct tuner *t)
560{ 560{
561 if (t->using_v4l2) { 561 /* bttv still uses both v4l1 and v4l2 calls to the tuner (v4l2 for
562 tuner_dbg ("ignore v4l1 call\n"); 562 TV, v4l1 for radio), until that is fixed this code is disabled.
563 return EINVAL; 563 Otherwise the radio (v4l1) wouldn't tune after using the TV (v4l2)
564 } 564 first. */
565 return 0; 565 return 0;
566} 566}
567 567
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 11a97f30b876..d330fa985bcc 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -317,6 +317,7 @@ static const char *v4l2_int_ioctls[] = {
317 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", 317 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
318 [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG", 318 [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG",
319 319
320 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
320 [_IOC_NR(VIDIOC_INT_S_REGISTER)] = "VIDIOC_INT_S_REGISTER", 321 [_IOC_NR(VIDIOC_INT_S_REGISTER)] = "VIDIOC_INT_S_REGISTER",
321 [_IOC_NR(VIDIOC_INT_G_REGISTER)] = "VIDIOC_INT_G_REGISTER", 322 [_IOC_NR(VIDIOC_INT_G_REGISTER)] = "VIDIOC_INT_G_REGISTER",
322 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET", 323 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
@@ -325,7 +326,12 @@ static const char *v4l2_int_ioctls[] = {
325 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA", 326 [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA",
326 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA", 327 [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA",
327 [_IOC_NR(VIDIOC_INT_G_CHIP_IDENT)] = "VIDIOC_INT_G_CHIP_IDENT", 328 [_IOC_NR(VIDIOC_INT_G_CHIP_IDENT)] = "VIDIOC_INT_G_CHIP_IDENT",
328 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ" 329 [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ",
330 [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY",
331 [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING",
332 [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING",
333 [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING",
334 [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING"
329}; 335};
330#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls) 336#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
331 337