All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable
@ 2016-09-19  8:23 ` Jani Nikula
  0 siblings, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2016-09-19  8:23 UTC (permalink / raw)
  To: intel-gfx
  Cc: jani.nikula, Shawn Lee, Cooper Chiou, Wei Shun Chen, Gary C Wang, stable

From: Shawn Lee <shawn.c.lee@intel.com>

Backlight enable is supposed to do a full setup of the backlight. We
were missing the PWM alternate increment bit in the south chicken
registers on lpt+ pch. This potentially caused a PWM frequency change
when the chicken register value was lost e.g. on suspend.

v2 by Jani, rebase on the patch caching alt increment

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97486
Cc: Cooper Chiou <cooper.chiou@intel.com>
Cc: Wei Shun Chen <wei.shun.chang@intel.com>
Cc: Gary C Wang <gary.c.wang@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Shawn Lee <shawn.c.lee@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_panel.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 8bc43205d6a0..be4b4d546fd9 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, schicken;
 
 	pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
 	if (pch_ctl1 & BLM_PCH_PWM_ENABLE) {
@@ -850,6 +850,22 @@ static void lpt_enable_backlight(struct intel_connector *connector)
 		I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
 	}
 
+	if (HAS_PCH_LPT(dev_priv)) {
+		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);
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable
@ 2016-09-19  8:23 ` Jani Nikula
  0 siblings, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2016-09-19  8:23 UTC (permalink / raw)
  To: intel-gfx; +Cc: Cooper Chiou, jani.nikula, stable, Wei Shun Chen

From: Shawn Lee <shawn.c.lee@intel.com>

Backlight enable is supposed to do a full setup of the backlight. We
were missing the PWM alternate increment bit in the south chicken
registers on lpt+ pch. This potentially caused a PWM frequency change
when the chicken register value was lost e.g. on suspend.

v2 by Jani, rebase on the patch caching alt increment

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97486
Cc: Cooper Chiou <cooper.chiou@intel.com>
Cc: Wei Shun Chen <wei.shun.chang@intel.com>
Cc: Gary C Wang <gary.c.wang@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Shawn Lee <shawn.c.lee@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_panel.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 8bc43205d6a0..be4b4d546fd9 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, schicken;
 
 	pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
 	if (pch_ctl1 & BLM_PCH_PWM_ENABLE) {
@@ -850,6 +850,22 @@ static void lpt_enable_backlight(struct intel_connector *connector)
 		I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
 	}
 
