Commit 54828c0d authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Hans Verkuil
Browse files

media: uvcvideo: Split uvc_stop_streaming()



uvc_stop_streaming() is used for meta and video nodes. Split the function
in two to avoid confusion.

Use this opportunity to rename uvc_start_streaming() to
uvc_start_streaming_video(), as it is only called by the video nodes.

Reviewed-by: default avatarHans de Goede <hansg@kernel.org>
Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
Link: https://lore.kernel.org/r/20250616-uvc-fop-v4-3-250286570ee7@chromium.org


Reviewed-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarHans de Goede <hansg@kernel.org>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
parent b7ef5367
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb)
		uvc_video_clock_update(stream, vbuf, buf);
}

static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count)
static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count)
{
	struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
	struct uvc_streaming *stream = uvc_queue_to_stream(queue);
@@ -186,32 +186,45 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count)
	return ret;
}

static void uvc_stop_streaming(struct vb2_queue *vq)
static void uvc_stop_streaming_video(struct vb2_queue *vq)
{
	struct uvc_video_queue *queue = vb2_get_drv_priv(vq);

	lockdep_assert_irqs_enabled();

	if (vq->type != V4L2_BUF_TYPE_META_CAPTURE)
	uvc_video_stop_streaming(uvc_queue_to_stream(queue));

	uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR);
}

static void uvc_stop_streaming_meta(struct vb2_queue *vq)
{
	struct uvc_video_queue *queue = vb2_get_drv_priv(vq);

	lockdep_assert_irqs_enabled();

	uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR);
}

static const struct vb2_ops uvc_queue_qops = {
	.queue_setup = uvc_queue_setup,
	.buf_prepare = uvc_buffer_prepare,
	.buf_queue = uvc_buffer_queue,
	.buf_finish = uvc_buffer_finish,
	.start_streaming = uvc_start_streaming,
	.stop_streaming = uvc_stop_streaming,
	.start_streaming = uvc_start_streaming_video,
	.stop_streaming = uvc_stop_streaming_video,
};

static const struct vb2_ops uvc_meta_queue_qops = {
	.queue_setup = uvc_queue_setup,
	.buf_prepare = uvc_buffer_prepare,
	.buf_queue = uvc_buffer_queue,
	.stop_streaming = uvc_stop_streaming,
	/*
	 * .start_streaming is not provided here. Metadata relies on video
	 * streaming being active. If video isn't streaming, then no metadata
	 * will arrive either.
	 */
	.stop_streaming = uvc_stop_streaming_meta,
};

int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)