All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 0/4] enabling connectors (v2)
@ 2014-06-18 13:44 Thomas Wood
  2014-06-18 13:44 ` [PATCH i-g-t 1/4] lib: add function to change connector states Thomas Wood
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Thomas Wood @ 2014-06-18 13:44 UTC (permalink / raw)
  To: intel-gfx

The following series is a replacement for the previous series that enabled
connector states to be modified. It now uses the debugfs interface to change
the connection state of connectors and also adds the ability to override the
EDID blocks on the connectors.


Thomas Wood (4):
  lib: add function to change connector states
  lib: add the ability to set an EDID data block on a connector
  lib: add igt_enable_connectors and igt_reset_connectors
  tests: enable extra connectors in kms_flip and kms_pipe_crc_basic

 .../intel-gpu-tools/intel-gpu-tools-docs.xml       |   1 +
 lib/Makefile.sources                               |   1 +
 lib/igt_edid.h                                     | 125 +++++++++++++++
 lib/igt_kms.c                                      | 169 +++++++++++++++++++++
 lib/igt_kms.h                                      |  42 +++++
 tests/Makefile.sources                             |   1 +
 tests/kms_flip.c                                   |   2 +
 tests/kms_force_connector.c                        | 113 ++++++++++++++
 tests/kms_pipe_crc_basic.c                         |   2 +
 9 files changed, 456 insertions(+)
 create mode 100644 lib/igt_edid.h
 create mode 100644 tests/kms_force_connector.c

-- 
1.9.3

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH i-g-t 1/4] lib: add function to change connector states
  2014-06-18 13:44 [PATCH i-g-t 0/4] enabling connectors (v2) Thomas Wood
@ 2014-06-18 13:44 ` Thomas Wood
  2014-06-18 14:05   ` Chris Wilson
  2014-06-18 13:44 ` [PATCH i-g-t 2/4] lib: add the ability to set an EDID data block on a connector Thomas Wood
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Thomas Wood @ 2014-06-18 13:44 UTC (permalink / raw)
  To: intel-gfx

Add an API function and a test program to force a particular state on a
connector.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 lib/igt_kms.c               | 57 +++++++++++++++++++++++++++++
 lib/igt_kms.h               | 16 ++++++++
 tests/Makefile.sources      |  1 +
 tests/kms_force_connector.c | 89 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 163 insertions(+)
 create mode 100644 tests/kms_force_connector.c

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index c0f4f6c..8de8e0a 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -384,6 +384,63 @@ err1:
 	return -1;
 }
 
+static int get_card_number(int fd)
+{
+	struct stat buf;
+
+	/* find the minor number of the device */
+	fstat(fd, &buf);
+
+	return minor(buf.st_rdev);
+}
+
+/**
+ * kmstest_force_connector:
+ * @fd: drm file descriptor
+ * @connector: connector
+ * @state: state to force on @connector
+ *
+ * Force the specified state on the specified connector.
+ */
+void kmstest_force_connector(int drm_fd, drmModeConnector *connector, enum
+			     kmstest_force_connector_state state)
+{
+	char *path;
+	const char *value;
+	int debugfs_fd, ret;
+
+	switch (state) {
+	case FORCE_CONNECTOR_ON:
+		value = "on";
+		break;
+	case FORCE_CONNECTOR_DIGITAL:
+		value = "digital";
+		break;
+	case FORCE_CONNECTOR_OFF:
+		value = "off";
+		break;
+
+	default:
+	case FORCE_CONNECTOR_UNSPECIFIED:
+		value = "unspecified";
+		break;
+	}
+
+	asprintf(&path, "/sys/kernel/debug/dri/%d/%s-%d/force",
+		 get_card_number(drm_fd),
+		 kmstest_connector_type_str(connector->connector_type),
+		 connector->connector_type_id);
+	debugfs_fd = open(path, O_WRONLY | O_TRUNC);
+	free(path);
+
+	igt_assert(debugfs_fd != -1);
+
+	ret = write(debugfs_fd, value, strlen(value));
+	close(debugfs_fd);
+
+	igt_assert(ret != -1);
+}
+
 void kmstest_free_connector_config(struct kmstest_connector_config *config)
 {
 	drmModeFreeCrtc(config->crtc);
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 7d015b4..45a98c8 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -76,11 +76,27 @@ struct kmstest_connector_config {
 	int pipe;
 };
 
+/**
+ * kmstest_force_connector_state:
+ * @FORCE_CONNECTOR_UNSPECIFIED: Unspecified
+ * @FORCE_CONNECTOR_ON: On
+ * @FORCE_CONNECTOR_DIGITAL: Digital
+ * @FORCE_CONNECTOR_OFF: Off
+ */
+enum kmstest_force_connector_state {
+	FORCE_CONNECTOR_UNSPECIFIED,
+	FORCE_CONNECTOR_ON,
+	FORCE_CONNECTOR_DIGITAL,
+	FORCE_CONNECTOR_OFF
+};
+
 int kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 				      drmModeModeInfo *mode);
 int kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
 				 unsigned long crtc_idx_mask,
 				 struct kmstest_connector_config *config);
