Message ID | 1474275232-21478-1-git-send-email-shawn.c.lee@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, 19 Sep 2016, "Lee, Shawn C" <shawn.c.lee@intel.com> wrote: > From: "Lee, Shawn C" <shawn.c.lee@intel.com> > > SPT_PWM_GRANULARITY (SOUTH_CHICKEN1, bit 0) controls the granularity > (minimum increment) of the PWM backlight control counter. PWM frequency > adjustment on 128 clock increments when this bit was 1. And 16 clock > increments when it was 0. > > PWM frequency multiple octuple (from 200Hz to 1.6KHz) due to > SPT_PWM_GRANULARITY was clear to 0 after S3. This patch save > SOUTH_CHICKEN1 register value before suspend. And will restore > it after i915 resume. Sorry, I updated the patch already https://patchwork.freedesktop.org/patch/111128/ https://patchwork.freedesktop.org/patch/111129/ BR, Jani. > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97486 > > Cc: Jani Nikula <jani.nikula@intel.com> > Reviewed-by: Cooper Chiou <cooper.chiou@intel.com> > Reviewed-by: Wei Shun Chen <wei.shun.chang@intel.com> > Reviewed-by: Gary C Wang <gary.c.wang@intel.com> > Signed-off-by: Shawn Lee <shawn.c.lee@intel.com> > --- > drivers/gpu/drm/i915/intel_drv.h | 1 + > drivers/gpu/drm/i915/intel_panel.c | 24 ++++++++++++++++++++++-- > 2 files changed, 23 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h > index 570a7ca..c4bc690 100644 > --- a/drivers/gpu/drm/i915/intel_drv.h > +++ b/drivers/gpu/drm/i915/intel_drv.h > @@ -256,6 +256,7 @@ struct intel_panel { > u32 level; > u32 min; > u32 max; > + bool pwm_alternate_increment; > bool enabled; > bool combination_mode; /* gen 2/4 only */ > bool active_low_pwm; > diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c > index c10e9b0..e1dc6bd 100644 > --- a/drivers/gpu/drm/i915/intel_panel.c > +++ b/drivers/gpu/drm/i915/intel_panel.c > @@ -841,7 +841,7 @@ static void lpt_enable_backlight(struct intel_connector *connector) > { > struct drm_i915_private *dev_priv = to_i915(connector->base.dev); > struct intel_panel *panel = &connector->panel; > - u32 pch_ctl1, pch_ctl2; > + u32 pch_ctl1, pch_ctl2, mul; > > pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1); > if (pch_ctl1 & BLM_PCH_PWM_ENABLE) { > @@ -867,6 +867,16 @@ static void lpt_enable_backlight(struct intel_connector *connector) > > /* This won't stick until the above enable. */ > intel_panel_actually_set_backlight(connector, panel->backlight.level); > + > + if (HAS_PCH_LPT(dev_priv)) { > + mul = I915_READ(SOUTH_CHICKEN2); > + mul &= ~LPT_PWM_GRANULARITY; > + I915_WRITE(SOUTH_CHICKEN2, mul | (panel->backlight.pwm_alternate_increment << LPT_PWM_GRANULARITY)); > + } else { > + mul = I915_READ(SOUTH_CHICKEN1); > + mul &= ~SPT_PWM_GRANULARITY; > + I915_WRITE(SOUTH_CHICKEN1, mul | (panel->backlight.pwm_alternate_increment << SPT_PWM_GRANULARITY)); > + } > } > > static void pch_enable_backlight(struct intel_connector *connector) > @@ -1413,7 +1423,7 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus > { > struct drm_i915_private *dev_priv = to_i915(connector->base.dev); > struct intel_panel *panel = &connector->panel; > - u32 pch_ctl1, pch_ctl2, val; > + u32 pch_ctl1, pch_ctl2, val, mul; > > pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1); > panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY; > @@ -1436,6 +1446,16 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus > > panel->backlight.enabled = pch_ctl1 & BLM_PCH_PWM_ENABLE; > > + if (HAS_PCH_LPT(dev_priv)) > + mul = I915_READ(SOUTH_CHICKEN2) & LPT_PWM_GRANULARITY; > + else > + mul = I915_READ(SOUTH_CHICKEN1) & SPT_PWM_GRANULARITY; > + > + if ( mul ) > + panel->backlight.pwm_alternate_increment = true; > + else > + panel->backlight.pwm_alternate_increment = false; > + > return 0; > }
On Mon, 19 Sep 2016, "Lee, Shawn C" <shawn.c.lee@intel.com> wrote: > + if (HAS_PCH_LPT(dev_priv)) { > + mul = I915_READ(SOUTH_CHICKEN2); > + mul &= ~LPT_PWM_GRANULARITY; > + I915_WRITE(SOUTH_CHICKEN2, mul | (panel->backlight.pwm_alternate_increment << LPT_PWM_GRANULARITY)); > + } else { > + mul = I915_READ(SOUTH_CHICKEN1); > + mul &= ~SPT_PWM_GRANULARITY; > + I915_WRITE(SOUTH_CHICKEN1, mul | (panel->backlight.pwm_alternate_increment << SPT_PWM_GRANULARITY)); > + } Also, both of the shifts are wrong here. The *_PWM_GRANULARITY macros already contain the shifts. BR, Jani.
Hi Shawn, [auto build test WARNING on drm-intel/for-linux-next] [also build test WARNING on v4.8-rc7 next-20160916] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information] url: https://github.com/0day-ci/linux/commits/Lee-Shawn-C/drm-i915-Restore-PWM_GRANULARITY-after-resume/20160919-180644 base: git://anongit.freedesktop.org/drm-intel for-linux-next config: x86_64-randconfig-x008-201638 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All warnings (new ones prefixed by >>): In file included from drivers/gpu/drm/i915/intel_drv.h:32:0, from drivers/gpu/drm/i915/intel_panel.c:36: drivers/gpu/drm/i915/intel_panel.c: In function 'lpt_enable_backlight': >> drivers/gpu/drm/i915/intel_panel.c:874:78: warning: left shift count >= width of type [-Wshift-count-overflow] I915_WRITE(SOUTH_CHICKEN2, mul | (panel->backlight.pwm_alternate_increment << LPT_PWM_GRANULARITY)); ^ drivers/gpu/drm/i915/i915_drv.h:3735:83: note: in definition of macro 'I915_WRITE' #define I915_WRITE(reg, val) dev_priv->uncore.funcs.mmio_writel(dev_priv, (reg), (val), true) ^~~ vim +874 drivers/gpu/drm/i915/intel_panel.c 858 pch_ctl1 |= BLM_PCH_POLARITY; 859 860 /* After LPT, override is the default. */ 861 if (HAS_PCH_LPT(dev_priv)) 862 pch_ctl1 |= BLM_PCH_OVERRIDE_ENABLE; 863 864 I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1); 865 POSTING_READ(BLC_PWM_PCH_CTL1); 866 I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1 | BLM_PCH_PWM_ENABLE); 867 868 /* This won't stick until the above enable. */ 869 intel_panel_actually_set_backlight(connector, panel->backlight.level); 870 871 if (HAS_PCH_LPT(dev_priv)) { 872 mul = I915_READ(SOUTH_CHICKEN2); 873 mul &= ~LPT_PWM_GRANULARITY; > 874 I915_WRITE(SOUTH_CHICKEN2, mul | (panel->backlight.pwm_alternate_increment << LPT_PWM_GRANULARITY)); 875 } else { 876 mul = I915_READ(SOUTH_CHICKEN1); 877 mul &= ~SPT_PWM_GRANULARITY; 878 I915_WRITE(SOUTH_CHICKEN1, mul | (panel->backlight.pwm_alternate_increment << SPT_PWM_GRANULARITY)); 879 } 880 } 881 882 static void pch_enable_backlight(struct intel_connector *connector) --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Shawn, [auto build test ERROR on drm-intel/for-linux-next] [also build test ERROR on v4.8-rc7 next-20160916] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] [Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information] url: https://github.com/0day-ci/linux/commits/Lee-Shawn-C/drm-i915-Restore-PWM_GRANULARITY-after-resume/20160919-180644 base: git://anongit.freedesktop.org/drm-intel for-linux-next config: x86_64-randconfig-x012-201638 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): In file included from drivers/gpu/drm/i915/intel_drv.h:32:0, from drivers/gpu/drm/i915/intel_panel.c:36: drivers/gpu/drm/i915/intel_panel.c: In function 'lpt_enable_backlight': >> drivers/gpu/drm/i915/intel_panel.c:874:78: error: left shift count >= width of type [-Werror=shift-count-overflow] I915_WRITE(SOUTH_CHICKEN2, mul | (panel->backlight.pwm_alternate_increment << LPT_PWM_GRANULARITY)); ^ drivers/gpu/drm/i915/i915_drv.h:3735:83: note: in definition of macro 'I915_WRITE' #define I915_WRITE(reg, val) dev_priv->uncore.funcs.mmio_writel(dev_priv, (reg), (val), true) ^~~ cc1: all warnings being treated as errors vim +874 drivers/gpu/drm/i915/intel_panel.c 868 /* This won't stick until the above enable. */ 869 intel_panel_actually_set_backlight(connector, panel->backlight.level); 870 871 if (HAS_PCH_LPT(dev_priv)) { 872 mul = I915_READ(SOUTH_CHICKEN2); 873 mul &= ~LPT_PWM_GRANULARITY; > 874 I915_WRITE(SOUTH_CHICKEN2, mul | (panel->backlight.pwm_alternate_increment << LPT_PWM_GRANULARITY)); 875 } else { 876 mul = I915_READ(SOUTH_CHICKEN1); 877 mul &= ~SPT_PWM_GRANULARITY; --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 570a7ca..c4bc690 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -256,6 +256,7 @@ struct intel_panel { u32 level; u32 min; u32 max; + bool pwm_alternate_increment; bool enabled; bool combination_mode; /* gen 2/4 only */ bool active_low_pwm; diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index c10e9b0..e1dc6bd 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c @@ -841,7 +841,7 @@ static void lpt_enable_backlight(struct intel_connector *connector) { struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct intel_panel *panel = &connector->panel; - u32 pch_ctl1, pch_ctl2; + u32 pch_ctl1, pch_ctl2, mul; pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1); if (pch_ctl1 & BLM_PCH_PWM_ENABLE) { @@ -867,6 +867,16 @@ static void lpt_enable_backlight(struct intel_connector *connector) /* This won't stick until the above enable. */ intel_panel_actually_set_backlight(connector, panel->backlight.level); + + if (HAS_PCH_LPT(dev_priv)) { + mul = I915_READ(SOUTH_CHICKEN2); + mul &= ~LPT_PWM_GRANULARITY; + I915_WRITE(SOUTH_CHICKEN2, mul | (panel->backlight.pwm_alternate_increment << LPT_PWM_GRANULARITY)); + } else { + mul = I915_READ(SOUTH_CHICKEN1); + mul &= ~SPT_PWM_GRANULARITY; + I915_WRITE(SOUTH_CHICKEN1, mul | (panel->backlight.pwm_alternate_increment << SPT_PWM_GRANULARITY)); + } } static void pch_enable_backlight(struct intel_connector *connector) @@ -1413,7 +1423,7 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus { struct drm_i915_private *dev_priv = to_i915(connector->base.dev); struct intel_panel *panel = &connector->panel; - u32 pch_ctl1, pch_ctl2, val; + u32 pch_ctl1, pch_ctl2, val, mul; pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1); panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY; @@ -1436,6 +1446,16 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus panel->backlight.enabled = pch_ctl1 & BLM_PCH_PWM_ENABLE; + if (HAS_PCH_LPT(dev_priv)) + mul = I915_READ(SOUTH_CHICKEN2) & LPT_PWM_GRANULARITY; + else + mul = I915_READ(SOUTH_CHICKEN1) & SPT_PWM_GRANULARITY; + + if ( mul ) + panel->backlight.pwm_alternate_increment = true; + else + panel->backlight.pwm_alternate_increment = false; + return 0; }