From 388171128d47bcf6d47bf57243261c90457e5d71 Mon Sep 17 00:00:00 2001 From: acki2 Date: Sun, 1 Apr 2001 08:07:14 +0000 Subject: - 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 ... git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@267 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/vo_dga.c | 128 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 64 insertions(+), 64 deletions(-) (limited to 'libvo/vo_dga.c') diff --git a/libvo/vo_dga.c b/libvo/vo_dga.c index 14e9897f47..827990b621 100644 --- a/libvo/vo_dga.c +++ b/libvo/vo_dga.c @@ -1,6 +1,8 @@ #define DISP /* + * $Id$ + * * video_out_dga.c, X11 interface * * @@ -15,6 +17,14 @@ * o this is alpha * 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 * @@ -39,7 +49,7 @@ * */ - +//#define VO_DGA_FORCE_DEPTH 32 #include #include @@ -80,6 +90,9 @@ static XF86VidModeModeInfo **vo_dga_vidmodes=NULL; #endif +//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 // framebuffer @@ -246,6 +259,14 @@ static uint32_t query_format( uint32_t format ) ) ) { + // 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= x) && (new_y >= y) && @@ -359,7 +383,7 @@ int check_mode( int x, int y, !(new_y > *old_y)) || ((new_y < *old_y) && !(new_x > *old_x)) - ) + ) // but if we get an identical resolution choose // the one with the lower refreshrate (saves bandwidth !!!) // as long as it's above 50 Hz (acki2 on 30/3/2001) @@ -370,23 +394,25 @@ int check_mode( int x, int y, ( ( new_vbi >= *old_vbi && *old_vbi < 50 - ) + ) || ( *old_vbi >= 50 && 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; } } @@ -404,16 +430,17 @@ static uint32_t init( uint32_t width, uint32_t height, #ifdef HAVE_DGA2 // needed to change DGA video mode - int modecount,mX, mY, mVBI, i,j; + 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,have_vm=0; - int modecount,mX, mY, mVBI, dga_modenum; + int i, j=0, have_vm=0; + int modecount, mX=100000, mY=100000, mVBI=100000, dga_modenum; #endif int bank, ram; #endif @@ -465,36 +492,17 @@ static uint32_t init( uint32_t width, uint32_t height, if (modelines==NULL) 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; ihdisplay; - 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; ihdisplay, - 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, + for (i=0; ihdisplay, vo_dga_vidmodes[i]->vdisplay, GET_VREFRESH(vo_dga_vidmodes[i]->dotclock, vo_dga_vidmodes[i]->htotal, vo_dga_vidmodes[i]->vtotal), - &mX, &mY, &mVBI )){ - j = i; - printf(".ok!!\n"); - }else{ - printf(".no\n"); - } + &mX, &mY, &mVBI )) j = i; } printf("vo_dga: Selected video mode %4d x %4d @ %3d Hz for image size %3d x %3d.\n", @@ -581,7 +565,6 @@ static uint32_t init( uint32_t width, uint32_t height, #endif #endif - vo_dga_src_format = format; vo_dga_src_width = width; vo_dga_src_height = height; @@ -686,7 +669,12 @@ static uint32_t init( uint32_t width, uint32_t height, if(format ==IMGFMT_YV12 )vo_dga_dbf_mem_offset = 0; // disable doublebuffering for YV12 - printf("vo_dga: Doublebuffering %s.\n", vo_dga_dbf_mem_offset ? "enabled" : "disabled"); +#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 { @@ -694,9 +682,21 @@ static uint32_t init( uint32_t width, uint32_t height, (vo_dga_vp_height + (vo_dga_dbf_mem_offset != 0 ? (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); +#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; } -- cgit v1.2.3