]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/tuner-simple.c
V4L/DVB (3568d): saa7111.c fix
[linux-2.6-omap-h63xx.git] / drivers / media / video / tuner-simple.c
index 907ea8c5d9b3f24f379ccc1790489e07ef836c15..5d7abed71674f179ee6797a21b33ab89ee4ea5ff 100644 (file)
@@ -79,17 +79,6 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
 #define TUNER_PLL_LOCKED   0x40
 #define TUNER_STEREO_MK3   0x04
 
-#define TUNER_PARAM_ANALOG 0  /* to be removed */
-/* FIXME:
- * Right now, all tuners are using the first tuner_params[] array element
- * for analog mode. In the future, we will be merging similar tuner
- * definitions together, such that each tuner definition will have a
- * tuner_params struct for each available video standard. At that point,
- * TUNER_PARAM_ANALOG will be removed, and the tuner_params[] array
- * element will be chosen based on the video standard in use.
- *
- */
-
 /* ---------------------------------------------------------------------- */
 
 static int tuner_getstatus(struct i2c_client *c)
@@ -138,9 +127,9 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
        struct tunertype *tun;
        u8 buffer[4];
        int rc, IFPCoff, i, j;
+       enum param_type desired_type;
 
        tun = &tuners[t->type];
-       j = TUNER_PARAM_ANALOG;
 
        /* IFPCoff = Video Intermediate Frequency - Vif:
                940  =16*58.75  NTSC/J (Japan)
@@ -155,14 +144,30 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
        */
 
        if (t->std == V4L2_STD_NTSC_M_JP) {
-               IFPCoff = 940;
+               IFPCoff      = 940;
+               desired_type = TUNER_PARAM_TYPE_NTSC;
        } else if ((t->std & V4L2_STD_MN) &&
                  !(t->std & ~V4L2_STD_MN)) {
-               IFPCoff = 732;
+               IFPCoff      = 732;
+               desired_type = TUNER_PARAM_TYPE_NTSC;
        } else if (t->std == V4L2_STD_SECAM_LC) {
-               IFPCoff = 543;
+               IFPCoff      = 543;
+               desired_type = TUNER_PARAM_TYPE_SECAM;
        } else {
-               IFPCoff = 623;
+               IFPCoff      = 623;
+               desired_type = TUNER_PARAM_TYPE_PAL;
+       }
+
+       for (j = 0; j < tun->count-1; j++) {
+               if (desired_type != tun->params[j].type)
+                       continue;
+               break;
+       }
+       /* use default tuner_params if desired_type not available */
+       if (desired_type != tun->params[j].type) {
+               tuner_dbg("IFPCoff = %d: tuner_params undefined for tuner %d\n",
+                         IFPCoff,t->type);
+               j = 0;
        }
 
        for (i = 0; i < tun->params[j].count; i++) {
@@ -180,7 +185,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
        /*  i == 0 -> VHF_LO
         *  i == 1 -> VHF_HI
         *  i == 2 -> UHF     */
-       tuner_dbg("tv: range %d\n",i);
+       tuner_dbg("tv: param %d, range %d\n",j,i);
 
        div=freq + IFPCoff + offset;
 
@@ -333,9 +338,18 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
        u8 buffer[4];
        u16 div;
        int rc, j;
+       enum param_type desired_type = TUNER_PARAM_TYPE_RADIO;
 
        tun = &tuners[t->type];
-       j = TUNER_PARAM_ANALOG;
+
+       for (j = 0; j < tun->count-1; j++) {
+               if (desired_type != tun->params[j].type)
+                       continue;
+               break;
+       }
+       /* use default tuner_params if desired_type not available */
+       if (desired_type != tun->params[j].type)
+               j = 0;
 
        div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */
        buffer[2] = (tun->params[j].ranges[0].config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */
@@ -350,6 +364,9 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
        case TUNER_PHILIPS_FMD1216ME_MK3:
                buffer[3] = 0x19;
                break;
+       case TUNER_TNF_5335MF:
+               buffer[3] = 0x11;
+               break;
        case TUNER_PHILIPS_FM1256_IH3:
                div = (20 * freq) / 16000 + (int)(33.3 * 20);  /* IF 33.3 MHz */
                buffer[3] = 0x19;