Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2888639ybd; Mon, 24 Jun 2019 14:45:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzK7RS8+lqquWrZCVITGKR+yNUWIzfw4JPU077Mj8wFSnQ+CRmNAgVVSoyW1J6auXFTJaZ4 X-Received: by 2002:a17:90a:fa18:: with SMTP id cm24mr18850094pjb.120.1561412753185; Mon, 24 Jun 2019 14:45:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561412753; cv=none; d=google.com; s=arc-20160816; b=htrEUWEmB2qYbQc8MpIGrqjjW8yJ7OqkW8S6e97ZbjjePjWdIpaz8ogBQxmwMITf6e 0pBFaMNNikrUgzoMFlm6WX0C8SKLb/R9OrJuitoFh6vkfgHOnKVyYL1A7u+DxVdATjJ0 2777oZuWuJ+aEQ/ecV2wDfIz65shUDiFKVJCKVNZbeR7OXqikaandttDytZ1UzvPBKzt J2vS2VgdQ7hDTPLg6UX1BuP0B4/OYuKlWSCe6LmZfTsyKAARo1idHLSNm1P0KcWF7gVA u7wGM9GxvXYRcXgpNJvPg6cHpexuU9Sw2jBQKLQ8RG4v8OIX+snJSr3IsH6cE2QEExsp XkdA== 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:dkim-signature; bh=b5H8RtrC0Gc1uC0P9BdPRFehSMvKPE2eLTGWQg50TOo=; b=Z04VriIO6SlOf60HkXC5BF/3XmvYD3Wuq/B/lRpJsj3WAOXznVSpgBMA2w7iuqvAlp my563pGgTBhoZXbCnRCQfDaEnuLv/IlbnuBJsLx4n6M1dQBiZMoUhvfbfLehRgqZ+fMc Xfu/Gms/miYFKNJaRakfU0AMmhSN3bd5e1K8fqUIG1tUX46zRY42LOJJoea7PdV4YEvf 9NwtggsSlg7H02Q+TW0jhrnGMNQSHoP9SMQxBeW+FmuSJM3HDMAiZsho97y5ag8bc9VK fwiS6QO6kSXu7znK1NuHiuwlsM9sVffn3vQco4G5ZB3LkL9ReVmugdEF28lTZS7LN3vM YjMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VRfzqrCH; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si11029868plo.328.2019.06.24.14.45.37; Mon, 24 Jun 2019 14:45:53 -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=@chromium.org header.s=google header.b=VRfzqrCH; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729565AbfFXSyN (ORCPT + 99 others); Mon, 24 Jun 2019 14:54:13 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:32858 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbfFXSyM (ORCPT ); Mon, 24 Jun 2019 14:54:12 -0400 Received: by mail-pf1-f194.google.com with SMTP id x15so8062402pfq.0 for ; Mon, 24 Jun 2019 11:54:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=b5H8RtrC0Gc1uC0P9BdPRFehSMvKPE2eLTGWQg50TOo=; b=VRfzqrCH2jFEWWjjlDlGd02Xe8ZQsb0AVWLLZIFUZPGPtVv9VLFJ+zz8bC8OUOaOUx Oqcae7vUarDSmjpET3Ghcc9JlKP5Vf1bg21hv25Rq8NQJgF9ue1AbbSuNNetGP6GzyMs qfJaOC3Qph/i6rx21qTIWZqCKCXB8QBPi1VFQ= 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:in-reply-to:user-agent; bh=b5H8RtrC0Gc1uC0P9BdPRFehSMvKPE2eLTGWQg50TOo=; b=Hv/oDoGF31l2zpCIwhQ/MHtXFMcy6+8KjbBycTueaCF0qyIeuky8/1vuiGXWytSTTk nuiWp5dk4l/wWwKrjE+Or/PfFSd/5Wig6IgBI/W7DH4OhJ+Ppt8QSdYK1Zu8K1nPbEqG u5Gfh+so39jypgVbphP0EctPm0Wh0WVW/Xfgd5LTJy6nrkrDivdKtSj/NpNLCq8HOhE+ dsaAB2JUUM9KvXLw9/5iLxb6C2Met1klIAldWab2v8FWC2DOvC+/3sOfrH3MPczlQmvy jIN4Wz5Oyyp0EoW9UN8jGb8nQQPHhtz9aLWe3Ec/IyiDOU/Wft9sPpqdBJ5wyW0Aq0Ij PDIg== X-Gm-Message-State: APjAAAXVZsp+RYDFZ1151wdyW9hp0Sl+oEXvGAuCCthw/tQcae9bMGZn ZOaHzjf0dT+nYWvtY2RBfqwhBw== X-Received: by 2002:a17:90a:8a0b:: with SMTP id w11mr26442545pjn.125.1561402452192; Mon, 24 Jun 2019 11:54:12 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id l7sm14434756pfl.9.2019.06.24.11.54.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2019 11:54:11 -0700 (PDT) Date: Mon, 24 Jun 2019 11:54:08 -0700 From: Matthias Kaehlcke To: Daniel Thompson 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, Enric Balletbo i Serra , Douglas Anderson , Brian Norris , Pavel Machek , Jacek Anaszewski Subject: Re: [PATCH 4/4] backlight: pwm_bl: Set scale type for brightness curves specified in the DT Message-ID: <20190624185408.GB137143@google.com> References: <20190613194326.180889-1-mka@chromium.org> <20190613194326.180889-5-mka@chromium.org> <9ea1bb40-95a6-7a67-a8a6-ecc77a70e547@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <9ea1bb40-95a6-7a67-a8a6-ecc77a70e547@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, On Fri, Jun 21, 2019 at 02:10:19PM +0100, Daniel Thompson wrote: > On 13/06/2019 20:43, Matthias Kaehlcke wrote: > > Check if a brightness curve specified in the device tree is linear or > > not and set the corresponding property accordingly. This makes the > > scale type available to userspace via the 'scale' sysfs attribute. > > > > To determine if a curve is linear it is compared to a interpolated linear > > curve between min and max brightness. The curve is considered linear if > > no value deviates more than +/-5% of ${brightness_range} from their > > interpolated value. > > > > Signed-off-by: Matthias Kaehlcke > > --- > > drivers/video/backlight/pwm_bl.c | 25 +++++++++++++++++++++++++ > > 1 file changed, 25 insertions(+) > > > > diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c > > index f067fe7aa35d..912407b6d67f 100644 > > --- a/drivers/video/backlight/pwm_bl.c > > +++ b/drivers/video/backlight/pwm_bl.c > > @@ -404,6 +404,26 @@ int pwm_backlight_brightness_default(struct device *dev, > > } > > #endif > > +static bool pwm_backlight_is_linear(struct platform_pwm_backlight_data *data) > > +{ > > + unsigned int nlevels = data->max_brightness + 1; > > + unsigned int min_val = data->levels[0]; > > + unsigned int max_val = data->levels[nlevels - 1]; > > + unsigned int slope = (100 * (max_val - min_val)) / nlevels; > > Why 100 (rather than a power of 2)? I guess it came from the decimal part of my brain, I can change it to 128 ;-) > It would also be good to have a comment here saying what the maximum > quantization error is. Doesn't have to be over complex just mentioning > something like the following (assuming you agree that its true ;-) ): > > Multiplying by XXX means that even in pathalogical cases such as > (max_val - min_val) == nlevels then the error at max_val is less than > 1%. Sounds good, thanks for the suggestion! > With a suitable comment in the fixed point code: > Acked-by: Daniel Thompson Thanks