include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / media / dvb / frontends / dvb-pll.c
index b2491f1..4d4d0bb 100644 (file)
@@ -18,6 +18,7 @@
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/dvb/frontend.h>
 #include <asm/types.h>
@@ -48,10 +49,6 @@ static int debug;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "enable verbose debug messages");
 
-static unsigned int input[DVB_PLL_MAX] = { [ 0 ... (DVB_PLL_MAX-1) ] = 0 };
-module_param_array(input, int, NULL, 0644);
-MODULE_PARM_DESC(input,"specify rf input choice, 0 for autoselect (default)");
-
 static unsigned int id[DVB_PLL_MAX] =
        { [ 0 ... (DVB_PLL_MAX-1) ] = DVB_PLL_UNDEFINED };
 module_param_array(id, int, NULL, 0644);
@@ -80,7 +77,6 @@ struct dvb_pll_desc {
 /* ----------------------------------------------------------- */
 /* descriptions                                                */
 
-
 static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
        .name  = "Thomson dtt7579",
        .min   = 177000000,
@@ -96,7 +92,6 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
        },
 };
 
-
 static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf,
                               const struct dvb_frontend_parameters *params)
 {
@@ -137,7 +132,6 @@ static struct dvb_pll_desc dvb_pll_lg_z201 = {
        },
 };
 
-
 static struct dvb_pll_desc dvb_pll_unknown_1 = {
        .name  = "unknown 1", /* used by dntv live dvb-t */
        .min   = 174000000,
@@ -246,7 +240,6 @@ static struct dvb_pll_desc dvb_pll_tua6034 = {
        },
 };
 
-
 /* ALPS TDED4
  * used in Nebula-Cards and USB boxes
  */
@@ -289,55 +282,6 @@ static struct dvb_pll_desc dvb_pll_tdhu2 = {
        }
 };
 
-/* Philips TUV1236D
- * used in ATI HDTV Wonder
- */
-static void tuv1236d_rf(struct dvb_frontend *fe, u8 *buf,
-                       const struct dvb_frontend_parameters *params)
-{
-       struct dvb_pll_priv *priv = fe->tuner_priv;
-       unsigned int new_rf = input[priv->nr];
-
-       if ((new_rf == 0) || (new_rf > 2)) {
-               switch (params->u.vsb.modulation) {
-                       case QAM_64:
-                       case QAM_256:
-                               new_rf = 1;
-                               break;
-                       case VSB_8:
-                       default:
-                               new_rf = 2;
-               }
-       }
-
-       switch (new_rf) {
-               case 1:
-                       buf[3] |= 0x08;
-                       break;
-               case 2:
-                       buf[3] &= ~0x08;
-                       break;
-               default:
-                       printk(KERN_WARNING
-                              "%s: unhandled rf input selection: %d",
-                              __FUNCTION__, new_rf);
-       }
-}
-
-static struct dvb_pll_desc dvb_pll_tuv1236d = {
-       .name  = "Philips TUV1236D",
-       .min   =  54000000,
-       .max   = 864000000,
-       .iffreq= 44000000,
-       .set   = tuv1236d_rf,
-       .count = 3,
-       .entries = {
-               { 157250000, 62500, 0xc6, 0x41 },
-               { 454000000, 62500, 0xc6, 0x42 },
-               { 999999999, 62500, 0xc6, 0x44 },
-       },
-};
-
 /* Samsung TBMV30111IN / TBMV30712IN1
  * used in Air2PC ATSC - 2nd generation (nxt2002)
  */
@@ -368,14 +312,12 @@ static struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
        .count = 4,
        .entries = {
                { 1250000, 500, 0xc4, 0x00},
-               { 1550000, 500, 0xc4, 0x40},
+               { 1450000, 500, 0xc4, 0x40},
                { 2050000, 500, 0xc4, 0x80},
                { 2150000, 500, 0xc4, 0xc0},
        },
 };
 
-
-
 static void opera1_bw(struct dvb_frontend *fe, u8 *buf,
                      const struct dvb_frontend_parameters *params)
 {
@@ -402,6 +344,122 @@ static struct dvb_pll_desc dvb_pll_opera1 = {
        }
 };
 
