All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: safeguard against too high minimum brightness
Date: Thu, 06 Nov 2014 18:41:26 +0200	[thread overview]
Message-ID: <878ujojn7t.fsf@intel.com> (raw)
In-Reply-To: <20141105155637.GV26941@phenom.ffwll.local>

On Wed, 05 Nov 2014, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Wed, Nov 05, 2014 at 02:46:31PM +0200, Jani Nikula wrote:
>> Never trust (your interpretation of) the VBT. Regression from
>> 
>> commit 6dda730e55f412a6dfb181cae6784822ba463847
>> Author: Jani Nikula <jani.nikula@intel.com>
>> Date:   Tue Jun 24 18:27:40 2014 +0300
>> 
>>     drm/i915: respect the VBT minimum backlight brightness
>> 
>> causing div by zero if VBT minimum brightness equals maximum brightness.
>> 
>> Despite my attempts I've failed in my detective work to figure out what
>> the root cause is. This is not the real fix, but we have to do
>> something.
>> 
>> Reported-by: Mike Auty <mike.auty@gmail.com>
>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=86551
>> Cc: stable@vger.kernel.org (v3.17+)
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  drivers/gpu/drm/i915/intel_panel.c | 17 +++++++++++++++--
>>  1 file changed, 15 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
>> index e18b3f49074c..b001c90312e7 100644
>> --- a/drivers/gpu/drm/i915/intel_panel.c
>> +++ b/drivers/gpu/drm/i915/intel_panel.c
>> @@ -1094,12 +1094,25 @@ 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;
>> +	int min;
>>  
>>  	WARN_ON(panel->backlight.max == 0);
>>  
>> +	/*
>> +	 * XXX: If the vbt value is 255, it makes min equal to max, which leads
>> +	 * to problems. There are such machines out there. Either our
>> +	 * interpretation is wrong or the vbt has bogus data. Or both. Safeguard
>> +	 * against this by letting the minimum be at most (arbitrarily chosen)
>> +	 * 25% of the max.
>> +	 */
>> +	min = clamp_t(int, dev_priv->vbt.backlight.min_brightness, 0, 64);
>
> min_brightness is unsigned everywhere I've look, so a min_t looks
> sufficient here. Otherwise
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Pushed to drm-intel-fixes, thanks for the review.

BR,
Jani.

>
> Also, more gin pls :(
> -Daniel
>
>> +	if (min != dev_priv->vbt.backlight.min_brightness) {
>> +		DRM_DEBUG_KMS("clamping VBT min backlight %d/255 to %d/255\n",
>> +			      dev_priv->vbt.backlight.min_brightness, min);
>> +	}
>> +
>>  	/* vbt value is a coefficient in range [0..255] */
>> -	return scale(dev_priv->vbt.backlight.min_brightness, 0, 255,
>> -		     0, panel->backlight.max);
>> +	return scale(min, 0, 255, 0, panel->backlight.max);
>>  }
>>  
>>  static int bdw_setup_backlight(struct intel_connector *connector)
>> -- 
>> 2.1.1
>> 
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2014-11-06 16:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-05 12:46 [PATCH] drm/i915: safeguard against too high minimum brightness Jani Nikula
2014-11-05 15:56 ` Daniel Vetter
2014-11-06 16:41   ` Jani Nikula [this message]

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=878ujojn7t.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.