Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1612024ybi; Sat, 8 Jun 2019 14:04:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/eJn2xE1bJy5PAAT2mcGNrgbHnBsZIawZ45XGC62d54BAXkx9vgmC1fobiElcjez/t0iU X-Received: by 2002:a17:902:b497:: with SMTP id y23mr38436444plr.309.1560027851911; Sat, 08 Jun 2019 14:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560027851; cv=none; d=google.com; s=arc-20160816; b=R9+Owc/M/CrBvAZmqpZ06OwfX34nLgAtb1QAO+hWIdEiQakO7TKhRFHSNA9soTMwPH bTAvx9E5PuquIRGBlTFbqh5C6x3546XSguNI7om0DU1j75JBRdYIZ4FnhTAw9gMkTHLx IR3m8X1tFjXwkUXUwHHbH4fQ60AfaxydcxhDAzQ7wWs6ILur2gRAZDOwyBCALYCdMB18 TJkOekQvK5ou8Ge1BinSQTslcq/Ogs07ndrD3gOefIqOfcxk+hjhBzWyaotOfV6motsh 2CZP1cmEU/Jq7JI+AdLQ0Iujlv+TprT3XmSPMGAvEF2i+ry+tob0tDh0dqimsflL1sCF EwYg== 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; bh=eB7+Cop8JkU+fTEZ94R9rgY7S8Cyb1vOSVZC1LyudJQ=; b=Vl9qHjbQsgY19BWmGerPLTO7zHdMsGMfVbizSJcdbYWF2eOOvnLr1I4jBWUpMiSCZZ FEo/JK6lxh5oIwilhTNYnvB9Uzt8aG5I1ya+TCL0IrelTYXsmg2tMuLcl59TwF/VFyEp LBUAh3j+9aNCuPqFm81y5uaXuDb6Iv5YXEWU6HCr+pijzUzUoyoqIpV5oh9DL96bb2oe nb4Y4RBLhlK5WxIRzNGzPYAf2CR7u1Do4oR3Owunx4AcKLJWUa6fx4umQFfBtHfFpcpA 6XB/HccG/2R1SEwN1cB+hUKQoK7l6Nf/orbPuXTx0pwqhPEW/31yn9/EE0G7ldttcixd uBBw== 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 p13si5387292plo.33.2019.06.08.14.03.52; Sat, 08 Jun 2019 14:04:11 -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; 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 S1727522AbfFHVCk (ORCPT + 99 others); Sat, 8 Jun 2019 17:02:40 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:38457 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727372AbfFHVCk (ORCPT ); Sat, 8 Jun 2019 17:02:40 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 7551880257; Sat, 8 Jun 2019 23:02:27 +0200 (CEST) Date: Sat, 8 Jun 2019 23:02:26 +0200 From: Pavel Machek To: Matthias Kaehlcke Cc: Enric Balletbo i Serra , Daniel Thompson , Doug Anderson , Rob Herring , Jingoo Han , Richard Purdie , Jacek Anaszewski , Brian Norris , Guenter Roeck , Lee Jones , Alexandru Stan , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH v3 3/4] backlight: pwm_bl: compute brightness of LED linearly to human eye. Message-ID: <20190608210226.GB2359@xo-6d-61-c0.localdomain> References: <20180208113032.27810-1-enric.balletbo@collabora.com> <20180208113032.27810-4-enric.balletbo@collabora.com> <20190607220947.GR40515@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190607220947.GR40515@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! > > + * Note that this method is based on empirical testing on different > > + * devices with PWM of 8 and 16 bits of resolution. > > + */ > > + n = period; > > + while (n) { > > + counter += n % 2; > > + n >>= 1; > > + } > > I don't quite follow the heuristics above. Are you sure the number of > PWM bits can be infered from the period? What if the period value (in > ns) doesn't directly correspond to a register value? And even if it > did, counting the number of set bits (the above loops is a > re-implementation of ffs()) doesn't really result in the dividers > mentioned in the comment. E.g. a period of 32768 ns (0x8000) results > in a divider of 1, i.e. 32768 brighness levels. > > On veyron minnie the period is 1000000 ns, which results in 142858 > levels (1000000 / 7)! > > Not sure if there is a clean solution using heuristics, a DT property > specifying the number of levels could be an alternative. This could > also be useful to limit the number of (mostly) redundant levels, even > the intended max of 4096 seems pretty high. > > Another (not directly related) observation is that on minnie the > actual brightness at a nominal 50% is close to 0 (duty cycle ~3%). I > haven't tested with other devices, but I wonder if it would make > sense to have an option to drop the bottom N% of levels, since the > near 0 brightness in the lower 50% probably isn't very useful in most > use cases, but maybe it looks different on other devices. Eye percieves logarithm(duty cycle), mostly, and I find very low brightness levels quite useful when trying to use machine in dark room. But yes, specifying if brightness is linear or exponential would be quite useful. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html