enabling connectors (v2)
cover enabling connectors (v2)
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
Signature · 1 line
1.9.3
PATCH 1/4 lib: add function to change connector states
Add an API function and a test program to force a particular state on a connector.
--- 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
lib/igt_kms.c +57 -0
@@ -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);
lib/igt_kms.h +16 -0
@@ -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);
tests/Makefile.sources +1 -0
@@ -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 \
tests/kms_force_connector.c new file +89 -0
89 lines not on this page · raw message
Signature · 6 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 1/4] lib: add function to change connector states
lib/igt_kms.c err1: · line 394
Quoted 8 lines · Thomas Wood
lib/igt_kms.c +8
-0+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
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 2/4 lib: add the ability to set an EDID data block on a connector
In reply to Thomas WoodAdd a function to set an EDID data block on a connector and include a set of generic EDID blocks for testing.
--- .../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
docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml +1 -0
@@ -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">
lib/Makefile.sources +1 -0
@@ -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 \
lib/igt_edid.h new file +125 -0
125 lines not on this page · raw message
lib/igt_kms.c +46 -4
68 lines not on this page · raw message
lib/igt_kms.h +23 -0
@@ -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);
tests/kms_force_connector.c +24 -0
@@ -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 );
Signature · 1 line
1.9.3
Re: [PATCH i-g-t 2/4] lib: add the ability to set an EDID data block on a connector
Quoted 5 lines · Thomas Wood
lib/igt_kms.h +5
-0+/** +* kmstest_generic_edid: +* @EDID_XGA: 1024x768 +* @EDID_SXGA: 1280x1024 +* @EDID_UXGA: 1600x1200
lib/igt_kms.h enum kmstest_force_connector_state { · line 108
Quoted 10 lines
lib/igt_kms.h +10
-0+* @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
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH i-g-t 2/4] lib: add the ability to set an EDID data block on a connector
Quoted 11 lines · Daniel Vetter
Quoted 10 lines · Thomas Wood
lib/igt_kms.h +10
-0+/** +* 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 {
Quoted 8 lines
lib/igt_kms.h enum kmstest_force_connector_state { · line 108
Quoted 5 lines
lib/igt_kms.h +5
-0+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.
Quoted 5 lines
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 3/4 lib: add igt_enable_connectors and igt_reset_connectors
In reply to Thomas Woodigt_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(+)
lib/igt_kms.c +70 -0
@@ -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); +}
lib/igt_kms.h +3 -0
@@ -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__ */
Signature · 1 line
1.9.3
PATCH 4/4 tests: enable extra connectors in kms_flip and kms_pipe_crc_basic
In reply to Thomas Wood--- tests/kms_flip.c | 2 ++ tests/kms_pipe_crc_basic.c | 2 ++ 2 files changed, 4 insertions(+)
tests/kms_flip.c +2 -0
@@ -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 ();
tests/kms_pipe_crc_basic.c +2 -0
@@ -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 ();
Signature · 1 line
1.9.3