From patchwork Mon Feb 1 13:57:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: durgadoss.r@intel.com X-Patchwork-Id: 8179511 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8CDE8BEEE5 for ; Mon, 1 Feb 2016 13:24:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF53220451 for ; Mon, 1 Feb 2016 13:24:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C330520450 for ; Mon, 1 Feb 2016 13:24:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 475776E3D1; Mon, 1 Feb 2016 05:24:06 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id A1F516E2E0 for ; Mon, 1 Feb 2016 05:24:04 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 01 Feb 2016 05:24:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,380,1449561600"; d="scan'208";a="645145592" Received: from dr3-desktop.iind.intel.com ([10.223.26.125]) by FMSMGA003.fm.intel.com with ESMTP; 01 Feb 2016 05:24:03 -0800 From: Durgadoss R To: intel-gfx@lists.freedesktop.org Date: Mon, 1 Feb 2016 19:27:51 +0530 Message-Id: <1454335073-20405-3-git-send-email-durgadoss.r@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454335073-20405-1-git-send-email-durgadoss.r@intel.com> References: <1454335073-20405-1-git-send-email-durgadoss.r@intel.com> Cc: ander.conselvan.de.oliveira@intel.com Subject: [Intel-gfx] [PATCHv2 2/4] drm/i915: Make finding unused crtc as a generic function 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.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 Looping over the crtc list and finding an unused crtc has users other than load_detect(). Hence move it to a common function so that we can re-use the logic. Signed-off-by: Durgadoss R Reviewed-by: Ander Conselvan de Oliveira --- drivers/gpu/drm/i915/intel_display.c | 37 ++++++++++++++++++++++-------------- drivers/gpu/drm/i915/intel_drv.h | 1 + 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 92cd5c6..af50e61 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -10417,6 +10417,27 @@ static int intel_modeset_setup_plane_state(struct drm_atomic_state *state, return 0; } +struct drm_crtc *intel_get_unused_crtc(struct drm_encoder *encoder) +{ + struct drm_crtc *possible_crtc; + struct drm_crtc *crtc = NULL; + struct drm_device *dev = encoder->dev; + int i = -1; + + for_each_crtc(dev, possible_crtc) { + i++; + if (!(encoder->possible_crtcs & (1 << i))) + continue; + if (possible_crtc->state->enable) + continue; + + crtc = possible_crtc; + break; + } + + return crtc; +} + bool intel_get_load_detect_pipe(struct drm_connector *connector, struct drm_display_mode *mode, struct intel_load_detect_pipe *old, @@ -10425,7 +10446,6 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector, struct intel_crtc *intel_crtc; struct intel_encoder *intel_encoder = intel_attached_encoder(connector); - struct drm_crtc *possible_crtc; struct drm_encoder *encoder = &intel_encoder->base; struct drm_crtc *crtc = NULL; struct drm_device *dev = encoder->dev; @@ -10434,7 +10454,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector, struct drm_atomic_state *state = NULL; struct drm_connector_state *connector_state; struct intel_crtc_state *crtc_state; - int ret, i = -1; + int ret; DRM_DEBUG_KMS("[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", connector->base.id, connector->name, @@ -10476,21 +10496,10 @@ retry: return true; } - /* Find an unused one (if possible) */ - for_each_crtc(dev, possible_crtc) { - i++; - if (!(encoder->possible_crtcs & (1 << i))) - continue; - if (possible_crtc->state->enable) - continue; - - crtc = possible_crtc; - break; - } - /* * If we didn't find an unused CRTC, don't use any. */ + crtc = intel_get_unused_crtc(encoder); if (!crtc) { DRM_DEBUG_KMS("no pipe available for load-detect\n"); goto fail; diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index c7a6e32..9fe7c4b 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -1106,6 +1106,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector, void intel_release_load_detect_pipe(struct drm_connector *connector, struct intel_load_detect_pipe *old, struct drm_modeset_acquire_ctx *ctx); +struct drm_crtc *intel_get_unused_crtc(struct drm_encoder *encoder); int intel_pin_and_fence_fb_obj(struct drm_plane *plane, struct drm_framebuffer *fb, const struct drm_plane_state *plane_state);