drm/i915/backlight: setup and cache pwm alternate increment value
authorJani Nikula <jani.nikula@intel.com>
Mon, 19 Sep 2016 10:35:25 +0000 (13:35 +0300)
committerJani Nikula <jani.nikula@intel.com>
Mon, 10 Oct 2016 13:04:59 +0000 (16:04 +0300)
This will also be needed later on when setting up the alternate
increment in backlight enable.

Cc: Shawn Lee <shawn.c.lee@intel.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/9984b20bc59aee90b83caf59ce91f3fb122c9627.1474281249.git.jani.nikula@intel.com
(cherry picked from commit 32b421e79e6b546da1d469f1229403ac9142d695)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_panel.c

index 8fd16adf069b2f894d0eb1d65d662e39754fbaf4..c3e65e515c9d515e0c35aa690f95734ae55be2a1 100644 (file)
@@ -263,6 +263,7 @@ struct intel_panel {
                bool enabled;
                bool combination_mode;  /* gen 2/4 only */
                bool active_low_pwm;
+               bool alternate_pwm_increment;   /* lpt+ */
 
                /* PWM chip */
                bool util_pin_active_low;       /* bxt+ */
index c10e9b0405e8035d96d990286a65ed37bc550a39..8bc43205d6a0074a7f3b54251bd3d06f42174c82 100644 (file)
@@ -1242,10 +1242,10 @@ static u32 bxt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
  */
 static u32 spt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
 {
-       struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+       struct intel_panel *panel = &connector->panel;
        u32 mul;
 
-       if (I915_READ(SOUTH_CHICKEN1) & SPT_PWM_GRANULARITY)
+       if (panel->backlight.alternate_pwm_increment)
                mul = 128;
        else
                mul = 16;
@@ -1261,9 +1261,10 @@ static u32 spt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
 static u32 lpt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
 {
        struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+       struct intel_panel *panel = &connector->panel;
        u32 mul, clock;
 
-       if (I915_READ(SOUTH_CHICKEN2) & LPT_PWM_GRANULARITY)
+       if (panel->backlight.alternate_pwm_increment)
                mul = 16;
        else
                mul = 128;
@@ -1414,6 +1415,13 @@ 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;
+       bool alt;
+
+       if (HAS_PCH_LPT(dev_priv))
+               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;