linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Dave Stevenson <linux-media@destevenson.freeserve.co.uk>,
	Eric Anholt <eric@anholt.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-rpi-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH 1/6] staging: Import the BCM2835 MMAL-based V4L2 camera driver.
Date: Mon, 6 Feb 2017 17:00:33 +0100	[thread overview]
Message-ID: <92d0017b-0156-06ab-1884-59708ad1b91a@xs4all.nl> (raw)
In-Reply-To: <05af3466-704f-6beb-7650-208d548a5bbc@destevenson.freeserve.co.uk>

On 02/06/2017 04:21 PM, Dave Stevenson wrote:
> Hi Hans.
> 
> On 06/02/17 12:58, Hans Verkuil wrote:
>> On 02/06/2017 12:37 PM, Dave Stevenson wrote:
>>> Hi Hans.
>>>
>>> On 06/02/17 09:08, Hans Verkuil wrote:
>>>> Hi Eric,
>>>>
>>>> Great to see this driver appearing for upstream merging!
>>>>
>>>> See below for my review comments, focusing mostly on V4L2 specifics.
>>>>
> 
> <snip>
> 
>>>>> +	f->fmt.pix.pixelformat = dev->capture.fmt->fourcc;
>>>>> +	f->fmt.pix.bytesperline = dev->capture.stride;
>>>>> +	f->fmt.pix.sizeimage = dev->capture.buffersize;
>>>>> +
>>>>> +	if (dev->capture.fmt->fourcc == V4L2_PIX_FMT_RGB24)
>>>>> +		f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
>>>>> +	else if (dev->capture.fmt->fourcc == V4L2_PIX_FMT_JPEG)
>>>>> +		f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
>>>>> +	else
>>>>> +		f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
>>>>
>>>> Colorspace has nothing to do with the pixel format. It should come from the
>>>> sensor/video receiver.
>>>>
>>>> If this information is not available, then COLORSPACE_SRGB is generally a
>>>> good fallback.
>>>
>>> I would if I could, but then I fail v4l2-compliance on V4L2_PIX_FMT_JPEG
>>> https://git.linuxtv.org/v4l-utils.git/tree/utils/v4l2-compliance/v4l2-test-formats.cpp#n329
>>> The special case for JPEG therefore has to remain.
>>
>> Correct. Sorry, my fault, I forgot about that.
>>
>>>
>>> It looks like I tripped over the subtlety between V4L2_COLORSPACE_,
>>> V4L2_XFER_FUNC_, V4L2_YCBCR_ENC_, and V4L2_QUANTIZATION_, and Y'CbCr
>>> encoding vs colourspace.
>>>
>>> The ISP coefficients are set up for BT601 limited range, and any
>>> conversion back to RGB is done based on that. That seemed to fit
>>> SMPTE170M rather than SRGB.
>>
>> Colorspace refers to the primary colors + whitepoint that are used to
>> create the colors (basically this answers the question to which colors
>> R, G and B exactly refer to). The SMPTE170M has different primaries
>> compared to sRGB (and a different default transfer function as well).
>>
>> RGB vs Y'CbCr is just an encoding and it doesn't change the underlying
>> colorspace. Unfortunately, the term 'colorspace' is often abused to just
>> refer to RGB vs Y'CbCr.
>>
>> If the colorspace is SRGB, then when the pixelformat is a Y'CbCr encoding,
>> then the BT601 limited range encoding is implied, unless overridden via
>> the ycbcr_enc and/or quantization fields in struct v4l2_pix_format.
>>
>> In other words, this does already the right thing.
> 
> https://linuxtv.org/downloads/v4l-dvb-apis-new/uapi/v4l/pixfmt-007.html#colorspace-srgb-v4l2-colorspace-srgb
> "The default transfer function is V4L2_XFER_FUNC_SRGB. The default 
> Y’CbCr encoding is V4L2_YCBCR_ENC_601. The default Y’CbCr quantization 
> is full range."
> So full range or limited?

Ah, good catch. The default range for SRGB is full range, so the documentation
is correct. This is according to the sYCC standard.

This means that you need to set the quantization field to limited range in this driver.

Sorry for the confusion I caused.

Interesting, I should take a look at other drivers since I suspect that this is
signaled wrong elsewhere as well. It used to be limited range but I changed it
to full range (as per the sYCC spec). But in practice it is limited range in most
cases.

I'll take another look at this on Friday.

I recommend that you leave the code as is for now.

Regards,

	Hans