+void kmstest_force_connector(int fd, drmModeConnector *connector,
+			     enum kmstest_force_connector_state state);
 void kmstest_free_connector_config(struct kmstest_connector_config *config);
 
 void kmstest_dump_mode(drmModeModeInfo *mode);
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 17c0ab9..dc08a3c 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -138,6 +138,7 @@ TESTS_progs = \
 	gen3_render_tiledx_blits \
 	gen3_render_tiledy_blits \
 	gen7_forcewake_mt \
+	kms_force_connector \
 	kms_sink_crc_basic \
 	kms_fence_pin_leak \
 	pm_psr \
diff --git a/tests/kms_force_connector.c b/tests/kms_force_connector.c
new file mode 100644
index 0000000..0591da0
--- /dev/null
+++ b/tests/kms_force_connector.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#include "igt_core.h"
+#include "igt_kms.h"
+#include "drmtest.h"
+
+int
+main (int argc, char **argv)
+{
+	/* force the VGA output and test that it worked */
+	int drm_fd;
+	drmModeRes *res;
+	drmModeConnector *connector, *temp;
+	igt_display_t display;
+
+	igt_simple_init();
+
+	drm_fd = drm_open_any();
+	res = drmModeGetResources(drm_fd);
+
+	/* find the vga connector */
+	for (int i = 0; i < res->count_connectors; i++) {
+
+		connector = drmModeGetConnector(drm_fd, res->connectors[i]);
+
+		if (connector->connector_type == DRM_MODE_CONNECTOR_VGA)
+			break;
+
+		drmModeFreeConnector(connector);
+
+		connector = NULL;
+	}
+
+	igt_assert(connector);
+
+	/* force the connector on and check the reported values */
+	kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON);
+	temp = drmModeGetConnector(drm_fd, connector->connector_id);
+	igt_assert(temp->connection == DRM_MODE_CONNECTED);
+	igt_assert(temp->count_modes > 0);
+	drmModeFreeConnector(temp);
+
+	/* attempt to use the display */
+	igt_set_vt_graphics_mode();
+
+	igt_display_init(&display, drm_fd);
+	igt_display_commit(&display);
+
+
+	/* force the connector off */
+	kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_OFF);
+	temp = drmModeGetConnector(drm_fd, connector->connector_id);
+	igt_assert(temp->connection == DRM_MODE_DISCONNECTED);
+	igt_assert(temp->count_modes == 0);
+	drmModeFreeConnector(temp);
+
+
+	/* check that the previous state is restored */
+	kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_UNSPECIFIED);
+	temp = drmModeGetConnector(drm_fd, connector->connector_id);
+	igt_assert(temp->connection == connector->connection);
+	drmModeFreeConnector(temp);
+
+	drmModeFreeConnector(connector);
+
+	igt_success();
+}
-- 
1.9.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH i-g-t 2/4] lib: add the ability to set an EDID data block on a connector
  2014-06-18 13:44 [PATCH i-g-t 0/4] enabling connectors (v2) Thomas Wood
  2014-06-18 13:44 ` [PATCH i-g-t 1/4] lib: add function to change connector states Thomas Wood
@ 2014-06-18 13:44 ` Thomas Wood
  2014-06-18 13:57   ` Daniel Vetter
  2014-06-18 13:44 ` [PATCH i-g-t 3/4] lib: add igt_enable_connectors and igt_reset_connectors Thomas Wood
  2014-06-18 13:44 ` [PATCH i-g-t 4/4] tests: enable extra connectors in kms_flip and kms_pipe_crc_basic Thomas Wood
  3 siblings, 1 reply; 8+ messages in thread
From: Thomas Wood @ 2014-06-18 13:44 UTC (permalink / raw)
  To: intel-gfx

Add a function to set an EDID data block on a connector and include a
set of generic EDID blocks for testing.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 .../intel-gpu-tools/intel-gpu-tools-docs.xml       |   1 +
 lib/Makefile.sources                               |   1 +
 lib/igt_edid.h                                     | 125 +++++++++++++++++++++
 lib/igt_kms.c                                      |  50 ++++++++-
 lib/igt_kms.h                                      |  23 ++++
 tests/kms_force_connector.c                        |  24 ++++
 6 files changed, 220 insertions(+), 4 deletions(-)
 create mode 100644 lib/igt_edid.h

diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
index 68ca8d4..3d9caf8 100644
--- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
+++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
@@ -25,6 +25,7 @@
     <xi:include href="xml/intel_batchbuffer.xml"/>
     <xi:include href="xml/intel_chipset.xml"/>
     <xi:include href="xml/intel_io.xml"/>
+    <xi:include href="xml/igt_edid.xml"/>
 
   </chapter>
   <index id="api-index-full">
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 62a0c75..8c6c4dc 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -40,6 +40,7 @@ libintel_tools_la_SOURCES = 	\
 	intel_iosf.c		\
 	igt_kms.c		\
 	igt_kms.h		\
+	igt_edid.h		\
 	igt_fb.c		\
 	igt_fb.h		\
 	igt_core.c		\
diff --git a/lib/igt_edid.h b/lib/igt_edid.h
new file mode 100644
index 0000000..27373b7
--- /dev/null
+++ b/lib/igt_edid.h
@@ -0,0 +1,125 @@
+/*
+ * generic edid taken from Linux, drivers/gpu/drm/drm_edid_load.c:
+ *
+ *
+   drm_edid_load.c: use a built-in EDID data set or load it via the firmware
+		    interface
+
+   Copyright (C) 2012 Carsten Emde <C.Emde@osadl.org>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2
+   of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+*/
+
+#ifndef __IGT_EDID_H__
+#define __IGT_EDID_H__
+
+#include "igt_kms.h"
+
+#define EDID_LENGTH 128
+
+static const unsigned char generic_edid[MAX_EDIDS][EDID_LENGTH] = {
+	{
+	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+	0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x05, 0x16, 0x01, 0x03, 0x6d, 0x23, 0x1a, 0x78,
+	0xea, 0x5e, 0xc0, 0xa4, 0x59, 0x4a, 0x98, 0x25,
+	0x20, 0x50, 0x54, 0x00, 0x08, 0x00, 0x61, 0x40,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x64, 0x19,
+	0x00, 0x40, 0x41, 0x00, 0x26, 0x30, 0x08, 0x90,
+	0x36, 0x00, 0x63, 0x0a, 0x11, 0x00, 0x00, 0x18,
+	0x00, 0x00, 0x00, 0xff, 0x00, 0x4c, 0x69, 0x6e,
+	0x75, 0x78, 0x20, 0x23, 0x30, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3b,
+	0x3d, 0x2f, 0x31, 0x07, 0x00, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
+	0x00, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x58,
+	0x47, 0x41, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x55,
+	},
+	{
+	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+	0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x05, 0x16, 0x01, 0x03, 0x6d, 0x2c, 0x23, 0x78,
+	0xea, 0x5e, 0xc0, 0xa4, 0x59, 0x4a, 0x98, 0x25,
+	0x20, 0x50, 0x54, 0x00, 0x00, 0x00, 0x81, 0x80,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x30, 0x2a,
+	0x00, 0x98, 0x51, 0x00, 0x2a, 0x40, 0x30, 0x70,
+	0x13, 0x00, 0xbc, 0x63, 0x11, 0x00, 0x00, 0x1e,
+	0x00, 0x00, 0x00, 0xff, 0x00, 0x4c, 0x69, 0x6e,
+	0x75, 0x78, 0x20, 0x23, 0x30, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3b,
+	0x3d, 0x3e, 0x40, 0x0b, 0x00, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
+	0x00, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x53,
+	0x58, 0x47, 0x41, 0x0a, 0x20, 0x20, 0x00, 0xa0,
+	},
+	{
+	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+	0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x05, 0x16, 0x01, 0x03, 0x6d, 0x37, 0x29, 0x78,
+	0xea, 0x5e, 0xc0, 0xa4, 0x59, 0x4a, 0x98, 0x25,
+	0x20, 0x50, 0x54, 0x00, 0x00, 0x00, 0xa9, 0x40,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x48, 0x3f,
+	0x40, 0x30, 0x62, 0xb0, 0x32, 0x40, 0x40, 0xc0,
+	0x13, 0x00, 0x2b, 0xa0, 0x21, 0x00, 0x00, 0x1e,
+	0x00, 0x00, 0x00, 0xff, 0x00, 0x4c, 0x69, 0x6e,
+	0x75, 0x78, 0x20, 0x23, 0x30, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3b,
+	0x3d, 0x4a, 0x4c, 0x11, 0x00, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
+	0x00, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x55,
+	0x58, 0x47, 0x41, 0x0a, 0x20, 0x20, 0x00, 0x9d,
+	},
+	{
+	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+	0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x05, 0x16, 0x01, 0x03, 0x6d, 0x2b, 0x1b, 0x78,
+	0xea, 0x5e, 0xc0, 0xa4, 0x59, 0x4a, 0x98, 0x25,
+	0x20, 0x50, 0x54, 0x00, 0x00, 0x00, 0xb3, 0x00,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x21, 0x39,
+	0x90, 0x30, 0x62, 0x1a, 0x27, 0x40, 0x68, 0xb0,
+	0x36, 0x00, 0xb5, 0x11, 0x11, 0x00, 0x00, 0x1e,
+	0x00, 0x00, 0x00, 0xff, 0x00, 0x4c, 0x69, 0x6e,
+	0x75, 0x78, 0x20, 0x23, 0x30, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3b,
+	0x3d, 0x40, 0x42, 0x0f, 0x00, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
+	0x00, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x57,
+	0x53, 0x58, 0x47, 0x41, 0x0a, 0x20, 0x00, 0x26,
+	},
+	{
+	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+	0x31, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x05, 0x16, 0x01, 0x03, 0x6d, 0x32, 0x1c, 0x78,
+	0xea, 0x5e, 0xc0, 0xa4, 0x59, 0x4a, 0x98, 0x25,
+	0x20, 0x50, 0x54, 0x00, 0x00, 0x00, 0xd1, 0xc0,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a,
+	0x80, 0x18, 0x71, 0x38, 0x2d, 0x40, 0x58, 0x2c,
+	0x45, 0x00, 0xf4, 0x19, 0x11, 0x00, 0x00, 0x1e,
+	0x00, 0x00, 0x00, 0xff, 0x00, 0x4c, 0x69, 0x6e,
+	0x75, 0x78, 0x20, 0x23, 0x30, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x3b,
+	0x3d, 0x42, 0x44, 0x0f, 0x00, 0x0a, 0x20, 0x20,
+	0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfc,
+	0x00, 0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x46,
+	0x48, 0x44, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x05,
+	}
+};
+
+#endif /* __IGT_EDID_H__ */
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 8de8e0a..86dec51 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -394,6 +394,20 @@ static int get_card_number(int fd)
 	return minor(buf.st_rdev);
 }
 
+static char* get_debugfs_connector_path(int drm_fd, drmModeConnector *connector,
+					const char *file)
+{
+	char *path;
+
+	asprintf(&path, "/sys/kernel/debug/dri/%d/%s-%d/%s",
+		 get_card_number(drm_fd),
+		 kmstest_connector_type_str(connector->connector_type),
+		 connector->connector_type_id,
+		 file);
+
+	return path;
+}
+
 /**
  * kmstest_force_connector:
  * @fd: drm file descriptor
@@ -426,10 +440,7 @@ void kmstest_force_connector(int drm_fd, drmModeConnector *connector, enum
 		break;
 	}
 
-	asprintf(&path, "/sys/kernel/debug/dri/%d/%s-%d/force",
-		 get_card_number(drm_fd),
-		 kmstest_connector_type_str(connector->connector_type),
-		 connector->connector_type_id);
+	path = get_debugfs_connector_path(drm_fd, connector, "force");
 	debugfs_fd = open(path, O_WRONLY | O_TRUNC);
 	free(path);
 
@@ -441,6 +452,37 @@ void kmstest_force_connector(int drm_fd, drmModeConnector *connector, enum
 	igt_assert(ret != -1);
 }
 
+/**
+ * kmstest_force_edid:
+ * @drm_fd: drm file descriptor
+ * @connector: connector to set @edid on
+ * @edid: An EDID data block
+ * @length: length of the EDID data. #EDID_LENGTH defines the standard EDID
+ * length
+ *
+ * Set the EDID data on @connector to @edid. See #generic_edid and
+ * #kmstest_generic_edid for a set of generic EDID data blocks.
+ */
+void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
+			const unsigned char *edid, size_t length)
+{
+	char *path;
+	int debugfs_fd, ret;
+
+	path = get_debugfs_connector_path(drm_fd, connector, "edid_override");
+
+	debugfs_fd = open(path, O_WRONLY | O_TRUNC);
+
+	free(path);
+
+	igt_assert(debugfs_fd != -1);
+
+	ret = write(debugfs_fd, edid, length);
+	close(debugfs_fd);
+
+	igt_assert(ret != -1);
+}
+
 void kmstest_free_connector_config(struct kmstest_connector_config *config)
 {
 	drmModeFreeCrtc(config->crtc);
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 45a98c8..4cf74e8 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -90,6 +90,27 @@ enum kmstest_force_connector_state {
 	FORCE_CONNECTOR_OFF
 };
 
+
+/**
+ * kmstest_generic_edid:
+ * @EDID_XGA: 1024x768
+ * @EDID_SXGA: 1280x1024
+ * @EDID_UXGA: 1600x1200
+ * @EDID_WSXGA: 1680x1050
+ * @EDID_FHD: 1920x1080
+ * @MAX_EDIDS: Size of #generic_edid array
+ */
+enum kmstest_generic_edid {
+	EDID_XGA,   /* 1024x768 */
+	EDID_SXGA,  /* 1280x1024 */
+	EDID_UXGA,  /* 1600x1200 */
+	EDID_WSXGA, /* 1680x1050 */
+	EDID_FHD,   /* 1920x1080 */
+
+	MAX_EDIDS
+};
+
+
 int kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 				      drmModeModeInfo *mode);
 int kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
@@ -97,6 +118,8 @@ int kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
 				 struct kmstest_connector_config *config);
 void kmstest_force_connector(int fd, drmModeConnector *connector,
 			     enum kmstest_force_connector_state state);
+void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
+			const unsigned char *edid, size_t length);
 void kmstest_free_connector_config(struct kmstest_connector_config *config);
 
 void kmstest_dump_mode(drmModeModeInfo *mode);
diff --git a/tests/kms_force_connector.c b/tests/kms_force_connector.c
index 0591da0..54a92c5 100644
--- a/tests/kms_force_connector.c
+++ b/tests/kms_force_connector.c
@@ -25,6 +25,7 @@
 #include "igt_core.h"
 #include "igt_kms.h"
 #include "drmtest.h"
+#include "igt_edid.h"
 
 int
 main (int argc, char **argv)
@@ -68,6 +69,29 @@ main (int argc, char **argv)
 	igt_display_init(&display, drm_fd);
 	igt_display_commit(&display);
 
+	/* test edid forcing */
+	kmstest_force_edid(drm_fd, connector, generic_edid[EDID_FHD],
+			   EDID_LENGTH);
+	temp = drmModeGetConnector(drm_fd, connector->connector_id);
+
+	igt_assert(temp->count_modes == 1);
+	igt_assert(temp->modes[0].vrefresh == 60
+		   && temp->modes[0].hdisplay == 1920
+		   && temp->modes[0].vdisplay == 1080);
+
+	drmModeFreeConnector(temp);
+
+	/* custom edid */
+	kmstest_force_edid(drm_fd, connector, generic_edid[EDID_WSXGA],
+			   EDID_LENGTH);
+	temp = drmModeGetConnector(drm_fd, connector->connector_id);
+
+	igt_assert(temp->count_modes == 1);
+	igt_assert(temp->modes[0].vrefresh == 60
+		   && temp->modes[0].hdisplay == 1680
+		   && temp->modes[0].vdisplay == 1050);
+
+	drmModeFreeConnector(temp);
 
 	/* force the connector off */
 	kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_OFF);
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH i-g-t 3/4] lib: add igt_enable_connectors and igt_reset_connectors
  2014-06-18 13:44 [PATCH i-g-t 0/4] enabling connectors (v2) Thomas Wood
  2014-06-18 13:44 ` [PATCH i-g-t 1/4] lib: add function to change connector states Thomas Wood
  2014-06-18 13:44 ` [PATCH i-g-t 2/4] lib: add the ability to set an EDID data block on a connector Thomas Wood
@ 2014-06-18 13:44 ` Thomas Wood
  2014-06-18 13:44 ` [PATCH i-g-t 4/4] tests: enable extra connectors in kms_flip and kms_pipe_crc_basic Thomas Wood
  3 siblings, 0 replies; 8+ messages in thread
From: Thomas Wood @ 2014-06-18 13:44 UTC (permalink / raw)
  To: intel-gfx

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__ */
 
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH i-g-t 4/4] tests: enable extra connectors in kms_flip and kms_pipe_crc_basic
  2014-06-18 13:44 [PATCH i-g-t 0/4] enabling connectors (v2) Thomas Wood
                   ` (2 preceding siblings ...)
  2014-06-18 13:44 ` [PATCH i-g-t 3/4] lib: add igt_enable_connectors and igt_reset_connectors Thomas Wood
@ 2014-06-18 13:44 ` Thomas Wood
  3 siblings, 0 replies; 8+ messages in thread
