Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 1/2] lib/kms: Turn the based_edid into a template
@ 2015-12-04 14:08 ville.syrjala
  2015-12-04 14:08 ` [PATCH i-g-t 2/2] tests/kms_force_connector_basic: Add prune-stale-modes subtest ville.syrjala
  2015-12-07 16:38 ` [PATCH i-g-t 1/2] lib/kms: Turn the based_edid into a template Thomas Wood
  0 siblings, 2 replies; 6+ messages in thread
From: ville.syrjala @ 2015-12-04 14:08 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/Makefile.sources    |  1 +
 lib/igt_edid_template.h | 74 ++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.c           | 90 +++++++++++--------------------------------------
 3 files changed, 95 insertions(+), 70 deletions(-)
 create mode 100644 lib/igt_edid_template.h

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index cb20f030cbec..4999868052b1 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -11,6 +11,7 @@ libintel_tools_la_SOURCES = 	\
 	igt_debugfs.h		\
 	igt_aux.c		\
 	igt_aux.h		\
+	igt_edid_template.h	\
 	igt_gt.c		\
 	igt_gt.h		\
 	igt_stats.c		\
diff --git a/lib/igt_edid_template.h b/lib/igt_edid_template.h
new file mode 100644
index 000000000000..de421e080a88
--- /dev/null
+++ b/lib/igt_edid_template.h
@@ -0,0 +1,74 @@
+#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 fd4f05e81f3d..da49f5676641 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -53,6 +53,23 @@
 #define MAX_CONNECTORS 32
 static char *forced_connectors[MAX_CONNECTORS + 1];
 
+static void update_edid_csum(unsigned char *edid)
+{
+	int i, sum = 0;
+	struct tm *tm;
+	time_t t;
+
+	/* year of manufacture */
+	t = time(NULL);
+	tm = localtime(&t);
+	edid[17] = tm->tm_year - 90;
+
+	/* calculate checksum */
+	for (i = 0; i < 127; i++) {
+		sum = sum + edid[i];
+	}
+	edid[127] = 256 - sum;
+}
 
 #define VFREQ 60
 #define CLOCK 148500
@@ -68,62 +85,8 @@ static char *forced_connectors[MAX_CONNECTORS + 1];
 #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
-};
+#define EDID_NAME base_edid
+#include "igt_edid_template.h"
 
 /**
  * igt_kms_get_base_edid:
@@ -143,20 +106,7 @@ static unsigned char base_edid[EDID_LENGTH] = {
  */
 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;
+	update_edid_csum(base_edid);
 
 	return base_edid;
 }
-- 
2.4.10

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

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

* [PATCH i-g-t 2/2] tests/kms_force_connector_basic: Add prune-stale-modes subtest
  2015-12-04 14:08 [PATCH i-g-t 1/2] lib/kms: Turn the based_edid into a template ville.syrjala
@ 2015-12-04 14:08 ` ville.syrjala
  2015-12-04 16:20   ` Daniel Vetter
  2015-12-04 18:10   ` [PATCH i-g-t v2 " ville.syrjala
  2015-12-07 16:38 ` [PATCH i-g-t 1/2] lib/kms: Turn the based_edid into a template Thomas Wood
  1 sibling, 2 replies; 6+ messages in thread
From: ville.syrjala @ 2015-12-04 14:08 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a new subtest that makes sure old stale modes get pruned from the
connector's mode list when the EDID changes.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_kms.c                     | 40 +++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h                     |  1 +
 tests/kms_force_connector_basic.c | 40 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index da49f5676641..5d5a95c20106 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -111,6 +111,46 @@ const unsigned char* igt_kms_get_base_edid(void)
 	return base_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
+
+#define HSIZE 52
+#define VSIZE 30
+
+#define EDID_NAME alt_edid
+#include "igt_edid_template.h"
+
+/**
+ * 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);
+
+	return alt_edid;
+}
 
 /**
  * SECTION:igt_kms
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 965c47c1c7f4..94f315fe13e2 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -286,6 +286,7 @@ void igt_reset_connectors(void);
 
 #define EDID_LENGTH 128
 const unsigned char* igt_kms_get_base_edid(void);
+const unsigned char* igt_kms_get_alt_edid(void);
 
 
 #endif /* __IGT_KMS_H__ */
