# HG changeset patch # User Sam Lantinga # Date 995137806 0 # Node ID 5a9c36a45db179736256fc356c06c4618024028b # Parent e021a4c9e25f965e3d05ac1b94d69fc2c7f0e00f Fixed switching away from the SDL at the framebuffer console diff -r e021a4c9e25f -r 5a9c36a45db1 src/video/fbcon/SDL_fb3dfx.c --- a/src/video/fbcon/SDL_fb3dfx.c Sat Jul 14 19:08:25 2001 +0000 +++ b/src/video/fbcon/SDL_fb3dfx.c Sat Jul 14 19:10:06 2001 +0000 @@ -61,6 +61,11 @@ Uint32 format; int dstX, dstY; + /* Don't blit to the display surface when switched away */ + if ( dst == this->screen ) { + SDL_mutexP(hw_lock); + } + /* Set the destination pixel format */ dst_base = (char *)((char *)dst->pixels - mapped_mem); bpp = dst->format->BitsPerPixel; @@ -81,13 +86,16 @@ FB_AddBusySurface(dst); + if ( dst == this->screen ) { + SDL_mutexV(hw_lock); + } return(0); } static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { - SDL_VideoDevice *this; + SDL_VideoDevice *this = current_video; int bpp; Uint32 src_format; Uint32 dst_format; @@ -98,8 +106,12 @@ Uint32 blitop; Uint32 use_colorkey; + /* Don't blit to the display surface when switched away */ + if ( dst == this->screen ) { + SDL_mutexP(hw_lock); + } + /* Set the source and destination pixel format */ - this = current_video; src_base = (char *)((char *)src->pixels - mapped_mem); bpp = src->format->BitsPerPixel; src_format = src->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13); @@ -149,6 +161,9 @@ FB_AddBusySurface(src); FB_AddBusySurface(dst); + if ( dst == this->screen ) { + SDL_mutexV(hw_lock); + } return(0); } diff -r e021a4c9e25f -r 5a9c36a45db1 src/video/fbcon/SDL_fbevents.c --- a/src/video/fbcon/SDL_fbevents.c Sat Jul 14 19:08:25 2001 +0000 +++ b/src/video/fbcon/SDL_fbevents.c Sat Jul 14 19:10:06 2001 +0000 @@ -311,7 +311,7 @@ static enum { MOUSE_NONE = -1, - MOUSE_GPM, /* Note: GPM uses the MSC protocol */ + MOUSE_MSC, /* Note: GPM uses the MSC protocol */ MOUSE_PS2, MOUSE_IMPS2, MOUSE_MS, @@ -535,7 +535,7 @@ #ifdef DEBUG_MOUSE fprintf(stderr, "Using GPM mouse\n"); #endif - mouse_drv = MOUSE_GPM; + mouse_drv = MOUSE_MSC; } } } @@ -642,7 +642,7 @@ } } -/* For now, use GPM, PS/2, and MS protocols +/* For now, use MSC, PS/2, and MS protocols Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.) */ static void handle_mouse(_THIS) @@ -663,7 +663,7 @@ /* Ack! */ read(mouse_fd, mousebuf, BUFSIZ); return; - case MOUSE_GPM: + case MOUSE_MSC: packetsize = 5; break; case MOUSE_IMPS2: @@ -709,8 +709,8 @@ switch (mouse_drv) { case MOUSE_NONE: break; - case MOUSE_GPM: - /* GPM protocol has 0x80 in high byte */ + case MOUSE_MSC: + /* MSC protocol has 0x80 in high byte */ if ( (mousebuf[i] & 0xF8) != 0x80 ) { /* Go to next byte */ i -= (packetsize-1); @@ -825,7 +825,11 @@ return; } -/* Handle switching to another VC, returns when our VC is back */ +/* Handle switching to another VC, returns when our VC is back. + This isn't necessarily the best solution. For SDL 1.3 we need + a way of notifying the application when we lose access to the + video hardware and when we regain it. + */ static void switch_vt(_THIS, unsigned short which) { struct vt_stat vtstate; @@ -844,6 +848,7 @@ /* Save the contents of the screen, and go to text mode */ SDL_mutexP(hw_lock); + wait_idle(this); screen = SDL_VideoSurface; screen_arealen = (screen->h*screen->pitch); screen_contents = (Uint8 *)malloc(screen_arealen); @@ -908,7 +913,9 @@ case SDLK_F11: case SDLK_F12: if ( SDL_GetModState() & KMOD_ALT ) { - switch_vt(this, (keysym.sym-SDLK_F1)+1); + if ( pressed ) { + switch_vt(this, (keysym.sym-SDLK_F1)+1); + } break; } /* Fall through to normal processing */ diff -r e021a4c9e25f -r 5a9c36a45db1 src/video/fbcon/SDL_fbmatrox.c --- a/src/video/fbcon/SDL_fbmatrox.c Sat Jul 14 19:08:25 2001 +0000 +++ b/src/video/fbcon/SDL_fbmatrox.c Sat Jul 14 19:10:06 2001 +0000 @@ -74,6 +74,11 @@ Uint32 ydstlen; Uint32 fillop; + /* Don't blit to the display surface when switched away */ + if ( dst == this->screen ) { + SDL_mutexP(hw_lock); + } + switch (dst->format->BytesPerPixel) { case 1: color |= (color<<8); @@ -108,13 +113,16 @@ FB_AddBusySurface(dst); + if ( dst == this->screen ) { + SDL_mutexV(hw_lock); + } return(0); } static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { - SDL_VideoDevice *this; + SDL_VideoDevice *this = current_video; int pitch, w, h; int srcX, srcY; int dstX, dstY; @@ -128,8 +136,12 @@ return(src->map->sw_blit(src, srcrect, dst, dstrect)); } + /* Don't blit to the display surface when switched away */ + if ( dst == this->screen ) { + SDL_mutexP(hw_lock); + } + /* Calculate source and destination base coordinates (in pixels) */ - this = current_video; w = dstrect->w; h = dstrect->h; FB_dst_to_xy(this, src, &srcX, &srcY); @@ -201,6 +213,9 @@ FB_AddBusySurface(src); FB_AddBusySurface(dst); + if ( dst == this->screen ) { + SDL_mutexV(hw_lock); + } return(0); }