]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/tuner-simple.c
V4L/DVB (5842): ivtv: Add locking to ensure stream setup is atomic.
[linux-2.6-omap-h63xx.git] / drivers / media / video / tuner-simple.c
index abe37cf632c6845eabab734962e631e78dda5342..2d57e8bc0db3467e406d184d80647582abf2c0c8 100644 (file)
@@ -8,9 +8,11 @@
 #include <linux/videodev.h>
 #include <media/tuner.h>
 #include <media/v4l2-common.h>
+#include <media/tuner-types.h>
+#include "tuner-driver.h"
 
 static int offset = 0;
-module_param(offset, int, 0666);
+module_param(offset, int, 0664);
 MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
 
 /* ---------------------------------------------------------------------- */
@@ -54,9 +56,9 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
     sound 2          33.16  -      -
     NICAM            33.05  33.05  39.80
  */
-#define PHILIPS_MF_SET_BG      0x01 /* Bit 2 must be zero, Bit 3 is system output */
-#define PHILIPS_MF_SET_PAL_L   0x03 // France
-#define PHILIPS_MF_SET_PAL_L2  0x02 // L'
+#define PHILIPS_MF_SET_STD_BG  0x01 /* Bit 2 must be zero, Bit 3 is system output */
+#define PHILIPS_MF_SET_STD_L   0x03 /* Used on Secam France */
+#define PHILIPS_MF_SET_STD_LC  0x02 /* Used on SECAM L' */
 
 /* Control byte */
 
@@ -108,6 +110,7 @@ static int tuner_stereo(struct i2c_client *c)
                case TUNER_PHILIPS_FM1216ME_MK3:
                case TUNER_PHILIPS_FM1236_MK3:
                case TUNER_PHILIPS_FM1256_IH3:
+               case TUNER_LG_NTSC_TAPE:
                        stereo = ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
                        break;
                default:
@@ -204,9 +207,13 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
                /* 0x01 -> ??? no change ??? */
                /* 0x02 -> PAL BDGHI / SECAM L */
                /* 0x04 -> ??? PAL others / SECAM others ??? */
-               cb &= ~0x02;
-               if (t->std & V4L2_STD_SECAM)
-                       cb |= 0x02;
+               cb &= ~0x03;
+               if (t->std & V4L2_STD_SECAM_L) //also valid for V4L2_STD_SECAM
+                       cb |= PHILIPS_MF_SET_STD_L;
+               else if (t->std & V4L2_STD_SECAM_LC)
+                       cb |= PHILIPS_MF_SET_STD_LC;
+               else /* V4L2_STD_B|V4L2_STD_GH */
+                       cb |= PHILIPS_MF_SET_STD_BG;
                break;
 
        case TUNER_TEMIC_4046FM5:
@@ -331,6 +338,8 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
                        else if (params->default_top_high)
                                config |= TDA9887_TOP(params->default_top_high);
                }
+               if (params->default_pll_gating_18)
+                       config |= TDA9887_GATING_18;
                i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config);
        }
        tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
@@ -419,6 +428,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
        case TUNER_PHILIPS_FM1216ME_MK3:
        case TUNER_PHILIPS_FM1236_MK3:
        case TUNER_PHILIPS_FMD1216ME_MK3:
+       case TUNER_LG_NTSC_TAPE:
                buffer[3] = 0x19;
                break;
        case TUNER_TNF_5335MF:
@@ -439,8 +449,6 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
                buffer[3] = 0xa4;
                break;
        }
-       buffer[0] = (div>>8) & 0x7f;
-       buffer[1] = div      & 0xff;
        if (params->cb_first_if_lower_freq && div < t->last_div) {
                buffer[0] = buffer[2];
                buffer[1] = buffer[3];
@@ -465,12 +473,21 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
                        config |= TDA9887_INTERCARRIER;
 /*             if (params->port1_set_for_fm_mono)
                        config &= ~TDA9887_PORT1_ACTIVE;*/
+               if (params->fm_gain_normal)
+                       config |= TDA9887_GAIN_NORMAL;
                i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config);
        }
        if (4 != (rc = i2c_master_send(c,buffer,4)))
                tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
 }
 
+static struct tuner_operations simple_tuner_ops = {
+       .set_tv_freq    = default_set_tv_freq,
+       .set_radio_freq = default_set_radio_freq,
+       .has_signal     = tuner_signal,
+       .is_stereo      = tuner_stereo,
+};
+
 int default_tuner_init(struct i2c_client *c)
 {
        struct tuner *t = i2c_get_clientdata(c);
@@ -479,11 +496,7 @@ int default_tuner_init(struct i2c_client *c)
                   t->type, tuners[t->type].name);
        strlcpy(c->name, tuners[t->type].name, sizeof(c->name));
 
-       t->set_tv_freq = default_set_tv_freq;
-       t->set_radio_freq = default_set_radio_freq;
-       t->has_signal = tuner_signal;
-       t->is_stereo = tuner_stereo;
-       t->standby = NULL;
+       memcpy(&t->ops, &simple_tuner_ops, sizeof(struct tuner_operations));
 
        return 0;
 }