diff options
author | Joshua Stein <jcs@cvs.openbsd.org> | 2017-03-07 02:48:16 +0000 |
---|---|---|
committer | Joshua Stein <jcs@cvs.openbsd.org> | 2017-03-07 02:48:16 +0000 |
commit | 4ab37d1c31f8aba9f695e4262845f4985ec3aa0c (patch) | |
tree | 5c28aba3715c65f4ed70194cb5dd40ef7493cb4c /sys/dev/pci/drm | |
parent | c83534dcda42e46ebb75e94224a7b9f423f09b58 (diff) |
Setup backlight pwm alternate increment on backlight enable
On at least the MacBookAir7,1 (Broadwell), upon S3 resume, the
backlight value was treated as 0 or 100 despite reporting
intermediate values, so if the backlight value was anything other
than 100 at suspend time, the screen would stay off upon resume.
This is backported from Linux commits
32b421e79e6b546da1d469f1229403ac9142d695 and
e29aff05f239f8dd24e9ee7816fd96726e20105a which were noted in
freedesktop.org bug 67454.
ok jsg
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r-- | sys/dev/pci/drm/i915/i915_reg.h | 4 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/intel_drv.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/intel_panel.c | 27 |
3 files changed, 30 insertions, 4 deletions
diff --git a/sys/dev/pci/drm/i915/i915_reg.h b/sys/dev/pci/drm/i915/i915_reg.h index 8aab4400005..d08a1cada85 100644 --- a/sys/dev/pci/drm/i915/i915_reg.h +++ b/sys/dev/pci/drm/i915/i915_reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_reg.h,v 1.11 2015/09/25 16:15:19 jsg Exp $ */ +/* $OpenBSD: i915_reg.h,v 1.12 2017/03/07 02:48:15 jcs Exp $ */ /* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * @@ -4540,9 +4540,11 @@ #define FDI_PHASE_SYNC_OVR(pipe) (1<<(FDIA_PHASE_SYNC_SHIFT_OVR - ((pipe) * 2))) #define FDI_PHASE_SYNC_EN(pipe) (1<<(FDIA_PHASE_SYNC_SHIFT_EN - ((pipe) * 2))) #define FDI_BC_BIFURCATION_SELECT (1 << 12) +#define SPT_PWM_GRANULARITY (1<<0) #define SOUTH_CHICKEN2 0xc2004 #define FDI_MPHY_IOSFSB_RESET_STATUS (1<<13) #define FDI_MPHY_IOSFSB_RESET_CTL (1<<12) +#define LPT_PWM_GRANULARITY (1<<5) #define DPLS_EDP_PPS_FIX_DIS (1<<0) #define _FDI_RXA_CHICKEN 0xc200c diff --git a/sys/dev/pci/drm/i915/intel_drv.h b/sys/dev/pci/drm/i915/intel_drv.h index d536066c522..bc3620fef32 100644 --- a/sys/dev/pci/drm/i915/intel_drv.h +++ b/sys/dev/pci/drm/i915/intel_drv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intel_drv.h,v 1.9 2015/12/09 05:17:44 jsg Exp $ */ +/* $OpenBSD: intel_drv.h,v 1.10 2017/03/07 02:48:15 jcs Exp $ */ /* * Copyright (c) 2006 Dave Airlie <airlied@linux.ie> * Copyright (c) 2007-2008 Intel Corporation @@ -168,6 +168,7 @@ struct intel_panel { bool enabled; bool combination_mode; /* gen 2/4 only */ bool active_low_pwm; + bool alternate_pwm_increment; /* lpt+ */ struct backlight_device *device; } backlight; }; diff --git a/sys/dev/pci/drm/i915/intel_panel.c b/sys/dev/pci/drm/i915/intel_panel.c index 9d4f73fd790..a329c3231b8 100644 --- a/sys/dev/pci/drm/i915/intel_panel.c +++ b/sys/dev/pci/drm/i915/intel_panel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intel_panel.c,v 1.11 2015/09/23 23:12:12 kettenis Exp $ */ +/* $OpenBSD: intel_panel.c,v 1.12 2017/03/07 02:48:15 jcs Exp $ */ /* * Copyright © 2006-2010 Intel Corporation * Copyright (c) 2006 Dave Airlie <airlied@linux.ie> @@ -611,7 +611,7 @@ static void bdw_enable_backlight(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 pch_ctl1, pch_ctl2; + u32 pch_ctl1, pch_ctl2, schicken; pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1); if (pch_ctl1 & BLM_PCH_PWM_ENABLE) { @@ -620,6 +620,22 @@ static void bdw_enable_backlight(struct intel_connector *connector) I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1); } + if (HAS_PCH_LPT(dev)) { + schicken = I915_READ(SOUTH_CHICKEN2); + if (panel->backlight.alternate_pwm_increment) + schicken |= LPT_PWM_GRANULARITY; + else + schicken &= ~LPT_PWM_GRANULARITY; + I915_WRITE(SOUTH_CHICKEN2, schicken); + } else { + schicken = I915_READ(SOUTH_CHICKEN1); + if (panel->backlight.alternate_pwm_increment) + schicken |= SPT_PWM_GRANULARITY; + else + schicken &= ~SPT_PWM_GRANULARITY; + I915_WRITE(SOUTH_CHICKEN1, schicken); + } + pch_ctl2 = panel->backlight.max << 16; I915_WRITE(BLC_PWM_PCH_CTL2, pch_ctl2); @@ -956,6 +972,13 @@ static int bdw_setup_backlight(struct intel_connector *connector) struct drm_i915_private *dev_priv = dev->dev_private; struct intel_panel *panel = &connector->panel; u32 pch_ctl1, pch_ctl2, val; + bool alt; + + if (HAS_PCH_LPT(dev)) + alt = I915_READ(SOUTH_CHICKEN2) & LPT_PWM_GRANULARITY; + else + alt = I915_READ(SOUTH_CHICKEN1) & SPT_PWM_GRANULARITY; + panel->backlight.alternate_pwm_increment = alt; pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1); panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY; |