Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5907638iog; Thu, 23 Jun 2022 07:39:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v6w/HLwv4iWjJU6/juYtjCsb+DRCtQvVnAnzpofP/IS6+h0AuCNr2v4tuvWMgOc1ILwOxT X-Received: by 2002:a17:906:2da:b0:712:14b:62da with SMTP id 26-20020a17090602da00b00712014b62damr8662450ejk.351.1655995168446; Thu, 23 Jun 2022 07:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655995168; cv=none; d=google.com; s=arc-20160816; b=env9od8FezrFjFuFsTwY90aXh6eNASGvaBjjrWU694ViilZV9SpwrcmBX5RExFVRwu IluzMuRyQ3q8wVZOFIAdfjd28SZ5LCLvJnkJm5eja05rL60+iGspL7p+b+h8vs9JFcKO m7CK58NL8I3MkA5mwKwOjSUSvZmRyfqe5SnyJb5neDRWuEtGEl1C5B1oN9oTwRUKJZLd SQHiZHKxtOyyCuMsnqNuU4fuya47PACvwKt67z4o6hOgbP54/7JWHniowXHLXgUxcUgx Je6yAIf8v4/+hNfafNxd6mFFXIUz65jwGZmLirJkFypUT5nS+Z9lNAuqcDdd0OnQMOyZ hzQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eRK+unsPW70xNn5MF8+19eCG7D3AK/lgynWxuPdsIyE=; b=m49HgxPzIdt2VefMa6A80X47+hPw/9X3zZwca5m9rQKkYuVpR50JgIQNFMF41c2LFQ H2LFgd/AWfPpgiZRsrJtwpvdNpbCNqhxw4CX6BgkawY8kt5lhx/FxBpkHeg2Lq6QpRad vGcjMy9Pg2xpDmmkaksefUxxZjzNDRvDp2lobZEsGK/eoD48XROVtUTaLM7/IWoxtC26 c1n7BE2Um2mWOh+gTpgDjRe1QiQzpxKoN/aLZJP1Li2N41CKqKrTj6voDn1Ew3vjM9vc WBveKGGDjpAxFi7buB1qh0JGetYtx3bkl2y+jbDwZN9o84LMJgtODk9ZRp8N1hu7jH3+ o3tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KC804tV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 29-20020a17090602dd00b006e86aac6b67si23146661ejk.351.2022.06.23.07.39.01; Thu, 23 Jun 2022 07:39:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KC804tV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231169AbiFWNnb (ORCPT + 99 others); Thu, 23 Jun 2022 09:43:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbiFWNn1 (ORCPT ); Thu, 23 Jun 2022 09:43:27 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 541B0240A8 for ; Thu, 23 Jun 2022 06:43:21 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id o16so28029825wra.4 for ; Thu, 23 Jun 2022 06:43:21 -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; bh=eRK+unsPW70xNn5MF8+19eCG7D3AK/lgynWxuPdsIyE=; b=KC804tV7q8m5lKxx02VfQNPyCFRxbLo+UN5MqQqk1P+QbuQa4VcB2DrqvkkpPc4wLh s8YD9o2Eiw8erHMZ6g3Ia7a0hyCPKQt3dQhrWjxY7MVQ+N+R6b5WlLXKQYsrlnRxHzog E2sf54tTcmTN6YbXT+A5UHQ5N/d1dBEzbXYSl58xn/DSXDKRHGikl18c1Dewu5+tmqAo JWR2R+BecqmGJdKOoqPajDcTtrvcsivMLPCP1TsgqwJCt60ewBhMWun7q+A0t7wb6Fa5 u7SPQBBJb5LqETPHZT7BjI6j+0AwxO054RkyMDT9jgCAOSDplPJobh2EkUOEu7PwvTVI nrzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eRK+unsPW70xNn5MF8+19eCG7D3AK/lgynWxuPdsIyE=; b=jSfS+pq46v9wsqz/mmPj+onveM/KUlCdQDvHJndth+0Q3S3EvUF/mnX2u5VIu9PDC0 piM8D8UVct0D3ik+uvApHgWBl/HUYXcPwnxnbopOZ5nLAJX/Ix4cgeMZmCXid+jhpT5H L0P86foVBBQJOvJGf3jRB3rWgaxhdPKoVZo4OqjpCCr+L/XRKwqEQRBfajXIUxrtX/HK UduOA5YvaWl0MMzHqyPqIkCzVM6QrsLz6XO39JGDbmk/SROBbGZs420UUcYhCvuufous ntYufvPZZQdwFwRZlCyjlrFRZSjrTpvKa8L2EI/7x1DLioS+g5q0EyT0TD+geNLI2t6i mOeA== X-Gm-Message-State: AJIora9cZWj1GQCBLJW984tE0xXurBFmts3RO/N/CY983pUt38nOvOMp mw/gcZgCeMqgwaoKudF/2aJwlA== X-Received: by 2002:a05:6000:10b:b0:21b:88ca:9abf with SMTP id o11-20020a056000010b00b0021b88ca9abfmr8191539wrx.694.1655991799771; Thu, 23 Jun 2022 06:43:19 -0700 (PDT) Received: from maple.lan (cpc141216-aztw34-2-0-cust174.18-1.cable.virginm.net. [80.7.220.175]) by smtp.gmail.com with ESMTPSA id p129-20020a1c2987000000b003974cb37a94sm3313906wmp.22.2022.06.23.06.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 06:43:18 -0700 (PDT) Date: Thu, 23 Jun 2022 14:43:16 +0100 From: Daniel Thompson To: ChiaEn Wu Cc: lee.jones@linaro.org, jingoohan1@gmail.com, pavel@ucw.cz, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, sre@kernel.org, chunfeng.yun@mediatek.com, gregkh@linuxfoundation.org, jic23@kernel.org, lars@metafoo.de, lgirdwood@gmail.com, broonie@kernel.org, linux@roeck-us.net, heikki.krogerus@linux.intel.com, deller@gmx.de, chiaen_wu@richtek.com, alice_chen@richtek.com, cy_huang@richtek.com, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-iio@vger.kernel.org, linux-fbdev@vger.kernel.org, szunichen@gmail.com Subject: Re: [PATCH v3 14/14] video: backlight: mt6370: Add Mediatek MT6370 support Message-ID: <20220623134316.rg3adyobz3hkgflt@maple.lan> References: <20220623115631.22209-1-peterwu.pub@gmail.com> <20220623115631.22209-15-peterwu.pub@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220623115631.22209-15-peterwu.pub@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 23, 2022 at 07:56:31PM +0800, ChiaEn Wu wrote: > From: ChiaEn Wu > > Add Mediatek MT6370 Backlight support. > > Signed-off-by: ChiaEn Wu > diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig > index a003e02..7cd823d 100644 > > +static int mt6370_init_backlight_properties(struct mt6370_priv *priv, > + struct backlight_properties *props) > +{ > + struct device *dev = priv->dev; > + u8 prop_val; > + u32 brightness, ovp_uV, ocp_uA; > + unsigned int mask, val; > + int ret; > + > + /* Vendor optional properties */ > + val = 0; > + if (device_property_read_bool(dev, "mediatek,bled-pwm-enable")) > + val |= MT6370_BL_PWM_EN_MASK; > + > + if (device_property_read_bool(dev, "mediatek,bled-pwm-hys-enable")) > + val |= MT6370_BL_PWM_HYS_EN_MASK; > + > + ret = device_property_read_u8(dev, > + "mediatek,bled-pwm-hys-input-th-steps", > + &prop_val); > + if (!ret) { > + prop_val = clamp_val(prop_val, > + MT6370_BL_PWM_HYS_TH_MIN_STEP, > + MT6370_BL_PWM_HYS_TH_MAX_STEP); > + /* > + * prop_val = 1 --> 1 steps --> 0x00 > + * prop_val = 2 ~ 4 --> 4 steps --> 0x01 > + * prop_val = 5 ~ 16 --> 16 steps --> 0x10 > + * prop_val = 17 ~ 64 --> 64 steps --> 0x11 ^^^^^ These numbers are binary, not hex, right? If so, the comments should be 0b00 to 0b03 . > + */ > + prop_val = (ilog2(roundup_pow_of_two(prop_val)) + 1) >> 1; > + val |= prop_val << (ffs(MT6370_BL_PWM_HYS_SEL_MASK) - 1); > + } > + > + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_PWM, > + val, val); > + if (ret) > + return ret; Overall, I like this approach! Easy to read and understand. > > +static int mt6370_bl_probe(struct platform_device *pdev) > +{ > + struct mt6370_priv *priv; > + struct backlight_properties props = { > + .type = BACKLIGHT_RAW, > + .scale = BACKLIGHT_SCALE_LINEAR, Sorry, I missed this before but the KConfig comment says that the backlight can support both linear and exponential curves. Is there a good reason to default to linear? Daniel. >