Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5206802ybi; Tue, 11 Jun 2019 21:46:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJuAgrcbJ3cPVvFY8e5ShZ/T8GwYLDqK/zKkmkOKcY/ab2JWZFhTpQVGp58FVAf9B+HRla X-Received: by 2002:a17:90a:8d0c:: with SMTP id c12mr14779830pjo.140.1560314765296; Tue, 11 Jun 2019 21:46:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560314765; cv=none; d=google.com; s=arc-20160816; b=XOfMpyX73wpSadULBut5ckBpYDPk5bo1f6XOPKWt8BqWAL2CVJZpfcWNn8L5MJt1AF IPsecxEsxGn2lW2JlpM6yJhdpbK5MExuvlxZUHkqMHXe7KRS9Y5am62ikkS8ium7K8Ew gpy3VGyYpr/sFNFfZ1S2bRCbnNiAKFG5+xc70bv2bBsb5f94gLHTZkvTRKpnCCWpd9Tw 3OJEatC+XgobC2lDvt+AZ6SDz+jCF7R+Pzpy0wpqSkdgQSgH2tD5hDcoBTwkRhkR5IDi l8sRPnU89u+oRvIrFI2jPk30ta86dxTnCLbCfH+sGNSDBcBJ+Z901ed37s1y46seC6mJ TyYA== 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=STdR09JTplMSpZu8BTmSobDKkVojc1fyDlFwggPK8Uk=; b=ba9DiICBfNe7nIfBkqRL3+dmsrzRocpSD+qG8EXuYBpzz/fspWKVo03hk+3uQ9VSwz 7LBkLEsCkM4JHfjZUq5qI7g4UVPT7CuZB0LIK7pCpJTRVVXxKvAggF2XJIk4md0hI6i7 qiBBaKDPUukVwW5qE8pvSwxNAS0lVqchYDyZHeP3pbsQKK8ikTXOvYNwBwkMb18Pt5Cf VWH4ED/2RY9lcD5TWKfur7sHCj5U9wmoFP8X6hiqXP/RSE90j2JWWsETns8u6lCgB1KV Pte9wIWKRCwO11aqLNhHF50lg0IIFr3M35EonmYiB3zuoAV8dkx4VxCULMgib2Fst4hz ZAHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MR5Ygywl; 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 h9si14097956pgs.397.2019.06.11.21.45.50; Tue, 11 Jun 2019 21:46:05 -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=MR5Ygywl; 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 S2407794AbfFKV7C (ORCPT + 99 others); Tue, 11 Jun 2019 17:59:02 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38642 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407784AbfFKV7C (ORCPT ); Tue, 11 Jun 2019 17:59:02 -0400 Received: by mail-pf1-f195.google.com with SMTP id a186so8275285pfa.5 for ; Tue, 11 Jun 2019 14:59:01 -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=STdR09JTplMSpZu8BTmSobDKkVojc1fyDlFwggPK8Uk=; b=MR5Ygywl093uFDulviOIYvyfuuIg7LVcRCENxaahnbQl3TWTuyLFxmaN/CsCFje4ZW lMOJpV5vlQByThnbSdpFW5pDrScHKNyi5Uayf6G9Qo/JGt6L3QsMwiyIsPBFjywBcNsB KOnwwUTJm+TTD2GsLYgy//6zZNVAYMjKqx244= 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=STdR09JTplMSpZu8BTmSobDKkVojc1fyDlFwggPK8Uk=; b=o1du3beUFnePbc+6KqzyN3YZs8yReZwWjd7UGdbWPQG9SrjucfyZFLlgMY3s3s1A4T om17kusq5hrZINAeayuyRc30h4PKhbbih9zvUy28ZZm9XaStqXBhuHr7hK8/NQVHXQuD x5OuKS3VF5n+juFran7CfI6tryaz7DUrLDMpo+twP7rhSXVpFsr62zxvEpkot2ffkDCN Zd7pLyOIhx5BqRs0iz+ID9IqL7CL7D6RhGqbdDS+REVUeWF/GqsbXeUa2rDNV5VvoIMP WkrWcrdFug/XbhBEfvbdG0Q1hHLGboqW9PzU9ZYRTtPzrByUeJayE3nV0stC4qbuAphq bQaw== X-Gm-Message-State: APjAAAVb/5hT6aodXaHGxY4IfvyvCZ1A97sDJCgvkYVh4ddBy3VfEcW2 nKXcATaWARfwvCJp9GyHXST2RQ== X-Received: by 2002:a17:90b:d8a:: with SMTP id bg10mr29155223pjb.92.1560290341471; Tue, 11 Jun 2019 14:59:01 -0700 (PDT) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id m2sm15311952pgq.48.2019.06.11.14.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 14:59:00 -0700 (PDT) Date: Tue, 11 Jun 2019 14:58:59 -0700 From: Matthias Kaehlcke To: Pavel Machek Cc: Lee Jones , Daniel Thompson , Jingoo Han , Jacek Anaszewski , Rob Herring , Mark Rutland , Thierry Reding , Bartlomiej Zolnierkiewicz , Enric Balletbo i Serra , dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-fbdev@vger.kernel.org, Douglas Anderson , Brian Norris Subject: Re: [PATCH 2/2] backlight: pwm_bl: Get number of brightness levels for CIE 1931 from the device tree Message-ID: <20190611215859.GF137143@google.com> References: <20190610233739.29477-1-mka@chromium.org> <20190610233739.29477-2-mka@chromium.org> <20190611101843.GD7526@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190611101843.GD7526@amd> 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 Pavel, On Tue, Jun 11, 2019 at 12:18:43PM +0200, Pavel Machek wrote: > On Mon 2019-06-10 16:37:39, Matthias Kaehlcke wrote: > > Commit 88ba95bedb79 ("backlight: pwm_bl: Compute brightness of LED > > linearly to human eye") uses pwm_period / hweight32(pwm_period) as > > as heuristic to determine the number of brightness levels when the DT > > doesn't provide a brightness level table. This heuristic is broken > > and can result in excessively large brightness tables. > > > > Instead of using the heuristic try to retrieve the number of > > brightness levels from the device tree (property 'max-brightness' > > + 1). If the value is not specified use a default of 256 levels. > > > > Fixes: 88ba95bedb79 ("backlight: pwm_bl: Compute brightness of LED linearly to human eye") > > I don't think this one is suitable for stable. I'm pretty sure the > heuristics works well for many boards, and you just replaced it with > another heuristics ("256"). whether the patch is suitable for stable/upstream is certainly debatable, in any case I'd argue the current heuristic is bogus and works by accident or at a cost: nlevels = period / hweight(period) w/ period = 131071 ns (0x1FFFF) nlevels = 131071 / 17 = 7710 w/ period = 131072 ns (0x20000) nlevels = 131072 / 1 = 131072 and some PWMs use significantly higher periods like 1 ms or 10 ms.