[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220623134316.rg3adyobz3hkgflt@maple.lan>
Date: Thu, 23 Jun 2022 14:43:16 +0100
From: Daniel Thompson <daniel.thompson@...aro.org>
To: ChiaEn Wu <peterwu.pub@...il.com>
Cc: lee.jones@...aro.org, jingoohan1@...il.com, pavel@....cz,
robh+dt@...nel.org, krzysztof.kozlowski+dt@...aro.org,
matthias.bgg@...il.com, sre@...nel.org, chunfeng.yun@...iatek.com,
gregkh@...uxfoundation.org, jic23@...nel.org, lars@...afoo.de,
lgirdwood@...il.com, broonie@...nel.org, linux@...ck-us.net,
heikki.krogerus@...ux.intel.com, deller@....de,
chiaen_wu@...htek.com, alice_chen@...htek.com,
cy_huang@...htek.com, dri-devel@...ts.freedesktop.org,
linux-leds@...r.kernel.org, devicetree@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org, linux-usb@...r.kernel.org,
linux-iio@...r.kernel.org, linux-fbdev@...r.kernel.org,
szunichen@...il.com
Subject: Re: [PATCH v3 14/14] video: backlight: mt6370: Add Mediatek MT6370
support
On Thu, Jun 23, 2022 at 07:56:31PM +0800, ChiaEn Wu wrote:
> From: ChiaEn Wu <chiaen_wu@...htek.com>
>
> Add Mediatek MT6370 Backlight support.
>
> Signed-off-by: ChiaEn Wu <chiaen_wu@...htek.com>
> diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
> index a003e02..7cd823d 100644
> <snip>
> +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.
> <snip>
> +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.
>
Powered by blists - more mailing lists