All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-sh@vger.kernel.org
Subject: Re: [PATCH v2 03/23] v4l: Support extending the v4l2_pix_format structure
Date: Fri, 18 Jul 2014 13:12:57 +0000	[thread overview]
Message-ID: <53C91D59.7010000@xs4all.nl> (raw)
In-Reply-To: <1521674.bDcZxklUhm@avalon>

On 07/18/2014 02:27 PM, Laurent Pinchart wrote:
> Hi Hans,
> 
> On Friday 18 July 2014 07:10:48 Hans Verkuil wrote:
>> On 07/17/2014 11:22 PM, Hans Verkuil wrote:
>>> And another thing that I found while implementing this in v4l2-ctl:
>>>
>>> On 06/24/2014 01:54 AM, Laurent Pinchart wrote:
>>>> The v4l2_pix_format structure has no reserved field. It is embedded in
>>>> the v4l2_framebuffer structure which has no reserved fields either, and
>>>> in the v4l2_format structure which has reserved fields that were not
>>>> previously required to be zeroed out by applications.
>>>>
>>>> To allow extending v4l2_pix_format, inline it in the v4l2_framebuffer
>>>> structure, and use the priv field as a magic value to indicate that the
>>>> application has set all v4l2_pix_format extended fields and zeroed all
>>>> reserved fields following the v4l2_pix_format field in the v4l2_format
>>>> structure.
>>>>
>>>> The availability of this API extension is reported to userspace through
>>>> the new V4L2_CAP_EXT_PIX_FORMAT capability flag. Just checking that the
>>>> priv field is still set to the magic value at [GS]_FMT return wouldn't
>>>> be enough, as older kernels don't zero the priv field on return.
>>>>
>>>> To simplify the internal API towards drivers zero the extended fields
>>>> and set the priv field to the magic value for applications not aware of
>>>> the extensions.
>>>>
>>>> Signed-off-by: Laurent Pinchart
>>>> <laurent.pinchart+renesas@ideasonboard.com>
>>>>
>>>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
>>>> b/drivers/media/v4l2-core/v4l2-ioctl.c index 16bffd8..01b4588 100644
>>>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>>>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>>>> @@ -959,13 +959,48 @@ static int check_fmt(struct file *file, enum
>>>> v4l2_buf_type type)
> 
> [snip]
> 
>>>>  static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
>>>>  				struct file *file, void *fh, void *arg)
>>>>  {
>>>>  	struct v4l2_capability *cap = (struct v4l2_capability *)arg;
>>>> +	int ret;
>>>>
>>>>  	cap->version = LINUX_VERSION_CODE;
>>>>
>>>> -	return ops->vidioc_querycap(file, fh, cap);
>>>> +
>>>> +	ret = ops->vidioc_querycap(file, fh, cap);
>>>> +
>>>> +	cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
>>>
>>> It should be ORed to cap->device_caps as well.
>>
>> But only if cap->capabilities sets V4L2_CAP_DEVICE_CAPS.
>>
>> Should we unconditionally add this flag or only if CAP_VIDEO_CAPTURE or
>> CAP_VIDEO_OUTPUT is set?
>>
>> So we could do this:
>>
>> 	if (cap->capabilities & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT))
>> 		cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
>> 	if ((cap->capabilities & V4L2_CAP_DEVICE_CAPS) &&
>> 	    (cap->device_caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT))
>> 		cap->device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
>>
>>
>> I can argue either direction: on the one hand ext_pix_format handling is
>> part of the v4l2 core, so it is valid for all that use it, on the other
>> hand it makes no sense for a non-video device.
>>
>> My preference would be to set it only in combination with video
>> capture/output since it just looks peculiar otherwise.
> 
> I have mixed feelings here. As the flag indicates whether a particular feature 
> is supported by the V4L2 API, wouldn't it make more sense to set it only in 
> the capabilities field, and unconditionally ? Does setting it conditionally 
> bring any benefit to kernel space or userspace ? Same question for 
> device_caps, I don't think it would help applications in a any way (but please 
> feel free to point me to use cases I might have missed).

There are two things: should it be set for device_caps as well: absolutely. The
device_caps field should contain all caps relevant for that device and
EXT_PIX_FORMAT definitely belongs there.

Several of the apps in v4l-utils do something like this:

	__u32 caps = qcap->capabilities;
	if (caps & V4L2_CAP_DEVICE_CAPS)
		caps = qcap->device_caps;

And after that I just use caps. It makes life very easy.

Whether V4L2_CAP_EXT_PIX_FORMAT should be set unconditionally: I've got
mixed feelings as well. So let's leave it as is, I'm OK with that. Just
add it to device_caps as well...

