From patchwork Tue Aug 28 22:06:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 1382741 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 8B3F23FDF5 for ; Tue, 28 Aug 2012 22:12:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 570E29E95A for ; Tue, 28 Aug 2012 15:12:56 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yw0-f53.google.com (mail-yw0-f53.google.com [209.85.213.53]) by gabe.freedesktop.org (Postfix) with ESMTP id 641649F06F for ; Tue, 28 Aug 2012 15:07:29 -0700 (PDT) Received: by mail-yw0-f53.google.com with SMTP id 3so1991825yhp.26 for ; Tue, 28 Aug 2012 15:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=96eIgBAgH1TC4kZ5SKfM3XpobTc5WY0m0Y3tq6RRJoY=; b=lXcDEBlqvxKBFVkuki9Yorw2zvjSFGD2eVdRUDZt/B7O54WdZwljO+7i50fLILbEi4 +pHWje8XJJhrJwVBvgQsz6ky7phRxhB4Yu8VAZgW8FOpSrIn9zzfH3j8EQqjegiA0JF6 W3gN2t7F9kc+gDp2990HqMLN2Bt08F2o8vfo1qDFjkJGFvreA84D50VuV3H3zCsWBbM9 VWqTVlstlyA5s2D8DBDM9EhxmwLWl5kcim3zboz16CaWwRjoLWSjF9Fgv/Io8Syeh3OY OZesks8gru1x3ev6Tsex5xFui048YKlNmn3P7XxWV+4E/LPeiudxMaiqlCkHDwQDfGR8 TsbA== Received: by 10.236.72.103 with SMTP id s67mr15322849yhd.78.1346191649315; Tue, 28 Aug 2012 15:07:29 -0700 (PDT) Received: from vicky.domain.invalid (189.114.178.236.dynamic.adsl.gvt.net.br. [189.114.178.236]) by mx.google.com with ESMTPS id z3sm4434172anj.20.2012.08.28.15.07.27 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Aug 2012 15:07:28 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 28 Aug 2012 19:06:38 -0300 Message-Id: <1346191621-12996-8-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1346191621-12996-1-git-send-email-przanoni@gmail.com> References: <1346191621-12996-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [RFC 07/30] drm/i915: make intel_ddi_enable_pipe work on DP X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org From: Paulo Zanoni Not just HDMI/DVI. Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/i915_reg.h | 10 +++++ drivers/gpu/drm/i915/intel_ddi.c | 95 +++++++++++++++++++++++++++------------- drivers/gpu/drm/i915/intel_dp.c | 5 --- drivers/gpu/drm/i915/intel_drv.h | 4 ++ 4 files changed, 79 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index ee70588..9d34a2e 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -4514,6 +4514,16 @@ #define PIPE_CLK_SEL_DISABLED (0x0<<29) #define PIPE_CLK_SEL_PORT(x) ((x+1)<<29) +#define _PIPEA_MSA_MISC 0x60410 +#define _PIPEB_MSA_MISC 0x61410 +#define PIPE_MSA_MISC(pipe) _PIPE(pipe, _PIPEA_MSA_MISC, _PIPEB_MSA_MISC) +#define PIPE_MSA_SYNC_CLK (1<<0) +#define PIPE_MSA_6_BPC (0<<5) +#define PIPE_MSA_8_BPC (1<<5) +#define PIPE_MSA_10_BPC (2<<5) +#define PIPE_MSA_12_BPC (3<<5) +#define PIPE_MSA_16_BPC (3<<5) + /* LCPLL Control */ #define LCPLL_CTL 0x130040 #define LCPLL_PLL_DISABLE (1<<31) diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index 0c83ffa..208f13f 100644 --- a/drivers/gpu/drm/i915/intel_ddi.c +++ b/drivers/gpu/drm/i915/intel_ddi.c @@ -762,65 +762,100 @@ static void intel_ddi_enable_pipe(struct intel_encoder *intel_encoder, struct drm_display_mode *adjusted_mode) { struct drm_encoder *encoder = &intel_encoder->base; - struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); struct drm_device *dev = encoder->dev; struct drm_i915_private *dev_priv = dev->dev_private; struct drm_crtc *crtc = encoder->crtc; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - int port = intel_hdmi->ddi_port; + int port; int pipe = intel_crtc->pipe; - u32 temp; + u32 func_val, msa_val; + struct intel_hdmi *intel_hdmi = NULL; + struct intel_dp *intel_dp = NULL; + + if (intel_encoder->type == INTEL_OUTPUT_HDMI) { + intel_hdmi = enc_to_intel_hdmi(encoder); + port = intel_hdmi->ddi_port; + } else { + intel_dp = enc_to_intel_dp(encoder); + port = intel_dp->port; + } I915_WRITE(PIPE_CLK_SEL(pipe), PIPE_CLK_SEL_PORT(port)); udelay(20); - if (intel_hdmi->has_audio) { - /* Proper support for digital audio needs a new logic and a new set - * of registers, so we leave it for future patch bombing. - */ - DRM_DEBUG_DRIVER("HDMI audio on pipe %c on DDI\n", - pipe_name(intel_crtc->pipe)); - - /* write eld */ - DRM_DEBUG_DRIVER("HDMI audio: write eld information\n"); - intel_write_eld(encoder, adjusted_mode); - } - - /* Enable PIPE_DDI_FUNC_CTL for the pipe to work in HDMI mode */ - temp = PIPE_DDI_FUNC_ENABLE | PIPE_DDI_SELECT_PORT(port); + func_val = PIPE_DDI_FUNC_ENABLE | PIPE_DDI_SELECT_PORT(port); + msa_val = PIPE_MSA_SYNC_CLK; switch (intel_crtc->bpp) { case 18: - temp |= PIPE_DDI_BPC_6; + func_val |= PIPE_DDI_BPC_6; + msa_val |= PIPE_MSA_6_BPC; break; case 24: - temp |= PIPE_DDI_BPC_8; + func_val |= PIPE_DDI_BPC_8; + msa_val |= PIPE_MSA_8_BPC; break; case 30: - temp |= PIPE_DDI_BPC_10; + func_val |= PIPE_DDI_BPC_10; + msa_val |= PIPE_MSA_10_BPC; break; case 36: - temp |= PIPE_DDI_BPC_12; + func_val |= PIPE_DDI_BPC_12; + msa_val |= PIPE_MSA_12_BPC; break; default: WARN(1, "%d bpp unsupported by pipe DDI function\n", intel_crtc->bpp); } - if (intel_hdmi->has_hdmi_sink) - temp |= PIPE_DDI_MODE_SELECT_HDMI; - else - temp |= PIPE_DDI_MODE_SELECT_DVI; - if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) - temp |= PIPE_DDI_PVSYNC; + func_val |= PIPE_DDI_PVSYNC; if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) - temp |= PIPE_DDI_PHSYNC; + func_val |= PIPE_DDI_PHSYNC; - I915_WRITE(DDI_FUNC_CTL(pipe), temp); + if (intel_encoder->type == INTEL_OUTPUT_HDMI) { + if (intel_hdmi->has_hdmi_sink) + func_val |= PIPE_DDI_MODE_SELECT_HDMI; + else + func_val |= PIPE_DDI_MODE_SELECT_DVI; + } else { + func_val |= PIPE_DDI_MODE_SELECT_DP_SST; - intel_hdmi->set_infoframes(encoder, adjusted_mode); + switch (intel_dp->lane_count) { + case 1: + func_val |= PIPE_DDI_PORT_WIDTH_X1; + break; + case 2: + func_val |= PIPE_DDI_PORT_WIDTH_X2; + break; + case 4: + func_val |= PIPE_DDI_PORT_WIDTH_X4; + break; + default: + WARN(1, "Unsupported lane count %d\n", + intel_dp->lane_count); + } + + I915_WRITE(PIPE_MSA_MISC(pipe), msa_val); + } + + I915_WRITE(DDI_FUNC_CTL(pipe), func_val); + + if (intel_encoder->type == INTEL_OUTPUT_HDMI) { + if (intel_hdmi->has_audio) { + DRM_DEBUG_KMS("HDMI audio on pipe %c on DDI\n", + pipe_name(intel_crtc->pipe)); + + DRM_DEBUG_KMS("HDMI audio: write eld information\n"); + intel_write_eld(encoder, adjusted_mode); + } + + intel_hdmi->set_infoframes(encoder, adjusted_mode); + } else { + if (intel_dp->has_audio) + DRM_DEBUG_KMS("DP audio not supported yet\n"); + } } void intel_ddi_mode_set(struct drm_encoder *encoder, diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 977d9d2..31d6e78 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -76,11 +76,6 @@ static bool is_cpu_edp(struct intel_dp *intel_dp) return is_edp(intel_dp) && !is_pch_edp(intel_dp); } -static struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder) -{ - return container_of(encoder, struct intel_dp, base.base); -} - static struct intel_dp *intel_attached_dp(struct drm_connector *connector) { return container_of(intel_attached_encoder(connector), diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index aa62439..52c7547 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -420,6 +420,10 @@ static inline struct intel_encoder *intel_attached_encoder(struct drm_connector { return to_intel_connector(connector)->encoder; } +static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder) +{ + return container_of(encoder, struct intel_dp, base.base); +} extern void intel_connector_attach_encoder(struct intel_connector *connector, struct intel_encoder *encoder);