linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-media@vger.kernel.org
Subject: Re: vb2_queue type question
Date: Wed, 31 Mar 2021 08:22:07 +0300	[thread overview]
Message-ID: <6eae31f1-3293-c771-19b9-03835c564a1e@ideasonboard.com> (raw)
In-Reply-To: <a964df70-612e-6ae3-a183-f1c34a1c4629@xs4all.nl>

On 30/03/2021 11:56, Hans Verkuil wrote:
> On 3/30/21 10:18 AM, Tomi Valkeinen wrote:
>> Hi Hans,
>>
>> On 26/03/2021 12:18, Hans Verkuil wrote:
>>
>>> The only thing that you do is update the queue type when you set the
>>> video or metadata format. When you start allocating buffers the queue type
>>> of the last set format is used. At that moment any attempt to set the format
>>> to another type will fail since vb2_is_busy(queue) will be true.
>>>
>>> So only the s_fmt ioctl will change the type. The g/try_fmt ioctls just must
>>> keep working as-is.
>>
>> I noticed that v4l2-compliance complains about this. It first tests the
>> format ioctls for both video and metadata buffers, and the last s_fmt is
>> for metadata. Then it tests buffer ioctls, and reqbufs for video buffers
>> fails as the queue is in metadata mode, not video mode.
>>
>> I added a custom .vidioc_reqbufs function to the driver which sets the
>> queue type and then calls vb2_ioctl_reqbufs normally. This makes
>> v4l2-compliance pass.
>>
>> But is that correct change, or should v4l2-compliance be changed?
>>
>>    Tomi
>>
> 
> Good question.
> 
> So currently this is something that is rarely used. The few implementations
> of this rely on the last set format to decide what the queue type will be.
> 
> But is this actually something you want? Wouldn't it be better to rely on the
> queue type as passed with VIDIOC_REQBUFS/CREATE_BUFS? That's really the moment
> where you lock in the queue type.
> 
> To do this you would have to make your own ioctl op:
> 
> int my_ioctl_reqbufs(struct file *file, void *priv,
>                            struct v4l2_requestbuffers *p)
> {
> 	struct video_device *vdev = video_devdata(file);
> 
> 	if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
> 	    p->type != V4L2_BUF_TYPE_META_CAPTURE)
> 		return -EINVAL;
> 	if (p->type != vdev->queue.type && vb2_queue_is_busy(vdev, file))
>                  return -EBUSY;
> 	vdev->queue.type = p->type;
> 	return vb2_ioctl_reqbufs(file, priv, p);
> }
> 
> And ditto for create_bufs.
> 
> I think this makes more sense than relying on the format.

Thanks! This works fine and I agree, it makes more sense.

  Tomi

      reply	other threads:[~2021-03-31  5:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  9:18 vb2_queue type question Tomi Valkeinen
2021-03-22  9:49 ` Hans Verkuil
2021-03-22  9:59   ` Laurent Pinchart
2021-03-22 10:08     ` Hans Verkuil
2021-03-22 10:30   ` Tomi Valkeinen
2021-03-26  9:57   ` Tomi Valkeinen
2021-03-26 10:18     ` Hans Verkuil
2021-03-30  8:18       ` Tomi Valkeinen
2021-03-30  8:56         ` Hans Verkuil
2021-03-31  5:22           ` Tomi Valkeinen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6eae31f1-3293-c771-19b9-03835c564a1e@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).