Skip to content

Commit 959d150

Browse files
ribaldamchehab
authored andcommitted
media: atomisp: Replace queryctrl with query_ext_ctrl
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> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent b810697 commit 959d150

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

drivers/staging/media/atomisp/pci/atomisp_ioctl.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static const char *CARD = "ATOM ISP"; /* max size 31 */
3434
* FIXME: ISP should not know beforehand all CIDs supported by sensor.
3535
* Instead, it needs to propagate to sensor unknown CIDs.
3636
*/
37-
static struct v4l2_queryctrl ci_v4l2_controls[] = {
37+
static struct v4l2_query_ext_ctrl ci_v4l2_controls[] = {
3838
{
3939
.id = V4L2_CID_AUTO_WHITE_BALANCE,
4040
.type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -1140,31 +1140,34 @@ static int atomisp_s_ctrl(struct file *file, void *fh,
11401140

11411141
/*
11421142
* To query the attributes of a control.
1143-
* applications set the id field of a struct v4l2_queryctrl and call the
1143+
* applications set the id field of a struct v4l2_query_ext_ctrl and call the
11441144
* this ioctl with a pointer to this structure. The driver fills
11451145
* the rest of the structure.
11461146
*/
1147-
static int atomisp_queryctl(struct file *file, void *fh,
1148-
struct v4l2_queryctrl *qc)
1147+
static int atomisp_query_ext_ctrl(struct file *file, void *fh,
1148+
struct v4l2_query_ext_ctrl *qc)
11491149
{
1150-
int i, ret = -EINVAL;
1150+
int i;
11511151

1152+
/* TODO: implement V4L2_CTRL_FLAG_NEXT_CTRL */
11521153
if (qc->id & V4L2_CTRL_FLAG_NEXT_CTRL)
1153-
return ret;
1154+
return -EINVAL;
11541155

11551156
for (i = 0; i < ctrls_num; i++) {
11561157
if (ci_v4l2_controls[i].id == qc->id) {
1157-
memcpy(qc, &ci_v4l2_controls[i],
1158-
sizeof(struct v4l2_queryctrl));
1159-
qc->reserved[0] = 0;
1160-
ret = 0;
1161-
break;
1158+
*qc = ci_v4l2_controls[i];
1159+
qc->elems = 1;
1160+
qc->elem_size = 4;
1161+
return 0;
11621162
}
11631163
}
1164-
if (ret != 0)
1165-
qc->flags = V4L2_CTRL_FLAG_DISABLED;
11661164

1167-
return ret;
1165+
/*
1166+
* This is probably not needed, but this flag has been set for
1167+
* many kernel versions. Leave it to avoid breaking any apps.
1168+
*/
1169+
qc->flags = V4L2_CTRL_FLAG_DISABLED;
1170+
return -EINVAL;
11681171
}
11691172

11701173
static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh,
@@ -1561,7 +1564,7 @@ const struct v4l2_ioctl_ops atomisp_ioctl_ops = {
15611564
.vidioc_enum_input = atomisp_enum_input,
15621565
.vidioc_g_input = atomisp_g_input,
15631566
.vidioc_s_input = atomisp_s_input,
1564-
.vidioc_queryctrl = atomisp_queryctl,
1567+
.vidioc_query_ext_ctrl = atomisp_query_ext_ctrl,
15651568
.vidioc_s_ctrl = atomisp_s_ctrl,
15661569
.vidioc_g_ctrl = atomisp_g_ctrl,
15671570
.vidioc_s_ext_ctrls = atomisp_s_ext_ctrls,

0 commit comments

Comments
 (0)