+static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf,
+                      const struct dvb_frontend_parameters *params)
+{
+       struct dvb_pll_priv *priv = fe->tuner_priv;
+       struct i2c_msg msg = {
+               .addr = priv->pll_i2c_address,
+               .flags = 0,
+               .buf = buf,
+               .len = 4
+       };
+       int result;
+
+       if (fe->ops.i2c_gate_ctrl)
+               fe->ops.i2c_gate_ctrl(fe, 1);
+
+       result = i2c_transfer(priv->i2c, &msg, 1);
+       if (result != 1)
+               printk(KERN_ERR "%s: i2c_transfer failed:%d",
+                       __func__, result);
+
+       buf[2] = 0x9e;
+       buf[3] = 0x90;
+
+       return;
+}
+
+/* unknown pll used in Samsung DTOS403IH102A DVB-C tuner */
+static struct dvb_pll_desc dvb_pll_samsung_dtos403ih102a = {
+       .name   = "Samsung DTOS403IH102A",
+       .min    =  44250000,
+       .max    = 858000000,
+       .iffreq =  36125000,
+       .count  = 8,
+       .set    = samsung_dtos403ih102a_set,
+       .entries = {
+               { 135000000, 62500, 0xbe, 0x01 },
+               { 177000000, 62500, 0xf6, 0x01 },
+               { 370000000, 62500, 0xbe, 0x02 },
+               { 450000000, 62500, 0xf6, 0x02 },
+               { 466000000, 62500, 0xfe, 0x02 },
+               { 538000000, 62500, 0xbe, 0x08 },
+               { 826000000, 62500, 0xf6, 0x08 },
+               { 999999999, 62500, 0xfe, 0x08 },
+       }
+};
+
+/* Samsung TDTC9251DH0 DVB-T NIM, as used on AirStar 2 */
+static struct dvb_pll_desc dvb_pll_samsung_tdtc9251dh0 = {
+       .name   = "Samsung TDTC9251DH0",
+       .min    =  48000000,
+       .max    = 863000000,
+       .iffreq =  36166667,
+       .count  = 3,
+       .entries = {
+               { 157500000, 166667, 0xcc, 0x09 },
+               { 443000000, 166667, 0xcc, 0x0a },
+               { 863000000, 166667, 0xcc, 0x08 },
+       }
+};
+
+/* Samsung TBDU18132 DVB-S NIM with TSA5059 PLL, used in SkyStar2 DVB-S 2.3 */
+static struct dvb_pll_desc dvb_pll_samsung_tbdu18132 = {
+       .name = "Samsung TBDU18132",
+       .min    =  950000,
+       .max    = 2150000, /* guesses */
+       .iffreq = 0,
+       .count = 2,
+       .entries = {
+               { 1550000, 125, 0x84, 0x82 },
+               { 4095937, 125, 0x84, 0x80 },
+       }
+       /* TSA5059 PLL has a 17 bit divisor rather than the 15 bits supported
+        * by this driver.  The two extra bits are 0x60 in the third byte.  15
+        * bits is enough for over 4 GHz, which is enough to cover the range
+        * of this tuner.  We could use the additional divisor bits by adding
+        * more entries, e.g.
+        { 0x0ffff * 125 + 125/2, 125, 0x84 | 0x20, },
+        { 0x17fff * 125 + 125/2, 125, 0x84 | 0x40, },
+        { 0x1ffff * 125 + 125/2, 125, 0x84 | 0x60, }, */
+};
+
+/* Samsung TBMU24112 DVB-S NIM with SL1935 zero-IF tuner */
+static struct dvb_pll_desc dvb_pll_samsung_tbmu24112 = {
+       .name = "Samsung TBMU24112",
+       .min    =  950000,
+       .max    = 2150000, /* guesses */
+       .iffreq = 0,
+       .count = 2,
+       .entries = {
+               { 1500000, 125, 0x84, 0x18 },
+               { 9999999, 125, 0x84, 0x08 },
+       }
+};
+
+/* Alps TDEE4 DVB-C NIM, used on Cablestar 2 */
+/* byte 4 : 1  *   *   AGD R3  R2  R1  R0
+ * byte 5 : C1 *   RE  RTS BS4 BS3 BS2 BS1
+ * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95
+ * Range(MHz)  C1 *  RE RTS BS4 BS3 BS2 BS1  Byte 5
+ *  47 - 153   0  *  0   0   0   0   0   1   0x01
+ * 153 - 430   0  *  0   0   0   0   1   0   0x02
+ * 430 - 822   0  *  0   0   1   0   0   0   0x08
+ * 822 - 862   1  *  0   0   1   0   0   0   0x88 */
+static struct dvb_pll_desc dvb_pll_alps_tdee4 = {
+       .name = "ALPS TDEE4",
+       .min    =  47000000,
+       .max    = 862000000,
+       .iffreq =  36125000,
+       .count = 4,
+       .entries = {
+               { 153000000, 62500, 0x95, 0x01 },
+               { 430000000, 62500, 0x95, 0x02 },
+               { 822000000, 62500, 0x95, 0x08 },
+               { 999999999, 62500, 0x95, 0x88 },
+       }
+};
 
 /* ----------------------------------------------------------- */
 
@@ -416,11 +474,15 @@ static struct dvb_pll_desc *pll_list[] = {
        [DVB_PLL_TUA6034]                = &dvb_pll_tua6034,
        [DVB_PLL_TDA665X]                = &dvb_pll_tda665x,
        [DVB_PLL_TDED4]                  = &dvb_pll_tded4,
-       [DVB_PLL_TUV1236D]               = &dvb_pll_tuv1236d,
+       [DVB_PLL_TDEE4]                  = &dvb_pll_alps_tdee4,
        [DVB_PLL_TDHU2]                  = &dvb_pll_tdhu2,
        [DVB_PLL_SAMSUNG_TBMV]           = &dvb_pll_samsung_tbmv,
        [DVB_PLL_PHILIPS_SD1878_TDA8261] = &dvb_pll_philips_sd1878_tda8261,
        [DVB_PLL_OPERA1]                 = &dvb_pll_opera1,
+       [DVB_PLL_SAMSUNG_DTOS403IH102A]  = &dvb_pll_samsung_dtos403ih102a,
+       [DVB_PLL_SAMSUNG_TDTC9251DH0]    = &dvb_pll_samsung_tdtc9251dh0,
+       [DVB_PLL_SAMSUNG_TBDU18132]      = &dvb_pll_samsung_tbdu18132,
+       [DVB_PLL_SAMSUNG_TBMU24112]      = &dvb_pll_samsung_tbmu24112,
 };
 
 /* ----------------------------------------------------------- */
@@ -666,20 +728,6 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,
                       id[priv->nr] == pll_desc_id ?
                                "insmod option" : "autodetected");
        }
-       if ((debug) || (input[priv->nr] > 0)) {
-               printk("dvb-pll[%d]", priv->nr);
-               if (i2c != NULL)
-                       printk(" %d-%04x", i2c_adapter_id(i2c), pll_addr);
-               printk(": tuner rf input will be ");
-               switch (input[priv->nr]) {
-               case 0:
-                       printk("autoselected\n");
-                       break;
-               default:
-                       printk("set to input %d (insmod option)\n",
-                              input[priv->nr]);
-               }
-       }
 
        return fe;
 }