[media] v4l2: integrate support for VIDIOC_QUERY_EXT_CTRL
authorHans Verkuil <hans.verkuil@cisco.com>
Tue, 10 Jun 2014 07:22:06 +0000 (04:22 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Thu, 17 Jul 2014 13:38:44 +0000 (10:38 -0300)
Add the v4l2 core plumbing for the new VIDIOC_QUERY_EXT_CTRL ioctl.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/v4l2-dev.c
drivers/media/v4l2-core/v4l2-ioctl.c
drivers/media/v4l2-core/v4l2-subdev.c
include/media/v4l2-ioctl.h

index 35698aa377f5fdbb0d86f0dfa61e159300dd86ee..1cfdbdd034bce23b81cfffbc660fa020d92dafb2 100644 (file)
@@ -575,6 +575,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
           be valid if the filehandle passed the control handler. */
        if (vdev->ctrl_handler || ops->vidioc_queryctrl)
                set_bit(_IOC_NR(VIDIOC_QUERYCTRL), valid_ioctls);
+       if (vdev->ctrl_handler || ops->vidioc_query_ext_ctrl)
+               set_bit(_IOC_NR(VIDIOC_QUERY_EXT_CTRL), valid_ioctls);
        if (vdev->ctrl_handler || ops->vidioc_g_ctrl || ops->vidioc_g_ext_ctrls)
                set_bit(_IOC_NR(VIDIOC_G_CTRL), valid_ioctls);
        if (vdev->ctrl_handler || ops->vidioc_s_ctrl || ops->vidioc_s_ext_ctrls)
index 8d4a25d62e476aa887d4035f0288475f42679512..c38a6208d2cdbe081f6abde5e8ff1c8bce924abb 100644 (file)
@@ -525,6 +525,21 @@ static void v4l_print_queryctrl(const void *arg, bool write_only)
                        p->step, p->default_value, p->flags);
 }
 
+static void v4l_print_query_ext_ctrl(const void *arg, bool write_only)
+{
+       const struct v4l2_query_ext_ctrl *p = arg;
+
+       pr_cont("id=0x%x, type=%d, name=%.*s, min/max=%lld/%lld, "
+               "step=%lld, default=%lld, flags=0x%08x, elem_size=%u, elems=%u, "
+               "nr_of_dims=%u, dims=%u,%u,%u,%u,%u,%u,%u,%u\n",
+                       p->id, p->type, (int)sizeof(p->name), p->name,
+                       p->minimum, p->maximum,
+                       p->step, p->default_value, p->flags,
+                       p->elem_size, p->elems, p->nr_of_dims,
+                       p->dims[0], p->dims[1], p->dims[2], p->dims[3],
+                       p->dims[4], p->dims[5], p->dims[6], p->dims[7]);
+}
+
 static void v4l_print_querymenu(const void *arg, bool write_only)
 {
        const struct v4l2_querymenu *p = arg;
@@ -1561,6 +1576,23 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
        return -ENOTTY;
 }
 
+static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,
+                               struct file *file, void *fh, void *arg)
+{
+       struct video_device *vfd = video_devdata(file);
+       struct v4l2_query_ext_ctrl *p = arg;
+       struct v4l2_fh *vfh =
+               test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+
+       if (vfh && vfh->ctrl_handler)
+               return v4l2_query_ext_ctrl(vfh->ctrl_handler, p);
+       if (vfd->ctrl_handler)
+               return v4l2_query_ext_ctrl(vfd->ctrl_handler, p);
+       if (ops->vidioc_query_ext_ctrl)
+               return ops->vidioc_query_ext_ctrl(file, fh, p);
+       return -ENOTTY;
+}
+
 static int v4l_querymenu(const struct v4l2_ioctl_ops *ops,
                                struct file *file, void *fh, void *arg)
 {
@@ -2121,6 +2153,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
        IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, v4l_print_dv_timings_cap, INFO_FL_CLEAR(v4l2_dv_timings_cap, type)),
        IOCTL_INFO_FNC(VIDIOC_ENUM_FREQ_BANDS, v4l_enum_freq_bands, v4l_print_freq_band, 0),
        IOCTL_INFO_FNC(VIDIOC_DBG_G_CHIP_INFO, v4l_dbg_g_chip_info, v4l_print_dbg_chip_info, INFO_FL_CLEAR(v4l2_dbg_chip_info, match)),
+       IOCTL_INFO_FNC(VIDIOC_QUERY_EXT_CTRL, v4l_query_ext_ctrl, v4l_print_query_ext_ctrl, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_query_ext_ctrl, id)),
 };
 #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
 
index 058c1a6e839275ce1e61cad44946b5c30093c0ad..b984f33de7f4aa330d490015b552e08917a64c68 100644 (file)
@@ -139,6 +139,9 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
        case VIDIOC_QUERYCTRL:
                return v4l2_queryctrl(vfh->ctrl_handler, arg);
 
+       case VIDIOC_QUERY_EXT_CTRL:
+               return v4l2_query_ext_ctrl(vfh->ctrl_handler, arg);
+
        case VIDIOC_QUERYMENU:
                return v4l2_querymenu(vfh->ctrl_handler, arg);
 
index 50cf7c110a70ead9197ca15928d2cd1520285889..53605f0f990340ddc3da5a822d2a7945ad3ce94b 100644 (file)
@@ -158,6 +158,8 @@ struct v4l2_ioctl_ops {
                /* Control handling */
        int (*vidioc_queryctrl)        (struct file *file, void *fh,
                                        struct v4l2_queryctrl *a);
+       int (*vidioc_query_ext_ctrl)   (struct file *file, void *fh,
+                                       struct v4l2_query_ext_ctrl *a);
        int (*vidioc_g_ctrl)           (struct file *file, void *fh,
                                        struct v4l2_control *a);
        int (*vidioc_s_ctrl)           (struct file *file, void *fh,