]> err.no Git - linux-2.6/blobdiff - drivers/media/video/cx18/cx18-i2c.c
V4L/DVB (8091): cx18: show GPIO pins when VIDIOC_LOG_STATUS is called.
[linux-2.6] / drivers / media / video / cx18 / cx18-i2c.c
index 1d6c51a753137652028763005bc3c318404e4011..bca905901d61f99f02c33e5eb0eadaee60f47563 100644 (file)
@@ -311,8 +311,12 @@ int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg)
 {
        int addr;
 
-       if (hw == CX18_HW_GPIO || hw == 0)
+       if (hw == 0)
                return 0;
+
+       if (hw == CX18_HW_GPIO)
+               return cx18_gpio(cx, cmd, arg);
+
        if (hw == CX18_HW_CX23418)
                return cx18_av_cmd(cx, cmd, arg);
 
@@ -350,6 +354,8 @@ void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg)
        cx18_av_cmd(cx, cmd, arg);
        i2c_clients_command(&cx->i2c_adap[0], cmd, arg);
        i2c_clients_command(&cx->i2c_adap[1], cmd, arg);
+       if (cx->hw_flags & CX18_HW_GPIO)
+               cx18_gpio(cx, cmd, arg);
 }
 
 /* init + register i2c algo-bit adapter */
@@ -358,6 +364,18 @@ int init_cx18_i2c(struct cx18 *cx)
        int i;
        CX18_DEBUG_I2C("i2c init\n");
 
+       /* Sanity checks for the I2C hardware arrays. They must be the
+        * same size and GPIO/CX23418 must be the last entries.
+        */
+       if (ARRAY_SIZE(hw_driverids) != ARRAY_SIZE(hw_addrs) ||
+           ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_addrs) ||
+           CX18_HW_GPIO != (1 << (ARRAY_SIZE(hw_addrs) - 2)) ||
+           CX18_HW_CX23418 != (1 << (ARRAY_SIZE(hw_addrs) - 1)) ||
+           hw_driverids[ARRAY_SIZE(hw_addrs) - 1]) {
+               CX18_ERR("Mismatched I2C hardware arrays\n");
+               return -ENODEV;
+       }
+
        for (i = 0; i < 2; i++) {
                memcpy(&cx->i2c_adap[i], &cx18_i2c_adap_template,
                        sizeof(struct i2c_adapter));
@@ -405,6 +423,8 @@ int init_cx18_i2c(struct cx18 *cx)
        cx18_setscl(&cx->i2c_algo_cb_data[1], 1);
        cx18_setsda(&cx->i2c_algo_cb_data[1], 1);
 
+       cx18_reset_i2c_slaves_gpio(cx);
+
        return i2c_bit_add_bus(&cx->i2c_adap[0]) ||
                i2c_bit_add_bus(&cx->i2c_adap[1]);
 }