dri-devel Archive on lore.kernel.org
 help / color / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: dri-devel@lists.freedesktop.org,
	Jingoo Han <jingoohan1@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jernej Skrabec <jernej.skrabec@siol.net>,
	Jonas Karlman <jonas@kwiboo.se>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH v1 16/22] drm/bridge: parade-ps8622: Backlight update
Date: Sun, 2 Aug 2020 16:32:59 +0200
Message-ID: <20200802143259.GA1264750@ravnborg.org> (raw)
In-Reply-To: <20200802110636.1018743-17-sam@ravnborg.org>

On Sun, Aug 02, 2020 at 01:06:30PM +0200, Sam Ravnborg wrote:
> - Use blacklight_get_brightness() helper
> - Use devm_ variant to register backlight device and drop explicit
>   unregister
> - Use macro for initialization
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
> Cc: Jonas Karlman <jonas@kwiboo.se>
> Cc: Jernej Skrabec <jernej.skrabec@siol.net>

Build errors fixed, will be included in v2.

	Sam

> ---
>  drivers/gpu/drm/bridge/parade-ps8622.c | 43 +++++++++++++-------------
>  1 file changed, 21 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/parade-ps8622.c b/drivers/gpu/drm/bridge/parade-ps8622.c
> index d789ea2a7fb9..9304484e7f71 100644
> --- a/drivers/gpu/drm/bridge/parade-ps8622.c
> +++ b/drivers/gpu/drm/bridge/parade-ps8622.c
> @@ -284,8 +284,7 @@ static int ps8622_send_config(struct ps8622_bridge *ps8622)
>  			goto error;
>  
>  		/* FFh for 100% brightness, 0h for 0% brightness */
> -		err = ps8622_set(cl, 0x01, 0xa7,
> -				ps8622->bl->props.brightness);
> +		err = ps8622_set(cl, 0x01, 0xa7, backlight_get_brightness(ps8622->bl));
>  		if (err)
>  			goto error;
>  	} else {
> @@ -331,18 +330,11 @@ static int ps8622_send_config(struct ps8622_bridge *ps8622)
>  static int ps8622_backlight_update(struct backlight_device *bl)
>  {
>  	struct ps8622_bridge *ps8622 = dev_get_drvdata(&bl->dev);
> -	int ret, brightness = bl->props.brightness;
> -
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
> -		brightness = 0;
>  
>  	if (!ps8622->enabled)
>  		return -EINVAL;
>  
> -	ret = ps8622_set(ps8622->client, 0x01, 0xa7, brightness);
> -
> -	return ret;
> +	return ps8622_set(ps8622->client, 0x01, 0xa7, blacklight_get_brightness(bl));
>  }
>  
>  static const struct backlight_ops ps8622_backlight_ops = {
> @@ -521,7 +513,23 @@ static const struct drm_bridge_funcs ps8622_bridge_funcs = {
>  	.attach = ps8622_attach,
>  };
>  
> -static const struct of_device_id ps8622_devices[] = {
> +static int ps8622_register_blacklight(struct ps8622_bridge *ps8622)
> +{
> +	DECLARE_BACKLIGHT_INIT_RAW(props, PS8622_MAX_BRIGHTNESS, PS8622_MAX_BRIGHTNESS);
> +	backlight_device *bl;
> +
> +	bl = devm_backlight_device_register(dev, dev_name(dev), dev,
> +					    ps8622, &ps8622_backlight_ops, &props);
> +	if (IS_ERR(bl)) {
> +		DRM_ERROR("failed to register backlight\n");
> +		return PTR_ERR(bl);
> +	}
> +
> +	ps8622->bl = bl;
> +	return 0;
> +}
> +
> +const struct of_device_id ps8622_devices[] = {
>  	{.compatible = "parade,ps8622",},
>  	{.compatible = "parade,ps8625",},
>  	{}
> @@ -581,17 +589,9 @@ static int ps8622_probe(struct i2c_client *client,
>  	}
>  
>  	if (!of_find_property(dev->of_node, "use-external-pwm", NULL)) {
> -		ps8622->bl = backlight_device_register("ps8622-backlight",
> -				dev, ps8622, &ps8622_backlight_ops,
> -				NULL);
> -		if (IS_ERR(ps8622->bl)) {
> -			DRM_ERROR("failed to register backlight\n");
> -			ret = PTR_ERR(ps8622->bl);
> -			ps8622->bl = NULL;
> +		ret = ps8622_register_blacklight(ps8622);
> +		if (ret)
>  			return ret;
> -		}
> -		ps8622->bl->props.max_brightness = PS8622_MAX_BRIGHTNESS;
> -		ps8622->bl->props.brightness = PS8622_MAX_BRIGHTNESS;
>  	}
>  
>  	ps8622->bridge.funcs = &ps8622_bridge_funcs;
> @@ -607,7 +607,6 @@ static int ps8622_remove(struct i2c_client *client)
>  {
>  	struct ps8622_bridge *ps8622 = i2c_get_clientdata(client);
>  
> -	backlight_device_unregister(ps8622->bl);
>  	drm_bridge_remove(&ps8622->bridge);
>  
>  	return 0;
> -- 
> 2.25.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply index

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02 11:06 [RFC PATCH v1 0/22] backlight: add init macros and accessors Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 01/22] backlight: Silently fail backlight_update_status() if no device Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 02/22] backlight: Add DECLARE_* macro for device registration Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 03/22] backlight: Add get/set operations for brightness/power properties Sam Ravnborg
2020-08-04 16:43   ` daniel
2020-08-04 19:56     ` Sam Ravnborg
2020-08-05  7:16       ` daniel
2020-08-02 11:06 ` [PATCH v1 04/22] backlight: gpio: Use DECLARE_BACKLIGHT_INIT_RAW and get/setters Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 05/22] drm/gma500: Backlight support Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 06/22] drm/panel: asus-z00t-tm5p5-n35596: Backlight update Sam Ravnborg
2020-08-04 16:59   ` daniel
2020-08-02 11:06 ` [PATCH v1 07/22] drm/panel: jdi-lt070me05000: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 08/22] drm/panel: novatek-nt35510: " Sam Ravnborg
2020-08-04 21:29   ` Linus Walleij
2020-08-02 11:06 ` [PATCH v1 09/22] drm/panel: orisetech-otm8009a: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 10/22] drm/panel: raydium-rm67191: " Sam Ravnborg
2020-08-04 17:04   ` daniel
2020-08-02 11:06 ` [PATCH v1 11/22] drm/panel: samsung-s6e63m0: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 12/22] drm/panel: samsung-s6e63j0x03: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 13/22] drm/panel: samsung-s6e3ha2: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 14/22] drm/panel: sony-acx424akp: " Sam Ravnborg
2020-08-04 21:31   ` Linus Walleij
2020-08-02 11:06 ` [PATCH v1 15/22] drm/panel: sony-acx565akm: " Sam Ravnborg
2020-08-04 17:09   ` daniel
2020-08-02 11:06 ` [PATCH v1 16/22] drm/bridge: parade-ps8622: " Sam Ravnborg
2020-08-02 14:05   ` kernel test robot
2020-08-02 14:32   ` Sam Ravnborg [this message]
2020-08-02 11:06 ` [PATCH v1 17/22] drm/tilcdc: " Sam Ravnborg
2020-08-02 13:21   ` kernel test robot
2020-08-02 11:06 ` [PATCH v1 18/22] drm/radeon: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 19/22] drm/amdgpu/atom: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 20/22] drm/i915: " Sam Ravnborg
2020-08-02 11:06 ` [PATCH v1 21/22] drm/omap: display: " Sam Ravnborg
2020-08-02 14:26   ` Sebastian Reichel
2020-08-02 14:32     ` Sam Ravnborg
2020-08-02 22:48       ` Sebastian Reichel
2020-08-02 11:06 ` [PATCH v1 22/22] drm/shmobile: " Sam Ravnborg
2020-08-04 16:51 ` [RFC PATCH v1 0/22] backlight: add init macros and accessors daniel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200802143259.GA1264750@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=daniel.thompson@linaro.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@siol.net \
    --cc=jingoohan1@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=lee.jones@linaro.org \
    --cc=narmstrong@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

dri-devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dri-devel/0 dri-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dri-devel dri-devel/ https://lore.kernel.org/dri-devel \
		dri-devel@lists.freedesktop.org
	public-inbox-index dri-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.freedesktop.lists.dri-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git