[Intel-gfx] [PATCH 07/11] CHROMIUM: drm/i915/vlv: Scale backlight to min duty ratio

clinton.a.taylor at intel.com clinton.a.taylor at intel.com
Wed Jul 16 23:49:43 CEST 2014


From: Ben Widawsky <benjamin.widawsky at intel.com>

On VLV specifically, going too low runs the risk of getting the BLC_EN
signal out of sync, preventing resume from working correctly.  Scale
/sys/class/backlight at this level to prevent userspace from doing this
on suspend.

This gets rid of the explicitly hardcoded value for a previous/similar
patch. Instead relies on the VBT to provide the value, and if VBT does
not provide one, then it uses a hardcoded 5% min duty cycle. This was
defined a couple patches ago for the same fallback on VLV.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
Signed-off-by: Wayne Boyer <wayne.boyer at intel.com>

Change-Id: Ibbbc33338ef1659d0f797d6a33d3727a45ad95d5
Reviewed-on: https://chromium-review.googlesource.com/196609
Reviewed-by: Aaron Durbin <adurbin at chromium.org>
Tested-by: Wayne Boyer <wayne.boyer at intel.com>
Commit-Queue: Wayne Boyer <wayne.boyer at intel.com>

Conflicts:
	drivers/gpu/drm/i915/intel_panel.c
---
 drivers/gpu/drm/i915/intel_panel.c |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index b3327d0..02248a5 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -576,11 +576,22 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
 
 	WARN_ON(panel->backlight.max == 0);
 
-	/* scale to hardware max, but be careful to not overflow */
-	freq = panel->backlight.max;
-	n = (u64)level * freq;
-	do_div(n, max);
-	level = n;
+	/* XXX: we probably want to do this for all platforms. */
+	if (IS_VALLEYVIEW(dev)) {
+		/* It's always safe to use vbt values for VLV since we fake them
+		 * if they don't actually exist. */
+		const int min_duty = (dev_priv->vbt.backlight.min_duty_cycle_percentage *
+				      __vlv_calculate_mod_freq(dev_priv->vbt.backlight.pwm_freq_hz, true)) / 100;
+		BUG_ON(min_duty == 0);
+		/* linear conversion to new range */
+#define FIXED_POINT_SCALE 1000
+		level = ((level * FIXED_POINT_SCALE / max) * (max - min_duty) / FIXED_POINT_SCALE) + min_duty;
+#undef FIXED_POINT_SCALE
+	} else if (freq < max)
+		/* scale to hardware, but be careful to not overflow */
+		level = level * freq / max;
+	else
+		level = freq / max * level;
 
 	panel->backlight.level = level;
 	if (panel->backlight.device)
-- 
1.7.9.5




More information about the Intel-gfx mailing list