summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Makefile.sources3
-rw-r--r--lib/igt_edid.c270
-rw-r--r--lib/igt_edid.h196
-rw-r--r--lib/igt_edid_template.h74
-rw-r--r--lib/igt_kms.c113
-rw-r--r--lib/meson.build3
6 files changed, 525 insertions, 134 deletions
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index a1d25351..62219349 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -25,7 +25,8 @@ lib_source_list = \
igt_aux.h \
igt_color_encoding.c \
igt_color_encoding.h \
- igt_edid_template.h \
+ igt_edid.c \
+ igt_edid.h \
igt_gpu_power.c \
igt_gpu_power.h \
igt_gt.c \
diff --git a/lib/igt_edid.c b/lib/igt_edid.c
new file mode 100644
index 00000000..52e66ab2
--- /dev/null
+++ b/lib/igt_edid.c
@@ -0,0 +1,270 @@
+/*
+ * Copyright © 2019 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.
+ *
+ * Authors: Simon Ser <simon.ser@intel.com>
+ */
+
+#include "config.h"
+
+#include <assert.h>
+#include <string.h>
+#include <stdint.h>
+#include <time.h>
+#include <xf86drmMode.h>
+
+#include "igt_core.h"
+#include "igt_edid.h"
+
+static const char edid_header[] = {
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
+};
+
+static const char monitor_range_padding[] = {
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
+};
+
+/* vfreq is in Hz */
+static void std_timing_set(struct std_timing *st, int hsize, int vfreq,
+ enum std_timing_aspect aspect)
+{
+ assert(hsize >= 256 && hsize <= 2288);
+ st->hsize = hsize / 8 - 31;
+ st->vfreq_aspect = aspect << 6 | (vfreq - 60);
+}
+
+static void std_timing_unset(struct std_timing *st)
+{
+ memset(st, 0x01, sizeof(struct std_timing));
+}
+
+/**
+ * detailed_timing_set_mode: fill a detailed timing based on a mode
+ */
+void detailed_timing_set_mode(struct detailed_timing *dt, drmModeModeInfo *mode,
+ int width_mm, int height_mm)
+{
+ int hactive, hblank, vactive, vblank, hsync_offset, hsync_pulse_width,
+ vsync_offset, vsync_pulse_width;
+ struct detailed_pixel_timing *pt = &dt->data.pixel_data;
+
+ hactive = mode->hdisplay;
+ hsync_offset = mode->hsync_start - mode->hdisplay;
+ hsync_pulse_width = mode->hsync_end - mode->hsync_start;
+ hblank = mode->htotal - mode->hdisplay;
+
+ vactive = mode->vdisplay;
+ vsync_offset = mode->vsync_start - mode->vdisplay;
+ vsync_pulse_width = mode->vsync_end - mode->vsync_start;
+ vblank = mode->vtotal - mode->vdisplay;
+
+ dt->pixel_clock[0] = (mode->clock / 10) & 0x00FF;
+ dt->pixel_clock[1] = ((mode->clock / 10) & 0xFF00) >> 8;
+
+ assert(hactive <= 0xFFF);
+ assert(hblank <= 0xFFF);
+ pt->hactive_lo = hactive & 0x0FF;
+ pt->hblank_lo = hblank & 0x0FF;
+ pt->hactive_hblank_hi = (hactive & 0xF00) >> 4 | (hblank & 0xF00) >> 8;
+
+ assert(vactive <= 0xFFF);
+ assert(vblank <= 0xFFF);
+ pt->vactive_lo = vactive & 0x0FF;
+ pt->vblank_lo = vblank & 0x0FF;
+ pt->vactive_vblank_hi = (vactive & 0xF00) >> 4 | (vblank & 0xF00) >> 8;
+
+ assert(hsync_offset <= 0x3FF);
+ assert(hsync_pulse_width <= 0x3FF);
+ assert(vsync_offset <= 0x3F);
+ assert(vsync_pulse_width <= 0x3F);
+ pt->hsync_offset_lo = hsync_offset & 0x0FF;
+ pt->hsync_pulse_width_lo = hsync_pulse_width & 0x0FF;
+ pt->vsync_offset_pulse_width_lo = (vsync_offset & 0xF) << 4
+ | (vsync_pulse_width & 0xF);
+ pt->hsync_vsync_offset_pulse_width_hi =
+ ((hsync_offset & 0x300) >> 2) | ((hsync_pulse_width & 0x300) >> 4)
+ | ((vsync_offset & 0x30) >> 2) | ((vsync_pulse_width & 0x30) >> 4);
+
+ assert(width_mm <= 0xFFF);
+ assert(height_mm <= 0xFFF);
+ pt->width_mm_lo = width_mm & 0x0FF;
+ pt->height_mm_lo = height_mm & 0x0FF;
+ pt->width_height_mm_hi = (width_mm & 0xF00) >> 4
+ | (height_mm & 0xF00) >> 8;
+
+ pt->misc = 0;
+ if (mode->flags & DRM_MODE_FLAG_PHSYNC)
+ pt->misc |= EDID_PT_HSYNC_POSITIVE;
+ if (mode->flags & DRM_MODE_FLAG_PVSYNC)
+ pt->misc |= EDID_PT_VSYNC_POSITIVE;
+}
+
+/**
+ * detailed_timing_set_monitor_range_mode: set a detailed timing to be a
+ * monitor range based on a mode
+ */
+void detailed_timing_set_monitor_range_mode(struct detailed_timing *dt,
+ drmModeModeInfo *mode)
+{
+ struct detailed_non_pixel *np = &dt->data.other_data;
+ struct detailed_data_monitor_range *mr = &np->data.range;
+
+ dt->pixel_clock[0] = dt->pixel_clock[1] = 0;
+
+ np->type = EDID_DETAIL_MONITOR_RANGE;
+
+ mr->min_vfreq = mode->vrefresh - 1;
+ mr->max_vfreq = mode->vrefresh + 1;
+ mr->min_hfreq_khz = (mode->clock / mode->htotal) - 1;
+ mr->max_hfreq_khz = (mode->clock / mode->htotal) + 1;
+ mr->pixel_clock_mhz = (mode->clock / 10000) + 1;
+ mr->flags = 0;
+
+ memcpy(mr->formula.pad, monitor_range_padding,
+ sizeof(monitor_range_padding));
+}
+
+/**
+ * detailed_timing_set_string: set a detailed timing to be a string
+ */
+void detailed_timing_set_string(struct detailed_timing *dt,
+ enum detailed_non_pixel_type type,
+ const char *str)
+{
+ struct detailed_non_pixel *np = &dt->data.other_data;
+ struct detailed_data_string *ds = &np->data.string;
+ size_t len;
+
+ switch (type) {
+ case EDID_DETAIL_MONITOR_NAME:
+ case EDID_DETAIL_MONITOR_STRING:
+ case EDID_DETAIL_MONITOR_SERIAL:
+ break;
+ default:
+ assert(0); /* not a string type */
+ }
+
+ dt->pixel_clock[0] = dt->pixel_clock[1] = 0;
+
+ np->type = type;
+
+ strncpy(ds->str, str, sizeof(ds->str));
+ len = strlen(str);
+ if (len < sizeof(ds->str))
+ ds->str[len] = '\n';
+}
+
+static void edid_set_mfg(struct edid *edid, const char mfg[static 3])
+{
+ edid->mfg_id[0] = (mfg[0] - '@') << 2 | (mfg[1] - '@') >> 3;
+ edid->mfg_id[1] = (mfg[1] - '@') << 5 | (mfg[2] - '@');
+}
+
+static void edid_set_gamma(struct edid *edid, float gamma)
+{
+ edid->gamma = (gamma * 100) - 100;
+}
+
+/**
+ * edid_init: initialize an EDID
+ *
+ * The EDID will be pre-filled with established and standard timings:
+ *
+ * - 1920x1080 60Hz
+ * - 1280x720 60Hz
+ * - 1024x768 60Hz
+ * - 800x600 60Hz
+ * - 640x480 60Hz
+ */
+void edid_init(struct edid *edid)
+{
+ size_t i;
+ time_t t;
+ struct tm *tm;
+
+ memset(edid, 0, sizeof(struct edid));
+
+ memcpy(edid->header, edid_header, sizeof(edid_header));
+ edid_set_mfg(edid, "IGT");
+ edid->version = 1;
+ edid->revision = 3;
+ edid->input = 0x80;
+ edid->width_cm = 52;
+ edid->height_cm = 30;
+ edid_set_gamma(edid, 2.20);
+ edid->features = 0x02;
+
+ /* Year of manufacture */
+ t = time(NULL);
+ tm = localtime(&t);
+ edid->mfg_year = tm->tm_year - 90;
+
+ /* Established timings: 640x480 60Hz, 800x600 60Hz, 1024x768 60Hz */
+ edid->established_timings.t1 = 0x21;
+ edid->established_timings.t2 = 0x08;
+
+ /* Standard timings */
+ /* 1920x1080 60Hz */
+ std_timing_set(&edid->standard_timings[0], 1920, 60, STD_TIMING_16_9);
+ /* 1280x720 60Hz */
+ std_timing_set(&edid->standard_timings[1], 1280, 60, STD_TIMING_16_9);
+ /* 1024x768 60Hz */
+ std_timing_set(&edid->standard_timings[2], 1024, 60, STD_TIMING_4_3);
+ /* 800x600 60Hz */
+ std_timing_set(&edid->standard_timings[3], 800, 60, STD_TIMING_4_3);
+ /* 640x480 60Hz */
+ std_timing_set(&edid->standard_timings[4], 640, 60, STD_TIMING_4_3);
+ for (i = 5; i < STD_TIMINGS_LEN; i++)
+ std_timing_unset(&edid->standard_timings[i]);
+}
+
+/**
+ * edid_init_with_mode: initialize an EDID and sets its preferred mode
+ */
+void edid_init_with_mode(struct edid *edid, drmModeModeInfo *mode)
+{
+ edid_init(edid);
+
+ /* Preferred timing */
+ detailed_timing_set_mode(&edid->detailed_timings[0], mode,
+ edid->width_cm * 10, edid->height_cm * 10);
+ detailed_timing_set_monitor_range_mode(&edid->detailed_timings[1],
+ mode);
+ detailed_timing_set_string(&edid->detailed_timings[2],
+ EDID_DETAIL_MONITOR_NAME, "IGT");
+}
+
+/**
+ * edid_update_checksum: compute and update the EDID checksum
+ */
+void edid_update_checksum(struct edid *edid)
+{
+ size_t i;
+ const uint8_t *buf = (const uint8_t *) edid;
+ uint8_t sum = 0;
+
+ /* calculate checksum */
+ for (i = 0; i < sizeof(struct edid) - 1; i++) {
+ sum = sum + buf[i];
+ }
+
+ edid->checksum = 256 - sum;
+}
diff --git a/lib/igt_edid.h b/lib/igt_edid.h
new file mode 100644
index 00000000..bbcb939a
--- /dev/null
+++ b/lib/igt_edid.h
@@ -0,0 +1,196 @@
+/*
+ * Copyright © 2019 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.
+ *
+ * Authors: Simon Ser <simon.ser@intel.com>
+ */
+
+#ifndef IGT_EDID_H
+#define IGT_EDID_H
+
+#include "config.h"
+
+#include <stdint.h>
+
+struct est_timings {
+ uint8_t t1;
+ uint8_t t2;
+ uint8_t mfg_rsvd;
+} __attribute__((packed));
+
+#define STD_TIMINGS_LEN 8
+
+enum std_timing_aspect {
+ STD_TIMING_16_10 = 0b00,
+ STD_TIMING_4_3 = 0b01,
+ STD_TIMING_5_4 = 0b10,
+ STD_TIMING_16_9 = 0b11,
+};
+
+struct std_timing {
+ uint8_t hsize;
+ uint8_t vfreq_aspect;
+} __attribute__((packed));
+
+#define DETAILED_TIMINGS_LEN 4
+
+#define EDID_PT_HSYNC_POSITIVE (1 << 1)
+#define EDID_PT_VSYNC_POSITIVE (1 << 2)
+#define EDID_PT_SEPARATE_SYNC (3 << 3)
+#define EDID_PT_STEREO (1 << 5)
+#define EDID_PT_INTERLACED (1 << 7)
+
+struct detailed_pixel_timing {
+ uint8_t hactive_lo;
+ uint8_t hblank_lo;
+ uint8_t hactive_hblank_hi;
+ uint8_t vactive_lo;
+ uint8_t vblank_lo;
+ uint8_t vactive_vblank_hi;
+ uint8_t hsync_offset_lo;
+ uint8_t hsync_pulse_width_lo;
+ uint8_t vsync_offset_pulse_width_lo;
+ uint8_t hsync_vsync_offset_pulse_width_hi;
+ uint8_t width_mm_lo;
+ uint8_t height_mm_lo;
+ uint8_t width_height_mm_hi;
+ uint8_t hborder;
+ uint8_t vborder;
+ uint8_t misc;
+} __attribute__((packed));
+
+struct detailed_data_string {
+ char str[13];
+} __attribute__((packed));
+
+struct detailed_data_monitor_range {
+ uint8_t min_vfreq;
+ uint8_t max_vfreq;
+ uint8_t min_hfreq_khz;
+ uint8_t max_hfreq_khz;
+ uint8_t pixel_clock_mhz; /* need to multiply by 10 */
+ uint8_t flags;
+ union {
+ char pad[7];
+ struct {
+ uint8_t reserved;
+ uint8_t hfreq_start_khz; /* need to multiply by 2 */
+ uint8_t c; /* need to divide by 2 */
+ uint8_t m[2];
+ uint8_t k;
+ uint8_t j; /* need to divide by 2 */
+ } __attribute__((packed)) gtf2;
+ struct {
+ uint8_t version;
+ uint8_t data1; /* high 6 bits: extra clock resolution */
+ uint8_t data2; /* plus low 2 of above: max hactive */
+ uint8_t supported_aspects;
+ uint8_t flags; /* preferred aspect and blanking support */
+ uint8_t supported_scalings;
+ uint8_t preferred_refresh;
+ } __attribute__((packed)) cvt;
+ } formula;
+} __attribute__((packed));
+
+enum detailed_non_pixel_type {
+ EDID_DETAIL_EST_TIMINGS = 0xf7,
+ EDID_DETAIL_CVT_3BYTE = 0xf8,
+ EDID_DETAIL_COLOR_MGMT_DATA = 0xf9,
+ EDID_DETAIL_STD_MODES = 0xfa,
+ EDID_DETAIL_MONITOR_CPDATA = 0xfb,
+ EDID_DETAIL_MONITOR_NAME = 0xfc,
+ EDID_DETAIL_MONITOR_RANGE = 0xfd,
+ EDID_DETAIL_MONITOR_STRING = 0xfe,
+ EDID_DETAIL_MONITOR_SERIAL = 0xff,
+};
+
+struct detailed_non_pixel {
+ uint8_t pad1;
+ uint8_t type; /* enum detailed_non_pixel_type */
+ uint8_t pad2;
+ union {
+ struct detailed_data_string str;
+ struct detailed_data_monitor_range range;
+ struct detailed_data_string string;
+ /* TODO: other types */
+ } data;
+} __attribute__((packed));
+
+struct detailed_timing {
+ uint8_t pixel_clock[2]; /* need to multiply by 10 KHz, zero if not a pixel timing */
+ union {
+ struct detailed_pixel_timing pixel_data;
+ struct detailed_non_pixel other_data;
+ } data;
+} __attribute__((packed));
+
+struct edid {
+ char header[8];
+ /* Vendor & product info */
+ uint8_t mfg_id[2];
+ uint8_t prod_code[2];
+ uint8_t serial[4];
+ uint8_t mfg_week;
+ uint8_t mfg_year;
+ /* EDID version */
+ uint8_t version;
+ uint8_t revision;
+ /* Display info: */
+ uint8_t input;
+ uint8_t width_cm;
+ uint8_t height_cm;
+ uint8_t gamma;
+ uint8_t features;
+ /* Color characteristics */
+ uint8_t red_green_lo;
+ uint8_t black_white_lo;
+ uint8_t red_x;
+ uint8_t red_y;
+ uint8_t green_x;
+ uint8_t green_y;
+ uint8_t blue_x;
+ uint8_t blue_y;
+ uint8_t white_x;
+ uint8_t white_y;
+ /* Est. timings and mfg rsvd timings*/
+ struct est_timings established_timings;
+ /* Standard timings 1-8*/
+ struct std_timing standard_timings[STD_TIMINGS_LEN];
+ /* Detailing timings 1-4 */
+ struct detailed_timing detailed_timings[DETAILED_TIMINGS_LEN];
+ /* Number of 128 byte ext. blocks */
+ uint8_t extensions;
+ /* Checksum */
+ uint8_t checksum;
+} __attribute__((packed));
+
+void edid_init(struct edid *edid);
+void edid_init_with_mode(struct edid *edid, drmModeModeInfo *mode);
+void edid_update_checksum(struct edid *edid);
+void detailed_timing_set_mode(struct detailed_timing *dt, drmModeModeInfo *mode,
+ int width_mm, int height_mm);
+void detailed_timing_set_monitor_range_mode(struct detailed_timing *dt,
+ drmModeModeInfo *mode);
+void detailed_timing_set_string(struct detailed_timing *dt,
+ enum detailed_non_pixel_type type,
+ const char *str);
+
+#endif
diff --git a/lib/igt_edid_template.h b/lib/igt_edid_template.h
deleted file mode 100644
index 8dbd19ca..00000000
--- a/lib/igt_edid_template.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#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 EDID_NAME[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
-};
-
-#undef EDID_NAME
-#undef VFREQ
-#undef CLOCK
-#undef HACTIVE
-#undef HBLANK
-#undef VACTIVE
-#undef VBLANK
-#undef HOFFSET
-#undef HPULSE
-#undef VOFFSET
-#undef VPULSE
-#undef HSIZE
-#undef VSIZE
-#undef GAMMA
-#undef MANUFACTURER_ID
-#undef ab
-#undef op
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f8b0dab2..df9aafd2 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -50,6 +50,7 @@
#include "drmtest.h"
#include "igt_kms.h"
#include "igt_aux.h"
+#include "igt_edid.h"
#include "intel_chipset.h"
#include "igt_debugfs.h"
#include "igt_device.h"
@@ -102,23 +103,6 @@ static void update_edid_csum(unsigned char *edid, int cea_pos)
edid[cea_pos + 127] = 256 - sum;
}
-#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 EDID_NAME base_edid
-#include "igt_edid_template.h"
-
/**
* igt_kms_get_base_edid:
*
@@ -135,29 +119,66 @@ static void update_edid_csum(unsigned char *edid, int cea_pos)
*
* Returns: a basic edid block
*/
-const unsigned char* igt_kms_get_base_edid(void)
+const unsigned char *igt_kms_get_base_edid(void)
{
- update_edid_csum(base_edid, 0);
+ static struct edid edid;
+ drmModeModeInfo mode = {};
- return base_edid;
+ mode.clock = 148500;
+ mode.hdisplay = 1920;
+ mode.hsync_start = 2008;
+ mode.hsync_end = 2052;
+ mode.htotal = 2200;
+ mode.vdisplay = 1080;
+ mode.vsync_start = 1084;
+ mode.vsync_end = 1089;
+ mode.vtotal = 1125;
+ mode.vrefresh = 60;
+
+ edid_init_with_mode(&edid, &mode);
+ edid_update_checksum(&edid);
+
+ return (unsigned char *) &edid;
}
-#define VFREQ 60
-#define CLOCK 101000
-#define HACTIVE 1400
-#define HBLANK 160
-#define VACTIVE 1050
-#define VBLANK 30
-#define HOFFSET 48
-#define HPULSE 32
-#define VOFFSET 3
-#define VPULSE 4
+/**
+ * igt_kms_get_alt_edid:
+ *
+ * Get an alternate edid block, which includes the following modes:
+ *
+ * - 1400x1050 60Hz
+ * - 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: an alternate edid block
+ */
+const unsigned char *igt_kms_get_alt_edid(void)
+{
+ static struct edid edid;
+ drmModeModeInfo mode = {};
+
+ mode.clock = 101000;
+ mode.hdisplay = 1400;
+ mode.hsync_start = 1448;
+ mode.hsync_end = 1480;
+ mode.htotal = 1560;
+ mode.vdisplay = 1050;
+ mode.vsync_start = 1053;
+ mode.vsync_end = 1057;
+ mode.vtotal = 1080;
+ mode.vrefresh = 60;
-#define HSIZE 52
-#define VSIZE 30
+ edid_init_with_mode(&edid, &mode);
+ edid_update_checksum(&edid);
-#define EDID_NAME alt_edid
-#include "igt_edid_template.h"
+ return (unsigned char *) &edid;
+}
const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
[IGT_PLANE_SRC_X] = "SRC_X",
@@ -302,30 +323,6 @@ igt_fill_pipe_props(igt_display_t *display, igt_pipe_t *pipe,
}
/**
- * igt_kms_get_alt_edid:
- *
- * Get an alternate edid block, which includes the following modes:
- *
- * - 1400x1050 60Hz
- * - 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: an alternate edid block
- */
-const unsigned char* igt_kms_get_alt_edid(void)
-{
- update_edid_csum(alt_edid, 0);
-
- return alt_edid;
-}
-
-/**
* kmstest_pipe_name:
* @pipe: display pipe
*
diff --git a/lib/meson.build b/lib/meson.build
index a8462933..20c0e3e6 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -54,7 +54,8 @@ lib_sources = [
'igt_v3d.c',
'igt_vc4.c',
'igt_psr.c',
- 'igt_amd.c'
+ 'igt_amd.c',
+ 'igt_edid.c',
]
lib_deps = [