# HG changeset patch # User iive # Date 1134253830 0 # Node ID e2b0daab849cd874d7a0074570093f996c3d57c1 # Parent 4dbe8679f3e181880a9acb1ef730ec48aaeae47e move to next vo if /dev/3dfx could not be opened open it on preinit not at config time. diff -r 4dbe8679f3e1 -r e2b0daab849c libvo/vo_3dfx.c --- a/libvo/vo_3dfx.c Sat Dec 10 22:22:24 2005 +0000 +++ b/libvo/vo_3dfx.c Sat Dec 10 22:30:30 2005 +0000 @@ -101,6 +101,8 @@ static int bpp; static XWindowAttributes attribs; +static int fd=-1; + static void restore(void) @@ -307,11 +309,12 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format) { - int fd; char *name = ":0.0"; pioData data; uint32_t retval; +//TODO use x11_common for X and window handling + if(getenv("DISPLAY")) name = getenv("DISPLAY"); display = XOpenDisplay(name); @@ -328,9 +331,9 @@ //alarm(120); // Open driver device - if ( (fd = open("/dev/3dfx",O_RDWR) ) == -1) + if ( fd == -1 ) { - printf("Couldn't open /dev/3dfx\n"); + printf("Device not opened /dev/3dfx\n"); return -1; } @@ -350,7 +353,7 @@ if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0) { printf("Error: %d\n",retval); - //return -1; + return -1; } // Ask 3dfx driver for base memory address 1 @@ -361,7 +364,7 @@ if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0) { printf("Error: %d\n",retval); - //return -1; + return -1; } // Map all 3dfx memory areas @@ -406,8 +409,6 @@ //XF86DGADirectVideo(display,0,XF86DGADirectGraphics); //| XF86DGADirectMouse | XF86DGADirectKeyb); #endif - /* fd is deliberately not closed - if it were, mmaps might be released??? */ - atexit(restore); printf("(display) 3dfx initialized %p\n",memBase1); @@ -469,6 +470,8 @@ static void uninit(void) { + if( fd != -1 ) + close(fd); } @@ -478,6 +481,12 @@ static int preinit(const char *arg) { + if ( (fd = open("/dev/3dfx",O_RDWR) ) == -1) + { + printf("Couldn't open /dev/3dfx\n"); + return -1; + } + if(arg) { printf("vo_3dfx: Unknown subdevice: %s\n",arg);