Fixed switching away from the SDL at the framebuffer console
authorSam Lantinga <slouken@lokigames.com>
Sat, 14 Jul 2001 19:10:06 +0000
changeset 1095a9c36a45db1
parent 108 e021a4c9e25f
child 110 7edee9f0f2cc
Fixed switching away from the SDL at the framebuffer console
src/video/fbcon/SDL_fb3dfx.c
src/video/fbcon/SDL_fbevents.c
src/video/fbcon/SDL_fbmatrox.c
     1.1 --- a/src/video/fbcon/SDL_fb3dfx.c	Sat Jul 14 19:08:25 2001 +0000
     1.2 +++ b/src/video/fbcon/SDL_fb3dfx.c	Sat Jul 14 19:10:06 2001 +0000
     1.3 @@ -61,6 +61,11 @@
     1.4  	Uint32 format;
     1.5  	int dstX, dstY;
     1.6  
     1.7 +	/* Don't blit to the display surface when switched away */
     1.8 +	if ( dst == this->screen ) {
     1.9 +		SDL_mutexP(hw_lock);
    1.10 +	}
    1.11 +
    1.12  	/* Set the destination pixel format */
    1.13  	dst_base = (char *)((char *)dst->pixels - mapped_mem);
    1.14  	bpp = dst->format->BitsPerPixel;
    1.15 @@ -81,13 +86,16 @@
    1.16  
    1.17  	FB_AddBusySurface(dst);
    1.18  
    1.19 +	if ( dst == this->screen ) {
    1.20 +		SDL_mutexV(hw_lock);
    1.21 +	}
    1.22  	return(0);
    1.23  }
    1.24  
    1.25  static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
    1.26                         SDL_Surface *dst, SDL_Rect *dstrect)
    1.27  {
    1.28 -	SDL_VideoDevice *this;
    1.29 +	SDL_VideoDevice *this = current_video;
    1.30  	int bpp;
    1.31  	Uint32 src_format;
    1.32  	Uint32 dst_format;
    1.33 @@ -98,8 +106,12 @@
    1.34  	Uint32 blitop;
    1.35  	Uint32 use_colorkey;
    1.36  
    1.37 +	/* Don't blit to the display surface when switched away */
    1.38 +	if ( dst == this->screen ) {
    1.39 +		SDL_mutexP(hw_lock);
    1.40 +	}
    1.41 +
    1.42  	/* Set the source and destination pixel format */
    1.43 -	this = current_video;
    1.44  	src_base = (char *)((char *)src->pixels - mapped_mem);
    1.45  	bpp = src->format->BitsPerPixel;
    1.46  	src_format = src->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
    1.47 @@ -149,6 +161,9 @@
    1.48  	FB_AddBusySurface(src);
    1.49  	FB_AddBusySurface(dst);
    1.50  
    1.51 +	if ( dst == this->screen ) {
    1.52 +		SDL_mutexV(hw_lock);
    1.53 +	}
    1.54  	return(0);
    1.55  }
    1.56  
     2.1 --- a/src/video/fbcon/SDL_fbevents.c	Sat Jul 14 19:08:25 2001 +0000
     2.2 +++ b/src/video/fbcon/SDL_fbevents.c	Sat Jul 14 19:10:06 2001 +0000
     2.3 @@ -311,7 +311,7 @@
     2.4  
     2.5  static enum {
     2.6  	MOUSE_NONE = -1,
     2.7 -	MOUSE_GPM,	/* Note: GPM uses the MSC protocol */
     2.8 +	MOUSE_MSC,	/* Note: GPM uses the MSC protocol */
     2.9  	MOUSE_PS2,
    2.10  	MOUSE_IMPS2,
    2.11  	MOUSE_MS,
    2.12 @@ -535,7 +535,7 @@
    2.13  #ifdef DEBUG_MOUSE
    2.14  fprintf(stderr, "Using GPM mouse\n");
    2.15  #endif
    2.16 -					mouse_drv = MOUSE_GPM;
    2.17 +					mouse_drv = MOUSE_MSC;
    2.18  				}
    2.19  			}
    2.20  		}
    2.21 @@ -642,7 +642,7 @@
    2.22  	}
    2.23  }
    2.24  
    2.25 -/* For now, use GPM, PS/2, and MS protocols
    2.26 +/* For now, use MSC, PS/2, and MS protocols
    2.27     Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
    2.28   */
    2.29  static void handle_mouse(_THIS)
    2.30 @@ -663,7 +663,7 @@
    2.31  			/* Ack! */
    2.32  			read(mouse_fd, mousebuf, BUFSIZ);
    2.33  			return;
    2.34 -		case MOUSE_GPM:
    2.35 +		case MOUSE_MSC:
    2.36  			packetsize = 5;
    2.37  			break;
    2.38  		case MOUSE_IMPS2:
    2.39 @@ -709,8 +709,8 @@
    2.40  		switch (mouse_drv) {
    2.41  			case MOUSE_NONE:
    2.42  				break;
    2.43 -			case MOUSE_GPM:
    2.44 -				/* GPM protocol has 0x80 in high byte */
    2.45 +			case MOUSE_MSC:
    2.46 +				/* MSC protocol has 0x80 in high byte */
    2.47  				if ( (mousebuf[i] & 0xF8) != 0x80 ) {
    2.48  					/* Go to next byte */
    2.49  					i -= (packetsize-1);
    2.50 @@ -825,7 +825,11 @@
    2.51  	return;
    2.52  }
    2.53  
    2.54 -/* Handle switching to another VC, returns when our VC is back */
    2.55 +/* Handle switching to another VC, returns when our VC is back.
    2.56 +   This isn't necessarily the best solution.  For SDL 1.3 we need
    2.57 +   a way of notifying the application when we lose access to the
    2.58 +   video hardware and when we regain it.
    2.59 + */
    2.60  static void switch_vt(_THIS, unsigned short which)
    2.61  {
    2.62  	struct vt_stat vtstate;
    2.63 @@ -844,6 +848,7 @@
    2.64  
    2.65  	/* Save the contents of the screen, and go to text mode */
    2.66  	SDL_mutexP(hw_lock);
    2.67 +	wait_idle(this);
    2.68  	screen = SDL_VideoSurface;
    2.69  	screen_arealen = (screen->h*screen->pitch);
    2.70  	screen_contents = (Uint8 *)malloc(screen_arealen);
    2.71 @@ -908,7 +913,9 @@
    2.72  		    case SDLK_F11:
    2.73  		    case SDLK_F12:
    2.74  			if ( SDL_GetModState() & KMOD_ALT ) {
    2.75 -				switch_vt(this, (keysym.sym-SDLK_F1)+1);
    2.76 +				if ( pressed ) {
    2.77 +					switch_vt(this, (keysym.sym-SDLK_F1)+1);
    2.78 +				}
    2.79  				break;
    2.80  			}
    2.81  			/* Fall through to normal processing */
     3.1 --- a/src/video/fbcon/SDL_fbmatrox.c	Sat Jul 14 19:08:25 2001 +0000
     3.2 +++ b/src/video/fbcon/SDL_fbmatrox.c	Sat Jul 14 19:10:06 2001 +0000
     3.3 @@ -74,6 +74,11 @@
     3.4  	Uint32 ydstlen;
     3.5  	Uint32 fillop;
     3.6  
     3.7 +	/* Don't blit to the display surface when switched away */
     3.8 +	if ( dst == this->screen ) {
     3.9 +		SDL_mutexP(hw_lock);
    3.10 +	}
    3.11 +
    3.12  	switch (dst->format->BytesPerPixel) {
    3.13  	    case 1:
    3.14  		color |= (color<<8);
    3.15 @@ -108,13 +113,16 @@
    3.16  
    3.17  	FB_AddBusySurface(dst);
    3.18  
    3.19 +	if ( dst == this->screen ) {
    3.20 +		SDL_mutexV(hw_lock);
    3.21 +	}
    3.22  	return(0);
    3.23  }
    3.24  
    3.25  static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
    3.26                         SDL_Surface *dst, SDL_Rect *dstrect)
    3.27  {
    3.28 -	SDL_VideoDevice *this;
    3.29 +	SDL_VideoDevice *this = current_video;
    3.30  	int pitch, w, h;
    3.31  	int srcX, srcY;
    3.32  	int dstX, dstY;
    3.33 @@ -128,8 +136,12 @@
    3.34  		return(src->map->sw_blit(src, srcrect, dst, dstrect));
    3.35  	}
    3.36  
    3.37 +	/* Don't blit to the display surface when switched away */
    3.38 +	if ( dst == this->screen ) {
    3.39 +		SDL_mutexP(hw_lock);
    3.40 +	}
    3.41 +
    3.42  	/* Calculate source and destination base coordinates (in pixels) */
    3.43 -	this = current_video;
    3.44  	w = dstrect->w;
    3.45  	h = dstrect->h;
    3.46  	FB_dst_to_xy(this, src, &srcX, &srcY);
    3.47 @@ -201,6 +213,9 @@
    3.48  	FB_AddBusySurface(src);
    3.49  	FB_AddBusySurface(dst);
    3.50  
    3.51 +	if ( dst == this->screen ) {
    3.52 +		SDL_mutexV(hw_lock);
    3.53 +	}
    3.54  	return(0);
    3.55  }
    3.56