diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-22 11:18:27 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-30 06:39:27 -0500 |
commit | 531c98e71805b32e9ea35a218119100bbd2b7615 (patch) | |
tree | 548f878b2d4abd66bee8d0fa0b19eeb9cf3182c9 | |
parent | 4b00eb25340c1a9b9eedaf0bc5b0f0d18eddb028 (diff) |
V4L/DVB (9953): 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 <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/em28xx/em28xx-core.c | 4 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 19 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx.h | 3 | ||||
-rw-r--r-- | include/linux/videodev2.h | 1 |
4 files changed, 25 insertions, 2 deletions
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index c647dcb20a57..5964998daf2e 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -259,7 +259,7 @@ static int em28xx_is_ac97_ready(struct em28xx *dev) | |||
259 | * em28xx_read_ac97() | 259 | * em28xx_read_ac97() |
260 | * write a 16 bit value to the specified AC97 address (LSB first!) | 260 | * write a 16 bit value to the specified AC97 address (LSB first!) |
261 | */ | 261 | */ |
262 | static int em28xx_read_ac97(struct em28xx *dev, u8 reg) | 262 | int em28xx_read_ac97(struct em28xx *dev, u8 reg) |
263 | { | 263 | { |
264 | int ret; | 264 | int ret; |
265 | u8 addr = (reg & 0x7f) | 0x80; | 265 | u8 addr = (reg & 0x7f) | 0x80; |
@@ -285,7 +285,7 @@ static int em28xx_read_ac97(struct em28xx *dev, u8 reg) | |||
285 | * em28xx_write_ac97() | 285 | * em28xx_write_ac97() |
286 | * write a 16 bit value to the specified AC97 address (LSB first!) | 286 | * write a 16 bit value to the specified AC97 address (LSB first!) |
287 | */ | 287 | */ |
288 | static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val) | 288 | int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val) |
289 | { | 289 | { |
290 | int ret; | 290 | int ret; |
291 | u8 addr = reg & 0x7f; | 291 | u8 addr = reg & 0x7f; |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 4701b6589b10..4ea4920c927a 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -1221,6 +1221,17 @@ static int vidioc_g_register(struct file *file, void *priv, | |||
1221 | struct em28xx *dev = fh->dev; | 1221 | struct em28xx *dev = fh->dev; |
1222 | int ret; | 1222 | int ret; |
1223 | 1223 | ||
1224 | if (reg->match_type == V4L2_CHIP_MATCH_AC97) { | ||
1225 | mutex_lock(&dev->lock); | ||
1226 | ret = em28xx_read_ac97(dev, reg->reg); | ||
1227 | mutex_unlock(&dev->lock); | ||
1228 | if (ret < 0) | ||
1229 | return ret; | ||
1230 | |||
1231 | reg->val = ret; | ||
1232 | return 0; | ||
1233 | } | ||
1234 | |||
1224 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 1235 | if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) |
1225 | return -EINVAL; | 1236 | return -EINVAL; |
1226 | 1237 | ||
@@ -1256,6 +1267,14 @@ static int vidioc_s_register(struct file *file, void *priv, | |||
1256 | __le64 buf; | 1267 | __le64 buf; |
1257 | int rc; | 1268 | int rc; |
1258 | 1269 | ||
1270 | if (reg->match_type == V4L2_CHIP_MATCH_AC97) { | ||
1271 | mutex_lock(&dev->lock); | ||
1272 | rc = em28xx_write_ac97(dev, reg->reg, reg->val); | ||
1273 | mutex_unlock(&dev->lock); | ||
1274 | |||
1275 | return rc; | ||
1276 | } | ||
1277 | |||
1259 | buf = cpu_to_le64(reg->val); | 1278 | buf = cpu_to_le64(reg->val); |
1260 | 1279 | ||
1261 | mutex_lock(&dev->lock); | 1280 | mutex_lock(&dev->lock); |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 80d1d55d80f9..100f27819cdc 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -564,6 +564,9 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
564 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); | 564 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); |
565 | int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val); | 565 | int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val); |
566 | 566 | ||
567 | int em28xx_read_ac97(struct em28xx *dev, u8 reg); | ||
568 | int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val); | ||
569 | |||
567 | int em28xx_audio_analog_set(struct em28xx *dev); | 570 | int em28xx_audio_analog_set(struct em28xx *dev); |
568 | int em28xx_audio_setup(struct em28xx *dev); | 571 | int em28xx_audio_setup(struct em28xx *dev); |
569 | 572 | ||
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 754c8d9685a4..e31144d22237 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h | |||
@@ -1376,6 +1376,7 @@ struct v4l2_streamparm { | |||
1376 | #define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */ | 1376 | #define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */ |
1377 | #define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver ID */ | 1377 | #define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver ID */ |
1378 | #define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ | 1378 | #define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ |
1379 | #define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */ | ||
1379 | 1380 | ||
1380 | struct v4l2_register { | 1381 | struct v4l2_register { |
1381 | __u32 match_type; /* Match type */ | 1382 | __u32 match_type; /* Match type */ |