* [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness
@ 2014-11-20 11:58 Jani Nikula
2014-11-20 17:33 ` Eoff, Ullysses A
0 siblings, 1 reply; 4+ messages in thread
From: Jani Nikula @ 2014-11-20 11:58 UTC (permalink / raw)
To: intel-gfx; +Cc: jani.nikula
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@intel.com>
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@intel.com
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=85861
Cc: U. Artie Eoff <ullysses.a.eoff@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness
2014-11-20 11:58 [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness Jani Nikula
@ 2014-11-20 17:33 ` Eoff, Ullysses A
2014-12-02 19:00 ` Eoff, Ullysses A
0 siblings, 1 reply; 4+ messages in thread
From: Eoff, Ullysses A @ 2014-11-20 17:33 UTC (permalink / raw)
To: Nikula, Jani, intel-gfx@lists.freedesktop.org
> -----Original Message-----
> From: Nikula, Jani
> Sent: Thursday, November 20, 2014 3:59 AM
> To: intel-gfx@lists.freedesktop.org
> 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@intel.com>
> 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@intel.com
> Reference: https://bugzilla.kernel.org/show_bug.cgi?id=85861
> Cc: U. Artie Eoff <ullysses.a.eoff@intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Tested-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
> ---
> 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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness
2014-11-20 17:33 ` Eoff, Ullysses A
@ 2014-12-02 19:00 ` Eoff, Ullysses A
2014-12-05 13:09 ` Jani Nikula
0 siblings, 1 reply; 4+ messages in thread
From: Eoff, Ullysses A @ 2014-12-02 19:00 UTC (permalink / raw)
To: Eoff, Ullysses A, Nikula, Jani, intel-gfx@lists.freedesktop.org
bump
> -----Original Message-----
> From: Intel-gfx [mailto:intel-gfx-bounces@lists.freedesktop.org] On Behalf Of Eoff, Ullysses A
> Sent: Thursday, November 20, 2014 9:34 AM
> To: Nikula, Jani; intel-gfx@lists.freedesktop.org
> Subject: Re: [Intel-gfx] [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness
>
> > -----Original Message-----
> > From: Nikula, Jani
> > Sent: Thursday, November 20, 2014 3:59 AM
> > To: intel-gfx@lists.freedesktop.org
> > 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@intel.com>
> > 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@intel.com
> > Reference: https://bugzilla.kernel.org/show_bug.cgi?id=85861
> > Cc: U. Artie Eoff <ullysses.a.eoff@intel.com>
> > Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> Tested-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
>
> > ---
> > 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@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness
2014-12-02 19:00 ` Eoff, Ullysses A
@ 2014-12-05 13:09 ` Jani Nikula
0 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2014-12-05 13:09 UTC (permalink / raw)
To: Eoff, Ullysses A
On Tue, 02 Dec 2014, "Eoff, Ullysses A" <ullysses.a.eoff@intel.com> wrote:
> bump
Talked about this with Daniel a while back, his take was, "preemptively
catering to bonghits userspace means we'll have less wiggle-room in the
future"
BR,
Jani.
>
>> -----Original Message-----
>> From: Intel-gfx [mailto:intel-gfx-bounces@lists.freedesktop.org] On Behalf Of Eoff, Ullysses A
>> Sent: Thursday, November 20, 2014 9:34 AM
>> To: Nikula, Jani; intel-gfx@lists.freedesktop.org
>> Subject: Re: [Intel-gfx] [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness
>>
>> > -----Original Message-----
>> > From: Nikula, Jani
>> > Sent: Thursday, November 20, 2014 3:59 AM
>> > To: intel-gfx@lists.freedesktop.org
>> > 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@intel.com>
>> > 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@intel.com
>> > Reference: https://bugzilla.kernel.org/show_bug.cgi?id=85861
>> > Cc: U. Artie Eoff <ullysses.a.eoff@intel.com>
>> > Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>>
>> Tested-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
>>
>> > ---
>> > 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@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-05 13:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-20 11:58 [RFC PATCH] drm/i915: avoid round-trip scaling errors in actual_brightness Jani Nikula
2014-11-20 17:33 ` Eoff, Ullysses A
2014-12-02 19:00 ` Eoff, Ullysses A
2014-12-05 13:09 ` Jani Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox