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)
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 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
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 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
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 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
FB_AddBusySurface(src);
FB_AddBusySurface(dst);
if ( dst == this->screen ) {
SDL_mutexV(hw_lock);
}
return(0);
}
......
......@@ -311,7 +311,7 @@ int FB_OpenKeyboard(_THIS)
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 @@ fprintf(stderr, "Using ELO touchscreen\n");
#ifdef DEBUG_MOUSE
fprintf(stderr, "Using GPM mouse\n");
#endif
mouse_drv = MOUSE_GPM;
mouse_drv = MOUSE_MSC;
}
}
}
......@@ -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.)
*/
static void handle_mouse(_THIS)
......@@ -663,7 +663,7 @@ static void handle_mouse(_THIS)
/* Ack! */
read(mouse_fd, mousebuf, BUFSIZ);
return;
case MOUSE_GPM:
case MOUSE_MSC:
packetsize = 5;
break;
case MOUSE_IMPS2:
......@@ -709,8 +709,8 @@ static void handle_mouse(_THIS)
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 @@ static void handle_mouse(_THIS)
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 @@ static void switch_vt(_THIS, unsigned short which)
/* 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 @@ static void handle_keyboard(_THIS)
case SDLK_F11:
case SDLK_F12:
if ( SDL_GetModState() & KMOD_ALT ) {
if ( pressed ) {
switch_vt(this, (keysym.sym-SDLK_F1)+1);
}
break;
}
/* Fall through to normal processing */
......
......@@ -74,6 +74,11 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
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 @@ static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
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 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
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 @@ static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
FB_AddBusySurface(src);
FB_AddBusySurface(dst);
if ( dst == this->screen ) {
SDL_mutexV(hw_lock);
}
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