All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 18/43] drm/i915: simplify dvo dpms interface
Date: Tue,  3 Jul 2012 11:28:10 +0200	[thread overview]
Message-ID: <1341307715-3886-19-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1341307715-3886-1-git-send-email-daniel.vetter@ffwll.ch>

All dvo drivers only support 2 dpms states, and our dvo driver
even switches of the dvo port for anything else than DPMS_ON. Hence
ditch this complexity and simply use bool enable.

While reading through this code I've noticed that the mode_set
function of ch7017 is a bit peculiar - it disable the lvds again, even
though the crtc helper code should have done that ... This might be to
work around an issue at driver load, we pretty much ignore the hw
state when taking over.

Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/dvo.h        |    9 ++++-----
 drivers/gpu/drm/i915/dvo_ch7017.c |    8 ++++----
 drivers/gpu/drm/i915/dvo_ch7xxx.c |    4 ++--
 drivers/gpu/drm/i915/dvo_ivch.c   |    8 ++++----
 drivers/gpu/drm/i915/dvo_sil164.c |    4 ++--
 drivers/gpu/drm/i915/dvo_tfp410.c |    4 ++--
 drivers/gpu/drm/i915/intel_dvo.c  |    4 ++--
 7 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/i915/dvo.h b/drivers/gpu/drm/i915/dvo.h
