]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
V4L/DVB (5323): Updated support for tuner callbacks
authorHartmut Hackmann <hartmut.hackmann@t-online.de>
Fri, 27 Apr 2007 15:31:17 +0000 (12:31 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Fri, 27 Apr 2007 18:43:40 +0000 (15:43 -0300)
This change supplies a more generic version of the tuner callback.
The tuner struct now has a function pointer
  int (*tuner_callback) (void *dev, int command, int arg)
additionally to a int config parameter.
both can be set through the TUNER_SET_TYPE_ADDR client call.
Note that the meaning of the parameters depend on the tuner type.

Signed-off-by: Hartmut Hackmann <hartmut.hackmann@t-online.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/saa7134/saa7134-cards.c
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/saa7134/saa7134-i2c.c
drivers/media/video/saa7134/saa7134.h
drivers/media/video/tda8290.c
drivers/media/video/tuner-core.c
include/media/tuner.h

index f44e7c7e18a551689116066e7cc7dc1a7bde0676..87a8a68efc5c470dc1ede95ccb219166effba731 100644 (file)
@@ -4185,6 +4185,9 @@ int saa7134_board_init2(struct saa7134_dev *dev)
 {
        unsigned char buf;
        int board;
+       struct tuner_setup tun_setup;
+       tun_setup.config = 0;
+       tun_setup.tuner_callback = saa7134_tuner_callback;
 
        switch (dev->board) {
        case SAA7134_BOARD_BMK_MPEX_NOTUNER:
@@ -4201,20 +4204,15 @@ int saa7134_board_init2(struct saa7134_dev *dev)
                dev->tuner_type = saa7134_boards[dev->board].tuner_type;
 
                if (TUNER_ABSENT != dev->tuner_type) {
-                               struct tuner_setup tun_setup;
-
                                tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
                                tun_setup.type = dev->tuner_type;
                                tun_setup.addr = ADDR_UNSET;
-                               tun_setup.config = 0;
-                               tun_setup.gpio_func = NULL;
 
                                saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup);
                }
                break;
        case SAA7134_BOARD_MD7134:
                {
-               struct tuner_setup tun_setup;
                u8 subaddr;
                u8 data[3];
                int ret, tuner_t;
@@ -4275,8 +4273,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
                tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
                tun_setup.type = dev->tuner_type;
                tun_setup.addr = ADDR_UNSET;
-               tun_setup.config = 0;
-               tun_setup.gpio_func = NULL;
 
                saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
                }
@@ -4288,7 +4284,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
                 * the channel decoder. We have to make it transparent to find it
                 */
                {
-               struct tuner_setup tun_setup;
                u8 data[] = { 0x07, 0x02};
                struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
                i2c_transfer(&dev->i2c_adap, &msg, 1);
@@ -4296,8 +4291,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
                tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
                tun_setup.type = dev->tuner_type;
                tun_setup.addr = dev->tuner_addr;
-               tun_setup.config = 0;
-               tun_setup.gpio_func = NULL;
 
                saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
                }
@@ -4306,7 +4299,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
        case SAA7134_BOARD_PHILIPS_TIGER_S:
                {
                u8 data[] = { 0x3c, 0x33, 0x60};
-               struct tuner_setup tun_setup;
                struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
                if(dev->autodetected && (dev->eedata[0x49] == 0x50)) {
                        dev->board = SAA7134_BOARD_PHILIPS_TIGER_S;
@@ -4318,7 +4310,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
                        tun_setup.type = TUNER_PHILIPS_TDA8290;
                        tun_setup.addr = 0x4b;
                        tun_setup.config = 2;
-                       tun_setup.gpio_func = (tuner_gpio_func_t) saa7134_set_gpio;
 
                        saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
                        data[2] = 0x68;
index 8ed03d65a34e82c89dd90f94030cfe330796bdf8..5f74ea467d4e153abe9febd463cca25cafceb76d 100644 (file)
@@ -120,7 +120,6 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
 void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value)
 {
        u32 index, bitval;
-       u8 sync_control;
 
        index = 1 << bit_no;
        switch (value) {
@@ -140,22 +139,40 @@ void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value)
                dprintk("setting GPIO%d to tristate\n", bit_no);
                saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, index, 0);
                break;
-       case 4: /* sync output on GPIO 22 for tda8275a, 50Hz*/
-       case 5: /* sync output on GPIO 22 for tda8275a, 60Hz*/
-               if (bit_no == 22) {
-                       dprintk("setting GPIO22 to vsync %d\n", value - 4);
+       }
+}
+
+int saa7134_tuner_callback(void *ptr, int command, int arg)
+{
+       u8 sync_control;
+       struct saa7134_dev *dev = ptr;
+
+       switch (dev->tuner_type) {
+       case TUNER_PHILIPS_TDA8290:
+               switch (command) {
+               case 0: /* switch LNA gain through GPIO 22*/
+                       saa7134_set_gpio(dev, 22, arg) ;
+                       break;
+               case 1: /* vsync output at GPIO22. 50 / 60Hz */
+                       dprintk("setting GPIO22 to vsync %d\n", arg);
                        saa_andorb(SAA7134_VIDEO_PORT_CTRL3, 0x80, 0x80);
                        saa_andorb(SAA7134_VIDEO_PORT_CTRL6, 0x0f, 0x03);
-                       if (value == 5)
+                       if (arg == 1)
                                sync_control = 11;
                        else
                                sync_control = 17;
                        saa_writeb(SAA7134_VGATE_START, sync_control);
                        saa_writeb(SAA7134_VGATE_STOP, sync_control + 1);
                        saa_andorb(SAA7134_MISC_VGATE_MSB, 0x03, 0x00);
+                       break;
+               default:
+                       return -EINVAL;
                }
                break;
+       default:
+               return -ENODEV;
        }
+       return 0;
 }
 
 /* ------------------------------------------------------------------ */
index 62c107e7759d90a5dde076dde272c9e5379a61b5..4e8d6c94ea600fb3f2925dd841eaea2eab484f4d 100644 (file)
@@ -371,7 +371,7 @@ static int attach_inform(struct i2c_client *client)
                tun_setup.type = tuner;
                tun_setup.addr = saa7134_boards[dev->board].tuner_addr;
                tun_setup.config = saa7134_boards[dev->board].tuner_config;
-               tun_setup.gpio_func = (tuner_gpio_func_t) saa7134_set_gpio;
+               tun_setup.tuner_callback = saa7134_tuner_callback;
 
                if ((tun_setup.addr == ADDR_UNSET)||(tun_setup.addr == client->addr)) {
 
index b46265a97565665e6d4c5f737c854ab2e7533a07..c365ec581a11f96ecd505171ab9be1792f4cf7bf 100644 (file)
@@ -565,6 +565,7 @@ extern int saa7134_no_overlay;
 
 void saa7134_track_gpio(struct saa7134_dev *dev, char *msg);
 void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value);
+int saa7134_tuner_callback(void *ptr, int command, int arg);
 
 #define SAA7134_PGTABLE_SIZE 4096
 
index e6c3e616719197f6ad1fba21fbb4fb7b9c5d3fc8..44348f95dd4c7bd281112c0d0b6575dc42bc3e7e 100644 (file)
@@ -211,19 +211,19 @@ static void tda827xa_lna_gain(struct i2c_client *c, int high)
        case 2:
                /* turn Vsync on */
                if (t->std & V4L2_STD_MN)
-                       arg = 5;
+                       arg = 1;
                else
-                       arg = 4;
-               if (t->gpio_func)
-                       t->gpio_func(c->adapter->algo_data, 22, 5);
+                       arg = 0;
+               if (t->tuner_callback)
+                       t->tuner_callback(c->adapter->algo_data, 1, arg);
                buf[1] = high ? 0 : 1;
                if (t->config == 2)
                        buf[1] = high ? 1 : 0;
                i2c_transfer(c->adapter, &msg, 1);
                break;
        case 3: /* switch with GPIO of saa713x */
-               if (t->gpio_func)
-                       t->gpio_func(c->adapter->algo_data, 22, high);
+               if (t->tuner_callback)
+                       t->tuner_callback(c->adapter->algo_data, 0, high);
                break;
        }
 }
