From patchwork Wed Jul 11 14:28:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1184171 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 01258DF25A for ; Wed, 11 Jul 2012 16:23:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9297A0ED9 for ; Wed, 11 Jul 2012 09:23:58 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id B673D9E8A8 for ; Wed, 11 Jul 2012 08:36:35 -0700 (PDT) Received: by mail-wg0-f43.google.com with SMTP id dr1so946426wgb.12 for ; Wed, 11 Jul 2012 08:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=4eJflDhg7LlmqORZ0s1QgRXOdxrIYvQen+25Amf+S9s=; b=TNZHyM4gEvKjpW49HSFFY/BgpklnpKqxVvzwZxsCzHJcxXfLig7s2IZ51O4y1qm3gk BsyXH6vEM+Zqo98EvNdzVK/XsJhwjB5f9ljTmKDxw6SmbPsj7UfEjN/a0LLTkMsXCvAy jdgxUORzEg7qbPxworKHEKUuagXkuzfZdh2Uk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=4eJflDhg7LlmqORZ0s1QgRXOdxrIYvQen+25Amf+S9s=; b=LioUSlwQLMWcP1eSeYN+j8glIVi7b1OvV0p+DjXKeWkEtttXlC9RDHkooIfJ7k33BR UL78JJESY/VxPn3OHvxTb8xQKkb77RGPBzQyZ6p6+RANw3b9ZK/KxkdCHxiXmCzu7wNt uoxl/toAf4GLxQaalrJ+yBB90Tic6qp8Ekwq28Cd2kWqNBaVekBZ3CZcH2yAbdYAGd4U 8g1DR+iEMFbnWbzz+mm8yYo58HFHmj5Q/D2g6Fk8BMz7cejPhUXZm1xONjze2vQf0G/s tvlkr9rOhNoCkIRAEBZmR9x3nief9fZ9/g1nisZ9Ug21ovZ3dremese6abcEafK3Wvx5 nZWg== Received: by 10.180.84.164 with SMTP id a4mr13779162wiz.12.1342020995511; Wed, 11 Jul 2012 08:36:35 -0700 (PDT) Received: from wespe.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id bc2sm5777080wib.0.2012.07.11.08.36.33 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Jul 2012 08:36:34 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Wed, 11 Jul 2012 16:28:46 +0200 Message-Id: <1342016944-23395-64-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1342016944-23395-1-git-send-email-daniel.vetter@ffwll.ch> References: <1342016944-23395-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQm+SrS8rntUZB4bVGLOlfwxNE+ac6dcFy57xGuCWl7gsmIqYGBD4MuMf/FsEU8TCGQFP/jC Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 63/81] drm/i915: implement new set_mode code flow 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 ... using the pipe masks from the previous patch. Well, not quite: - We still need to call the disable_unused_functions helper, until we've moved the call to commit_output_state further down and adjusted intel_crtc_disable a bit. The next patch will do that. - Because we don't support (yet) mode changes on more than one crtc at a time, some of the modeset_pipes checks are a bit hackish - but that only needs fixing once we incorporate global modeset support. Signed-Off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_display.c | 99 +++++++++++++++++++++------------ 1 files changed, 63 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index b69afbc..d946f73 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6791,6 +6791,12 @@ intel_modeset_affected_pipes(struct drm_crtc *crtc, unsigned *modeset_pipes, *prepare_pipes &= ~(*disable_pipes); } +#define for_each_intel_crtc_masked(dev, mask, intel_crtc) \ + list_for_each_entry((intel_crtc), \ + &(dev)->mode_config.crtc_list, \ + base.head) \ + if (mask & (1 <<(intel_crtc)->pipe)) \ + bool intel_crtc_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode, int x, int y, @@ -6801,73 +6807,92 @@ bool intel_crtc_set_mode(struct drm_crtc *crtc, struct drm_display_mode *adjusted_mode, saved_mode, saved_hwmode; struct drm_encoder_helper_funcs *encoder_funcs; struct drm_encoder *encoder; - unsigned disable_pipe, prepare_pipes, modeset_pipes; + struct intel_crtc *intel_crtc; + unsigned disable_pipes, prepare_pipes, modeset_pipes; bool ret = true; intel_modeset_affected_pipes(crtc, &modeset_pipes, - &prepare_pipes, &disable_pipe); + &prepare_pipes, &disable_pipes); + + DRM_DEBUG_KMS("set mode pipe masks: modeset: %x, prepare: %x, disable: %x\n", + modeset_pipes, prepare_pipes, disable_pipes); intel_modeset_commit_output_state(dev); crtc->enabled = drm_helper_crtc_in_use(crtc); - if (!crtc->enabled) { - drm_helper_disable_unused_functions(dev); - return true; - } + for_each_intel_crtc_masked(dev, disable_pipes, intel_crtc) + drm_helper_disable_unused_functions(dev); saved_hwmode = crtc->hwmode; saved_mode = crtc->mode; - adjusted_mode = intel_modeset_adjusted_mode(crtc, mode); - if (IS_ERR(adjusted_mode)) { - return false; - } + /* Hack: Because we don't (yet) support global modeset on multiple + * crtcs, we don't keep track of the new mode for more than one crtc. + * Hence simply check whether any bit is set in modeset_pipes in all the + * pieces of code that are not yet converted to deal with mutliple crtcs + * changing their mode at the same time. */ + adjusted_mode = NULL; + if (modeset_pipes) { + adjusted_mode = intel_modeset_adjusted_mode(crtc, mode); + if (IS_ERR(adjusted_mode)) { + return false; + } - intel_crtc_prepare_encoders(dev); + intel_crtc_prepare_encoders(dev); + } - dev_priv->display.crtc_disable(crtc); + for_each_intel_crtc_masked(dev, prepare_pipes, intel_crtc) + dev_priv->display.crtc_disable(&intel_crtc->base); - crtc->mode = *mode; + if (modeset_pipes) { + crtc->mode = *mode; + crtc->x = x; + crtc->y = y; + } /* Set up the DPLL and any encoders state that needs to adjust or depend * on the DPLL. */ - ret = !intel_crtc_mode_set(crtc, mode, adjusted_mode, x, y, fb); - if (!ret) - goto done; + for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) { + ret = !intel_crtc_mode_set(&intel_crtc->base, + mode, adjusted_mode, + x, y, fb); + if (!ret) + goto done; - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { + list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { - if (encoder->crtc != crtc) - continue; + if (encoder->crtc != &intel_crtc->base) + continue; - DRM_DEBUG_KMS("[ENCODER:%d:%s] set [MODE:%d:%s]\n", - encoder->base.id, drm_get_encoder_name(encoder), - mode->base.id, mode->name); - encoder_funcs = encoder->helper_private; - encoder_funcs->mode_set(encoder, mode, adjusted_mode); + DRM_DEBUG_KMS("[ENCODER:%d:%s] set [MODE:%d:%s]\n", + encoder->base.id, drm_get_encoder_name(encoder), + mode->base.id, mode->name); + encoder_funcs = encoder->helper_private; + encoder_funcs->mode_set(encoder, mode, adjusted_mode); + } } - crtc->x = x; - crtc->y = y; - /* Now enable the clocks, plane, pipe, and connectors that we set up. */ - dev_priv->display.crtc_enable(crtc); + for_each_intel_crtc_masked(dev, prepare_pipes, intel_crtc) + dev_priv->display.crtc_enable(&intel_crtc->base); - /* Store real post-adjustment hardware mode. */ - crtc->hwmode = *adjusted_mode; + if (modeset_pipes) { + /* Store real post-adjustment hardware mode. */ + crtc->hwmode = *adjusted_mode; - /* Calculate and store various constants which - * are later needed by vblank and swap-completion - * timestamping. They are derived from true hwmode. - */ - drm_calc_timestamping_constants(crtc); + /* Calculate and store various constants which + * are later needed by vblank and swap-completion + * timestamping. They are derived from true hwmode. + */ + drm_calc_timestamping_constants(crtc); + } /* FIXME: add subpixel order */ done: drm_mode_destroy(dev, adjusted_mode); - if (!ret) { + if (!ret && crtc->enabled) { crtc->hwmode = saved_hwmode; crtc->mode = saved_mode; } @@ -6875,6 +6900,8 @@ done: return ret; } +#undef for_each_intel_crtc_masked + static void intel_set_config_free(struct intel_set_config *config) { if (config) {