mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-21 23:06:29 +00:00
testdisplay: make termio unbuffered
So hotkeys take effect immediately.
This commit is contained in:
parent
3d9e63f2ad
commit
7255a84c9c
@ -56,6 +56,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <termios.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@ -70,6 +71,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
struct termios saved_tio;
|
||||||
|
|
||||||
drmModeRes *resources;
|
drmModeRes *resources;
|
||||||
int drm_fd, modes;
|
int drm_fd, modes;
|
||||||
int test_all_modes = 0, test_preferred_mode = 0, force_mode = 0, test_plane,
|
int test_all_modes = 0, test_preferred_mode = 0, force_mode = 0, test_plane,
|
||||||
@ -720,6 +723,15 @@ static void __attribute__((noreturn)) usage(char *name)
|
|||||||
|
|
||||||
#define dump_resource(res) if (res) dump_##res()
|
#define dump_resource(res) if (res) dump_##res()
|
||||||
|
|
||||||
|
static void cleanup_and_exit(int ret)
|
||||||
|
{
|
||||||
|
close(drm_fd);
|
||||||
|
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &saved_tio);
|
||||||
|
|
||||||
|
exit(ret);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean input_event(GIOChannel *source, GIOCondition condition,
|
static gboolean input_event(GIOChannel *source, GIOCondition condition,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
@ -728,7 +740,7 @@ static gboolean input_event(GIOChannel *source, GIOCondition condition,
|
|||||||
|
|
||||||
count = read(g_io_channel_unix_get_fd(source), buf, sizeof(buf));
|
count = read(g_io_channel_unix_get_fd(source), buf, sizeof(buf));
|
||||||
if (buf[0] == 'q' && (count == 1 || buf[1] == '\n')) {
|
if (buf[0] == 'q' && (count == 1 || buf[1] == '\n')) {
|
||||||
exit(0);
|
cleanup_and_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -754,6 +766,21 @@ static void enter_exec_path( char **argv )
|
|||||||
free(exec_path);
|
free(exec_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_termio_mode(void)
|
||||||
|
{
|
||||||
|
struct termios tio;
|
||||||
|
|
||||||
|
tcgetattr(STDIN_FILENO, &saved_tio);
|
||||||
|
|
||||||
|
tio = saved_tio;
|
||||||
|
|
||||||
|
tio.c_lflag &= ~(ICANON | ECHO);
|
||||||
|
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &tio);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
@ -826,6 +853,8 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_termio_mode();
|
||||||
|
|
||||||
if (depth <= 8)
|
if (depth <= 8)
|
||||||
bpp = 8;
|
bpp = 8;
|
||||||
else if (depth <= 16)
|
else if (depth <= 16)
|
||||||
@ -898,5 +927,7 @@ out_mainloop:
|
|||||||
out_close:
|
out_close:
|
||||||
close(drm_fd);
|
close(drm_fd);
|
||||||
|
|
||||||
|
tcsetattr(STDIN_FILENO, TCSANOW, &saved_tio);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user