drm/i915: add DP support to intel_ddi_mode_set
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Mon, 15 Oct 2012 18:51:33 +0000 (15:51 -0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 18 Oct 2012 19:19:22 +0000 (21:19 +0200)
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_ddi.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_drv.h

index aabbeb8..5103172 100644 (file)
@@ -650,28 +650,55 @@ void intel_ddi_mode_set(struct drm_encoder *encoder,
 {
        struct drm_crtc *crtc = encoder->crtc;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-       struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
-       int port = intel_hdmi->ddi_port;
+       struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
+       int port = intel_ddi_get_encoder_port(intel_encoder);
        int pipe = intel_crtc->pipe;
+       int type = intel_encoder->type;
 
-       /* On Haswell, we need to enable the clocks and prepare DDI function to
-        * work in HDMI mode for this pipe.
-        */
-       DRM_DEBUG_KMS("Preparing HDMI DDI mode for Haswell on port %c, pipe %c\n", port_name(port), pipe_name(pipe));
+       DRM_DEBUG_KMS("Preparing DDI mode for Haswell on port %c, pipe %c\n",
+                     port_name(port), pipe_name(pipe));
 
-       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));
+       if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) {
+               struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
-               /* write eld */
-               DRM_DEBUG_DRIVER("HDMI audio: write eld information\n");
-               intel_write_eld(encoder, adjusted_mode);
-       }
+               intel_dp->DP = DDI_BUF_CTL_ENABLE | DDI_BUF_EMP_400MV_0DB_HSW;
+               switch (intel_dp->lane_count) {
+               case 1:
+                       intel_dp->DP |= DDI_PORT_WIDTH_X1;
+                       break;
+               case 2:
+                       intel_dp->DP |= DDI_PORT_WIDTH_X2;
+                       break;
+               case 4:
+                       intel_dp->DP |= DDI_PORT_WIDTH_X4;
+                       break;
+               default:
+                       intel_dp->DP |= DDI_PORT_WIDTH_X4;
+                       WARN(1, "Unexpected DP lane count %d\n",
+                            intel_dp->lane_count);
+                       break;
+               }
+
+               intel_dp_init_link_config(intel_dp);
 
-       intel_hdmi->set_infoframes(encoder, adjusted_mode);
+       } else if (type == INTEL_OUTPUT_HDMI) {
+               struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
+
+               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);
+               }
+
+               intel_hdmi->set_infoframes(encoder, adjusted_mode);
+       }
 }
 
 static struct intel_encoder *
index 07208bc..c875e2e 100644 (file)
@@ -835,6 +835,21 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
        }
 }
 
+void intel_dp_init_link_config(struct intel_dp *intel_dp)
+{
+       memset(intel_dp->link_configuration, 0, DP_LINK_CONFIGURATION_SIZE);
+       intel_dp->link_configuration[0] = intel_dp->link_bw;
+       intel_dp->link_configuration[1] = intel_dp->lane_count;
+       intel_dp->link_configuration[8] = DP_SET_ANSI_8B10B;
+       /*
+        * Check for DPCD version > 1.1 and enhanced framing support
+        */
+       if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 &&
+           (intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_ENHANCED_FRAME_CAP)) {
+               intel_dp->link_configuration[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
+       }
+}
+
 static void
 intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
                  struct drm_display_mode *adjusted_mode)
@@ -887,17 +902,8 @@ intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
                intel_dp->DP |= DP_AUDIO_OUTPUT_ENABLE;
                intel_write_eld(encoder, adjusted_mode);
        }
-       memset(intel_dp->link_configuration, 0, DP_LINK_CONFIGURATION_SIZE);
-       intel_dp->link_configuration[0] = intel_dp->link_bw;
-       intel_dp->link_configuration[1] = intel_dp->lane_count;
-       intel_dp->link_configuration[8] = DP_SET_ANSI_8B10B;
-       /*
-        * Check for DPCD version > 1.1 and enhanced framing support
-        */
-       if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 &&
-           (intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_ENHANCED_FRAME_CAP)) {
-               intel_dp->link_configuration[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
-       }
+
+       intel_dp_init_link_config(intel_dp);
 
        /* Split out the IBX/CPU vs CPT settings */
 
index ed75a36..d89d428 100644 (file)
@@ -422,6 +422,7 @@ extern void intel_dp_init(struct drm_device *dev, int output_reg,
 void
 intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
                 struct drm_display_mode *adjusted_mode);
+extern void intel_dp_init_link_config(struct intel_dp *intel_dp);
 extern bool intel_dpd_is_edp(struct drm_device *dev);
 extern void intel_edp_link_config(struct intel_encoder *, int *, int *);
 extern int intel_edp_target_clock(struct intel_encoder *,