comparison libvo/vo_3dfx.c @ 18234:a107276371a8

Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
author reynaldo
date Mon, 24 Apr 2006 04:23:53 +0000
parents e2b0daab849c
children cea0eb833758
comparison
equal deleted inserted replaced
18233:30fcc199bec7 18234:a107276371a8
25 #include <stdio.h> 25 #include <stdio.h>
26 #include <stdlib.h> 26 #include <stdlib.h>
27 #include <string.h> 27 #include <string.h>
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "mp_msg.h"
31 #include "help_mp.h"
30 #include "video_out.h" 32 #include "video_out.h"
31 #include "video_out_internal.h" 33 #include "video_out_internal.h"
32 34
33 #include <sys/ioctl.h> 35 #include <sys/ioctl.h>
34 #include <unistd.h> 36 #include <unistd.h>
165 167
166 XGetWindowAttributes(display, DefaultRootWindow(display), &attribs); 168 XGetWindowAttributes(display, DefaultRootWindow(display), &attribs);
167 bpp = attribs.depth; 169 bpp = attribs.depth;
168 if (bpp != 16) 170 if (bpp != 16)
169 { 171 {
170 printf("Only 16bpp supported!"); 172 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_Only16BppSupported);
171 exit(-1); 173 exit(-1);
172 } 174 }
173 175
174 XMatchVisualInfo(display,screen,bpp,TrueColor,&vinfo); 176 XMatchVisualInfo(display,screen,bpp,TrueColor,&vinfo);
175 printf("visual id is %lx\n",vinfo.visualid); 177 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_3DFX_VisualIdIs,vinfo.visualid);
176 178
177 theCmap = XCreateColormap(display, RootWindow(display,screen), 179 theCmap = XCreateColormap(display, RootWindow(display,screen),
178 vinfo.visual, AllocNone); 180 vinfo.visual, AllocNone);
179 181
180 xswa.background_pixel = 0; 182 xswa.background_pixel = 0;
331 //alarm(120); 333 //alarm(120);
332 334
333 // Open driver device 335 // Open driver device
334 if ( fd == -1 ) 336 if ( fd == -1 )
335 { 337 {
336 printf("Device not opened /dev/3dfx\n"); 338 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_UnableToOpenDevice);
337 return -1; 339 return -1;
338 } 340 }
339 341
340 // Store sizes for later 342 // Store sizes for later
341 vidwidth = width; 343 vidwidth = width;
350 data.size = 4; 352 data.size = 4;
351 data.value = &baseAddr0; 353 data.value = &baseAddr0;
352 data.device = 0; 354 data.device = 0;
353 if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0) 355 if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0)
354 { 356 {
355 printf("Error: %d\n",retval); 357 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_Error,retval);
356 return -1; 358 return -1;
357 } 359 }
358 360
359 // Ask 3dfx driver for base memory address 1 361 // Ask 3dfx driver for base memory address 1
360 data.port = 0x14; // PCI_BASE_ADDRESS_1_LINUX; 362 data.port = 0x14; // PCI_BASE_ADDRESS_1_LINUX;
361 data.size = 4; 363 data.size = 4;
362 data.value = &baseAddr1; 364 data.value = &baseAddr1;
363 data.device = 0; 365 data.device = 0;
364 if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0) 366 if ((retval = ioctl(fd,_IOC(_IOC_READ,'3',3,0),&data)) < 0)
365 { 367 {
366 printf("Error: %d\n",retval); 368 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_Error,retval);
367 return -1; 369 return -1;
368 } 370 }
369 371
370 // Map all 3dfx memory areas 372 // Map all 3dfx memory areas
371 memBase0 = mmap(0,0x1000000,PROT_READ | PROT_WRITE,MAP_SHARED,fd,baseAddr0); 373 memBase0 = mmap(0,0x1000000,PROT_READ | PROT_WRITE,MAP_SHARED,fd,baseAddr0);
372 memBase1 = mmap(0,3*page_space,PROT_READ | PROT_WRITE,MAP_SHARED,fd,baseAddr1); 374 memBase1 = mmap(0,3*page_space,PROT_READ | PROT_WRITE,MAP_SHARED,fd,baseAddr1);
373 if (memBase0 == (uint32_t *) 0xFFFFFFFF || memBase1 == (uint32_t *) 0xFFFFFFFF) 375 if (memBase0 == (uint32_t *) 0xFFFFFFFF || memBase1 == (uint32_t *) 0xFFFFFFFF)
374 { 376 {
375 printf("Couldn't map 3dfx memory areas: %p,%p,%d\n", 377 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_CouldntMapMemoryArea,
376 memBase0,memBase1,errno); 378 memBase0,memBase1,errno);
377 } 379 }
378 380
379 // Set up global pointers 381 // Set up global pointers
380 reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET; 382 reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
409 //XF86DGADirectVideo(display,0,XF86DGADirectGraphics); //| XF86DGADirectMouse | XF86DGADirectKeyb); 411 //XF86DGADirectVideo(display,0,XF86DGADirectGraphics); //| XF86DGADirectMouse | XF86DGADirectKeyb);
410 #endif 412 #endif
411 413
412 atexit(restore); 414 atexit(restore);
413 415
414 printf("(display) 3dfx initialized %p\n",memBase1); 416 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_3DFX_DisplayInitialized,memBase1);
415 return 0; 417 return 0;
416 } 418 }
417 419
418 static int 420 static int
419 draw_frame(uint8_t *src[]) 421 draw_frame(uint8_t *src[])
481 483
482 static int preinit(const char *arg) 484 static int preinit(const char *arg)
483 { 485 {
484 if ( (fd = open("/dev/3dfx",O_RDWR) ) == -1) 486 if ( (fd = open("/dev/3dfx",O_RDWR) ) == -1)
485 { 487 {
486 printf("Couldn't open /dev/3dfx\n"); 488 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_UnableToOpenDevice);
487 return -1; 489 return -1;
488 } 490 }
489 491
490 if(arg) 492 if(arg)
491 { 493 {
492 printf("vo_3dfx: Unknown subdevice: %s\n",arg); 494 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_3DFX_UnknownSubdevice,arg);
493 return ENOSYS; 495 return ENOSYS;
494 } 496 }
495 return 0; 497 return 0;
496 } 498 }
497 499