From f51dc37d75b0b1b8e5636f8f2c201e29986517ea Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Thu, 7 Feb 2008 22:21:50 +0000 Subject: [PATCH] After the previous revert fix libdrm to start at minor 1 and fixup the demos --- libdrm/xf86drm.c | 29 +++++++++++++---------------- tests/mode/modetest.c | 2 +- tests/modedemo/demo.c | 39 +++++++++++++++++++++++++++++++++------ tests/modefb/demo.c | 2 +- 4 files changed, 48 insertions(+), 24 deletions(-) diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c index 39a849c..8849f8b 100644 --- a/libdrm/xf86drm.c +++ b/libdrm/xf86drm.c @@ -355,7 +355,7 @@ static int drmOpenMinor(int minor, int create, int type) { int fd; char buf[64]; - + if (create) return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type); @@ -421,8 +421,15 @@ static int drmOpenByBusid(const char *busid) const char *buf; drmSetVersion sv; + /* + * Open the first minor number that matches the driver name and isn't + * already in use. If it's in use it will have a busid assigned already. + * + * start at 1, as 0 is the control node, and we should use drmOpenControl + * for that. + */ drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid); - for (i = 0; i < DRM_MAX_MINOR; i++) { + for (i = 1; i < DRM_MAX_MINOR; i++) { fd = drmOpenMinor(i, 1, DRM_NODE_RENDER); drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd); if (fd >= 0) { @@ -467,24 +474,14 @@ static int drmOpenByName(const char *name) drmVersionPtr version; char * id; - if (!drmAvailable()) { - if (!drm_server_info) { - return -1; - } - else { - /* try to load the kernel module now */ - if (!drm_server_info->load_module(name)) { - drmMsg("[drm] failed to load kernel module \"%s\"\n", name); - return -1; - } - } - } - /* * Open the first minor number that matches the driver name and isn't * already in use. If it's in use it will have a busid assigned already. + * + * start at 1, as 0 is the control node, and we should use drmOpenControl + * for that. */ - for (i = 0; i < DRM_MAX_MINOR; i++) { + for (i = 1; i < DRM_MAX_MINOR; i++) { if ((fd = drmOpenMinor(i, 1, DRM_NODE_RENDER)) >= 0) { if ((version = drmGetVersion(fd))) { if (!strcmp(version->name, name)) { diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index ab0cdc9..caa3d97 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -351,7 +351,7 @@ int main(int argc, char **argv) printf("Starting test\n"); - fd = drmOpenControl(0); + fd = drmOpen("i915", NULL); if (fd < 0) { printf("Failed to open the card fb (%d)\n",fd); diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 0882fc9..6b6997a 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -1,11 +1,16 @@ - +#define CLEAN_FBDEV #include #include #include #include #include #include - +#ifdef CLEAN_FBDEV +#include +#include +#include +#include +#endif #include "xf86drm.h" #include "xf86drmMode.h" @@ -20,6 +25,11 @@ void testCursor(int fd, uint32_t crtc); void prettyColors(int fd, unsigned int handle); void prettyCursor(int fd, unsigned int handle, unsigned int color); +#ifdef CLEAN_FBDEV +struct fb_var_screeninfo var; +struct fb_fix_screeninfo fix; +#endif + /* structs for the demo_driver */ struct demo_driver; @@ -90,6 +100,19 @@ int main(int argc, char **argv) struct demo_driver *driver; int num; int i; +#ifdef CLEAN_FBDEV + int fbdev_fd; + + fbdev_fd = open("/dev/fb0", O_RDWR); + + memset(&var, 0, sizeof(struct fb_var_screeninfo)); + memset(&fix, 0, sizeof(struct fb_fix_screeninfo)); + + if (ioctl(fbdev_fd, FBIOGET_VSCREENINFO, &var)) + printf("var %s\n", strerror(errno)); + if (ioctl(fbdev_fd, FBIOGET_FSCREENINFO, &fix)) + printf("fix %s\n", strerror(errno)); +#endif printf("starting demo\n"); @@ -131,9 +154,13 @@ int main(int argc, char **argv) testCursor(driver->fd, driver->screens[i].crtc->crtc_id); } - sleep(2); - printf("ok\n"); - return 0; +#ifdef CLEAN_FBDEV + if (ioctl(fbdev_fd, FBIOPUT_VSCREENINFO, &var)) + printf("var %s\n", strerror(errno)); +#endif + + printf("ok\n"); + return 0; } int demoCreateScreens(struct demo_driver *driver) @@ -260,7 +287,7 @@ struct demo_driver* demoCreateDriver(void) memset(driver, 0, sizeof(struct demo_driver)); - driver->fd = drmOpenControl(0); + driver->fd = drmOpen("i915", NULL); if (driver->fd < 0) { printf("Failed to open the card fb\n"); diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c index 7fa3b93..4d81e51 100644 --- a/tests/modefb/demo.c +++ b/tests/modefb/demo.c @@ -26,7 +26,7 @@ int main(int argc, char **argv) char name[100]; int i,d; int fd; - int drmfd = drmOpenControl(0); + int drmfd = drmOpen("i915", NULL); /* try four devices */ for (d = 0; d < 4; d++) { -- 2.7.4