]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/media/video/tuner-core.c
[PATCH] DRIVER MODEL: Get rid of the obsolete tri-level suspend/resume callbacks
[mirror_ubuntu-bionic-kernel.git] / drivers / media / video / tuner-core.c
index de190630babb167e80f74fb339e59864c0b2e817..ad85bef1c3d5d20bcd256704ea868352fd3fca1f 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * $Id: tuner-core.c,v 1.55 2005/07/08 13:20:33 mchehab Exp $
  *
  * i2c tv tuner chip device driver
  * core core, i.e. kernel interfaces, registering and so on
@@ -23,6 +22,8 @@
 #include <media/tuner.h>
 #include <media/audiochip.h>
 
+#include "msp3400.h"
+
 #define UNSET (-1U)
 
 /* standard i2c insmod options */
@@ -39,6 +40,12 @@ I2C_CLIENT_INSMOD;
 static unsigned int addr = 0;
 module_param(addr, int, 0444);
 
+static unsigned int no_autodetect = 0;
+module_param(no_autodetect, int, 0444);
+
+static unsigned int show_i2c = 0;
+module_param(show_i2c, int, 0444);
+
 /* insmod options used at runtime => read/write */
 unsigned int tuner_debug = 0;
 module_param(tuner_debug, int, 0644);
@@ -174,6 +181,14 @@ static void set_type(struct i2c_client *c, unsigned int type,
                i2c_master_send(c, buffer, 4);
                default_tuner_init(c);
                break;
+       case TUNER_LG_TDVS_H062F:
+               /* Set the Auxiliary Byte. */
+               buffer[2] &= ~0x20;
+               buffer[2] |= 0x18;
+               buffer[3] = 0x20;
+               i2c_master_send(c, buffer, 4);
+               default_tuner_init(c);
+               break;
        default:
                default_tuner_init(c);
                break;
@@ -200,31 +215,31 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup)
 {
        struct tuner *t = i2c_get_clientdata(c);
 
-       if (tun_setup->addr == ADDR_UNSET) {
-               if (t->mode_mask & tun_setup->mode_mask)
+       if ((tun_setup->addr == ADDR_UNSET &&
+               (t->mode_mask & tun_setup->mode_mask)) ||
+               tun_setup->addr == c->addr) {
                        set_type(c, tun_setup->type, tun_setup->mode_mask);
-       } else if (tun_setup->addr == c->addr) {
-               set_type(c, tun_setup->type, tun_setup->mode_mask);
        }
 }
 
 static inline int check_mode(struct tuner *t, char *cmd)
 {
-       if (1 << t->mode & t->mode_mask) {
-               switch (t->mode) {
-               case V4L2_TUNER_RADIO:
-                       tuner_dbg("Cmd %s accepted for radio\n", cmd);
-                       break;
-               case V4L2_TUNER_ANALOG_TV:
-                       tuner_dbg("Cmd %s accepted for analog TV\n", cmd);
-                       break;
-               case V4L2_TUNER_DIGITAL_TV:
-                       tuner_dbg("Cmd %s accepted for digital TV\n", cmd);
-                       break;
-               }
-               return 0;
+       if ((1 << t->mode & t->mode_mask) == 0) {
+               return EINVAL;
        }
-       return EINVAL;
+
+       switch (t->mode) {
+       case V4L2_TUNER_RADIO:
+               tuner_dbg("Cmd %s accepted for radio\n", cmd);
+               break;
+       case V4L2_TUNER_ANALOG_TV:
+               tuner_dbg("Cmd %s accepted for analog TV\n", cmd);
+               break;
+       case V4L2_TUNER_DIGITAL_TV:
+               tuner_dbg("Cmd %s accepted for digital TV\n", cmd);
+               break;
+       }
+       return 0;
 }
 
 static char pal[] = "-";
@@ -266,6 +281,12 @@ static int tuner_fixup_std(struct tuner *t)
                        tuner_dbg ("insmod fixup: PAL => PAL-N\n");
                        t->std = V4L2_STD_PAL_N;
                        break;
+               case '-':
+                       /* default parameter, do nothing */
+                       break;
+               default:
+                       tuner_warn ("pal= argument not recognised\n");
+                       break;
                }
        }
        if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) {
@@ -282,6 +303,12 @@ static int tuner_fixup_std(struct tuner *t)
                        tuner_dbg ("insmod fixup: SECAM => SECAM-L\n");
                        t->std = V4L2_STD_SECAM_L;
                        break;
+               case '-':
+                       /* default parameter, do nothing */
+                       break;
+               default:
+                       tuner_warn ("secam= argument not recognised\n");
+                       break;
                }
        }
 
@@ -317,18 +344,31 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
 
        tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
 
