Patch(bttv-0.7.97): Pinnacle PCTV w/ MT2032/TDA9885/6 PAL+NTSC resolved

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi,
this patch makes the PAL variant work perfectly (NTSC and SECAM should
work, but untested). The missing point was, we need to set OP2
on TDA9886, else MT2032 would be disabled after loading tda9887.o
(thanks to Barry for pinpointing this failure mode).

With this patch everything will work out-of-the-box (modulo bugs:-)
- MT2032 is detected automatically
- tda9885/6 is detected and module is loaded automatically
- Pal/Secam/Ntsc will automatically follow your selection in xawtv

Todo:
- FM Radio (untested)

Regards, Gunther
diff -Nur bttv-0.7.97/Cards bttv0797/Cards
--- bttv-0.7.97/Cards	Mon Aug 12 10:38:34 2002
+++ bttv0797/Cards	Fri Sep  6 21:04:26 2002
@@ -275,6 +275,7 @@
    WinView 601 (Bt848)
    WinView 610 (Zoran)
    WinFast2000
+   WinFast2000 XP
 
 KNC One
 -------
@@ -372,6 +373,7 @@
    LR74 is a newer PCB revision of ceb105 (both incl. connector for Active Radio Upgrade)
 
    Cinergy 400 (saa7134), "E877 11(S)", "PM820092D" printed on PCB
+   Cinergy 600 (saa7134)
 
 Technisat
 ---------
@@ -396,6 +398,9 @@
 Powercolor
 ----------
    MTV878
+       Package comes with different contents:
+       a) pcb "MTV878" (CARD=75)
+       b) Pixelview Rev. 4_
    MTV878R w/Remote Control
    MTV878F w/Remote Control w/FM radio
 
@@ -403,10 +408,14 @@
 --------
    Mirovideo PCTV (Bt848)
    Mirovideo PCTV SE (Bt848)
-   Mirovideo PCTV Pro (Bt848 + Daughterboard)
+   Mirovideo PCTV Pro (Bt848 + Daughterboard for TV Stereo and FM)
+   Studio PCTV Rave (Bt848 Version = Mirovideo PCTV)
    Studio PCTV Rave (Bt878 package w/o infrared)
    Studio PCTV      (Bt878)
    Studio PCTV Pro  (Bt878 stereo w/ FM)
+   Pinnacle PCTV    (Bt878, MT2032)
+   Pinnacle PCTV Pro (Bt878, MT2032)
+   Pinncale PCTV Sat
 
    M(J)PEG capture and playback:
    DC1+ (ISA)
@@ -624,7 +633,7 @@
 
 NoBrand
 -------
-   TV Excel = Australian Name for "PV-BT878P+ 8E" or so
+   TV Excel = Australian Name for "PV-BT878P+ 8E" or "878TV Rev.3_"
 
 Mach www.machspeed.com
 ----
@@ -666,6 +675,7 @@
 AITech
 ------
    AITech WaveWatcher TV-PCI = LR26
+   WaveWatcher TVR-202 TV/FM Radio Card (ISA)
 
 MAXRON
 ------
@@ -674,3 +684,9 @@
 www.ids-imaging.de
 ------------------
    Falcon Series (capture only)
+ In USA: http://www.theimagingsource.com/
+   DFG/LC1	
+
+www.sknet-web.co.jp
+-------------------
+   SKnet Monster TV (saa7134)
diff -Nur bttv-0.7.97/Changes bttv0797/Changes
--- bttv-0.7.97/Changes	Wed Aug 28 11:23:47 2002
+++ bttv0797/Changes	Sun Sep  1 22:21:42 2002
@@ -1,3 +1,8 @@
+bttv-0.7.98
+-----------
+ * Support and autodetect Terratec Active Radio Upgrade (TEA5757,OM5610,Matchbox).
+    (Todo: support rds6588 on extra i2c-bus via GPIO)
+    
 
 bttv-0.7.97
 -----------
