From patchwork Thu Aug 14 15:40:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 4724561 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 7B0D69F377 for ; Thu, 14 Aug 2014 15:40:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B814F201BC for ; Thu, 14 Aug 2014 15:40:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B571820160 for ; Thu, 14 Aug 2014 15:40:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A2E4F6E6DC; Thu, 14 Aug 2014 08:40:44 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by gabe.freedesktop.org (Postfix) with ESMTP id 72C306E6D3 for ; Thu, 14 Aug 2014 08:40:43 -0700 (PDT) Received: by mail-wi0-f173.google.com with SMTP id f8so9151370wiw.6 for ; Thu, 14 Aug 2014 08:40:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Qh6TwPBvFbeAz//xyfZVNzhKGBxHoiQno5D7W/N+2aw=; b=PP9qVQo9lSAHAwNUa1yCi+p95awOlWFbI8jsSu+iGSftQyxR/5/9yX6OhE5okpCdk5 ov3e5yPm+gO2r8h54L+P/tupxE2Aeu1gM7IP40FUUuKvs58nHO/uWrSP8sNN9vyqKGoK m7F5Cvn+gvX0J1FbYG2iRm+tWMwxMt6ZpP0Eeyghu8lNjUY0v36qhF4Zw1K38B6yWWFR qYYSSDaMgWiOYiuCH+DBYS7T0GNrCos4m4LOun4FfOuv9QnONzYhfaYzz09hA+9yWy9y z1wYR+lq2XrXYm5GM0TlTFXmEVhppADjOK8KXbbem2cCjQbWjWvFL3p6zlCrNmjB7Ohh /b6g== X-Gm-Message-State: ALoCoQkCWuZzvJo7kERYpZSLXztb2/GzyQiy4KvWfjMgmItml6RkeViPhAEAArenkU3vYxEkPUS3 X-Received: by 10.180.106.138 with SMTP id gu10mr47926999wib.21.1408030842578; Thu, 14 Aug 2014 08:40:42 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id kz6sm796558wjb.47.2014.08.14.08.40.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Aug 2014 08:40:41 -0700 (PDT) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Thu, 14 Aug 2014 16:40:37 +0100 Message-Id: <1408030838-19097-2-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1408030838-19097-1-git-send-email-thomas.wood@intel.com> References: <1408030838-19097-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 1/2] lib: add igt_restore_vt_mode X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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.9 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 Add a function to restore the previous VT mode after igt_set_vt_graphics_mode is called. Signed-off-by: Thomas Wood --- lib/igt_kms.c | 27 +++++++++++++++++++++------ lib/igt_kms.h | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 11fd4e2..a414d96 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -269,17 +269,30 @@ err: static unsigned long orig_vt_mode = -1UL; -static void restore_vt_mode_at_exit(int sig) +/** + * kmstest_restore_vt_mode: + * + * Restore the VT mode in use before #kmstest_set_vt_graphics_mode was called. + */ +void kmstest_restore_vt_mode(void) { - if (orig_vt_mode != -1UL) - set_vt_mode(orig_vt_mode); + long ret; + + if (orig_vt_mode != -1UL) { + ret = set_vt_mode(orig_vt_mode); + orig_vt_mode = -1UL; + + igt_assert(ret >= 0); + igt_debug("VT: original mode restored\n"); + } } /** * kmstest_set_vt_graphics_mode: * - * Sets the controlling VT (if available) into graphics/raw mode and installs an - * igt exit handler to set the VT back to text mode on exit. + * Sets the controlling VT (if available) into graphics/raw mode and installs + * an igt exit handler to set the VT back to text mode on exit. Use + * #kmstest_restore_vt_mode to restore the previous VT mode manually. * * All kms tests must call this function to make sure that the fbcon doesn't * interfere by e.g. blanking the screen. @@ -288,7 +301,7 @@ void kmstest_set_vt_graphics_mode(void) { long ret; - igt_install_exit_handler(restore_vt_mode_at_exit); + igt_install_exit_handler((igt_exit_handler_t) kmstest_restore_vt_mode); igt_disable_exit_handler(); ret = set_vt_mode(KD_GRAPHICS); @@ -296,6 +309,8 @@ void kmstest_set_vt_graphics_mode(void) igt_assert(ret >= 0); orig_vt_mode = ret; + + igt_debug("VT: graphics mode set\n"); } static int get_card_number(int fd) diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 754d856..4263a01 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -102,6 +102,7 @@ void kmstest_dump_mode(drmModeModeInfo *mode); int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id); void kmstest_set_vt_graphics_mode(void); +void kmstest_restore_vt_mode(void); struct kmstest_connector_config { drmModeCrtc *crtc;