From: Thomas Wood @ 2014-06-18 13:44 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 tests/kms_flip.c           | 2 ++
 tests/kms_pipe_crc_basic.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 46ce2ed..337e224 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1595,6 +1595,8 @@ int main(int argc, char **argv)
 	igt_fixture {
 		drm_fd = drm_open_any();
 
+		igt_enable_connectors();
+
 		igt_set_vt_graphics_mode();
 		igt_install_exit_handler(kms_flip_exit_handler);
 		get_timestamp_format();
diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c
index 9eec4e6..0557b03 100644
--- a/tests/kms_pipe_crc_basic.c
+++ b/tests/kms_pipe_crc_basic.c
@@ -186,6 +186,8 @@ igt_main
 	igt_fixture {
 		data.drm_fd = drm_open_any();
 
+		igt_enable_connectors();
+
 		igt_set_vt_graphics_mode();
 
 		igt_require_pipe_crc();
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH i-g-t 2/4] lib: add the ability to set an EDID data block on a connector
  2014-06-18 13:44 ` [PATCH i-g-t 2/4] lib: add the ability to set an EDID data block on a connector Thomas Wood
@ 2014-06-18 13:57   ` Daniel Vetter
  2014-06-18 14:03     ` Thomas Wood
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Vetter @ 2014-06-18 13:57 UTC (permalink / raw)
  To: Thomas Wood; +Cc: intel-gfx

On Wed, Jun 18, 2014 at 02:44:11PM +0100, Thomas Wood wrote:
> +/**
> + * kmstest_generic_edid:
> + * @EDID_XGA: 1024x768
> + * @EDID_SXGA: 1280x1024
> + * @EDID_UXGA: 1600x1200
> + * @EDID_WSXGA: 1680x1050
> + * @EDID_FHD: 1920x1080
> + * @MAX_EDIDS: Size of #generic_edid array
> + */
> +enum kmstest_generic_edid {
> +	EDID_XGA,   /* 1024x768 */
> +	EDID_SXGA,  /* 1280x1024 */
> +	EDID_UXGA,  /* 1600x1200 */
> +	EDID_WSXGA, /* 1680x1050 */
> +	EDID_FHD,   /* 1920x1080 */

Hm, can't we have just one full hd edid which supports all the above
modes?
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH i-g-t 2/4] lib: add the ability to set an EDID data block on a connector
  2014-06-18 13:57   ` Daniel Vetter
@ 2014-06-18 14:03     ` Thomas Wood
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Wood @ 2014-06-18 14:03 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Intel Graphics Development

On 18 June 2014 14:57, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Wed, Jun 18, 2014 at 02:44:11PM +0100, Thomas Wood wrote:
>> +/**
>> + * kmstest_generic_edid:
>> + * @EDID_XGA: 1024x768
>> + * @EDID_SXGA: 1280x1024
>> + * @EDID_UXGA: 1600x1200
>> + * @EDID_WSXGA: 1680x1050
>> + * @EDID_FHD: 1920x1080
>> + * @MAX_EDIDS: Size of #generic_edid array
>> + */
>> +enum kmstest_generic_edid {
>> +     EDID_XGA,   /* 1024x768 */
>> +     EDID_SXGA,  /* 1280x1024 */
>> +     EDID_UXGA,  /* 1600x1200 */
>> +     EDID_WSXGA, /* 1680x1050 */
>> +     EDID_FHD,   /* 1920x1080 */
>
> Hm, can't we have just one full hd edid which supports all the above
> modes?


Yes, although for kms_force_connector I actually wanted two different
EDIDs to make sure overwriting the value worked correctly.


> -Daniel
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH i-g-t 1/4] lib: add function to change connector states
  2014-06-18 13:44 ` [PATCH i-g-t 1/4] lib: add function to change connector states Thomas Wood
@ 2014-06-18 14:05   ` Chris Wilson
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Wilson @ 2014-06-18 14:05 UTC (permalink / raw)
  To: Thomas Wood; +Cc: intel-gfx

On Wed, Jun 18, 2014 at 02:44:10PM +0100, Thomas Wood wrote:
> +static int get_card_number(int fd)
> +{
> +	struct stat buf;
> +
> +	/* find the minor number of the device */
> +	fstat(fd, &buf);
> +
> +	return minor(buf.st_rdev);

This mixes in rendernode/controlnode tags.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-18 14:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 13:44 [PATCH i-g-t 0/4] enabling connectors (v2) Thomas Wood
2014-06-18 13:44 ` [PATCH i-g-t 1/4] lib: add function to change connector states Thomas Wood
2014-06-18 14:05   ` Chris Wilson
2014-06-18 13:44 ` [PATCH i-g-t 2/4] lib: add the ability to set an EDID data block on a connector Thomas Wood
2014-06-18 13:57   ` Daniel Vetter
2014-06-18 14:03     ` Thomas Wood
2014-06-18 13:44 ` [PATCH i-g-t 3/4] lib: add igt_enable_connectors and igt_reset_connectors Thomas Wood
2014-06-18 13:44 ` [PATCH i-g-t 4/4] tests: enable extra connectors in kms_flip and kms_pipe_crc_basic Thomas Wood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.