Binary files bttv-0.7.97/driver/.tuner.c.swp and bttv0797/driver/.tuner.c.swp differ
diff -Nur bttv-0.7.97/driver/bttv-cards.c bttv0797/driver/bttv-cards.c
--- bttv-0.7.97/driver/bttv-cards.c	Wed Aug 28 11:18:30 2002
+++ bttv0797/driver/bttv-cards.c	Sat Sep  7 19:32:04 2002
@@ -58,6 +58,10 @@
 static void fv2000s_audio(struct bttv *btv, struct video_audio *v, int set);
 static void windvr_audio(struct bttv *btv, struct video_audio *v, int set);
 static void rv605_muxsel(struct bttv *btv, unsigned int input);
+static int terratec_active_radio_upgrade(struct bttv *btv);
+static int tea5757_read(struct bttv *btv);
+static int tea5757_write(struct bttv *btv, int value);
+
 
 /* config variables */
 static int triton1=0;
@@ -136,7 +140,7 @@
 
 	{ 0x6606107d, BTTV_WINFAST2000,   "Leadtek WinFast TV 2000" },
 	{ 0x6607107d, BTTV_WINFAST2000,   "Leadtek WinFast VC 100" },
-	{ 0x263610b4, BTTV_STB2,          "STB TV PCI FM, P/N 6000704" },
+	{ 0x263610b4, BTTV_STB2,          "STB TV PCI FM, Gateway P/N 6000704" },
  	{ 0x402010fc, BTTV_GVBCTV3PCI,    "I-O Data Co. GV-BCTV3/PCI" },
 	{ 0x405010fc, BTTV_GVBCTV4PCI,    "I-O Data Co. GV-BCTV4/PCI" },
 	{ 0x407010fc, BTTV_GVBCTV5PCI,    "I-O Data Co. GV-BCTV5/PCI" },
@@ -227,7 +231,7 @@
 	needs_tvaudio:	1,
 	tuner_type:	-1,
 },{
-	name:		"STB",
+	name:		"STB, Gateway P/N 6000699 (bt848)",
 	video_inputs:	3,
 	audio_inputs:	1,
 	tuner:		0,
@@ -237,7 +241,9 @@
 	audiomux:	{ 4, 0, 2, 3, 1},
 	no_msp34xx:	1,
 	needs_tvaudio:	1,
-	tuner_type:	-1,
+	tuner_type:     TUNER_PHILIPS_NTSC,
+	pll:            PLL_28,
+	has_radio:      1,
 },{
 
 /* ---- card 0x04 ---------------------------------- */
@@ -492,16 +498,17 @@
 	pll:		PLL_28,
 	tuner_type:	-1,
 },{
-	name:		"Terratec Terra TV+ Version 1.0 (Bt848)/Vobis TV-Boostar",
+	name:           "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar",
 	video_inputs:	3,
 	audio_inputs:	1,
 	tuner:		0,
 	svhs:		2,
-	gpiomask:	16777215,
+	gpiomask:       0x1f0fff,
 	muxsel:		{ 2, 3, 1, 1},
-	audiomux:	{ 131072, 1, 1638400, 3,4},
-	needs_tvaudio:	1,
-	tuner_type:	-1,
+	audiomux:       { 0x20000, 0x30000, 0x10000, 0, 0x40000},
+	needs_tvaudio:	0,
+	tuner_type:	TUNER_PHILIPS_PAL,
+	audio_hook:     terratv_audio,
 },{
 	name:		"Hauppauge WinCam newer (bt878)",
 	video_inputs:	4,
@@ -527,17 +534,48 @@
 },{
 
 /* ---- card 0x1c ---------------------------------- */
-	name:		"Terratec TerraTV+",
+	name:           "Terratec TerraTV+ Version 1.1 (bt878)",
 	video_inputs:	3,
 	audio_inputs:	1,
 	tuner:		0,
 	svhs:		2,
-	gpiomask:	0x70000,
+	gpiomask:	0x1f0fff,
 	muxsel:		{ 2, 3, 1, 1},
 	audiomux:	{ 0x20000, 0x30000, 0x10000, 0x00000, 0x40000},
-	needs_tvaudio:	1,
+	needs_tvaudio:	0,
 	tuner_type:	TUNER_PHILIPS_PAL,
 	audio_hook:	terratv_audio,
+	/* GPIO wiring:
+               External 20 pin connector (for Active Radio Upgrade board)
+               gpio00: i2c-sda
+               gpio01: i2c-scl
+               gpio02: om5610-data
+               gpio03: om5610-clk
+               gpio04: om5610-wre
+               gpio05: om5610-stereo
+               gpio06: rds6588-davn
+               gpio07: Pin 7 n.c.
+               gpio08: nIOW
+               gpio09+10: nIOR, nSEL ?? (bt878)
+                gpio09: nIOR (bt848)
+                gpio10: nSEL (bt848)
+              Sound Routing:
+               gpio16: u2-A0 (1st 4052bt)
+               gpio17: u2-A1
+               gpio18: u2-nEN
+               gpio19: u4-A0 (2nd 4052)
+               gpio20: u4-A1
+                       u4-nEN - GND
+	    Btspy:
+	  	00000 : Cdrom (internal audio input)
+		10000 : ext. Video audio input
+		20000 : TV Mono
+		a0000 : TV Mono/2
+	       1a0000 : TV Stereo	
+		30000 : Radio
+		40000 : Mute
+       */
+
 },{
 	/* Jannik Fritsch <jannik@xxxxxxxxxxxxxxxxxxxxxxxx> */
 	name:		"Imagenation PXC200",
@@ -585,7 +623,7 @@
 	needs_tvaudio:	0,
 	tuner_type:	4,
 },{
-	name:		"Terratec TerraTValue",
+	name:           "Terratec TerraTValue Version Bt878",
 	video_inputs:	3,
 	audio_inputs:	1,
 	tuner:		0,
@@ -685,7 +723,7 @@
 },{
 
 /* ---- card 0x28 ---------------------------------- */
-	name:		"STB2",
+	name:		"STB TV PCI FM, Gateway P/N 6000704 (bt878)",
 	video_inputs:	3,
 	audio_inputs:	1,
 	tuner:		0,
@@ -695,7 +733,9 @@
 	audiomux:	{ 4, 0, 2, 3, 1},
 	no_msp34xx:	1,
 	needs_tvaudio:	1,
-	tuner_type:	-1,
+	tuner_type:     TUNER_PHILIPS_NTSC,
+	pll:            PLL_28,
+	has_radio:      1,
 },{
 	name:		"AVerMedia TVPhone 98",
 	video_inputs:	3,
@@ -1464,12 +1504,18 @@
 
 static void miro_pinnacle_gpio(struct bttv *btv)
 {
-	int id,msp;
-	
-	id  = ((btread(BT848_GPIO_DATA)>>10) & 31) -1;
+	int id,msp,gpio,outbits;
+
+	outbits = btread(BT848_GPIO_OUT_EN);
+        btwrite(0x00, BT848_GPIO_OUT_EN);
+        udelay(8);  // without this we would see the mask ?
+        gpio=btread(BT848_GPIO_DATA);
+        btwrite(outbits, BT848_GPIO_OUT_EN);
+		
+	id  = ((gpio>>10) & 31) -1;
 	msp = bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx");
 	btv->tuner_type = miro_tunermap[id];
-	if (0 == (btread(BT848_GPIO_DATA) & 0x20)) {
+	if (0 == (gpio & 0x20)) {
 		btv->has_radio = 1;
 		if (!miro_fmtuner[id]) {
 			btv->has_matchbox = 1;
@@ -1488,15 +1534,20 @@
 		if (btv->type == BTTV_PINNACLE)
 			btv->type = BTTV_PINNACLEPRO;
 	}
-	printk(KERN_INFO "bttv%d: miro: id=%d tuner=%d radio=%s stereo=%s\n",
-	       btv->nr, id+1, btv->tuner_type,
+	printk(KERN_INFO "bttv%d: miro: gpio=%6x id=%d tuner=%d radio=%s stereo=%s\n",
+	       btv->nr, gpio, id+1, btv->tuner_type,
 	       !btv->has_radio ? "no" :
 	       (btv->has_matchbox ? "matchbox" : "fmtuner"),
 	       (-1 == msp) ? "no" : "yes");
 
-	if (33 == btv->tuner_type)
-		if (autoload)
-			request_module("msp3400");
+	if(bttv_I2CRead(btv, I2C_TDA9887, "TDA9885,TDA9886,TDA9887") >=0) {
+                if (autoload)
+                        request_module("tda9887");
+		if(btv->tuner_type!= 33) {
+			printk("bttv: tuner corrected to 33.\n");
+			btv->tuner_type=33;
+		}
+	}
 }
 
 /* initialization part one -- before registering i2c bus */
@@ -1566,6 +1617,10 @@
 		btv->mbox_data    = 0x10;
 		btv->mbox_mask    = 0x38;
 		break;
+	case BTTV_VOBIS_BOOSTAR: // Terratec TV+ Bt848
+	case BTTV_TERRATV: // Terratec TV+ Bt878
+		terratec_active_radio_upgrade(btv);
+		break;
 	case BTTV_MAGICTVIEW061:
 		if (btv->cardid == 0x4002144f) {
 			btv->has_radio=1;
@@ -1744,6 +1799,38 @@
 		       btv->tuner_type, radio ? "yes" : "no");
 }
 
+static int terratec_active_radio_upgrade(struct bttv *btv)
+{
+	int r,freq;
+
+	printk("Probing for Terratec Active Radio Upgrade ...\n");
+	btv->has_radio    = 1;
+	btv->has_matchbox = 1;
+	btv->is_terratec_active_radio_upgrade = 1; 
+	btv->mbox_we      = 0x10;
+	btv->mbox_most    = 0x20;
+	btv->mbox_clk     = 0x08;
+	btv->mbox_data    = 0x04;
+	btv->mbox_mask    = 0x3c;
+
+	freq=88000/62.5;
+	tea5757_write(btv, 5 * freq + 0x358); // write 0x1ed8
+	r=tea5757_read(btv);
+
+	if(r == 0x1ed8) {
+		printk("Terratec Active Radio Upgrade found.\n");
+		btv->has_radio    = 1;
+		btv->has_matchbox = 1;
+	}
+	else {
+		printk("Terratec Active Radio Upgrade not found(%x).\n",r);
+		btv->has_radio    = 0;
+	}
+	return 1;
+}	
+
+
+
 /* ----------------------------------------------------------------------- */
 
 /*
@@ -1982,15 +2069,62 @@
  * Brutally hacked by Dan Sheridan <dan.sheridan@xxxxxxxxxxxxxx> djs52 8/3/00
  */
 
-#if 0
-/* bus bits on the GPIO port */
-#define TEA_WE			6
-#define TEA_DATA		9
-#define TEA_CLK			8
-#define TEA_MOST		7
-#endif
+#define TT_ACTIVE_RADIO_IOW (1<<8) 
+#define TT_ACTIVE_RADIO_IOR  (1<<9)
+#define TT_ACTIVE_RADIO_CSEL (1<<10)
 
 #define BUS_LOW(bit) 	btand(~(bit), BT848_GPIO_DATA)
+
+void bus_low(struct bttv *btv, int bit)
+{
+	if(btv->is_terratec_active_radio_upgrade)
+		// set nCSEL, nIOR, nIOW to 1.
+		btor( TT_ACTIVE_RADIO_IOR|TT_ACTIVE_RADIO_IOW|TT_ACTIVE_RADIO_CSEL,
+			BT848_GPIO_DATA);
+	udelay(5);
+	btand(~(bit), BT848_GPIO_DATA);
+	udelay(5);
+
+	if(btv->is_terratec_active_radio_upgrade)
+		// set nCSEL, IOW to 0.
+		btand( ~(TT_ACTIVE_RADIO_IOW|TT_ACTIVE_RADIO_CSEL),
+			BT848_GPIO_DATA);
+}
+
+void bus_high(struct bttv *btv, int bit)
+{
+	if(btv->is_terratec_active_radio_upgrade)
+                // set nCSEL, nIOR, nIOW to 1.
+                btor( TT_ACTIVE_RADIO_IOR|TT_ACTIVE_RADIO_IOW|TT_ACTIVE_RADIO_CSEL,
+                        BT848_GPIO_DATA);
+	udelay(5);
+	btor((bit), BT848_GPIO_DATA);
+	udelay(5);
+
+        if(btv->is_terratec_active_radio_upgrade)
+                // set nCSEL, IOW to 0.
+                btand( ~(TT_ACTIVE_RADIO_IOW|TT_ACTIVE_RADIO_CSEL),
+                        BT848_GPIO_DATA);
+}
+
+int bus_in(struct bttv *btv, int bit)
+{
+	if(btv->is_terratec_active_radio_upgrade) {
+                // set nCSEL, nIOR, nIOW to 1.
+                btor( TT_ACTIVE_RADIO_IOR|TT_ACTIVE_RADIO_IOW|TT_ACTIVE_RADIO_CSEL,
+                        BT848_GPIO_DATA);
+		udelay(5);
+
+                // set nCSEL, IOR to 0.
+		btand( ~(TT_ACTIVE_RADIO_IOR|TT_ACTIVE_RADIO_CSEL),
+                        BT848_GPIO_DATA);
+		udelay(5);
+	}
+
+	return btread(BT848_GPIO_DATA) & (bit);
+}
+
+
 #define BUS_HIGH(bit)	btor((bit), BT848_GPIO_DATA)
 #define BUS_IN(bit)	(btread(BT848_GPIO_DATA) & (bit))
 
@@ -2031,34 +2165,43 @@
 	/* better safe than sorry */
 	btaor((btv->mbox_clk | btv->mbox_we),
 	      ~btv->mbox_mask, BT848_GPIO_OUT_EN);
+
+	if(btv->is_terratec_active_radio_upgrade)
+                btor(TT_ACTIVE_RADIO_IOW | TT_ACTIVE_RADIO_IOR | TT_ACTIVE_RADIO_CSEL,
+                        BT848_GPIO_OUT_EN);
+
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv,"tea5757 read");
 	
-	BUS_LOW(btv->mbox_we);
-	BUS_LOW(btv->mbox_clk);
+	bus_low(btv,btv->mbox_we);
+	bus_low(btv,btv->mbox_clk);
 	
 	udelay(10);
-	for(timeout = jiffies + 10 * HZ;
-	    BUS_IN(btv->mbox_data) && time_before(jiffies, timeout);
-	    schedule());	/* 10 s */
-	if (BUS_IN(btv->mbox_data)) {
+
+	if(btv->is_terratec_active_radio_upgrade)
+		timeout= jiffies + HZ/5;  // fast autodetect
+	else
+		timeout = jiffies + 10 * HZ;  // 10s as before
+
+	// wait for DATA line to go low; error if it doesn't
+	for(; bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout);
+	    schedule());
+	if (bus_in(btv,btv->mbox_data)) {
 		printk(KERN_WARNING "bttv%d: tea5757: read timeout\n",btv->nr);
 		return -1;
 	}
-	for(timeout = jiffies + HZ/5;
-	    BUS_IN(btv->mbox_data) == 1 && time_before(jiffies, timeout);
-	    schedule());	/* 0.2 s */
+
 	dprintk("bttv%d: tea5757:",btv->nr);
 	for(i = 0; i < 24; i++)
 	{
 		udelay(5);
-		BUS_HIGH(btv->mbox_clk);
+		bus_high(btv,btv->mbox_clk);
 		udelay(5);
-		dprintk("%c",(BUS_IN(btv->mbox_most) == 0)?'T':'-');
-		BUS_LOW(btv->mbox_clk);
+		dprintk("%c",(bus_in(btv,btv->mbox_most) == 0)?'T':'-');
+		bus_low(btv,btv->mbox_clk);
 		value <<= 1;
-		value |= (BUS_IN(btv->mbox_data) == 0)?0:1;  /* MSB first */
-		dprintk("%c", (BUS_IN(btv->mbox_most) == 0)?'S':'M');
+		value |= (bus_in(btv,btv->mbox_data) == 0)?0:1;  /* MSB first */
+		dprintk("%c", (bus_in(btv,btv->mbox_most) == 0)?'S':'M');
 	}
 	dprintk("\nbttv%d: tea5757: read 0x%X\n", btv->nr, value);
 	return value;
@@ -2071,32 +2214,39 @@
 	
 	btaor(btv->mbox_clk | btv->mbox_we | btv->mbox_data,
 	      ~btv->mbox_mask, BT848_GPIO_OUT_EN);
+
+	if(btv->is_terratec_active_radio_upgrade)
+		btor(TT_ACTIVE_RADIO_IOW | TT_ACTIVE_RADIO_IOR | TT_ACTIVE_RADIO_CSEL,
+			BT848_GPIO_OUT_EN);
 	if (bttv_gpio)
 		bttv_gpio_tracking(btv,"tea5757 write");
 	dprintk("bttv%d: tea5757: write 0x%X\n", btv->nr, value);
-	BUS_LOW(btv->mbox_clk);
-	BUS_HIGH(btv->mbox_we);
+	bus_low(btv,btv->mbox_clk);
+	bus_high(btv,btv->mbox_we);
 	for(i = 0; i < 25; i++)
 	{
 		if (reg & 0x1000000)
-			BUS_HIGH(btv->mbox_data);
+			bus_high(btv,btv->mbox_data);
 		else
-			BUS_LOW(btv->mbox_data);
+			bus_low(btv,btv->mbox_data);
 		reg <<= 1;
-		BUS_HIGH(btv->mbox_clk);
+		bus_high(btv,btv->mbox_clk);
 		udelay(10);
-		BUS_LOW(btv->mbox_clk);
+		bus_low(btv,btv->mbox_clk);
 		udelay(10);
 	}
-	BUS_LOW(btv->mbox_we);  /* unmute !!! */
+	bus_low(btv,btv->mbox_we);  /* unmute !!! */
 	return 0;
 }
 
 void tea5757_set_freq(struct bttv *btv, unsigned short freq)
 {
+	dprintk("tea5757_set_freq %d\n",freq);
 	tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */
-	if (bttv_debug)
-		tea5757_read(btv);
+	if (bttv_debug || btv->is_terratec_active_radio_upgrade) 
+		// Terratec stays muted if we don't read back !?
+		printk("bttv%d: tea5757 readback =0x%x\n",btv->nr,tea5757_read(btv));
+	
 }
 
 
@@ -2236,7 +2386,7 @@
         }
 }
 
