Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / media / video / cx88 / cx88-i2c.c
index 0725b12..f720901 100644 (file)
@@ -1,10 +1,9 @@
 /*
-    $Id: cx88-i2c.c,v 1.20 2005/02/15 15:59:35 kraxel Exp $
 
     cx88-i2c.c  --  all the i2c code is here
 
     Copyright (C) 1996,97,98 Ralph  Metzler (rjkm@thp.uni-koeln.de)
-                           & Marcus Metzler (mocm@thp.uni-koeln.de)
+                          & Marcus Metzler (mocm@thp.uni-koeln.de)
     (c) 2002 Yurij Sysoev <yurij@naturesoft.net>
     (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
 
@@ -31,6 +30,7 @@
 #include <asm/io.h>
 
 #include "cx88.h"
+#include <media/v4l2-common.h>
 
 static unsigned int i2c_debug = 0;
 module_param(i2c_debug, int, 0644);
@@ -91,15 +91,34 @@ static int cx8800_bit_getsda(void *data)
 
 static int attach_inform(struct i2c_client *client)
 {
+       struct tuner_setup tun_setup;
        struct cx88_core *core = i2c_get_adapdata(client->adapter);
 
-       dprintk(1, "i2c attach [addr=0x%x,client=%s]\n",
-               client->addr, i2c_clientname(client));
+       dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
+               client->driver->driver.name, client->addr, client->name);
        if (!client->driver->command)
                return 0;
 
-       if (core->tuner_type != UNSET)
-               client->driver->command(client, TUNER_SET_TYPE, &core->tuner_type);
+       if (core->radio_type != UNSET) {
+               if ((core->radio_addr==ADDR_UNSET)||(core->radio_addr==client->addr)) {
+                       tun_setup.mode_mask = T_RADIO;
+                       tun_setup.type = core->radio_type;
+                       tun_setup.addr = core->radio_addr;
+
+                       client->driver->command (client, TUNER_SET_TYPE_ADDR, &tun_setup);
+               }
+       }
+       if (core->tuner_type != UNSET) {
+               if ((core->tuner_addr==ADDR_UNSET)||(core->tuner_addr==client->addr)) {
+
+                       tun_setup.mode_mask = T_ANALOG_TV;
+                       tun_setup.type = core->tuner_type;
+                       tun_setup.addr = core->tuner_addr;
+
+                       client->driver->command (client,TUNER_SET_TYPE_ADDR, &tun_setup);
+               }
+       }
+
        if (core->tda9887_conf)
                client->driver->command(client, TDA9887_SET_CONFIG, &core->tda9887_conf);
        return 0;
@@ -109,7 +128,7 @@ static int detach_inform(struct i2c_client *client)
 {
        struct cx88_core *core = i2c_get_adapdata(client->adapter);
 
-       dprintk(1, "i2c detach [client=%s]\n", i2c_clientname(client));
+       dprintk(1, "i2c detach [client=%s]\n", client->name);
        return 0;
 }
 
@@ -117,7 +136,17 @@ void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg)
 {
        if (0 != core->i2c_rc)
                return;
-       i2c_clients_command(&core->i2c_adap, cmd, arg);
+
+       if (core->dvbdev) {
+               if (core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl)
+                       core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl(core->dvbdev->dvb.frontend, 1);
+
+               i2c_clients_command(&core->i2c_adap, cmd, arg);
+
+               if (core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl)
+                       core->dvbdev->dvb.frontend->ops->i2c_gate_ctrl(core->dvbdev->dvb.frontend, 0);
+       } else
+               i2c_clients_command(&core->i2c_adap, cmd, arg);
 }
 
 static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
@@ -133,7 +162,7 @@ static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
 /* ----------------------------------------------------------------------- */
 
 static struct i2c_adapter cx8800_i2c_adap_template = {
-       I2C_DEVNAME("cx2388x"),
+       .name              = "cx2388x",
        .owner             = THIS_MODULE,
        .id                = I2C_HW_B_CX2388x,
        .client_register   = attach_inform,
@@ -141,10 +170,11 @@ static struct i2c_adapter cx8800_i2c_adap_template = {
 };
 
 static struct i2c_client cx8800_i2c_client_template = {
-        I2C_DEVNAME("cx88xx internal"),
+       .name   = "cx88xx internal",
 };
 
 static char *i2c_devs[128] = {
+       [ 0x1c >> 1 ] = "lgdt330x",
        [ 0x86 >> 1 ] = "tda9887/cx22702",
        [ 0xa0 >> 1 ] = "eeprom",
        [ 0xc0 >> 1 ] = "tuner (analog)",
@@ -183,10 +213,10 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
 
        core->i2c_adap.dev.parent = &pci->dev;
        strlcpy(core->i2c_adap.name,core->name,sizeof(core->i2c_adap.name));
-        core->i2c_algo.data = core;
-        i2c_set_adapdata(&core->i2c_adap,core);
-        core->i2c_adap.algo_data = &core->i2c_algo;
-        core->i2c_client.adapter = &core->i2c_adap;
+       core->i2c_algo.data = core;
+       i2c_set_adapdata(&core->i2c_adap,core);
+       core->i2c_adap.algo_data = &core->i2c_algo;
+       core->i2c_client.adapter = &core->i2c_adap;
 
        cx8800_bit_setscl(core,1);
        cx8800_bit_setsda(core,1);