+	if (HAS_PCH_LPT(dev_priv)) {
+		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);
 
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value
  2016-09-19  8:23 ` Jani Nikula
  (?)
@ 2016-09-19  8:24 ` Jani Nikula
  2016-09-19  8:24     ` Jani Nikula
  2016-09-19  9:18   ` [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value Lee, Shawn C
  -1 siblings, 2 replies; 12+ messages in thread
From: Jani Nikula @ 2016-09-19  8:24 UTC (permalink / raw)
  To: intel-gfx; +Cc: jani.nikula

This will also be needed later on when setting up the alternate
increment in backlight enable.

Cc: Shawn Lee <shawn.c.lee@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_drv.h   |  1 +
 drivers/gpu/drm/i915/intel_panel.c | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 8fd16adf069b..c3e65e515c9d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -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+ */
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index c10e9b0405e8..8bc43205d6a0 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -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;
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable
  2016-09-19  8:24 ` [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value Jani Nikula
@ 2016-09-19  8:24     ` Jani Nikula
  2016-09-19  9:18   ` [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value Lee, Shawn C
  1 sibling, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2016-09-19  8:24 UTC (permalink / raw)
  To: intel-gfx
  Cc: jani.nikula, Shawn Lee, Cooper Chiou, Wei Shun Chen, Gary C Wang, stable

From: Shawn Lee <shawn.c.lee@intel.com>

Backlight enable is supposed to do a full setup of the backlight. We
were missing the PWM alternate increment bit in the south chicken
registers on lpt+ pch. This potentially caused a PWM frequency change
when the chicken register value was lost e.g. on suspend.

v2 by Jani, rebase on the patch caching alt increment

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97486
Cc: Cooper Chiou <cooper.chiou@intel.com>
Cc: Wei Shun Chen <wei.shun.chang@intel.com>
Cc: Gary C Wang <gary.c.wang@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Shawn Lee <shawn.c.lee@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_panel.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 8bc43205d6a0..be4b4d546fd9 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, schicken;
 
 	pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
 	if (pch_ctl1 & BLM_PCH_PWM_ENABLE) {
@@ -850,6 +850,22 @@ static void lpt_enable_backlight(struct intel_connector *connector)
 		I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
 	}
 
+	if (HAS_PCH_LPT(dev_priv)) {
+		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);
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable
@ 2016-09-19  8:24     ` Jani Nikula
  0 siblings, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2016-09-19  8:24 UTC (permalink / raw)
  To: intel-gfx; +Cc: Cooper Chiou, jani.nikula, stable, Wei Shun Chen

From: Shawn Lee <shawn.c.lee@intel.com>

Backlight enable is supposed to do a full setup of the backlight. We
were missing the PWM alternate increment bit in the south chicken
registers on lpt+ pch. This potentially caused a PWM frequency change
when the chicken register value was lost e.g. on suspend.

v2 by Jani, rebase on the patch caching alt increment

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97486
Cc: Cooper Chiou <cooper.chiou@intel.com>
Cc: Wei Shun Chen <wei.shun.chang@intel.com>
Cc: Gary C Wang <gary.c.wang@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Shawn Lee <shawn.c.lee@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_panel.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 8bc43205d6a0..be4b4d546fd9 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, schicken;
 
 	pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
 	if (pch_ctl1 & BLM_PCH_PWM_ENABLE) {
@@ -850,6 +850,22 @@ static void lpt_enable_backlight(struct intel_connector *connector)
 		I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
 	}
 
+	if (HAS_PCH_LPT(dev_priv)) {
+		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);
 
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable
  2016-09-19  8:23 ` Jani Nikula
  (?)
  (?)
@ 2016-09-19  8:25 ` Jani Nikula
  -1 siblings, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2016-09-19  8:25 UTC (permalink / raw)
  To: intel-gfx; +Cc: Shawn Lee, Cooper Chiou, Wei Shun Chen, Gary C Wang, stable

On Mon, 19 Sep 2016, Jani Nikula <jani.nikula@intel.com> wrote:
> From: Shawn Lee <shawn.c.lee@intel.com>
>
> Backlight enable is supposed to do a full setup of the backlight. We
> were missing the PWM alternate increment bit in the south chicken
> registers on lpt+ pch. This potentially caused a PWM frequency change
> when the chicken register value was lost e.g. on suspend.
>
> v2 by Jani, rebase on the patch caching alt increment

Fat fingered this one, please ignore, and look at the two patches in
reply to this one. Sorry.

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable
  2016-09-19  8:24     ` Jani Nikula
@ 2016-09-19  8:32       ` Jani Nikula
  -1 siblings, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2016-09-19  8:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Shawn Lee, Cooper Chiou, Wei Shun Chen, Gary C Wang, stable

On Mon, 19 Sep 2016, Jani Nikula <jani.nikula@intel.com> wrote:
> From: Shawn Lee <shawn.c.lee@intel.com>
>
> Backlight enable is supposed to do a full setup of the backlight. We
> were missing the PWM alternate increment bit in the south chicken
> registers on lpt+ pch. This potentially caused a PWM frequency change
> when the chicken register value was lost e.g. on suspend.
>
> v2 by Jani, rebase on the patch caching alt increment
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97486

There's a good chance this'll also fix a bug long ago deemed
NOTOURBUG...

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67454

> Cc: Cooper Chiou <cooper.chiou@intel.com>
> Cc: Wei Shun Chen <wei.shun.chang@intel.com>
> Cc: Gary C Wang <gary.c.wang@intel.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Shawn Lee <shawn.c.lee@intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_panel.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index 8bc43205d6a0..be4b4d546fd9 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, schicken;
>  
>  	pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
>  	if (pch_ctl1 & BLM_PCH_PWM_ENABLE) {
> @@ -850,6 +850,22 @@ static void lpt_enable_backlight(struct intel_connector *connector)
>  		I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
>  	}
>  
> +	if (HAS_PCH_LPT(dev_priv)) {
> +		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);

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable
@ 2016-09-19  8:32       ` Jani Nikula
  0 siblings, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2016-09-19  8:32 UTC (permalink / raw)
  To: intel-gfx; +Cc: Cooper Chiou, stable, Wei Shun Chen

On Mon, 19 Sep 2016, Jani Nikula <jani.nikula@intel.com> wrote:
> From: Shawn Lee <shawn.c.lee@intel.com>
>
> Backlight enable is supposed to do a full setup of the backlight. We
> were missing the PWM alternate increment bit in the south chicken
> registers on lpt+ pch. This potentially caused a PWM frequency change
> when the chicken register value was lost e.g. on suspend.
>
> v2 by Jani, rebase on the patch caching alt increment
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97486

There's a good chance this'll also fix a bug long ago deemed
NOTOURBUG...

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=67454

> Cc: Cooper Chiou <cooper.chiou@intel.com>
> Cc: Wei Shun Chen <wei.shun.chang@intel.com>
> Cc: Gary C Wang <gary.c.wang@intel.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Shawn Lee <shawn.c.lee@intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_panel.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index 8bc43205d6a0..be4b4d546fd9 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, schicken;
>  
>  	pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
>  	if (pch_ctl1 & BLM_PCH_PWM_ENABLE) {
> @@ -850,6 +850,22 @@ static void lpt_enable_backlight(struct intel_connector *connector)
>  		I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
>  	}
>  
> +	if (HAS_PCH_LPT(dev_priv)) {
> +		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);

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value
  2016-09-19  8:24 ` [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value Jani Nikula
  2016-09-19  8:24     ` Jani Nikula
@ 2016-09-19  9:18   ` Lee, Shawn C
  2016-09-19  9:20     ` Jani Nikula
  1 sibling, 1 reply; 12+ messages in thread
From: Lee, Shawn C @ 2016-09-19  9:18 UTC (permalink / raw)
  To: Nikula, Jani, intel-gfx

PWM was enabled in bios. i915 driver will save max duty to panel->backlight.max.
So *_hz_to_pwm will not be called if backlight.max not zero. 

	pch_ctl2 = I915_READ(BLC_PWM_PCH_CTL2);
	panel->backlight.max = pch_ctl2 >> 16;

	if (!panel->backlight.max)
		panel->backlight.max = get_backlight_max_vbt(connector);

-----Original Message-----
From: Nikula, Jani 
Sent: Monday, September 19, 2016 4:24 PM
To: intel-gfx@lists.freedesktop.org
Cc: Nikula, Jani <jani.nikula@intel.com>; Lee, Shawn C <shawn.c.lee@intel.com>
Subject: [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value

This will also be needed later on when setting up the alternate increment in backlight enable.

Cc: Shawn Lee <shawn.c.lee@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_drv.h   |  1 +
 drivers/gpu/drm/i915/intel_panel.c | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 8fd16adf069b..c3e65e515c9d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -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+ */
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index c10e9b0405e8..8bc43205d6a0 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -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;
--
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value
  2016-09-19  9:18   ` [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value Lee, Shawn C
@ 2016-09-19  9:20     ` Jani Nikula
  0 siblings, 0 replies; 12+ messages in thread
From: Jani Nikula @ 2016-09-19  9:20 UTC (permalink / raw)
  To: Lee, Shawn C, intel-gfx

On Mon, 19 Sep 2016, "Lee, Shawn C" <shawn.c.lee@intel.com> wrote:
> PWM was enabled in bios. i915 driver will save max duty to panel->backlight.max.
> So *_hz_to_pwm will not be called if backlight.max not zero. 

And what difference does it make?

BR,
Jani.

>
> 	pch_ctl2 = I915_READ(BLC_PWM_PCH_CTL2);
> 	panel->backlight.max = pch_ctl2 >> 16;
>
> 	if (!panel->backlight.max)
> 		panel->backlight.max = get_backlight_max_vbt(connector);
>
> -----Original Message-----
> From: Nikula, Jani 
> Sent: Monday, September 19, 2016 4:24 PM
> To: intel-gfx@lists.freedesktop.org
> Cc: Nikula, Jani <jani.nikula@intel.com>; Lee, Shawn C <shawn.c.lee@intel.com>
> Subject: [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value
>
> This will also be needed later on when setting up the alternate increment in backlight enable.
>
> Cc: Shawn Lee <shawn.c.lee@intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_drv.h   |  1 +
>  drivers/gpu/drm/i915/intel_panel.c | 14 +++++++++++---
>  2 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 8fd16adf069b..c3e65e515c9d 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -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+ */
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index c10e9b0405e8..8bc43205d6a0 100644
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -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;
> --
> 2.1.4
>

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable
  2016-09-19  8:23 ` Jani Nikula
@ 2016-09-19 10:48   ` kbuild test robot
  -1 siblings, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2016-09-19 10:48 UTC (permalink / raw)
  To: Jani Nikula
  Cc: kbuild-all, intel-gfx, Cooper Chiou, jani.nikula, stable, Wei Shun Chen

[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]

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/Jani-Nikula/drm-i915-backlight-setup-backlight-pwm-alternate-increment-on-backlight-enable/20160919-181342
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 errors (new ones prefixed by >>):

   drivers/gpu/drm/i915/intel_panel.c: In function 'lpt_enable_backlight':
>> drivers/gpu/drm/i915/intel_panel.c:855:23: error: 'struct <anonymous>' has no member named 'alternate_pwm_increment'
      if (panel->backlight.alternate_pwm_increment)
                          ^
   drivers/gpu/drm/i915/intel_panel.c:862:23: error: 'struct <anonymous>' has no member named 'alternate_pwm_increment'
      if (panel->backlight.alternate_pwm_increment)
                          ^

vim +855 drivers/gpu/drm/i915/intel_panel.c

   849			pch_ctl1 &= ~BLM_PCH_PWM_ENABLE;
   850			I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
   851		}
   852	
   853		if (HAS_PCH_LPT(dev_priv)) {
   854			schicken = I915_READ(SOUTH_CHICKEN2);
 > 855			if (panel->backlight.alternate_pwm_increment)
   856				schicken |= LPT_PWM_GRANULARITY;
   857			else
   858				schicken &= ~LPT_PWM_GRANULARITY;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27646 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Intel-gfx] [PATCH] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable
@ 2016-09-19 10:48   ` kbuild test robot
  0 siblings, 0 replies; 12+ messages in thread
From: kbuild test robot @ 2016-09-19 10:48 UTC (permalink / raw)
  Cc: kbuild-all, intel-gfx, Cooper Chiou, jani.nikula, stable, Wei Shun Chen

[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]

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/Jani-Nikula/drm-i915-backlight-setup-backlight-pwm-alternate-increment-on-backlight-enable/20160919-181342
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 errors (new ones prefixed by >>):

   drivers/gpu/drm/i915/intel_panel.c: In function 'lpt_enable_backlight':
>> drivers/gpu/drm/i915/intel_panel.c:855:23: error: 'struct <anonymous>' has no member named 'alternate_pwm_increment'
      if (panel->backlight.alternate_pwm_increment)
                          ^
   drivers/gpu/drm/i915/intel_panel.c:862:23: error: 'struct <anonymous>' has no member named 'alternate_pwm_increment'
      if (panel->backlight.alternate_pwm_increment)
                          ^

vim +855 drivers/gpu/drm/i915/intel_panel.c

   849			pch_ctl1 &= ~BLM_PCH_PWM_ENABLE;
   850			I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
   851		}
   852	
   853		if (HAS_PCH_LPT(dev_priv)) {
   854			schicken = I915_READ(SOUTH_CHICKEN2);
 > 855			if (panel->backlight.alternate_pwm_increment)
   856				schicken |= LPT_PWM_GRANULARITY;
   857			else
   858				schicken &= ~LPT_PWM_GRANULARITY;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27646 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-09-19 10:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19  8:23 [PATCH] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable Jani Nikula
2016-09-19  8:23 ` Jani Nikula
2016-09-19  8:24 ` [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value Jani Nikula
2016-09-19  8:24   ` [PATCH v2 2/2] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable Jani Nikula
2016-09-19  8:24     ` Jani Nikula
2016-09-19  8:32     ` Jani Nikula
2016-09-19  8:32       ` Jani Nikula
2016-09-19  9:18   ` [PATCH v2 1/2] drm/i915/backlight: setup and cache pwm alternate increment value Lee, Shawn C
2016-09-19  9:20     ` Jani Nikula
2016-09-19  8:25 ` [PATCH] drm/i915/backlight: setup backlight pwm alternate increment on backlight enable Jani Nikula
2016-09-19 10:48 ` [Intel-gfx] " kbuild test robot
2016-09-19 10:48   ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.