lib/igt_kms.c: remove tests dependency on VT /dev/tty0
PATCH v2 1/1 lib/igt_kms.c: remove tests dependency on VT /dev/tty0
Required to run on any recent, freon-based and X11-free ChromeOS release.
---
Changes from v1:
- igt_debug() instead of igt_warn()
- return KD_GRAPHICS instead of -1UL
- print previous mode in debug statements. Among others this help a tiny bit with the now confusing debug output ("cannot change" immediately followed by a misleading "mode changed").
Note: a naive "mv /dev/tty0 /dev/tty0.orig" is typically enough to test this patch.
lib/igt_kms.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
lib/igt_kms.c +18 -4
@@ -299,12 +299,26 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id)return pfci.pipe; } +/* +* Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was +* found and nothing was done. +*/ static signed long set_vt_mode (unsigned long mode) {int fd;unsigned long prev_mode; +static const char TTY0 [] ="/dev/tty0" ; + +if (access (TTY0 ,F_OK )) { +/* errno message should be "No such file". Do not +hardcode but ask strerror() in the very unlikely +case something else happened. */ +igt_debug ("VT: %s: %s, cannot change its mode\n" , +TTY0 ,strerror (errno)); +return KD_GRAPHICS ; + } - fd =open ("/dev/tty0" ,O_RDONLY ); + fd =open (TTY0 ,O_RDONLY );if (fd <0 )return -errno;
@@ -336,10 +350,10 @@ void kmstest_restore_vt_mode(void)if (orig_vt_mode !=-1UL ) { ret =set_vt_mode (orig_vt_mode); - orig_vt_mode =-1UL ;igt_assert (ret >=0 ); -igt_debug ("VT: original mode restored\n" ); +igt_debug ("VT: original mode 0x%lx restored\n" , orig_vt_mode); + orig_vt_mode =-1UL ; } }
@@ -366,7 +380,7 @@ void kmstest_set_vt_graphics_mode(void)igt_assert (ret >=0 ); orig_vt_mode = ret; -igt_debug ("VT: graphics mode set\n" ); +igt_debug ("VT: graphics mode set (mode was 0x%lx)\n" , ret); }
Signature · 6 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines · Marc Herbert
Required to run on any recent, freon-based and X11-free ChromeOS release.
Signed-off-by Marc Herbert <[email protected]>---
Changes from v1:
-igt_debug()instead ofigt_warn()
- returnKD_GRAPHICSinstead of -1UL
- print previous mode in debug statements. Among others this help a tiny bit with the now confusing debug output ("cannot change" immediately followed by a misleading "mode changed").
Thanks for the patch, merged to igt.
-Daniel
Quoted 68 lines
Note: a naive "mv
/dev/tty0/dev/tty0.orig" is typically enough to test this patch.lib/igt_kms.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)lib/igt_kms.c +18
-4@@ -299,12 +299,26 @@ int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id)return pfci.pipe; } +/* +* Returns: the previous mode, or KD_GRAPHICS if no /dev/tty0 was +* found and nothing was done. +*/ static signed long set_vt_mode (unsigned long mode) {int fd;unsigned long prev_mode; +static const char TTY0 [] ="/dev/tty0" ; + +if (access (TTY0 ,F_OK )) { +/* errno message should be "No such file". Do not +hardcode but ask strerror() in the very unlikely +case something else happened. */ +igt_debug ("VT: %s: %s, cannot change its mode\n" , +TTY0 ,strerror (errno)); +return KD_GRAPHICS ; + } - fd =open ("/dev/tty0" ,O_RDONLY ); + fd =open (TTY0 ,O_RDONLY );if (fd <0 )return -errno;@@ -336,10 +350,10 @@ void kmstest_restore_vt_mode(void)if (orig_vt_mode !=-1UL ) { ret =set_vt_mode (orig_vt_mode); - orig_vt_mode =-1UL ;igt_assert (ret >=0 ); -igt_debug ("VT: original mode restored\n" ); +igt_debug ("VT: original mode 0x%lx restored\n" , orig_vt_mode); + orig_vt_mode =-1UL ; } }@@ -366,7 +380,7 @@ void kmstest_set_vt_graphics_mode(void)igt_assert (ret >=0 ); orig_vt_mode = ret; -igt_debug ("VT: graphics mode set\n" ); +igt_debug ("VT: graphics mode set (mode was 0x%lx)\n" , ret); }Signature · 6 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx