Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3650430imj; Tue, 12 Feb 2019 02:19:12 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibbdehe1c2EJivMes8+9Jasp+arJx8zBGnQJBNTeryIpxXBWQJRdYZlSsZt4MSkDXODU7Df X-Received: by 2002:a65:6298:: with SMTP id f24mr2936252pgv.183.1549966752683; Tue, 12 Feb 2019 02:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549966752; cv=none; d=google.com; s=arc-20160816; b=xXNeuIP2VHV27onw90xywE1xohBJDYw4xIi9n70S8qKOJtYi3BshIGy7R02m2nfzit 1pzgPCtfk9C6OaL6LPTjAX85Tb1o19q9wwECBtocM8xVywFplTV+ylnOMCEnmAMa5zxD 8gfQefwdzhKazZliyD54d8XSiz2n6Q2/o7PUJ0Pr+dKTyLjn0f32IzAf1jatrY57Yymd BMUywQPmG+sF6ny4mt7mQWh7BUiLdziCh8mwz7tAmyChU4ofMqvR0i7OYZV0AsWRssDX MtXFSEG6pLaFGq+NrdeuG77O2b+EbhZ9qyzngUMrugsu+ZQ70AOwouAD/RG3m+FwTY6d S/cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=vhrJ7+AHmC5G9abPugWJ6JmUjvwHfEpKwBn3+iNRlmc=; b=XeYB8Yd6gTyZhqjLxDdF+2m5Nf33U5tqc0DZEYdXKr5GCGNSu5AMyglb07ihljIV+F rS6W1ro4DrhL39rlSADxadrCgPzyfak4/mA/cQ9Y6upNEzkLVD2qVIZS+0DbnynkZhFC Q6cI4AUG0RH9uqxQ8vMZreBzzw5KFjGHvbpGuFYBDx2nl4odGXymkd2fEWM0mqRba2wg K8TjMo90XqvUYzC6R5ppBehG50zQydw+i19nc6HpVIaQz1JM43ihGN12pPBPHFR4fsiI jO+mCVmGiNz58usMnKKLbrkbdQc4cnR1J7KDjDCE8C4zkTQMl55V5P4tlM/FkvqOrxA1 R3Kw== 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 d10si879431pfh.133.2019.02.12.02.18.56; Tue, 12 Feb 2019 02:19:12 -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 S1728523AbfBLKRu (ORCPT + 99 others); Tue, 12 Feb 2019 05:17:50 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:58721 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726003AbfBLKRu (ORCPT ); Tue, 12 Feb 2019 05:17:50 -0500 Received: from lupine.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:1a17] helo=lupine) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1gtV8M-00068m-Sn; Tue, 12 Feb 2019 11:17:46 +0100 Message-ID: <1549966666.4800.3.camel@pengutronix.de> Subject: Re: [PATCH v4 1/4] gpu: ipu-v3: ipu-ic: Rename yuv2rgb encoding matrices From: Philipp Zabel To: Steve Longerbeam , linux-media@vger.kernel.org Cc: Tim Harvey , "open list:DRM DRIVERS FOR FREESCALE IMX" , open list Date: Tue, 12 Feb 2019 11:17:46 +0100 In-Reply-To: <0f987e19-e6e9-a56e-00ec-61e7e300a92e@gmail.com> References: <20190209014748.10427-1-slongerbeam@gmail.com> <20190209014748.10427-2-slongerbeam@gmail.com> <1549879117.7687.2.camel@pengutronix.de> <0f987e19-e6e9-a56e-00ec-61e7e300a92e@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:1a17 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steve, On Mon, 2019-02-11 at 10:24 -0800, Steve Longerbeam wrote: [...] > Looking more closely at these coefficients now, I see you are right, > they are the BT.601 YUV full-range coefficients (Y range 0 to 1, U and V > range -0.5 to 0.5). Well, not even that -- the coefficients are not > being scaled to the limited ranges, but the 0.5 offset (128) _is_ being > added to U/V, but no offset for Y. So it is even more messed up. > > Your corrected coefficients and offsets look correct to me: Y > coefficients scaled to (235 - 16) / 255 and U/V coefficients scaled to > (240 - 16)  / 255, and add the offsets for both Y and U/V. > > But what about this "SAT_MODE" field in the IC task parameter memory? That just controls the saturation. The result after the matrix multiplication is either saturated to [0..255] or to [16..235]/[16..240] when converting from the internal representation to the 8 bit output. > According to the manual the hardware will automatically convert the > written coefficients to the correct limited ranges. Where did you get that from? "The final calculation result is limited according to the SAT_MODE parameter and rounded to 8 bits." I see no mention of coefficients being modified. > I see there is a "sat" field defined in the struct but is not being > set in the tables. > > So what should we do, define the full range coefficients, and make use > of SAT_MODE h/w feature, or scale/offset the coefficients ourselves and > not use SAT_MODE? I'm inclined to do the former. SAT_MODE should be set for conversions to YUV limited range so that the coefficients can be rounded to the closest value. Otherwise we'd have to round towards zero, possibly with a larger error, to make sure the results are inside the valid ranges. regards Philipp