Commit 75213d17 authored by Sam Lantinga's avatar Sam Lantinga

Fixed switching away from the SDL at the framebuffer console

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40110
parent f18a8a4b
...@@ -61,6 +61,11 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color) ...@@ -61,6 +61,11 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
Uint32 format; Uint32 format;
int dstX, dstY; 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 */ /* Set the destination pixel format */
dst_base = (char *)((char *)dst->pixels - mapped_mem); dst_base = (char *)((char *)dst->pixels - mapped_mem);
bpp = dst->format->BitsPerPixel; bpp = dst->format->BitsPerPixel;
...@@ -81,13 +86,16 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color) ...@@ -81,13 +86,16 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
FB_AddBusySurface(dst); FB_AddBusySurface(dst);
if ( dst == this->screen ) {
SDL_mutexV(hw_lock);
}
return(0); return(0);
} }
static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect) SDL_Surface *dst, SDL_Rect *dstrect)
{ {
SDL_VideoDevice *this; SDL_VideoDevice *this = current_video;
int bpp; int bpp;
Uint32 src_format; Uint32 src_format;
Uint32 dst_format; Uint32 dst_format;
...@@ -98,8 +106,12 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, ...@@ -98,8 +106,12 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
Uint32 blitop; Uint32 blitop;
Uint32 use_colorkey; 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 */ /* Set the source and destination pixel format */
this = current_video;
src_base = (char *)((char *)src->pixels - mapped_mem); src_base = (char *)((char *)src->pixels - mapped_mem);
bpp = src->format->BitsPerPixel; bpp = src->format->BitsPerPixel;
src_format = src->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13); src_format = src->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
...@@ -149,6 +161,9 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, ...@@ -149,6 +161,9 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
FB_AddBusySurface(src); FB_AddBusySurface(src);
FB_AddBusySurface(dst); FB_AddBusySurface(dst);
if ( dst == this->screen ) {
SDL_mutexV(hw_lock);
}
return(0); return(0);
} }
......
...@@ -311,7 +311,7 @@ int FB_OpenKeyboard(_THIS) ...@@ -311,7 +311,7 @@ int FB_OpenKeyboard(_THIS)
static enum { static enum {
MOUSE_NONE = -1, MOUSE_NONE = -1,
MOUSE_GPM, /* Note: GPM uses the MSC protocol */ MOUSE_MSC, /* Note: GPM uses the MSC protocol */
MOUSE_PS2, MOUSE_PS2,
MOUSE_IMPS2, MOUSE_IMPS2,
MOUSE_MS, MOUSE_MS,
...@@ -535,7 +535,7 @@ fprintf(stderr, "Using ELO touchscreen\n"); ...@@ -535,7 +535,7 @@ fprintf(stderr, "Using ELO touchscreen\n");
#ifdef DEBUG_MOUSE #ifdef DEBUG_MOUSE
fprintf(stderr, "Using GPM mouse\n"); fprintf(stderr, "Using GPM mouse\n");
#endif #endif
mouse_drv = MOUSE_GPM; mouse_drv = MOUSE_MSC;
} }
} }
} }
...@@ -642,7 +642,7 @@ void FB_vgamousecallback(int button, int relative, int dx, int dy) ...@@ -642,7 +642,7 @@ void FB_vgamousecallback(int button, int relative, int dx, int dy)
} }
} }
/* 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.) Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
*/ */
static void handle_mouse(_THIS) static void handle_mouse(_THIS)
...@@ -663,7 +663,7 @@ static void handle_mouse(_THIS) ...@@ -663,7 +663,7 @@ static void handle_mouse(_THIS)
/* Ack! */ /* Ack! */
read(mouse_fd, mousebuf, BUFSIZ); read(mouse_fd, mousebuf, BUFSIZ);
return; return;
case MOUSE_GPM: case MOUSE_MSC:
packetsize = 5; packetsize = 5;
break; break;
case MOUSE_IMPS2: case MOUSE_IMPS2:
...@@ -709,8 +709,8 @@ static void handle_mouse(_THIS) ...@@ -709,8 +709,8 @@ static void handle_mouse(_THIS)
switch (mouse_drv) { switch (mouse_drv) {
case MOUSE_NONE: case MOUSE_NONE:
break; break;
case MOUSE_GPM: case MOUSE_MSC:
/* GPM protocol has 0x80 in high byte */ /* MSC protocol has 0x80 in high byte */
if ( (mousebuf[i] & 0xF8) != 0x80 ) { if ( (mousebuf[i] & 0xF8) != 0x80 ) {
/* Go to next byte */ /* Go to next byte */
i -= (packetsize-1); i -= (packetsize-1);
...@@ -825,7 +825,11 @@ static void handle_mouse(_THIS) ...@@ -825,7 +825,11 @@ static void handle_mouse(_THIS)
return; 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) static void switch_vt(_THIS, unsigned short which)
{ {
struct vt_stat vtstate; struct vt_stat vtstate;
...@@ -844,6 +848,7 @@ static void switch_vt(_THIS, unsigned short which) ...@@ -844,6 +848,7 @@ static void switch_vt(_THIS, unsigned short which)
/* Save the contents of the screen, and go to text mode */ /* Save the contents of the screen, and go to text mode */
SDL_mutexP(hw_lock); SDL_mutexP(hw_lock);
wait_idle(this);
screen = SDL_VideoSurface; screen = SDL_VideoSurface;
screen_arealen = (screen->h*screen->pitch); screen_arealen = (screen->h*screen->pitch);
screen_contents = (Uint8 *)malloc(screen_arealen); screen_contents = (Uint8 *)malloc(screen_arealen);
...@@ -908,7 +913,9 @@ static void handle_keyboard(_THIS) ...@@ -908,7 +913,9 @@ static void handle_keyboard(_THIS)
case SDLK_F11: case SDLK_F11:
case SDLK_F12: case SDLK_F12:
if ( SDL_GetModState() & KMOD_ALT ) { if ( SDL_GetModState() & KMOD_ALT ) {
switch_vt(this, (keysym.sym-SDLK_F1)+1); if ( pressed ) {
switch_vt(this, (keysym.sym-SDLK_F1)+1);
}
break; break;
} }
/* Fall through to normal processing */ /* Fall through to normal processing */
......
...@@ -74,6 +74,11 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color) ...@@ -74,6 +74,11 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
Uint32 ydstlen; Uint32 ydstlen;
Uint32 fillop; Uint32 fillop;
/* Don't blit to the display surface when switched away */
if ( dst == this->screen ) {
SDL_mutexP(hw_lock);
}
switch (dst->format->BytesPerPixel) { switch (dst->format->BytesPerPixel) {
case 1: case 1:
color |= (color<<8); color |= (color<<8);
...@@ -108,13 +113,16 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color) ...@@ -108,13 +113,16 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
FB_AddBusySurface(dst); FB_AddBusySurface(dst);
if ( dst == this->screen ) {
SDL_mutexV(hw_lock);
}
return(0); return(0);
} }
static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect) SDL_Surface *dst, SDL_Rect *dstrect)
{ {
SDL_VideoDevice *this; SDL_VideoDevice *this = current_video;
int pitch, w, h; int pitch, w, h;
int srcX, srcY; int srcX, srcY;
int dstX, dstY; int dstX, dstY;
...@@ -128,8 +136,12 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, ...@@ -128,8 +136,12 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
return(src->map->sw_blit(src, srcrect, dst, dstrect)); 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) */ /* Calculate source and destination base coordinates (in pixels) */
this = current_video;
w = dstrect->w; w = dstrect->w;
h = dstrect->h; h = dstrect->h;
FB_dst_to_xy(this, src, &srcX, &srcY); FB_dst_to_xy(this, src, &srcX, &srcY);
...@@ -201,6 +213,9 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, ...@@ -201,6 +213,9 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
FB_AddBusySurface(src); FB_AddBusySurface(src);
FB_AddBusySurface(dst); FB_AddBusySurface(dst);
if ( dst == this->screen ) {
SDL_mutexV(hw_lock);
}
return(0); return(0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment