* [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks
@ 2024-12-09 19:25 Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 01/10] media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl Ricardo Ribalda
` (9 more replies)
0 siblings, 10 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
Most of the drivers use the control framework or can use the superset
version of these callbacks: vidioc_g/s_ext_ctrl and
vidioc_query_ext_ctrl.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
Ricardo Ribalda (10):
media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl
media: pvrusb2: Convert queryctrl to query_ext_ctrl
media: pvrusb2: Remove g/s_ctrl callbacks
media: uvcvideo: Remove vidioc_queryctrl
media: atomisp: Replace queryctrl with query_ext_ctrl
media: atomisp: Remove vidioc_g/s callback
media: v4l2: Remove vidioc_queryctrl callback
media: v4l2: Remove vidioc_g_ctrl callback
media: cx231xx: Replace s_ctrl with s_ext_ctrls
media: v4l2: Remove vidioc_s_ctrl callback
drivers/media/usb/cx231xx/cx231xx-417.c | 21 ++++++++----
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 40 +++++------------------
drivers/media/usb/uvc/uvc_v4l2.c | 10 ------
drivers/media/v4l2-core/v4l2-dev.c | 6 ++--
drivers/media/v4l2-core/v4l2-ioctl.c | 28 ++++++++++++----
drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 36 ++++++++++----------
include/media/v4l2-ioctl.h | 12 -------
7 files changed, 65 insertions(+), 88 deletions(-)
---
base-commit: 6c10d1adae82e1c8da16e7ebd2320e69f20b9d6f
change-id: 20241209-queryctrl-5c3632b7c857
Best regards,
--
Ricardo Ribalda <ribalda@chromium.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 01/10] media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
2024-12-09 19:34 ` Hans Verkuil
2024-12-09 19:25 ` [PATCH 02/10] media: pvrusb2: Convert queryctrl to query_ext_ctrl Ricardo Ribalda
` (8 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
v4l2_queryctrl is a subset of v4l2_query_ext_ctrl. If the driver does
not implement v4l2_queryctrl we can implement it with
v4l2_query_ext_ctrl.
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/v4l2-core/v4l2-dev.c | 3 ++-
drivers/media/v4l2-core/v4l2-ioctl.c | 22 +++++++++++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 5bcaeeba4d09..252308a67fa8 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -572,7 +572,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
and that can't be tested here. If the bit for these control ioctls
is set, then the ioctl is valid. But if it is 0, then it can still
be valid if the filehandle passed the control handler. */
- if (vdev->ctrl_handler || ops->vidioc_queryctrl)
+ if (vdev->ctrl_handler || ops->vidioc_queryctrl ||
+ ops->vidioc_query_ext_ctrl)
__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);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 0304daa8471d..a5562f2f1fc9 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2284,9 +2284,11 @@ static int v4l_queryctrl(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 qec;
struct v4l2_queryctrl *p = arg;
struct v4l2_fh *vfh =
test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+ int ret;
if (vfh && vfh->ctrl_handler)
return v4l2_queryctrl(vfh->ctrl_handler, p);
@@ -2294,7 +2296,25 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
return v4l2_queryctrl(vfd->ctrl_handler, p);
if (ops->vidioc_queryctrl)
return ops->vidioc_queryctrl(file, fh, p);
- return -ENOTTY;
+ if (!ops->vidioc_query_ext_ctrl)
+ return -ENOTTY;
+
+ /* Simulate query_ext_ctr using query_ctrl. */
+ qec.id = p->id;
+ ret = ops->vidioc_query_ext_ctrl(file, fh, &qec);
+ if (ret)
+ return ret;
+
+ p->id = qec.id;
+ p->type = qec.type;
+ strscpy(p->name, qec.name, sizeof(p->name));
+ p->minimum = qec.minimum;
+ p->maximum = qec.maximum;
+ p->step = qec.step;
+ p->default_value = qec.default_value;
+ p->flags = qec.flags;
+
+ return 0;
}
static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 02/10] media: pvrusb2: Convert queryctrl to query_ext_ctrl
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 01/10] media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 03/10] media: pvrusb2: Remove g/s_ctrl callbacks Ricardo Ribalda
` (7 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
The driver was missing support for query_ext_ctrl. Instead of adding a
new callback for it, replace the current implementation of queryctrl and
let the ioctl framework emulate the old function.
Most of the fields are identical, so the change is pretty simple.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index d608b793fa84..7c8be6a0cf7c 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -497,8 +497,8 @@ static int pvr2_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
return pvr2_hdw_set_streaming(hdw, 0);
}
-static int pvr2_queryctrl(struct file *file, void *priv,
- struct v4l2_queryctrl *vc)
+static int pvr2_query_ext_ctrl(struct file *file, void *priv,
+ struct v4l2_query_ext_ctrl *vc)
{
struct pvr2_v4l2_fh *fh = file->private_data;
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
@@ -521,13 +521,16 @@ static int pvr2_queryctrl(struct file *file, void *priv,
}
pvr2_trace(PVR2_TRACE_V4LIOCTL,
- "QUERYCTRL id=0x%x mapping name=%s (%s)",
+ "QUERYEXTCTRL id=0x%x mapping name=%s (%s)",
vc->id, pvr2_ctrl_get_name(cptr),
pvr2_ctrl_get_desc(cptr));
strscpy(vc->name, pvr2_ctrl_get_desc(cptr), sizeof(vc->name));
vc->flags = pvr2_ctrl_get_v4lflags(cptr);
pvr2_ctrl_get_def(cptr, &val);
vc->default_value = val;
+ vc->nr_of_dims = 0;
+ vc->elems = 1;
+ vc->elem_size = 4;
switch (pvr2_ctrl_get_type(cptr)) {
case pvr2_ctl_enum:
vc->type = V4L2_CTRL_TYPE_MENU;
@@ -549,7 +552,7 @@ static int pvr2_queryctrl(struct file *file, void *priv,
break;
default:
pvr2_trace(PVR2_TRACE_V4LIOCTL,
- "QUERYCTRL id=0x%x name=%s not mappable",
+ "QUERYEXTCTRL id=0x%x name=%s not mappable",
vc->id, pvr2_ctrl_get_name(cptr));
return -EINVAL;
}
@@ -812,7 +815,7 @@ static const struct v4l2_ioctl_ops pvr2_ioctl_ops = {
.vidioc_try_fmt_vid_cap = pvr2_try_fmt_vid_cap,
.vidioc_streamon = pvr2_streamon,
.vidioc_streamoff = pvr2_streamoff,
- .vidioc_queryctrl = pvr2_queryctrl,
+ .vidioc_query_ext_ctrl = pvr2_query_ext_ctrl,
.vidioc_querymenu = pvr2_querymenu,
.vidioc_g_ctrl = pvr2_g_ctrl,
.vidioc_s_ctrl = pvr2_s_ctrl,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 03/10] media: pvrusb2: Remove g/s_ctrl callbacks
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 01/10] media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 02/10] media: pvrusb2: Convert queryctrl to query_ext_ctrl Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 04/10] media: uvcvideo: Remove vidioc_queryctrl Ricardo Ribalda
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
The ioctl helpers can emulate g/s_ctrl with g/s_ext_ctrl. Simplify the
code.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 27 ---------------------------
1 file changed, 27 deletions(-)
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index 7c8be6a0cf7c..ad38e1240541 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -574,31 +574,6 @@ static int pvr2_querymenu(struct file *file, void *priv, struct v4l2_querymenu *
return ret;
}
-static int pvr2_g_ctrl(struct file *file, void *priv, struct v4l2_control *vc)
-{
- struct pvr2_v4l2_fh *fh = file->private_data;
- struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
- int val = 0;
- int ret;
-
- ret = pvr2_ctrl_get_value(pvr2_hdw_get_ctrl_v4l(hdw, vc->id),
- &val);
- vc->value = val;
- return ret;
-}
-
-static int pvr2_s_ctrl(struct file *file, void *priv, struct v4l2_control *vc)
-{
- struct pvr2_v4l2_fh *fh = file->private_data;
- struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
- int ret;
-
- ret = pvr2_ctrl_set_value(pvr2_hdw_get_ctrl_v4l(hdw, vc->id),
- vc->value);
- pvr2_hdw_commit_ctl(hdw);
- return ret;
-}
-
static int pvr2_g_ext_ctrls(struct file *file, void *priv,
struct v4l2_ext_controls *ctls)
{
@@ -817,8 +792,6 @@ static const struct v4l2_ioctl_ops pvr2_ioctl_ops = {
.vidioc_streamoff = pvr2_streamoff,
.vidioc_query_ext_ctrl = pvr2_query_ext_ctrl,
.vidioc_querymenu = pvr2_querymenu,
- .vidioc_g_ctrl = pvr2_g_ctrl,
- .vidioc_s_ctrl = pvr2_s_ctrl,
.vidioc_g_ext_ctrls = pvr2_g_ext_ctrls,
.vidioc_s_ext_ctrls = pvr2_s_ext_ctrls,
.vidioc_try_ext_ctrls = pvr2_try_ext_ctrls,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 04/10] media: uvcvideo: Remove vidioc_queryctrl
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
` (2 preceding siblings ...)
2024-12-09 19:25 ` [PATCH 03/10] media: pvrusb2: Remove g/s_ctrl callbacks Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 05/10] media: atomisp: Replace queryctrl with query_ext_ctrl Ricardo Ribalda
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
It can be implemented by the v4l2 ioctl framework using
vidioc_query_ext_ctrl.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/uvc/uvc_v4l2.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 97c5407f6603..39f0ddb6d01c 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -1014,15 +1014,6 @@ static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
return ret;
}
-static int uvc_ioctl_queryctrl(struct file *file, void *fh,
- struct v4l2_queryctrl *qc)
-{
- struct uvc_fh *handle = fh;
- struct uvc_video_chain *chain = handle->chain;
-
- return uvc_query_v4l2_ctrl(chain, qc);
-}
-
static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,
struct v4l2_query_ext_ctrl *qec)
{
@@ -1563,7 +1554,6 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = {
.vidioc_enum_input = uvc_ioctl_enum_input,
.vidioc_g_input = uvc_ioctl_g_input,
.vidioc_s_input = uvc_ioctl_s_input,
- .vidioc_queryctrl = uvc_ioctl_queryctrl,
.vidioc_query_ext_ctrl = uvc_ioctl_query_ext_ctrl,
.vidioc_g_ext_ctrls = uvc_ioctl_g_ext_ctrls,
.vidioc_s_ext_ctrls = uvc_ioctl_s_ext_ctrls,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 05/10] media: atomisp: Replace queryctrl with query_ext_ctrl
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
` (3 preceding siblings ...)
2024-12-09 19:25 ` [PATCH 04/10] media: uvcvideo: Remove vidioc_queryctrl Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 06/10] media: atomisp: Remove vidioc_g/s callback Ricardo Ribalda
` (4 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
The ioctl framework provides an emulator of queryctrl using
query_ext_ctrl.
Replace our implementation of queryctrl to support both.
Now that we are at it:
- Add comment about missing functionality.
- Remove superfluous clear of reserved[0].
- Remove ret var.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 34 +++++++++++++----------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
index 1a960a01854f..d24420d8bd57 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
@@ -34,7 +34,7 @@ static const char *CARD = "ATOM ISP"; /* max size 31 */
* FIXME: ISP should not know beforehand all CIDs supported by sensor.
* Instead, it needs to propagate to sensor unknown CIDs.
*/
-static struct v4l2_queryctrl ci_v4l2_controls[] = {
+static struct v4l2_query_ext_ctrl ci_v4l2_controls[] = {
{
.id = V4L2_CID_AUTO_WHITE_BALANCE,
.type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -1140,31 +1140,35 @@ static int atomisp_s_ctrl(struct file *file, void *fh,
/*
* To query the attributes of a control.
- * applications set the id field of a struct v4l2_queryctrl and call the
+ * applications set the id field of a struct v4l2_query_ext_ctrl and call the
* this ioctl with a pointer to this structure. The driver fills
* the rest of the structure.
*/
-static int atomisp_queryctl(struct file *file, void *fh,
- struct v4l2_queryctrl *qc)
+static int atomisp_query_ext_ctrl(struct file *file, void *fh,
+ struct v4l2_query_ext_ctrl *qc)
{
- int i, ret = -EINVAL;
+ int i;
+ /* TODO: implement V4L2_CTRL_FLAG_NEXT_CTRL */
if (qc->id & V4L2_CTRL_FLAG_NEXT_CTRL)
- return ret;
+ return -EINVAL;
for (i = 0; i < ctrls_num; i++) {
if (ci_v4l2_controls[i].id == qc->id) {
- memcpy(qc, &ci_v4l2_controls[i],
- sizeof(struct v4l2_queryctrl));
- qc->reserved[0] = 0;
- ret = 0;
- break;
+ memcpy(qc, &ci_v4l2_controls[i], sizeof(*qc));
+ qc->nr_of_dims = 0;
+ qc->elems = 1;
+ qc->elem_size = 4;
+ return 0;
}
}
- if (ret != 0)
- qc->flags = V4L2_CTRL_FLAG_DISABLED;
- return ret;
+ /*
+ * This is probably not needed, but this flag has been set for
+ * many kernel versions. Leave to avoid breaking any apps
+ */
+ qc->flags = V4L2_CTRL_FLAG_DISABLED;
+ return -EINVAL;
}
static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh,
@@ -1561,7 +1565,7 @@ const struct v4l2_ioctl_ops atomisp_ioctl_ops = {
.vidioc_enum_input = atomisp_enum_input,
.vidioc_g_input = atomisp_g_input,
.vidioc_s_input = atomisp_s_input,
- .vidioc_queryctrl = atomisp_queryctl,
+ .vidioc_query_ext_ctrl = atomisp_query_ext_ctrl,
.vidioc_s_ctrl = atomisp_s_ctrl,
.vidioc_g_ctrl = atomisp_g_ctrl,
.vidioc_s_ext_ctrls = atomisp_s_ext_ctrls,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 06/10] media: atomisp: Remove vidioc_g/s callback
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
` (4 preceding siblings ...)
2024-12-09 19:25 ` [PATCH 05/10] media: atomisp: Replace queryctrl with query_ext_ctrl Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 07/10] media: v4l2: Remove vidioc_queryctrl callback Ricardo Ribalda
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
The v4l2 ioctl framework can implement vidioc_g/s_ctrl with
vidioc_g/s_ext_ctrl() and we provide those.
These are the last references of vidioc_s/g_ctrl in the codebase. We can
attempt to remove them now.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
index d24420d8bd57..394b6f06246c 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
@@ -1566,8 +1566,6 @@ const struct v4l2_ioctl_ops atomisp_ioctl_ops = {
.vidioc_g_input = atomisp_g_input,
.vidioc_s_input = atomisp_s_input,
.vidioc_query_ext_ctrl = atomisp_query_ext_ctrl,
- .vidioc_s_ctrl = atomisp_s_ctrl,
- .vidioc_g_ctrl = atomisp_g_ctrl,
.vidioc_s_ext_ctrls = atomisp_s_ext_ctrls,
.vidioc_g_ext_ctrls = atomisp_g_ext_ctrls,
.vidioc_enum_framesizes = atomisp_enum_framesizes,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 07/10] media: v4l2: Remove vidioc_queryctrl callback
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
` (5 preceding siblings ...)
2024-12-09 19:25 ` [PATCH 06/10] media: atomisp: Remove vidioc_g/s callback Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 08/10] media: v4l2: Remove vidioc_g_ctrl callback Ricardo Ribalda
` (2 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
All the drivers either use the control framework or provide a
vidioc_query_ext_ctrl. We can remove this callback to reduce the
temptation of new drivers to implement it.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/v4l2-core/v4l2-dev.c | 3 +--
drivers/media/v4l2-core/v4l2-ioctl.c | 2 --
include/media/v4l2-ioctl.h | 4 ----
3 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 252308a67fa8..5267a0686400 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -572,8 +572,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
and that can't be tested here. If the bit for these control ioctls
is set, then the ioctl is valid. But if it is 0, then it can still
be valid if the filehandle passed the control handler. */
- if (vdev->ctrl_handler || ops->vidioc_queryctrl ||
- ops->vidioc_query_ext_ctrl)
+ if (vdev->ctrl_handler || ops->vidioc_query_ext_ctrl)
__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);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index a5562f2f1fc9..30e32ce5278f 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2294,8 +2294,6 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
return v4l2_queryctrl(vfh->ctrl_handler, p);
if (vfd->ctrl_handler)
return v4l2_queryctrl(vfd->ctrl_handler, p);
- if (ops->vidioc_queryctrl)
- return ops->vidioc_queryctrl(file, fh, p);
if (!ops->vidioc_query_ext_ctrl)
return -ENOTTY;
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index bdbb7e542321..013996c33a9e 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -193,8 +193,6 @@ struct v4l2_fh;
* :ref:`VIDIOC_G_OUTPUT <vidioc_g_output>` ioctl
* @vidioc_s_output: pointer to the function that implements
* :ref:`VIDIOC_S_OUTPUT <vidioc_g_output>` ioctl
- * @vidioc_queryctrl: pointer to the function that implements
- * :ref:`VIDIOC_QUERYCTRL <vidioc_queryctrl>` ioctl
* @vidioc_query_ext_ctrl: pointer to the function that implements
* :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
* @vidioc_g_ctrl: pointer to the function that implements
@@ -461,8 +459,6 @@ struct v4l2_ioctl_ops {
int (*vidioc_s_output)(struct file *file, void *fh, unsigned int i);
/* 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,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 08/10] media: v4l2: Remove vidioc_g_ctrl callback
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
` (6 preceding siblings ...)
2024-12-09 19:25 ` [PATCH 07/10] media: v4l2: Remove vidioc_queryctrl callback Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 09/10] media: cx231xx: Replace s_ctrl with s_ext_ctrls Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 10/10] media: v4l2: Remove vidioc_s_ctrl callback Ricardo Ribalda
9 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
All the drivers either use the control framework or provide a
vidioc_g_ext_ctrls callback. We can remove this callback.
Thanks for your service!
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/v4l2-core/v4l2-dev.c | 2 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 2 --
include/media/v4l2-ioctl.h | 4 ----
3 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 5267a0686400..068ee67cd574 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -576,7 +576,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
__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)
+ if (vdev->ctrl_handler || 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)
__set_bit(_IOC_NR(VIDIOC_S_CTRL), valid_ioctls);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 30e32ce5278f..4e65d50bef27 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2363,8 +2363,6 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops,
return v4l2_g_ctrl(vfh->ctrl_handler, p);
if (vfd->ctrl_handler)
return v4l2_g_ctrl(vfd->ctrl_handler, p);
- if (ops->vidioc_g_ctrl)
- return ops->vidioc_g_ctrl(file, fh, p);
if (ops->vidioc_g_ext_ctrls == NULL)
return -ENOTTY;
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index 013996c33a9e..4d69128023f8 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -195,8 +195,6 @@ struct v4l2_fh;
* :ref:`VIDIOC_S_OUTPUT <vidioc_g_output>` ioctl
* @vidioc_query_ext_ctrl: pointer to the function that implements
* :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
- * @vidioc_g_ctrl: pointer to the function that implements
- * :ref:`VIDIOC_G_CTRL <vidioc_g_ctrl>` ioctl
* @vidioc_s_ctrl: pointer to the function that implements
* :ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
* @vidioc_g_ext_ctrls: pointer to the function that implements
@@ -461,8 +459,6 @@ struct v4l2_ioctl_ops {
/* Control handling */
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,
struct v4l2_control *a);
int (*vidioc_g_ext_ctrls)(struct file *file, void *fh,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 09/10] media: cx231xx: Replace s_ctrl with s_ext_ctrls
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
` (7 preceding siblings ...)
2024-12-09 19:25 ` [PATCH 08/10] media: v4l2: Remove vidioc_g_ctrl callback Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 10/10] media: v4l2: Remove vidioc_s_ctrl callback Ricardo Ribalda
9 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
The v4l2 ioctl framework can provide support for s_ctrl. This the last
driver implementing s_ctrl.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/cx231xx/cx231xx-417.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index a4a9781328c5..3c1941709ebf 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1538,17 +1538,24 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id)
return 0;
}
-static int vidioc_s_ctrl(struct file *file, void *priv,
- struct v4l2_control *ctl)
+static int cx231xx_s_ext_ctrls(struct file *file, void *priv,
+ struct v4l2_ext_controls *ctls)
{
struct cx231xx *dev = video_drvdata(file);
+ struct v4l2_control ctl;
struct v4l2_subdev *sd;
+ unsigned int i;
- dprintk(3, "enter vidioc_s_ctrl()\n");
+ dprintk(3, "enter vidioc_s_ext_ctrl()\n");
/* Update the A/V core */
- v4l2_device_for_each_subdev(sd, &dev->v4l2_dev)
- v4l2_s_ctrl(NULL, sd->ctrl_handler, ctl);
- dprintk(3, "exit vidioc_s_ctrl()\n");
+ for (i = 0; i < ctls->count; i++) {
+ ctl.id = ctls->controls[i].id;
+ ctl.value = ctls->controls[i].value;
+ v4l2_device_for_each_subdev(sd, &dev->v4l2_dev)
+ v4l2_s_ctrl(NULL, sd->ctrl_handler, &ctl);
+ ctls->controls[i].value = ctl.value;
+ }
+ dprintk(3, "exit vidioc_s_ext_ctrl()\n");
return 0;
}
@@ -1627,7 +1634,7 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
.vidioc_enum_input = cx231xx_enum_input,
.vidioc_g_input = cx231xx_g_input,
.vidioc_s_input = cx231xx_s_input,
- .vidioc_s_ctrl = vidioc_s_ctrl,
+ .vidioc_s_ext_ctrls = cx231xx_s_ext_ctrls,
.vidioc_g_pixelaspect = vidioc_g_pixelaspect,
.vidioc_g_selection = vidioc_g_selection,
.vidioc_querycap = cx231xx_querycap,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 10/10] media: v4l2: Remove vidioc_s_ctrl callback
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
` (8 preceding siblings ...)
2024-12-09 19:25 ` [PATCH 09/10] media: cx231xx: Replace s_ctrl with s_ext_ctrls Ricardo Ribalda
@ 2024-12-09 19:25 ` Ricardo Ribalda
9 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 19:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-staging, Ricardo Ribalda
All the drivers either use the control framework or provide a
vidiod_ext_ctrl. We can remove this callback.
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/v4l2-core/v4l2-dev.c | 2 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 2 --
include/media/v4l2-ioctl.h | 4 ----
3 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 068ee67cd574..b40c08ce909d 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -578,7 +578,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
__set_bit(_IOC_NR(VIDIOC_QUERY_EXT_CTRL), valid_ioctls);
if (vdev->ctrl_handler || 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)
+ if (vdev->ctrl_handler || ops->vidioc_s_ext_ctrls)
__set_bit(_IOC_NR(VIDIOC_S_CTRL), valid_ioctls);
if (vdev->ctrl_handler || ops->vidioc_g_ext_ctrls)
__set_bit(_IOC_NR(VIDIOC_G_EXT_CTRLS), valid_ioctls);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 4e65d50bef27..5a54e796086d 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2396,8 +2396,6 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops,
return v4l2_s_ctrl(vfh, vfh->ctrl_handler, p);
if (vfd->ctrl_handler)
return v4l2_s_ctrl(NULL, vfd->ctrl_handler, p);
- if (ops->vidioc_s_ctrl)
- return ops->vidioc_s_ctrl(file, fh, p);
if (ops->vidioc_s_ext_ctrls == NULL)
return -ENOTTY;
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index 4d69128023f8..c6ec87e88dfe 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -195,8 +195,6 @@ struct v4l2_fh;
* :ref:`VIDIOC_S_OUTPUT <vidioc_g_output>` ioctl
* @vidioc_query_ext_ctrl: pointer to the function that implements
* :ref:`VIDIOC_QUERY_EXT_CTRL <vidioc_queryctrl>` ioctl
- * @vidioc_s_ctrl: pointer to the function that implements
- * :ref:`VIDIOC_S_CTRL <vidioc_g_ctrl>` ioctl
* @vidioc_g_ext_ctrls: pointer to the function that implements
* :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
* @vidioc_s_ext_ctrls: pointer to the function that implements
@@ -459,8 +457,6 @@ struct v4l2_ioctl_ops {
/* Control handling */
int (*vidioc_query_ext_ctrl)(struct file *file, void *fh,
struct v4l2_query_ext_ctrl *a);
- int (*vidioc_s_ctrl)(struct file *file, void *fh,
- struct v4l2_control *a);
int (*vidioc_g_ext_ctrls)(struct file *file, void *fh,
struct v4l2_ext_controls *a);
int (*vidioc_s_ext_ctrls)(struct file *file, void *fh,
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 01/10] media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl
2024-12-09 19:25 ` [PATCH 01/10] media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl Ricardo Ribalda
@ 2024-12-09 19:34 ` Hans Verkuil
2024-12-09 20:02 ` Ricardo Ribalda
0 siblings, 1 reply; 14+ messages in thread
From: Hans Verkuil @ 2024-12-09 19:34 UTC (permalink / raw)
To: Ricardo Ribalda, Mauro Carvalho Chehab, Mike Isely,
Laurent Pinchart, Hans de Goede, Sakari Ailus, Andy Shevchenko,
Greg Kroah-Hartman
Cc: linux-media, linux-kernel, linux-staging
On 09/12/2024 20:25, Ricardo Ribalda wrote:
> v4l2_queryctrl is a subset of v4l2_query_ext_ctrl. If the driver does
> not implement v4l2_queryctrl we can implement it with
> v4l2_query_ext_ctrl.
>
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/v4l2-core/v4l2-dev.c | 3 ++-
> drivers/media/v4l2-core/v4l2-ioctl.c | 22 +++++++++++++++++++++-
> 2 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> index 5bcaeeba4d09..252308a67fa8 100644
> --- a/drivers/media/v4l2-core/v4l2-dev.c
> +++ b/drivers/media/v4l2-core/v4l2-dev.c
> @@ -572,7 +572,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
> and that can't be tested here. If the bit for these control ioctls
> is set, then the ioctl is valid. But if it is 0, then it can still
> be valid if the filehandle passed the control handler. */
> - if (vdev->ctrl_handler || ops->vidioc_queryctrl)
> + if (vdev->ctrl_handler || ops->vidioc_queryctrl ||
> + ops->vidioc_query_ext_ctrl)
> __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);
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 0304daa8471d..a5562f2f1fc9 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -2284,9 +2284,11 @@ static int v4l_queryctrl(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 qec;
> struct v4l2_queryctrl *p = arg;
> struct v4l2_fh *vfh =
> test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
> + int ret;
>
> if (vfh && vfh->ctrl_handler)
> return v4l2_queryctrl(vfh->ctrl_handler, p);
> @@ -2294,7 +2296,25 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
> return v4l2_queryctrl(vfd->ctrl_handler, p);
> if (ops->vidioc_queryctrl)
> return ops->vidioc_queryctrl(file, fh, p);
> - return -ENOTTY;
> + if (!ops->vidioc_query_ext_ctrl)
> + return -ENOTTY;
> +
> + /* Simulate query_ext_ctr using query_ctrl. */
> + qec.id = p->id;
> + ret = ops->vidioc_query_ext_ctrl(file, fh, &qec);
> + if (ret)
> + return ret;
> +
> + p->id = qec.id;
> + p->type = qec.type;
> + strscpy(p->name, qec.name, sizeof(p->name));
> + p->minimum = qec.minimum;
> + p->maximum = qec.maximum;
> + p->step = qec.step;
> + p->default_value = qec.default_value;
> + p->flags = qec.flags;
That's not quite correct. See v4l2_queryctrl() in v4l2-ctrls-api.c
on how to do this: for types that VIDIOC_QUERYCTRL doesn't support,
some of these fields must be set to 0.
In fact, once vidioc_queryctrl has been removed, then you can also
remove v4l2_queryctrl() and just rely on this code. Unless I missed
something.
Regards,
Hans
> +
> + return 0;
> }
>
> static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 01/10] media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl
2024-12-09 19:34 ` Hans Verkuil
@ 2024-12-09 20:02 ` Ricardo Ribalda
2024-12-09 21:26 ` Ricardo Ribalda
0 siblings, 1 reply; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 20:02 UTC (permalink / raw)
To: Hans Verkuil
Cc: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
linux-media, linux-kernel, linux-staging
Hi Hans
On Mon, 9 Dec 2024 at 20:34, Hans Verkuil <hverkuil@xs4all.nl> wrote:
>
> On 09/12/2024 20:25, Ricardo Ribalda wrote:
> > v4l2_queryctrl is a subset of v4l2_query_ext_ctrl. If the driver does
> > not implement v4l2_queryctrl we can implement it with
> > v4l2_query_ext_ctrl.
> >
> > Suggested-by: Hans de Goede <hdegoede@redhat.com>
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > ---
> > drivers/media/v4l2-core/v4l2-dev.c | 3 ++-
> > drivers/media/v4l2-core/v4l2-ioctl.c | 22 +++++++++++++++++++++-
> > 2 files changed, 23 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> > index 5bcaeeba4d09..252308a67fa8 100644
> > --- a/drivers/media/v4l2-core/v4l2-dev.c
> > +++ b/drivers/media/v4l2-core/v4l2-dev.c
> > @@ -572,7 +572,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
> > and that can't be tested here. If the bit for these control ioctls
> > is set, then the ioctl is valid. But if it is 0, then it can still
> > be valid if the filehandle passed the control handler. */
> > - if (vdev->ctrl_handler || ops->vidioc_queryctrl)
> > + if (vdev->ctrl_handler || ops->vidioc_queryctrl ||
> > + ops->vidioc_query_ext_ctrl)
> > __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);
> > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> > index 0304daa8471d..a5562f2f1fc9 100644
> > --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> > @@ -2284,9 +2284,11 @@ static int v4l_queryctrl(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 qec;
> > struct v4l2_queryctrl *p = arg;
> > struct v4l2_fh *vfh =
> > test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
> > + int ret;
> >
> > if (vfh && vfh->ctrl_handler)
> > return v4l2_queryctrl(vfh->ctrl_handler, p);
> > @@ -2294,7 +2296,25 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
> > return v4l2_queryctrl(vfd->ctrl_handler, p);
> > if (ops->vidioc_queryctrl)
> > return ops->vidioc_queryctrl(file, fh, p);
> > - return -ENOTTY;
> > + if (!ops->vidioc_query_ext_ctrl)
> > + return -ENOTTY;
> > +
> > + /* Simulate query_ext_ctr using query_ctrl. */
> > + qec.id = p->id;
> > + ret = ops->vidioc_query_ext_ctrl(file, fh, &qec);
> > + if (ret)
> > + return ret;
> > +
> > + p->id = qec.id;
> > + p->type = qec.type;
> > + strscpy(p->name, qec.name, sizeof(p->name));
> > + p->minimum = qec.minimum;
> > + p->maximum = qec.maximum;
> > + p->step = qec.step;
> > + p->default_value = qec.default_value;
> > + p->flags = qec.flags;
>
> That's not quite correct. See v4l2_queryctrl() in v4l2-ctrls-api.c
> on how to do this: for types that VIDIOC_QUERYCTRL doesn't support,
> some of these fields must be set to 0.
>
> In fact, once vidioc_queryctrl has been removed, then you can also
> remove v4l2_queryctrl() and just rely on this code. Unless I missed
> something.
Thanks for the mega-fast review :)
I do not think that we can easily remove v4l2_queryctrl(). It is still
called by v4l2-subdev.c
We could do something to remove the code duplication... but it will
probably make the code more difficult to follow.
I will send a new version with the fix that you proposed, as well as:
-- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2290,10 +2290,6 @@ static int v4l_queryctrl(const struct
v4l2_ioctl_ops *ops,
test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
int ret;
- if (vfh && vfh->ctrl_handler)
- return v4l2_queryctrl(vfh->ctrl_handler, p);
- if (vfd->ctrl_handler)
- return v4l2_queryctrl(vfd->ctrl_handler, p);
if (!ops->vidioc_query_ext_ctrl)
return -ENOTTY;
>
> Regards,
>
> Hans
>
> > +
> > + return 0;
> > }
> >
> > static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,
> >
>
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 01/10] media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl
2024-12-09 20:02 ` Ricardo Ribalda
@ 2024-12-09 21:26 ` Ricardo Ribalda
0 siblings, 0 replies; 14+ messages in thread
From: Ricardo Ribalda @ 2024-12-09 21:26 UTC (permalink / raw)
To: Hans Verkuil
Cc: Mauro Carvalho Chehab, Mike Isely, Laurent Pinchart,
Hans de Goede, Sakari Ailus, Andy Shevchenko, Greg Kroah-Hartman,
linux-media, linux-kernel, linux-staging
On Mon, 9 Dec 2024 at 21:02, Ricardo Ribalda <ribalda@chromium.org> wrote:
>
> Hi Hans
>
> On Mon, 9 Dec 2024 at 20:34, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> >
> > On 09/12/2024 20:25, Ricardo Ribalda wrote:
> > > v4l2_queryctrl is a subset of v4l2_query_ext_ctrl. If the driver does
> > > not implement v4l2_queryctrl we can implement it with
> > > v4l2_query_ext_ctrl.
> > >
> > > Suggested-by: Hans de Goede <hdegoede@redhat.com>
> > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > > ---
> > > drivers/media/v4l2-core/v4l2-dev.c | 3 ++-
> > > drivers/media/v4l2-core/v4l2-ioctl.c | 22 +++++++++++++++++++++-
> > > 2 files changed, 23 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> > > index 5bcaeeba4d09..252308a67fa8 100644
> > > --- a/drivers/media/v4l2-core/v4l2-dev.c
> > > +++ b/drivers/media/v4l2-core/v4l2-dev.c
> > > @@ -572,7 +572,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
> > > and that can't be tested here. If the bit for these control ioctls
> > > is set, then the ioctl is valid. But if it is 0, then it can still
> > > be valid if the filehandle passed the control handler. */
> > > - if (vdev->ctrl_handler || ops->vidioc_queryctrl)
> > > + if (vdev->ctrl_handler || ops->vidioc_queryctrl ||
> > > + ops->vidioc_query_ext_ctrl)
> > > __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);
> > > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > index 0304daa8471d..a5562f2f1fc9 100644
> > > --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> > > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > @@ -2284,9 +2284,11 @@ static int v4l_queryctrl(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 qec;
> > > struct v4l2_queryctrl *p = arg;
> > > struct v4l2_fh *vfh =
> > > test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
> > > + int ret;
> > >
> > > if (vfh && vfh->ctrl_handler)
> > > return v4l2_queryctrl(vfh->ctrl_handler, p);
> > > @@ -2294,7 +2296,25 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
> > > return v4l2_queryctrl(vfd->ctrl_handler, p);
> > > if (ops->vidioc_queryctrl)
> > > return ops->vidioc_queryctrl(file, fh, p);
> > > - return -ENOTTY;
> > > + if (!ops->vidioc_query_ext_ctrl)
> > > + return -ENOTTY;
> > > +
> > > + /* Simulate query_ext_ctr using query_ctrl. */
> > > + qec.id = p->id;
> > > + ret = ops->vidioc_query_ext_ctrl(file, fh, &qec);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + p->id = qec.id;
> > > + p->type = qec.type;
> > > + strscpy(p->name, qec.name, sizeof(p->name));
> > > + p->minimum = qec.minimum;
> > > + p->maximum = qec.maximum;
> > > + p->step = qec.step;
> > > + p->default_value = qec.default_value;
> > > + p->flags = qec.flags;
> >
> > That's not quite correct. See v4l2_queryctrl() in v4l2-ctrls-api.c
> > on how to do this: for types that VIDIOC_QUERYCTRL doesn't support,
> > some of these fields must be set to 0.
> >
> > In fact, once vidioc_queryctrl has been removed, then you can also
> > remove v4l2_queryctrl() and just rely on this code. Unless I missed
> > something.
>
> Thanks for the mega-fast review :)
>
> I do not think that we can easily remove v4l2_queryctrl(). It is still
> called by v4l2-subdev.c
>
> We could do something to remove the code duplication... but it will
> probably make the code more difficult to follow.
>
> I will send a new version with the fix that you proposed, as well as:
>
> -- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -2290,10 +2290,6 @@ static int v4l_queryctrl(const struct
> v4l2_ioctl_ops *ops,
> test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
> int ret;
>
> - if (vfh && vfh->ctrl_handler)
> - return v4l2_queryctrl(vfh->ctrl_handler, p);
> - if (vfd->ctrl_handler)
> - return v4l2_queryctrl(vfd->ctrl_handler, p);
> if (!ops->vidioc_query_ext_ctrl)
> return -ENOTTY;
Actually we cannot remove these four lines. I have a set ready with a helper....
https://gitlab.freedesktop.org/linux-media/users/ribalda/-/commits/queryctrl
Not sure if it is better with or without the helper.
Will send it tomorrow if I do not have more feedback.
Best rergards!
>
> >
> > Regards,
> >
> > Hans
> >
> > > +
> > > + return 0;
> > > }
> > >
> > > static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,
> > >
> >
>
>
> --
> Ricardo Ribalda
--
Ricardo Ribalda
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-12-09 21:26 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09 19:25 [PATCH 00/10] media: Remove vidioc_g/s_ctrl and vidioc_queryctrl callbacks Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 01/10] media: ioctl: Simulate v4l2_queryctrl with v4l2_query_ext_ctrl Ricardo Ribalda
2024-12-09 19:34 ` Hans Verkuil
2024-12-09 20:02 ` Ricardo Ribalda
2024-12-09 21:26 ` Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 02/10] media: pvrusb2: Convert queryctrl to query_ext_ctrl Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 03/10] media: pvrusb2: Remove g/s_ctrl callbacks Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 04/10] media: uvcvideo: Remove vidioc_queryctrl Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 05/10] media: atomisp: Replace queryctrl with query_ext_ctrl Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 06/10] media: atomisp: Remove vidioc_g/s callback Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 07/10] media: v4l2: Remove vidioc_queryctrl callback Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 08/10] media: v4l2: Remove vidioc_g_ctrl callback Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 09/10] media: cx231xx: Replace s_ctrl with s_ext_ctrls Ricardo Ribalda
2024-12-09 19:25 ` [PATCH 10/10] media: v4l2: Remove vidioc_s_ctrl callback Ricardo Ribalda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).