From patchwork Thu Oct 11 21:10:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 1584231 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id CAACFDFABE for ; Thu, 11 Oct 2012 21:11:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 91CF4A09CC for ; Thu, 11 Oct 2012 14:11:15 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-gg0-f177.google.com (mail-gg0-f177.google.com [209.85.161.177]) by gabe.freedesktop.org (Postfix) with ESMTP id ACDDD9E756 for ; Thu, 11 Oct 2012 14:10:54 -0700 (PDT) Received: by mail-gg0-f177.google.com with SMTP id h1so605479gge.36 for ; Thu, 11 Oct 2012 14:10:54 -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; bh=65x7TmBFGow9SL2CUA6OIzdsK0elCB1JlxjLjKVDwiU=; b=edALAYb6DHSkJ/eRwv2XJdun8gv/IWjrxTfpEnVZ8YwDJ1pv0h36vEbRJKA5uY/W/e FaFoGvN9mCHQkRR4vcn9Prd16wmASKzT2w5ymJRv015qrww5r+Juqw6ljCXY2CD1rSgq uNqQ722R4hA5lYUZ8PlAk94dDyyjDsD7dbMUbv6VbeYWMdBG+N4jrp+uWL4jXlCgcrZc vGfBTH2PucVFDKPPFCS23h765y1YJd2iyUdWV286GFpylli7zBOXN7IVu61WC0va1FnU gML07lY0Z+XsXkEQapvQJqkeFNIwO7+uIuP2/K2JrhEfpVxCnDruGH6L05Duf2YWKJac N65w== Received: by 10.236.117.33 with SMTP id i21mr2282431yhh.81.1349989853949; Thu, 11 Oct 2012 14:10:53 -0700 (PDT) Received: from vicky.domain.invalid ([177.16.65.62]) by mx.google.com with ESMTPS id k20sm4864965anl.11.2012.10.11.14.10.51 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Oct 2012 14:10:53 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Thu, 11 Oct 2012 18:10:17 -0300 Message-Id: <1349989817-9510-1-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 1.7.10.4 Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH xf86-video-intel] uxa: fix possible_clones computation 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 Libdrm's possible_clones is a mask of encoders. Xorg's possible_clones is a mask of outputs, so we just can't do the following: output->possible_clones = kencoder->possible_clones; This is a problem on Haswell because, at least with the current patches floating on the mailing list, there is more than one connector per encoder. This patch writes the code to properly translate libdrm's encoder mask into Xorg's output mask. Still need an SNA version. Signed-off-by: Paulo Zanoni --- src/intel_display.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/src/intel_display.c b/src/intel_display.c index b2a5904..d58e6e0 100644 --- a/src/intel_display.c +++ b/src/intel_display.c @@ -1435,7 +1435,6 @@ intel_output_init(ScrnInfoPtr scrn, struct intel_mode *mode, int num) intel_output_backlight_init(output); output->possible_crtcs = kencoder->possible_crtcs; - output->possible_clones = kencoder->possible_clones; output->interlaceAllowed = TRUE; intel_output->output = output; @@ -1680,6 +1679,60 @@ drm_wakeup_handler(pointer data, int err, pointer p) drmHandleEvent(mode->fd, &mode->event_context); } +static drmModeEncoderPtr +intel_get_kencoder(struct intel_mode *mode, int num) +{ + struct intel_output *iterator; + int id = mode->mode_res->encoders[num]; + + list_for_each_entry(iterator, &mode->outputs, link) + if (iterator->mode_encoder->encoder_id == id) + return iterator->mode_encoder; + + return NULL; +} + +/* + * Libdrm's possible_clones is a mask of encoders, Xorg's possible_clones is a + * mask of outputs. This function sets Xorg's possible_clones based on the + * values read from libdrm. + */ +static void +intel_compute_possible_clones(ScrnInfoPtr scrn, struct intel_mode *mode) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + struct intel_output *intel_output, *clone; + drmModeEncoderPtr cloned_encoder; + uint32_t mask; + int i, j, k; + CARD32 possible_clones; + + for (i = 0; i < config->num_output; i++) { + possible_clones = 0; + intel_output = config->output[i]->driver_private; + + mask = intel_output->mode_encoder->possible_clones; + for (j = 0; mask != 0; j++, mask >>= 1) { + + if ((mask & 1) == 0) + continue; + + cloned_encoder = intel_get_kencoder(mode, j); + if (!cloned_encoder) + continue; + + for (k = 0; k < config->num_output; k++) { + clone = config->output[k]->driver_private; + if (clone->mode_encoder->encoder_id == + cloned_encoder->encoder_id) + possible_clones |= (1 << k); + } + } + + config->output[i]->possible_clones = possible_clones; + } +} + Bool intel_mode_pre_init(ScrnInfoPtr scrn, int fd, int cpp) { intel_screen_private *intel = intel_get_screen_private(scrn); @@ -1716,6 +1769,8 @@ Bool intel_mode_pre_init(ScrnInfoPtr scrn, int fd, int cpp) for (i = 0; i < mode->mode_res->count_connectors; i++) intel_output_init(scrn, mode, i); + intel_compute_possible_clones(scrn, mode); + #ifdef INTEL_PIXMAP_SHARING xf86ProviderSetup(scrn, NULL, "Intel"); #endif