[PATCH] V4L: tveeprom MAC address parsing/cleanup

- Added a mac address field to the tveeprom structure.

- allow callers to query the MAC address.

- removed some redundant eeprom parsing code in cx88-cards.c (specific to
  Hauppauge DVB products) Instead, placed calls directly to the single eeprom
  parsing function in tveeprom.c

Signed-off-by: Steven Toth <stoth@hauppauge.com>
Signed-off-by: Michael Krufky <mkrufky@m1k.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index 746ccaf..cf2d2c3 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1083,44 +1083,26 @@
 	tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data);
 	core->tuner_type = tv.tuner_type;
 	core->has_radio  = tv.has_radio;
-}
-
-/* fixme: This is bogus code... add new pnp code to parse or see tveeprom.ko */
-static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
-{
-	int model;
-	int tuner;
 
 	/* Make sure we support the board model */
-	model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c];
-	switch(model) {
+	switch (tv.model)
+	{
 	case 90002: /* Nova-T-PCI (9002) */
 	case 90500: /* Nova-T-PCI (oem) */
 	case 90501: /* Nova-T-PCI (oem/IR) */
-	case 92000: /* Nova-S-Plus */
-	case 92002: /* Nova-SE2 */
+	case 92000: /* Nova-SE2 (OEM, No Video or IR) */
+	case 92001: /* Nova-S-Plus (Video and IR) */
+	case 92002: /* Nova-S-Plus (Video and IR) */
 		/* known */
 		break;
 	default:
 		printk("%s: warning: unknown hauppauge model #%d\n",
-		       core->name, model);
+		       core->name, tv.model);
 		break;
 	}
 
-	/* Make sure we support the tuner */
-	tuner = ee[0x2d];
-	switch(tuner) {
-	case 0x4B: /* dtt 7595 */
-	case 0x4C: /* dtt 7592 */
-		break;
-	default:
-		printk("%s: error: unknown hauppauge tuner 0x%02x\n",
-		       core->name, tuner);
-		return -ENODEV;
-	}
-	printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%d\n",
-	       core->name, model, tuner);
-	return 0;
+	printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
+			core->name, tv.model);
 }
 
 /* ----------------------------------------------------------------------- */
@@ -1204,7 +1186,7 @@
 
 void cx88_card_setup(struct cx88_core *core)
 {
-	static u8 eeprom[128];
+	static u8 eeprom[256];
 
 	if (0 == core->i2c_rc) {
 		core->i2c_client.addr = 0xa0 >> 1;
@@ -1227,7 +1209,7 @@
 		break;
 	case CX88_BOARD_HAUPPAUGE_DVB_T1:
 		if (0 == core->i2c_rc)
-			hauppauge_eeprom_dvb(core,eeprom);
+			hauppauge_eeprom(core,eeprom);
 		break;
 	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
 	case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 72e8741..d6afd91 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -81,7 +81,7 @@
 	{ 0x00000010, " PAL(I)" },
 	{ 0x00400000, " SECAM(L/L')" },
 	{ 0x00000e00, " PAL(D/K)" },
-	{ 0x03000000, " ATSC Digital" },
+	{ 0x03000000, " ATSC/DVB Digital" },
 };
 
 /* This is the full list of possible tuners. Many thanks to Hauppauge for
@@ -216,6 +216,20 @@
 	{ TUNER_ABSENT,        "LG TAPC-W701D"},
 	{ TUNER_ABSENT,        "TCL 9886P-WM"},
 	{ TUNER_ABSENT,        "TCL 1676NM-WM"},
+	/* 110-119 */
+	{ TUNER_ABSENT,        "Thompson DTT75105"},
+	{ TUNER_ABSENT,        "Conexant_CX24109"},
+	{ TUNER_ABSENT,        "TCL M2523_5N_E"},
+	{ TUNER_ABSENT,        "TCL M2523_3DB_E"},
+	{ TUNER_ABSENT,        "Philips 8275A"},
+	{ TUNER_ABSENT,        "Microtune MT2060"},
+	{ TUNER_ABSENT,        "Philips FM1236 MK5"},
+	{ TUNER_ABSENT,        "Philips FM1216ME MK5"},
+	{ TUNER_ABSENT,        "TCL M2523_3DI_E"},
+	{ TUNER_ABSENT,        "Samsung THPD5222FG30A"},
+	/* 120-129 */
+	{ TUNER_ABSENT,        "Xceive XC3028"},
+	{ TUNER_ABSENT,        "Philips FQ1216LME MK5"},
 };
 
 static struct HAUPPAUGE_AUDIOIC