diff --git a/tests/kms_force_connector_basic.c b/tests/kms_force_connector_basic.c
index 637f625a852f..f1b2da32dddc 100644
--- a/tests/kms_force_connector_basic.c
+++ b/tests/kms_force_connector_basic.c
@@ -178,6 +178,46 @@ int main(int argc, char **argv)
 
 	}
 
+	igt_subtest("prune-stale-modes") {
+		int i;
+
+		kmstest_force_connector(drm_fd, vga_connector,
+					FORCE_CONNECTOR_ON);
+
+		/* test pruning of stale modes */
+		kmstest_force_edid(drm_fd, vga_connector,
+				   igt_kms_get_alt_edid(), EDID_LENGTH);
+		temp = drmModeGetConnector(drm_fd,
+					   vga_connector->connector_id);
+
+		for (i = 0; i < temp->count_modes; i++) {
+			if (temp->modes[i].hdisplay == 1400 &&
+			    temp->modes[i].vdisplay == 1050)
+				break;
+		}
+		igt_assert_f(i != temp->count_modes, "1400x1050 not on mode list\n");
+
+		drmModeFreeConnector(temp);
+
+		kmstest_force_edid(drm_fd, vga_connector,
+				   igt_kms_get_base_edid(), EDID_LENGTH);
+		temp = drmModeGetConnector(drm_fd,
+					   vga_connector->connector_id);
+
+		for (i = 0; i < temp->count_modes; i++) {
+			if (temp->modes[i].hdisplay == 1400 &&
+			    temp->modes[i].vdisplay == 1050)
+				break;
+		}
+		igt_assert_f(i == temp->count_modes, "1400x1050 not pruned from mode list\n");
+
+		drmModeFreeConnector(temp);
+
+		kmstest_force_edid(drm_fd, vga_connector, NULL, 0);
+		kmstest_force_connector(drm_fd, vga_connector,
+					FORCE_CONNECTOR_UNSPECIFIED);
+	}
+
 	igt_fixture {
 		drmModeFreeConnector(vga_connector);
 		close(drm_fd);
-- 
2.4.10

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

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

* Re: [PATCH i-g-t 2/2] tests/kms_force_connector_basic: Add prune-stale-modes subtest
  2015-12-04 14:08 ` [PATCH i-g-t 2/2] tests/kms_force_connector_basic: Add prune-stale-modes subtest ville.syrjala
@ 2015-12-04 16:20   ` Daniel Vetter
  2015-12-04 18:10   ` [PATCH i-g-t v2 " ville.syrjala
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2015-12-04 16:20 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx

On Fri, Dec 04, 2015 at 04:08:30PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new subtest that makes sure old stale modes get pruned from the
> connector's mode list when the EDID changes.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  lib/igt_kms.c                     | 40 +++++++++++++++++++++++++++++++++++++++
>  lib/igt_kms.h                     |  1 +
>  tests/kms_force_connector_basic.c | 40 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 81 insertions(+)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index da49f5676641..5d5a95c20106 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -111,6 +111,46 @@ const unsigned char* igt_kms_get_base_edid(void)
>  	return base_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
> +
> +#define HSIZE 52
> +#define VSIZE 30
> +
> +#define EDID_NAME alt_edid
> +#include "igt_edid_template.h"
> +
> +/**
> + * 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);
> +
> +	return alt_edid;
> +}
>  
>  /**
>   * SECTION:igt_kms
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 965c47c1c7f4..94f315fe13e2 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -286,6 +286,7 @@ void igt_reset_connectors(void);
>  
>  #define EDID_LENGTH 128
>  const unsigned char* igt_kms_get_base_edid(void);
> +const unsigned char* igt_kms_get_alt_edid(void);
>  
>  
>  #endif /* __IGT_KMS_H__ */
> diff --git a/tests/kms_force_connector_basic.c b/tests/kms_force_connector_basic.c
> index 637f625a852f..f1b2da32dddc 100644
> --- a/tests/kms_force_connector_basic.c
> +++ b/tests/kms_force_connector_basic.c
> @@ -178,6 +178,46 @@ int main(int argc, char **argv)
>  
>  	}
>  
> +	igt_subtest("prune-stale-modes") {
> +		int i;
> +
> +		kmstest_force_connector(drm_fd, vga_connector,
> +					FORCE_CONNECTOR_ON);
> +
> +		/* test pruning of stale modes */
> +		kmstest_force_edid(drm_fd, vga_connector,
> +				   igt_kms_get_alt_edid(), EDID_LENGTH);
> +		temp = drmModeGetConnector(drm_fd,

GetConnectorCurrent everywhere please. The helper library inserts a full
GetConnector including probing where needed, no need to blow through a few
msec here again ...

Cheers, Daniel
> +					   vga_connector->connector_id);
> +
> +		for (i = 0; i < temp->count_modes; i++) {
> +			if (temp->modes[i].hdisplay == 1400 &&
> +			    temp->modes[i].vdisplay == 1050)
> +				break;
> +		}
> +		igt_assert_f(i != temp->count_modes, "1400x1050 not on mode list\n");
> +
> +		drmModeFreeConnector(temp);
> +
> +		kmstest_force_edid(drm_fd, vga_connector,
> +				   igt_kms_get_base_edid(), EDID_LENGTH);
> +		temp = drmModeGetConnector(drm_fd,
> +					   vga_connector->connector_id);
> +
> +		for (i = 0; i < temp->count_modes; i++) {
> +			if (temp->modes[i].hdisplay == 1400 &&
> +			    temp->modes[i].vdisplay == 1050)
> +				break;
> +		}
> +		igt_assert_f(i == temp->count_modes, "1400x1050 not pruned from mode list\n");
> +
> +		drmModeFreeConnector(temp);
> +
> +		kmstest_force_edid(drm_fd, vga_connector, NULL, 0);
> +		kmstest_force_connector(drm_fd, vga_connector,
> +					FORCE_CONNECTOR_UNSPECIFIED);
> +	}
> +
>  	igt_fixture {
>  		drmModeFreeConnector(vga_connector);
>  		close(drm_fd);
> -- 
> 2.4.10
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH i-g-t v2 2/2] tests/kms_force_connector_basic: Add prune-stale-modes subtest
  2015-12-04 14:08 ` [PATCH i-g-t 2/2] tests/kms_force_connector_basic: Add prune-stale-modes subtest ville.syrjala
  2015-12-04 16:20   ` Daniel Vetter
@ 2015-12-04 18:10   ` ville.syrjala
  2015-12-07  8:33     ` Daniel Vetter
  1 sibling, 1 reply; 6+ messages in thread
From: ville.syrjala @ 2015-12-04 18:10 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a new subtest that makes sure old stale modes get pruned from the
connector's mode list when the EDID changes.

v2: s/drmModeGetConnector/drmModeGetConnectorCurrent/ since
    kmstest_force_edid() already takes care of doing the heavier
    call for us (Daniel)

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_kms.c                     | 40 +++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h                     |  1 +
 tests/kms_force_connector_basic.c | 40 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index da49f5676641..5d5a95c20106 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -111,6 +111,46 @@ const unsigned char* igt_kms_get_base_edid(void)
 	return base_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
+
+#define HSIZE 52
+#define VSIZE 30
+
+#define EDID_NAME alt_edid
+#include "igt_edid_template.h"
+
+/**
+ * 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);
+
+	return alt_edid;
+}
 
 /**
  * SECTION:igt_kms
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 965c47c1c7f4..94f315fe13e2 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -286,6 +286,7 @@ void igt_reset_connectors(void);
 
 #define EDID_LENGTH 128
 const unsigned char* igt_kms_get_base_edid(void);
+const unsigned char* igt_kms_get_alt_edid(void);
 
 
 #endif /* __IGT_KMS_H__ */
diff --git a/tests/kms_force_connector_basic.c b/tests/kms_force_connector_basic.c
index 637f625a852f..bd80caeffd82 100644
--- a/tests/kms_force_connector_basic.c
+++ b/tests/kms_force_connector_basic.c
@@ -178,6 +178,46 @@ int main(int argc, char **argv)
 
 	}
 
+	igt_subtest("prune-stale-modes") {
+		int i;
+
+		kmstest_force_connector(drm_fd, vga_connector,
+					FORCE_CONNECTOR_ON);
+
+		/* test pruning of stale modes */
+		kmstest_force_edid(drm_fd, vga_connector,
+				   igt_kms_get_alt_edid(), EDID_LENGTH);
+		temp = drmModeGetConnectorCurrent(drm_fd,
+						  vga_connector->connector_id);
+
+		for (i = 0; i < temp->count_modes; i++) {
+			if (temp->modes[i].hdisplay == 1400 &&
+			    temp->modes[i].vdisplay == 1050)
+				break;
+		}
+		igt_assert_f(i != temp->count_modes, "1400x1050 not on mode list\n");
+
+		drmModeFreeConnector(temp);
+
+		kmstest_force_edid(drm_fd, vga_connector,
+				   igt_kms_get_base_edid(), EDID_LENGTH);
+		temp = drmModeGetConnectorCurrent(drm_fd,
+						  vga_connector->connector_id);
+
+		for (i = 0; i < temp->count_modes; i++) {
+			if (temp->modes[i].hdisplay == 1400 &&
+			    temp->modes[i].vdisplay == 1050)
+				break;
+		}
+		igt_assert_f(i == temp->count_modes, "1400x1050 not pruned from mode list\n");
+
+		drmModeFreeConnector(temp);
+
+		kmstest_force_edid(drm_fd, vga_connector, NULL, 0);
+		kmstest_force_connector(drm_fd, vga_connector,
+					FORCE_CONNECTOR_UNSPECIFIED);
+	}
+
 	igt_fixture {
 		drmModeFreeConnector(vga_connector);
 		close(drm_fd);
-- 
2.4.10

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

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

* Re: [PATCH i-g-t v2 2/2] tests/kms_force_connector_basic: Add prune-stale-modes subtest
  2015-12-04 18:10   ` [PATCH i-g-t v2 " ville.syrjala
@ 2015-12-07  8:33     ` Daniel Vetter
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2015-12-07  8:33 UTC (permalink / raw)
  To: ville.syrjala; +Cc: intel-gfx

On Fri, Dec 04, 2015 at 08:10:29PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new subtest that makes sure old stale modes get pruned from the
> connector's mode list when the EDID changes.
> 
> v2: s/drmModeGetConnector/drmModeGetConnectorCurrent/ since
>     kmstest_force_edid() already takes care of doing the heavier
>     call for us (Daniel)
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

And pretty awesome that we can abuse the force connector stuff to test
these corner-cases in the probe code \o/
-Daniel

> ---
>  lib/igt_kms.c                     | 40 +++++++++++++++++++++++++++++++++++++++
>  lib/igt_kms.h                     |  1 +
>  tests/kms_force_connector_basic.c | 40 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 81 insertions(+)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index da49f5676641..5d5a95c20106 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -111,6 +111,46 @@ const unsigned char* igt_kms_get_base_edid(void)
>  	return base_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
> +
> +#define HSIZE 52
> +#define VSIZE 30
> +
> +#define EDID_NAME alt_edid
> +#include "igt_edid_template.h"
> +
> +/**
> + * 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);
> +
> +	return alt_edid;
> +}
>  
>  /**
>   * SECTION:igt_kms
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 965c47c1c7f4..94f315fe13e2 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -286,6 +286,7 @@ void igt_reset_connectors(void);
>  
>  #define EDID_LENGTH 128
>  const unsigned char* igt_kms_get_base_edid(void);
> +const unsigned char* igt_kms_get_alt_edid(void);
>  
>  
>  #endif /* __IGT_KMS_H__ */
> diff --git a/tests/kms_force_connector_basic.c b/tests/kms_force_connector_basic.c
> index 637f625a852f..bd80caeffd82 100644
> --- a/tests/kms_force_connector_basic.c
> +++ b/tests/kms_force_connector_basic.c
> @@ -178,6 +178,46 @@ int main(int argc, char **argv)
>  
>  	}
>  
> +	igt_subtest("prune-stale-modes") {
> +		int i;
> +
> +		kmstest_force_connector(drm_fd, vga_connector,
> +					FORCE_CONNECTOR_ON);
> +
> +		/* test pruning of stale modes */
> +		kmstest_force_edid(drm_fd, vga_connector,
> +				   igt_kms_get_alt_edid(), EDID_LENGTH);
> +		temp = drmModeGetConnectorCurrent(drm_fd,
> +						  vga_connector->connector_id);
> +
> +		for (i = 0; i < temp->count_modes; i++) {
> +			if (temp->modes[i].hdisplay == 1400 &&
> +			    temp->modes[i].vdisplay == 1050)
> +				break;
> +		}
> +		igt_assert_f(i != temp->count_modes, "1400x1050 not on mode list\n");
> +
> +		drmModeFreeConnector(temp);
> +
> +		kmstest_force_edid(drm_fd, vga_connector,
> +				   igt_kms_get_base_edid(), EDID_LENGTH);
> +		temp = drmModeGetConnectorCurrent(drm_fd,
> +						  vga_connector->connector_id);
> +
> +		for (i = 0; i < temp->count_modes; i++) {
> +			if (temp->modes[i].hdisplay == 1400 &&
> +			    temp->modes[i].vdisplay == 1050)
> +				break;
> +		}
> +		igt_assert_f(i == temp->count_modes, "1400x1050 not pruned from mode list\n");
> +
> +		drmModeFreeConnector(temp);
> +
> +		kmstest_force_edid(drm_fd, vga_connector, NULL, 0);
> +		kmstest_force_connector(drm_fd, vga_connector,
> +					FORCE_CONNECTOR_UNSPECIFIED);
> +	}
> +
>  	igt_fixture {
>  		drmModeFreeConnector(vga_connector);
>  		close(drm_fd);
> -- 
> 2.4.10
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t 1/2] lib/kms: Turn the based_edid into a template
  2015-12-04 14:08 [PATCH i-g-t 1/2] lib/kms: Turn the based_edid into a template ville.syrjala
  2015-12-04 14:08 ` [PATCH i-g-t 2/2] tests/kms_force_connector_basic: Add prune-stale-modes subtest ville.syrjala
@ 2015-12-07 16:38 ` Thomas Wood
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Wood @ 2015-12-07 16:38 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: Intel Graphics Development

based_edid should be "base edid"?


On 4 December 2015 at 14:08,  <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  lib/Makefile.sources    |  1 +
>  lib/igt_edid_template.h | 74 ++++++++++++++++++++++++++++++++++++++++
>  lib/igt_kms.c           | 90 +++++++++++--------------------------------------
>  3 files changed, 95 insertions(+), 70 deletions(-)
>  create mode 100644 lib/igt_edid_template.h
>
> diff --git a/lib/Makefile.sources b/lib/Makefile.sources
> index cb20f030cbec..4999868052b1 100644
> --- a/lib/Makefile.sources
> +++ b/lib/Makefile.sources
> @@ -11,6 +11,7 @@ libintel_tools_la_SOURCES =   \
>         igt_debugfs.h           \
>         igt_aux.c               \
>         igt_aux.h               \
> +       igt_edid_template.h     \

Since this new header doesn't have any public API, please add it to
IGNORE_HFILES in docs/reference/intel-gpu-tools/Makefile.am


>         igt_gt.c                \
>         igt_gt.h                \
>         igt_stats.c             \
> diff --git a/lib/igt_edid_template.h b/lib/igt_edid_template.h
> new file mode 100644
> index 000000000000..de421e080a88
> --- /dev/null
> +++ b/lib/igt_edid_template.h
> @@ -0,0 +1,74 @@
> +#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 fd4f05e81f3d..da49f5676641 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -53,6 +53,23 @@
>  #define MAX_CONNECTORS 32
>  static char *forced_connectors[MAX_CONNECTORS + 1];
>
> +static void update_edid_csum(unsigned char *edid)
> +{
> +       int i, sum = 0;
> +       struct tm *tm;
> +       time_t t;
> +
> +       /* year of manufacture */
> +       t = time(NULL);
> +       tm = localtime(&t);
> +       edid[17] = tm->tm_year - 90;
> +
> +       /* calculate checksum */
> +       for (i = 0; i < 127; i++) {
> +               sum = sum + edid[i];
> +       }
> +       edid[127] = 256 - sum;
> +}
>
>  #define VFREQ 60
>  #define CLOCK 148500
> @@ -68,62 +85,8 @@ static char *forced_connectors[MAX_CONNECTORS + 1];
>  #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
> -};
> +#define EDID_NAME base_edid
> +#include "igt_edid_template.h"
>
>  /**
>   * igt_kms_get_base_edid:
> @@ -143,20 +106,7 @@ static unsigned char base_edid[EDID_LENGTH] = {
>   */
>  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;
> +       update_edid_csum(base_edid);
>
>         return base_edid;
>  }
> --
> 2.4.10
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2015-12-07 16:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-04 14:08 [PATCH i-g-t 1/2] lib/kms: Turn the based_edid into a template ville.syrjala
2015-12-04 14:08 ` [PATCH i-g-t 2/2] tests/kms_force_connector_basic: Add prune-stale-modes subtest ville.syrjala
2015-12-04 16:20   ` Daniel Vetter
2015-12-04 18:10   ` [PATCH i-g-t v2 " ville.syrjala
2015-12-07  8:33     ` Daniel Vetter
2015-12-07 16:38 ` [PATCH i-g-t 1/2] lib/kms: Turn the based_edid into a template Thomas Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox