[Mplayer-cvslog] CVS: main/libvo vo_dga.c,1.8,1.9

Andreas Ackermann acki2 at users.sourceforge.net
Sun Apr 1 10:07:16 CEST 2001


Update of /cvsroot/mplayer/main/libvo
In directory usw-pr-cvs1:/tmp/cvs-serv6326

Modified Files:
	vo_dga.c 
Log Message:
- added detection of memsize of graphics card to check if double buffering is possible
- fixed resolution switching a little and added more debug output
- resolution switching is still according to d_width and d_height which 
  is not always a good idea ...


Index: vo_dga.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_dga.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** vo_dga.c	2001/03/31 09:16:08	1.8
--- vo_dga.c	2001/04/01 08:07:14	1.9
***************
*** 2,5 ****
--- 2,7 ----
  
  /*
+  * $Id$
+  * 
   * video_out_dga.c, X11 interface
   *
***************
*** 16,19 ****
--- 18,29 ----
   * o covers only common video card formats
   * o works only on intel architectures
+  *
+  * $Log$
+  * Revision 1.9  2001/04/01 08:07:14  acki2
+  * - added detection of memsize of graphics card to check if double buffering is possible
+  * - fixed resolution switching a little and added more debug output
+  * - resolution switching is still according to d_width and d_height which
+  *   is not always a good idea ...
+  *
   * 
   * 30/02/2001
***************
*** 40,45 ****
   */
  
  
- 
  #include <stdio.h>
  #include <stdlib.h>
--- 50,55 ----
   */
  
+ //#define VO_DGA_FORCE_DEPTH 32
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 81,84 ****
--- 91,97 ----
  
  
+ //extern int       verbose;           // shouldn't someone remove the static from 
+                                       // its definition in mplayer.c ???
+ 
  static int       vo_dga_width;           // bytes per line in framebuffer
  static int       vo_dga_vp_width;        // visible pixels per line in 
***************
*** 247,250 ****
--- 260,271 ----
  	)
          {
+           // this only for debug reasons ...
+ 	  if(modelines[i].bitsPerPixel == 15 || modelines[i].bitsPerPixel == 16){
+               printf("vo_dga: depth: %d, %08x, %08x, %08x\n",
+ 		       modelines[i].bitsPerPixel,
+ 		       modelines[i].redMask,
+ 		       modelines[i].greenMask,
+ 	               modelines[i].blueMask);			  
+           }
            for(k=0, dummy=1; k<modelines[i].bitsPerPixel-1; k++)dummy <<=1;
  	  dga_depths |= dummy;
***************
*** 337,344 ****
  //----------------------------------------------------------
  
! int check_mode( int x, int y, 
                  int new_x, int new_y, int new_vbi, 
                  int *old_x, int *old_y, int *old_vbi){
  
    if (
        (new_x >= x) && 
--- 358,368 ----
  //----------------------------------------------------------
  
! int check_mode( int num, int x, int y, int bpp,  
                  int new_x, int new_y, int new_vbi, 
                  int *old_x, int *old_y, int *old_vbi){
  
+   printf("vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ %2d bpp ..",
+           num, new_x, new_y, new_vbi, bpp );
+   printf("(old: %dx%d@%d).", *old_x, *old_y, *old_vbi);	
    if (
        (new_x >= x) && 
***************
*** 360,364 ****
  	((new_y < *old_y) &&
  	 !(new_x > *old_x)) 
! 	) 
         // but if we get an identical resolution choose
         // the one with the lower refreshrate (saves bandwidth !!!)
--- 384,388 ----
  	((new_y < *old_y) &&
  	 !(new_x > *old_x)) 
!        ) 
         // but if we get an identical resolution choose
         // the one with the lower refreshrate (saves bandwidth !!!)
***************
*** 371,375 ****
  	 (
  	  new_vbi >= *old_vbi && *old_vbi < 50
! 	  )  
  	 ||
  	 (
--- 395,399 ----
  	 (
  	  new_vbi >= *old_vbi && *old_vbi < 50
! 	 )  
  	 ||
  	 (
***************
*** 377,391 ****
  	  new_vbi < *old_vbi &&
  	  new_vbi >= 50
- 	  )
  	 )
  	)
         )
!       )  
      {
        *old_x = new_x;
        *old_y = new_y;
        *old_vbi = new_vbi;
        return 1;
      }else{
        return 0;
      }
--- 401,417 ----
  	  new_vbi < *old_vbi &&
  	  new_vbi >= 50
  	 )
  	)
         )
!       )
!      )  
      {
        *old_x = new_x;
        *old_y = new_y;
        *old_vbi = new_vbi;
+       printf(".ok!!\n");
        return 1;
      }else{
+       printf(".no\n");
        return 0;
      }
***************
*** 405,418 ****
  #ifdef HAVE_DGA2
    // needed to change DGA video mode
!   int modecount,mX, mY, mVBI, i,j;
    int dga_modenum;
    XDGAMode   *modelines=NULL;
    XDGADevice *dgadevice;
  #else
  #ifdef HAVE_XF86VM
    unsigned int vm_event, vm_error;
    unsigned int vm_ver, vm_rev;
!   int i,j,have_vm=0;
!   int modecount,mX, mY, mVBI, dga_modenum;  
  #endif
    int bank, ram;
--- 431,445 ----
  #ifdef HAVE_DGA2
    // needed to change DGA video mode
!   int modecount, mX=100000, mY=100000 , mVBI=100000, i,j=0;
    int dga_modenum;
    XDGAMode   *modelines=NULL;
    XDGADevice *dgadevice;
+   int max_vpy_pos;
  #else
  #ifdef HAVE_XF86VM
    unsigned int vm_event, vm_error;
    unsigned int vm_ver, vm_rev;
!   int i, j=0, have_vm=0;
!   int modecount, mX=100000, mY=100000, mVBI=100000, dga_modenum;  
  #endif
    int bank, ram;
***************
*** 466,499 ****
      modelines=XDGAQueryModes(vo_dga_dpy, XDefaultScreen(vo_dga_dpy),&modecount);
    
-   mX=modelines[0].imageWidth;
-   mY=modelines[0].imageHeight;
-   mVBI = modelines[0].verticalRefresh;
- 
-   
    printf("vo_dga: Using DGA 2.0 mode changing support\n");	
-   j=0; 
    // offbyone-error !!! i<=modecount is WRONG !!!
!   for (i=1; i<modecount; i++)
    {
       if( modelines[i].bitsPerPixel == vo_dga_planes)
       {
!        printf("vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ %2d bpp ..",
! 		     i,
! 		     modelines[i].viewportWidth, 
! 		     modelines[i].viewportHeight,
! 		     (unsigned int) modelines[i].verticalRefresh,
! 		     modelines[i].bitsPerPixel );
!      
!        if ( check_mode(d_width, d_height, 
                    modelines[i].viewportWidth, 
                    modelines[i].viewportHeight, 
                    (unsigned) modelines[i].verticalRefresh,
!                    &mX, &mY, &mVBI ))
!        {
!          j = i;
! 	 printf(".ok!!\n");
!        }else{
!          printf(".no\n");
!        }
       }
    }
--- 493,507 ----
      modelines=XDGAQueryModes(vo_dga_dpy, XDefaultScreen(vo_dga_dpy),&modecount);
    
    printf("vo_dga: Using DGA 2.0 mode changing support\n");	
    // offbyone-error !!! i<=modecount is WRONG !!!
!   for (i=0; i<modecount; i++)
    {
       if( modelines[i].bitsPerPixel == vo_dga_planes)
       {
!        if ( check_mode(i, d_width, d_height, modelines[i].bitsPerPixel,  
                    modelines[i].viewportWidth, 
                    modelines[i].viewportHeight, 
                    (unsigned) modelines[i].verticalRefresh,
!                    &mX, &mY, &mVBI )) j = i;
       }
    }
***************
*** 505,508 ****
--- 513,517 ----
    vo_dga_width = modelines[j].bytesPerScanline / vo_dga_bpp;
    dga_modenum =  modelines[j].num;
+   max_vpy_pos = modelines[j].maxViewportY;
    
    XFree(modelines);
***************
*** 511,515 ****
  #else
  
- 
  #ifdef HAVE_XF86VM
  
--- 520,523 ----
***************
*** 521,525 ****
      have_vm=1;
    } else {
!     printf("vo_dga: XF86VidMode Extention not available.\n");
    }
  
--- 529,533 ----
      have_vm=1;
    } else {
!     printf("vo_dga: XF86VidMode Extension not available.\n");
    }
  
