Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7051186ybi; Thu, 13 Jun 2019 08:45:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQXKkOBEkjVFGmo1kL1dHELsN8BUnGGVW2k8ZSvCE7+CA7F3p0dvVMzvspH82YUXkV+cgm X-Received: by 2002:a17:902:760f:: with SMTP id k15mr64052960pll.125.1560440713209; Thu, 13 Jun 2019 08:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560440713; cv=none; d=google.com; s=arc-20160816; b=kYbbKK5tDNHQ7Sdmpq2vlVyB6yC2ux52okXUxWvudRKktjkpg3sGmCgGHCEkaBghsR xairwFJubx0e7Xb9wX6ddZ+p6G99y/goPhnGQo7o7kbGbGr6wWqfO6Qi6E0z4zPoUgSs NUEista1bAx3zUqXEShqh6zmotqWDpCiyseKs1knStUbCY7prT4jHMb8BdC75OKUK8GU IoaD0mntdXHLNi74RSFwLhmvGNBSy2Io4GCjf1baGHK262/ckMAMGuO2EEzKwA7UiY2N I8utWsvPoNGb6BCOQvx8htiFoIIEOzGkUguP055+9wov8VfeeYE39cJ5ndmjTYrJ03er oR9w== 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=5o6Xk9ScYRxy+DZ0+69hUl5hUqdW0wuATddsUALu0XI=; b=wvw3Ge1OCusQpR0/YLfMg1KIQytBBLq7xhPXfLM2bdr4hQLHoatDMAb853EOnLm64U QKOs9Nj13eLPQDP8kYGICEAYnm7pUnYsgkk5TXIPv9DoduhN7Pj7j/OwE5wt3lqu3tqU GFYC28Kw9pvU+YfYtkL+6Xd7Whf+YL88c8VAf7/7InZfNmB2roHyT/5uB3k/mUzI78pB 14bD2Tf4BJoXv64FQ1iTjT3aqtw9rITnODWd8Q3joPwBrtYSfaNH1jwv4RuLy9SUkI9E n7pYztlAxpkkkoa7BMykJM9TWNcNj/q1D/6bKjmw4/45Vx2egTnXRtV0hMf2dweywTpO /NNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YrwQDeew; 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 a10si3586463pff.277.2019.06.13.08.44.58; Thu, 13 Jun 2019 08:45:13 -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=YrwQDeew; 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 S1732964AbfFMPoL (ORCPT + 99 others); Thu, 13 Jun 2019 11:44:11 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:35057 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732447AbfFMPoA (ORCPT ); Thu, 13 Jun 2019 11:44:00 -0400 Received: by mail-pl1-f193.google.com with SMTP id p1so8328457plo.2 for ; Thu, 13 Jun 2019 08:44:00 -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=5o6Xk9ScYRxy+DZ0+69hUl5hUqdW0wuATddsUALu0XI=; b=YrwQDeew1cdkq1HePhmUGExkzD7Hw0Tl9YIAShml3dVLN1XHu+g9LfJ8uAgS7R5RWE vVD76Aa60Fl6EQMMI+h5azGxOGo1dv54iB0+mySBPTr0F49K8qblZ6aupnQqoMwUQR64 MMj6txi1/IGCtz2lKZFK2F0nwMFKLYBfm/IC4= 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=5o6Xk9ScYRxy+DZ0+69hUl5hUqdW0wuATddsUALu0XI=; b=VN/710DPqVRGI6C9urUmT2rW7NjPqQtY2kSMRbm429uXMqD9fgzs23f2YX7Nd+KG1A ZwxTwHiaYpozhLteKc30ubugshESr7GAsz+5zZjJxXFJ/hilO8x2ncePY+YepFk/dluE 0MtIXCio3yGjNvbNo/6JlvzUboyMXgfbj8pPmE46k/eJ33UAS0iy7jariGv2YPq119JR Inkf1e9CkF2bK4yPg5mPkhDpbRZBBGes8zHeMKnM4W7jyP1gAcTK3hkCkULcJ4+vhjvl gPzvCU7CS4D/3xUOzyKXjKZstRGO05ReIKSsalI9VPn2GpzuIGV7WcMfOstRUt9nWdVq GLqg== X-Gm-Message-State: APjAAAVpPs5IqjzOE54mg78NsCdxXzzXyTepXglckhK7jhCcCgLS+eWL aES2v0SIzkvu8o5FMTRYzG5qmA== X-Received: by 2002:a17:902:24d:: with SMTP id 71mr90950845plc.166.1560440640131; Thu, 13 Jun 2019 08:44:00 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id w66sm83713pfb.47.2019.06.13.08.43.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 08:43:59 -0700 (PDT) Date: Thu, 13 Jun 2019 08:43:57 -0700 From: Matthias Kaehlcke To: Enric Balletbo i Serra Cc: Thierry Reding , Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Douglas Anderson , Brian Norris , Pavel Machek , Jacek Anaszewski Subject: Re: [PATCH] backlight: pwm_bl: Fix heuristic to determine number of brightness levels Message-ID: <20190613154357.GN137143@google.com> References: <20190612180003.161966-1-mka@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 On Thu, Jun 13, 2019 at 11:14:55AM +0200, Enric Balletbo i Serra wrote: > Hi Matthias, > > On 12/6/19 20:00, Matthias Kaehlcke wrote: > > With commit 88ba95bedb79 ("backlight: pwm_bl: Compute brightness of > > LED linearly to human eye") the number of set bits (aka hweight()) > > in the PWM period is used in the heuristic to determine the number > > of brightness levels, when the brightness table isn't specified in > > the DT. The number of set bits doesn't provide a reliable clue about > > the length of the period, instead change the heuristic to: > > > > nlevels = period / fls(period) > > > > Also limit the maximum number of brightness levels to 4096 to avoid > > excessively large tables. > > > > With this the number of levels increases monotonically with the PWM > > period, until the maximum of 4096 levels is reached: > > > > period (ns) # levels > > > > 100 16 > > 500 62 > > 1000 111 > > 5000 416 > > 10000 769 > > 50000 3333 > > 100000 4096 > > > > Fixes: 88ba95bedb79 ("backlight: pwm_bl: Compute brightness of LED linearly to human eye") > > Signed-off-by: Matthias Kaehlcke > > Tested on Samsung Chromebook Plus (16-bit pwm) > > Tested-by: Enric Balletbo i Serra Thanks!