igt_kms: add a base edid
PATCH 1/4 igt_kms: add a base edid
Add a basic edid block that includes several different display modes.
Signed-off-by Thomas Wood <[email protected]>
--- lib/igt_kms.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 3 ++ 2 files changed, 113 insertions(+)
lib/igt_kms.c +110 -0
@@ -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
lib/igt_kms.h +3 -0
@@ -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__ */
Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 tests/kms_force_connect: split into subtests
Signed-off-by Thomas Wood <[email protected]>
--- tests/kms_force_connector.c | 167 +++++++++++++++++++++++--------------------- 1 file changed, 89 insertions(+), 78 deletions(-)
tests/kms_force_connector.c +89 -78
@@ -27,98 +27,109 @@#include "drmtest.h" #include "igt_edid.h" -int -main (int argc,char **argv) +igt_main {/* force the VGA output and test that it worked */ -int drm_fd; +int drm_fd =0 ;drmModeRes *res; -drmModeConnector *vga_connector, *temp; +drmModeConnector *vga_connector =NULL , *temp;igt_display_t display;int start_n_modes; -igt_simple_init (argc, argv); + igt_fixture { + drm_fd =drm_open_any_master (); + res =drmModeGetResources (drm_fd); - drm_fd =drm_open_any_master (); - res =drmModeGetResources (drm_fd); +/* find the vga connector */ +for (int i =0 ; i < res->count_connectors; i++) { -/* find the vga connector */ -for (int i =0 ; i < res->count_connectors; i++) { + vga_connector =drmModeGetConnector (drm_fd, res->connectors[i]); - vga_connector =drmModeGetConnector (drm_fd, res->connectors[i]); +if (vga_connector->connector_type ==DRM_MODE_CONNECTOR_VGA ) +break ; -if (vga_connector->connector_type ==DRM_MODE_CONNECTOR_VGA ) -break ; +drmModeFreeConnector (vga_connector); -drmModeFreeConnector (vga_connector); + vga_connector =NULL ; + } + +igt_require (vga_connector); + } - vga_connector =NULL ; + igt_subtest("force-connector-state") { +/* force the connector on and check the reported values */ +kmstest_force_connector (drm_fd, vga_connector,FORCE_CONNECTOR_ON ); + temp =drmModeGetConnector (drm_fd, vga_connector->connector_id); +igt_assert (temp->connection ==DRM_MODE_CONNECTED ); +igt_assert (temp->count_modes >0 ); + start_n_modes = temp->count_modes; +drmModeFreeConnector (temp); + +/* attempt to use the display */ +kmstest_set_vt_graphics_mode (); +igt_display_init (&display, drm_fd); +igt_display_commit (&display); + + +/* force the connector off */ +kmstest_force_connector (drm_fd, vga_connector, +FORCE_CONNECTOR_OFF ); + temp =drmModeGetConnector (drm_fd, vga_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, vga_connector, +FORCE_CONNECTOR_UNSPECIFIED ); + temp =drmModeGetConnector (drm_fd, vga_connector->connector_id); +igt_assert (temp->connection == vga_connector->connection); +drmModeFreeConnector (temp); } -igt_require (vga_connector); - -/* force the connector on and check the reported values */ -kmstest_force_connector (drm_fd, vga_connector,FORCE_CONNECTOR_ON ); - temp =drmModeGetConnector (drm_fd, vga_connector->connector_id); -igt_assert (temp->connection ==DRM_MODE_CONNECTED ); -igt_assert (temp->count_modes >0 ); - start_n_modes = temp->count_modes; -drmModeFreeConnector (temp); - -/* attempt to use the display */ -kmstest_set_vt_graphics_mode (); - -igt_display_init (&display, drm_fd); -igt_display_commit (&display); - -/* test edid forcing */ -kmstest_force_edid (drm_fd, vga_connector, generic_edid[EDID_FHD ], -EDID_LENGTH ); - temp =drmModeGetConnector (drm_fd, vga_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, vga_connector, generic_edid[EDID_WSXGA ], -EDID_LENGTH ); - temp =drmModeGetConnector (drm_fd, vga_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); - -/* remove edid */ -kmstest_force_edid (drm_fd, vga_connector,NULL ,0 ); - temp =drmModeGetConnector (drm_fd, vga_connector->connector_id); -/* the connector should now have the same number of modes that it -* started with */ -igt_assert (temp->count_modes == start_n_modes); -drmModeFreeConnector (temp); - -/* force the connector off */ -kmstest_force_connector (drm_fd, vga_connector,FORCE_CONNECTOR_OFF ); - temp =drmModeGetConnector (drm_fd, vga_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, vga_connector, -FORCE_CONNECTOR_UNSPECIFIED ); - temp =drmModeGetConnector (drm_fd, vga_connector->connector_id); -igt_assert (temp->connection == vga_connector->connection); -drmModeFreeConnector (temp); - -drmModeFreeConnector (vga_connector); + igt_subtest("force-edid") { +kmstest_force_connector (drm_fd, vga_connector, +FORCE_CONNECTOR_ON ); + +/* test edid forcing */ +kmstest_force_edid (drm_fd, vga_connector, + generic_edid[EDID_FHD ],EDID_LENGTH ); + temp =drmModeGetConnector (drm_fd, vga_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, vga_connector, + generic_edid[EDID_WSXGA ],EDID_LENGTH ); + temp =drmModeGetConnector (drm_fd, vga_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); + +/* remove edid */ +kmstest_force_edid (drm_fd, vga_connector,NULL ,0 ); + temp =drmModeGetConnector (drm_fd, vga_connector->connector_id); +/* the connector should now have the same number of modes that +* it started with */ +igt_assert (temp->count_modes == start_n_modes); +drmModeFreeConnector (temp); + +kmstest_force_connector (drm_fd, vga_connector, +FORCE_CONNECTOR_UNSPECIFIED ); + } + + igt_fixture { +drmModeFreeConnector (vga_connector); + }igt_exit (); }
Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 tests: use base edid
In reply to Thomas WoodUse the base edid for testing, which includes several different display modes.
Signed-off-by Thomas Wood <[email protected]>
--- tests/kms_3d.c | 4 ++-- tests/kms_force_connector.c | 31 ++++++++++++------------------- 2 files changed, 14 insertions(+), 21 deletions(-)
tests/kms_3d.c +2 -2
@@ -58,7 +58,7 @@ igt_simple_main }igt_require (connector); -kmstest_edid_add_3d (generic_edid[EDID_FHD ],EDID_LENGTH , &edid, +kmstest_edid_add_3d (igt_kms_get_base_edid (),EDID_LENGTH , &edid, &length);kmstest_force_edid (drm_fd, connector, edid, length);
@@ -75,7 +75,7 @@ igt_simple_main mode_count++; } -igt_assert (mode_count ==13 ); +igt_assert (mode_count ==15 );/* set 3D modes */ igt_info ("Testing:\n" );
tests/kms_force_connector.c +12 -19
@@ -27,6 +27,9 @@#include "drmtest.h" #include "igt_edid.h" +#define CHECK_MODE (m, h, w, r) igt_assert(m.hdisplay == h && m.vdisplay == w \ + && m.vrefresh == r) + igt_main {/* force the VGA output and test that it worked */
@@ -93,25 +96,15 @@ igt_main/* test edid forcing */ kmstest_force_edid (drm_fd, vga_connector, - generic_edid[EDID_FHD ],EDID_LENGTH ); - temp =drmModeGetConnector (drm_fd, vga_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, vga_connector, - generic_edid[EDID_WSXGA ],EDID_LENGTH ); - temp =drmModeGetConnector (drm_fd, vga_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 ); +igt_kms_get_base_edid (),EDID_LENGTH ); + temp =drmModeGetConnector (drm_fd, + vga_connector->connector_id); + +CHECK_MODE (temp->modes[0 ],1920 ,1080 ,60 ); +CHECK_MODE (temp->modes[1 ],1280 ,720 ,60 ); +CHECK_MODE (temp->modes[2 ],1024 ,768 ,60 ); +CHECK_MODE (temp->modes[3 ],800 ,600 ,60 ); +CHECK_MODE (temp->modes[4 ],640 ,480 ,60 );drmModeFreeConnector (temp);
Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 lib: remove igt_edid.h
In reply to Thomas WoodThis has been replaced by igt_kms_get_base_edid().
Signed-off-by Thomas Wood <[email protected]>
--- .../intel-gpu-tools/intel-gpu-tools-docs.xml | 1 - lib/Makefile.sources | 1 - lib/igt_edid.h | 125 --------------------- lib/igt_kms.c | 4 +- lib/igt_kms.h | 21 +--- tests/kms_3d.c | 1 - tests/kms_force_connector.c | 1 - 7 files changed, 2 insertions(+), 152 deletions(-) delete mode 100644 lib/igt_edid.h
docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml +0 -1
@@ -26,7 +26,6 @@ <xi:include href="xml/intel_chipset.xml"/> <xi:include href="xml/intel_io.xml"/> <xi:include href="xml/igt_test_programs.xml"/> - <xi:include href="xml/igt_edid.xml"/> </chapter> <index id="api-index-full">
lib/Makefile.sources +0 -1
@@ -44,7 +44,6 @@ 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 \
lib/igt_edid.h deleted +0 -125
125 lines not on this page · raw message
lib/igt_kms.c +1 -3
@@ -44,7 +44,6 @@#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
@@ -460,8 +459,7 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,* @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. +* Set the EDID data on @connector to @edid. See also #igt_kms_get_base_edid. * * If @length is zero, the forced EDID will be removed. */
lib/igt_kms.h +1 -20
@@ -127,26 +127,6 @@ 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 -}; -bool kmstest_force_connector (int fd,drmModeConnector *connector,enum kmstest_force_connector_state state);void kmstest_edid_add_3d (const unsigned char *edid,size_t length,unsigned char *new_edid_ptr[],size_t *new_length);
@@ -292,6 +272,7 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe);void igt_enable_connectors (void );void igt_reset_connectors (void ); +#define EDID_LENGTH 128const unsigned char *igt_kms_get_base_edid (void );
tests/kms_3d.c +0 -1
@@ -25,7 +25,6 @@#include "igt_core.h" #include "igt_kms.h" #include "drmtest.h" -#include "igt_edid.h" IGT_TEST_DESCRIPTION ("Tests 3D mode setting." );
tests/kms_force_connector.c +0 -1
@@ -25,7 +25,6 @@#include "igt_core.h" #include "igt_kms.h" #include "drmtest.h" -#include "igt_edid.h" #define CHECK_MODE (m, h, w, r) igt_assert(m.hdisplay == h && m.vdisplay == w \ && m.vrefresh == r)
Signature · 6 lines
2.1.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx