Skip to content

Commit e6bee36

Browse files
Hans Verkuilmchehab
authored andcommitted
[media] v4l2: integrate support for VIDIOC_QUERY_EXT_CTRL
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>
1 parent d9a2547 commit e6bee36

4 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎drivers/media/v4l2-core/v4l2-dev.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
575575
be valid if the filehandle passed the control handler. */
576576
if (vdev->ctrl_handler || ops->vidioc_queryctrl)
577577
set_bit(_IOC_NR(VIDIOC_QUERYCTRL), valid_ioctls);
578+
if (vdev->ctrl_handler || ops->vidioc_query_ext_ctrl)
579+
set_bit(_IOC_NR(VIDIOC_QUERY_EXT_CTRL), valid_ioctls);
578580
if (vdev->ctrl_handler || ops->vidioc_g_ctrl || ops->vidioc_g_ext_ctrls)
579581
set_bit(_IOC_NR(VIDIOC_G_CTRL), valid_ioctls);
580582
if (vdev->ctrl_handler || ops->vidioc_s_ctrl || ops->vidioc_s_ext_ctrls)

‎drivers/media/v4l2-core/v4l2-ioctl.c‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,21 @@ static void v4l_print_queryctrl(const void *arg, bool write_only)
525525
p->step, p->default_value, p->flags);
526526
}
527527

528+
static void v4l_print_query_ext_ctrl(const void *arg, bool write_only)
529+
{
530+
const struct v4l2_query_ext_ctrl *p = arg;
531+
532+
pr_cont("id=0x%x, type=%d, name=%.*s, min/max=%lld/%lld, "
533+
"step=%lld, default=%lld, flags=0x%08x, elem_size=%u, elems=%u, "
534+
"nr_of_dims=%u, dims=%u,%u,%u,%u,%u,%u,%u,%u\n",
535+
p->id, p->type, (int)sizeof(p->name), p->name,
536+
p->minimum, p->maximum,
537+
p->step, p->default_value, p->flags,
538+
p->elem_size, p->elems, p->nr_of_dims,
539+
p->dims[0], p->dims[1], p->dims[2], p->dims[3],
540+
p->dims[4], p->dims[5], p->dims[6], p->dims[7]);
541+
}
542+
528543
static void v4l_print_querymenu(const void *arg, bool write_only)
529544
{
530545
const struct v4l2_querymenu *p = arg;
@@ -1561,6 +1576,23 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
15611576
return -ENOTTY;
15621577
}
15631578

1579+
static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,
1580+
struct file *file, void *fh, void *arg)
1581+
{
1582+
struct video_device *vfd = video_devdata(file);
1583+
struct v4l2_query_ext_ctrl *p = arg;
1584+
struct v4l2_fh *vfh =
1585+
test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
1586+
1587+
if (vfh && vfh->ctrl_handler)
1588+
return v4l2_query_ext_ctrl(vfh->ctrl_handler, p);
1589+
if (vfd->ctrl_handler)
1590+
return v4l2_query_ext_ctrl(vfd->ctrl_handler, p);
1591+
if (ops->vidioc_query_ext_ctrl)
1592+
return ops->vidioc_query_ext_ctrl(file, fh, p);
1593+
return -ENOTTY;
1594+
}
1595+
15641596
static int v4l_querymenu(const struct v4l2_ioctl_ops *ops,
15651597
struct file *file, void *fh, void *arg)
15661598
{
@@ -2121,6 +2153,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
21212153
IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, v4l_print_dv_timings_cap, INFO_FL_CLEAR(v4l2_dv_timings_cap, type)),
21222154
IOCTL_INFO_FNC(VIDIOC_ENUM_FREQ_BANDS, v4l_enum_freq_bands, v4l_print_freq_band, 0),
21232155
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)),
2156+
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)),
21242157
};
21252158
#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
21262159

‎drivers/media/v4l2-core/v4l2-subdev.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
139139
case VIDIOC_QUERYCTRL:
140140
return v4l2_queryctrl(vfh->ctrl_handler, arg);
141141

142+
case VIDIOC_QUERY_EXT_CTRL:
143+
return v4l2_query_ext_ctrl(vfh->ctrl_handler, arg);
144+
142145
case VIDIOC_QUERYMENU:
143146
return v4l2_querymenu(vfh->ctrl_handler, arg);
144147

‎include/media/v4l2-ioctl.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ struct v4l2_ioctl_ops {
158158
/* Control handling */
159159
int (*vidioc_queryctrl) (struct file *file, void *fh,
160160
struct v4l2_queryctrl *a);
161+
int (*vidioc_query_ext_ctrl) (struct file *file, void *fh,
162+
struct v4l2_query_ext_ctrl *a);
161163
int (*vidioc_g_ctrl) (struct file *file, void *fh,
162164
struct v4l2_control *a);
163165
int (*vidioc_s_ctrl) (struct file *file, void *fh,

0 commit comments

Comments
 (0)