Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3214509imu; Sat, 24 Nov 2018 00:16:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/UKzY8Tua5MdER2XTjB/VA8aG2OYQRGZ3+BTN1yRvY1oyGozMKc2r5Zedav5xD+ZPsQhCC/ X-Received: by 2002:a17:902:2868:: with SMTP id e95mr17199122plb.317.1543047386620; Sat, 24 Nov 2018 00:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047386; cv=none; d=google.com; s=arc-20160816; b=Eat82KXcSa3Apd89XoztKbS/hCUh+KEwaGkPiYXke2ZsrwKmgFbzjLQ3BFvvhyCmDk taEFOOHfYwLtmpoHqXAA09LfHgUNevNjkZFRx9mxpjB0j+AtKWxnHL2SaMmyNhbhoc8n +DrDOjGW/goPUhPenVtTF/M7R/WD+JD54hsyGdG6tj+eLUM2NRFXuE6lnf/31i6Yi6rP VsM6/FcYjoPxQU58jVVtQ11adOxMi0OUqnAUIztdz8nUVgneHmqXNrXQ2OM+QLAglClD 0tn5QW1sMTsQVRNfCXUl2K2KVWDH2YDXrS/fP2Xi8h0Ky5+gZS4t4DQdIuDDBTVDaoMl MbTg== 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:message-id:date:subject:cc:to:from; bh=aZSQHrClfT/5r1FwpbVlWHdOpISdMGA7v2IZgLk3wk8=; b=h7I8O4gXIWreGbOCkJnbb2uhuziB9n1qtuyPMnKfXUO1XNYeyWUBiFTlfdknn0cjvX JgMQlqVK3u5juYS+6y49QQZCnjKMr01C8BF0vVeQ0ZAOzUnFCUB3pBQ3CZzZjEYGkJWT sz7Y4bhm+8pfCXVvqxG/jkNFngD/pnASgW82ysznMEV2mYM1YvhASQLu5vByQMfcSzRt P656XReuBt/CbERJqs5x9kt/G8C5Hr4nboAvqzyQemERHl7IJkppRJqRt0LVdQBDzUrY w6LXqnhiTLpDUy4vaGd1aVHPGNJ1bAw9Y6c5Td/mxtXUHLNvASp6S3cnJ+B+13gAwpLH pHBw== 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 m3si23145018pld.331.2018.11.24.00.16.12; Sat, 24 Nov 2018 00:16:26 -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 S2408951AbeKWUK3 (ORCPT + 99 others); Fri, 23 Nov 2018 15:10:29 -0500 Received: from mail.bootlin.com ([62.4.15.54]:49412 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502722AbeKWUK1 (ORCPT ); Fri, 23 Nov 2018 15:10:27 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 5D23820DF0; Fri, 23 Nov 2018 10:26:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-94-205.w90-88.abo.wanadoo.fr [90.88.35.205]) by mail.bootlin.com (Postfix) with ESMTPSA id 7659720DF9; Fri, 23 Nov 2018 10:26:33 +0100 (CET) From: Paul Kocialkowski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Chen-Yu Tsai , Thomas Petazzoni , linux-sunxi@googlegroups.com, Daniel Vetter , Paul Kocialkowski Subject: [PATCH v2 23/43] drm/sun4i: backend: Detail the YUV to RGB values coding explanation Date: Fri, 23 Nov 2018 10:24:55 +0100 Message-Id: <20181123092515.2511-24-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> References: <20181123092515.2511-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paul Kocialkowski The values in the BT601 YUV to RGB colorspace translation are not simply coded as multiples, but rather as fixed-point signed fractional values on a given number of bits. Add an explanation about that. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_backend.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index a39d8b75d76a..986bdb64521c 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -48,8 +48,12 @@ static const u32 sunxi_rgb2yuv_coef[12] = { /* * These coefficients are taken from the A33 BSP from Allwinner. * - * The formula is for each component, each coefficient being multiplied by - * 1024 and each constant being multiplied by 16: + * The first three values of each row are coded as 13-bit signed fixed-point + * numbers, with 10 bits for the fractional part. The fourth value is a + * constant coded as a 14-bit signed fixed-point number with 4 bits for the + * fractional part. + * + * The values in table order give the following colorspace translation: * G = 1.164 * Y - 0.391 * U - 0.813 * V + 135 * R = 1.164 * Y + 1.596 * V - 222 * B = 1.164 * Y + 2.018 * U + 276 -- 2.19.1