src/video/fbcon/SDL_fb3dfx.c
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1659 14717b52abc0
child 1668 4da1ee79c9af
     1.1 --- a/src/video/fbcon/SDL_fb3dfx.c	Sun May 21 17:27:13 2006 +0000
     1.2 +++ b/src/video/fbcon/SDL_fb3dfx.c	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -28,190 +28,197 @@
     1.4  
     1.5  
     1.6  /* Wait for vertical retrace */
     1.7 -static void WaitVBL(_THIS)
     1.8 +static void
     1.9 +WaitVBL (_THIS)
    1.10  {
    1.11 -	/* find start of retrace */
    1.12 -	tdfx_waitidle();
    1.13 -	while( (tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE )
    1.14 -		;
    1.15 -	/* wait until we're past the start */
    1.16 -	while( (tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == 0 )
    1.17 -		; 
    1.18 +    /* find start of retrace */
    1.19 +    tdfx_waitidle ();
    1.20 +    while ((tdfx_in32 (TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE);
    1.21 +    /* wait until we're past the start */
    1.22 +    while ((tdfx_in32 (TDFX_STATUS) & STATUS_RETRACE) == 0);
    1.23  }
    1.24 -static void WaitIdle(_THIS)
    1.25 +static void
    1.26 +WaitIdle (_THIS)
    1.27  {
    1.28 -	tdfx_waitidle();
    1.29 +    tdfx_waitidle ();
    1.30  }
    1.31  
    1.32  /* Sets video mem colorkey and accelerated blit function */
    1.33 -static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
    1.34 +static int
    1.35 +SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key)
    1.36  {
    1.37 -	return(0);
    1.38 +    return (0);
    1.39  }
    1.40  
    1.41 -static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
    1.42 +static int
    1.43 +FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
    1.44  {
    1.45 -	int bpp;
    1.46 -	char *dst_base;
    1.47 -	Uint32 format;
    1.48 -	int dstX, dstY;
    1.49 +    int bpp;
    1.50 +    char *dst_base;
    1.51 +    Uint32 format;
    1.52 +    int dstX, dstY;
    1.53  
    1.54 -	/* Don't blit to the display surface when switched away */
    1.55 -	if ( switched_away ) {
    1.56 -		return -2; /* no hardware access */
    1.57 -	}
    1.58 -	if ( dst == this->screen ) {
    1.59 -		SDL_mutexP(hw_lock);
    1.60 -	}
    1.61 +    /* Don't blit to the display surface when switched away */
    1.62 +    if (switched_away) {
    1.63 +        return -2;              /* no hardware access */
    1.64 +    }
    1.65 +    if (dst == this->screen) {
    1.66 +        SDL_mutexP (hw_lock);
    1.67 +    }
    1.68  
    1.69 -	/* Set the destination pixel format */
    1.70 -	dst_base = (char *)((char *)dst->pixels - mapped_mem);
    1.71 -	bpp = dst->format->BitsPerPixel;
    1.72 -	format = dst->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
    1.73 +    /* Set the destination pixel format */
    1.74 +    dst_base = (char *) ((char *) dst->pixels - mapped_mem);
    1.75 +    bpp = dst->format->BitsPerPixel;
    1.76 +    format = dst->pitch | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
    1.77  
    1.78 -	/* Calculate source and destination base coordinates */
    1.79 -	dstX = rect->x;
    1.80 -	dstY = rect->y;
    1.81 +    /* Calculate source and destination base coordinates */
    1.82 +    dstX = rect->x;
    1.83 +    dstY = rect->y;
    1.84  
    1.85 -	/* Execute the fill command */
    1.86 -	tdfx_wait(6);
    1.87 -	tdfx_out32(DSTBASE, (Uint32)dst_base);
    1.88 -	tdfx_out32(DSTFORMAT, format);
    1.89 -	tdfx_out32(COLORFORE, color);
    1.90 -	tdfx_out32(COMMAND_2D, COMMAND_2D_FILLRECT);
    1.91 -	tdfx_out32(DSTSIZE, rect->w | (rect->h << 16));
    1.92 -	tdfx_out32(LAUNCH_2D, dstX | (dstY << 16));
    1.93 +    /* Execute the fill command */
    1.94 +    tdfx_wait (6);
    1.95 +    tdfx_out32 (DSTBASE, (Uint32) dst_base);
    1.96 +    tdfx_out32 (DSTFORMAT, format);
    1.97 +    tdfx_out32 (COLORFORE, color);
    1.98 +    tdfx_out32 (COMMAND_2D, COMMAND_2D_FILLRECT);
    1.99 +    tdfx_out32 (DSTSIZE, rect->w | (rect->h << 16));
   1.100 +    tdfx_out32 (LAUNCH_2D, dstX | (dstY << 16));
   1.101  
   1.102 -	FB_AddBusySurface(dst);
   1.103 +    FB_AddBusySurface (dst);
   1.104  
   1.105 -	if ( dst == this->screen ) {
   1.106 -		SDL_mutexV(hw_lock);
   1.107 -	}
   1.108 -	return(0);
   1.109 +    if (dst == this->screen) {
   1.110 +        SDL_mutexV (hw_lock);
   1.111 +    }
   1.112 +    return (0);
   1.113  }
   1.114  
   1.115 -static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
   1.116 -                       SDL_Surface *dst, SDL_Rect *dstrect)
   1.117 +static int
   1.118 +HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect,
   1.119 +             SDL_Surface * dst, SDL_Rect * dstrect)
   1.120  {
   1.121 -	SDL_VideoDevice *this = current_video;
   1.122 -	int bpp;
   1.123 -	Uint32 src_format;
   1.124 -	Uint32 dst_format;
   1.125 -	char *src_base;
   1.126 -	char *dst_base;
   1.127 -	int srcX, srcY;
   1.128 -	int dstX, dstY;
   1.129 -	Uint32 blitop;
   1.130 -	Uint32 use_colorkey;
   1.131 +    SDL_VideoDevice *this = current_video;
   1.132 +    int bpp;
   1.133 +    Uint32 src_format;
   1.134 +    Uint32 dst_format;
   1.135 +    char *src_base;
   1.136 +    char *dst_base;
   1.137 +    int srcX, srcY;
   1.138 +    int dstX, dstY;
   1.139 +    Uint32 blitop;
   1.140 +    Uint32 use_colorkey;
   1.141  
   1.142 -	/* Don't blit to the display surface when switched away */
   1.143 -	if ( switched_away ) {
   1.144 -		return -2; /* no hardware access */
   1.145 -	}
   1.146 -	if ( dst == this->screen ) {
   1.147 -		SDL_mutexP(hw_lock);
   1.148 -	}
   1.149 +    /* Don't blit to the display surface when switched away */
   1.150 +    if (switched_away) {
   1.151 +        return -2;              /* no hardware access */
   1.152 +    }
   1.153 +    if (dst == this->screen) {
   1.154 +        SDL_mutexP (hw_lock);
   1.155 +    }
   1.156  
   1.157 -	/* Set the source and destination pixel format */
   1.158 -	src_base = (char *)((char *)src->pixels - mapped_mem);
   1.159 -	bpp = src->format->BitsPerPixel;
   1.160 -	src_format = src->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
   1.161 -	dst_base = (char *)((char *)dst->pixels - mapped_mem);
   1.162 -	bpp = dst->format->BitsPerPixel;
   1.163 -	dst_format = dst->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
   1.164 +    /* Set the source and destination pixel format */
   1.165 +    src_base = (char *) ((char *) src->pixels - mapped_mem);
   1.166 +    bpp = src->format->BitsPerPixel;
   1.167 +    src_format = src->pitch | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
   1.168 +    dst_base = (char *) ((char *) dst->pixels - mapped_mem);
   1.169 +    bpp = dst->format->BitsPerPixel;
   1.170 +    dst_format = dst->pitch | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
   1.171  
   1.172 -	srcX = srcrect->x;
   1.173 -	srcY = srcrect->y;
   1.174 -	dstX = dstrect->x;
   1.175 -	dstY = dstrect->y;
   1.176 +    srcX = srcrect->x;
   1.177 +    srcY = srcrect->y;
   1.178 +    dstX = dstrect->x;
   1.179 +    dstY = dstrect->y;
   1.180  
   1.181 -	/* Assemble the blit operation */
   1.182 -	blitop = COMMAND_2D_BITBLT | (0xCC << 24);
   1.183 -	if ( srcX <= dstX ) {
   1.184 -		blitop |= BIT(14);
   1.185 -		srcX += (dstrect->w - 1);
   1.186 -		dstX += (dstrect->w - 1);
   1.187 -	}
   1.188 -	if ( srcY <= dstY ) {
   1.189 -		blitop |= BIT(15);
   1.190 -		srcY += (dstrect->h - 1);
   1.191 -		dstY += (dstrect->h - 1);
   1.192 -	}
   1.193 +    /* Assemble the blit operation */
   1.194 +    blitop = COMMAND_2D_BITBLT | (0xCC << 24);
   1.195 +    if (srcX <= dstX) {
   1.196 +        blitop |= BIT (14);
   1.197 +        srcX += (dstrect->w - 1);
   1.198 +        dstX += (dstrect->w - 1);
   1.199 +    }
   1.200 +    if (srcY <= dstY) {
   1.201 +        blitop |= BIT (15);
   1.202 +        srcY += (dstrect->h - 1);
   1.203 +        dstY += (dstrect->h - 1);
   1.204 +    }
   1.205  
   1.206 -	/* Perform the blit! */
   1.207 -	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
   1.208 -    		tdfx_wait(3);
   1.209 -    		tdfx_out32(SRCCOLORKEYMIN, src->format->colorkey);
   1.210 -    		tdfx_out32(SRCCOLORKEYMAX, src->format->colorkey);
   1.211 -    		tdfx_out32(ROP_2D, 0xAA00);
   1.212 -		use_colorkey = 1;
   1.213 -	} else {
   1.214 -		use_colorkey = 0;
   1.215 -	}
   1.216 -	tdfx_wait(9);
   1.217 -	tdfx_out32(SRCBASE, (Uint32)src_base);
   1.218 -	tdfx_out32(SRCFORMAT, src_format);
   1.219 -	tdfx_out32(DSTBASE, (Uint32)dst_base);
   1.220 -	tdfx_out32(DSTFORMAT, src_format);
   1.221 -	tdfx_out32(COMMAND_2D, blitop);
   1.222 -	tdfx_out32(COMMANDEXTRA_2D, use_colorkey);
   1.223 -	tdfx_out32(DSTSIZE, dstrect->w | (dstrect->h << 16));
   1.224 -	tdfx_out32(DSTXY, dstX | (dstY << 16));
   1.225 -	tdfx_out32(LAUNCH_2D, srcX | (srcY << 16));
   1.226 +    /* Perform the blit! */
   1.227 +    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
   1.228 +        tdfx_wait (3);
   1.229 +        tdfx_out32 (SRCCOLORKEYMIN, src->format->colorkey);
   1.230 +        tdfx_out32 (SRCCOLORKEYMAX, src->format->colorkey);
   1.231 +        tdfx_out32 (ROP_2D, 0xAA00);
   1.232 +        use_colorkey = 1;
   1.233 +    } else {
   1.234 +        use_colorkey = 0;
   1.235 +    }
   1.236 +    tdfx_wait (9);
   1.237 +    tdfx_out32 (SRCBASE, (Uint32) src_base);
   1.238 +    tdfx_out32 (SRCFORMAT, src_format);
   1.239 +    tdfx_out32 (DSTBASE, (Uint32) dst_base);
   1.240 +    tdfx_out32 (DSTFORMAT, src_format);
   1.241 +    tdfx_out32 (COMMAND_2D, blitop);
   1.242 +    tdfx_out32 (COMMANDEXTRA_2D, use_colorkey);
   1.243 +    tdfx_out32 (DSTSIZE, dstrect->w | (dstrect->h << 16));
   1.244 +    tdfx_out32 (DSTXY, dstX | (dstY << 16));
   1.245 +    tdfx_out32 (LAUNCH_2D, srcX | (srcY << 16));
   1.246  
   1.247 -	FB_AddBusySurface(src);
   1.248 -	FB_AddBusySurface(dst);
   1.249 +    FB_AddBusySurface (src);
   1.250 +    FB_AddBusySurface (dst);
   1.251  
   1.252 -	if ( dst == this->screen ) {
   1.253 -		SDL_mutexV(hw_lock);
   1.254 -	}
   1.255 -	return(0);
   1.256 +    if (dst == this->screen) {
   1.257 +        SDL_mutexV (hw_lock);
   1.258 +    }
   1.259 +    return (0);
   1.260  }
   1.261  
   1.262 -static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
   1.263 +static int
   1.264 +CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst)
   1.265  {
   1.266 -	int accelerated;
   1.267 +    int accelerated;
   1.268  
   1.269 -	/* Set initial acceleration on */
   1.270 -	src->flags |= SDL_HWACCEL;
   1.271 +    /* Set initial acceleration on */
   1.272 +    src->flags |= SDL_HWACCEL;
   1.273  
   1.274 -	/* Set the surface attributes */
   1.275 -	if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
   1.276 -		if ( ! this->info.blit_hw_A ) {
   1.277 -			src->flags &= ~SDL_HWACCEL;
   1.278 -		}
   1.279 -	}
   1.280 -	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
   1.281 -		if ( ! this->info.blit_hw_CC ) {
   1.282 -			src->flags &= ~SDL_HWACCEL;
   1.283 -		}
   1.284 -	}
   1.285 +    /* Set the surface attributes */
   1.286 +    if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
   1.287 +        if (!this->info.blit_hw_A) {
   1.288 +            src->flags &= ~SDL_HWACCEL;
   1.289 +        }
   1.290 +    }
   1.291 +    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
   1.292 +        if (!this->info.blit_hw_CC) {
   1.293 +            src->flags &= ~SDL_HWACCEL;
   1.294 +        }
   1.295 +    }
   1.296  
   1.297 -	/* Check to see if final surface blit is accelerated */
   1.298 -	accelerated = !!(src->flags & SDL_HWACCEL);
   1.299 -	if ( accelerated ) {
   1.300 -		src->map->hw_blit = HWAccelBlit;
   1.301 -	}
   1.302 -	return(accelerated);
   1.303 +    /* Check to see if final surface blit is accelerated */
   1.304 +    accelerated = !!(src->flags & SDL_HWACCEL);
   1.305 +    if (accelerated) {
   1.306 +        src->map->hw_blit = HWAccelBlit;
   1.307 +    }
   1.308 +    return (accelerated);
   1.309  }
   1.310  
   1.311 -void FB_3DfxAccel(_THIS, __u32 card)
   1.312 +void
   1.313 +FB_3DfxAccel (_THIS, __u32 card)
   1.314  {
   1.315 -	/* We have hardware accelerated surface functions */
   1.316 -	this->CheckHWBlit = CheckHWBlit;
   1.317 -	wait_vbl = WaitVBL;
   1.318 -	wait_idle = WaitIdle;
   1.319 +    /* We have hardware accelerated surface functions */
   1.320 +    this->CheckHWBlit = CheckHWBlit;
   1.321 +    wait_vbl = WaitVBL;
   1.322 +    wait_idle = WaitIdle;
   1.323  
   1.324 -	/* Reset the 3Dfx controller */
   1.325 -	tdfx_out32(BRESERROR0, 0);
   1.326 -	tdfx_out32(BRESERROR1, 0);
   1.327 +    /* Reset the 3Dfx controller */
   1.328 +    tdfx_out32 (BRESERROR0, 0);
   1.329 +    tdfx_out32 (BRESERROR1, 0);
   1.330  
   1.331 -	/* The 3Dfx has an accelerated color fill */
   1.332 -	this->info.blit_fill = 1;
   1.333 -	this->FillHWRect = FillHWRect;
   1.334 +    /* The 3Dfx has an accelerated color fill */
   1.335 +    this->info.blit_fill = 1;
   1.336 +    this->FillHWRect = FillHWRect;
   1.337  
   1.338 -	/* The 3Dfx has accelerated normal and colorkey blits */
   1.339 -	this->info.blit_hw = 1;
   1.340 -	this->info.blit_hw_CC = 1;
   1.341 -	this->SetHWColorKey = SetHWColorKey;
   1.342 +    /* The 3Dfx has accelerated normal and colorkey blits */
   1.343 +    this->info.blit_hw = 1;
   1.344 +    this->info.blit_hw_CC = 1;
   1.345 +    this->SetHWColorKey = SetHWColorKey;
   1.346  }
   1.347 +
   1.348 +/* vi: set ts=4 sw=4 expandtab: */