Received: by 10.223.185.116 with SMTP id b49csp1869944wrg; Thu, 22 Feb 2018 04:37:05 -0800 (PST) X-Google-Smtp-Source: AH8x227a3BxCBzNXmq2E+jC3Wl92BcEKhHtL5YbKF1mnuE5DQIH1uVa6cgeJSyMoikunQ3jI1FAN X-Received: by 2002:a17:902:f:: with SMTP id 15-v6mr6334429pla.419.1519303025216; Thu, 22 Feb 2018 04:37:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519303025; cv=none; d=google.com; s=arc-20160816; b=csq76IDgpyziW7Gf3oB0xD6fcdvMA8Jsw8g3utTEmpHMremB/FqdgtvzV6ZLBW1OJv rdPjvPljJxsONUlf/FdIzptv2tHTQdJOOrw+/PoC8XpmNWd3pdFiJyA9j58AsCTkmwfO jwrr04stGI80HMQBkjoWShrxTUYcen/cA7dN0Ip9lcCSBT9dPqkJxw6F7WU0TXqoWQbY ryzhDVsnt1BBVxELVvW1oHCO/5/9nNiKgL11gPqzERILdt2nifQOmXalpSnddrfU5+pv fesHtqzYG78Q3JsFDlxYnDnp2E7tND7VY8namx3BvuVYoZsriaVJeBVuOLAvYP8A7TZa KwPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=Zkrzb7Hp5+AHBUVgLRw1Pp0sB6YYY8uGiAb2TJ7Gkvs=; b=EWjNTEr7vvrOzAKSx0GmHPQBqPotmQCbmEAmECKvMNB2Xa4xTzUxbrkOVPuYt1f92a 5JdzbdsBmImg9bmhz+Xa1jzoB7jgXj2sLxTcPuXaZi9Q0OOsHtP69zCuQwJojGc+m6eg FhjabnmM5/2BT50FzaKRtPH1vvn3jfaZsVv1kXChQ7qBrIPUQY0eiRb1y9bY3DOu/kkC AJfxxElHRqZ8r7R6iZW4X+jjNsAruRazf6O477CzUtrjHAROUO6i3Y4grBNYc6bpHeDg X+rVVmTf0YPTk+cNdQ3Y6D57S0lw2sqRLdh7OCMfeqoE7yqkcIpAWYhu0sYovVMzeBZW 2dig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m14si2598pff.156.2018.02.22.04.36.49; Thu, 22 Feb 2018 04:37:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932251AbeBVMgK (ORCPT + 99 others); Thu, 22 Feb 2018 07:36:10 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:46217 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932077AbeBVMgI (ORCPT ); Thu, 22 Feb 2018 07:36:08 -0500 Received: from w540 (unknown [IPv6:2001:b07:6442:1ac4:3969:b0e2:8dc9:48c3]) (Authenticated sender: jacopo@jmondi.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id D7DFCC5A7B; Thu, 22 Feb 2018 13:36:01 +0100 (CET) Date: Thu, 22 Feb 2018 13:36:00 +0100 From: jacopo mondi To: Laurent Pinchart Cc: Jacopo Mondi , 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 Message-ID: <20180222123600.GM7203@w540> References: <1519059584-30844-1-git-send-email-jacopo+renesas@jmondi.org> <56271779.hLAmkO6BAC@avalon> <20180222120412.GL7203@w540> <2864762.IPlziE6Y0S@avalon> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2864762.IPlziE6Y0S@avalon> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > > > >> --- > > > > >> > > > > >> 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 >