Skip to content

Commit

Permalink
Fixed switching away from the SDL at the framebuffer console
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Lantinga committed Jul 14, 2001
1 parent b38901d commit 654349e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 12 deletions.
19 changes: 17 additions & 2 deletions src/video/fbcon/SDL_fb3dfx.c
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
23 changes: 15 additions & 8 deletions src/video/fbcon/SDL_fbevents.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -908,7 +913,9 @@ static void handle_keyboard(_THIS)
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 */
Expand Down
19 changes: 17 additions & 2 deletions src/video/fbcon/SDL_fbmatrox.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 654349e

Please sign in to comment.