aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134/saa7134-tvaudio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-tvaudio.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-tvaudio.c93
1 files changed, 40 insertions, 53 deletions
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
index d31220d20495..dd759d6d8d25 100644
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -72,12 +72,12 @@ static struct mainscan {
72 int carr; 72 int carr;
73} mainscan[] = { 73} mainscan[] = {
74 { 74 {
75 .name = "M", 75 .name = "MN",
76 .std = V4L2_STD_NTSC | V4L2_STD_PAL_M, 76 .std = V4L2_STD_MN,
77 .carr = 4500, 77 .carr = 4500,
78 },{ 78 },{
79 .name = "BG", 79 .name = "BGH",
80 .std = V4L2_STD_PAL_BG, 80 .std = V4L2_STD_B | V4L2_STD_GH,
81 .carr = 5500, 81 .carr = 5500,
82 },{ 82 },{
83 .name = "I", 83 .name = "I",
@@ -85,7 +85,7 @@ static struct mainscan {
85 .carr = 6000, 85 .carr = 6000,
86 },{ 86 },{
87 .name = "DKL", 87 .name = "DKL",
88 .std = V4L2_STD_PAL_DK | V4L2_STD_SECAM, 88 .std = V4L2_STD_DK | V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC,
89 .carr = 6500, 89 .carr = 6500,
90 } 90 }
91}; 91};
@@ -93,76 +93,70 @@ static struct mainscan {
93static struct saa7134_tvaudio tvaudio[] = { 93static struct saa7134_tvaudio tvaudio[] = {
94 { 94 {
95 .name = "PAL-B/G FM-stereo", 95 .name = "PAL-B/G FM-stereo",
96 .std = V4L2_STD_PAL, 96 .std = V4L2_STD_PAL_BG,
97 .mode = TVAUDIO_FM_BG_STEREO, 97 .mode = TVAUDIO_FM_BG_STEREO,
98 .carr1 = 5500, 98 .carr1 = 5500,
99 .carr2 = 5742, 99 .carr2 = 5742,
100 },{ 100 },{
101 .name = "PAL-D/K1 FM-stereo", 101 .name = "PAL-D/K1 FM-stereo",
102 .std = V4L2_STD_PAL, 102 .std = V4L2_STD_PAL_DK,
103 .carr1 = 6500, 103 .carr1 = 6500,
104 .carr2 = 6258, 104 .carr2 = 6258,
105 .mode = TVAUDIO_FM_BG_STEREO, 105 .mode = TVAUDIO_FM_BG_STEREO,
106 },{ 106 },{
107 .name = "PAL-D/K2 FM-stereo", 107 .name = "PAL-D/K2 FM-stereo",
108 .std = V4L2_STD_PAL, 108 .std = V4L2_STD_PAL_DK,
109 .carr1 = 6500, 109 .carr1 = 6500,
110 .carr2 = 6742, 110 .carr2 = 6742,
111 .mode = TVAUDIO_FM_BG_STEREO, 111 .mode = TVAUDIO_FM_BG_STEREO,
112 },{ 112 },{
113 .name = "PAL-D/K3 FM-stereo", 113 .name = "PAL-D/K3 FM-stereo",
114 .std = V4L2_STD_PAL, 114 .std = V4L2_STD_PAL_DK,
115 .carr1 = 6500, 115 .carr1 = 6500,
116 .carr2 = 5742, 116 .carr2 = 5742,
117 .mode = TVAUDIO_FM_BG_STEREO, 117 .mode = TVAUDIO_FM_BG_STEREO,
118 },{ 118 },{
119 .name = "PAL-B/G NICAM", 119 .name = "PAL-B/G NICAM",
120 .std = V4L2_STD_PAL, 120 .std = V4L2_STD_PAL_BG,
121 .carr1 = 5500, 121 .carr1 = 5500,
122 .carr2 = 5850, 122 .carr2 = 5850,
123 .mode = TVAUDIO_NICAM_FM, 123 .mode = TVAUDIO_NICAM_FM,
124 },{ 124 },{
125 .name = "PAL-I NICAM", 125 .name = "PAL-I NICAM",
126 .std = V4L2_STD_PAL, 126 .std = V4L2_STD_PAL_I,
127 .carr1 = 6000, 127 .carr1 = 6000,
128 .carr2 = 6552, 128 .carr2 = 6552,
129 .mode = TVAUDIO_NICAM_FM, 129 .mode = TVAUDIO_NICAM_FM,
130 },{ 130 },{
131 .name = "PAL-D/K NICAM", 131 .name = "PAL-D/K NICAM",
132 .std = V4L2_STD_PAL, 132 .std = V4L2_STD_PAL_DK,
133 .carr1 = 6500, 133 .carr1 = 6500,
134 .carr2 = 5850, 134 .carr2 = 5850,
135 .mode = TVAUDIO_NICAM_FM, 135 .mode = TVAUDIO_NICAM_FM,
136 },{ 136 },{
137 .name = "SECAM-L NICAM", 137 .name = "SECAM-L NICAM",
138 .std = V4L2_STD_SECAM, 138 .std = V4L2_STD_SECAM_L,
139 .carr1 = 6500, 139 .carr1 = 6500,
140 .carr2 = 5850, 140 .carr2 = 5850,
141 .mode = TVAUDIO_NICAM_AM, 141 .mode = TVAUDIO_NICAM_AM,
142 },{ 142 },{
143 .name = "SECAM-L MONO", 143 .name = "SECAM-D/K NICAM",
144 .std = V4L2_STD_SECAM, 144 .std = V4L2_STD_SECAM_DK,
145 .carr1 = 6500, 145 .carr1 = 6500,
146 .carr2 = -1, 146 .carr2 = 5850,
147 .mode = TVAUDIO_AM_MONO, 147 .mode = TVAUDIO_NICAM_FM,
148 },{ 148 },{
149 .name = "SECAM-D/K", 149 .name = "NTSC-A2 FM-stereo",
150 .std = V4L2_STD_SECAM, 150 .std = V4L2_STD_NTSC,
151 .carr1 = 6500, 151 .carr1 = 4500,
152 .carr2 = -1, 152 .carr2 = 4724,
153 .mode = TVAUDIO_FM_MONO, 153 .mode = TVAUDIO_FM_K_STEREO,
154 },{ 154 },{
155 .name = "NTSC-M", 155 .name = "NTSC-M",
156 .std = V4L2_STD_NTSC, 156 .std = V4L2_STD_NTSC,
157 .carr1 = 4500, 157 .carr1 = 4500,
158 .carr2 = -1, 158 .carr2 = -1,
159 .mode = TVAUDIO_FM_MONO, 159 .mode = TVAUDIO_FM_MONO,
160 },{
161 .name = "NTSC-A2 FM-stereo",
162 .std = V4L2_STD_NTSC,
163 .carr1 = 4500,
164 .carr2 = 4724,
165 .mode = TVAUDIO_FM_K_STEREO,
166 } 160 }
167}; 161};
168#define TVAUDIO (sizeof(tvaudio)/sizeof(struct saa7134_tvaudio)) 162#define TVAUDIO (sizeof(tvaudio)/sizeof(struct saa7134_tvaudio))
@@ -340,12 +334,6 @@ static void tvaudio_setmode(struct saa7134_dev *dev,
340 saa_writeb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0xa1); 334 saa_writeb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0xa1);
341 saa_writeb(SAA7134_NICAM_CONFIG, 0x00); 335 saa_writeb(SAA7134_NICAM_CONFIG, 0x00);
342 break; 336 break;
343 case TVAUDIO_AM_MONO:
344 saa_writeb(SAA7134_DEMODULATOR, 0x12);
345 saa_writeb(SAA7134_DCXO_IDENT_CTRL, 0x00);
346 saa_writeb(SAA7134_FM_DEEMPHASIS, 0x44);
347 saa_writeb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0xa0);
348 break;
349 case TVAUDIO_FM_SAT_STEREO: 337 case TVAUDIO_FM_SAT_STEREO:
350 /* not implemented (yet) */ 338 /* not implemented (yet) */
351 break; 339 break;
@@ -390,7 +378,6 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
390 } 378 }
391 printk("\n"); 379 printk("\n");
392 } 380 }
393
394 if (dev->tvnorm->id & scan->std) { 381 if (dev->tvnorm->id & scan->std) {
395 tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90); 382 tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90);
396 saa_readl(SAA7134_LEVEL_READOUT1 >> 2); 383 saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
@@ -426,7 +413,6 @@ static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au
426 413
427 switch (audio->mode) { 414 switch (audio->mode) {
428 case TVAUDIO_FM_MONO: 415 case TVAUDIO_FM_MONO:
429 case TVAUDIO_AM_MONO:
430 return V4L2_TUNER_SUB_MONO; 416 return V4L2_TUNER_SUB_MONO;
431 case TVAUDIO_FM_K_STEREO: 417 case TVAUDIO_FM_K_STEREO:
432 case TVAUDIO_FM_BG_STEREO: 418 case TVAUDIO_FM_BG_STEREO:
@@ -495,7 +481,6 @@ static int tvaudio_setstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au
495 481
496 switch (audio->mode) { 482 switch (audio->mode) {
497 case TVAUDIO_FM_MONO: 483 case TVAUDIO_FM_MONO:
498 case TVAUDIO_AM_MONO:
499 /* nothing to do ... */ 484 /* nothing to do ... */
500 break; 485 break;
501 case TVAUDIO_FM_K_STEREO: 486 case TVAUDIO_FM_K_STEREO:
@@ -556,6 +541,7 @@ static int tvaudio_thread(void *data)
556 541
557 if (1 == nscan) { 542 if (1 == nscan) {
558 /* only one candidate -- skip scan ;) */ 543 /* only one candidate -- skip scan ;) */
544 dprintk("only one main carrier candidate - skipping scan\n");
559 max1 = 12345; 545 max1 = 12345;
560 carrier = default_carrier; 546 carrier = default_carrier;
561 } else { 547 } else {
@@ -603,7 +589,6 @@ static int tvaudio_thread(void *data)
603 dev->automute = 0; 589 dev->automute = 0;
604 saa_andorb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0x30, 0x00); 590 saa_andorb(SAA7134_STEREO_DAC_OUTPUT_SELECT, 0x30, 0x00);
605 saa7134_tvaudio_setmute(dev); 591 saa7134_tvaudio_setmute(dev);
606
607 /* find the exact tv audio norm */ 592 /* find the exact tv audio norm */
608 for (audio = UNSET, i = 0; i < TVAUDIO; i++) { 593 for (audio = UNSET, i = 0; i < TVAUDIO; i++) {
609 if (dev->tvnorm->id != UNSET && 594 if (dev->tvnorm->id != UNSET &&
@@ -611,7 +596,7 @@ static int tvaudio_thread(void *data)
611 continue; 596 continue;
612 if (tvaudio[i].carr1 != carrier) 597 if (tvaudio[i].carr1 != carrier)
613 continue; 598 continue;
614 599 /* Note: at least the primary carrier is right here */
615 if (UNSET == audio) 600 if (UNSET == audio)
616 audio = i; 601 audio = i;
617 tvaudio_setmode(dev,&tvaudio[i],"trying"); 602 tvaudio_setmode(dev,&tvaudio[i],"trying");
@@ -626,6 +611,7 @@ static int tvaudio_thread(void *data)
626 if (UNSET == audio) 611 if (UNSET == audio)
627 continue; 612 continue;
628 tvaudio_setmode(dev,&tvaudio[audio],"using"); 613 tvaudio_setmode(dev,&tvaudio[audio],"using");
614
629 tvaudio_setstereo(dev,&tvaudio[audio],V4L2_TUNER_MODE_MONO); 615 tvaudio_setstereo(dev,&tvaudio[audio],V4L2_TUNER_MODE_MONO);
630 dev->tvaudio = &tvaudio[audio]; 616 dev->tvaudio = &tvaudio[audio];
631 617
@@ -750,7 +736,6 @@ static int mute_input_7133(struct saa7134_dev *dev)
750 int mask; 736 int mask;
751 struct saa7134_input *in; 737 struct saa7134_input *in;
752 738
753 /* Hac 0506 route OSS sound simultanously */
754 xbarin = 0x03; 739 xbarin = 0x03;
755 switch (dev->input->amux) { 740 switch (dev->input->amux) {
756 case TV: 741 case TV:
@@ -834,18 +819,16 @@ static int tvaudio_thread_ddep(void *data)
834 } else { 819 } else {
835 /* (let chip) scan for sound carrier */ 820 /* (let chip) scan for sound carrier */
836 norms = 0; 821 norms = 0;
837 if (dev->tvnorm->id & V4L2_STD_PAL) { 822 if (dev->tvnorm->id & (V4L2_STD_B | V4L2_STD_GH))
838 dprintk("PAL scan\n"); 823 norms |= 0x04;
839 norms |= 0x2c; /* B/G + D/K + I */ 824 if (dev->tvnorm->id & V4L2_STD_PAL_I)
840 } 825 norms |= 0x20;
841 if (dev->tvnorm->id & V4L2_STD_NTSC) { 826 if (dev->tvnorm->id & V4L2_STD_DK)
842 dprintk("NTSC scan\n"); 827 norms |= 0x08;
843 norms |= 0x40; /* M */ 828 if (dev->tvnorm->id & V4L2_STD_MN)
844 } 829 norms |= 0x40;
845 if (dev->tvnorm->id & V4L2_STD_SECAM) { 830 if (dev->tvnorm->id & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))
846 dprintk("SECAM scan\n"); 831 norms |= 0x10;
847 norms |= 0x18; /* L + D/K */
848 }
849 if (0 == norms) 832 if (0 == norms)
850 norms = 0x7c; /* all */ 833 norms = 0x7c; /* all */
851 dprintk("scanning:%s%s%s%s%s\n", 834 dprintk("scanning:%s%s%s%s%s\n",
@@ -1034,7 +1017,11 @@ int saa7134_tvaudio_fini(struct saa7134_dev *dev)
1034 1017
1035int saa7134_tvaudio_do_scan(struct saa7134_dev *dev) 1018int saa7134_tvaudio_do_scan(struct saa7134_dev *dev)
1036{ 1019{
1037 if (dev->thread.pid >= 0) { 1020 if (dev->input->amux != TV) {
1021 dprintk("sound IF not in use, skipping scan\n");
1022 dev->automute = 0;
1023 saa7134_tvaudio_setmute(dev);
1024 } else if (dev->thread.pid >= 0) {
1038 dev->thread.mode = UNSET; 1025 dev->thread.mode = UNSET;
1039 dev->thread.scan2++; 1026 dev->thread.scan2++;
1040 wake_up_interruptible(&dev->thread.wq); 1027 wake_up_interruptible(&dev->thread.wq);