The patch number 9953 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: Add suport for debugging AC97 anciliary chips


The em28xx driver can be coupled to an anciliary AC97 chip. This patch
allows read/write AC97 registers directly.

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


---

 linux/drivers/media/video/em28xx/em28xx-core.c  |    4 +--
 linux/drivers/media/video/em28xx/em28xx-video.c |   19 ++++++++++++++++
 linux/drivers/media/video/em28xx/em28xx.h       |    3 ++
 linux/include/linux/videodev2.h                 |    1 
 4 files changed, 25 insertions(+), 2 deletions(-)

diff -r b1b1e22fffd8 -r d6eb998a84bb 
linux/drivers/media/video/em28xx/em28xx-core.c
--- a/linux/drivers/media/video/em28xx/em28xx-core.c    Mon Dec 22 10:22:42 
2008 -0200
+++ b/linux/drivers/media/video/em28xx/em28xx-core.c    Mon Dec 22 14:18:27 
2008 -0200
@@ -259,7 +259,7 @@ static int em28xx_is_ac97_ready(struct e
  * em28xx_read_ac97()
  * write a 16 bit value to the specified AC97 address (LSB first!)
  */
-static int em28xx_read_ac97(struct em28xx *dev, u8 reg)
+int em28xx_read_ac97(struct em28xx *dev, u8 reg)
 {
        int ret;
        u8 addr = (reg & 0x7f) | 0x80;
@@ -285,7 +285,7 @@ static int em28xx_read_ac97(struct em28x
  * em28xx_write_ac97()
  * write a 16 bit value to the specified AC97 address (LSB first!)
  */
-static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val)
+int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val)
 {
        int ret;
        u8 addr = reg & 0x7f;
diff -r b1b1e22fffd8 -r d6eb998a84bb 
linux/drivers/media/video/em28xx/em28xx-video.c
--- a/linux/drivers/media/video/em28xx/em28xx-video.c   Mon Dec 22 10:22:42 
2008 -0200
+++ b/linux/drivers/media/video/em28xx/em28xx-video.c   Mon Dec 22 14:18:27 
2008 -0200
@@ -1233,6 +1233,17 @@ static int vidioc_g_register(struct file
        struct em28xx         *dev = fh->dev;
        int ret;
 
+       if (reg->match_type == V4L2_CHIP_MATCH_AC97) {
+               mutex_lock(&dev->lock);
+               ret = em28xx_read_ac97(dev, reg->reg);
+               mutex_unlock(&dev->lock);
+               if (ret < 0)
+                       return ret;
+
+               reg->val = ret;
+               return 0;
+       }
+
        if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
                return -EINVAL;
 
@@ -1267,6 +1278,14 @@ static int vidioc_s_register(struct file
        struct em28xx         *dev = fh->dev;
        __le64 buf;
        int    rc;
+
+       if (reg->match_type == V4L2_CHIP_MATCH_AC97) {
+               mutex_lock(&dev->lock);
+               rc = em28xx_write_ac97(dev, reg->reg, reg->val);
+               mutex_unlock(&dev->lock);
+
+               return rc;
+       }
 
        buf = cpu_to_le64(reg->val);
 
diff -r b1b1e22fffd8 -r d6eb998a84bb linux/drivers/media/video/em28xx/em28xx.h
--- a/linux/drivers/media/video/em28xx/em28xx.h Mon Dec 22 10:22:42 2008 -0200
+++ b/linux/drivers/media/video/em28xx/em28xx.h Mon Dec 22 14:18:27 2008 -0200
@@ -577,6 +577,9 @@ int em28xx_write_regs(struct em28xx *dev
 int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len);
 int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val);
 
+int em28xx_read_ac97(struct em28xx *dev, u8 reg);
+int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val);
+
 int em28xx_audio_analog_set(struct em28xx *dev);
 int em28xx_audio_setup(struct em28xx *dev);
 
diff -r b1b1e22fffd8 -r d6eb998a84bb linux/include/linux/videodev2.h
--- a/linux/include/linux/videodev2.h   Mon Dec 22 10:22:42 2008 -0200
+++ b/linux/include/linux/videodev2.h   Mon Dec 22 14:18:27 2008 -0200
@@ -1376,6 +1376,7 @@ struct v4l2_streamparm {
 #define V4L2_CHIP_MATCH_HOST       0  /* Match against chip ID on host (0 for 
the host) */
 #define V4L2_CHIP_MATCH_I2C_DRIVER 1  /* Match against I2C driver ID */
 #define V4L2_CHIP_MATCH_I2C_ADDR   2  /* Match against I2C 7-bit address */
+#define V4L2_CHIP_MATCH_AC97       3  /* Match against anciliary AC97 chip */
 
 struct v4l2_register {
        __u32 match_type; /* Match type */


---

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

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

Reply via email to