diff options
author | Jerome Glisse <glisse@freedesktop.org> | 2008-03-20 17:44:32 +0100 |
---|---|---|
committer | John Doe <glisse@freedesktop.org> | 2008-03-20 17:44:32 +0100 |
commit | 71b66b00435a10e762a4bb7abedb263196942da4 (patch) | |
tree | 99bbf149f64f14fdc2cd389ec53188c7ce4e040f /tests/modedemo/demo.c | |
parent | 6ef119abf5d19c85fe039fd19d12e9bd64fd44df (diff) | |
parent | 607964ed9e5f6d86a0960bef2341e7f5de9c71da (diff) |
Merge branch 'modesetting-101' of ssh://git.freedesktop.org/git/mesa/drm into modesetting-101
Diffstat (limited to 'tests/modedemo/demo.c')
-rw-r--r-- | tests/modedemo/demo.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 83a33aa6..3fad984d 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -22,6 +22,7 @@ #include <sys/ioctl.h> #include <linux/fb.h> #endif +#include <signal.h> #include "xf86drm.h" #include "xf86drmMode.h" @@ -387,9 +388,28 @@ drmModeCrtcPtr demoFindFreeCrtc(struct demo_driver *driver, drmModeOutputPtr out return crtc; } +static int driverfd; + +static void +hotplugSIGNAL(int sig, siginfo_t *si, void *d) +{ + union drm_wait_hotplug hw; + int ret; + + printf("GOT HOTPLUG EVENT!\n"); + + /* ask for another hotplug event ! */ + memset(&hw, 0, sizeof(hw)); + hw.request.type = _DRM_HOTPLUG_SIGNAL; + hw.request.signal = SIGUSR1; + ret = ioctl(driverfd, DRM_IOCTL_WAIT_HOTPLUG, &hw); +} + struct demo_driver* demoCreateDriver(void) { struct demo_driver* driver = malloc(sizeof(struct demo_driver)); + union drm_wait_hotplug hw; + int ret = 0; memset(driver, 0, sizeof(struct demo_driver)); @@ -400,6 +420,33 @@ struct demo_driver* demoCreateDriver(void) goto err_driver; } +#if 0 + /* ioctl wait for hotplug */ + do { + memset(&hw, 0, sizeof(hw)); + ret = ioctl(driver->fd, DRM_IOCTL_WAIT_HOTPLUG, &hw); + printf("HOTPLUG %d %d %d\n",ret,errno,hw.reply.counter); + } while (ret && errno == EBUSY); +#else + /* signal for hotplug */ + { + struct sigaction sa; + struct sigaction osa; + + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_SIGINFO; + sa.sa_sigaction = hotplugSIGNAL; + sigaction(SIGUSR1, &sa, &osa); + + driverfd = driver->fd; + + memset(&hw, 0, sizeof(hw)); + hw.request.type = _DRM_HOTPLUG_SIGNAL; + hw.request.signal = SIGUSR1; + ret = ioctl(driver->fd, DRM_IOCTL_WAIT_HOTPLUG, &hw); + } +#endif + demoUpdateRes(driver); if (!driver->res) { printf("could not retrive resources\n"); |