linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jacopo mondi <jacopo@jmondi.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>,
	magnus.damm@gmail.com, geert@glider.be, hverkuil@xs4all.nl,
	mchehab@kernel.org, festevam@gmail.com, sakari.ailus@iki.fi,
	robh+dt@kernel.org, mark.rutland@arm.com, pombredanne@nexb.com,
	linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org,
	linux-sh@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 11/11] media: i2c: ov7670: Fully set mbus frame fmt
Date: Thu, 22 Feb 2018 13:36:00 +0100	[thread overview]
Message-ID: <20180222123600.GM7203@w540> (raw)
In-Reply-To: <2864762.IPlziE6Y0S@avalon>

Hi Laurent,

On Thu, Feb 22, 2018 at 02:14:53PM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> On Thursday, 22 February 2018 14:04:12 EET jacopo mondi wrote:
> > On Wed, Feb 21, 2018 at 10:28:06PM +0200, Laurent Pinchart wrote:
> > > On Tuesday, 20 February 2018 10:58:57 EET jacopo mondi wrote:
> > > > On Mon, Feb 19, 2018 at 09:19:32PM +0200, Laurent Pinchart wrote:
> > > > > On Monday, 19 February 2018 18:59:44 EET Jacopo Mondi wrote:
> > > > >> The sensor driver sets mbus format colorspace information and sizes,
> > > > >> but not ycbcr encoding, quantization and xfer function. When supplied
> > > > >> with an badly initialized mbus frame format structure, those fields
> > > > >> need to be set explicitly not to leave them uninitialized. This is
> > > > >> tested by v4l2-compliance, which supplies a mbus format description
> > > > >> structure and checks for all fields to be properly set.
> > > > >>
> > > > >> Without this commit, v4l2-compliance fails when testing formats with:
> > > > >> fail: v4l2-test-formats.cpp(335): ycbcr_enc >= 0xff
> > > > >>
> > > > >> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > > > >> ---
> > > > >>
> > > > >>  drivers/media/i2c/ov7670.c | 4 ++++
> > > > >>  1 file changed, 4 insertions(+)
> > > > >>
> > > > >> diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
> > > > >> index 25b26d4..61c472e 100644
> > > > >> --- a/drivers/media/i2c/ov7670.c
> > > > >> +++ b/drivers/media/i2c/ov7670.c
> > > > >> @@ -996,6 +996,10 @@ static int ov7670_try_fmt_internal(struct
> > > > >> v4l2_subdev
> > > > >> *sd, fmt->height = wsize->height;
> > > > >>
> > > > >>  	fmt->colorspace = ov7670_formats[index].colorspace;
> > > > >
> > > > > On a side note, if I'm not mistaken the colorspace field is set to
> > > > > SRGB
> > > > > for all entries. Shouldn't you hardcode it here and remove the field ?
> > > > >
> > > > >> +	fmt->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
> > > > >> +	fmt->quantization = V4L2_QUANTIZATION_DEFAULT;
> > > > >> +	fmt->xfer_func = V4L2_XFER_FUNC_DEFAULT;
> > > > >
> > > > > How about setting the values explicitly instead of relying on defaults
> > > > > ?
> > > > > That would be V4L2_YCBCR_ENC_601, V4L2_QUANTIZATION_LIM_RANGE and
> > > > > V4L2_XFER_FUNC_SRGB. And could you then check a captured frame to see
> > > > > if
> > > > > the sensor outputs limited or full range ?
> > > >
> > > > This actually makes me wonder if those informations (ycbcb_enc,
> > > > quantization and xfer_func) shouldn't actually be part of the
> > > > supported format list... I blindly added those default fields in the
> > > > try_fmt function, but I doubt they applies to all supported formats.
> > > >
> > > > Eg. the sensor supports YUYV as well as 2 RGB encodings (RGB444 and
> > > > RGB 565) and 1 raw format (BGGR). I now have a question here:
> > > >
> > > > 1) ycbcr_enc transforms non-linear R'G'B' to Y'CbCr: does this
> > > > applies to RGB and raw formats? I don't think so, and what value is
> > > > the correct one for the ycbcr_enc field in this case? I assume
> > > > xfer_func and quantization applies to all formats instead..
> > >
> > > There's no encoding for RGB formats if I understand things correctly, so
> > > I'd set ycbcr_enc to V4L2_YCBCR_ENC_DEFAULT. The transfer function and
> > > the quantization apply to all formats, but I'd be surprised to find a
> > > sensor outputting limited range for RGB.
> >
> > Ack, we got the same understanding for RGB formats. I wonder if for
> > those formats we wouldn't need a V4L2_YCBCR_ENC_NONE or similar...
>
> That, or explicitly documenting that when the format is not YUV the field
> should be set by both drivers and applications to V4L2_YCBCR_ENC_DEFAULT when
> written and ignored when read.
>

Well, if no encoding is performed because the color encoding scheme is
RGB, the colorspace does anyway define an encoding method, so it seems
to me the latter is more appropriate (use DEFAULT and ignore when read).

That's anyway just my opinion, but I could send a patch for
documentation and see what feedback it gets.

> > > Have you been able to check whether the sensor outputs limited range of
> > > full range YUV ? If it outputs full range you can hardcode quantization
> > > to V4L2_QUANTIZATION_FULL_RANGE for all formats.
> >
> > In YUYV mode, I see values > 0xf0 ( > 240, which is the max value for
> > CbCr samples in limited quantization range), so I assume quantization
> > is full range.
>
> It should be, yes. What's the minimum and maximum values you get ?

>From a white surface:
min = 0x39
max = 0xfc

>From a black surface:
min = 0x00 (with 62 occurrences)
max = 0x8b

I guess that's indeed full range quantization

>
> > Actually the hardest part here was having a white enough surface to
> > point the sensor to :)
>
> Pointing a flashlight to the sensor usually does the trick.

I had a yellowish light that didn't work that well, I ended up putting
a white paper sheet in front of it and then took the picture.

Thanks
  j

>
> > >>>>  	info->format = *fmt;
> > >>>>
> > >>>>  	return 0;
>
> --
> Regards,
>
> Laurent Pinchart
>

  reply	other threads:[~2018-02-22 12:36 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-19 16:59 [PATCH v9 00/11] Renesas Capture Engine Unit (CEU) V4L2 driver Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 01/11] dt-bindings: media: Add Renesas CEU bindings Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 02/11] include: media: Add Renesas CEU driver interface Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 03/11] media: platform: Add Renesas CEU driver Jacopo Mondi
2018-02-20  3:35   ` kbuild test robot
2018-02-21 12:03   ` Hans Verkuil
2018-02-21 12:29     ` Laurent Pinchart
2018-02-21 13:02       ` Hans Verkuil
2018-02-21 16:43         ` jacopo mondi
2018-02-19 16:59 ` [PATCH v9 04/11] ARM: dts: r7s72100: Add Capture Engine Unit (CEU) Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 05/11] media: i2c: Copy ov772x soc_camera sensor driver Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 06/11] media: i2c: ov772x: Remove soc_camera dependencies Jacopo Mondi
2018-02-21 12:08   ` Hans Verkuil
2018-02-19 16:59 ` [PATCH v9 07/11] media: i2c: ov772x: Support frame interval handling Jacopo Mondi
2018-02-20  4:25   ` kbuild test robot
2018-02-20  5:22   ` kbuild test robot
2018-02-20  5:22   ` [RFC PATCH] media: i2c: ov772x: ov772x_frame_intervals[] can be static kbuild test robot
2018-02-21 12:12   ` [PATCH v9 07/11] media: i2c: ov772x: Support frame interval handling Hans Verkuil
2018-02-21 15:16     ` jacopo mondi
2018-02-21 15:23       ` Hans Verkuil
2018-02-19 16:59 ` [PATCH v9 08/11] media: i2c: Copy tw9910 soc_camera sensor driver Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 09/11] media: i2c: tw9910: Remove soc_camera dependencies Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 10/11] arch: sh: migor: Use new renesas-ceu camera driver Jacopo Mondi
2018-02-19 16:59 ` [PATCH v9 11/11] media: i2c: ov7670: Fully set mbus frame fmt Jacopo Mondi
2018-02-19 19:19   ` Laurent Pinchart
2018-02-20  8:58     ` jacopo mondi
2018-02-21 15:47       ` jacopo mondi
2018-02-21 16:28         ` Hans Verkuil
2018-02-21 20:28       ` Laurent Pinchart
2018-02-22 12:04         ` jacopo mondi
2018-02-22 12:14           ` Laurent Pinchart
2018-02-22 12:36             ` jacopo mondi [this message]
2018-02-22 12:47               ` Laurent Pinchart
2018-02-22 14:26                 ` jacopo mondi

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=20180222123600.GM7203@w540 \
    --to=jacopo@jmondi.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=geert@glider.be \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo+renesas@jmondi.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=mchehab@kernel.org \
    --cc=pombredanne@nexb.com \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@iki.fi \
    /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).