Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/4] kms_flip: do a DPMS ON when exiting with error
Date: Wed, 22 May 2013 17:40:47 +0300	[thread overview]
Message-ID: <1369233648-5873-3-git-send-email-imre.deak@intel.com> (raw)
In-Reply-To: <1369233648-5873-1-git-send-email-imre.deak@intel.com>

Currently when exiting with error, we'll get stuck in a DPMS OFF state
if the error happens while we have DPMS OFF set in the test sequence.
This happens even though we switch back to text mode at exit. This might
be a bug in itself to be fixed later, but in any case we want a working
console, so do an explicit DPMS ON.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 tests/kms_flip.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 85e5c11..83293ba 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -78,6 +78,8 @@ uint32_t devid;
 int test_time = 3;
 static bool monotonic_timestamp;
 
+static drmModeConnector *last_connector;
+
 uint32_t *fb_ptr;
 
 struct type_name {
@@ -190,14 +192,14 @@ static void emit_dummy_load(struct test_output *o)
 	drm_intel_bo_unreference(target_bo);
 }
 
-static int set_dpms(struct test_output *o, int mode)
+static int set_connector_dpms(drmModeConnector *connector, int mode)
 {
 	int i, dpms = 0;
 
-	for (i = 0; i < o->connector->count_props; i++) {
+	for (i = 0; i < connector->count_props; i++) {
 		struct drm_mode_get_property prop;
 
-		prop.prop_id = o->connector->props[i];
+		prop.prop_id = connector->props[i];
 		prop.count_values = 0;
 		prop.count_enum_blobs = 0;
 		if (drmIoctl(drm_fd, DRM_IOCTL_MODE_GETPROPERTY, &prop))
@@ -210,12 +212,19 @@ static int set_dpms(struct test_output *o, int mode)
 		break;
 	}
 	if (!dpms) {
-		fprintf(stderr, "DPMS property not found on %d\n", o->id);
+		fprintf(stderr, "DPMS property not found on %d\n",
+			connector->connector_id);
 		errno = ENOENT;
 		return -1;
 	}
 
-	return drmModeConnectorSetProperty(drm_fd, o->id, dpms, mode);
+	return drmModeConnectorSetProperty(drm_fd, connector->connector_id,
+					   dpms, mode);
+}
+
+static int set_dpms(struct test_output *o, int mode)
+{
+	return set_connector_dpms(o->connector, mode);
 }
 
 static void set_flag(unsigned int *v, unsigned int flag)
@@ -1037,6 +1046,8 @@ static void run_test_on_crtc(struct test_output *o, int crtc, int duration)
 	if (!o->mode_valid)
 		return;
 
+	last_connector = o->connector;
+
 	fprintf(stdout, "Beginning %s on crtc %d, connector %d\n",
 		o->test_name, crtc, o->id);
 
@@ -1104,6 +1115,8 @@ static void run_test_on_crtc(struct test_output *o, int crtc, int duration)
 	kmstest_remove_fb(drm_fd, o->fb_ids[1]);
 	kmstest_remove_fb(drm_fd, o->fb_ids[0]);
 
+	last_connector = NULL;
+
 	drmModeFreeEncoder(o->encoder);
 	drmModeFreeConnector(o->connector);
 }
@@ -1154,6 +1167,12 @@ static void get_timestamp_format(void)
 		monotonic_timestamp ? "monotonic" : "real");
 }
 
+static void kms_flip_exit_handler(int sig)
+{
+	if (last_connector)
+		set_connector_dpms(last_connector, DRM_MODE_DPMS_ON);
+}
+
 int main(int argc, char **argv)
 {
 	struct {
@@ -1208,6 +1227,7 @@ int main(int argc, char **argv)
 
 	if (!drmtest_only_list_subtests()) {
 		do_or_die(drmtest_set_vt_graphics_mode());
+		do_or_die(drmtest_install_exit_handler(kms_flip_exit_handler));
 		get_timestamp_format();
 	}
 
-- 
1.8.1.2

  parent reply	other threads:[~2013-05-22 14:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-22 14:40 [PATCH 1/4] lib: fix exit handler when multiple handlers are registered Imre Deak
2013-05-22 14:40 ` [PATCH 2/4] lib: export the exit handler interface Imre Deak
2013-05-22 14:40 ` Imre Deak [this message]
2013-05-22 14:40 ` [PATCH 4/4] kms_flip: add subtests for the DPMS OFF->modeset->flip sequence Imre Deak
2013-05-22 16:18   ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369233648-5873-3-git-send-email-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox