Commit c9cbf021 authored by Tomi Valkeinen's avatar Tomi Valkeinen Committed by Mauro Carvalho Chehab
Browse files

media: vivid: use vb2_queue_change_type



Use the new vb2_queue_change_type() function in .vidioc_reqbufs and
.vidioc_create_bufs instead of changing the queue type manually in
vidioc_s_fmt_vbi_cap() and vidioc_s_fmt_sliced_vbi_cap().

This allows for a more consistent behavior, as .vidioc_reqbufs and
.vidioc_create_bufs are when the queue will become "busy".

Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 2d8b2a64
Loading
Loading
Loading
Loading
+42 −2
Original line number Diff line number Diff line
@@ -656,6 +656,46 @@ static const struct v4l2_file_operations vivid_radio_fops = {
	.unlocked_ioctl = video_ioctl2,
};

static int vidioc_reqbufs(struct file *file, void *priv,
			  struct v4l2_requestbuffers *p)
{
	struct video_device *vdev = video_devdata(file);
	int r;

	/*
	 * Sliced and raw VBI capture share the same queue so we must
	 * change the type.
	 */
	if (p->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE ||
	    p->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
		r = vb2_queue_change_type(vdev->queue, p->type);
		if (r)
			return r;
	}

	return vb2_ioctl_reqbufs(file, priv, p);
}

static int vidioc_create_bufs(struct file *file, void *priv,
			      struct v4l2_create_buffers *p)
{
	struct video_device *vdev = video_devdata(file);
	int r;

	/*
	 * Sliced and raw VBI capture share the same queue so we must
	 * change the type.
	 */
	if (p->format.type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE ||
	    p->format.type == V4L2_BUF_TYPE_VBI_CAPTURE) {
		r = vb2_queue_change_type(vdev->queue, p->format.type);
		if (r)
			return r;
	}

	return vb2_ioctl_create_bufs(file, priv, p);
}

static const struct v4l2_ioctl_ops vivid_ioctl_ops = {
	.vidioc_querycap		= vidioc_querycap,

@@ -717,8 +757,8 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = {
	.vidioc_g_fbuf			= vidioc_g_fbuf,
	.vidioc_s_fbuf			= vidioc_s_fbuf,

	.vidioc_reqbufs			= vb2_ioctl_reqbufs,
	.vidioc_create_bufs		= vb2_ioctl_create_bufs,
	.vidioc_reqbufs			= vidioc_reqbufs,
	.vidioc_create_bufs		= vidioc_create_bufs,
	.vidioc_prepare_buf		= vb2_ioctl_prepare_buf,
	.vidioc_querybuf		= vb2_ioctl_querybuf,
	.vidioc_qbuf			= vb2_ioctl_qbuf,
+0 −2
Original line number Diff line number Diff line
@@ -257,7 +257,6 @@ int vidioc_s_fmt_vbi_cap(struct file *file, void *priv,
		return ret;
	if (f->type != V4L2_BUF_TYPE_VBI_CAPTURE && vb2_is_busy(&dev->vb_vbi_cap_q))
		return -EBUSY;
	dev->vbi_cap_dev.queue->type = V4L2_BUF_TYPE_VBI_CAPTURE;
	return 0;
}

@@ -324,7 +323,6 @@ int vidioc_s_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format
	if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE && vb2_is_busy(&dev->vb_vbi_cap_q))
		return -EBUSY;
	dev->service_set_cap = vbi->service_set;
	dev->vbi_cap_dev.queue->type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
	return 0;
}