public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Shih-Yuan Lee (FourDollars)" <sylee@canonical.com>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v4] drm/i915: Set brightness maximum to a fixed	value 100.
Date: Wed, 11 Nov 2015 21:09:15 +0800	[thread overview]
Message-ID: <20151111130915.GA4778@localhost> (raw)
In-Reply-To: <878u64ivve.fsf@intel.com>

On Wed, Nov 11, 2015 at 02:05:57PM +0200, Jani Nikula wrote:
> On Wed, 11 Nov 2015, "Shih-Yuan Lee (FourDollars)" <sylee@canonical.com> wrote:
> > Take Dell XPS 13 (2015) as an example. The vbt min 10 out of [0..255].
> > The PWM max is 937 so the corresponding PWM min is 37 (10*937/256).
> > This commit makes the sysfs brightness 1 map to the PWM brightness 37
> > and 100 map to the PWM brightness 937.
> >
> > Signed-off-by: Shih-Yuan Lee (FourDollars) <sylee@canonical.com>
> > ---
> >  drivers/gpu/drm/i915/intel_panel.c | 30 ++++++++++++++++++++++++------
> >  1 file changed, 24 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> > index a24df35..8652ce2 100644
> > --- a/drivers/gpu/drm/i915/intel_panel.c
> > +++ b/drivers/gpu/drm/i915/intel_panel.c
> > @@ -1207,11 +1207,12 @@ static int intel_backlight_device_register(struct intel_connector *connector)
> >  	memset(&props, 0, sizeof(props));
> >  	props.type = BACKLIGHT_RAW;
> >  
> > -	/*
> > -	 * Note: Everything should work even if the backlight device max
> > -	 * presented to the userspace is arbitrarily chosen.
> > -	 */
> > -	props.max_brightness = panel->backlight.max;
> > +	/* Setting max to fixed 100 if the range is large enough. */
> > +	if (panel->backlight.max > panel->backlight.min + 99)
> > +		props.max_brightness = 100;
> > +	else
> > +		props.max_brightness = panel->backlight.max - panel->backlight.min;
> 
> No, the intention is to have a fixed 0..100 range no ifs no buts.
> 
> > +
> >  	props.brightness = scale_hw_to_user(connector,
> >  					    panel->backlight.level,
> >  					    props.max_brightness);
> > @@ -1414,6 +1415,8 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector)
> >  	struct drm_device *dev = connector->base.dev;
> >  	struct drm_i915_private *dev_priv = dev->dev_private;
> >  	struct intel_panel *panel = &connector->panel;
> > +	u32 pwm_min;
> > +	u32 pwm_step;
> >  	int min;
> >  
> >  	WARN_ON(panel->backlight.max == 0);
> > @@ -1432,7 +1435,22 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector)
> >  	}
> >  
> >  	/* vbt value is a coefficient in range [0..255] */
> > -	return scale(min, 0, 255, 0, panel->backlight.max);
> > +	pwm_min = scale(min, 0, 255, 0, panel->backlight.max);
> > +
> > +	/* Calculate the PWM step */
> > +	if (panel->backlight.max > pwm_min + 99)
> > +		pwm_step = scale(1, 0, 99, 0, panel->backlight.max - pwm_min);
> > +	else
> > +		pwm_step = 1;
> > +
> > +	/*
> > +	 * Because sysfs brightness 0 is used to turn off the backlight, we need step
> > +	 * down a little bit to make sysfs brightness 1 match the lowest brightness.
> > +	 */
> > +	if (pwm_min >= pwm_step)
> > +		pwm_min -= pwm_step;
> > +
> > +	return pwm_min;
> 
> This is getting tricky, and you assume too much.
> 
> Currently, 0 means off if dev_priv->vbt.backlight.min_brightness == 0 or
> the panel is eDP. LVDS panels with non-zero min brightness aren't
> switched off with 0 brightness.

The following change makes sysfs brightness 0 to turn off the backlight.

