[Intel-gfx] [PATCH v4 11/31] drm/i915: Call acpi_video_register_backlight() (v2)

Jani Nikula jani.nikula at linux.intel.com
Wed Aug 24 12:47:05 UTC 2022


On Wed, 24 Aug 2022, Hans de Goede <hdegoede at redhat.com> wrote:
> On machins without an i915 opregion the acpi_video driver immediately
> probes the ACPI video bus and used to also immediately register
> acpi_video# backlight devices when supported.
>
> Once the drm/kms driver then loaded later and possibly registered
> a native backlight device then the drivers/acpi/video_detect.c code
> unregistered the acpi_video0 device to avoid there being 2 backlight
> devices (when acpi_video_get_backlight_type()==native).
>
> This means that userspace used to briefly see 2 devices and the
> disappearing of acpi_video0 after a brief time confuses the systemd
> backlight level save/restore code, see e.g.:
> https://bbs.archlinux.org/viewtopic.php?id=269920
>
> To fix this the ACPI video code has been modified to make backlight class
> device registration a separate step, relying on the drm/kms driver to
> ask for the acpi_video backlight registration after it is done setting up
> its native backlight device.
>
> Add a call to the new acpi_video_register_backlight() after the i915 calls
> acpi_video_register() (after setting up the i915 opregion) so that the
> acpi_video backlight devices get registered on systems where the i915
> native backlight device is not registered.
>
> Changes in v2:
> -Only call acpi_video_register_backlight() when a panel is detected
>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 8 ++++++++
>  drivers/gpu/drm/i915/display/intel_panel.c   | 3 +++
>  drivers/gpu/drm/i915/i915_drv.h              | 2 ++
>  3 files changed, 13 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 6103b02c081f..2bb53efdb149 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -9088,6 +9088,14 @@ void intel_display_driver_register(struct drm_i915_private *i915)
>  	/* Must be done after probing outputs */
>  	intel_opregion_register(i915);
>  	acpi_video_register();
> +	/*
> +	 * Only call this if i915 is driving the internal panel. If the internal
> +	 * panel is not driven by i915 then another GPU driver may still register
> +	 * a native backlight driver later and this should only be called after
> +	 * any native backlights have been registered.
> +	 */
> +	if (i915->have_panel)
> +		acpi_video_register_backlight();

Apologies for procrastinating the review.

Please let's not add new flags like have_panel to i915; we're trying to
clean it up instead.

The code here needs to iterate over the connectors to decide. Maybe
better abstracted a function.

BR,
Jani.


>  
>  	intel_audio_init(i915);
>  
> diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c
> index 237a40623dd7..4536c527f50c 100644
> --- a/drivers/gpu/drm/i915/display/intel_panel.c
> +++ b/drivers/gpu/drm/i915/display/intel_panel.c
> @@ -646,8 +646,11 @@ intel_panel_mode_valid(struct intel_connector *connector,
>  
>  int intel_panel_init(struct intel_connector *connector)
>  {
> +	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
>  	struct intel_panel *panel = &connector->panel;
>  
> +	dev_priv->have_panel = true;
> +
>  	intel_backlight_init_funcs(panel);
>  
>  	drm_dbg_kms(connector->base.dev,
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 69ce6db6a7c1..14b0dcaf25c2 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -756,6 +756,8 @@ struct drm_i915_private {
>  
>  	bool ipc_enabled;
>  
> +	bool have_panel;
> +
>  	struct intel_audio_private audio;
>  
>  	struct i915_pmu pmu;

-- 
Jani Nikula, Intel Open Source Graphics Center


More information about the Intel-gfx mailing list