diff mbox

[08/58] drm/i915/crt: convert to encoder disable/enable

Message ID 1345403595-9678-9-git-send-email-daniel.vetter@ffwll.ch (mailing list archive)
State Accepted
Headers show

Commit Message

Daniel Vetter Aug. 19, 2012, 7:12 p.m. UTC
CRT is the first output which can be cloned, hence we cannot (yet)
move the dpms handling over to disable/enable. This requires some more
smarts in intel_crtc_dpms first to set the display pipe status
depening upon encoder->connectors_active of all connected encoders.

Because that will happen in a separate step, don't touch the dpms
functions, yet.

v2: Be careful about clearing the _DISABLE flags for intermediate dpms
modes - otherwise we might clobber the crt state when another (cloned)
connector gets enabled.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/intel_crt.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

Comments

Jesse Barnes Sept. 4, 2012, 7:50 p.m. UTC | #1
On Sun, 19 Aug 2012 21:12:25 +0200
Daniel Vetter <daniel.vetter@ffwll.ch> wrote:

> CRT is the first output which can be cloned, hence we cannot (yet)
> move the dpms handling over to disable/enable. This requires some more
> smarts in intel_crtc_dpms first to set the display pipe status
> depening upon encoder->connectors_active of all connected encoders.
> 
> Because that will happen in a separate step, don't touch the dpms
> functions, yet.
> 
> v2: Be careful about clearing the _DISABLE flags for intermediate dpms
> modes - otherwise we might clobber the crt state when another (cloned)
> connector gets enabled.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/i915/intel_crt.c | 36 ++++++++++++++++++++++++++++++++----
>  1 file changed, 32 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
> index 1d05b2d..543ea40 100644
> --- a/drivers/gpu/drm/i915/intel_crt.c
> +++ b/drivers/gpu/drm/i915/intel_crt.c
> @@ -61,6 +61,29 @@ static struct intel_crt *intel_encoder_to_crt(struct intel_encoder *encoder)
>  	return container_of(encoder, struct intel_crt, base);
>  }
>  
> +static void intel_disable_crt(struct intel_encoder *encoder)
> +{
> +	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
> +	struct intel_crt *crt = intel_encoder_to_crt(encoder);
> +	u32 temp;
> +
> +	temp = I915_READ(crt->adpa_reg);
> +	temp &= ~(ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE);
> +	temp &= ~ADPA_DAC_ENABLE;
> +	I915_WRITE(crt->adpa_reg, temp);
> +}
> +
> +static void intel_enable_crt(struct intel_encoder *encoder)
> +{
> +	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
> +	struct intel_crt *crt = intel_encoder_to_crt(encoder);
> +	u32 temp;
> +
> +	temp = I915_READ(crt->adpa_reg);
> +	temp |= ADPA_DAC_ENABLE;
> +	I915_WRITE(crt->adpa_reg, temp);
> +}
> +
>  static void pch_crt_dpms(struct drm_encoder *encoder, int mode)
>  {
>  	struct drm_device *dev = encoder->dev;
> @@ -575,18 +598,20 @@ static void intel_crt_reset(struct drm_connector *connector)
>  
>  static const struct drm_encoder_helper_funcs pch_encoder_funcs = {
>  	.mode_fixup = intel_crt_mode_fixup,
> -	.prepare = intel_encoder_prepare,
> -	.commit = intel_encoder_commit,
> +	.prepare = intel_encoder_noop,
> +	.commit = intel_encoder_noop,
>  	.mode_set = intel_crt_mode_set,
>  	.dpms = pch_crt_dpms,
> +	.disable = intel_encoder_disable,
>  };
>  
>  static const struct drm_encoder_helper_funcs gmch_encoder_funcs = {
>  	.mode_fixup = intel_crt_mode_fixup,
> -	.prepare = intel_encoder_prepare,
> -	.commit = intel_encoder_commit,
> +	.prepare = intel_encoder_noop,
> +	.commit = intel_encoder_noop,
>  	.mode_set = intel_crt_mode_set,
>  	.dpms = gmch_crt_dpms,
> +	.disable = intel_encoder_disable,
>  };
>  
>  static const struct drm_connector_funcs intel_crt_connector_funcs = {
> @@ -682,6 +707,9 @@ void intel_crt_init(struct drm_device *dev)
>  	else
>  		crt->adpa_reg = ADPA;
>  
> +	crt->base.disable = intel_disable_crt;
> +	crt->base.enable = intel_enable_crt;
> +
>  	drm_encoder_helper_add(&crt->base.base, encoder_helper_funcs);
>  	drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
>  

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 1d05b2d..543ea40 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -61,6 +61,29 @@  static struct intel_crt *intel_encoder_to_crt(struct intel_encoder *encoder)
 	return container_of(encoder, struct intel_crt, base);
 }
 
+static void intel_disable_crt(struct intel_encoder *encoder)
+{
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	struct intel_crt *crt = intel_encoder_to_crt(encoder);
+	u32 temp;
+
+	temp = I915_READ(crt->adpa_reg);
+	temp &= ~(ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE);
+	temp &= ~ADPA_DAC_ENABLE;
+	I915_WRITE(crt->adpa_reg, temp);
+}
+
+static void intel_enable_crt(struct intel_encoder *encoder)
+{
+	struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
+	struct intel_crt *crt = intel_encoder_to_crt(encoder);
+	u32 temp;
+
+	temp = I915_READ(crt->adpa_reg);
+	temp |= ADPA_DAC_ENABLE;
+	I915_WRITE(crt->adpa_reg, temp);
+}
+
 static void pch_crt_dpms(struct drm_encoder *encoder, int mode)
 {
 	struct drm_device *dev = encoder->dev;
@@ -575,18 +598,20 @@  static void intel_crt_reset(struct drm_connector *connector)
 
 static const struct drm_encoder_helper_funcs pch_encoder_funcs = {
 	.mode_fixup = intel_crt_mode_fixup,
-	.prepare = intel_encoder_prepare,
-	.commit = intel_encoder_commit,
+	.prepare = intel_encoder_noop,
+	.commit = intel_encoder_noop,
 	.mode_set = intel_crt_mode_set,
 	.dpms = pch_crt_dpms,
+	.disable = intel_encoder_disable,
 };
 
 static const struct drm_encoder_helper_funcs gmch_encoder_funcs = {
 	.mode_fixup = intel_crt_mode_fixup,
-	.prepare = intel_encoder_prepare,
-	.commit = intel_encoder_commit,
+	.prepare = intel_encoder_noop,
+	.commit = intel_encoder_noop,
 	.mode_set = intel_crt_mode_set,
 	.dpms = gmch_crt_dpms,
+	.disable = intel_encoder_disable,
 };
 
 static const struct drm_connector_funcs intel_crt_connector_funcs = {
@@ -682,6 +707,9 @@  void intel_crt_init(struct drm_device *dev)
 	else
 		crt->adpa_reg = ADPA;
 
+	crt->base.disable = intel_disable_crt;
+	crt->base.enable = intel_enable_crt;
+
 	drm_encoder_helper_add(&crt->base.base, encoder_helper_funcs);
 	drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);