All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Junghak Sung <jh1009.sung@samsung.com>,
	linux-media@vger.kernel.org, mchehab@osg.samsung.com,
	laurent.pinchart@ideasonboard.com, sakari.ailus@iki.fi,
	pawel@osciak.com
Cc: inki.dae@samsung.com, sw0312.kim@samsung.com,
	nenggun.kim@samsung.com, sangbae90.lee@samsung.com,
	rany.kwon@samsung.com
Subject: Re: [RFC PATCH v4 5/8] [media] videobuf2: Change queue_setup argument
Date: Fri, 11 Sep 2015 13:18:50 +0200	[thread overview]
Message-ID: <55F2B89A.6050701@xs4all.nl> (raw)
In-Reply-To: <55F2B5FA.2010003@samsung.com>

On 09/11/2015 01:07 PM, Junghak Sung wrote:
> 
> Hello Hans,
> 
> First of all, thank you for your review.
> 
> 
> On 09/11/2015 05:52 PM, Hans Verkuil wrote:
>> On 09/09/2015 01:19 PM, Junghak Sung wrote:
>>> Replace struct v4l2_format * with void * to make queue_setup()
>>> for common use.
>>> And then, modify all device drivers related with this change.
>>>
>>> Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
>>> Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
>>> Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
>>> Acked-by: Inki Dae <inki.dae@samsung.com>
>>
>> OK, so I never liked this void * change. After I thought about it some
>> more I came to the conclusion that this should be changed.
>>
>> For probably all drivers all that they do with the fmt argument is to
>> check the sizeimage field. So I would replace the v4l2_format pointer
>> by an 'unsigned int *req_sizes' argument. This contains the requested
>> per-plane sizes. That is also nicely generic and makes much more sense
>> in videobuf2-core.c.
>>
>> A vb2_v4l2_create_bufs helper function will just call the internal
>> vb2-core function with the correct requested sizes. Note: these sizes
>> will depend on the type of v4l2_format, so the helper will have to do
>> a bit more work.
>>
>> If a driver needs to do more checking for the format, then it can do
>> that before calling the vb2_v4l2_create_bufs helper.
>>
>> When called from reqbufs the req_sizes argument will be NULL, just like
>> fmt is NULL today.
>>
>> I believe this is a much better solution.
>>
>> Regards,
>>
>> 	Hans
>>
> 
> I'm afraid but it seems very hard to implement your idea.
> Some device drivers use not only the sizeimage field but also other
> fields.
> For example, type, fmt.pix_mp of v4l2_format are used by
> vid_out_queue_setup() function in vivid-vid-out.c
> And, fmt.vbi.samples_per_line and fmt.vbi.count are used by
> vbi_queue_setup() function in au0828-vbi.c.

If you look carefully in both cases these fields are used to determine
the size of each plane. So again, it is just the per-plane requested
size that is relevant here.

So the vb2_v4l2_create_bufs() helper function would look something like
this:

	unsigned req_sizes[VB2_MAX_PLANES];

	switch (fmt->type) {
	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
	case V4L2_BUF_TYPE_VIDEO_OUTPUT:
		req_sizes[0] = fmt->fmt.pix.sizeimage;
		break;
	case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
	case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
		for (i = 0; i < fmt->fmt.pix_mp.length; i++)
			req_sizes[i] = fmt->fmt.pix_mp.plane_fmt[i].sizeimage;
		break;
	case V4L2_BUF_TYPE_VBI_CAPTURE:
	case V4L2_BUF_TYPE_VBI_OUTPUT:
		req_sizes[0] = fmt->fmt.vbi.samples_per_line *
			(fmt->fmt.vbi.count[0] + fmt->fmt.vbi.count[1]);
		break;
	// etc. For sliced vbi it is io_size, for sdr is it buffersize
	}

	vb2_core_create_bufs(...., req_sizes, ...)

> Even if you put that only these two example, it will be very
> hard to make vb2_v4l2_create_bufs helper function to use something
> common instead of v4l2_format, IMHO.

All queue_setup is interested in is the requested plane sizes obtained
from v4l2_format. So I don't think this is a problem at all.

Regards,

	Hans

> 
> Best regards,
> Junghak


  reply	other threads:[~2015-09-11 11:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-09 11:19 [RFC PATCH v4 0/8] Refactoring Videobuf2 for common use Junghak Sung
2015-09-09 11:19 ` [RFC PATCH v4 1/8] [media] videobuf2: Replace videobuf2-core with videobuf2-v4l2 Junghak Sung
2015-09-11  8:02   ` Hans Verkuil
2015-09-14  5:48     ` Junghak Sung
2015-09-14  6:33       ` Hans Verkuil
2015-09-09 11:19 ` [RFC PATCH v4 2/8] [media] videobuf2: Restructure vb2_buffer (1/3) Junghak Sung
2015-09-11  9:19   ` Hans Verkuil
2015-09-09 11:19 ` [RFC PATCH v4 3/8] [media] videobuf2: Restructure vb2_buffer (2/3) Junghak Sung
2015-09-09 11:19 ` [RFC PATCH v4 4/8] [media] videobuf2: Restructure vb2_buffer (3/3) Junghak Sung
2015-09-09 11:19 ` [RFC PATCH v4 5/8] [media] videobuf2: Change queue_setup argument Junghak Sung
2015-09-11  8:52   ` Hans Verkuil
2015-09-11 11:07     ` Junghak Sung
2015-09-11 11:18       ` Hans Verkuil [this message]
2015-09-09 11:19 ` [RFC PATCH v4 6/8] [media] videobuf2: Replace v4l2-specific data with vb2 data Junghak Sung
2015-09-11  8:14   ` Hans Verkuil
2015-09-11 11:12     ` Junghak Sung
2015-09-09 11:19 ` [RFC PATCH v4 7/8] [media] videobuf2: Move v4l2-specific stuff to videobuf2-v4l2 Junghak Sung
2015-09-11  8:17   ` Hans Verkuil
2015-09-09 11:19 ` [RFC PATCH v4 8/8] [media] videobuf2: Remove v4l2-dependencies from videobuf2-core Junghak Sung
2015-09-11 12:47   ` Hans Verkuil
2015-09-14  7:05     ` Junghak Sung

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=55F2B89A.6050701@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=inki.dae@samsung.com \
    --cc=jh1009.sung@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=nenggun.kim@samsung.com \
    --cc=pawel@osciak.com \
    --cc=rany.kwon@samsung.com \
    --cc=sakari.ailus@iki.fi \
    --cc=sangbae90.lee@samsung.com \
    --cc=sw0312.kim@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.