V4L/DVB (7121): Renames videobuf lock to vb_lock
[cascardo/linux.git] / drivers / media / video / tuner-core.c
index 67b9ed1..78a09a2 100644 (file)
@@ -27,6 +27,7 @@
 #include "tuner-xc2028.h"
 #include "tuner-simple.h"
 #include "tda9887.h"
+#include "xc5000.h"
 
 #define UNSET (-1U)
 
@@ -247,7 +248,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
                tuner_warn ("tuner type not set\n");
                return;
        }
-       if (analog_ops->set_params) {
+       if (NULL == analog_ops->set_params) {
                tuner_warn ("tuner has no way to set radio frequency\n");
                return;
        }
@@ -296,6 +297,12 @@ static void tuner_i2c_address_check(struct tuner *t)
            ((t->i2c->addr < 0x64) || (t->i2c->addr > 0x6f)))
                return;
 
+       /* We already know that the XC5000 can only be located at
+        * i2c address 0x61, 0x62, 0x63 or 0x64 */
+       if ((t->type == TUNER_XC5000) &&
+           ((t->i2c->addr <= 0x64)) && (t->i2c->addr >= 0x61))
+               return;
+
        tuner_warn("====================== WARNING! ======================\n");
        tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n");
        tuner_warn("will soon be dropped. This message indicates that your\n");
@@ -329,6 +336,8 @@ static void attach_tda829x(struct tuner *t)
        tda829x_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg);
 }
 
+static struct xc5000_config xc5000_cfg;
+
 static void set_type(struct i2c_client *c, unsigned int type,
                     unsigned int new_mode_mask, unsigned int new_config,
                     int (*tuner_callback) (void *dev, int command,int arg))
@@ -428,6 +437,23 @@ static void set_type(struct i2c_client *c, unsigned int type,
        case TUNER_TDA9887:
                tda9887_attach(&t->fe, t->i2c->adapter, t->i2c->addr);
                break;
+       case TUNER_XC5000:
+               xc5000_cfg.i2c_address    = t->i2c->addr;
+               xc5000_cfg.if_khz         = 5380;
+               xc5000_cfg.priv           = c->adapter->algo_data;
+               xc5000_cfg.tuner_callback = t->tuner_callback;
+               if (!xc5000_attach(&t->fe, t->i2c->adapter, &xc5000_cfg)) {
+                       t->type = TUNER_ABSENT;
+                       t->mode_mask = T_UNINITIALIZED;
+                       return;
+               }
+               {
+               struct dvb_tuner_ops *xc_tuner_ops;
+               xc_tuner_ops = &t->fe.ops.tuner_ops;
+               if(xc_tuner_ops->init != NULL)
+                       xc_tuner_ops->init(&t->fe);
+               }
+               break;
        default:
                attach_simple_tuner(t);
                break;
@@ -1012,7 +1038,7 @@ static int tuner_resume(struct i2c_client *c)
 
 /* ---------------------------------------------------------------------- */
 
-LIST_HEAD(tuner_list);
+static LIST_HEAD(tuner_list);
 
 /* Search for existing radio and/or TV tuners on the given I2C adapter.
    Note that when this function is called from tuner_probe you can be