Skip to content

Commit 2acded8

Browse files
ribaldahverkuil
authored andcommitted
media: uvcvideo: uvc_v4l2_unlocked_ioctl: Invert PM logic
Instead of listing the IOCTLs that do not need to turn on the camera, list the IOCTLs that need to turn it on. This makes the code more maintainable. This patch changes the behaviour for unsupported IOCTLs. Those IOCTLs will not turn on the camera. Suggested-by: Hans Verkuil <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Reviewed-by: Hans Verkuil <[email protected]> Signed-off-by: Ricardo Ribalda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 1657624 commit 2acded8

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

drivers/media/usb/uvc/uvc_v4l2.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,36 +1222,36 @@ static long uvc_v4l2_unlocked_ioctl(struct file *file,
12221222
unsigned int cmd, unsigned long arg)
12231223
{
12241224
struct uvc_fh *handle = file->private_data;
1225+
unsigned int converted_cmd = v4l2_translate_cmd(cmd);
12251226
int ret;
12261227

1227-
/* The following IOCTLs do not need to turn on the camera. */
1228-
switch (cmd) {
1229-
case VIDIOC_CREATE_BUFS:
1230-
case VIDIOC_DQBUF:
1231-
case VIDIOC_ENUM_FMT:
1232-
case VIDIOC_ENUM_FRAMEINTERVALS:
1233-
case VIDIOC_ENUM_FRAMESIZES:
1234-
case VIDIOC_ENUMINPUT:
1235-
case VIDIOC_EXPBUF:
1236-
case VIDIOC_G_FMT:
1237-
case VIDIOC_G_PARM:
1238-
case VIDIOC_G_SELECTION:
1239-
case VIDIOC_QBUF:
1240-
case VIDIOC_QUERYCAP:
1241-
case VIDIOC_REQBUFS:
1242-
case VIDIOC_SUBSCRIBE_EVENT:
1243-
case VIDIOC_UNSUBSCRIBE_EVENT:
1244-
return video_ioctl2(file, cmd, arg);
1245-
}
1246-
1247-
ret = uvc_pm_get(handle->stream->dev);
1248-
if (ret)
1228+
/* The following IOCTLs need to turn on the camera. */
1229+
switch (converted_cmd) {
1230+
case UVCIOC_CTRL_MAP:
1231+
case UVCIOC_CTRL_QUERY:
1232+
case VIDIOC_G_CTRL:
1233+
case VIDIOC_G_EXT_CTRLS:
1234+
case VIDIOC_G_INPUT:
1235+
case VIDIOC_QUERYCTRL:
1236+
case VIDIOC_QUERYMENU:
1237+
case VIDIOC_QUERY_EXT_CTRL:
1238+
case VIDIOC_S_CTRL:
1239+
case VIDIOC_S_EXT_CTRLS:
1240+
case VIDIOC_S_FMT:
1241+
case VIDIOC_S_INPUT:
1242+
case VIDIOC_S_PARM:
1243+
case VIDIOC_TRY_EXT_CTRLS:
1244+
case VIDIOC_TRY_FMT:
1245+
ret = uvc_pm_get(handle->stream->dev);
1246+
if (ret)
1247+
return ret;
1248+
ret = video_ioctl2(file, cmd, arg);
1249+
uvc_pm_put(handle->stream->dev);
12491250
return ret;
1251+
}
12501252

1251-
ret = video_ioctl2(file, cmd, arg);
1252-
1253-
uvc_pm_put(handle->stream->dev);
1254-
return ret;
1253+
/* The other IOCTLs can run with the camera off. */
1254+
return video_ioctl2(file, cmd, arg);
12551255
}
12561256

12571257
const struct v4l2_ioctl_ops uvc_ioctl_ops = {

0 commit comments

Comments
 (0)