From patchwork Mon Oct 27 19:47:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 5166041 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C9F3B9F318 for ; Mon, 27 Oct 2014 19:48:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C876F201E4 for ; Mon, 27 Oct 2014 19:48:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 907D0201D3 for ; Mon, 27 Oct 2014 19:48:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6F0F6E254; Mon, 27 Oct 2014 12:48:13 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qa0-f53.google.com (mail-qa0-f53.google.com [209.85.216.53]) by gabe.freedesktop.org (Postfix) with ESMTP id BF1B66E254 for ; Mon, 27 Oct 2014 12:48:12 -0700 (PDT) Received: by mail-qa0-f53.google.com with SMTP id n8so2007881qaq.26 for ; Mon, 27 Oct 2014 12:48:12 -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; bh=rtrdnwbsFt3bRgbbVDDpn9TkLmkMlruy9mOTkhlQMms=; b=Acdy7gw7bXcp16xea3GNoR8kR/WKs0JoUrFNyz+7ypNRYHWZ3hMrEwNnqhGGeYfOab oX+L/yLOeOW4Dp93Y+mI9NawkeJbwBTJdwWnw5+ZI79w9jb30ROyDBn3Lk/wHLzvPiPk JP2CoKygpPHap+RHGhWEKcEVF5scfyLfnnaydZvpJYg3m1OsPJAjo7dII5JPRmSOkIlh 27gNSreCnB4sHhsxCAgV2vVliNMFqLuaH8n6PxIR+5u7nwhFNQuOMJGPG/WTNLIYgFG1 /q5UJEa7+DFNrY6cmfgPfRjaKHrTagZMioTV+yMNkdZK6J5rwMaKw2QRHPYIJiCU8pnL rKRw== X-Received: by 10.140.93.43 with SMTP id c40mr10559375qge.58.1414439292226; Mon, 27 Oct 2014 12:48:12 -0700 (PDT) Received: from localhost.localdomain ([177.16.188.126]) by mx.google.com with ESMTPSA id h79sm11917150qgd.27.2014.10.27.12.48.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Oct 2014 12:48:11 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Mon, 27 Oct 2014 17:47:51 -0200 Message-Id: <1414439272-1885-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: Daniel Vetter , Paulo Zanoni Subject: [Intel-gfx] [PATCH 1/2] drm/i915: introduce pipe_config->ddi_personality X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paulo Zanoni On HSW+, one encoder (DDI) can have multiple connectors (HDMI and DP). If no connector is connected, we consider the encoder type to be INTEL_OUTPUT_UNKNOWN. The problem is that we allow user space to set modes on disconnected connectors, so when we try to set a mode on an INTEL_OUTPUT_UNKNOWN connector, we don't know what to do and end up printing a WARN. So on this patch, we introduce pipe_config->ddi_personality to help with that. When the user space sets a mode on a connector, we check the connector type and match it against intel_encoder->type and set the DDI personality accordingly. Then, after the compute config stage is over, we properly assign the personality to intel_encoder->type. This patch was previously called "drm/i915: Set the digital port encoder personality during modeset". References: http://patchwork.freedesktop.org/patch/17838/ Testcase: igt/kms_setmode/clone-exclusive-crtc Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68463 Credits-to: Damien Lespiau (for the previous versions of the patch). Cc: Damien Lespiau Cc: Daniel Vetter Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/intel_ddi.c | 97 ++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/i915/intel_display.c | 2 + drivers/gpu/drm/i915/intel_drv.h | 4 ++ 3 files changed, 100 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index cb5367c..5cdc2f4 100644 --- a/drivers/gpu/drm/i915/intel_ddi.c +++ b/drivers/gpu/drm/i915/intel_ddi.c @@ -1557,18 +1557,109 @@ static void intel_ddi_destroy(struct drm_encoder *encoder) intel_dp_encoder_destroy(encoder); } +static bool intel_ddi_set_personality(struct intel_encoder *encoder, + struct intel_crtc_config *pipe_config) +{ + struct drm_device *dev = encoder->base.dev; + struct intel_connector *connector; + int connectors = 0; + enum port port = intel_ddi_get_encoder_port(encoder); + + list_for_each_entry(connector, &dev->mode_config.connector_list, + base.head) { + + if (connector->new_encoder != encoder) + continue; + + connectors++; + if (WARN_ON(connectors > 1)) + return false; + + switch (connector->base.connector_type) { + case DRM_MODE_CONNECTOR_HDMIA: + case DRM_MODE_CONNECTOR_HDMIB: + pipe_config->ddi_personality = INTEL_OUTPUT_HDMI; + break; + case DRM_MODE_CONNECTOR_DisplayPort: + pipe_config->ddi_personality = INTEL_OUTPUT_DISPLAYPORT; + break; + case DRM_MODE_CONNECTOR_eDP: + pipe_config->ddi_personality = INTEL_OUTPUT_EDP; + break; + default: + WARN(1, "DRM connector type %d\n", + connector->base.connector_type); + return false; + } + + if (encoder->type == pipe_config->ddi_personality) + continue; + + /* We expect eDP to always have encoder->type correctly set, so + * it shouldn't reach this point. */ + if (pipe_config->ddi_personality == INTEL_OUTPUT_EDP) { + DRM_ERROR("DDI %c, type %s marked as eDP\n", + port_name(port), + intel_output_name(encoder->type)); + return false; + } + + /* + * We can't change the DDI type if we already have a connected + * device on this port. The first time a DDI is used though + * (encoder_type is INTEL_OUTPUT_UNKNOWN) and we force a + * connector to be connected (either trought the kernel command + * line or KMS) we need to comply. + */ + if (encoder->type != INTEL_OUTPUT_UNKNOWN && + connector->base.status == connector_status_connected) { + DRM_DEBUG_KMS("Can't set DDI %c personality to %s, it has a connected %s device\n", + port_name(port), + intel_output_name(encoder->type), + intel_output_name(pipe_config->ddi_personality)); + return false; + } + + DRM_DEBUG_KMS("Setting DDI %c personality to %s\n", + port_name(port), + intel_output_name(pipe_config->ddi_personality)); + } + + return true; + +} + +void intel_ddi_commit_personality(struct intel_crtc *crtc) +{ + struct intel_encoder *encoder = intel_ddi_get_crtc_encoder(&crtc->base); + + switch (encoder->type) { + case INTEL_OUTPUT_HDMI: + case INTEL_OUTPUT_DISPLAYPORT: + case INTEL_OUTPUT_EDP: + case INTEL_OUTPUT_UNKNOWN: + encoder->type = crtc->config.ddi_personality; + break; + case INTEL_OUTPUT_ANALOG: + break; + default: + WARN(1, "Output type %s\n", intel_output_name(encoder->type)); + break; + } +} + static bool intel_ddi_compute_config(struct intel_encoder *encoder, struct intel_crtc_config *pipe_config) { - int type = encoder->type; int port = intel_ddi_get_encoder_port(encoder); - WARN(type == INTEL_OUTPUT_UNKNOWN, "compute_config() on unknown output!\n"); + if (!intel_ddi_set_personality(encoder, pipe_config)) + return false; if (port == PORT_A) pipe_config->cpu_transcoder = TRANSCODER_EDP; - if (type == INTEL_OUTPUT_HDMI) + if (pipe_config->ddi_personality == INTEL_OUTPUT_HDMI) return intel_hdmi_compute_config(encoder, pipe_config); else return intel_dp_compute_config(encoder, pipe_config); diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index b5dbc88..16750c4 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -7810,6 +7810,8 @@ static int haswell_crtc_mode_set(struct intel_crtc *crtc, int x, int y, struct drm_framebuffer *fb) { + intel_ddi_commit_personality(crtc); + if (!intel_ddi_pll_select(crtc)) return -EINVAL; diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 5ab813c..bf3267c 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -386,6 +386,9 @@ struct intel_crtc_config { bool dp_encoder_is_mst; int pbn; + + /* This should be INTEL_OUTPUT_*. */ + int ddi_personality; }; struct intel_pipe_wm { @@ -817,6 +820,7 @@ void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder); void intel_ddi_clock_get(struct intel_encoder *encoder, struct intel_crtc_config *pipe_config); void intel_ddi_set_vc_payload_alloc(struct drm_crtc *crtc, bool state); +void intel_ddi_commit_personality(struct intel_crtc *crtc); /* intel_frontbuffer.c */ void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,