commit e6755fb78e8f20ecadf2a4080084121336624ad9
 Author: Jani Nikula <jani.nikula at intel.com>
 Date:   Tue Aug 12 17:11:42 2014 +0300

     drm/i915: switch off backlight for backlight class 0 brightness

 drivers/gpu/drm/i915/intel_panel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index af54356..764f928 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -986,7 +986,8 @@ static int intel_backlight_device_update_status(struct backlight_device *bd)
         */
        if (panel->backlight.enabled) {
                if (panel->backlight_power) {
-                       bool enable = bd->props.power == FB_BLANK_UNBLANK;
+                       bool enable = bd->props.power == FB_BLANK_UNBLANK &&
+                               bd->props.brightness != 0;
                        panel->backlight_power(connector, enable);
                }
        } else {

But it also abandoned the lowest brightness level from VBT because it is used
to turn off the backlight.

> 
> Pardon my bluntness, but I'm starting to feel like you just want to get
> a patch in. Take my word for it, backlight is not where you should get
> started.
My intention is to respect the VBT minimum backlight brightness again.
Just like what you did before.

commit 6dda730e55f412a6dfb181cae6784822ba463847
Author: Jani Nikula <jani.nikula at intel.com>
Date:   Tue Jun 24 18:27:40 2014 +0300

    drm/i915: respect the VBT minimum backlight brightness

I don't mind if you can fix this minor issue for me.
However I am interested to work with the upstream developer.
Thanks a lot for your feedback and let me know many things about the
brightness control in i915.

BTW, I wrote the brightness kernel module (ideapad-laptop) before.

Regards,
$4

> 
> BR,
> Jani.
> 
> 
> 
> >  }
> >  
> >  static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unused)
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
https://about.me/fourdollars
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-11-11 13:09 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09  6:42 [PATCH] drm/i915: A better maximum brightness for users Shih-Yuan Lee (FourDollars)
2015-11-09 10:17 ` Jani Nikula
2015-11-09 10:30   ` Shih-Yuan Lee (FourDollars)
2015-11-09 10:51     ` Jani Nikula
2015-11-09 11:54       ` Shih-Yuan Lee (FourDollars)
2015-11-09 12:58         ` Jani Nikula
2015-11-09 14:02           ` Shih-Yuan Lee (FourDollars)
2015-11-09 15:25             ` Ville Syrjälä
2015-11-09 16:02   ` Paulo Zanoni
2015-11-09 16:57     ` Jani Nikula
2015-11-10  1:59       ` Shih-Yuan Lee (FourDollars)
2015-11-10  8:01 ` [PATCH v2] drm/i915: Respect the brightness range from VBT Shih-Yuan Lee (FourDollars)
2015-11-10 10:15   ` Jani Nikula
2015-11-10 11:26     ` Shih-Yuan Lee (FourDollars)
2015-11-10 12:57       ` Jani Nikula
2015-11-10 16:11         ` Shih-Yuan Lee (FourDollars)
2015-11-11  4:11   ` [PATCH v3] drm/i915: Set brightness maximum to a fixed value 100 Shih-Yuan Lee (FourDollars)
2015-11-11  4:57     ` kbuild test robot
2015-11-11  7:31 ` [PATCH v4] " Shih-Yuan Lee (FourDollars)
2015-11-11 12:05   ` Jani Nikula
2015-11-11 13:09     ` Shih-Yuan Lee (FourDollars) [this message]
2015-11-11 14:10 ` [PATCH v5] drm/i915: Set backlight class max to 100 and respect the VBT minimum again Shih-Yuan Lee (FourDollars)
2015-11-12  5:43 ` [PATCH v6] drm/i915: respect the VBT minimum backlight brightness again Shih-Yuan Lee (FourDollars)
2015-11-12  8:08   ` Stéphane ANCELOT
2015-11-12  8:28     ` Shih-Yuan Lee (FourDollars)
2015-11-12  8:40       ` Stéphane ANCELOT
2015-11-12  8:57         ` Shih-Yuan Lee (FourDollars)
2015-11-12  9:05           ` Stéphane ANCELOT
2015-11-12 10:01             ` Shih-Yuan Lee (FourDollars)
2015-11-18  9:06               ` Stéphane ANCELOT
2015-11-18  9:11                 ` Shih-Yuan Lee (FourDollars)
2015-11-12 13:44     ` Jani Nikula
2015-11-13  3:50 ` [PATCH v7] drm/i915: A better backlight class brightness range Shih-Yuan Lee (FourDollars)
2015-11-13  3:50   ` Shih-Yuan Lee (FourDollars)

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=20151111130915.GA4778@localhost \
    --to=sylee@canonical.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.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