V4L/DVB (10394): KWorld ATSC 115 all static
authorMauro Carvalho Chehab <mchehab@infradead.org>
Mon, 19 Jan 2009 11:01:24 +0000 (08:01 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:42:35 +0000 (12:42 -0300)
saa7134: Fix tuner access on Kworld ATSC110

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/saa7134/saa7134-cards.c
drivers/media/video/saa7134/saa7134.h

index 0d50d7448fc5d9076914b7ebcc64e77420f25e19..42684d16204059b7d9df6cc4b8d9d1447554de8b 100644 (file)
@@ -5896,6 +5896,32 @@ static void hauppauge_eeprom(struct saa7134_dev *dev, u8 *eeprom_data)
 
 /* ----------------------------------------------------------- */
 
+static void nxt200x_gate_ctrl(struct saa7134_dev *dev, int open)
+{
+       /* enable tuner */
+       int i;
+       static const u8 buffer [][2] = {
+               { 0x10, 0x12 },
+               { 0x13, 0x04 },
+               { 0x16, 0x00 },
+               { 0x14, 0x04 },
+               { 0x17, 0x00 },
+       };
+
+       dev->i2c_client.addr = 0x0a;
+
+       /* FIXME: don't know how to close the i2c gate on NXT200x */
+       if (!open)
+               return;
+
+       for (i = 0; i < ARRAY_SIZE(buffer); i++)
+               if (2 != i2c_master_send(&dev->i2c_client,
+                                        &buffer[i][0], ARRAY_SIZE(buffer[0])))
+                       printk(KERN_WARNING
+                              "%s: Unable to enable tuner(%i).\n",
+                              dev->name, i);
+}
+
 int saa7134_board_init1(struct saa7134_dev *dev)
 {
        /* Always print gpio, often manufacturers encode tuner type and other info. */
@@ -6089,6 +6115,10 @@ int saa7134_board_init1(struct saa7134_dev *dev)
                       "are supported for now.\n",
                        dev->name, card(dev).name, dev->name);
                break;
+       case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
+       case SAA7134_BOARD_KWORLD_ATSC110:
+               dev->gate_ctrl = nxt200x_gate_ctrl;
+               break;
        }
        return 0;
 }
@@ -6350,22 +6380,6 @@ int saa7134_board_init2(struct saa7134_dev *dev)
                i2c_transfer(&dev->i2c_adap, &msg, 1);
                break;
        }
-       case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
-       case SAA7134_BOARD_KWORLD_ATSC110:
-       {
-               /* enable tuner */
-               int i;
-               static const u8 buffer [] = { 0x10, 0x12, 0x13, 0x04, 0x16,
-                                             0x00, 0x14, 0x04, 0x17, 0x00 };
-               dev->i2c_client.addr = 0x0a;
-               for (i = 0; i < 5; i++)
-                       if (2 != i2c_master_send(&dev->i2c_client,
-                                                &buffer[i*2], 2))
-                               printk(KERN_WARNING
-                                      "%s: Unable to enable tuner(%i).\n",
-                                      dev->name, i);
-               break;
-       }
        case SAA7134_BOARD_VIDEOMATE_DVBT_200:
        case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
                /* The T200 and the T200A share the same pci id.  Consequently,
index bb6952118d0134fce6713170707be421be92d18c..6fbf5088c97af86342c3a19c602516324dcd34d2 100644 (file)
@@ -589,6 +589,7 @@ struct saa7134_dev {
        int (*original_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
        int (*original_set_high_voltage)(struct dvb_frontend *fe, long arg);
 #endif
+       void (*gate_ctrl)(struct saa7134_dev *dev, int open);
 };
 
 /* ----------------------------------------------------------- */
@@ -618,10 +619,24 @@ struct saa7134_dev {
                V4L2_STD_PAL_60)
 
 #define GRP_EMPRESS (1)
-#define saa_call_all(dev, o, f, args...) \
-       v4l2_device_call_all(&(dev)->v4l2_dev, 0, o, f , ##args)
-#define saa_call_empress(dev, o, f, args...) \
-       v4l2_device_call_until_err(&(dev)->v4l2_dev, GRP_EMPRESS, o, f , ##args)
+#define saa_call_all(dev, o, f, args...) do {                          \
+       if (dev->gate_ctrl)                                             \
+               dev->gate_ctrl(dev, 1);                                 \
+       v4l2_device_call_all(&(dev)->v4l2_dev, 0, o, f , ##args);       \
+       if (dev->gate_ctrl)                                             \
+               dev->gate_ctrl(dev, 0);                                 \
+} while (0)
+
+#define saa_call_empress(dev, o, f, args...) ({                                \
+       long _rc;                                                       \
+       if (dev->gate_ctrl)                                             \
+               dev->gate_ctrl(dev, 1);                                 \
+       _rc = v4l2_device_call_until_err(&(dev)->v4l2_dev,              \
+                                        GRP_EMPRESS, o, f , ##args);   \
+       if (dev->gate_ctrl)                                             \
+               dev->gate_ctrl(dev, 0);                                 \
+       _rc;                                                            \
+})
 
 /* ----------------------------------------------------------- */
 /* saa7134-core.c                                              */