From patchwork Thu Jul 26 18:49:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1245131 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 46A1ADFFCE for ; Thu, 26 Jul 2012 20:36:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EDD49E9FE for ; Thu, 26 Jul 2012 13:36:37 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by gabe.freedesktop.org (Postfix) with ESMTP id ABFDA9EC4F for ; Thu, 26 Jul 2012 12:57:09 -0700 (PDT) Received: by mail-we0-f177.google.com with SMTP id r3so1738770wey.36 for ; Thu, 26 Jul 2012 12:57:09 -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=8nUz7gayCBiJDAdmK4WTxqmJVZgoKZjkh81GaYr8fEY=; b=EXnWIi4IMo/44uOWsBv3uHJhNISGX+jCNm0JiQFjsg6ClGxPC6Qw4GZDlVXy6uoQDw bX2KH2J1M68EpTqovf6u1BTpSCGff+yYJ4TEkN3I/N1Ih3XNyIyQdHn+Dl4csO6q+oiG SbVJ2PwETWeLS39mC5oPVksjXKsWGtWZYLlxk= 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=8nUz7gayCBiJDAdmK4WTxqmJVZgoKZjkh81GaYr8fEY=; b=nxxq24DstpMkTWtqqU7M5ZBsqWPAryTS/k1tH4OwMtpscfqX6suLSusNDvkYOSpn2f c6pF6XpHoR8n7mDKKRgKY1yHr1L84t4CgM1m8TpjFq2c33920NoMUWnfUrNoGFIjH93j dmLzlKnGOylVSN/5j79nwhM9syN5tJbFnxD1kxYc6Xn0yFOrvJUr1wHZjFgelcBgEuaE zGeQiE5yeoJnZoz8wSdXBMAuPImb5P4J5VPrZP4+9a99ROFAlP4EelqnVCBeTPIKafC0 8YjxpMH9FEezXSpW2RimEppvXBx5C/1blW1fEPavkzqnHKCfbpJMDTlyZKJyLbyvkfSM RMXQ== Received: by 10.180.81.38 with SMTP id w6mr133219wix.10.1343332629453; Thu, 26 Jul 2012 12:57:09 -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 fr4sm391403wib.8.2012.07.26.12.57.08 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 12:57:08 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Thu, 26 Jul 2012 20:49:10 +0200 Message-Id: <1343328581-2324-46-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1343328581-2324-1-git-send-email-daniel.vetter@ffwll.ch> References: <1343328581-2324-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQl2MszXgDQ27e5iEGA7y3b2APjS0IEduedaaTguP7d1xYhhIYtkiPl9PahTTYc3ZIJRLAvT Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 45/76] drm/i915: extract intel_set_config_compute_mode_changes 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 This computes what exactly changed in the modeset configuration, i.e. whether a full modeset is required or only an update of the framebuffer base address or no change at all. In the future we might add more checks for e.g. when only the output mode changed, so that we could do a minimal modeset for outputs that support this. Like the lvds/eDP panels where we only need to update the panel fitter. Signed-Off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_display.c | 81 +++++++++++++++++++--------------- drivers/gpu/drm/i915/intel_drv.h | 3 ++ 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 2e5edc7..b109710 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6731,14 +6731,46 @@ static void intel_set_config_restore_state(struct drm_device *dev, } } +static void +intel_set_config_compute_mode_changes(struct drm_mode_set *set, + struct intel_set_config *config) +{ + + /* We should be able to check here if the fb has the same properties + * and then just flip_or_move it */ + if (set->crtc->fb != set->fb) { + /* If we have no fb then treat it as a full mode set */ + if (set->crtc->fb == NULL) { + DRM_DEBUG_KMS("crtc has no fb, full mode set\n"); + config->mode_changed = true; + } else if (set->fb == NULL) { + config->mode_changed = true; + } else if (set->fb->depth != set->crtc->fb->depth) { + config->mode_changed = true; + } else if (set->fb->bits_per_pixel != + set->crtc->fb->bits_per_pixel) { + config->mode_changed = true; + } else + config->fb_changed = true; + } + + if (set->x != set->crtc->x || set->y != set->crtc->y) + config->fb_changed = true; + + if (set->mode && !drm_mode_equal(set->mode, &set->crtc->mode)) { + DRM_DEBUG_KMS("modes are different, full mode set\n"); + drm_mode_debug_printmodeline(&set->crtc->mode); + drm_mode_debug_printmodeline(set->mode); + config->mode_changed = true; + } +} + static int intel_crtc_set_config(struct drm_mode_set *set) { struct drm_device *dev; struct drm_crtc *new_crtc; struct drm_encoder *new_encoder; struct drm_framebuffer *old_fb = NULL; - bool mode_changed = false; /* if true do a full mode set */ - bool fb_changed = false; /* if true and !mode_changed just do a flip */ struct drm_connector *connector; int count = 0, ro; struct drm_mode_set save_set; @@ -6786,33 +6818,11 @@ static int intel_crtc_set_config(struct drm_mode_set *set) save_set.y = set->crtc->y; save_set.fb = set->crtc->fb; - /* We should be able to check here if the fb has the same properties - * and then just flip_or_move it */ - if (set->crtc->fb != set->fb) { - /* If we have no fb then treat it as a full mode set */ - if (set->crtc->fb == NULL) { - DRM_DEBUG_KMS("crtc has no fb, full mode set\n"); - mode_changed = true; - } else if (set->fb == NULL) { - mode_changed = true; - } else if (set->fb->depth != set->crtc->fb->depth) { - mode_changed = true; - } else if (set->fb->bits_per_pixel != - set->crtc->fb->bits_per_pixel) { - mode_changed = true; - } else - fb_changed = true; - } - - if (set->x != set->crtc->x || set->y != set->crtc->y) - fb_changed = true; - - if (set->mode && !drm_mode_equal(set->mode, &set->crtc->mode)) { - DRM_DEBUG_KMS("modes are different, full mode set\n"); - drm_mode_debug_printmodeline(&set->crtc->mode); - drm_mode_debug_printmodeline(set->mode); - mode_changed = true; - } + /* Compute whether we need a full modeset, only an fb base update or no + * change at all. In the future we might also check whether only the + * mode changed, e.g. for LVDS where we only change the panel fitter in + * such cases. */ + intel_set_config_compute_mode_changes(set, config); /* a) traverse passed in connector list and get encoders for them */ count = 0; @@ -6828,7 +6838,7 @@ static int intel_crtc_set_config(struct drm_mode_set *set) if (new_encoder != connector->encoder) { DRM_DEBUG_KMS("encoder changed, full mode switch\n"); - mode_changed = true; + config->mode_changed = true; /* If the encoder is reused for another connector, then * the appropriate crtc will be set later. */ @@ -6856,12 +6866,11 @@ static int intel_crtc_set_config(struct drm_mode_set *set) /* Make sure the new CRTC will work with the encoder */ if (new_crtc && !intel_encoder_crtc_ok(connector->encoder, new_crtc)) { - ret = -EINVAL; - goto fail; + return -EINVAL; } if (new_crtc != connector->encoder->crtc) { DRM_DEBUG_KMS("crtc changed, full mode switch\n"); - mode_changed = true; + config->mode_changed = true; connector->encoder->crtc = new_crtc; } if (new_crtc) { @@ -6874,7 +6883,7 @@ static int intel_crtc_set_config(struct drm_mode_set *set) } } - if (mode_changed) { + if (config->mode_changed) { set->crtc->enabled = drm_helper_crtc_in_use(set->crtc); if (set->crtc->enabled) { DRM_DEBUG_KMS("attempting to set mode from" @@ -6898,7 +6907,7 @@ static int intel_crtc_set_config(struct drm_mode_set *set) } } drm_helper_disable_unused_functions(dev); - } else if (fb_changed) { + } else if (config->fb_changed) { set->crtc->x = set->x; set->crtc->y = set->y; @@ -6921,7 +6930,7 @@ fail: intel_set_config_restore_state(dev, config); /* Try to restore the config */ - if (mode_changed && + if (config->mode_changed && !intel_set_mode(save_set.crtc, save_set.mode, save_set.x, save_set.y, save_set.fb)) DRM_ERROR("failed to restore config after modeset failure\n"); diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index ed47b27..5f36119 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -427,6 +427,9 @@ struct intel_set_config { struct drm_connector *save_connectors; struct drm_encoder *save_encoders; struct drm_crtc *save_crtcs; + + bool fb_changed; + bool mode_changed; }; extern bool intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,