>>> Test input 0:
>>>
>>> 	Control ioctls:
>>> 		test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
>>> 		test VIDIOC_QUERYCTRL: OK
>>> 		test VIDIOC_G/S_CTRL: OK
>>> 		test VIDIOC_G/S/TRY_EXT_CTRLS: OK
>>> 		test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
>>> 		test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
>>> 		Standard Controls: 33 Private Controls: 0
>>>
>>> 	Format ioctls:
>>> 		test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
>>> 		test VIDIOC_G/S_PARM: OK
>>> 		test VIDIOC_G_FBUF: OK
>>> 		test VIDIOC_G_FMT: OK
>>> 		test VIDIOC_TRY_FMT: OK
>>> 		test VIDIOC_S_FMT: OK
>>> 		test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
>>> 		test Cropping: OK (Not Supported)
>>> 		test Composing: OK (Not Supported)
>>> 		test Scaling: OK
>>
>> Is scaling supported? Just checking.
> 
> The cropping/composing/scaling API is not currently supported.
> The hardware can do it, but I need to work out how it should be set up, 
> and what resolutions to quote via V4L2_SEL_TGT_CROP_BOUNDS and similar. 
> It just needs a bit of time.

OK. This needs some attention before it can be moved out of staging.

Regards,

	Hans

> 
>>>
>>> 	Codec ioctls:
>>> 		test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
>>> 		test VIDIOC_G_ENC_INDEX: OK (Not Supported)
>>> 		test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
>>>
>>> 	Buffer ioctls:
>>> 		test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
>>> 		test VIDIOC_EXPBUF: OK (Not Supported)
>>>
>>> Test input 0:
>>>
>>>
>>> Total: 43, Succeeded: 43, Failed: 0, Warnings: 0
>>
>> Note that v4l2-compliance does very limited testing of overlay handling.
>> You should test this manually to make sure it functions properly.
> 
> OK, thanks for the heads up. It's not one that gets used that often in 
> the wild either from what I can tell.
> 
>> Regards,
>>
>> 	Hans
> 
> Thanks,
>    Dave
> 

  reply	other threads:[~2017-02-06 16:00 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 21:54 [PATCH 0/6] staging: BCM2835 MMAL V4L2 camera driver Eric Anholt
2017-01-27 21:54 ` [PATCH 1/6] staging: Import the BCM2835 MMAL-based " Eric Anholt
2017-02-03 18:59   ` Mauro Carvalho Chehab
2017-02-05 22:15     ` Dave Stevenson
2017-02-05 23:13       ` Michael Zoran
2017-02-06  8:30       ` Greg Kroah-Hartman
2017-02-06 12:37       ` Mauro Carvalho Chehab
2017-02-06 15:01         ` Dave Stevenson
2017-02-06  9:08   ` Hans Verkuil
2017-02-06 11:37     ` Dave Stevenson
2017-02-06 12:58       ` Hans Verkuil
2017-02-06 15:21         ` Dave Stevenson
2017-02-06 16:00           ` Hans Verkuil [this message]
2017-02-10  9:47             ` Hans Verkuil
2017-02-06 12:59   ` Hans Verkuil
2017-01-27 21:54 ` [PATCH 2/6] staging: bcm2835-v4l2: Update the driver to the current VCHI API Eric Anholt
2017-01-27 21:55 ` [PATCH 3/6] staging: bcm2835-v4l2: Add a build system for the module Eric Anholt
2017-01-29 14:12   ` Michael Zoran
2017-02-03 19:01   ` Mauro Carvalho Chehab
2017-01-27 21:55 ` [PATCH 4/6] staging: bcm2835-v4l2: Add a TODO file for improvements we need Eric Anholt
2017-01-27 21:55 ` [PATCH 5/6] staging: bcm2835-v4l2: Apply many whitespace fixes from checkpatch Eric Anholt
2017-01-27 21:55 ` [PATCH 6/6] staging: bcm2835-v4l2: Apply spelling " Eric Anholt
2017-01-27 22:30   ` Joe Perches
2017-01-30 20:05     ` Eric Anholt
2017-01-31  1:38       ` Joe Perches
2017-01-31 18:30         ` Eric Anholt
2017-01-31 18:49           ` Joe Perches
2017-03-15 14:01 ` [PATCH 0/6] staging: BCM2835 MMAL V4L2 camera driver Mauro Carvalho Chehab
2017-03-15 21:50   ` Stefan Wahren
2017-03-15 22:01   ` Eric Anholt
2017-03-16  1:08     ` Mauro Carvalho Chehab
2017-03-16  1:46       ` Michael Zoran
2017-03-16  9:29         ` Mauro Carvalho Chehab
2017-03-18  0:34           ` Eric Anholt
2017-03-19 16:58             ` Mauro Carvalho Chehab
2017-03-19 17:04               ` Michael Zoran
2017-03-20  1:11                 ` Mauro Carvalho Chehab
2017-03-20 10:58                   ` Mauro Carvalho Chehab
2017-03-20 11:08                     ` Michael Zoran
2017-03-20 14:58                       ` Mauro Carvalho Chehab
2017-03-20 15:11                         ` Michael Zoran
2017-03-20 15:33                           ` Mauro Carvalho Chehab
2017-03-20 15:40                             ` Michael Zoran
2017-03-22 17:10                               ` Mauro Carvalho Chehab
2017-03-20 11:57                     ` Stefan Wahren

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=92d0017b-0156-06ab-1884-59708ad1b91a@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=devel@driverdev.osuosl.org \
    --cc=eric@anholt.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@destevenson.freeserve.co.uk \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=mchehab@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 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).