aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2008-12-22 18:58:41 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:39:34 -0500
commit14983d8163c78826386404b27ee5bfc72e25a9d4 (patch)
tree4d014366e77ae1c010d8610fb499e672d959243a
parentbc97430510960846b6e8f2d62c503653031991e1 (diff)
V4L/DVB (9970): em28xx: Allow get/set registers for debug on i2c slave chips
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 4ea4920c927a..b5ea18e12290 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -39,6 +39,7 @@
39#include "em28xx.h" 39#include "em28xx.h"
40#include <media/v4l2-common.h> 40#include <media/v4l2-common.h>
41#include <media/v4l2-ioctl.h> 41#include <media/v4l2-ioctl.h>
42#include <media/v4l2-chip-ident.h>
42#include <media/msp3400.h> 43#include <media/msp3400.h>
43#include <media/tuner.h> 44#include <media/tuner.h>
44 45
@@ -1214,6 +1215,21 @@ static int em28xx_reg_len(int reg)
1214 } 1215 }
1215} 1216}
1216 1217
1218static int vidioc_g_chip_ident(struct file *file, void *priv,
1219 struct v4l2_chip_ident *chip)
1220{
1221 struct em28xx_fh *fh = priv;
1222 struct em28xx *dev = fh->dev;
1223
1224 chip->ident = V4L2_IDENT_NONE;
1225 chip->revision = 0;
1226
1227 em28xx_i2c_call_clients(dev, VIDIOC_G_CHIP_IDENT, chip);
1228
1229 return 0;
1230}
1231
1232
1217static int vidioc_g_register(struct file *file, void *priv, 1233static int vidioc_g_register(struct file *file, void *priv,
1218 struct v4l2_register *reg) 1234 struct v4l2_register *reg)
1219{ 1235{
@@ -1221,7 +1237,8 @@ static int vidioc_g_register(struct file *file, void *priv,
1221 struct em28xx *dev = fh->dev; 1237 struct em28xx *dev = fh->dev;
1222 int ret; 1238 int ret;
1223 1239
1224 if (reg->match_type == V4L2_CHIP_MATCH_AC97) { 1240 switch (reg->match_type) {
1241 case V4L2_CHIP_MATCH_AC97:
1225 mutex_lock(&dev->lock); 1242 mutex_lock(&dev->lock);
1226 ret = em28xx_read_ac97(dev, reg->reg); 1243 ret = em28xx_read_ac97(dev, reg->reg);
1227 mutex_unlock(&dev->lock); 1244 mutex_unlock(&dev->lock);
@@ -1230,11 +1247,18 @@ static int vidioc_g_register(struct file *file, void *priv,
1230 1247
1231 reg->val = ret; 1248 reg->val = ret;
1232 return 0; 1249 return 0;
1233 } 1250 case V4L2_CHIP_MATCH_I2C_DRIVER:
1234 1251 em28xx_i2c_call_clients(dev, VIDIOC_DBG_G_REGISTER, reg);
1235 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 1252 return 0;
1253 case V4L2_CHIP_MATCH_I2C_ADDR:
1254 /* Not supported yet */
1236 return -EINVAL; 1255 return -EINVAL;
1256 default:
1257 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
1258 return -EINVAL;
1259 }
1237 1260
1261 /* Match host */
1238 if (em28xx_reg_len(reg->reg) == 1) { 1262 if (em28xx_reg_len(reg->reg) == 1) {
1239 mutex_lock(&dev->lock); 1263 mutex_lock(&dev->lock);
1240 ret = em28xx_read_reg(dev, reg->reg); 1264 ret = em28xx_read_reg(dev, reg->reg);
@@ -1267,14 +1291,25 @@ static int vidioc_s_register(struct file *file, void *priv,
1267 __le64 buf; 1291 __le64 buf;
1268 int rc; 1292 int rc;
1269 1293
1270 if (reg->match_type == V4L2_CHIP_MATCH_AC97) { 1294 switch (reg->match_type) {
1295 case V4L2_CHIP_MATCH_AC97:
1271 mutex_lock(&dev->lock); 1296 mutex_lock(&dev->lock);
1272 rc = em28xx_write_ac97(dev, reg->reg, reg->val); 1297 rc = em28xx_write_ac97(dev, reg->reg, reg->val);
1273 mutex_unlock(&dev->lock); 1298 mutex_unlock(&dev->lock);
1274 1299
1275 return rc; 1300 return rc;
1301 case V4L2_CHIP_MATCH_I2C_DRIVER:
1302 em28xx_i2c_call_clients(dev, VIDIOC_DBG_S_REGISTER, reg);
1303 return 0;
1304 case V4L2_CHIP_MATCH_I2C_ADDR:
1305 /* Not supported yet */
1306 return -EINVAL;
1307 default:
1308 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
1309 return -EINVAL;
1276 } 1310 }
1277 1311
1312 /* Match host */
1278 buf = cpu_to_le64(reg->val); 1313 buf = cpu_to_le64(reg->val);
1279 1314
1280 mutex_lock(&dev->lock); 1315 mutex_lock(&dev->lock);
@@ -1927,6 +1962,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
1927#ifdef CONFIG_VIDEO_ADV_DEBUG 1962#ifdef CONFIG_VIDEO_ADV_DEBUG
1928 .vidioc_g_register = vidioc_g_register, 1963 .vidioc_g_register = vidioc_g_register,
1929 .vidioc_s_register = vidioc_s_register, 1964 .vidioc_s_register = vidioc_s_register,
1965 .vidioc_g_chip_ident = vidioc_g_chip_ident,
1930#endif 1966#endif
1931#ifdef CONFIG_VIDEO_V4L1_COMPAT 1967#ifdef CONFIG_VIDEO_V4L1_COMPAT
1932 .vidiocgmbuf = vidiocgmbuf, 1968 .vidiocgmbuf = vidiocgmbuf,