提交 2d28b686 编写于 作者: H Hans Verkuil 提交者: Mauro Carvalho Chehab

[media] v4l2-ioctl: add ctrl_handler to v4l2_fh

This is required to implement control events and is also needed to allow
for per-filehandle control handlers.
Signed-off-by: NHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 7ebbc39f
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
int v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev) int v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
{ {
fh->vdev = vdev; fh->vdev = vdev;
/* Inherit from video_device. May be overridden by the driver. */
fh->ctrl_handler = vdev->ctrl_handler;
INIT_LIST_HEAD(&fh->list); INIT_LIST_HEAD(&fh->list);
set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags); set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags);
fh->prio = V4L2_PRIORITY_UNSET; fh->prio = V4L2_PRIORITY_UNSET;
......
...@@ -1420,7 +1420,9 @@ static long __video_do_ioctl(struct file *file, ...@@ -1420,7 +1420,9 @@ static long __video_do_ioctl(struct file *file,
{ {
struct v4l2_queryctrl *p = arg; struct v4l2_queryctrl *p = arg;
if (vfd->ctrl_handler) if (vfh && vfh->ctrl_handler)
ret = v4l2_queryctrl(vfh->ctrl_handler, p);
else if (vfd->ctrl_handler)
ret = v4l2_queryctrl(vfd->ctrl_handler, p); ret = v4l2_queryctrl(vfd->ctrl_handler, p);
else if (ops->vidioc_queryctrl) else if (ops->vidioc_queryctrl)
ret = ops->vidioc_queryctrl(file, fh, p); ret = ops->vidioc_queryctrl(file, fh, p);
...@@ -1440,7 +1442,9 @@ static long __video_do_ioctl(struct file *file, ...@@ -1440,7 +1442,9 @@ static long __video_do_ioctl(struct file *file,
{ {
struct v4l2_control *p = arg; struct v4l2_control *p = arg;
if (vfd->ctrl_handler) if (vfh && vfh->ctrl_handler)
ret = v4l2_g_ctrl(vfh->ctrl_handler, p);
else if (vfd->ctrl_handler)
ret = v4l2_g_ctrl(vfd->ctrl_handler, p); ret = v4l2_g_ctrl(vfd->ctrl_handler, p);
else if (ops->vidioc_g_ctrl) else if (ops->vidioc_g_ctrl)
ret = ops->vidioc_g_ctrl(file, fh, p); ret = ops->vidioc_g_ctrl(file, fh, p);
...@@ -1472,12 +1476,16 @@ static long __video_do_ioctl(struct file *file, ...@@ -1472,12 +1476,16 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_ext_controls ctrls; struct v4l2_ext_controls ctrls;
struct v4l2_ext_control ctrl; struct v4l2_ext_control ctrl;
if (!vfd->ctrl_handler && if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler &&
!ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls) !ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls)
break; break;
dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value); dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
if (vfh && vfh->ctrl_handler) {
ret = v4l2_s_ctrl(vfh->ctrl_handler, p);
break;
}
if (vfd->ctrl_handler) { if (vfd->ctrl_handler) {
ret = v4l2_s_ctrl(vfd->ctrl_handler, p); ret = v4l2_s_ctrl(vfd->ctrl_handler, p);
break; break;
...@@ -1503,7 +1511,9 @@ static long __video_do_ioctl(struct file *file, ...@@ -1503,7 +1511,9 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_ext_controls *p = arg; struct v4l2_ext_controls *p = arg;
p->error_idx = p->count; p->error_idx = p->count;
if (vfd->ctrl_handler) if (vfh && vfh->ctrl_handler)
ret = v4l2_g_ext_ctrls(vfh->ctrl_handler, p);
else if (vfd->ctrl_handler)
ret = v4l2_g_ext_ctrls(vfd->ctrl_handler, p); ret = v4l2_g_ext_ctrls(vfd->ctrl_handler, p);
else if (ops->vidioc_g_ext_ctrls && check_ext_ctrls(p, 0)) else if (ops->vidioc_g_ext_ctrls && check_ext_ctrls(p, 0))
ret = ops->vidioc_g_ext_ctrls(file, fh, p); ret = ops->vidioc_g_ext_ctrls(file, fh, p);
...@@ -1517,10 +1527,13 @@ static long __video_do_ioctl(struct file *file, ...@@ -1517,10 +1527,13 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_ext_controls *p = arg; struct v4l2_ext_controls *p = arg;
p->error_idx = p->count; p->error_idx = p->count;
if (!vfd->ctrl_handler && !ops->vidioc_s_ext_ctrls) if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler &&
!ops->vidioc_s_ext_ctrls)
break; break;
v4l_print_ext_ctrls(cmd, vfd, p, 1); v4l_print_ext_ctrls(cmd, vfd, p, 1);
if (vfd->ctrl_handler) if (vfh && vfh->ctrl_handler)
ret = v4l2_s_ext_ctrls(vfh->ctrl_handler, p);
else if (vfd->ctrl_handler)
ret = v4l2_s_ext_ctrls(vfd->ctrl_handler, p); ret = v4l2_s_ext_ctrls(vfd->ctrl_handler, p);
else if (check_ext_ctrls(p, 0)) else if (check_ext_ctrls(p, 0))
ret = ops->vidioc_s_ext_ctrls(file, fh, p); ret = ops->vidioc_s_ext_ctrls(file, fh, p);
...@@ -1531,10 +1544,13 @@ static long __video_do_ioctl(struct file *file, ...@@ -1531,10 +1544,13 @@ static long __video_do_ioctl(struct file *file,
struct v4l2_ext_controls *p = arg; struct v4l2_ext_controls *p = arg;
p->error_idx = p->count; p->error_idx = p->count;
if (!vfd->ctrl_handler && !ops->vidioc_try_ext_ctrls) if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler &&
!ops->vidioc_try_ext_ctrls)
break; break;
v4l_print_ext_ctrls(cmd, vfd, p, 1); v4l_print_ext_ctrls(cmd, vfd, p, 1);
if (vfd->ctrl_handler) if (vfh && vfh->ctrl_handler)
ret = v4l2_try_ext_ctrls(vfh->ctrl_handler, p);
else if (vfd->ctrl_handler)
ret = v4l2_try_ext_ctrls(vfd->ctrl_handler, p); ret = v4l2_try_ext_ctrls(vfd->ctrl_handler, p);
else if (check_ext_ctrls(p, 0)) else if (check_ext_ctrls(p, 0))
ret = ops->vidioc_try_ext_ctrls(file, fh, p); ret = ops->vidioc_try_ext_ctrls(file, fh, p);
...@@ -1544,7 +1560,9 @@ static long __video_do_ioctl(struct file *file, ...@@ -1544,7 +1560,9 @@ static long __video_do_ioctl(struct file *file,
{ {
struct v4l2_querymenu *p = arg; struct v4l2_querymenu *p = arg;
if (vfd->ctrl_handler) if (vfh && vfh->ctrl_handler)
ret = v4l2_querymenu(vfh->ctrl_handler, p);
else if (vfd->ctrl_handler)
ret = v4l2_querymenu(vfd->ctrl_handler, p); ret = v4l2_querymenu(vfd->ctrl_handler, p);
else if (ops->vidioc_querymenu) else if (ops->vidioc_querymenu)
ret = ops->vidioc_querymenu(file, fh, p); ret = ops->vidioc_querymenu(file, fh, p);
......
...@@ -30,11 +30,13 @@ ...@@ -30,11 +30,13 @@
struct video_device; struct video_device;
struct v4l2_events; struct v4l2_events;
struct v4l2_ctrl_handler;
struct v4l2_fh { struct v4l2_fh {
struct list_head list; struct list_head list;
struct video_device *vdev; struct video_device *vdev;
struct v4l2_events *events; /* events, pending and subscribed */ struct v4l2_events *events; /* events, pending and subscribed */
struct v4l2_ctrl_handler *ctrl_handler;
enum v4l2_priority prio; enum v4l2_priority prio;
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册