index 8c2ad01..8efec6d 100644
--- a/drivers/gpu/drm/i915/dvo.h
+++ b/drivers/gpu/drm/i915/dvo.h
@@ -58,13 +58,12 @@ struct intel_dvo_dev_ops {
 	void (*create_resources)(struct intel_dvo_device *dvo);
 
 	/*
-	 * Turn on/off output or set intermediate power levels if available.
+	 * Turn on/off output.
 	 *
-	 * Unsupported intermediate modes drop to the lower power setting.
-	 * If the  mode is DPMSModeOff, the output must be disabled,
-	 * as the DPLL may be disabled afterwards.
+	 * Because none of our dvo drivers support an intermediate power levels,
+	 * we don't expose this in the interfac.
 	 */
-	void (*dpms)(struct intel_dvo_device *dvo, int mode);
+	void (*dpms)(struct intel_dvo_device *dvo, bool enable);
 
 	/*
 	 * Callback for testing a video mode for a given output.
diff --git a/drivers/gpu/drm/i915/dvo_ch7017.c b/drivers/gpu/drm/i915/dvo_ch7017.c
index 1ca799a..71e7650 100644
--- a/drivers/gpu/drm/i915/dvo_ch7017.c
+++ b/drivers/gpu/drm/i915/dvo_ch7017.c
@@ -163,7 +163,7 @@ struct ch7017_priv {
 };
 
 static void ch7017_dump_regs(struct intel_dvo_device *dvo);
-static void ch7017_dpms(struct intel_dvo_device *dvo, int mode);
+static void ch7017_dpms(struct intel_dvo_device *dvo, bool enable);
 
 static bool ch7017_read(struct intel_dvo_device *dvo, u8 addr, u8 *val)
 {
@@ -309,7 +309,7 @@ static void ch7017_mode_set(struct intel_dvo_device *dvo,
 	lvds_power_down = CH7017_LVDS_POWER_DOWN_DEFAULT_RESERVED |
 			  (mode->hdisplay & 0x0700) >> 8;
 
-	ch7017_dpms(dvo, DRM_MODE_DPMS_OFF);
+	ch7017_dpms(dvo, false);
 	ch7017_write(dvo, CH7017_HORIZONTAL_ACTIVE_PIXEL_INPUT,
 			horizontal_active_pixel_input);
 	ch7017_write(dvo, CH7017_HORIZONTAL_ACTIVE_PIXEL_OUTPUT,
@@ -331,7 +331,7 @@ static void ch7017_mode_set(struct intel_dvo_device *dvo,
 }
 
 /* set the CH7017 power state */
-static void ch7017_dpms(struct intel_dvo_device *dvo, int mode)
+static void ch7017_dpms(struct intel_dvo_device *dvo, bool enable)
 {
 	uint8_t val;
 
@@ -345,7 +345,7 @@ static void ch7017_dpms(struct intel_dvo_device *dvo, int mode)
 			CH7017_DAC3_POWER_DOWN |
 			CH7017_TV_POWER_DOWN_EN);
 
-	if (mode == DRM_MODE_DPMS_ON) {
+	if (enable) {
 		/* Turn on the LVDS */
 		ch7017_write(dvo, CH7017_LVDS_POWER_DOWN,
 			     val & ~CH7017_LVDS_POWER_DOWN_EN);
diff --git a/drivers/gpu/drm/i915/dvo_ch7xxx.c b/drivers/gpu/drm/i915/dvo_ch7xxx.c
index 4a03660..c1dea5b 100644
--- a/drivers/gpu/drm/i915/dvo_ch7xxx.c
+++ b/drivers/gpu/drm/i915/dvo_ch7xxx.c
@@ -289,9 +289,9 @@ static void ch7xxx_mode_set(struct intel_dvo_device *dvo,
 }
 
 /* set the CH7xxx power state */
-static void ch7xxx_dpms(struct intel_dvo_device *dvo, int mode)
+static void ch7xxx_dpms(struct intel_dvo_device *dvo, bool enable)
 {
-	if (mode == DRM_MODE_DPMS_ON)
+	if (enable)
 		ch7xxx_writeb(dvo, CH7xxx_PM, CH7xxx_PM_DVIL | CH7xxx_PM_DVIP);
 	else
 		ch7xxx_writeb(dvo, CH7xxx_PM, CH7xxx_PM_FPD);
diff --git a/drivers/gpu/drm/i915/dvo_ivch.c b/drivers/gpu/drm/i915/dvo_ivch.c
index 04f2893..fa8ff6b 100644
--- a/drivers/gpu/drm/i915/dvo_ivch.c
+++ b/drivers/gpu/drm/i915/dvo_ivch.c
@@ -288,7 +288,7 @@ static enum drm_mode_status ivch_mode_valid(struct intel_dvo_device *dvo,
 }
 
 /** Sets the power state of the panel connected to the ivch */
-static void ivch_dpms(struct intel_dvo_device *dvo, int mode)
+static void ivch_dpms(struct intel_dvo_device *dvo, bool enable)
 {
 	int i;
 	uint16_t vr01, vr30, backlight;
@@ -297,13 +297,13 @@ static void ivch_dpms(struct intel_dvo_device *dvo, int mode)
 	if (!ivch_read(dvo, VR01, &vr01))
 		return;
 
-	if (mode == DRM_MODE_DPMS_ON)
+	if (enable)
 		backlight = 1;
 	else
 		backlight = 0;
 	ivch_write(dvo, VR80, backlight);
 
-	if (mode == DRM_MODE_DPMS_ON)
+	if (enable)
 		vr01 |= VR01_LCD_ENABLE | VR01_DVO_ENABLE;
 	else
 		vr01 &= ~(VR01_LCD_ENABLE | VR01_DVO_ENABLE);
@@ -315,7 +315,7 @@ static void ivch_dpms(struct intel_dvo_device *dvo, int mode)
 		if (!ivch_read(dvo, VR30, &vr30))
 			break;
 
-		if (((vr30 & VR30_PANEL_ON) != 0) == (mode == DRM_MODE_DPMS_ON))
+		if (((vr30 & VR30_PANEL_ON) != 0) == enable)
 			break;
 		udelay(1000);
 	}
diff --git a/drivers/gpu/drm/i915/dvo_sil164.c b/drivers/gpu/drm/i915/dvo_sil164.c
index a0b13a6..cc24c1c 100644
--- a/drivers/gpu/drm/i915/dvo_sil164.c
+++ b/drivers/gpu/drm/i915/dvo_sil164.c
@@ -208,7 +208,7 @@ static void sil164_mode_set(struct intel_dvo_device *dvo,
 }
 
 /* set the SIL164 power state */
-static void sil164_dpms(struct intel_dvo_device *dvo, int mode)
+static void sil164_dpms(struct intel_dvo_device *dvo, bool enable)
 {
 	int ret;
 	unsigned char ch;
@@ -217,7 +217,7 @@ static void sil164_dpms(struct intel_dvo_device *dvo, int mode)
 	if (ret == false)
 		return;
 
-	if (mode == DRM_MODE_DPMS_ON)
+	if (enable)
 		ch |= SIL164_8_PD;
 	else
 		ch &= ~SIL164_8_PD;
diff --git a/drivers/gpu/drm/i915/dvo_tfp410.c b/drivers/gpu/drm/i915/dvo_tfp410.c
index aa2cd3e..097b3e8 100644
--- a/drivers/gpu/drm/i915/dvo_tfp410.c
+++ b/drivers/gpu/drm/i915/dvo_tfp410.c
@@ -234,14 +234,14 @@ static void tfp410_mode_set(struct intel_dvo_device *dvo,
 }
 
 /* set the tfp410 power state */
-static void tfp410_dpms(struct intel_dvo_device *dvo, int mode)
+static void tfp410_dpms(struct intel_dvo_device *dvo, bool enable)
 {
 	uint8_t ctl1;
 
 	if (!tfp410_readb(dvo, TFP410_CTL_1, &ctl1))
 		return;
 
-	if (mode == DRM_MODE_DPMS_ON)
+	if (enable)
 		ctl1 |= TFP410_CTL_1_PD;
 	else
 		ctl1 &= ~TFP410_CTL_1_PD;
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c
index 60ba50b9..d72584a 100644
--- a/drivers/gpu/drm/i915/intel_dvo.c
+++ b/drivers/gpu/drm/i915/intel_dvo.c
@@ -107,9 +107,9 @@ static void intel_dvo_dpms(struct drm_encoder *encoder, int mode)
 	if (mode == DRM_MODE_DPMS_ON) {
 		I915_WRITE(dvo_reg, temp | DVO_ENABLE);
 		I915_READ(dvo_reg);
-		intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, mode);
+		intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, true);
 	} else {
-		intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, mode);
+		intel_dvo->dev.dev_ops->dpms(&intel_dvo->dev, false);
 		I915_WRITE(dvo_reg, temp & ~DVO_ENABLE);
 		I915_READ(dvo_reg);
 	}
-- 
1.7.7.6

  parent reply	other threads:[~2012-07-03 10:34 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-03  9:27 [PATCH 00/43] [RFC] modeset rework, part 1 Daniel Vetter
2012-07-03  9:27 ` [PATCH 01/43] drm/i915: introduce for_each_encoder_on_crtc Daniel Vetter
2012-07-04 21:29   ` Paulo Zanoni
2012-07-05  7:50     ` [PATCH] " Daniel Vetter
2012-07-05 13:08       ` Daniel Vetter
2012-07-03  9:27 ` [PATCH 02/43] drm/i915: add crtc->enable/disable vfuncs insted of dpms Daniel Vetter
2012-07-03  9:27 ` [PATCH 03/43] drm/i915: rip out crtc prepare/commit indirection Daniel Vetter
2012-07-03  9:27 ` [PATCH 04/43] drm/i915: add direct encoder disable/enable infrastructure Daniel Vetter
2012-07-03  9:27 ` [PATCH 05/43] drm/i915: add missing gen2 pipe A quirk entries Daniel Vetter
2012-07-03  9:27 ` [PATCH 06/43] drm/i915: rip out the overlay pipe A workaround Daniel Vetter
2012-07-03  9:27 ` [PATCH 07/43] drm/i915: prepare load-detect pipe code for dpms changes Daniel Vetter
2012-07-03  9:28 ` [PATCH 08/43] drm/i915/hdmi: convert to encoder->disable/enable Daniel Vetter
2012-07-26 17:12   ` Paulo Zanoni
2012-07-03  9:28 ` [PATCH 09/43] drm/i915/tv: convert to encoder enable/disable Daniel Vetter
2012-07-03  9:28 ` [PATCH 10/43] drm/i915/lvds: ditch ->prepare special case Daniel Vetter
2012-07-03  9:28 ` [PATCH 11/43] drm/i915/lvds: convert to encoder disable/enable Daniel Vetter
2012-07-03  9:28 ` [PATCH 12/43] drm/i915/dp: " Daniel Vetter
2012-07-03  9:28 ` [PATCH 13/43] drm/i915: create VLV_DSIPLAY_BASE #define Daniel Vetter
2012-07-03  9:28 ` [PATCH 14/43] drm/i915: group ADPA #defines together Daniel Vetter
2012-07-03  9:28 ` [PATCH 15/43] drm/i915: add inte_crt->adpa_reg Daniel Vetter
2012-07-03  9:28 ` [PATCH 16/43] drm/i915/crt: convert to encoder disable/enable Daniel Vetter
2012-07-03  9:28 ` [PATCH 17/43] drm/i915/sdvo: convert to encoder disabl/enable Daniel Vetter
2012-07-03  9:28 ` Daniel Vetter [this message]
2012-07-03  9:28 ` [PATCH 19/43] drm/i915: simplify possible_clones computation Daniel Vetter
2012-07-03  9:28 ` [PATCH 20/43] drm/i915: add port parameter to intel_hdmi_init Daniel Vetter
2012-07-03  9:28 ` [PATCH 21/43] drm/i915: convert dpms functions of dvo/sdvo/crt Daniel Vetter
2012-07-03  9:28 ` [PATCH 22/43] drm/i915: rip out encoder->disable/enable checks Daniel Vetter
2012-07-03  9:28 ` [PATCH 23/43] drm/i915: clean up encoder_prepare/commit Daniel Vetter
2012-07-03  9:28 ` [PATCH 24/43] drm/fb helper: don't call drm_crtc_helper_set_config Daniel Vetter
2012-07-03  9:28 ` [PATCH 25/43] drm: remove the list_head from drm_mode_set Daniel Vetter
2012-07-03  9:28 ` [PATCH 26/43] drm/i915: copy&paste drm_crtc_helper_set_config Daniel Vetter
2012-07-03  9:28 ` [PATCH 27/43] drm/i915: call set_base directly Daniel Vetter
2012-07-03  9:28 ` [PATCH 28/43] drm/i915: inline intel_best_encoder Daniel Vetter
2012-07-03  9:28 ` [PATCH 29/43] drm/i915: copy&paste drm_crtc_helper_set_mode Daniel Vetter
2012-07-25 21:14   ` Paulo Zanoni
2012-07-03  9:28 ` [PATCH 30/43] drm/i915: simplify intel_crtc_prepare_encoders Daniel Vetter
2012-07-03  9:28 ` [PATCH 31/43] drm/i915: rip out encoder->prepare/commit Daniel Vetter
2012-07-03  9:28 ` [PATCH 32/43] drm/i915: call crtc functions directly Daniel Vetter
2012-07-03  9:28 ` [PATCH 33/43] drm/i915: WARN when trying to enabled an unused crtc Daniel Vetter
2012-07-03  9:28 ` [PATCH 34/43] drm/i915: Add interfaces to read out encoder/connector hw state Daniel Vetter
2012-07-03  9:28 ` [PATCH 35/43] drm/i915/dp: implement get_hw_state Daniel Vetter
2012-07-03  9:28 ` [PATCH 36/43] drm/i915/hdmi: " Daniel Vetter
2012-07-03  9:28 ` [PATCH 37/43] drm/i915/tv: " Daniel Vetter
2012-07-03  9:28 ` [PATCH 38/43] drm/i915/lvds: " Daniel Vetter
2012-07-03  9:28 ` [PATCH 39/43] drm/i915/crt: " Daniel Vetter
2012-07-03  9:28 ` [PATCH 40/43] drm/i915/sdvo: " Daniel Vetter
2012-07-03  9:28 ` [PATCH 41/43] drm/i915/dvo: " Daniel Vetter
2012-07-03  9:28 ` [PATCH 42/43] drm/i915: read out the modeset hw state at load and resume time Daniel Vetter
2012-07-03  9:28 ` [PATCH 43/43] drm/i915: check connector hw/sw state Daniel Vetter

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=1341307715-3886-19-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 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.