@@ -369,9 +383,13 @@
 	done = len = beenhere = 0;
 
 	/* Hack for processing eeprom for em28xx */
-	if ((eeprom_data[0]==0x1a)&&(eeprom_data[1]==0xeb)&&
-				(eeprom_data[2]==0x67)&&(eeprom_data[3]==0x95))
+	if ((eeprom_data[0] == 0x1a) && (eeprom_data[1] == 0xeb) &&
+		(eeprom_data[2] == 0x67) && (eeprom_data[3] == 0x95))
 		start=0xa0;
+	else if ((eeprom_data[0] == 0x1f) && (eeprom_data[8] == 0x84))
+		start=8;
+	else if ((eeprom_data[0] == 0x17) && (eeprom_data[8] == 0x84))
+		start=8;
 	else
 		start=0;
 
@@ -448,6 +466,17 @@
 				eeprom_data[i+5] +
 				(eeprom_data[i+6] << 8) +
 				(eeprom_data[i+7] << 16);
+
+				if ( (eeprom_data[i + 8] && 0xf0) &&
+					(tvee->serial_number < 0xffffff) ) {
+					tvee->MAC_address[0] = 0x00;
+					tvee->MAC_address[1] = 0x0D;
+					tvee->MAC_address[2] = 0xFE;
+					tvee->MAC_address[3] = eeprom_data[i + 7];
+					tvee->MAC_address[4] = eeprom_data[i + 6];
+					tvee->MAC_address[5] = eeprom_data[i + 5];
+					tvee->has_MAC_address = 1;
+				}
 			break;
 
 		case 0x05:
@@ -466,11 +495,14 @@
 		case 0x06:
 			/* tag 'ModelRev' */
 			tvee->model =
-				eeprom_data[i+1] +
-				(eeprom_data[i+2] << 8);
-			tvee->revision = eeprom_data[i+5] +
-				(eeprom_data[i+6] << 8) +
-				(eeprom_data[i+7] << 16);
+				eeprom_data[i + 1] +
+				(eeprom_data[i + 2] << 8) +
+				(eeprom_data[i + 3] << 16) +
+				(eeprom_data[i + 4] << 24);
+			tvee->revision =
+				eeprom_data[i +5 ] +
+				(eeprom_data[i + 6] << 8) +
+				(eeprom_data[i + 7] << 16);
 			break;
 
 		case 0x07:
@@ -578,6 +610,12 @@
 
 	tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n",
 		tvee->model, tvee->rev_str, tvee->serial_number);
+	if (tvee->has_MAC_address == 1) {
+		tveeprom_info("MAC address is %02X-%02X-%02X-%02X-%02X-%02X\n",
+			tvee->MAC_address[0], tvee->MAC_address[1],
+			tvee->MAC_address[2], tvee->MAC_address[3],
+			tvee->MAC_address[4], tvee->MAC_address[5]);
+	}
 	tveeprom_info("tuner model is %s (idx %d, type %d)\n",
 		t_name1, tuner1, tvee->tuner_type);
 	tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n",
diff --git a/include/media/tveeprom.h b/include/media/tveeprom.h
index e2035c7..9793008 100644
--- a/include/media/tveeprom.h
+++ b/include/media/tveeprom.h
@@ -4,6 +4,7 @@
 struct tveeprom {
 	u32 has_radio;
 	u32 has_ir;     /* 0: no IR, 1: IR present, 2: unknown */
+	u32 has_MAC_address; /* 0: no MAC, 1: MAC present, 2: unknown */
 
 	u32 tuner_type;
 	u32 tuner_formats;
@@ -21,6 +22,7 @@
 	u32 revision;
 	u32 serial_number;
 	char rev_str[5];
+	u8 MAC_address[6];
 };
 
 void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,