Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4346114ybi; Tue, 11 Jun 2019 05:15:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2NMcuB5c8z/qUmfcbl2ga5IaH7eEiF+cH10Yyj4xsmMf3yezLvRkUQrspl3v2WyCs/oZ6 X-Received: by 2002:a17:902:e282:: with SMTP id cf2mr52979941plb.301.1560255346654; Tue, 11 Jun 2019 05:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560255346; cv=none; d=google.com; s=arc-20160816; b=Hz3kmMeOUzc3hrD2Qqmn/k2eP8yxB+b+oB6aWrccpvT7qclyfR/nE0bSyUwhLnaXyU IazgJpaEXjJQMCW6AGgcpheeL5T7N8knXQgPjGysvqGZqs9EFy7k4guNg7rgudK1ZaBk veCuJRuO9cVw1QJDU3tiimyMRBBU2k7hIIuSp6RTtuMrqyfXceDrndeiCZvlEsHWqNnz P2gUPNOKEfckaiLcy9wI4oprMP4l6N6lPPkPgPsjUjqKh/WPQEmk0PV5CbNqWNJ7Tqcw g1NZFdMHjJ3fRTqaxFygLYkktSQlidF2PPYJWg+svqpzKNmi3tKBGfudZPG62d84NWak Lx0Q== 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=Wke+zJP5dCswbWV/u/esh55NqtZ1D4txLFIezrnYzvc=; b=T3jT4EN3Jj0FPljpJFRZzJO5L8WKykR/b2Hchov3kkVviS4voJRO6IxYd1qmPhysmL TJQNjAJEo9+4qZ2TIeIbh6MVkJb4O9FlhVEBmq30vFKH6patjBt+9lxaydDFImdxfZnD XO2O1sw/KrjW0emWhegDRtlGIiRI6nMDRB/9h+clMn2LZkypiVcHPfzjCVBMw73JzFv1 GvX9UR0hOiZiRlNEAfjBeuiqX2L9Ko88h2TrPwvkN0y2nkhcVsoaoKB/mo7OYjf2RuIX U/bRw1F+mtxWO79aMC3S5u+NJ66CWy/SsRyaPrgp9INUehJS/27ANI7vUeXFcKOpnDkd p01Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PxrxDslA; 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 i14si12667118pgh.437.2019.06.11.05.15.30; Tue, 11 Jun 2019 05:15:46 -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=PxrxDslA; 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 S1728901AbfFKKtR (ORCPT + 99 others); Tue, 11 Jun 2019 06:49:17 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36585 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728827AbfFKKtR (ORCPT ); Tue, 11 Jun 2019 06:49:17 -0400 Received: by mail-wm1-f67.google.com with SMTP id u8so2384069wmm.1 for ; Tue, 11 Jun 2019 03:49:16 -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:in-reply-to:user-agent; bh=Wke+zJP5dCswbWV/u/esh55NqtZ1D4txLFIezrnYzvc=; b=PxrxDslAIz/rFntDtsnZky+pHhSb0tuqmviueUjKiknFy3QJVo2pNovpjuqynjBoGd qtC0oufRU8IFFy4PaVjl3NH0rTHHabLnMJaUsqLuDXlAymNfwNtQPp3ihtWZHKluO7Xy z9IfrFxDUpcndgECSycZq4t6Cy+HMu5B6Y/ptdeljIhskZk6C2LaFXn63jevymcITGtn H0QyEVT1kKoirxc+XNQ1cZS21cx3Cgzfa5rPqgn/ZxFP7csu2xNhNH2yUGoQavy2XQBu 51QgvqpImw7EcwhPnRjvcJfA9xQkdPDiHY4WV+QUFC6GLuLPxqWrNlDE9XUAu1/W8PMc uDiA== 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=Wke+zJP5dCswbWV/u/esh55NqtZ1D4txLFIezrnYzvc=; b=WRSktaXr0eDLRdxyDtBZCovl8hKPHYNEdTP/wMoyyHCUMyleWXPQmhyClJkOsx2wJn +udX90rf1fSlqv8FnZJ2hmXb7NvwFRZ4srAc7qqbh+aHo4dFIo9gU83z+YxKRMJHfTZs K8lJ2iKeH7WZClPOACgKAJeEJmbcdwISCB4GyX8z+VVE5A6QxraFXRfdRYlPr8JLj+wM rClwUJtHNay5grGZ6LeRbrUWg1Afu+Se6ZK8UDg4AW0bNPPidpjN5j6yZommQJH7X9hX wiiUo9AL80/KrypDkViZ8WHKy94bWX8CeDWypXGAUJSuZfAB8/GWAq/FMCNuIhtF6xO5 yUbg== X-Gm-Message-State: APjAAAXmCsQQ2CX1+2g5Y1A6XjDPz6KEyyWaohzOtuOUSaoK+lWyw3ut klX57LEla2xcAWsPzzeCAbcpZg== X-Received: by 2002:a1c:a7c6:: with SMTP id q189mr17676575wme.146.1560250156070; Tue, 11 Jun 2019 03:49:16 -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 s9sm2336429wmc.11.2019.06.11.03.49.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 11 Jun 2019 03:49:15 -0700 (PDT) Date: Tue, 11 Jun 2019 11:49:13 +0100 From: Daniel Thompson To: Matthias Kaehlcke Cc: Pavel Machek , Enric Balletbo i Serra , 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: <20190611104913.egsbwcedshjdy3m5@holly.lan> References: <20180208113032.27810-1-enric.balletbo@collabora.com> <20180208113032.27810-4-enric.balletbo@collabora.com> <20190607220947.GR40515@google.com> <20190608210226.GB2359@xo-6d-61-c0.localdomain> <20190610205233.GB137143@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190610205233.GB137143@google.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 10, 2019 at 01:52:33PM -0700, Matthias Kaehlcke wrote: > Hi Pavel, > > On Sat, Jun 08, 2019 at 11:02:26PM +0200, Pavel Machek wrote: > > 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. > > I realized that the brightness level display on Chrome OS (= my test > device) is non-linear, and it isn't actually the lower 50% of levels > that is near 0 brightness, but 'only' about 20%. > > > But yes, specifying if brightness is linear or exponential would be quite > > useful. > > Agreed, this could help userspace with displaying a reasonable > brightness level. This is a long standing flaw in the backlight interfaces. AFAIK generic userspaces end up with a (flawed) heuristic. Basically devices with a narrow range of choices can be assumed to be logarithmic (since anything linear with a narrow range of choices is junk anyway and the slider will never feel right). On the other side though we can only really make a guess. Systems are coming along that allow us to animate the change of brightness (part of the reason for interpolated tables is to permit smooth animation rather than because the user explicitly wants to set the brightness to exactly 1117). These systems are often logarithmic but with a wide range of values. Daniel.