index 522ec1c35b8c8d86ed2befc049fa83a9e58e3f39..b8c38a0288413fce1e1502c18ad1c7b3cbab20b5 100644 (file)
@@ -145,7 +145,7 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
 
 static void set_type(struct i2c_client *c, unsigned int type,
                     unsigned int new_mode_mask, unsigned int new_config,
-                    tuner_gpio_func_t gpio_func)
+                    int (*tuner_callback) (void *dev, int command,int arg))
 {
        struct tuner *t = i2c_get_clientdata(c);
        unsigned char buffer[4];
@@ -169,16 +169,16 @@ static void set_type(struct i2c_client *c, unsigned int type,
        }
 
        t->type = type;
+       t->config = new_config;
+       if (tuner_callback != NULL) {
+               tuner_dbg("defining GPIO callback\n");
+               t->tuner_callback = tuner_callback;
+       }
        switch (t->type) {
        case TUNER_MT2032:
                microtune_init(c);
                break;
        case TUNER_PHILIPS_TDA8290:
-               t->config = new_config;
-               if (gpio_func != NULL) {
-                       tuner_dbg("Defining GPIO function\n");
-                       t->gpio_func = gpio_func;
-               }
                tda8290_init(c);
                break;
        case TUNER_TEA5767:
@@ -244,7 +244,7 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup)
                (t->mode_mask & tun_setup->mode_mask))) ||
                (tun_setup->addr == c->addr)) {
                        set_type(c, tun_setup->type, tun_setup->mode_mask,
-                                tun_setup->config, tun_setup->gpio_func);
+                                tun_setup->config, tun_setup->tuner_callback);
        }
 }
 
@@ -503,7 +503,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
 register_client:
        tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
        i2c_attach_client (&t->i2c);
-       set_type (&t->i2c,t->type, t->mode_mask, t->config, t->gpio_func);
+       set_type (&t->i2c,t->type, t->mode_mask, t->config, t->tuner_callback);
        return 0;
 }
 
index fe567129b22bac8918db042f6a47e909d2862790..a41ac41113acb5c5a2ff7e964bfc00b48fe2466e 100644 (file)
@@ -173,15 +173,12 @@ enum tuner_mode {
    when the tuner is set to TV mode.
  */
 
-/* allows to access the GPIOs of the host (pci bridge) */
-typedef void (*tuner_gpio_func_t) (void *dev, int bit_no,int value);
-
 struct tuner_setup {
        unsigned short  addr;   /* I2C address */
        unsigned int    type;   /* Tuner type */
        unsigned int    mode_mask;  /* Allowed tuner modes */
        unsigned int    config; /* configuraion for more complex tuners */
-       tuner_gpio_func_t gpio_func;
+       int (*tuner_callback) (void *dev, int command,int arg);
 };
 
 struct tuner {
@@ -215,8 +212,9 @@ struct tuner {
        unsigned char tda827x_addr;
        unsigned char tda827x_ver;
        unsigned int sgIF;
+
        unsigned int config;
-       tuner_gpio_func_t gpio_func;
+       int (*tuner_callback) (void *dev, int command,int arg);
 
        /* function ptrs */
        void (*set_tv_freq)(struct i2c_client *c, unsigned int freq);