The patch number 9970 was added via Mauro Carvalho Chehab <[email protected]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        [email protected]

------

From: Mauro Carvalho Chehab  <[email protected]>
em28xx: Allow get/set registers for debug on i2c slave chips


Signed-off-by: Mauro Carvalho Chehab <[email protected]>


---

 linux/drivers/media/video/em28xx/em28xx-video.c |   54 +++++++++++++---
 1 file changed, 45 insertions(+), 9 deletions(-)

diff -r 780be5d9259f -r 1828ab260dbe 
linux/drivers/media/video/em28xx/em28xx-video.c
--- a/linux/drivers/media/video/em28xx/em28xx-video.c   Mon Dec 22 21:34:18 
2008 -0200
+++ b/linux/drivers/media/video/em28xx/em28xx-video.c   Mon Dec 22 21:58:41 
2008 -0200
@@ -39,6 +39,7 @@
 #include "em28xx.h"
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
+#include <media/v4l2-chip-ident.h>
 #include <media/msp3400.h>
 #include <media/tuner.h>
 
@@ -1226,6 +1227,21 @@ static int em28xx_reg_len(int reg)
        }
 }
 
+static int vidioc_g_chip_ident(struct file *file, void *priv,
+              struct v4l2_chip_ident *chip)
+{
+       struct em28xx_fh      *fh  = priv;
+       struct em28xx         *dev = fh->dev;
+
+       chip->ident = V4L2_IDENT_NONE;
+       chip->revision = 0;
+
+       em28xx_i2c_call_clients(dev, VIDIOC_G_CHIP_IDENT, chip);
+
+       return 0;
+}
+
+
 static int vidioc_g_register(struct file *file, void *priv,
                             struct v4l2_register *reg)
 {
@@ -1233,7 +1249,8 @@ static int vidioc_g_register(struct file
        struct em28xx         *dev = fh->dev;
        int ret;
 
-       if (reg->match_type == V4L2_CHIP_MATCH_AC97) {
+       switch (reg->match_type) {
+       case V4L2_CHIP_MATCH_AC97:
                mutex_lock(&dev->lock);
                ret = em28xx_read_ac97(dev, reg->reg);
                mutex_unlock(&dev->lock);
@@ -1242,11 +1259,18 @@ static int vidioc_g_register(struct file
 
                reg->val = ret;
                return 0;
-       }
-
-       if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
-               return -EINVAL;
-
+       case V4L2_CHIP_MATCH_I2C_DRIVER:
+               em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_REGISTER, reg);
+               return 0;
+       case V4L2_CHIP_MATCH_I2C_ADDR:
+               /* Not supported yet */
+               return -EINVAL;
+       default:
+               if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
+                       return -EINVAL;
+       }
+
+       /* Match host */
        if (em28xx_reg_len(reg->reg) == 1) {
                mutex_lock(&dev->lock);
                ret = em28xx_read_reg(dev, reg->reg);
@@ -1279,14 +1303,25 @@ static int vidioc_s_register(struct file
        __le64 buf;
        int    rc;
 
-       if (reg->match_type == V4L2_CHIP_MATCH_AC97) {
+       switch (reg->match_type) {
+       case V4L2_CHIP_MATCH_AC97:
                mutex_lock(&dev->lock);
                rc = em28xx_write_ac97(dev, reg->reg, reg->val);
                mutex_unlock(&dev->lock);
 
                return rc;
-       }
-
+       case V4L2_CHIP_MATCH_I2C_DRIVER:
+               em28xx_i2c_call_clients(dev, VIDIOC_DBG_S_REGISTER, reg);
+               return 0;
+       case V4L2_CHIP_MATCH_I2C_ADDR:
+               /* Not supported yet */
+               return -EINVAL;
+       default:
+               if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
+                       return -EINVAL;
+       }
+
+       /* Match host */
        buf = cpu_to_le64(reg->val);
 
        mutex_lock(&dev->lock);
@@ -1996,6 +2031,7 @@ static const struct v4l2_ioctl_ops video
 #ifdef CONFIG_VIDEO_ADV_DEBUG
        .vidioc_g_register          = vidioc_g_register,
        .vidioc_s_register          = vidioc_s_register,
+       .vidioc_g_chip_ident        = vidioc_g_chip_ident,
 #endif
 #ifdef CONFIG_VIDEO_V4L1_COMPAT
        .vidiocgmbuf                = vidiocgmbuf,


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/1828ab260dbe622eb259aae28bfb676c72ef34c5

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to