Skip to contentSkip to conversation

drm/i915: backlight scaling and timing changes from chromium.

PATCH New [email protected] 1 participant 12 messages Jul 16, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover drm/i915: backlight scaling and timing changes from chromium.

From: Clint Taylor <[email protected]>

Upstreaming Chromium backlight related patches which including minimum duty cycle and 0..max_brightness scaling of the sysfs requested brightness level.

Ben Widawsky (5):
CHROMIUM: drm/i915/vlv: Initialize pipe B backlight to A's value
CHROMIUM: drm/i915: Provide valleyview backlight fallback value
CHROMIUM: drm/i915/vlv: Scale backlight to min duty ratio
CHROMIUM: drm/i915/vlv: Check BLC enable for pwm invariant
CHROMIUM: drm/i915/vlv: Prefer VBT to set PWM

Jani Nikula (1):
CHROMIUM: drm/i915: parse backlight modulation frequency from the
BIOS VBT

Jesse Barnes (4):
CHROMIUM: drm/i915: add backlight assertion funcs for PWM status
CHROMIUM: drm/i915: do not explicitly disable backlight in panel_off
CHROMIUM: drm/i915: use backlight wrapper functions instead of direct
calls
CHROMIUM: drm/i915: change order of PWM enable vs BLC enable

Kevin Strasser (1):
CHROMIUM: drm/i915/vlv: Fix BLM_PWM_ENABLE check in pwm invariant

 drivers/gpu/drm/i915/i915_drv.h    |   10 ++++++
 drivers/gpu/drm/i915/intel_bios.c  |   35 +++++++++++++++++++-
 drivers/gpu/drm/i915/intel_dp.c    |   36 ++++++++++++++++++---
 drivers/gpu/drm/i915/intel_drv.h   |    1 +
 drivers/gpu/drm/i915/intel_panel.c |   62 ++++++++++++++++++++++++++----------
 5 files changed, 123 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/11 CHROMIUM: drm/i915: add backlight assertion funcs for PWM status

From: Jesse Barnes <[email protected]>

Change-Id: I0838b7c84f1913e1026ad98b8b2e79eb133d17e3
Reviewed-on: https://chromium-review.googlesource.com/192468

Commit-Queue: Wayne Boyer <[email protected]>

Conflicts:

	drivers/gpu/drm/i915/intel_dp.c
---
 drivers/gpu/drm/i915/intel_dp.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/gpu/drm/i915/intel_dp.c +22 -0
index 2adb727..90b24f6 100644
@@ -369,6 +369,21 @@ static int edp_notify_handler(struct notifier_block *this, unsigned long code,
 	return 0;
 }
 