+       if (show_i2c) {
+               unsigned char buffer[16];
+               int i,rc;
+
+               memset(buffer, 0, sizeof(buffer));
+               rc = i2c_master_recv(&t->i2c, buffer, sizeof(buffer));
+               printk("tuner-%04x I2C RECV = ",addr);
+               for (i=0;i<rc;i++)
+                       printk("%02x ",buffer[i]);
+               printk("\n");
+       }
        /* TEA5767 autodetection code - only for addr = 0xc0 */
-       if (addr == 0x60) {
-               if (tea5767_autodetection(&t->i2c) != EINVAL) {
-                       t->type = TUNER_TEA5767;
-                       t->mode_mask = T_RADIO;
-                       t->mode = T_STANDBY;
-                       t->freq = 87.5 * 16; /* Sets freq to FM range */
-                       default_mode_mask &= ~T_RADIO;
-
-                       i2c_attach_client (&t->i2c);
-                       set_type(&t->i2c,t->type, t->mode_mask);
-                       return 0;
+       if (!no_autodetect) {
+               if (addr == 0x60) {
+                       if (tea5767_autodetection(&t->i2c) != EINVAL) {
+                               t->type = TUNER_TEA5767;
+                               t->mode_mask = T_RADIO;
+                               t->mode = T_STANDBY;
+                               t->freq = 87.5 * 16; /* Sets freq to FM range */
+                               default_mode_mask &= ~T_RADIO;
+
+                               i2c_attach_client (&t->i2c);
+                               set_type(&t->i2c,t->type, t->mode_mask);
+                               return 0;
+                       }
                }
        }
 
@@ -385,20 +425,18 @@ static int tuner_detach(struct i2c_client *client)
 
 static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd)
 {
-       if (mode != t->mode) {
-
-               t->mode = mode;
-               if (check_mode(t, cmd) == EINVAL) {
-                       t->mode = T_STANDBY;
-                       if (V4L2_TUNER_RADIO == mode) {
-                               set_tv_freq(client, 400 * 16);
-                       } else {
-                               set_radio_freq(client, 87.5 * 16000);
-                       }
-                       return EINVAL;
-               }
-       }
-       return 0;
+       if (mode == t->mode)
+               return 0;
+
+       t->mode = mode;
+
+       if (check_mode(t, cmd) == EINVAL) {
+               t->mode = T_STANDBY;
+               if (t->standby)
+                       t->standby (client);
+               return EINVAL;
+       }
+       return 0;
 }
 
 #define switch_v4l2()  if (!t->using_v4l2) \
@@ -432,6 +470,14 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
        case AUDC_SET_RADIO:
                set_mode(client,t,V4L2_TUNER_RADIO, "AUDC_SET_RADIO");
                break;
+       case TUNER_SET_STANDBY:
+               {
+                       if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL)
+                               return 0;
+                       if (t->standby)
+                               t->standby (client);
+                       break;
+               }
        case AUDC_CONFIG_PINNACLE:
                if (check_mode(t, "AUDC_CONFIG_PINNACLE") == EINVAL)
                        return 0;
@@ -446,6 +492,17 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                        break;
                }
                break;
+       case VIDIOCSAUDIO:
+               if (check_mode(t, "VIDIOCSAUDIO") == EINVAL)
+                       return 0;
+               if (check_v4l2(t) == EINVAL)
+                       return 0;
+
+               /* Should be implemented, since bttv calls it */
+               tuner_dbg("VIDIOCSAUDIO not implemented.\n");
+
+               break;
+       case MSP_SET_MATRIX:
        case TDA9887_SET_CONFIG:
                break;
        /* --- v4l ioctls --- */
@@ -631,14 +688,16 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                        break;
                }
        default:
-               tuner_dbg("Unimplemented IOCTL 0x%08x called to tuner.\n", cmd);
+               tuner_dbg("Unimplemented IOCTL 0x%08x(dir=%d,tp=0x%02x,nr=%d,sz=%d)\n",
+                                        cmd, _IOC_DIR(cmd), _IOC_TYPE(cmd),
+                                       _IOC_NR(cmd), _IOC_SIZE(cmd));
                break;
        }
 
        return 0;
 }
 
-static int tuner_suspend(struct device *dev, u32 state, u32 level)
+static int tuner_suspend(struct device *dev, pm_message_t state)
 {
        struct i2c_client *c = container_of (dev, struct i2c_client, dev);
        struct tuner *t = i2c_get_clientdata (c);
@@ -648,7 +707,7 @@ static int tuner_suspend(struct device *dev, u32 state, u32 level)
        return 0;
 }
 
-static int tuner_resume(struct device *dev, u32 level)
+static int tuner_resume(struct device *dev)
 {
        struct i2c_client *c = container_of (dev, struct i2c_client, dev);
        struct tuner *t = i2c_get_clientdata (c);
@@ -675,7 +734,7 @@ static struct i2c_driver driver = {
                   },
 };
 static struct i2c_client client_template = {
-       I2C_DEVNAME("(tuner unset)"),
+       .name = "(tuner unset)",
        .flags = I2C_CLIENT_ALLOW_USE,
        .driver = &driver,
 };