public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 11/13] drm/i915: do full backlight setup at enable time
Date: Thu, 14 Nov 2013 12:46:51 +0200	[thread overview]
Message-ID: <1384426011.30482.0.camel@intelbox> (raw)
In-Reply-To: <1384424021-14983-1-git-send-email-jani.nikula@intel.com>


[-- Attachment #1.1: Type: text/plain, Size: 7527 bytes --]

On Thu, 2013-11-14 at 12:13 +0200, Jani Nikula wrote:
> We should now have all the information we need to do a full
> initialization of the backlight registers.
> 
> v2: Keep QUIRK_NO_PCH_PWM_ENABLE for now (Imre).
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Looks ok:
Reviewed-by: Imre Deak <imre.deak@intel.com>

> ---
>  drivers/gpu/drm/i915/intel_panel.c |  149 ++++++++++++++++++++++--------------
>  1 file changed, 93 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
> index 0e8f0a3..0986472 100644
> --- a/drivers/gpu/drm/i915/intel_panel.c
> +++ b/drivers/gpu/drm/i915/intel_panel.c
> @@ -719,50 +719,75 @@ static void pch_enable_backlight(struct intel_connector *connector)
>  	enum pipe pipe = intel_get_pipe_from_connector(connector);
>  	enum transcoder cpu_transcoder =
>  		intel_pipe_to_cpu_transcoder(dev_priv, pipe);
> -	u32 tmp;
> -
> -	tmp = I915_READ(BLC_PWM_CPU_CTL2);
> +	u32 cpu_ctl2, pch_ctl1, pch_ctl2;
>  
> -	/* Note that this can also get called through dpms changes. And
> -	 * we don't track the backlight dpms state, hence check whether
> -	 * we have to do anything first. */
> -	if (tmp & BLM_PWM_ENABLE)
> -		return;
> +	cpu_ctl2 = I915_READ(BLC_PWM_CPU_CTL2);
> +	if (cpu_ctl2 & BLM_PWM_ENABLE) {
> +		WARN(1, "cpu backlight already enabled\n");
> +		cpu_ctl2 &= ~BLM_PWM_ENABLE;
> +		I915_WRITE(BLC_PWM_CPU_CTL2, cpu_ctl2);
> +	}
>  
> -	if (INTEL_INFO(dev)->num_pipes == 3)
> -		tmp &= ~BLM_PIPE_SELECT_IVB;
> -	else
> -		tmp &= ~BLM_PIPE_SELECT;
> +	pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
> +	if (pch_ctl1 & BLM_PCH_PWM_ENABLE) {
> +		DRM_DEBUG_KMS("pch backlight already enabled\n");
> +		pch_ctl1 &= ~BLM_PCH_PWM_ENABLE;
> +		I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
> +	}
>  
>  	if (cpu_transcoder == TRANSCODER_EDP)
> -		tmp |= BLM_TRANSCODER_EDP;
> +		cpu_ctl2 = BLM_TRANSCODER_EDP;
>  	else
> -		tmp |= BLM_PIPE(cpu_transcoder);
> -	tmp &= ~BLM_PWM_ENABLE;
> -
> -	I915_WRITE(BLC_PWM_CPU_CTL2, tmp);
> +		cpu_ctl2 = BLM_PIPE(cpu_transcoder);
> +	I915_WRITE(BLC_PWM_CPU_CTL2, cpu_ctl2);
>  	POSTING_READ(BLC_PWM_CPU_CTL2);
> -	I915_WRITE(BLC_PWM_CPU_CTL2, tmp | BLM_PWM_ENABLE);
> -
> -	if (!(dev_priv->quirks & QUIRK_NO_PCH_PWM_ENABLE)) {
> -		tmp = I915_READ(BLC_PWM_PCH_CTL1);
> -		tmp |= BLM_PCH_PWM_ENABLE;
> -		tmp &= ~BLM_PCH_OVERRIDE_ENABLE;
> -		I915_WRITE(BLC_PWM_PCH_CTL1, tmp);
> -	}
> +	I915_WRITE(BLC_PWM_CPU_CTL2, cpu_ctl2 | BLM_PWM_ENABLE);
>  
> -	/*
> -	 * Call below after setting BLC_PWM_CPU_CTL2 and BLC_PWM_PCH_CTL1.
> -	 * BLC_PWM_CPU_CTL may be cleared to zero automatically when these
> -	 * registers are set.
> -	 */
> +	/* This won't stick until the above enable. */
>  	intel_panel_actually_set_backlight(connector, panel->backlight.level);
> +
> +	pch_ctl2 = panel->backlight.max << 16;
> +	I915_WRITE(BLC_PWM_PCH_CTL2, pch_ctl2);
> +
> +	/* XXX: transitional */
> +	if (dev_priv->quirks & QUIRK_NO_PCH_PWM_ENABLE)
> +		return;
> +
> +	pch_ctl1 = 0;
> +	if (panel->backlight.active_low_pwm)
> +		pch_ctl1 |= BLM_PCH_POLARITY;
> +	I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
> +	POSTING_READ(BLC_PWM_PCH_CTL1);
> +	I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1 | BLM_PCH_PWM_ENABLE);
>  }
>  
>  static void i9xx_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 ctl, freq;
> +
> +	ctl = I915_READ(BLC_PWM_CTL);
> +	if (ctl & BACKLIGHT_DUTY_CYCLE_MASK_PNV) {
> +		WARN(1, "backlight already enabled\n");
> +		I915_WRITE(BLC_PWM_CTL, 0);
> +	}
>  
> +	freq = panel->backlight.max;
> +	if (panel->backlight.combination_mode)
> +		freq /= 0xff;
> +
> +	ctl = freq << 17;
> +	if (IS_GEN2(dev) && panel->backlight.combination_mode)
> +		ctl |= BLM_LEGACY_MODE;
> +	if (IS_PINEVIEW(dev) && panel->backlight.active_low_pwm)
> +		ctl |= BLM_POLARITY_PNV;
> +
> +	I915_WRITE(BLC_PWM_CTL, ctl);
> +	POSTING_READ(BLC_PWM_CTL);
> +
> +	/* XXX: combine this into above write? */
>  	intel_panel_actually_set_backlight(connector, panel->backlight.level);
>  }
>  
> @@ -772,25 +797,33 @@ static void i965_enable_backlight(struct intel_connector *connector)
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct intel_panel *panel = &connector->panel;
>  	enum pipe pipe = intel_get_pipe_from_connector(connector);
> -	u32 tmp;
> +	u32 ctl, ctl2, freq;
>  
> -	tmp = I915_READ(BLC_PWM_CTL2);
> +	ctl2 = I915_READ(BLC_PWM_CTL2);
> +	if (ctl2 & BLM_PWM_ENABLE) {
> +		WARN(1, "backlight already enabled\n");
> +		ctl2 &= ~BLM_PWM_ENABLE;
> +		I915_WRITE(BLC_PWM_CTL2, ctl2);
> +	}
>  
> -	/* Note that this can also get called through dpms changes. And
> -	 * we don't track the backlight dpms state, hence check whether
> -	 * we have to do anything first. */
> -	if (tmp & BLM_PWM_ENABLE)
> -		return;
> +	freq = panel->backlight.max;
> +	if (panel->backlight.combination_mode)
> +		freq /= 0xff;
>  
> -	tmp &= ~BLM_PIPE_SELECT;
> -	tmp |= BLM_PIPE(pipe);
> -	tmp &= ~BLM_PWM_ENABLE;
> -
> -	I915_WRITE(BLC_PWM_CTL2, tmp);
> -	POSTING_READ(BLC_PWM_CTL2);
> -	I915_WRITE(BLC_PWM_CTL2, tmp | BLM_PWM_ENABLE);
> +	ctl = freq << 16;
> +	I915_WRITE(BLC_PWM_CTL, ctl);
>  
> +	/* XXX: combine this into above write? */
>  	intel_panel_actually_set_backlight(connector, panel->backlight.level);
> +
> +	ctl2 = BLM_PIPE(pipe);
> +	if (panel->backlight.combination_mode)
> +		ctl2 |= BLM_COMBINATION_MODE;
> +	if (panel->backlight.active_low_pwm)
> +		ctl2 |= BLM_POLARITY_I965;
> +	I915_WRITE(BLC_PWM_CTL2, ctl2);
> +	POSTING_READ(BLC_PWM_CTL2);
> +	I915_WRITE(BLC_PWM_CTL2, ctl2 | BLM_PWM_ENABLE);
>  }
>  
>  static void vlv_enable_backlight(struct intel_connector *connector)
> @@ -799,23 +832,27 @@ static void vlv_enable_backlight(struct intel_connector *connector)
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct intel_panel *panel = &connector->panel;
>  	enum pipe pipe = intel_get_pipe_from_connector(connector);
> -	u32 tmp;
> +	u32 ctl, ctl2;
>  
> -	tmp = I915_READ(VLV_BLC_PWM_CTL2(pipe));
> +	ctl2 = I915_READ(VLV_BLC_PWM_CTL2(pipe));
> +	if (ctl2 & BLM_PWM_ENABLE) {
> +		WARN(1, "backlight already enabled\n");
> +		ctl2 &= ~BLM_PWM_ENABLE;
> +		I915_WRITE(VLV_BLC_PWM_CTL2(pipe), ctl2);
> +	}
>  
> -	/* Note that this can also get called through dpms changes. And
> -	 * we don't track the backlight dpms state, hence check whether
> -	 * we have to do anything first. */
> -	if (tmp & BLM_PWM_ENABLE)
> -		return;
> +	ctl = panel->backlight.max << 16;
> +	I915_WRITE(VLV_BLC_PWM_CTL(pipe), ctl);
>  
> -	tmp &= ~BLM_PWM_ENABLE;
> +	/* XXX: combine this into above write? */
> +	intel_panel_actually_set_backlight(connector, panel->backlight.level);
>  
> -	I915_WRITE(VLV_BLC_PWM_CTL2(pipe), tmp);
> +	ctl2 = 0;
> +	if (panel->backlight.active_low_pwm)
> +		ctl2 |= BLM_POLARITY_I965;
> +	I915_WRITE(VLV_BLC_PWM_CTL2(pipe), ctl2);
>  	POSTING_READ(VLV_BLC_PWM_CTL2(pipe));
> -	I915_WRITE(VLV_BLC_PWM_CTL2(pipe), tmp | BLM_PWM_ENABLE);
> -
> -	intel_panel_actually_set_backlight(connector, panel->backlight.level);
> +	I915_WRITE(VLV_BLC_PWM_CTL2(pipe), ctl2 | BLM_PWM_ENABLE);
>  }
>  
>  void intel_panel_enable_backlight(struct intel_connector *connector)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

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

  reply	other threads:[~2013-11-14 10:46 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-08 14:48 [PATCH 00/13] drm/i915: backlight rewrite Jani Nikula
2013-11-08 14:48 ` [PATCH 01/13] drm/i915: clean up backlight conditional build Jani Nikula
2013-11-12 21:23   ` Imre Deak
2013-11-08 14:48 ` [PATCH 02/13] drm/i915: make backlight info per-connector Jani Nikula
2013-11-12 21:29   ` Imre Deak
2013-11-08 14:48 ` [PATCH 03/13] drm/i915: make asle notifications update backlight on all connectors Jani Nikula
2013-11-12 21:29   ` Imre Deak
2013-11-08 14:48 ` [PATCH 04/13] drm/i915: handle backlight through chip specific functions Jani Nikula
2013-11-12 21:36   ` Imre Deak
2013-11-12 23:19     ` Daniel Vetter
2013-11-08 14:48 ` [PATCH 05/13] drm/i915: fix gen2-gen3 backlight set Jani Nikula
2013-11-12 22:00   ` Imre Deak
2013-11-13  8:27     ` Jani Nikula
2013-11-13  9:04       ` Daniel Vetter
2013-11-13  9:12       ` Imre Deak
2013-11-08 14:48 ` [PATCH 06/13] drm/i915: vlv does not have pipe field in backlight registers Jani Nikula
2013-11-12 22:00   ` Imre Deak
2013-11-08 14:48 ` [PATCH 07/13] drm/i915: move backlight level setting in enable/disable to hooks Jani Nikula
2013-11-12 22:01   ` Imre Deak
2013-11-08 14:49 ` [PATCH 08/13] drm/i915: use the initialized backlight max value instead of reading it Jani Nikula
2013-11-12 22:42   ` Imre Deak
2013-11-13  8:39     ` Jani Nikula
2013-11-13  9:12       ` Daniel Vetter
2013-11-08 14:49 ` [PATCH 09/13] drm/i915: debug print on backlight register Jani Nikula
2013-11-12 22:48   ` Imre Deak
2013-11-13 10:22     ` Daniel Vetter
2013-11-08 14:49 ` [PATCH 10/13] drm/i915: gather backlight information at setup Jani Nikula
2013-11-13 17:01   ` Imre Deak
2013-11-14  5:19     ` Jani Nikula
2013-11-14  8:22       ` Imre Deak
2013-11-08 14:49 ` [PATCH 11/13] drm/i915: do full backlight setup at enable time Jani Nikula
2013-11-13 17:53   ` Imre Deak
2013-11-14  5:43     ` Jani Nikula
2013-11-14  8:27       ` Daniel Vetter
2013-11-14  8:28       ` Imre Deak
2013-11-14 10:13   ` [PATCH v2 " Jani Nikula
2013-11-14 10:46     ` Imre Deak [this message]
2013-11-14 10:14   ` [PATCH 11.5/13] drm/i915: remove QUIRK_NO_PCH_PWM_ENABLE Jani Nikula
2013-11-14 10:50     ` Imre Deak
2013-11-08 14:49 ` [PATCH 12/13] drm/i915: nuke get max backlight functions Jani Nikula
2013-11-13 17:54   ` Imre Deak
2013-11-08 14:49 ` [PATCH 13/13] drm/i915: do not save/restore backlight registers Jani Nikula
2013-11-12 23:25   ` Daniel Vetter
2013-11-13  8:40     ` Jani Nikula
2013-11-13 10:56     ` [PATCH v2] drm/i915: do not save/restore backlight registers in KMS Jani Nikula
2013-11-13 18:05       ` Imre Deak
2013-11-14 11:22         ` Daniel Vetter
2013-11-11  8:36 ` [PATCH 00/13] drm/i915: backlight rewrite Jani Nikula
2013-11-12 21:22 ` Imre Deak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384426011.30482.0.camel@intelbox \
    --to=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox