From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3268C43334 for ; Thu, 23 Jun 2022 13:43:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10CBE112B96; Thu, 23 Jun 2022 13:43:23 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DCB5112B96 for ; Thu, 23 Jun 2022 13:43:21 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id g18so2212762wrb.10 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=g8OmdSnkqy9qsKz78Hl8aPEJudsGec9sEdW958AsNTgYBNFWY6uyWeCeT8DDemlRAm bSVT/AwXeqtQKZ/GB9TPgISEC3+4cjJqOs17qKNf/6J/Am0+fRex0oyAAksDnYkjb3TF iMOcYrvRfmgFxwpJYeG+MSYc/NhHcDmrz1jhaELwW4ZP0g0/n4bj5IDKojYR4NjU4cnD 4Qytp1TryoD5u9QXCBrPwL4pD1Adnm6QHXw61lxlXCCvMTHLM7q+oyiJhAGxT3t8PWSx He+Ytf3ebOd93OcqVbMpy3VipNh7TtJlMHwv4RMfWEnysJ+wdi2OiBJn+zKjcLiXNh4h KWXA== X-Gm-Message-State: AJIora96a5CCiVului6zaPVflii/aR3/9+XdPuC+ojDsl5W7hFlWjWnj 5PGNOqSluyRVcGLxVS7ypBin4Q== X-Google-Smtp-Source: AGRyM1vjF4PN7klzy0olb9rrzdVMRPfVzufgs3EKRfc33dNmi33WjI/0td30uX34aWiNQWi+iEa1Yg== 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 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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, alice_chen@richtek.com, linux-iio@vger.kernel.org, dri-devel@lists.freedesktop.org, lgirdwood@gmail.com, cy_huang@richtek.com, pavel@ucw.cz, lee.jones@linaro.org, linux-leds@vger.kernel.org, deller@gmx.de, robh+dt@kernel.org, chunfeng.yun@mediatek.com, linux@roeck-us.net, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, szunichen@gmail.com, broonie@kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, jingoohan1@gmail.com, linux-usb@vger.kernel.org, sre@kernel.org, linux-kernel@vger.kernel.org, chiaen_wu@richtek.com, gregkh@linuxfoundation.org, jic23@kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0D97C433EF for ; Thu, 23 Jun 2022 13:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231856AbiFWNn3 (ORCPT ); Thu, 23 Jun 2022 09:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbiFWNn1 (ORCPT ); Thu, 23 Jun 2022 09:43:27 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A3FB20BD6 for ; Thu, 23 Jun 2022 06:43:21 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id e10so1123396wra.11 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=q8cQ6DU7PY2uS1oftAGF9aXFbAIVRCOgOq/6A7AvpLCwcTmlYSAv0WIzMvegn9R8cn 1D6Czgd3NpzzoH+ghNFpzpvBVMVuQ3+SbWRLYa5JXF2DWreNcR2mMpMBwnuj0NP03fgQ 0tpf2ytqSiJJMwqEOdNYrrGkHkQvYBxgO9xVfeGGhumuwWzq9M82zO6hYrssiVVZgKpI wWkQx+uY64Tn7BMUgmx+yJ7rsMf0FUIWc6oB3x1j8GRs+rs8+PNS+SU/dPCmcppjiO+H rRZIMsOetldZ8XZ32lPWy1TWIH1OOHTNwWTkN0iMhu4z5YMZaNJe9f8MsoBU9QLpuouW 1CMg== X-Gm-Message-State: AJIora/SxA/wJKvL1HZQwQh5CpKffNGXDBjzOs/XUUuZFgzZBBrLMg6t Fy2kno7aXQ0LK5iXhlliS5ikdw== X-Google-Smtp-Source: AGRyM1vjF4PN7klzy0olb9rrzdVMRPfVzufgs3EKRfc33dNmi33WjI/0td30uX34aWiNQWi+iEa1Yg== 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> Precedence: bulk List-ID: X-Mailing-List: linux-leds@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. > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15E79C433EF for ; Thu, 23 Jun 2022 13:44:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IO6eOD1bBpGn/Yn5Y9OB4LxU03kkWOuk2U8IhWMWMvs=; b=28tLZAfA2gaNKA c5aYmZvIhqPh9Y0LPF41X3J3rllz+h3Zd5nFaQ1PBoVO12RQLjYZinhF6+Pjofj6CYavYwPvg/4TD 3P42K6UgLHLNv9uV3kUe9d+dvTyO0Ytwa+c5luayCDQ005jhmLRunXyKPJDID3efcb/DgJ12mPvuZ XIDp+3lla8b8B7hQ/6294QxondJzTqAM4NxXNA1j48Ho7ZPCzoNgIHX9VfS3VqWn8oZsVIN4qfyoT 4urJ+fSD1hv/MSmTR6E1h0+pa7R3lIzbY/7iu6UxDzlFxNfn1osK3unLXTWkPfUsAq9OAS3MUSpcz 4zBU9Egor6wUOpHb044A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4N7H-00FOfx-IL; Thu, 23 Jun 2022 13:43:27 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4N7F-00FOer-5Z for linux-arm-kernel@lists.infradead.org; Thu, 23 Jun 2022 13:43:26 +0000 Received: by mail-wr1-x430.google.com with SMTP id r20so7606721wra.1 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=5WxA1RCfwKM7lxV3somG1u1EujVx/CrZMQdRF13M5YPCurrt4OksYhHioBVep2WQxD kanL47CWfcQ5P5T6qLWR9W/guMI2Bf+MSEiZNtTrqzqVal/8Fi5R6SFmDfWJd/LQe6CE LtOGtv8tBMigOvj4tbnY9GN+TzAINItCMFDSIrBwry24wPlWJC0mJ08WF8FIxy1X4aUM tIWxg4CtVCcgisV2xfIWTqbLZOLwfuVHlMg3DqNMqzQqytkNTG5j3nG42d0+w/KFJwzA ptISOOEMDaNO6dng+J6iVublnofDElRwjRHEUoEB+ulnOdczuuZXUpj6qy+yPk+ZTGwP sc1g== X-Gm-Message-State: AJIora975JAiFGxoF7TfQBXq3hBoRMTx3wr+i2uznYMxJK+el36NWYvS uzx+u8C2E42+mvwDIBa82pNqhQ== X-Google-Smtp-Source: AGRyM1vjF4PN7klzy0olb9rrzdVMRPfVzufgs3EKRfc33dNmi33WjI/0td30uX34aWiNQWi+iEa1Yg== 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-Disposition: inline In-Reply-To: <20220623115631.22209-15-peterwu.pub@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220623_064325_249924_92DAAA8E X-CRM114-Status: GOOD ( 18.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel