[Intel-gfx] [PATCH i-g-t 1/4] igt_kms: add a base edid

Thomas Wood thomas.wood at intel.com
Fri Nov 28 17:22:21 CET 2014


Add a basic edid block that includes several different display modes.

Signed-off-by: Thomas Wood <thomas.wood at intel.com>
---
 lib/igt_kms.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |   3 ++
 2 files changed, 113 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index eb8e085..094f8c1 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -35,6 +35,7 @@
 #include <stdlib.h>
 #include <linux/kd.h>
 #include <errno.h>
+#include <time.h>
 
 #include <i915_drm.h>
 
@@ -43,6 +44,7 @@
 #include "igt_aux.h"
 #include "intel_chipset.h"
 #include "igt_debugfs.h"
+#include "igt_edid.h"
 
 /*
  * There hasn't been a release of libdrm containing these #define's yet, so
@@ -61,6 +63,114 @@
 static char *forced_connectors[MAX_CONNECTORS + 1];
 
 
+#define VFREQ 60
+#define CLOCK 148500
+#define HACTIVE 1920
+#define HBLANK 280
+#define VACTIVE 1080
+#define VBLANK 45
+#define HOFFSET 88
+#define HPULSE 44
+#define VOFFSET 4
+#define VPULSE 5
+
+#define HSIZE 52
+#define VSIZE 30
+
+#define GAMMA(x) (x * 100) - 100
+
+#define MANUFACTURER_ID(a, b, c) (a - '@') << 2 | (b - '@') >> 3, \
+				 (b - '@') << 5 | (c - '@')
+
+
+#define ab(x, y) (x & 0xff), (y & 0xff), ((x & 0xf00) >> 4) | ((y & 0xf00) >> 8)
+#define op(ho, hp, vo, vp) (ho & 0xff), (hp & 0xff), \
+			   ((vo & 0xf) << 4) | (vp & 0xf), \
+			   ((ho & 0x300) >> 2) | ((hp & 0x300) >> 4) \
+			   | ((vo & 0x30) >> 2) | (vp & 0x30 >> 4)
+
+static unsigned char base_edid[EDID_LENGTH] = {
+	0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, /* header */
+	MANUFACTURER_ID('I', 'G', 'T'),
+	/* product code, serial number, week and year of manufacture */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x01, 0x03, /* edid version (1.3) */
+	/* basic display parameters */
+	/* digital display, maximum horizontal image size, maximum vertical
+	 * image size, gamma, features: RGB 4:4:4, native pixel format and
+	 * refresh rate in descriptor 1 */
+	0x80, HSIZE, VSIZE, GAMMA(2.20), 0x02,
+	/* chromaticity coordinates */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* established timings: 640x480 60Hz, 800x600 60Hz, 1024x768 60Hz */
+	0x21, 0x08, 0x00,
+	/* standard timings */
+	0xd1, 0xc0, /* 1920x1080 60Hz */
+	0x81, 0xc0, /* 1280x720 60Hz */
+	0x61, 0x40, /* 1024x768 60Hz */
+	0x45, 0x40, /* 800x600 60Hz */
+	0x31, 0x40, /* 640x480 60Hz */
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+	/* descriptor 1 (preferred timing) */
+	(CLOCK / 10) & 0x00ff, ((CLOCK / 10) & 0xff00) >> 8,
+	ab(HACTIVE, HBLANK), ab(VACTIVE, VBLANK),
+	op(HOFFSET, HPULSE, VOFFSET, VPULSE),
+	ab(HSIZE * 10, VSIZE * 10),
+	0x00, 0x00, 0x00,
+	/* descriptor 2 (monitor range limits) */
+	0x00, 0x00, 0x00, 0xfd, 0x00,
+	VFREQ - 1, VFREQ + 1, /* minimum, maximum vertical field rate */
+	(CLOCK / (HACTIVE + HBLANK)) - 1, /* minimum horizontal line rate */
+	(CLOCK / (HACTIVE + HBLANK)) + 1, /* maximum horizontal line rate */
+	(CLOCK / 10000) + 1, /* maximum pixel clock rate */
+	0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+	/* descriptor 3 (name descriptor) */
+	0x00, 0x00, 0x00, 0xfc, 0x00,  'I',  'G',  'T', 0x0a,
+	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+	/* descriptor 4 */
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	/* extensions, checksum */
+	0x00, 0x00
+};
+
+/**
+ * igt_kms_get_base_edid:
+ *
+ * Get the base edid block, which includes the following modes:
+ *
+ *  - 1920x1080 60Hz
+ *  - 1280x720 60Hz
+ *  - 1024x768 60Hz
+ *  - 800x600 60Hz
+ *  - 640x480 60Hz
+ *
+ * This can be extended with further features using functions such as
+ * #kmstest_edid_add_3d.
+ *
+ * Returns: a basic edid block
+ */
+const unsigned char* igt_kms_get_base_edid(void)
+{
+	int i, sum = 0;
+	struct tm *tm;
+	time_t t;
+
+	/* year of manufacture */
+	t = time(NULL);
+	tm = localtime(&t);
+	base_edid[17] = tm->tm_year - 90;
+
+	/* calculate checksum */
+	for (i = 0; i < 127; i++) {
+		sum = sum + base_edid[i];
+	}
+	base_edid[127] = 256 - sum;
+
+	return base_edid;
+}
+
+
 /**
  * SECTION:igt_kms
  * @short_description: Kernel modesetting support library
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 6d05b00..991b34a 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -292,5 +292,8 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe);
 void igt_enable_connectors(void);
 void igt_reset_connectors(void);
 
+const unsigned char* igt_kms_get_base_edid(void);
+
+
 #endif /* __IGT_KMS_H__ */
 
-- 
2.1.0




More information about the Intel-gfx mailing list