Regards,

	Hans

WARNING: multiple messages have this Message-ID (diff)
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	linux-media@vger.kernel.org, linux-sh@vger.kernel.org
Subject: Re: [PATCH v2 03/23] v4l: Support extending the v4l2_pix_format structure
Date: Fri, 18 Jul 2014 15:12:57 +0200	[thread overview]
Message-ID: <53C91D59.7010000@xs4all.nl> (raw)
In-Reply-To: <1521674.bDcZxklUhm@avalon>

On 07/18/2014 02:27 PM, Laurent Pinchart wrote:
> Hi Hans,
> 
> On Friday 18 July 2014 07:10:48 Hans Verkuil wrote:
>> On 07/17/2014 11:22 PM, Hans Verkuil wrote:
>>> And another thing that I found while implementing this in v4l2-ctl:
>>>
>>> On 06/24/2014 01:54 AM, Laurent Pinchart wrote:
>>>> The v4l2_pix_format structure has no reserved field. It is embedded in
>>>> the v4l2_framebuffer structure which has no reserved fields either, and
>>>> in the v4l2_format structure which has reserved fields that were not
>>>> previously required to be zeroed out by applications.
>>>>
>>>> To allow extending v4l2_pix_format, inline it in the v4l2_framebuffer
>>>> structure, and use the priv field as a magic value to indicate that the
>>>> application has set all v4l2_pix_format extended fields and zeroed all
>>>> reserved fields following the v4l2_pix_format field in the v4l2_format
>>>> structure.
>>>>
>>>> The availability of this API extension is reported to userspace through
>>>> the new V4L2_CAP_EXT_PIX_FORMAT capability flag. Just checking that the
>>>> priv field is still set to the magic value at [GS]_FMT return wouldn't
>>>> be enough, as older kernels don't zero the priv field on return.
>>>>
>>>> To simplify the internal API towards drivers zero the extended fields
>>>> and set the priv field to the magic value for applications not aware of
>>>> the extensions.
>>>>
>>>> Signed-off-by: Laurent Pinchart
>>>> <laurent.pinchart+renesas@ideasonboard.com>
>>>>
>>>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c
>>>> b/drivers/media/v4l2-core/v4l2-ioctl.c index 16bffd8..01b4588 100644
>>>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>>>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>>>> @@ -959,13 +959,48 @@ static int check_fmt(struct file *file, enum
>>>> v4l2_buf_type type)
> 
> [snip]
> 
>>>>  static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
>>>>  				struct file *file, void *fh, void *arg)
>>>>  {
>>>>  	struct v4l2_capability *cap = (struct v4l2_capability *)arg;
>>>> +	int ret;
>>>>
>>>>  	cap->version = LINUX_VERSION_CODE;
>>>>
>>>> -	return ops->vidioc_querycap(file, fh, cap);
>>>> +
>>>> +	ret = ops->vidioc_querycap(file, fh, cap);
>>>> +
>>>> +	cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
>>>
>>> It should be ORed to cap->device_caps as well.
>>
>> But only if cap->capabilities sets V4L2_CAP_DEVICE_CAPS.
>>
>> Should we unconditionally add this flag or only if CAP_VIDEO_CAPTURE or
>> CAP_VIDEO_OUTPUT is set?
>>
>> So we could do this:
>>
>> 	if (cap->capabilities & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT))
>> 		cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
>> 	if ((cap->capabilities & V4L2_CAP_DEVICE_CAPS) &&
>> 	    (cap->device_caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT))
>> 		cap->device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
>>
>>
>> I can argue either direction: on the one hand ext_pix_format handling is
>> part of the v4l2 core, so it is valid for all that use it, on the other
>> hand it makes no sense for a non-video device.
>>
>> My preference would be to set it only in combination with video
>> capture/output since it just looks peculiar otherwise.
> 
> I have mixed feelings here. As the flag indicates whether a particular feature 
> is supported by the V4L2 API, wouldn't it make more sense to set it only in 
> the capabilities field, and unconditionally ? Does setting it conditionally 
> bring any benefit to kernel space or userspace ? Same question for 
> device_caps, I don't think it would help applications in a any way (but please 
> feel free to point me to use cases I might have missed).

There are two things: should it be set for device_caps as well: absolutely. The
device_caps field should contain all caps relevant for that device and
EXT_PIX_FORMAT definitely belongs there.

Several of the apps in v4l-utils do something like this:

	__u32 caps = qcap->capabilities;
	if (caps & V4L2_CAP_DEVICE_CAPS)
		caps = qcap->device_caps;

And after that I just use caps. It makes life very easy.

Whether V4L2_CAP_EXT_PIX_FORMAT should be set unconditionally: I've got
mixed feelings as well. So let's leave it as is, I'm OK with that. Just
add it to device_caps as well...

Regards,

	Hans

  reply	other threads:[~2014-07-18 13:12 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 23:54 [PATCH v2 00/23] Renesas VSP1: alpha support and miscellaneous fixes Laurent Pinchart
2014-06-23 23:54 ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 01/23] v4l: Add ARGB and XRGB pixel formats Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-27  9:34   ` Hans Verkuil
2014-06-27  9:34     ` Hans Verkuil
2014-07-17 21:53   ` Hans Verkuil
2014-07-17 21:53     ` Hans Verkuil
2014-07-18 12:31     ` Laurent Pinchart
2014-07-18 12:31       ` Laurent Pinchart
2014-07-18 13:14       ` Hans Verkuil
2014-07-18 13:14         ` Hans Verkuil
2014-07-18 13:21         ` Hans Verkuil
2014-07-18 13:21           ` Hans Verkuil
2014-06-23 23:54 ` [PATCH v2 02/23] DocBook: media: Document ALPHA_COMPONENT control usage on output devices Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-27  9:34   ` Hans Verkuil
2014-06-27  9:34     ` Hans Verkuil
2014-06-23 23:54 ` [PATCH v2 03/23] v4l: Support extending the v4l2_pix_format structure Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-27 12:36   ` Hans Verkuil
2014-06-27 12:36     ` Hans Verkuil
2014-06-29 20:41     ` Laurent Pinchart
2014-06-29 20:41       ` Laurent Pinchart
2014-07-17 21:04   ` Hans Verkuil
2014-07-17 21:04     ` Hans Verkuil
2014-07-21 20:56     ` Laurent Pinchart
2014-07-21 20:56       ` Laurent Pinchart
2014-07-21 22:17       ` Hans Verkuil
2014-07-21 22:17         ` Hans Verkuil
2014-07-17 21:22   ` Hans Verkuil
2014-07-17 21:22     ` Hans Verkuil
2014-07-18  5:10     ` Hans Verkuil
2014-07-18  5:10       ` Hans Verkuil
2014-07-18 12:27       ` Laurent Pinchart
2014-07-18 12:27         ` Laurent Pinchart
2014-07-18 13:12         ` Hans Verkuil [this message]
2014-07-18 13:12           ` Hans Verkuil
2014-06-23 23:54 ` [PATCH v2 04/23] v4l: Add premultiplied alpha flag for pixel formats Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-27 12:39   ` Hans Verkuil
2014-06-27 12:39     ` Hans Verkuil
2014-06-23 23:54 ` [PATCH v2 05/23] v4l: vb2: Fix stream start and buffer completion race Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-24 10:25   ` Hans Verkuil
2014-06-24 10:25     ` Hans Verkuil
2014-06-23 23:54 ` [PATCH v2 06/23] v4l: vsp1: Fix routing cleanup when stopping the stream Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 07/23] v4l: vsp1: Release buffers at stream stop Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-24 12:00   ` Sergei Shtylyov
2014-06-24 12:00     ` Sergei Shtylyov
2014-07-01  7:16     ` Laurent Pinchart
2014-07-01  7:16       ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 08/23] v4l: vsp1: Fix pipeline stop timeout Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 09/23] v4l: vsp1: Fix typos Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 10/23] v4l: vsp1: Cleanup video nodes at removal time Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 11/23] v4l: vsp1: Propagate vsp1_device_get errors to the callers Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 12/23] v4l: vsp1: Setup control handler automatically at stream on time Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 13/23] v4l: vsp1: sru: Fix the intensity control default value Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 14/23] v4l: vsp1: sru: Make the intensity controllable during streaming Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 15/23] v4l: vsp1: wpf: Simplify cast to pipeline structure Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 16/23] v4l: vsp1: wpf: Clear RPF to WPF association at stream off time Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 17/23] v4l: vsp1: Switch to XRGB formats Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 18/23] v4l: vsp1: Add alpha channel support to the memory ports Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 19/23] v4l: vsp1: Add V4L2_CID_ALPHA_COMPONENT control support Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 20/23] v4l: vsp1: bru: Support premultiplied alpha at the BRU inputs Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 21/23] v4l: vsp1: bru: Support non-premultiplied colors at the BRU output Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 22/23] v4l: vsp1: bru: Make the background color configurable Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart
2014-06-23 23:54 ` [PATCH v2 23/23] v4l: vsp1: uds: Fix scaling of alpha layer Laurent Pinchart
2014-06-23 23:54   ` Laurent Pinchart

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=53C91D59.7010000@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    /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.