Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4416335ybp; Mon, 7 Oct 2019 08:10:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwj1iS09jYJA8A30T6g62cyxEidwHMzouYvTdwTvcOvMShQZmmpAO8ps+NhLkk5k+nbYD+ X-Received: by 2002:a17:906:e92:: with SMTP id p18mr24242836ejf.308.1570461003639; Mon, 07 Oct 2019 08:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570461003; cv=none; d=google.com; s=arc-20160816; b=a4Tr8yAF/E5+672KBYOUfroLU598YzTKwilO8yILi0jYj22uFlSfthM0CGS39mm905 240O5dPq/6mrcNnJ7lKkbTNf6YJzcyENJG2dibefu+DCMDsd0MpbCsuq6s+8PE6I2vaA N4YzB+tw+NGWAbxQAPz6qemKTQc9725wPSLbQDNe/4HVQfTLU05kNwcN7BAyH7mzyAlN 3w4hjB5LkELxo8RoTUiYsw/4tlrujy7Osg0Bv8l1HGUfTg+b7aU1vtefRFTcKilLpJDz MEmrgS4eohW7kQmpdhw5ZL2iF5x/N/0m4JeyUn3RNZRZlc8asMIi+XxSBJqlx9e+HmxY eAnw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rmvp3U9wOO9fx1V5/5lVy3lHSgb3r92p/5Ndn8D9Cno=; b=kUu9X5iiYk/dueFukYlh4CKVUrlXzfZHp8+Q82YmJdu9b4X3pYvQYPiJZhQexpmWR6 7K454TYvaoLAHwtwLyPAkjPXZEY3iMLcqCps5cncQHMNhr8Hv9+cHHpkryg22LPAVXkr cfHdTqV39ebKysI9z/IOEILt6WxhQBrn8pakQEJpo0VocN0JtLAq0QKn8kcQdfBEANnC YFWAtpa7zvY8R0c+fGgs6ncQ4lbH9/xVVNdi7XFsKqmWekx8W2ukFAQf6iFeIuPQTnFm THsRvMNeaZ2OyeW3v3XS6VexON+cvTibzRN/e5r4x+ZkGYh1PwtOSZuv1p2tum3EJk5e Freg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PZ88vPGK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si9136626edc.227.2019.10.07.08.09.39; Mon, 07 Oct 2019 08:10:03 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=PZ88vPGK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729199AbfJGPIo (ORCPT + 99 others); Mon, 7 Oct 2019 11:08:44 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40162 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728762AbfJGPIn (ORCPT ); Mon, 7 Oct 2019 11:08:43 -0400 Received: by mail-wr1-f67.google.com with SMTP id h4so7027907wrv.7 for ; Mon, 07 Oct 2019 08:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=rmvp3U9wOO9fx1V5/5lVy3lHSgb3r92p/5Ndn8D9Cno=; b=PZ88vPGKZhvCrX5TQAJCXwbZ/+D6pVQWntk88MxmxD8JNoIcsCt3mUkxbkopRKq2Ok S4zvSHsn2Y4D2U15ngxrUfkOgx2ZnWmIrkIHbxaBIqhfzOQBjA/ixUT+jmWFnoRLJoUf Gr+x/k240g7pHGj3e5EWGz+4qddvm/hVrYCBRl/XV+bNGUYRfgnXy5nsWLgkANYb71ix 9Yl1XlQr8iq+6Qs4GaRLGgzG354SH3TytK8CKLgMVaGPzIVYqikwxQWhAVz18kCQQyT8 gaM+0swlRNT83/HMqXi3+wEbTmwu2QFdmqwgFVOz/RTQOA+1D1kl8rJ0C8OvcCjj/h3a ofpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=rmvp3U9wOO9fx1V5/5lVy3lHSgb3r92p/5Ndn8D9Cno=; b=QueWHbu5obHwOwgNWeuJnSWq6uwrs2WRADwkWf8HD4A0RHcpACzysFs9UEgn+1SZrG 4SzEB/tfs9IoC3lQi0ZYXoODoCKVIYVz/t4/Y1YBbhKju6e5laEkMEJ6CHohVfA8xfC1 lRidn7Bc3blk5jdX+jz//UkSIK1wUforR4TNRVU1J3Ay/EqcJY/gFYaEEyIQ5GB0PsnC gDohMktFZ8e7yEZKC+aiO3+Q2QzafBV91mmfAbl257Bmi0swSb4Sm+rD9OJolkUNcc3w tF5fBAezGnIdBpizVqnNK0g8ibaREHi/ZAbivBkUpfLaE3kfelGg5Ev8NGyuuJ1Tsuby IVKQ== X-Gm-Message-State: APjAAAXL6NZgx6VOWcCf9aMiLD2Vc37mROBEbxP+v89Gk5kpywbTmB3F Z9Ou4yaHoDDOKKYC6cnTZYDwkg== X-Received: by 2002:a5d:6a09:: with SMTP id m9mr21687302wru.12.1570460921085; Mon, 07 Oct 2019 08:08:41 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id s12sm29340436wra.82.2019.10.07.08.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:08:40 -0700 (PDT) Date: Mon, 7 Oct 2019 16:08:38 +0100 From: Daniel Thompson To: Rasmus Villemoes Cc: Thierry Reding , Lee Jones , Jingoo Han , Bartlomiej Zolnierkiewicz , linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] backlight: pwm_bl: fix cie1913 comments and constant Message-ID: <20191007150838.3qbrten34ln6ufo4@holly.lan> References: <20190919140620.32407-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190919140620.32407-1-linux@rasmusvillemoes.dk> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 19, 2019 at 04:06:16PM +0200, Rasmus Villemoes wrote: > The "break-even" point for the two formulas is L==8, which is also > what the code actually implements. [Incidentally, at that point one > has Y=0.008856, not 0.08856]. > > Moreover, all the sources I can find say the linear factor is 903.3 > rather than 902.3, which makes sense since then the formulas agree at > L==8, both yielding the 0.008856 figure to four significant digits. Indeed. Interestingly the following doc (with a high search rank in Google) has exactly this inconsistency and uses different values at different times: http://www.photonstophotos.net/GeneralTopics/Exposure/Psychometric_Lightness_and_Gamma.htm > > Signed-off-by: Rasmus Villemoes Reviewed-by: Daniel Thompson > --- > drivers/video/backlight/pwm_bl.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c > index 2201b8c78641..be36be1cacb7 100644 > --- a/drivers/video/backlight/pwm_bl.c > +++ b/drivers/video/backlight/pwm_bl.c > @@ -155,8 +155,8 @@ static const struct backlight_ops pwm_backlight_ops = { > * > * The CIE 1931 lightness formula is what actually describes how we perceive > * light: > - * Y = (L* / 902.3) if L* ≤ 0.08856 > - * Y = ((L* + 16) / 116)^3 if L* > 0.08856 > + * Y = (L* / 903.3) if L* ≤ 8 > + * Y = ((L* + 16) / 116)^3 if L* > 8 > * > * Where Y is the luminance, the amount of light coming out of the screen, and > * is a number between 0.0 and 1.0; and L* is the lightness, how bright a human > @@ -169,9 +169,15 @@ static u64 cie1931(unsigned int lightness, unsigned int scale) > { > u64 retval; > > + /* > + * @lightness is given as a number between 0 and 1, expressed > + * as a fixed-point number in scale @scale. Convert to a > + * percentage, still expressed as a fixed-point number, so the > + * above formulas can be applied. > + */ > lightness *= 100; > if (lightness <= (8 * scale)) { > - retval = DIV_ROUND_CLOSEST_ULL(lightness * 10, 9023); > + retval = DIV_ROUND_CLOSEST_ULL(lightness * 10, 9033); > } else { > retval = int_pow((lightness + (16 * scale)) / 116, 3); > retval = DIV_ROUND_CLOSEST_ULL(retval, (scale * scale)); > -- > 2.20.1