***************
*** 532,556 ****
  
      if(vo_dga_vidmodes != NULL ){
!    
!       mX=vo_dga_vidmodes[0]->hdisplay;
!       mY=vo_dga_vidmodes[0]->vdisplay;
!       
!       // TODO: calculate refreshrate from dotclock, hss, hstp, ...
!       mVBI = GET_VREFRESH(vo_dga_vidmodes[0]->dotclock, 
! 	                  vo_dga_vidmodes[0]->htotal,
! 			  vo_dga_vidmodes[0]->vtotal);                       
!       
!       j=0; 
!       for (i=1; i<modecount; i++){
! 	printf("vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ %2d bpp ..",
! 	       i,
! 	       vo_dga_vidmodes[i]->hdisplay, 
! 	       vo_dga_vidmodes[i]->vdisplay,
!                GET_VREFRESH(vo_dga_vidmodes[i]->dotclock, 
! 	                    vo_dga_vidmodes[i]->htotal,
! 			    vo_dga_vidmodes[i]->vtotal),
! 	       vo_dga_planes );
! 	
! 	if ( check_mode(d_width, d_height, 
  			vo_dga_vidmodes[i]->hdisplay, 
  			vo_dga_vidmodes[i]->vdisplay,
--- 540,545 ----
  
      if(vo_dga_vidmodes != NULL ){
!       for (i=0; i<modecount; i++){
! 	if ( check_mode(i, d_width, d_height, vo_dga_planes,  
  			vo_dga_vidmodes[i]->hdisplay, 
  			vo_dga_vidmodes[i]->vdisplay,
***************
*** 558,567 ****
  				     vo_dga_vidmodes[i]->htotal,
  				     vo_dga_vidmodes[i]->vtotal),
! 			&mX, &mY, &mVBI )){
! 	  j = i;
! 	  printf(".ok!!\n");
! 	}else{
! 	  printf(".no\n");
! 	}
        }
      
--- 547,551 ----
  				     vo_dga_vidmodes[i]->htotal,
  				     vo_dga_vidmodes[i]->vtotal),
! 			&mX, &mY, &mVBI )) j = i;
        }
      
***************
*** 582,586 ****
  #endif
  
- 
    vo_dga_src_format = format;
    vo_dga_src_width = width;
--- 566,569 ----
***************
*** 687,691 ****
    // disable doublebuffering for YV12
  
!   printf("vo_dga: Doublebuffering %s.\n", vo_dga_dbf_mem_offset ? "enabled" : "disabled");
    
    // now clear screen
--- 670,679 ----
    // disable doublebuffering for YV12
  
! #ifdef HAVE_DGA2
!       if(vo_dga_vp_height>max_vpy_pos){
!         vo_dga_dbf_mem_offset = 0;
! 	printf("vo_dga: Not enough memory for double buffering!\n");
!       }
! #endif  
    
    // now clear screen
***************
*** 695,701 ****
  	(vo_dga_src_height+y_off) : 0)) *
  	vo_dga_bpp;
!    fprintf(stderr, "vo_dga: Before memset: %d. If mplayer exits here, you haven't enough memory for doublebuffering. I'll fix this in the future to check for amount of mem available... For now, select a lower resolution ...\n", size);   
!    memset(vo_dga_base, 0, size);  
    }
    vo_dga_is_running = 1;
    return 0;
--- 683,701 ----
  	(vo_dga_src_height+y_off) : 0)) *
  	vo_dga_bpp;
! #ifndef HAVE_DGA2
!     printf("%d, %d\n", size, ram);
!     if(size>ram*1024){
!       vo_dga_dbf_mem_offset = 0;
!       printf("vo_dga: Not enough memory for double buffering!\n");
!       size -= (vo_dga_src_height+y_off) * vo_dga_width * vo_dga_bpp;
!     }				        
! #endif
!     
!     printf("vo_dga: Clearing framebuffer (%d bytes). If mplayer exits", size);
!     printf(" here, you haven't enough memory on your card.\n");   
!     fflush(stdout);
!     memset(vo_dga_base, 0, size);  
    }
+   printf("vo_dga: Doublebuffering %s.\n", vo_dga_dbf_mem_offset ? "enabled" : "disabled");
    vo_dga_is_running = 1;
    return 0;


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list