From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paulo Zanoni Subject: [PATCH 2/3] drm/i915: add some assertions about VBT DDI port types Date: Wed, 28 Aug 2013 12:45:06 -0300 Message-ID: <1377704707-3190-3-git-send-email-przanoni@gmail.com> References: <1377704707-3190-1-git-send-email-przanoni@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ye0-f177.google.com (mail-ye0-f177.google.com [209.85.213.177]) by gabe.freedesktop.org (Postfix) with ESMTP id C1449E7BAA for ; Wed, 28 Aug 2013 08:45:27 -0700 (PDT) Received: by mail-ye0-f177.google.com with SMTP id r13so1555314yen.8 for ; Wed, 28 Aug 2013 08:45:26 -0700 (PDT) In-Reply-To: <1377704707-3190-1-git-send-email-przanoni@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org Cc: Paulo Zanoni List-Id: intel-gfx@lists.freedesktop.org From: Paulo Zanoni Our code makes a lot of assumptions regarding what each DDI port actually supports, and the VBT should tell us what is really happening in the hardware. So parse the information provided by the VBT and check if any of our assumptions is wrong. Our driver also has a history of not really trusting the VBT, so a WARN here could mean that: a) our coding assumptions are wrong b) the VBT is wrong c) we're incorrectly parsing the VBT d) the checks are wrong But I really hope we won't ever trigger any of those WARNs. v2: Don't check the redundant "Capabilities" field from byte 24 since it doesn't seem to be used. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/intel_bios.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c index a6700ab..4003dbf 100644 --- a/drivers/gpu/drm/i915/intel_bios.c +++ b/drivers/gpu/drm/i915/intel_bios.c @@ -575,7 +575,7 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port, struct ddi_vbt_port_info *info = &dev_priv->vbt.ddi_port_info[port]; uint8_t hdmi_level_shift; int i, j; - bool is_dvi, is_dp; + bool is_dvi, is_hdmi, is_dp, is_edp, is_crt; uint8_t aux_channel; int dvo_ports[][2] = { {0, 10}, {1, 7}, {2, 8}, {3, 9}, {6, /* Unused */ 0}, @@ -604,6 +604,24 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port, is_dvi = child->common.device_type & (1 << 4); is_dp = child->common.device_type & (1 << 2); + is_crt = child->common.device_type & (1 << 0); + is_hdmi = is_dvi && (child->common.device_type & (1 << 11)) == 0; + is_edp = is_dp && (child->common.device_type & (1 << 12)); + + 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); + + WARN(is_edp && is_dvi, "Internal DP port %c is TMDS compatible\n", + port_name(port)); + WARN(is_crt && port != PORT_E, "Port %c is analog\n", port_name(port)); + WARN(is_crt && (is_dvi || is_dp), + "Analog port %c is also DP or TMDS compatible\n", port_name(port)); + WARN(is_dvi && (port == PORT_A || port == PORT_E), + "Port %c is TMDS compabile\n", port_name(port)); + WARN(!is_dvi && !is_dp && !is_crt, + "Port %c is not DP/TMDS/CRT compatible\n", port_name(port)); + WARN(is_edp && (port == PORT_B || port == PORT_C || port == PORT_E), + "Port %c is internal DP\n", port_name(port)); if (is_dvi) { WARN(child->common.ddc_pin == 0x05 && port != PORT_B, -- 1.8.1.2