Re: [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Nikula, Jani
> Sent: Thursday, November 20, 2014 3:59 AM
> To: intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> Cc: Nikula, Jani; Eoff, Ullysses A
> Subject: [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness
> 
> Due to scaling, the userspace and hardware brightness ranges might not
> have a 1:1 mapping, causing the backlight class sysfs actual_brightness
> not match the brightness attribute just written. While this is not a
> strict requirement per Documentation/ABI/stable/sysfs-class-backlight,
> try the userspace->hardware scaling for a match first and return the
> cached value to not confuse userspace.
> 
> The problem was already mitigated by
> 
> commit 673e7bbdb3920b62cfc6c710bea626b0a9b0f43a
> Author: U. Artie Eoff <ullysses.a.eoff@xxxxxxxxx>
> Date:   Mon Sep 29 15:49:32 2014 -0700
> 
>     drm/i915: intel_backlight scale() math WA
> 
> but this should be more robust for cases where the userspace expects
> actual_brightness to match the just written brightness.
> 
> Reference: http://mid.gmane.org/1415737838-9640-1-git-send-email-ullysses.a.eoff@xxxxxxxxx
> Reference: https://bugzilla.kernel.org/show_bug.cgi?id=85861
> Cc: U. Artie Eoff <ullysses.a.eoff@xxxxxxxxx>
> Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>

Tested-by: U. Artie Eoff <ullysses.a.eoff@xxxxxxxxx>

> ---
>  drivers/gpu/drm/i915/intel_panel.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index 4d63839bd9b4..675b56e105e7 100644
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -1024,7 +1024,17 @@ static int intel_backlight_device_get_brightness(struct backlight_device *bd)
>  	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
> 
>  	hw_level = intel_panel_get_backlight(connector);
> -	ret = scale_hw_to_user(connector, hw_level, bd->props.max_brightness);
> +
> +	/*
> +	 * Check the userspace->hardware scaling for a match first to avoid
> +	 * scaling errors in the userspace->hardware->userspace round-trip.
> +	 */
> +	if (hw_level == scale_user_to_hw(connector, bd->props.brightness,
> +					 bd->props.max_brightness))
> +		ret = bd->props.brightness;
> +	else
> +		ret = scale_hw_to_user(connector, hw_level,
> +				       bd->props.max_brightness);
> 
>  	drm_modeset_unlock(&dev->mode_config.connection_mutex);
>  	intel_runtime_pm_put(dev_priv);
> --
> 2.1.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux