AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Mario Limonciello <mario.limonciello@amd.com>,
	dri-devel@lists.freedesktop.org, harry.wentland@amd.com,
	Simona Vetter <simona@ffwll.ch>,
	Alex Deucher <alexander.deucher@amd.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	David Airlie <airlied@gmail.com>
Cc: Xaver Hugl <xaver.hugl@gmail.com>,
	amd-gfx@lists.freedesktop.org,
	"open list:INTEL DRM DISPLAY FOR XE AND I915 DRIVERS"
	<intel-gfx@lists.freedesktop.org>,
	"open list:INTEL DRM DISPLAY FOR XE AND I915 DRIVERS"
	<intel-xe@lists.freedesktop.org>,
	"Mario Limonciello (AMD)" <superm1@kernel.org>,
	Simon Ser <contact@emersion.fr>
Subject: Re: [PATCH v6 01/10] Revert "backlight: Remove notifier"
Date: Fri, 26 Jun 2026 13:41:36 +0200	[thread overview]
Message-ID: <e07d6da4-8199-4fc5-8c48-7fcd4abd6af6@suse.de> (raw)
In-Reply-To: <20260624165751.2014759-2-mario.limonciello@amd.com>

Hi

Am 24.06.26 um 18:57 schrieb Mario Limonciello:
> From: "Mario Limonciello (AMD)" <superm1@kernel.org>
>
> This reverts commit 5461f3fd74a89757f95f351eb0bc26aafc2a2e91.
> The backlight notifier support is needed in order to add backlight
> control support into DRM connectors.
>
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> Tested-by: Simon Ser <contact@emersion.fr>

I don't like this, but I don't have a better idea for now. Therefore

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

until a better idea shows up.