-
+// TDA9821 on TerraTV+ Bt848, Bt878
 static void
 terratv_audio(struct bttv *btv, struct video_audio *v, int set)
 {
diff -Nur bttv-0.7.97/driver/bttv.h bttv0797/driver/bttv.h
--- bttv-0.7.97/driver/bttv.h	Mon Aug 19 14:09:10 2002
+++ bttv0797/driver/bttv.h	Sat Sep  7 19:27:33 2002
@@ -107,6 +107,7 @@
 #define I2C_MSP3400        0x80
 #define I2C_TEA6300        0x80
 #define I2C_DPL3518	   0x84
+#define I2C_TDA9887	   0x86
 
 /* more card-specific defines */
 #define PT2254_L_CHANNEL 0x10
diff -Nur bttv-0.7.97/driver/bttvp.h bttv0797/driver/bttvp.h
--- bttv-0.7.97/driver/bttvp.h	Mon Aug 12 10:36:50 2002
+++ bttv0797/driver/bttvp.h	Sat Aug 31 19:10:59 2002
@@ -161,6 +161,11 @@
 	int mbox_most;
 	int mbox_mask;
 
+	/* Terratec Active Radio Upgrade has Matchbox aka OM5610 aka tea5757.
+	   But it uses the same clue chip it inherited from it's ISA implementation
+	   so we must set nSELECT, nIOR and nIOW ourselves*/
+	int is_terratec_active_radio_upgrade;
+
 	u32 *risc_jmp;
 	u32 *vbi_odd;
 	u32 *vbi_even;
diff -Nur bttv-0.7.97/driver/tda9887.c bttv0797/driver/tda9887.c
--- bttv-0.7.97/driver/tda9887.c	Tue Aug 27 12:52:00 2002
+++ bttv0797/driver/tda9887.c	Sat Sep  7 19:22:15 2002
@@ -10,6 +10,17 @@
 #include "id.h"
 #include "audiochip.h"
 
+/* Chips:
+   TDA9885 (PAL, NTSC)
+   TDA9886 (PAL, SECAM, NTSC)
+   TDA9887 (PAL, SECAM, NTSC, FM Radio)
+
+   found on:
+   - Pinnacle PCTV (Jul.2002 Version with MT2032): TDA9887 (world), TDA9885 (USA)
+      Note: OP2 of tda988x must be set to 1, else MT2032 is disabled!
+*/
+    
+
 /* Addresses to scan */
 static unsigned short normal_i2c[] = {I2C_CLIENT_END};
 static unsigned short normal_i2c_range[] = {0x86>>1,0x86>>1,I2C_CLIENT_END};
@@ -42,20 +53,27 @@
 
 /* ---------------------------------------------------------------------- */
 
-static unsigned char buf_pal_bg[]    = { 0x00, 0x16, 0x70, 0x49 };
-static unsigned char buf_pal_i[]     = { 0x00, 0x16, 0x70, 0x4a };
-static unsigned char buf_pal_dk[]    = { 0x00, 0x16, 0x70, 0x4b };
-static unsigned char buf_pal_l[]     = { 0x00, 0x06, 0x50, 0x4b };
-static unsigned char buf_fm_stereo[] = { 0x00, 0x0e, 0x0d, 0x77 };
+static unsigned char buf_pal_bg[]    = { 0x00, 0x96, 0x70, 0x49 };
+static unsigned char buf_pal_i[]     = { 0x00, 0x96, 0x70, 0x4a };
+static unsigned char buf_pal_dk[]    = { 0x00, 0x96, 0x70, 0x4b };
+static unsigned char buf_pal_l[]     = { 0x00, 0x86, 0x50, 0x4b };
+static unsigned char buf_fm_stereo[] = { 0x00, 0x8e, 0x0d, 0x77 };
+static unsigned char buf_ntsc[]	     = { 0x00, 0x96, 0x70, 0x44 }; // 45.75 Vif, Sif-4.5Mhz
+static unsigned char buf_ntsc_jp[]   = { 0x00, 0x96, 0x70, 0x40 }; // 58.75 Vif
 
 static int tda9887_configure(struct tda9887 *t)
 {
 	unsigned char *buf = NULL;
 	int rc;
 
-	if (t->radio)
+	printk("tda9887_configure\n");
+
+	if (t->radio) {
+		if(debug) printk("tda9885/6/7: FM Radio mode\n");
 		buf = buf_fm_stereo;
+	}
 	else if (t->tvnorm == VIDEO_MODE_PAL) {
+		if(debug) printk("tda9885/6/7: PAL mode\n");
 		switch (pal[0]) {
 		case 'b':
 		case 'g':
@@ -73,8 +91,23 @@
 			break;
 		}
 	}
-	if (NULL == buf)
+	else if (t->tvnorm == VIDEO_MODE_NTSC) {
+		if(debug) printk("tda9885/6/7: NTSC mode\n");
+		buf = buf_ntsc;
+	}
+	else if (t->tvnorm == VIDEO_MODE_SECAM) {
+                if(debug) printk("tda9885/6/7: SECAM mode\n");
+                buf = buf_pal_l;
+        }
+	else if (t->tvnorm == 6) {
+                if(debug) printk("tda9885/6/7: NTSC-Japan mode\n");
+                buf = buf_ntsc;
+        }
+
+	if (NULL == buf) {
+		printk("tda988x unknown norm=%d\n",t->tvnorm);
 		return 0;
+	}
 
 	if (debug)
 		printk("tda9887: 0x%02x 0x%02x 0x%02x 0x%02x\n",
diff -Nur bttv-0.7.97/driver/tuner.c bttv0797/driver/tuner.c
--- bttv-0.7.97/driver/tuner.c	Wed Aug  7 14:09:47 2002
+++ bttv0797/driver/tuner.c	Sat Sep  7 19:40:48 2002
@@ -127,7 +127,9 @@
 	unsigned char VHF_H;
 	unsigned char UHF;
 	unsigned char config; 
-	unsigned short IFPCoff; /* 622.4=16*38.90 MHz PAL, 732=16*45.75 NTSC */
+	unsigned short IFPCoff; /* 622.4=16*38.90 MHz PAL, 
+				   732  =16*45.75 NTSCi, 
+				   940  =58.75 NTSC-Japan */
 };
 
 /*
@@ -303,6 +305,13 @@
                 }
                 printk("\n ");
         }
+	// Look for MT2032 id:
+	// part= 0x04(MT2032), 0x06(MT2030), 0x07(MT2040)
+        if((buf[0x11] != 0x4d) || (buf[0x12] != 0x54) || (buf[0x13] != 0x04)) {
+                printk("not a MT2032.\n");
+                return 0;
+        }
+
 
         // Initialize Registers per spec.
         buf[1]=2; // Index to register 2
@@ -865,12 +874,14 @@
 
 	/* --- configuration --- */
 	case TUNER_SET_TYPE:
-		if (t->type != -1)
+		if (t->type != -1) {
+			printk("tuner: type already set\n");
 			return 0;
+		}
 		if (*iarg < 0 || *iarg >= TUNERS)
 			return 0;
 		t->type = *iarg;
-		dprintk("tuner: type set to %d (%s)\n",
+		printk("tuner: type set to %d (%s)\n",
                         t->type,tuners[t->type].name);
 		strncpy(client->name, tuners[t->type].name, sizeof(client->name));
 		if (t->type == TUNER_MT2032)
@@ -973,7 +984,7 @@
 };
 static struct i2c_client client_template =
 {
-        name:   "(unset)",
+        name:   "(tuner unset)",
 	flags:  I2C_CLIENT_ALLOW_USE,
         driver: &driver,
 };
diff -Nur bttv-0.7.97/tools/detect.c bttv0797/tools/detect.c
--- bttv-0.7.97/tools/detect.c	Tue Oct 23 15:23:36 2001
+++ bttv0797/tools/detect.c	Fri Sep  6 19:24:15 2002
@@ -25,6 +25,7 @@
     { 0x34, "Hauppauge IR (pic16c54 external)" },
     { 0x80, "msp34xx/tea6300 sound processor" },
     { 0x82, "TDA8425 audio chip" },
+    { 0x86, "TDA9885/TDA9886/TDA9887 tv and sound demodulator" }
     { 0xa0, "eeprom (bt878, Hauppauge-848)" },
     { 0xb6, "TDA9850/TDA9873/etc. audio chip" },
     { 0xc0, "tuner" },

[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux