V4L/DVB (7651): tuner-xc2028: Several fixes to SCODE

This patch fixes several issues on SCODE:

1) The extracting tool weren't generating the proper tags for SCODE. This
   has almost no effect, since those tags shouldn't be used;

2) DIBCOM52 were using a wrong IF. It should be 5200, instead of 5700;

3) seek_firmware were wanting an exact match for firmware type. This is
   wrong. As result, no SCODE firmware were loaded;

4) A few files were including the wrong file for seeking demod firmwares;

5) XC3028_FE_DEFAULT can be used, if user doesn't want to load a firmware.
   However, this weren't documentated. This feature require more testing.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index c4b0066..720fcd1 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -33,7 +33,6 @@
 #include "mt352_priv.h"
 #include "zl10353.h"
 #include "tuner-xc2028.h"
-#include "tuner-xc2028-types.h"
 #include "tuner-simple.h"
 
 /* debug */
@@ -521,7 +520,7 @@
 	static struct xc2028_ctrl ctl = {
 		.fname       = "xc3028-dvico-au-01.fw",
 		.max_len     = 64,
-		.scode_table = ZARLINK456,
+		.scode_table = XC3028_FE_ZARLINK456,
 	};
 
 	fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index a1086c8..1b9a85e 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -39,7 +39,6 @@
 #include "tda10048.h"
 #include "dvb-pll.h"
 #include "tuner-xc2028.h"
-#include "tuner-xc2028-types.h"
 #include "tuner-simple.h"
 
 static unsigned int debug;
@@ -320,7 +319,7 @@
 			static struct xc2028_ctrl ctl = {
 				.fname       = "xc3028-v27.fw",
 				.max_len     = 64,
-				.scode_table = OREN538,
+				.scode_table = XC3028_FE_OREN538,
 			};
 
 			fe = dvb_attach(xc2028_attach,
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index fda7334..f1251b8 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -45,7 +45,6 @@
 #include "nxt200x.h"
 #include "cx24123.h"
 #include "isl6421.h"
-#include "tuner-xc2028-types.h"
 #include "tuner-simple.h"
 #include "tda9887.h"
 
@@ -813,7 +812,7 @@
 			static struct xc2028_ctrl ctl = {
 				.fname       = "xc3028-v27.fw",
 				.max_len     = 64,
-				.scode_table = OREN538,
+				.scode_table = XC3028_FE_OREN538,
 			};
 
 			fe = dvb_attach(xc2028_attach,
diff --git a/drivers/media/video/tuner-xc2028-types.h b/drivers/media/video/tuner-xc2028-types.h
index d0057fb..17633c3 100644
--- a/drivers/media/video/tuner-xc2028-types.h
+++ b/drivers/media/video/tuner-xc2028-types.h
@@ -1,6 +1,9 @@
 /* tuner-xc2028_types
  *
- * Copyright (c) 2007 Mauro Carvalho Chehab (mchehab@infradead.org)
+ * This file includes internal tipes to be used inside tuner-xc2028.
+ * Shouldn't be included outside tuner-xc2028
+ *
+ * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org)
  * This code is placed under the terms of the GNU General Public License v2
  */
 
@@ -85,11 +88,16 @@
 /* This flag identifies that the scode table has a new format */
 #define HAS_IF         (1 << 30)
 
-#define SCODE_TYPES	(MTS|DTV6|QAM|DTV7|DTV78|DTV8|LCD|NOGD|MONO|ATSC|IF| \
-			 LG60|ATI638|OREN538|OREN36|TOYOTA388|TOYOTA794|     \
-			 DIBCOM52|ZARLINK456|CHINA|F6MHZ|SCODE)
+#define SCODE_TYPES SCODE
 
-/* Newer types to be moved to videodev2.h */
+
+/* Newer types not defined on videodev2.h.
+   The original idea were to move all those types to videodev2.h, but
+   it seemed overkill, since, with the exception of SECAM/K3, the other
+   types seem to be autodetected.
+   It is not clear where secam/k3 is used, nor we have a feedback of this
+   working or being autodetected by the standard secam firmware.
+ */
 
 #define V4L2_STD_SECAM_K3	(0x04000000)
 
diff --git a/drivers/media/video/tuner-xc2028.c b/drivers/media/video/tuner-xc2028.c
index 9dd688e..0e580bc 100644
--- a/drivers/media/video/tuner-xc2028.c
+++ b/drivers/media/video/tuner-xc2028.c
@@ -1,6 +1,6 @@
 /* tuner-xc2028
  *
- * Copyright (c) 2007 Mauro Carvalho Chehab (mchehab@infradead.org)
+ * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org)
  *
  * Copyright (c) 2007 Michel Ludwig (michel.ludwig@gmail.com)
  *       - frontend interface
@@ -404,7 +404,7 @@
 {
 	struct xc2028_data *priv = fe->tuner_priv;
 	int                 i, best_i = -1, best_nr_matches = 0;
-	unsigned int        ign_firm_type_mask = 0;
+	unsigned int        type_mask = 0;
 
 	tuner_dbg("%s called, want type=", __func__);
 	if (debug) {
@@ -421,18 +421,23 @@
 		*id = V4L2_STD_PAL;
 
 	if (type & BASE)
-		type &= BASE_TYPES;
+		type_mask = BASE_TYPES;
 	else if (type & SCODE) {
 		type &= SCODE_TYPES;
-		ign_firm_type_mask = HAS_IF;
+		type_mask = SCODE_TYPES & ~HAS_IF;
 	} else if (type & DTV_TYPES)
-		type &= DTV_TYPES;
+		type_mask = DTV_TYPES;
 	else if (type & STD_SPECIFIC_TYPES)
-		type &= STD_SPECIFIC_TYPES;
+		type_mask = STD_SPECIFIC_TYPES;
+
+	type &= type_mask;
+
+	if (!type & SCODE)
+		type_mask = ~0;
 
 	/* Seek for exact match */
 	for (i = 0; i < priv->firm_size; i++) {
-		if ((type == (priv->firm[i].type & ~ign_firm_type_mask)) &&
+		if ((type == (priv->firm[i].type & type_mask)) &&
 		    (*id == priv->firm[i].id))
 			goto found;
 	}
@@ -442,7 +447,7 @@
 		v4l2_std_id match_mask;
 		int nr_matches;
 
-		if (type != (priv->firm[i].type & ~ign_firm_type_mask))
+		if (type != (priv->firm[i].type & type_mask))
 			continue;
 
 		match_mask = *id & priv->firm[i].id;
diff --git a/drivers/media/video/tuner-xc2028.h b/drivers/media/video/tuner-xc2028.h
index 612e490..fc2f132 100644
--- a/drivers/media/video/tuner-xc2028.h
+++ b/drivers/media/video/tuner-xc2028.h
@@ -1,6 +1,6 @@
 /* tuner-xc2028
  *
- * Copyright (c) 2007 Mauro Carvalho Chehab (mchehab@infradead.org)
+ * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org)
  * This code is placed under the terms of the GNU General Public License v2
  */
 
@@ -12,7 +12,7 @@
 #define XC2028_DEFAULT_FIRMWARE "xc3028-v27.fw"
 
 /*      Dmoduler		IF (kHz) */
-#define	XC3028_FE_DEFAULT	0
+#define	XC3028_FE_DEFAULT	0		/* Don't load SCODE */
 #define XC3028_FE_LG60		6000
 #define	XC3028_FE_ATI638	6380
 #define	XC3028_FE_OREN538	5380