aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-05-16 08:24:06 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-08 22:43:04 -0400
commit11bbc1cadb638aaccb4764c6e16807b36b53cf19 (patch)
tree101be79d45abd28e30f5cc3ee6372004bf7880b9 /drivers/media
parenta42b57f5aacf2b43f3e7931e8b9c609051839aa8 (diff)
V4L/DVB: v4l2: hook up the new control framework into the core framework
Add the calls needed to automatically merge subdev controls into a bridge control handler. Hook up the control framework in __video_ioctl2 and video_register_device. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/v4l2-dev.c8
-rw-r--r--drivers/media/video/v4l2-device.c7
-rw-r--r--drivers/media/video/v4l2-ioctl.c46
3 files changed, 46 insertions, 15 deletions
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 9e89bf617790..21ffd030611e 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -447,8 +447,12 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
447 447
448 vdev->vfl_type = type; 448 vdev->vfl_type = type;
449 vdev->cdev = NULL; 449 vdev->cdev = NULL;
450 if (vdev->v4l2_dev && vdev->v4l2_dev->dev) 450 if (vdev->v4l2_dev) {
451 vdev->parent = vdev->v4l2_dev->dev; 451 if (vdev->v4l2_dev->dev)
452 vdev->parent = vdev->v4l2_dev->dev;
453 if (vdev->ctrl_handler == NULL)
454 vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler;
455 }
452 456
453 /* Part 2: find a free minor, device node number and device index. */ 457 /* Part 2: find a free minor, device node number and device index. */
454#ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES 458#ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 5a7dc4afe92a..0b08f96b74a5 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -26,6 +26,7 @@
26#endif 26#endif
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <media/v4l2-device.h> 28#include <media/v4l2-device.h>
29#include <media/v4l2-ctrls.h>
29 30
30int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev) 31int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
31{ 32{
@@ -115,6 +116,8 @@ EXPORT_SYMBOL_GPL(v4l2_device_unregister);
115int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, 116int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
116 struct v4l2_subdev *sd) 117 struct v4l2_subdev *sd)
117{ 118{
119 int err;
120
118 /* Check for valid input */ 121 /* Check for valid input */
119 if (v4l2_dev == NULL || sd == NULL || !sd->name[0]) 122 if (v4l2_dev == NULL || sd == NULL || !sd->name[0])
120 return -EINVAL; 123 return -EINVAL;
@@ -122,6 +125,10 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
122 WARN_ON(sd->v4l2_dev != NULL); 125 WARN_ON(sd->v4l2_dev != NULL);
123 if (!try_module_get(sd->owner)) 126 if (!try_module_get(sd->owner))
124 return -ENODEV; 127 return -ENODEV;
128 /* This just returns 0 if either of the two args is NULL */
129 err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler);
130 if (err)
131 return err;
125 sd->v4l2_dev = v4l2_dev; 132 sd->v4l2_dev = v4l2_dev;
126 spin_lock(&v4l2_dev->lock); 133 spin_lock(&v4l2_dev->lock);
127 list_add_tail(&sd->list, &v4l2_dev->subdevs); 134 list_add_tail(&sd->list, &v4l2_dev->subdevs);
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 0eeceae50329..dd9283fcb564 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -26,6 +26,7 @@
26#endif 26#endif
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/v4l2-ioctl.h> 28#include <media/v4l2-ioctl.h>
29#include <media/v4l2-ctrls.h>
29#include <media/v4l2-fh.h> 30#include <media/v4l2-fh.h>
30#include <media/v4l2-event.h> 31#include <media/v4l2-event.h>
31#include <media/v4l2-chip-ident.h> 32#include <media/v4l2-chip-ident.h>
@@ -1259,9 +1260,12 @@ static long __video_do_ioctl(struct file *file,
1259 { 1260 {
1260 struct v4l2_queryctrl *p = arg; 1261 struct v4l2_queryctrl *p = arg;
1261 1262
1262 if (!ops->vidioc_queryctrl) 1263 if (vfd->ctrl_handler)
1264 ret = v4l2_queryctrl(vfd->ctrl_handler, p);
1265 else if (ops->vidioc_queryctrl)
1266 ret = ops->vidioc_queryctrl(file, fh, p);
1267 else
1263 break; 1268 break;
1264 ret = ops->vidioc_queryctrl(file, fh, p);
1265 if (!ret) 1269 if (!ret)
1266 dbgarg(cmd, "id=0x%x, type=%d, name=%s, min/max=%d/%d, " 1270 dbgarg(cmd, "id=0x%x, type=%d, name=%s, min/max=%d/%d, "
1267 "step=%d, default=%d, flags=0x%08x\n", 1271 "step=%d, default=%d, flags=0x%08x\n",
@@ -1276,7 +1280,9 @@ static long __video_do_ioctl(struct file *file,
1276 { 1280 {
1277 struct v4l2_control *p = arg; 1281 struct v4l2_control *p = arg;
1278 1282
1279 if (ops->vidioc_g_ctrl) 1283 if (vfd->ctrl_handler)
1284 ret = v4l2_g_ctrl(vfd->ctrl_handler, p);
1285 else if (ops->vidioc_g_ctrl)
1280 ret = ops->vidioc_g_ctrl(file, fh, p); 1286 ret = ops->vidioc_g_ctrl(file, fh, p);
1281 else if (ops->vidioc_g_ext_ctrls) { 1287 else if (ops->vidioc_g_ext_ctrls) {
1282 struct v4l2_ext_controls ctrls; 1288 struct v4l2_ext_controls ctrls;
@@ -1306,11 +1312,16 @@ static long __video_do_ioctl(struct file *file,
1306 struct v4l2_ext_controls ctrls; 1312 struct v4l2_ext_controls ctrls;
1307 struct v4l2_ext_control ctrl; 1313 struct v4l2_ext_control ctrl;
1308 1314
1309 if (!ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls) 1315 if (!vfd->ctrl_handler &&
1316 !ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls)
1310 break; 1317 break;
1311 1318
1312 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value); 1319 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1313 1320
1321 if (vfd->ctrl_handler) {
1322 ret = v4l2_s_ctrl(vfd->ctrl_handler, p);
1323 break;
1324 }
1314 if (ops->vidioc_s_ctrl) { 1325 if (ops->vidioc_s_ctrl) {
1315 ret = ops->vidioc_s_ctrl(file, fh, p); 1326 ret = ops->vidioc_s_ctrl(file, fh, p);
1316 break; 1327 break;
@@ -1332,10 +1343,12 @@ static long __video_do_ioctl(struct file *file,
1332 struct v4l2_ext_controls *p = arg; 1343 struct v4l2_ext_controls *p = arg;
1333 1344
1334 p->error_idx = p->count; 1345 p->error_idx = p->count;
1335 if (!ops->vidioc_g_ext_ctrls) 1346 if (vfd->ctrl_handler)
1336 break; 1347 ret = v4l2_g_ext_ctrls(vfd->ctrl_handler, p);
1337 if (check_ext_ctrls(p, 0)) 1348 else if (ops->vidioc_g_ext_ctrls && check_ext_ctrls(p, 0))
1338 ret = ops->vidioc_g_ext_ctrls(file, fh, p); 1349 ret = ops->vidioc_g_ext_ctrls(file, fh, p);
1350 else
1351 break;
1339 v4l_print_ext_ctrls(cmd, vfd, p, !ret); 1352 v4l_print_ext_ctrls(cmd, vfd, p, !ret);
1340 break; 1353 break;
1341 } 1354 }
@@ -1344,10 +1357,12 @@ static long __video_do_ioctl(struct file *file,
1344 struct v4l2_ext_controls *p = arg; 1357 struct v4l2_ext_controls *p = arg;
1345 1358
1346 p->error_idx = p->count; 1359 p->error_idx = p->count;
1347 if (!ops->vidioc_s_ext_ctrls) 1360 if (!vfd->ctrl_handler && !ops->vidioc_s_ext_ctrls)
1348 break; 1361 break;
1349 v4l_print_ext_ctrls(cmd, vfd, p, 1); 1362 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1350 if (check_ext_ctrls(p, 0)) 1363 if (vfd->ctrl_handler)
1364 ret = v4l2_s_ext_ctrls(vfd->ctrl_handler, p);
1365 else if (check_ext_ctrls(p, 0))
1351 ret = ops->vidioc_s_ext_ctrls(file, fh, p); 1366 ret = ops->vidioc_s_ext_ctrls(file, fh, p);
1352 break; 1367 break;
1353 } 1368 }
@@ -1356,10 +1371,12 @@ static long __video_do_ioctl(struct file *file,
1356 struct v4l2_ext_controls *p = arg; 1371 struct v4l2_ext_controls *p = arg;
1357 1372
1358 p->error_idx = p->count; 1373 p->error_idx = p->count;
1359 if (!ops->vidioc_try_ext_ctrls) 1374 if (!vfd->ctrl_handler && !ops->vidioc_try_ext_ctrls)
1360 break; 1375 break;
1361 v4l_print_ext_ctrls(cmd, vfd, p, 1); 1376 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1362 if (check_ext_ctrls(p, 0)) 1377 if (vfd->ctrl_handler)
1378 ret = v4l2_try_ext_ctrls(vfd->ctrl_handler, p);
1379 else if (check_ext_ctrls(p, 0))
1363 ret = ops->vidioc_try_ext_ctrls(file, fh, p); 1380 ret = ops->vidioc_try_ext_ctrls(file, fh, p);
1364 break; 1381 break;
1365 } 1382 }
@@ -1367,9 +1384,12 @@ static long __video_do_ioctl(struct file *file,
1367 { 1384 {
1368 struct v4l2_querymenu *p = arg; 1385 struct v4l2_querymenu *p = arg;
1369 1386
1370 if (!ops->vidioc_querymenu) 1387 if (vfd->ctrl_handler)
1388 ret = v4l2_querymenu(vfd->ctrl_handler, p);
1389 else if (ops->vidioc_querymenu)
1390 ret = ops->vidioc_querymenu(file, fh, p);
1391 else
1371 break; 1392 break;
1372 ret = ops->vidioc_querymenu(file, fh, p);
1373 if (!ret) 1393 if (!ret)
1374 dbgarg(cmd, "id=0x%x, index=%d, name=%s\n", 1394 dbgarg(cmd, "id=0x%x, index=%d, name=%s\n",
1375 p->id, p->index, p->name); 1395 p->id, p->index, p->name);