From: Gerd Knorr <kraxel@bytesex.org>

This is a update for the analof tv tuner module, it adds support for two
new tuner chips.

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/media/video/tuner.c |   46 +++++++++++++++++++++++++++++++++---
 25-akpm/include/media/tuner.h       |    5 +++
 2 files changed, 48 insertions(+), 3 deletions(-)

diff -puN drivers/media/video/tuner.c~v4l-tuner-update drivers/media/video/tuner.c
--- 25/drivers/media/video/tuner.c~v4l-tuner-update	Thu Sep 16 14:40:10 2004
+++ 25-akpm/drivers/media/video/tuner.c	Thu Sep 16 14:40:10 2004
@@ -129,7 +129,8 @@ struct tunertype 
 	unsigned char config; 
 	unsigned short IFPCoff; /* 622.4=16*38.90 MHz PAL, 
 				   732  =16*45.75 NTSCi, 
-				   940  =58.75 NTSC-Japan */
+				   940  =16*58.75 NTSC-Japan
+				   704  =16*44    ATSC */
 };
 
 /*
@@ -244,10 +245,14 @@ static struct tunertype tuners[] = {
 	{ "Panasonic VP27s/ENGE4324D", Panasonic, NTSC,
 	  16*160.00,16*454.00,0x01,0x02,0x08,0xce,940},
         { "LG NTSC (TAPE series)", LGINNOTEK, NTSC,
-          16*170.00, 16*450.00, 0x01,0x02,0x04,0x8e,732 },
+          16*160.00,16*442.00,0x01,0x02,0x04,0xc8,732 },
 
         { "Tenna TNF 8831 BGFF)", Philips, PAL,
           16*161.25,16*463.25,0xa0,0x90,0x30,0x8e,623},
+	{ "Microtune 4042 FI5 ATSC/NTSC dual in", Microtune, NTSC,
+	  16*162.00,16*457.00,0xa2,0x94,0x31,0x8e,732},
+        { "TCL 2002N", TCL, NTSC,
+          16*172.00,16*448.00,0x01,0x02,0x08,0x88,732},
 
 };
 #define TUNERS ARRAY_SIZE(tuners)
@@ -886,8 +891,12 @@ static void default_set_tv_freq(struct i
 			config |= 2;
 		/* FIXME: input */
 		break;
-	}
 
+	case TUNER_MICROTUNE_4042FI5:
+		/* Set the charge pump for fast tuning */
+		tun->config |= 0x40;
+		break;
+	}
 	
 	/*
 	 * Philips FI1216MK2 remark from specification :
@@ -921,6 +930,37 @@ static void default_set_tv_freq(struct i
         if (4 != (rc = i2c_master_send(c,buffer,4)))
                 printk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
 
+	if (t->type == TUNER_MICROTUNE_4042FI5) {
+		// FIXME - this may also work for other tuners
+		unsigned long timeout = jiffies + msecs_to_jiffies(1);
+		u8 status_byte = 0;
+
+		/* Wait until the PLL locks */
+		for (;;) {
+			if (time_after(jiffies,timeout))
+				return;
+			if (1 != (rc = i2c_master_recv(c,&status_byte,1))) {
+				dprintk("tuner: i2c i/o read error: rc == %d (should be 1)\n",rc);
+				break;
+			}
+			/* bit 6 is PLL locked indicator */
+			if (status_byte & 0x40)
+				break;
+			udelay(10);
+		}
+
+		/* Set the charge pump for optimized phase noise figure */
+		tun->config &= ~0x40;
+		buffer[0] = (div>>8) & 0x7f;
+		buffer[1] = div      & 0xff;
+		buffer[2] = tun->config;
+		buffer[3] = config;
+		dprintk("tuner: tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
+			buffer[0],buffer[1],buffer[2],buffer[3]);
+
+		if (4 != (rc = i2c_master_send(c,buffer,4)))
+			dprintk("tuner: i2c i/o error: rc == %d (should be 4)\n",rc);
+	}
 }
 
 static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
diff -puN include/media/tuner.h~v4l-tuner-update include/media/tuner.h
--- 25/include/media/tuner.h~v4l-tuner-update	Thu Sep 16 14:40:10 2004
+++ 25-akpm/include/media/tuner.h	Thu Sep 16 14:40:10 2004
@@ -1,3 +1,4 @@
+
 /* 
     tuner.h - definition for different tuners
 
@@ -69,9 +70,12 @@
 #define TUNER_PHILIPS_ATSC       42
 #define TUNER_PHILIPS_FM1236_MK3 43
 #define TUNER_PHILIPS_4IN1       44	/* ATI TV Wonder Pro - Conexant */
+/* Microtune mergeged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */
 #define TUNER_MICROTUNE_4049FM5  45
 #define TUNER_LG_NTSC_TAPE       47
 #define TUNER_TNF_8831BGFF       48
+#define TUNER_MICROTUNE_4042FI5  49	/* FusionHDTV 3 Gold - 4042 FI5 (3X 8147) */
+#define TUNER_TCL_2002N          50
 
 #define NOTUNER 0
 #define PAL     1	/* PAL_BG */
@@ -91,6 +95,7 @@
 #define Microtune 8
 #define HITACHI 9
 #define Panasonic 10
+#define TCL     11
 
 #define TUNER_SET_TYPE               _IOW('t',1,int)    /* set tuner type */
 #define TUNER_SET_TVFREQ             _IOW('t',2,int)    /* set tv freq */
_