Skip to content

Commit 7dd56c4

Browse files
ribaldahverkuil
authored andcommitted
media: uvcvideo: Remove stream->is_streaming field
The is_streaming field is used by modular PM to know if the device is currently streaming or not. With the transition to vb2 and fop helpers, we can use vb2 functions for the same functionality. The great benefit is that vb2 already tracks the streaming state for us. Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Ricardo Ribalda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans Verkuil <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 54828c0 commit 7dd56c4

File tree

3 files changed

+11
-50
lines changed

3 files changed

+11
-50
lines changed

drivers/media/usb/uvc/uvc_queue.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,18 @@ static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count)
175175

176176
lockdep_assert_irqs_enabled();
177177

178+
ret = uvc_pm_get(stream->dev);
179+
if (ret)
180+
return ret;
181+
178182
queue->buf_used = 0;
179183

180184
ret = uvc_video_start_streaming(stream);
181185
if (ret == 0)
182186
return 0;
183187

188+
uvc_pm_put(stream->dev);
189+
184190
uvc_queue_return_buffers(queue, UVC_BUF_STATE_QUEUED);
185191

186192
return ret;
@@ -189,11 +195,14 @@ static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count)
189195
static void uvc_stop_streaming_video(struct vb2_queue *vq)
190196
{
191197
struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
198+
struct uvc_streaming *stream = uvc_queue_to_stream(queue);
192199

193200
lockdep_assert_irqs_enabled();
194201

195202
uvc_video_stop_streaming(uvc_queue_to_stream(queue));
196203

204+
uvc_pm_put(stream->dev);
205+
197206
uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR);
198207
}
199208

drivers/media/usb/uvc/uvc_v4l2.c

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,6 @@ static int uvc_v4l2_release(struct file *file)
617617

618618
uvc_ctrl_cleanup_fh(handle);
619619

620-
if (handle->is_streaming)
621-
uvc_pm_put(stream->dev);
622-
623620
/* Release the file handle. */
624621
vb2_fop_release(file);
625622

@@ -676,50 +673,6 @@ static int uvc_ioctl_try_fmt(struct file *file, void *fh,
676673
return uvc_v4l2_try_format(stream, fmt, &probe, NULL, NULL);
677674
}
678675

679-
static int uvc_ioctl_streamon(struct file *file, void *fh,
680-
enum v4l2_buf_type type)
681-
{
682-
struct uvc_fh *handle = fh;
683-
struct uvc_streaming *stream = handle->stream;
684-
int ret;
685-
686-
if (handle->is_streaming)
687-
return 0;
688-
689-
ret = uvc_pm_get(stream->dev);
690-
if (ret)
691-
return ret;
692-
693-
ret = vb2_ioctl_streamon(file, fh, type);
694-
if (ret) {
695-
uvc_pm_put(stream->dev);
696-
return ret;
697-
}
698-
699-
handle->is_streaming = true;
700-
701-
return 0;
702-
}
703-
704-
static int uvc_ioctl_streamoff(struct file *file, void *fh,
705-
enum v4l2_buf_type type)
706-
{
707-
struct uvc_fh *handle = fh;
708-
struct uvc_streaming *stream = handle->stream;
709-
int ret;
710-
711-
ret = vb2_ioctl_streamoff(file, fh, type);
712-
if (ret)
713-
return ret;
714-
715-
if (handle->is_streaming) {
716-
handle->is_streaming = false;
717-
uvc_pm_put(stream->dev);
718-
}
719-
720-
return 0;
721-
}
722-
723676
static int uvc_ioctl_enum_input(struct file *file, void *fh,
724677
struct v4l2_input *input)
725678
{
@@ -1320,8 +1273,8 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = {
13201273
.vidioc_expbuf = vb2_ioctl_expbuf,
13211274
.vidioc_dqbuf = vb2_ioctl_dqbuf,
13221275
.vidioc_create_bufs = vb2_ioctl_create_bufs,
1323-
.vidioc_streamon = uvc_ioctl_streamon,
1324-
.vidioc_streamoff = uvc_ioctl_streamoff,
1276+
.vidioc_streamon = vb2_ioctl_streamon,
1277+
.vidioc_streamoff = vb2_ioctl_streamoff,
13251278
.vidioc_enum_input = uvc_ioctl_enum_input,
13261279
.vidioc_g_input = uvc_ioctl_g_input,
13271280
.vidioc_s_input = uvc_ioctl_s_input,

drivers/media/usb/uvc/uvcvideo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ struct uvc_fh {
629629
struct uvc_video_chain *chain;
630630
struct uvc_streaming *stream;
631631
unsigned int pending_async_ctrls;
632-
bool is_streaming;
633632
};
634633

635634
/* ------------------------------------------------------------------------

0 commit comments

Comments
 (0)