+static void assert_pwm(struct drm_i915_private *dev_priv,
+		       struct intel_connector *connector,
+		       bool expected_state)
+{
+	bool state;
+
+	state = dev_priv->display.get_backlight(connector);
+
+	WARN(state != expected_state, "pwm state failure, expected %d, found "
+	     "%d\n", expected_state, state);
+}
+
+#define assert_pwm_enabled(d, p) assert_pwm((d), (p), true)
+#define assert_pwm_disabled(d, p) assert_pwm((d), (p), false)
+
 static bool edp_have_panel_power(struct intel_dp *intel_dp)
 {
 	struct drm_device *dev = intel_dp_to_dev(intel_dp);
@@ -1351,6 +1366,8 @@ void intel_edp_panel_off(struct intel_dp *intel_dp)
 
 	WARN(!intel_dp->want_panel_vdd, "Need VDD to turn off panel\n");
 
+	assert_pwm_disabled(dev_priv, intel_dp->attached_connector);
+
 	pp = ironlake_get_pp_control(intel_dp);
 	/* We need to switch off panel power _and_ force vdd, for otherwise some
 	 * panels get very unhappy and cease to work. */
@@ -1387,6 +1404,8 @@ void intel_edp_backlight_on(struct intel_dp *intel_dp)
 
 	intel_panel_enable_backlight(intel_dp->attached_connector);
 
+	assert_pwm_disabled(dev_priv, intel_dp->attached_connector);
+
 	/*
 	 * If we enable the backlight right away following a panel power
 	 * on, we may see slight flicker as the panel syncs with the eDP
@@ -1415,6 +1434,9 @@ void intel_edp_backlight_off(struct intel_dp *intel_dp)
 
 	DRM_DEBUG_KMS("\n");
 	pp = ironlake_get_pp_control(intel_dp);
+
+	assert_pwm_enabled(dev_priv, intel_dp->attached_connector);
+
 	pp &= ~EDP_BLC_ENABLE;
 
 	pp_ctrl_reg = _pp_ctrl_reg(intel_dp);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 2/11 CHROMIUM: drm/i915: do not explicitly disable backlight in panel_off

In reply to [email protected]

From: Jesse Barnes <[email protected]>

Per eDP spec, we must disable the backlight in order to power down the panel. However, in our code, we have always disabled the backlight before we try to turn off the panel. The assertions from the previous patch make sure this is the case.

Change-Id: I68ae4ee80cee40aa4745697ce7acf3883ffb721d
Reviewed-on: https://chromium-review.googlesource.com/194250

Commit-Queue: Wayne Boyer <[email protected]>

Conflicts:

	drivers/gpu/drm/i915/intel_dp.c
---
 drivers/gpu/drm/i915/intel_dp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +1 -2
index 90b24f6..9242499 100644
@@ -1371,8 +1371,7 @@ void intel_edp_panel_off(struct intel_dp *intel_dp)
 	pp = ironlake_get_pp_control(intel_dp);
 	/* We need to switch off panel power _and_ force vdd, for otherwise some
 	 * panels get very unhappy and cease to work. */
-	pp &= ~(POWER_TARGET_ON | PANEL_POWER_RESET | EDP_FORCE_VDD |
-		EDP_BLC_ENABLE);
+	pp &= ~(POWER_TARGET_ON | EDP_FORCE_VDD | PANEL_POWER_RESET);
 
 	pp_ctrl_reg = _pp_ctrl_reg(intel_dp);
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 3/11 CHROMIUM: drm/i915: use backlight wrapper functions instead of direct calls

In reply to [email protected]

From: Jesse Barnes <[email protected]>

BUG=chrome-os-partner:25159
TEST=suspend/resume test on instrumented system shows correct signaling on oscope.

Conflicts:

	drivers/gpu/drm/i915/intel_dp.c

Change-Id: Id736d39da630cdfb045b293772f5594576660c12
Reviewed-on: https://chromium-review.googlesource.com/192472

Commit-Queue: Wayne Boyer <[email protected]>

---
 drivers/gpu/drm/i915/intel_dp.c    |    2 +-
 drivers/gpu/drm/i915/intel_drv.h   |    1 +
 drivers/gpu/drm/i915/intel_panel.c |    2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +1 -1
index 9242499..e036da4 100644
@@ -375,7 +375,7 @@ static void assert_pwm(struct drm_i915_private *dev_priv,
 {
 	bool state;
 
-	state = dev_priv->display.get_backlight(connector);
+	state = intel_panel_get_backlight(connector);
 
 	WARN(state != expected_state, "pwm state failure, expected %d, found "
 	     "%d\n", expected_state, state);
drivers/gpu/drm/i915/intel_drv.h +1 -0
index ea137f4..4ce4aca 100644
@@ -954,6 +954,7 @@ void intel_gmch_panel_fitting(struct intel_crtc *crtc,
 			      int fitting_mode);
 void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
 			       u32 max);
+u32 intel_panel_get_backlight(struct intel_connector *connector);
 int intel_panel_setup_backlight(struct drm_connector *connector);
 void intel_panel_enable_backlight(struct intel_connector *connector);
 void intel_panel_disable_backlight(struct intel_connector *connector);
drivers/gpu/drm/i915/intel_panel.c +1 -1
index 12b02fe..40e0cb08 100644
@@ -470,7 +470,7 @@ static u32 vlv_get_backlight(struct intel_connector *connector)
 	return _vlv_get_backlight(dev, pipe);
 }
 
-static u32 intel_panel_get_backlight(struct intel_connector *connector)
+u32 intel_panel_get_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH 4/11 CHROMIUM: drm/i915/vlv: Initialize pipe B backlight to A's value

In reply to [email protected]

From: Ben Widawsky <[email protected]>

Not sure if this is needed or not. The code still falls back to a potentially bad value if PIPE_A was not set.

Change-Id: I54eb5d4d9fd93e86878c9fa1daec19bdb6b3bd0b
Reviewed-on: https://chromium-review.googlesource.com/196605

Commit-Queue: Wayne Boyer <[email protected]>

Conflicts:

	drivers/gpu/drm/i915/intel_panel.c
---
 drivers/gpu/drm/i915/intel_panel.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_panel.c +15 -6
index 40e0cb08..b3327d0 100644
@@ -1080,15 +1080,24 @@ static int vlv_setup_backlight(struct intel_connector *connector)
 	u32 ctl, ctl2, val;
 
 	for_each_pipe(pipe) {
-		u32 cur_val = I915_READ(VLV_BLC_PWM_CTL(pipe));
+		u32 duty = I915_READ(VLV_BLC_PWM_CTL(pipe)) & BACKLIGHT_DUTY_CYCLE_MASK;
+		u32 freq = I915_READ(VLV_BLC_PWM_CTL(pipe)) & ~BACKLIGHT_DUTY_CYCLE_MASK;
 
-		/* Skip if the modulation freq is already set */
-		if (cur_val & ~BACKLIGHT_DUTY_CYCLE_MASK)
+		if (freq) {
+			/* Skip if the modulation freq is already set */
 			continue;
+		}
+
+		if (WARN_ON(pipe == PIPE_A)) {
+			/* Assume BLC for pipe A is the default. Therefore, A
+			 * must be non-zero. */
+			freq = (VLV_DEFAULT_BACKLIGHT_MOD_FREQ << 16);
+		} else
+			freq = I915_READ(VLV_BLC_PWM_CTL(PIPE_A)) & ~BACKLIGHT_DUTY_CYCLE_MASK;
 
-		cur_val &= BACKLIGHT_DUTY_CYCLE_MASK;
-		I915_WRITE(VLV_BLC_PWM_CTL(pipe), (0xf42 << 16) |
-			   cur_val);
+		if (WARN_ON(freq == 0))
+			freq = (VLV_DEFAULT_BACKLIGHT_MOD_FREQ << 16);
+		I915_WRITE(VLV_BLC_PWM_CTL(pipe), freq | duty);
 	}
 
 	ctl2 = I915_READ(VLV_BLC_PWM_CTL2(PIPE_A));
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 5/11 CHROMIUM: drm/i915: parse backlight modulation frequency from the BIOS VBT

In reply to [email protected]

From: Jani Nikula <[email protected]>

We don't actually do anything with the information yet, but parse and log what's in the VBT.

(cherry picked from commit f00076d2fd3fe25b2e8c83921818914dee37ffef)

Change-Id: Ia3eb119069dfdb109f9c49a6d27f8d13ad8ba80a
Reviewed-on: https://chromium-review.googlesource.com/196606

Commit-Queue: Wayne Boyer <[email protected]>

Conflicts:

	drivers/gpu/drm/i915/i915_drv.h
	drivers/gpu/drm/i915/intel_bios.c
---
 drivers/gpu/drm/i915/intel_bios.h |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/i915/intel_bios.h +16 -0
index b986677..62cd658 100644
@@ -408,6 +408,22 @@ struct bdb_lfp_backlight_data {
 	u8 level[16];
 } __packed;
 
+struct bdb_lfp_backlight_data_entry {
+	u8 type:2;
+	u8 active_low_pwm:1;
+	u8 obsolete1:5;
+	u16 pwm_freq_hz;
+	u8 min_brightness;
+	u8 obsolete2;
+	u8 obsolete3;
+} __packed;
+
+struct bdb_lfp_backlight_data {
+	u8 entry_size;
+	struct bdb_lfp_backlight_data_entry data[16];
+	u8 level[16];
+} __packed;
+
 struct aimdb_header {
 	char signature[16];
 	char oem_device[20];
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 6/11 CHROMIUM: drm/i915: Provide valleyview backlight fallback value

In reply to [email protected]

From: Ben Widawsky <[email protected]>

The fallback values for VLV reflect the Rambi3 panel values.

This patch introduces min_brightness member, which defined a part of VBT that has some confusion. The field itself is a byte ranging from 0-255. How this value is supposed to be used by the driver is unclear. Though no code uses it yet, I've written a comment explaining that I intend to use the number in there as an absolute value that represents the minimum duty cycle ratio of the panel.

BUG=chrome-os-partner:25159
TEST=suspend/resume test on instrumented system shows correct signaling on oscope. Manual brightness checks.

Change-Id: I9f0d8d4fe2778c4768b06459b0a83293b1c6f023
Reviewed-on: https://chromium-review.googlesource.com/196607

Commit-Queue: Wayne Boyer <[email protected]>

---
 drivers/gpu/drm/i915/i915_drv.h   |   10 ++++++++++
 drivers/gpu/drm/i915/intel_bios.c |   35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +10 -0
index 90216bb..1962024 100644
@@ -1261,6 +1261,16 @@ struct intel_vbt_data {
 		u16 pwm_freq_hz;
 		bool present;
 		bool active_low_pwm;
+
+		/* NB: We expect this to be an absolute value (percentage)
+		 * indicating the minimum duty cycle. This value is provided by
+		 * the panel spec, and should be provided in some way/shape/form
+		 * from VBIOS.  It's unclear as of this point whether or not
+		 * this is the proper way.
+		 *
+		 * Example, 5 = 5% = .05
+		 */
+		u8 min_duty_cycle_percentage;
 	} backlight;
 
 	/* MIPI DSI */
drivers/gpu/drm/i915/intel_bios.c +34 -1
index 827498e..557338a 100644
@@ -309,6 +309,20 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
 	}
 }
 