> ---
>   drivers/video/backlight/backlight.c | 42 +++++++++++++++++++++++++++++
>   include/linux/backlight.h           | 20 ++++++++++++++
>   2 files changed, 62 insertions(+)
>
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index a22d0bbb6e639..ff2c2084c73a4 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -65,6 +65,7 @@
>   
>   static struct list_head backlight_dev_list;
>   static struct mutex backlight_dev_list_mutex;
> +static struct blocking_notifier_head backlight_notifier;
>   
>   static const char *const backlight_types[] = {
>   	[BACKLIGHT_RAW] = "raw",
> @@ -415,6 +416,9 @@ struct backlight_device *backlight_device_register(const char *name,
>   	list_add(&new_bd->entry, &backlight_dev_list);
>   	mutex_unlock(&backlight_dev_list_mutex);
>   
> +	blocking_notifier_call_chain(&backlight_notifier,
> +				     BACKLIGHT_REGISTERED, new_bd);
> +
>   	return new_bd;
>   }
>   EXPORT_SYMBOL(backlight_device_register);
> @@ -484,6 +488,9 @@ void backlight_device_unregister(struct backlight_device *bd)
>   	mutex_unlock(&pmac_backlight_mutex);
>   #endif
>   
> +	blocking_notifier_call_chain(&backlight_notifier,
> +				     BACKLIGHT_UNREGISTERED, bd);
> +
>   	mutex_lock(&bd->ops_lock);
>   	bd->ops = NULL;
>   	mutex_unlock(&bd->ops_lock);
> @@ -507,6 +514,40 @@ static int devm_backlight_device_match(struct device *dev, void *res,
>   	return *r == data;
>   }
>   
> +/**
> + * backlight_register_notifier - get notified of backlight (un)registration
> + * @nb: notifier block with the notifier to call on backlight (un)registration
> + *
> + * Register a notifier to get notified when backlight devices get registered
> + * or unregistered.
> + *
> + * RETURNS:
> + *
> + * 0 on success, otherwise a negative error code
> + */
> +int backlight_register_notifier(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_register(&backlight_notifier, nb);
> +}
> +EXPORT_SYMBOL(backlight_register_notifier);
> +
> +/**
> + * backlight_unregister_notifier - unregister a backlight notifier
> + * @nb: notifier block to unregister
> + *
> + * Register a notifier to get notified when backlight devices get registered
> + * or unregistered.
> + *
> + * RETURNS:
> + *
> + * 0 on success, otherwise a negative error code
> + */
> +int backlight_unregister_notifier(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_unregister(&backlight_notifier, nb);
> +}
> +EXPORT_SYMBOL(backlight_unregister_notifier);
> +
>   /**
>    * devm_backlight_device_register - register a new backlight device
>    * @dev: the device to register
> @@ -674,6 +715,7 @@ static int __init backlight_class_init(void)
>   
>   	INIT_LIST_HEAD(&backlight_dev_list);
>   	mutex_init(&backlight_dev_list_mutex);
> +	BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);
>   
>   	return 0;
>   }
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index f29a9ef1052e7..d905173c7f73c 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -64,6 +64,24 @@ enum backlight_type {
>   	BACKLIGHT_TYPE_MAX,
>   };
>   
> +/**
> + * enum backlight_notification - the type of notification
> + *
> + * The notifications that is used for notification sent to the receiver
> + * that registered notifications using backlight_register_notifier().
> + */
> +enum backlight_notification {
> +	/**
> +	 * @BACKLIGHT_REGISTERED: The backlight device is registered.
> +	 */
> +	BACKLIGHT_REGISTERED,
> +
> +	/**
> +	 * @BACKLIGHT_UNREGISTERED: The backlight revice is unregistered.
> +	 */
> +	BACKLIGHT_UNREGISTERED,
> +};
> +
>   /** enum backlight_scale - the type of scale used for brightness values
>    *
>    * The type of scale used for brightness values.
> @@ -388,6 +406,8 @@ void devm_backlight_device_unregister(struct device *dev,
>   				      struct backlight_device *bd);
>   void backlight_force_update(struct backlight_device *bd,
>   			    enum backlight_update_reason reason);
> +int backlight_register_notifier(struct notifier_block *nb);
> +int backlight_unregister_notifier(struct notifier_block *nb);
>   struct backlight_device *backlight_device_get_by_name(const char *name);
>   struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
>   int backlight_device_set_brightness(struct backlight_device *bd,

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)



  reply	other threads:[~2026-06-26 11:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24 16:57 [PATCH v6 00/10] Add support for a DRM backlight capability Mario Limonciello
2026-06-24 16:57 ` [PATCH v6 01/10] Revert "backlight: Remove notifier" Mario Limonciello
2026-06-26 11:41   ` Thomas Zimmermann [this message]
2026-06-24 16:57 ` [PATCH v6 02/10] backlight: add kernel-internal backlight API Mario Limonciello
2026-06-24 16:57 ` [PATCH v6 03/10] drm: link connectors to backlight devices Mario Limonciello
2026-06-26  7:34   ` Maxime Ripard
2026-06-26 21:40     ` Mario Limonciello
2026-07-07 11:53       ` Maxime Ripard
2026-06-26 11:49   ` Thomas Zimmermann
2026-06-24 16:57 ` [PATCH v6 04/10] DRM: Add support for client indicating support for luminance Mario Limonciello
2026-07-21 18:31   ` Hans de Goede
2026-06-24 16:57 ` [PATCH v6 05/10] drm/amd/display: Pass up errors reading actual brightness Mario Limonciello
2026-06-24 16:57 ` [PATCH v6 06/10] drm/amd/display: Allow backlight registration to fail Mario Limonciello
2026-06-24 16:57 ` [PATCH v6 07/10] drm/amd/display: use drm backlight Mario Limonciello
2026-06-24 16:57 ` [PATCH v6 08/10] drm/amd/display: Drop brightness caching in amdgpu_dm Mario Limonciello
2026-06-24 16:57 ` [PATCH v6 09/10] drm/bridge: auto-link panel backlight in bridge connector Mario Limonciello
2026-06-24 16:57 ` [PATCH v6 10/10] drm/i915/display: use drm backlight Mario Limonciello
2026-07-21 17:50 ` [PATCH v6 00/10] Add support for a DRM backlight capability Hans de Goede
2026-07-21 18:19   ` Hans de Goede

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=e07d6da4-8199-4fc5-8c48-7fcd4abd6af6@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=contact@emersion.fr \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mario.limonciello@amd.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=superm1@kernel.org \
    --cc=xaver.hugl@gmail.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox