mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 08:02:27 +02:00
media: uvcvideo: Keep streaming state in the file handle
Add a variable in the file handle state to figure out if a camera is in the streaming state or not. This variable will be used in the future for power management policies. Now that we are at it, make use of guards to simplify the code. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Message-ID: <20250327-uvc-granpower-ng-v6-1-35a2357ff348@chromium.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
This commit is contained in:
parent
f8953ee959
commit
14f6e205e5
|
|
@ -841,11 +841,18 @@ static int uvc_ioctl_streamon(struct file *file, void *fh,
|
|||
if (!uvc_has_privileges(handle))
|
||||
return -EBUSY;
|
||||
|
||||
mutex_lock(&stream->mutex);
|
||||
ret = uvc_queue_streamon(&stream->queue, type);
|
||||
mutex_unlock(&stream->mutex);
|
||||
guard(mutex)(&stream->mutex);
|
||||
|
||||
return ret;
|
||||
if (handle->is_streaming)
|
||||
return 0;
|
||||
|
||||
ret = uvc_queue_streamon(&stream->queue, type);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
handle->is_streaming = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uvc_ioctl_streamoff(struct file *file, void *fh,
|
||||
|
|
@ -857,9 +864,10 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh,
|
|||
if (!uvc_has_privileges(handle))
|
||||
return -EBUSY;
|
||||
|
||||
mutex_lock(&stream->mutex);
|
||||
guard(mutex)(&stream->mutex);
|
||||
|
||||
uvc_queue_streamoff(&stream->queue, type);
|
||||
mutex_unlock(&stream->mutex);
|
||||
handle->is_streaming = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -630,6 +630,7 @@ struct uvc_fh {
|
|||
struct uvc_streaming *stream;
|
||||
enum uvc_handle_state state;
|
||||
unsigned int pending_async_ctrls;
|
||||
bool is_streaming;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user