+#define VLV_DEFAULT_MIN_DUTY_CYCLE_RATIO 5
+static void fake_vlv_backlight(struct drm_i915_private *dev_priv)
+{
+	dev_priv->vbt.backlight.pwm_freq_hz = 200;
+	dev_priv->vbt.backlight.active_low_pwm = 0;
+	dev_priv->vbt.backlight.min_duty_cycle_percentage = VLV_DEFAULT_MIN_DUTY_CYCLE_RATIO;
+
+	DRM_DEBUG_KMS("VBT backlight PWM modulation frequency %u Hz, "
+		      "active %s, min brightness %u\n",
+		      dev_priv->vbt.backlight.pwm_freq_hz,
+		      dev_priv->vbt.backlight.active_low_pwm ? "low" : "high",
+		      dev_priv->vbt.backlight.min_duty_cycle_percentage);
+}
+
 static void
 parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 {
@@ -316,8 +330,10 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 	const struct bdb_lfp_backlight_data_entry *entry;
 
 	backlight_data = find_section(bdb, BDB_LVDS_BACKLIGHT);
-	if (!backlight_data)
+	if (!backlight_data && IS_VALLEYVIEW(dev_priv->dev)) {
+		fake_vlv_backlight(dev_priv);
 		return;
+	}
 
 	if (backlight_data->entry_size != sizeof(backlight_data->data[0])) {
 		DRM_DEBUG_KMS("Unsupported backlight data entry size %u\n",
@@ -336,6 +352,23 @@ parse_lfp_backlight(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
 
 	dev_priv->vbt.backlight.pwm_freq_hz = entry->pwm_freq_hz;
 	dev_priv->vbt.backlight.active_low_pwm = entry->active_low_pwm;
+
+	/* NB: It's probably safe to do this for !VLV platforms too. */
+	if (IS_VALLEYVIEW(dev_priv->dev) && !entry->min_brightness)
+		dev_priv->vbt.backlight.min_duty_cycle_percentage = VLV_DEFAULT_MIN_DUTY_CYCLE_RATIO;
+	else if (entry->min_brightness) {
+		/* Scale min_duty_cycle_percentage down to an absolute value */
+		u32 scaled_bright = entry->min_brightness;
+		u32 abs_bright = scaled_bright * 100 / 255;
+		DRM_DEBUG_KMS("Scaling VBT brightness from %d down to absolute %d\n",
+				scaled_bright, abs_bright);
+		dev_priv->vbt.backlight.min_duty_cycle_percentage = abs_bright;
+	}
+
+	/* All platforms should have a PWM */
+	if (WARN_ON(!dev_priv->vbt.backlight.pwm_freq_hz))
+		dev_priv->vbt.backlight.pwm_freq_hz = 200;
+
 	DRM_DEBUG_KMS("VBT backlight PWM modulation frequency %u Hz, "
 		      "active %s, min brightness %u, level %u\n",
 		      dev_priv->vbt.backlight.pwm_freq_hz,
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 7/11 CHROMIUM: drm/i915/vlv: Scale backlight to min duty ratio

In reply to [email protected]

From: Ben Widawsky <[email protected]>

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.

Change-Id: Ibbbc33338ef1659d0f797d6a33d3727a45ad95d5
Reviewed-on: https://chromium-review.googlesource.com/196609

Commit-Queue: Wayne Boyer <[email protected]>

Conflicts:

	drivers/gpu/drm/i915/intel_panel.c
---
 drivers/gpu/drm/i915/intel_panel.c |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_panel.c +16 -5
index b3327d0..02248a5 100644
@@ -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)
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH 8/11 CHROMIUM: drm/i915/vlv: Check BLC enable for pwm invariant

In reply to [email protected]

From: Ben Widawsky <[email protected]>

The new assertion code mandates that backlight should be disabled. Since we've just bent over backwards over the last few patches to make sure we don't program a 0 into duty cycle, we need some additional checks to see if the panel is on. This can easily be accomplished by checking the enable bit in the adjacent control register.

Based off of a patch originally written by Jesse.

BUG=chrome-os-partner:25159
TEST=suspend/resume test on instrumented system shows correct signaling on oscope. Manual brightness checks.

Change-Id: I0aed561451ab6432c7b4d358821347189eece966
Reviewed-on: https://chromium-review.googlesource.com/196620

Commit-Queue: Wayne Boyer <[email protected]>

---
 drivers/gpu/drm/i915/intel_dp.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +6 -1
index e036da4..4f0fc11 100644
@@ -373,9 +373,14 @@ static void assert_pwm(struct drm_i915_private *dev_priv,
 		       struct intel_connector *connector,
 		       bool expected_state)
 {
+	enum pipe pipe = intel_get_pipe_from_connector(connector);
 	bool state;
 
-	state = intel_panel_get_backlight(connector);
+	if (IS_VALLEYVIEW(dev_priv->dev) &&
+	    !(I915_READ(VLV_BLC_PWM_CTL2(pipe) & BLM_PWM_ENABLE)))
+		state = false;
+	else
+		state = (intel_panel_get_backlight(connector) != 0);
 
 	WARN(state != expected_state, "pwm state failure, expected %d, found "
 	     "%d\n", expected_state, state);
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH 9/11 CHROMIUM: drm/i915: change order of PWM enable vs BLC enable

In reply to [email protected]

From: Jesse Barnes <[email protected]>

Needed for spec compliance

Change-Id: Ib09f64bdc44108c13bbe5a6ab8ab2f536360f8d2
Reviewed-on: https://chromium-review.googlesource.com/192469

Commit-Queue: Wayne Boyer <[email protected]>

Conflicts:

	drivers/gpu/drm/i915/intel_dp.c
---
 drivers/gpu/drm/i915/intel_dp.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +4 -2
index 4f0fc11..f9becf8 100644
@@ -1410,6 +1410,8 @@ void intel_edp_backlight_on(struct intel_dp *intel_dp)
 
 	assert_pwm_disabled(dev_priv, intel_dp->attached_connector);
 
+	intel_panel_enable_backlight(intel_dp->attached_connector);
+
 	/*
 	 * If we enable the backlight right away following a panel power
 	 * on, we may see slight flicker as the panel syncs with the eDP
@@ -1447,10 +1449,10 @@ void intel_edp_backlight_off(struct intel_dp *intel_dp)
 
 	I915_WRITE(pp_ctrl_reg, pp);
 	POSTING_READ(pp_ctrl_reg);
-	intel_dp->last_backlight_off = jiffies;
 
-	edp_wait_backlight_off(intel_dp);
+	intel_dp->last_backlight_off = jiffies;
 
+	msleep(intel_dp->backlight_off_delay);
 	intel_panel_disable_backlight(intel_dp->attached_connector);
 }
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

PATCH 10/11 CHROMIUM: drm/i915/vlv: Fix BLM_PWM_ENABLE check in pwm invariant

In reply to [email protected]

From: Kevin Strasser <[email protected]>

Misplaced paren causing test to always fail.

BUG=chrome-os-partner:27096,chrome-os-partner:28914 TEST=Manual: Check that the screen immediately goes black at minimum brightness.

Change-Id If9d813ab4ef8cfd9c90f2183f1bb674172bdffe9

Reviewed-on: https://chromium-review.googlesource.com/200809

---
 drivers/gpu/drm/i915/intel_dp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +1 -1
index f9becf8..3382459 100644
@@ -377,7 +377,7 @@ static void assert_pwm(struct drm_i915_private *dev_priv,
 	bool state;
 
 	if (IS_VALLEYVIEW(dev_priv->dev) &&
-	    !(I915_READ(VLV_BLC_PWM_CTL2(pipe) & BLM_PWM_ENABLE)))
+	    !(I915_READ(VLV_BLC_PWM_CTL2(pipe)) & BLM_PWM_ENABLE))
 		state = false;
 	else
 		state = (intel_panel_get_backlight(connector) != 0);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

PATCH 11/11 CHROMIUM: drm/i915/vlv: Prefer VBT to set PWM

In reply to [email protected]

From: Ben Widawsky <[email protected]>

This patch enables the VBT to override the PWM left in the BLC register, or correct for VBIOS which doesn't program the BLC, with a VBT entry.

It kills the long hardcoded VLV_DEFAULT_BACKLIGHT_MOD_FREQ

As of the last patch, we always will have a default VBT value provided in intel_bios.c

Change-Id: I4116d5fa21706e9e9ac85e41c43f7443964a822b
Reviewed-on: https://chromium-review.googlesource.com/196608

Commit-Queue: Wayne Boyer <[email protected]>

Conflicts:

	drivers/gpu/drm/i915/intel_panel.c
---
 drivers/gpu/drm/i915/intel_bios.h  |   16 ----------------
 drivers/gpu/drm/i915/intel_panel.c |   30 ++++++++++++++++++++----------
 2 files changed, 20 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/intel_bios.h +0 -16
index 62cd658..b986677 100644
@@ -408,22 +408,6 @@ struct bdb_lfp_backlight_data {
 	u8 level[16];
 } __packed;
 
-struct bdb_lfp_backlight_data_entry {
-	u8 type:2;
-	u8 active_low_pwm:1;
-	u8 obsolete1:5;
-	u16 pwm_freq_hz;
-	u8 min_brightness;
-	u8 obsolete2;
-	u8 obsolete3;
-} __packed;
-
-struct bdb_lfp_backlight_data {
-	u8 entry_size;
-	struct bdb_lfp_backlight_data_entry data[16];
-	u8 level[16];
-} __packed;
-
 struct aimdb_header {
 	char signature[16];
 	char oem_device[20];
drivers/gpu/drm/i915/intel_panel.c +20 -10
index 02248a5..5270a08 100644
@@ -418,6 +418,14 @@ static u32 intel_panel_compute_brightness(struct intel_connector *connector,
 	return val;
 }
 
+static u16 __vlv_calculate_mod_freq(u16 hz, bool s0ix)
+{
+	if (!s0ix)
+		return 100000000 / (128 * hz);
+	else
+		return 25000000 / (16 * hz);
+}
+
 static u32 bdw_get_backlight(struct intel_connector *connector)
 {
 	struct drm_device *dev = connector->base.dev;
@@ -567,7 +575,6 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
 	enum pipe pipe = intel_get_pipe_from_connector(connector);
 	u32 freq;
 	unsigned long flags;
-	u64 n;
 
 	if (!panel->backlight.present || pipe == INVALID_PIPE)
 		return;
@@ -1093,21 +1100,24 @@ static int vlv_setup_backlight(struct intel_connector *connector)
 	for_each_pipe(pipe) {
 		u32 duty = I915_READ(VLV_BLC_PWM_CTL(pipe)) & BACKLIGHT_DUTY_CYCLE_MASK;
 		u32 freq = I915_READ(VLV_BLC_PWM_CTL(pipe)) & ~BACKLIGHT_DUTY_CYCLE_MASK;
+		u32 vbt_val = __vlv_calculate_mod_freq(dev_priv->vbt.backlight.pwm_freq_hz, true);
 
 		if (freq) {
-			/* Skip if the modulation freq is already set */
-			continue;
-		}
-
-		if (WARN_ON(pipe == PIPE_A)) {
-			/* Assume BLC for pipe A is the default. Therefore, A
-			 * must be non-zero. */
-			freq = (VLV_DEFAULT_BACKLIGHT_MOD_FREQ << 16);
+			if (vbt_val != freq >> 16) {
+				DRM_DEBUG_KMS("reg doesn't match VBT value 0x%x != 0x%x\n",
+					      freq >> 16, vbt_val);
+				freq = vbt_val << 16;
+			} else
+				continue;
+		} else if (WARN_ON(pipe == PIPE_A)) {
+			/* VLV will always have a vbt value, fake or other.  */
+			BUG_ON(IS_VALLEYVIEW(dev) && !vbt_val);
+			freq = vbt_val << 16;
 		} else
 			freq = I915_READ(VLV_BLC_PWM_CTL(PIPE_A)) & ~BACKLIGHT_DUTY_CYCLE_MASK;
 
 		if (WARN_ON(freq == 0))
-			freq = (VLV_DEFAULT_BACKLIGHT_MOD_FREQ << 16);
+			freq = vbt_val << 16;
 		I915_WRITE(VLV_BLC_PWM_CTL(pipe), freq | duty);
 	}
 
Signature · 1 line
1.7.9.5