From patchwork Wed Jun 18 13:44:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 4376131 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 F20A69F1C4 for ; Wed, 18 Jun 2014 13:44:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C63A2037A for ; Wed, 18 Jun 2014 13:44:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6214F20375 for ; Wed, 18 Jun 2014 13:44:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 93A476E288; Wed, 18 Jun 2014 06:44:20 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by gabe.freedesktop.org (Postfix) with ESMTP id 152C36E596 for ; Wed, 18 Jun 2014 06:44:18 -0700 (PDT) Received: by mail-wi0-f178.google.com with SMTP id n15so1153650wiw.17 for ; Wed, 18 Jun 2014 06:44:18 -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=JqX2ppT1gyEJT5mzQzZNbna9oOvMqpgxIS1cj0m0N/E=; b=k9ipdnp6CN7hsrCFVRsm6yLX0CvX2MyL9c/PCuPR98mSdrL1dHHCv1sCjFevdB1efB 6uphy78JZ8w0pUJQf9+LiSuFUVAXzKMIlXVGFr3xcuS2Q6PKSx1oH3bngPjVYwF6A9v2 K4wxH2kMiiYndEtA0yf47svYqOnHM/OPih2zw73a3A4Z2SqN452riEkb3ev9azIHugks oCe/684XFmDZwMba+hKYQNNci01ca/At9tfy42/2ZOILJ4JW8XLEUvYFjPPKv+GIXT2i 4zVijUTDC0BFYUIIax80f2Rs1q1+1vO0WMAo8sXGpq9Mk0N/LUCKvfJZbrUwY98lZTCi UjyQ== X-Gm-Message-State: ALoCoQmXY3I5hJBwTt24SKJnOn6/wUL+oFqSnA/hN7CUT72qCC7GGWHZZdcnHT8rimazakf8Z0j3 X-Received: by 10.180.83.200 with SMTP id s8mr5218519wiy.2.1403099058224; Wed, 18 Jun 2014 06:44:18 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id s14sm13919923wij.1.2014.06.18.06.44.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jun 2014 06:44:17 -0700 (PDT) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Wed, 18 Jun 2014 14:44:12 +0100 Message-Id: <1403099053-31243-4-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1403099053-31243-1-git-send-email-thomas.wood@intel.com> References: <1403099053-31243-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/4] lib: add igt_enable_connectors and igt_reset_connectors 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 igt_enable_connectors forces connectors to be enabled where doing so is known to work well. igt_reset_connectors resets the force state on all connectors. --- lib/igt_kms.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 3 +++ 2 files changed, 73 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 86dec51..3fcb0da 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1148,3 +1148,73 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe) igt_assert(drmWaitVBlank(drm_fd, &wait_vbl) == 0); } + +static void reset_connectors_at_exit(int sig) +{ + igt_reset_connectors(); +} + +/** + * igt_enable_connectors: + * + * Force connectors to be enabled where this is known to work well. Use + * #igt_reset_connectors to revert the changes. + * + * An exit handler is installed to ensure connectors are reset when the test + * exits. + */ +void igt_enable_connectors(void) +{ + drmModeRes *res; + drmModeConnector *c; + int drm_fd; + + drm_fd = drm_open_any(); + + res = drmModeGetResources(drm_fd); + + for (int i = 0; i < res->count_connectors; i++) { + + c = drmModeGetConnector(drm_fd, res->connectors[i]); + + /* don't attempt to force connectors that are already connected + */ + if (c->connection == DRM_MODE_CONNECTED) + continue; + + /* just enable VGA for now */ + if (c->connector_type == DRM_MODE_CONNECTOR_VGA) + kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_ON); + + drmModeFreeConnector(c); + } + close(drm_fd); + + igt_install_exit_handler(reset_connectors_at_exit); +} + +/** + * igt_reset_connectors: + * + * Remove any forced state from the connectors. + */ +void igt_reset_connectors(void) +{ + drmModeRes *res; + drmModeConnector *c; + int drm_fd; + + drm_fd = drm_open_any(); + res = drmModeGetResources(drm_fd); + + for (int i = 0; i < res->count_connectors; i++) { + + c = drmModeGetConnector(drm_fd, res->connectors[i]); + + kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_UNSPECIFIED); + + drmModeFreeConnector(c); + } + + close(drm_fd); +} diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 4cf74e8..d9b2c64 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -217,5 +217,8 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe); #define IGT_FIXED(i,f) ((i) << 16 | (f)) +void igt_enable_connectors(void); +void igt_reset_connectors(void); + #endif /* __IGT_KMS_H__ */