All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paulo Zanoni <przanoni@gmail.com>
To: intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH 5/5] drm/i915: don't init DP or HDMI when not supported by DDI port
Date: Wed, 11 Sep 2013 18:02:51 -0300	[thread overview]
Message-ID: <1378933371-1556-5-git-send-email-przanoni@gmail.com> (raw)
In-Reply-To: <1378933371-1556-1-git-send-email-przanoni@gmail.com>

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

There's no reason to init a DP connector if the encoder just supports
HDMI: we'll just waste hundreds and hundreds of cycles trying to do DP
AUX transactions to detect if there's something there. Same goes for a
DP connector that doesn't support HDMI, but I'm not sure these
actually exist.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
---
 drivers/gpu/drm/i915/i915_drv.h   |  3 +++
 drivers/gpu/drm/i915/intel_bios.c | 13 ++++++++++++-
 drivers/gpu/drm/i915/intel_ddi.c  | 30 ++++++++++++++++++++++--------
 3 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 298c671..8533bf1 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1054,6 +1054,9 @@ enum modeset_restore {
 
 struct ddi_vbt_port_info {
 	uint8_t hdmi_level_shift;
+	bool supports_dvi;
+	bool supports_hdmi;
+	bool supports_dp;
 };
 
 struct intel_vbt_data {
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index be07977..9aee153 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -632,6 +632,10 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
 	is_hdmi = is_dvi && (child->common.device_type & (1 << 11)) == 0;
 	is_edp = is_dp && (child->common.device_type & (1 << 12));
 
+	info->supports_dvi = is_dvi;
+	info->supports_hdmi = is_hdmi;
+	info->supports_dp = is_dp;
+
 	DRM_DEBUG_KMS("Port %c VBT info: DP:%d HDMI:%d DVI:%d EDP:%d CRT:%d\n",
 		      port_name(port), is_dp, is_hdmi, is_dvi, is_edp, is_crt);
 
@@ -786,8 +790,15 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
 		enum port port;
 
 		for (port = PORT_A; port <= PORT_E; port++) {
+			struct ddi_vbt_port_info *info =
+				&dev_priv->vbt.ddi_port_info[port];
+
 			/* Recommended BSpec default: 800mV 0dB. */
-			dev_priv->vbt.ddi_port_info[port].hdmi_level_shift = 6;
+			info->hdmi_level_shift = 6;
+
+			info->supports_dvi = (port != PORT_A && port != PORT_E);
+			info->supports_hdmi = info->supports_dvi;
+			info->supports_dp = (port != PORT_E);
 		}
 	}
 
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index a9887eb..df7f75c 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1325,6 +1325,17 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
 	struct drm_encoder *encoder;
 	struct intel_connector *hdmi_connector = NULL;
 	struct intel_connector *dp_connector = NULL;
+	bool init_hdmi, init_dp;
+
+	init_hdmi = (dev_priv->vbt.ddi_port_info[port].supports_dvi ||
+		     dev_priv->vbt.ddi_port_info[port].supports_hdmi);
+	init_dp = dev_priv->vbt.ddi_port_info[port].supports_dp;
+	if (!init_dp && !init_hdmi) {
+		DRM_ERROR("VBT says port %c is not DVI/HDMI/DP compatible\n",
+			  port_name(port));
+		init_hdmi = true;
+		init_dp = true;
+	}
 
 	intel_dig_port = kzalloc(sizeof(struct intel_digital_port), GFP_KERNEL);
 	if (!intel_dig_port)
@@ -1362,19 +1373,22 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
 	intel_encoder->cloneable = false;
 	intel_encoder->hot_plug = intel_ddi_hot_plug;
 
-	if (!intel_dp_init_connector(intel_dig_port, dp_connector)) {
-		drm_encoder_cleanup(encoder);
-		kfree(intel_dig_port);
-		kfree(dp_connector);
-		return;
+	if (init_dp) {
+		if (!intel_dp_init_connector(intel_dig_port, dp_connector)) {
+			drm_encoder_cleanup(encoder);
+			kfree(intel_dig_port);
+			kfree(dp_connector);
+			return;
+		}
 	}
 
-	if (intel_encoder->type != INTEL_OUTPUT_EDP) {
+	/* In theory we don't need the encoder->type check, but leave it just in
+	 * case we have some really bad VBTs... */
+	if (intel_encoder->type != INTEL_OUTPUT_EDP && init_hdmi) {
 		hdmi_connector = kzalloc(sizeof(struct intel_connector),
 					 GFP_KERNEL);
-		if (!hdmi_connector) {
+		if (!hdmi_connector)
 			return;
-		}
 
 		intel_dig_port->hdmi.hdmi_reg = DDI_BUF_CTL(port);
 		intel_hdmi_init_connector(intel_dig_port, hdmi_connector);
-- 
1.8.3.1

  parent reply	other threads:[~2013-09-11 21:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 21:02 [PATCH 1/5] drm/i915: VBT's child_device_config changes over time Paulo Zanoni
2013-09-11 21:02 ` [PATCH 2/5] drm/i915: use the HDMI DDI buffer translations from VBT Paulo Zanoni
2013-09-11 21:33   ` Chris Wilson
2013-09-12 17:14     ` Paulo Zanoni
2013-09-12 20:06       ` Paulo Zanoni
2013-09-11 21:02 ` [PATCH 3/5] drm/i915: check the DDC and AUX bits of the VBT on DDI machines Paulo Zanoni
2013-09-11 21:22   ` Chris Wilson
2013-09-12 20:07     ` Paulo Zanoni
2013-09-11 21:02 ` [PATCH 4/5] drm/i915: add some assertions about VBT DDI port types Paulo Zanoni
2013-09-11 21:23   ` Chris Wilson
2013-09-12 20:10     ` Paulo Zanoni
2013-09-11 21:02 ` Paulo Zanoni [this message]
2013-09-11 21:19   ` [PATCH 5/5] drm/i915: don't init DP or HDMI when not supported by DDI port Chris Wilson
2013-09-12 20:12     ` Paulo Zanoni
2013-09-20 22:45       ` 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=1378933371-1556-5-git-send-email-przanoni@gmail.com \
    --to=przanoni@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=paulo.r.zanoni@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 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.