Nobody has stepped up to maintain a framebuffer console driver. Bye bye! :)
authorSam Lantinga <slouken@libsdl.org>
Wed, 19 Jan 2011 22:18:45 -0800
changeset 50451cee937d9fcc
parent 5044 4913042e8572
child 5046 4cb778067834
Nobody has stepped up to maintain a framebuffer console driver. Bye bye! :)
configure.in
include/SDL_config.h.in
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/fbcon/3dfx_mmio.h
src/video/fbcon/3dfx_regs.h
src/video/fbcon/SDL_fb3dfx.c
src/video/fbcon/SDL_fb3dfx.h
src/video/fbcon/SDL_fbelo.c
src/video/fbcon/SDL_fbelo.h
src/video/fbcon/SDL_fbevents.c
src/video/fbcon/SDL_fbevents_c.h
src/video/fbcon/SDL_fbkeys.h
src/video/fbcon/SDL_fbmatrox.c
src/video/fbcon/SDL_fbmatrox.h
src/video/fbcon/SDL_fbmouse.c
src/video/fbcon/SDL_fbmouse_c.h
src/video/fbcon/SDL_fbriva.c
src/video/fbcon/SDL_fbriva.h
src/video/fbcon/SDL_fbvideo.c
src/video/fbcon/SDL_fbvideo.h
src/video/fbcon/matrox_mmio.h
src/video/fbcon/matrox_regs.h
src/video/fbcon/riva_mmio.h
src/video/fbcon/riva_regs.h
     1.1 --- a/configure.in	Wed Jan 19 19:51:04 2011 -0800
     1.2 +++ b/configure.in	Wed Jan 19 22:18:45 2011 -0800
     1.3 @@ -1420,33 +1420,6 @@
     1.4      fi
     1.5  }
     1.6  
     1.7 -dnl Find the framebuffer console includes
     1.8 -CheckFBCON()
     1.9 -{
    1.10 -    AC_ARG_ENABLE(video-fbcon,
    1.11 -AC_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [[default=no]]]),
    1.12 -                  , enable_video_fbcon=no)
    1.13 -    if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
    1.14 -        AC_MSG_CHECKING(for framebuffer console support)
    1.15 -        video_fbcon=no
    1.16 -        AC_TRY_COMPILE([
    1.17 -         #include <linux/fb.h>
    1.18 -         #include <linux/kd.h>
    1.19 -         #include <linux/keyboard.h>
    1.20 -        ],[
    1.21 -        ],[
    1.22 -        video_fbcon=yes
    1.23 -        ])
    1.24 -        AC_MSG_RESULT($video_fbcon)
    1.25 -        if test x$video_fbcon = xyes; then
    1.26 -            AC_CHECK_FUNCS(getpagesize)
    1.27 -            AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
    1.28 -            SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
    1.29 -            have_video=yes
    1.30 -        fi
    1.31 -    fi
    1.32 -}
    1.33 -
    1.34  dnl Find DirectFB
    1.35  CheckDirectFB()
    1.36  {
    1.37 @@ -2300,7 +2273,6 @@
    1.38          CheckESD
    1.39          CheckNAS
    1.40          CheckX11
    1.41 -        CheckFBCON
    1.42          CheckDirectFB
    1.43          CheckFusionSound
    1.44          CheckPS3
     2.1 --- a/include/SDL_config.h.in	Wed Jan 19 19:51:04 2011 -0800
     2.2 +++ b/include/SDL_config.h.in	Wed Jan 19 22:18:45 2011 -0800
     2.3 @@ -261,7 +261,6 @@
     2.4  #undef SDL_VIDEO_DRIVER_DIRECTFB
     2.5  #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
     2.6  #undef SDL_VIDEO_DRIVER_DUMMY
     2.7 -#undef SDL_VIDEO_DRIVER_FBCON
     2.8  #undef SDL_VIDEO_DRIVER_NDS
     2.9  #undef SDL_VIDEO_DRIVER_PHOTON
    2.10  #undef SDL_VIDEO_DRIVER_QNXGF
     3.1 --- a/src/video/SDL_sysvideo.h	Wed Jan 19 19:51:04 2011 -0800
     3.2 +++ b/src/video/SDL_sysvideo.h	Wed Jan 19 22:18:45 2011 -0800
     3.3 @@ -408,9 +408,6 @@
     3.4  #if SDL_VIDEO_DRIVER_X11
     3.5  extern VideoBootStrap X11_bootstrap;
     3.6  #endif
     3.7 -#if SDL_VIDEO_DRIVER_FBCON
     3.8 -extern VideoBootStrap FBCON_bootstrap;
     3.9 -#endif
    3.10  #if SDL_VIDEO_DRIVER_DIRECTFB
    3.11  extern VideoBootStrap DirectFB_bootstrap;
    3.12  #endif
     4.1 --- a/src/video/SDL_video.c	Wed Jan 19 19:51:04 2011 -0800
     4.2 +++ b/src/video/SDL_video.c	Wed Jan 19 22:18:45 2011 -0800
     4.3 @@ -62,9 +62,6 @@
     4.4  #if SDL_VIDEO_DRIVER_X11
     4.5      &X11_bootstrap,
     4.6  #endif
     4.7 -#if SDL_VIDEO_DRIVER_FBCON
     4.8 -    &FBCON_bootstrap,
     4.9 -#endif
    4.10  #if SDL_VIDEO_DRIVER_DIRECTFB
    4.11      &DirectFB_bootstrap,
    4.12  #endif
     5.1 --- a/src/video/fbcon/3dfx_mmio.h	Wed Jan 19 19:51:04 2011 -0800
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,56 +0,0 @@
     5.4 -/*
     5.5 -    SDL - Simple DirectMedia Layer
     5.6 -    Copyright (C) 1997-2010 Sam Lantinga
     5.7 -
     5.8 -    This library is free software; you can redistribute it and/or
     5.9 -    modify it under the terms of the GNU Lesser General Public
    5.10 -    License as published by the Free Software Foundation; either
    5.11 -    version 2.1 of the License, or (at your option) any later version.
    5.12 -
    5.13 -    This library is distributed in the hope that it will be useful,
    5.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 -    Lesser General Public License for more details.
    5.17 -
    5.18 -    You should have received a copy of the GNU Lesser General Public
    5.19 -    License along with this library; if not, write to the Free Software
    5.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 -
    5.22 -    Sam Lantinga
    5.23 -    slouken@libsdl.org
    5.24 -*/
    5.25 -#include "SDL_config.h"
    5.26 -
    5.27 -/* 3Dfx register definitions */
    5.28 -
    5.29 -#include "3dfx_regs.h"
    5.30 -
    5.31 -/* 3Dfx control macros */
    5.32 -
    5.33 -#define tdfx_in8(reg)		*(volatile Uint8  *)(mapped_io + (reg))
    5.34 -#define tdfx_in32(reg)		*(volatile Uint32 *)(mapped_io + (reg))
    5.35 -
    5.36 -#define tdfx_out8(reg,v)	*(volatile Uint8  *)(mapped_io + (reg)) = v;
    5.37 -#define tdfx_out32(reg,v)	*(volatile Uint32 *)(mapped_io + (reg)) = v;
    5.38 -
    5.39 -
    5.40 -/* Wait for fifo space */
    5.41 -#define tdfx_wait(space)						\
    5.42 -{									\
    5.43 -	while ( (tdfx_in8(TDFX_STATUS) & 0x1F) < space )		\
    5.44 -		;							\
    5.45 -}
    5.46 -
    5.47 -
    5.48 -/* Wait for idle accelerator */
    5.49 -#define tdfx_waitidle()							\
    5.50 -{									\
    5.51 -	int i = 0;							\
    5.52 -									\
    5.53 -	tdfx_wait(1);							\
    5.54 -	tdfx_out32(COMMAND_3D, COMMAND_3D_NOP);				\
    5.55 -	do {								\
    5.56 -		i = (tdfx_in32(TDFX_STATUS) & STATUS_BUSY) ? 0 : i + 1;	\
    5.57 -	} while ( i != 3 );						\
    5.58 -}
    5.59 -/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/video/fbcon/3dfx_regs.h	Wed Jan 19 19:51:04 2011 -0800
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,83 +0,0 @@
     6.4 -/*
     6.5 -    SDL - Simple DirectMedia Layer
     6.6 -    Copyright (C) 1997-2010 Sam Lantinga
     6.7 -
     6.8 -    This library is free software; you can redistribute it and/or
     6.9 -    modify it under the terms of the GNU Lesser General Public
    6.10 -    License as published by the Free Software Foundation; either
    6.11 -    version 2.1 of the License, or (at your option) any later version.
    6.12 -
    6.13 -    This library is distributed in the hope that it will be useful,
    6.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 -    Lesser General Public License for more details.
    6.17 -
    6.18 -    You should have received a copy of the GNU Lesser General Public
    6.19 -    License along with this library; if not, write to the Free Software
    6.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    6.21 -
    6.22 -    Sam Lantinga
    6.23 -    slouken@libsdl.org
    6.24 -*/
    6.25 -#include "SDL_config.h"
    6.26 -
    6.27 -#ifndef _3DFX_REGS_H
    6.28 -#define _3DFX_REGS_H
    6.29 -
    6.30 -/* This information comes from the public 3Dfx specs for the Voodoo 3000 */
    6.31 -
    6.32 -/* mapped_io register offsets */
    6.33 -#define TDFX_STATUS	0x00
    6.34 -
    6.35 -#define INTCTRL		(0x00100000 + 0x04)
    6.36 -#define CLIP0MIN	(0x00100000 + 0x08)
    6.37 -#define CLIP0MAX	(0x00100000 + 0x0c)
    6.38 -#define DSTBASE		(0x00100000 + 0x10)
    6.39 -#define DSTFORMAT	(0x00100000 + 0x14)
    6.40 -#define SRCCOLORKEYMIN	(0x00100000 + 0x18)
    6.41 -#define SRCCOLORKEYMAX	(0x00100000 + 0x1c)
    6.42 -#define DSTCOLORKEYMIN	(0x00100000 + 0x20)
    6.43 -#define DSTCOLORKEYMAX	(0x00100000 + 0x24)
    6.44 -#define BRESERROR0	(0x00100000 + 0x28)
    6.45 -#define BRESERROR1	(0x00100000 + 0x2c)
    6.46 -#define ROP_2D		(0x00100000 + 0x30)
    6.47 -#define SRCBASE		(0x00100000 + 0x34)
    6.48 -#define COMMANDEXTRA_2D	(0x00100000 + 0x38)
    6.49 -#define PATTERN0	(0x00100000 + 0x44)
    6.50 -#define PATTERN1	(0x00100000 + 0x48)
    6.51 -#define CLIP1MIN	(0x00100000 + 0x4c)
    6.52 -#define CLIP1MAX	(0x00100000 + 0x50)
    6.53 -#define SRCFORMAT	(0x00100000 + 0x54)
    6.54 -#define SRCSIZE		(0x00100000 + 0x58)
    6.55 -#define SRCXY		(0x00100000 + 0x5c)
    6.56 -#define COLORBACK	(0x00100000 + 0x60)
    6.57 -#define COLORFORE	(0x00100000 + 0x64)
    6.58 -#define DSTSIZE		(0x00100000 + 0x68)
    6.59 -#define DSTXY		(0x00100000 + 0x6c)
    6.60 -#define COMMAND_2D	(0x00100000 + 0x70)
    6.61 -#define LAUNCH_2D	(0x00100000 + 0x80)
    6.62 -#define PATTERNBASE	(0x00100000 + 0x100)
    6.63 -
    6.64 -#define COMMAND_3D	(0x00200000 + 0x120)
    6.65 -
    6.66 -/* register bitfields (not all, only as needed) */
    6.67 -
    6.68 -#define BIT(x) (1UL << (x))
    6.69 -
    6.70 -#define COMMAND_2D_BITBLT		0x01
    6.71 -#define COMMAND_2D_FILLRECT		0x05
    6.72 -#define COMMAND_2D_LINE			0x06
    6.73 -#define COMMAND_2D_POLYGON_FILL		0x08
    6.74 -#define COMMAND_2D_INITIATE		BIT(8)
    6.75 -#define COMMAND_2D_REVERSELINE		BIT(9)
    6.76 -#define COMMAND_2D_STIPPLELINE		BIT(12)
    6.77 -#define COMMAND_2D_MONOCHROME_PATT	BIT(13)
    6.78 -#define COMMAND_2D_MONOCHROME_TRANSP    BIT(16)
    6.79 -
    6.80 -#define COMMAND_3D_NOP			0x00
    6.81 -
    6.82 -#define STATUS_RETRACE			BIT(6)
    6.83 -#define STATUS_BUSY			BIT(9)
    6.84 -
    6.85 -#endif /* _3DFX_REGS_H */
    6.86 -/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/video/fbcon/SDL_fb3dfx.c	Wed Jan 19 19:51:04 2011 -0800
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,225 +0,0 @@
     7.4 -/*
     7.5 -    SDL - Simple DirectMedia Layer
     7.6 -    Copyright (C) 1997-2010 Sam Lantinga
     7.7 -
     7.8 -    This library is free software; you can redistribute it and/or
     7.9 -    modify it under the terms of the GNU Lesser General Public
    7.10 -    License as published by the Free Software Foundation; either
    7.11 -    version 2.1 of the License, or (at your option) any later version.
    7.12 -
    7.13 -    This library is distributed in the hope that it will be useful,
    7.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.16 -    Lesser General Public License for more details.
    7.17 -
    7.18 -    You should have received a copy of the GNU Lesser General Public
    7.19 -    License along with this library; if not, write to the Free Software
    7.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    7.21 -
    7.22 -    Sam Lantinga
    7.23 -    slouken@libsdl.org
    7.24 -*/
    7.25 -#include "SDL_config.h"
    7.26 -
    7.27 -#include "SDL_video.h"
    7.28 -#include "../SDL_blit.h"
    7.29 -#include "SDL_fb3dfx.h"
    7.30 -#include "3dfx_mmio.h"
    7.31 -
    7.32 -
    7.33 -/* Wait for vertical retrace */
    7.34 -static void
    7.35 -WaitVBL(_THIS)
    7.36 -{
    7.37 -    /* find start of retrace */
    7.38 -    tdfx_waitidle();
    7.39 -    while ((tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE);
    7.40 -    /* wait until we're past the start */
    7.41 -    while ((tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == 0);
    7.42 -}
    7.43 -
    7.44 -static void
    7.45 -WaitIdle(_THIS)
    7.46 -{
    7.47 -    tdfx_waitidle();
    7.48 -}
    7.49 -
    7.50 -/* Sets video mem colorkey and accelerated blit function */
    7.51 -static int
    7.52 -SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key)
    7.53 -{
    7.54 -    return (0);
    7.55 -}
    7.56 -
    7.57 -static int
    7.58 -FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
    7.59 -{
    7.60 -    int bpp;
    7.61 -    char *dst_base;
    7.62 -    Uint32 format;
    7.63 -    int dstX, dstY;
    7.64 -
    7.65 -    /* Don't blit to the display surface when switched away */
    7.66 -    if (switched_away) {
    7.67 -        return -2;              /* no hardware access */
    7.68 -    }
    7.69 -    if (dst == this->screen) {
    7.70 -        SDL_mutexP(hw_lock);
    7.71 -    }
    7.72 -
    7.73 -    /* Set the destination pixel format */
    7.74 -    dst_base = (char *) ((char *) dst->pixels - mapped_mem);
    7.75 -    bpp = dst->format->BitsPerPixel;
    7.76 -    format = dst->pitch | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
    7.77 -
    7.78 -    /* Calculate source and destination base coordinates */
    7.79 -    dstX = rect->x;
    7.80 -    dstY = rect->y;
    7.81 -
    7.82 -    /* Execute the fill command */
    7.83 -    tdfx_wait(6);
    7.84 -    tdfx_out32(DSTBASE, (Uint32) dst_base);
    7.85 -    tdfx_out32(DSTFORMAT, format);
    7.86 -    tdfx_out32(COLORFORE, color);
    7.87 -    tdfx_out32(COMMAND_2D, COMMAND_2D_FILLRECT);
    7.88 -    tdfx_out32(DSTSIZE, rect->w | (rect->h << 16));
    7.89 -    tdfx_out32(LAUNCH_2D, dstX | (dstY << 16));
    7.90 -
    7.91 -    FB_AddBusySurface(dst);
    7.92 -
    7.93 -    if (dst == this->screen) {
    7.94 -        SDL_mutexV(hw_lock);
    7.95 -    }
    7.96 -    return (0);
    7.97 -}
    7.98 -
    7.99 -static int
   7.100 -HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
   7.101 -            SDL_Surface * dst, SDL_Rect * dstrect)
   7.102 -{
   7.103 -    SDL_VideoDevice *this = current_video;
   7.104 -    int bpp;
   7.105 -    Uint32 src_format;
   7.106 -    Uint32 dst_format;
   7.107 -    char *src_base;
   7.108 -    char *dst_base;
   7.109 -    int srcX, srcY;
   7.110 -    int dstX, dstY;
   7.111 -    Uint32 blitop;
   7.112 -    Uint32 use_colorkey;
   7.113 -
   7.114 -    /* Don't blit to the display surface when switched away */
   7.115 -    if (switched_away) {
   7.116 -        return -2;              /* no hardware access */
   7.117 -    }
   7.118 -    if (dst == this->screen) {
   7.119 -        SDL_mutexP(hw_lock);
   7.120 -    }
   7.121 -
   7.122 -    /* Set the source and destination pixel format */
   7.123 -    src_base = (char *) ((char *) src->pixels - mapped_mem);
   7.124 -    bpp = src->format->BitsPerPixel;
   7.125 -    src_format = src->pitch | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
   7.126 -    dst_base = (char *) ((char *) dst->pixels - mapped_mem);
   7.127 -    bpp = dst->format->BitsPerPixel;
   7.128 -    dst_format = dst->pitch | ((bpp + ((bpp == 8) ? 0 : 8)) << 13);
   7.129 -
   7.130 -    srcX = srcrect->x;
   7.131 -    srcY = srcrect->y;
   7.132 -    dstX = dstrect->x;
   7.133 -    dstY = dstrect->y;
   7.134 -
   7.135 -    /* Assemble the blit operation */
   7.136 -    blitop = COMMAND_2D_BITBLT | (0xCC << 24);
   7.137 -    if (srcX <= dstX) {
   7.138 -        blitop |= BIT(14);
   7.139 -        srcX += (dstrect->w - 1);
   7.140 -        dstX += (dstrect->w - 1);
   7.141 -    }
   7.142 -    if (srcY <= dstY) {
   7.143 -        blitop |= BIT(15);
   7.144 -        srcY += (dstrect->h - 1);
   7.145 -        dstY += (dstrect->h - 1);
   7.146 -    }
   7.147 -
   7.148 -    /* Perform the blit! */
   7.149 -    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
   7.150 -        tdfx_wait(3);
   7.151 -        tdfx_out32(SRCCOLORKEYMIN, src->format->colorkey);
   7.152 -        tdfx_out32(SRCCOLORKEYMAX, src->format->colorkey);
   7.153 -        tdfx_out32(ROP_2D, 0xAA00);
   7.154 -        use_colorkey = 1;
   7.155 -    } else {
   7.156 -        use_colorkey = 0;
   7.157 -    }
   7.158 -    tdfx_wait(9);
   7.159 -    tdfx_out32(SRCBASE, (Uint32) src_base);
   7.160 -    tdfx_out32(SRCFORMAT, src_format);
   7.161 -    tdfx_out32(DSTBASE, (Uint32) dst_base);
   7.162 -    tdfx_out32(DSTFORMAT, src_format);
   7.163 -    tdfx_out32(COMMAND_2D, blitop);
   7.164 -    tdfx_out32(COMMANDEXTRA_2D, use_colorkey);
   7.165 -    tdfx_out32(DSTSIZE, dstrect->w | (dstrect->h << 16));
   7.166 -    tdfx_out32(DSTXY, dstX | (dstY << 16));
   7.167 -    tdfx_out32(LAUNCH_2D, srcX | (srcY << 16));
   7.168 -
   7.169 -    FB_AddBusySurface(src);
   7.170 -    FB_AddBusySurface(dst);
   7.171 -
   7.172 -    if (dst == this->screen) {
   7.173 -        SDL_mutexV(hw_lock);
   7.174 -    }
   7.175 -    return (0);
   7.176 -}
   7.177 -
   7.178 -static int
   7.179 -CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
   7.180 -{
   7.181 -    int accelerated;
   7.182 -
   7.183 -    /* Set initial acceleration on */
   7.184 -    src->flags |= SDL_HWACCEL;
   7.185 -
   7.186 -    /* Set the surface attributes */
   7.187 -    if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
   7.188 -        if (!this->info.blit_hw_A) {
   7.189 -            src->flags &= ~SDL_HWACCEL;
   7.190 -        }
   7.191 -    }
   7.192 -    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
   7.193 -        if (!this->info.blit_hw_CC) {
   7.194 -            src->flags &= ~SDL_HWACCEL;
   7.195 -        }
   7.196 -    }
   7.197 -
   7.198 -    /* Check to see if final surface blit is accelerated */
   7.199 -    accelerated = !!(src->flags & SDL_HWACCEL);
   7.200 -    if (accelerated) {
   7.201 -        src->map->hw_blit = HWAccelBlit;
   7.202 -    }
   7.203 -    return (accelerated);
   7.204 -}
   7.205 -
   7.206 -void
   7.207 -FB_3DfxAccel(_THIS, __u32 card)
   7.208 -{
   7.209 -    /* We have hardware accelerated surface functions */
   7.210 -    this->CheckHWBlit = CheckHWBlit;
   7.211 -    wait_vbl = WaitVBL;
   7.212 -    wait_idle = WaitIdle;
   7.213 -
   7.214 -    /* Reset the 3Dfx controller */
   7.215 -    tdfx_out32(BRESERROR0, 0);
   7.216 -    tdfx_out32(BRESERROR1, 0);
   7.217 -
   7.218 -    /* The 3Dfx has an accelerated color fill */
   7.219 -    this->info.blit_fill = 1;
   7.220 -    this->FillHWRect = FillHWRect;
   7.221 -
   7.222 -    /* The 3Dfx has accelerated normal and colorkey blits */
   7.223 -    this->info.blit_hw = 1;
   7.224 -    this->info.blit_hw_CC = 1;
   7.225 -    this->SetHWColorKey = SetHWColorKey;
   7.226 -}
   7.227 -
   7.228 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/fbcon/SDL_fb3dfx.h	Wed Jan 19 19:51:04 2011 -0800
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,30 +0,0 @@
     8.4 -/*
     8.5 -    SDL - Simple DirectMedia Layer
     8.6 -    Copyright (C) 1997-2010 Sam Lantinga
     8.7 -
     8.8 -    This library is free software; you can redistribute it and/or
     8.9 -    modify it under the terms of the GNU Lesser General Public
    8.10 -    License as published by the Free Software Foundation; either
    8.11 -    version 2.1 of the License, or (at your option) any later version.
    8.12 -
    8.13 -    This library is distributed in the hope that it will be useful,
    8.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 -    Lesser General Public License for more details.
    8.17 -
    8.18 -    You should have received a copy of the GNU Lesser General Public
    8.19 -    License along with this library; if not, write to the Free Software
    8.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    8.21 -
    8.22 -    Sam Lantinga
    8.23 -    slouken@libsdl.org
    8.24 -*/
    8.25 -#include "SDL_config.h"
    8.26 -
    8.27 -/* 3Dfx hardware acceleration for the SDL framebuffer console driver */
    8.28 -
    8.29 -#include "SDL_fbvideo.h"
    8.30 -
    8.31 -/* Set up the driver for 3Dfx acceleration */
    8.32 -extern void FB_3DfxAccel(_THIS, __u32 card);
    8.33 -/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/src/video/fbcon/SDL_fbelo.c	Wed Jan 19 19:51:04 2011 -0800
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,462 +0,0 @@
     9.4 -/*
     9.5 -    SDL - Simple DirectMedia Layer
     9.6 -    Copyright (C) 1997-2010 Sam Lantinga
     9.7 -
     9.8 -    This library is free software; you can redistribute it and/or
     9.9 -    modify it under the terms of the GNU Lesser General Public
    9.10 -    License as published by the Free Software Foundation; either
    9.11 -    version 2.1 of the License, or (at your option) any later version.
    9.12 -
    9.13 -    This library is distributed in the hope that it will be useful,
    9.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.16 -    Lesser General Public License for more details.
    9.17 -
    9.18 -    You should have received a copy of the GNU Lesser General Public
    9.19 -    License along with this library; if not, write to the Free Software
    9.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    9.21 -
    9.22 -    Sam Lantinga
    9.23 -    slouken@libsdl.org
    9.24 -*/
    9.25 -#include "SDL_config.h"
    9.26 -
    9.27 -#include <unistd.h>
    9.28 -#include <sys/time.h>
    9.29 -#include <ctype.h>
    9.30 -
    9.31 -#include "SDL_stdinc.h"
    9.32 -#include "SDL_fbvideo.h"
    9.33 -#include "SDL_fbelo.h"
    9.34 -
    9.35 -/*
    9.36 -	calibration default values
    9.37 -	values are read from the following environment variables:
    9.38 -
    9.39 -	SDL_ELO_MIN_X
    9.40 -	SDL_ELO_MAX_X
    9.41 -	SDL_ELO_MIN_Y
    9.42 -	SDL_ELO_MAX_Y
    9.43 -*/
    9.44 -
    9.45 -static int ELO_MIN_X = 400;
    9.46 -static int ELO_MAX_X = 3670;
    9.47 -static int ELO_MIN_Y = 500;
    9.48 -static int ELO_MAX_Y = 3540;
    9.49 -
    9.50 -#define ELO_SNAP_SIZE 6
    9.51 -#define ELO_TOUCH_BYTE		'T'
    9.52 -#define ELO_ID			'I'
    9.53 -#define ELO_MODE		'M'
    9.54 -#define ELO_PARAMETER		'P'
    9.55 -#define ELO_REPORT		'B'
    9.56 -#define ELO_ACK			'A'
    9.57 -
    9.58 -#define ELO_INIT_CHECKSUM	0xAA
    9.59 -
    9.60 -#define ELO_BTN_PRESS		0x01
    9.61 -#define ELO_STREAM		0x02
    9.62 -#define ELO_BTN_RELEASE		0x04
    9.63 -
    9.64 -#define ELO_TOUCH_MODE		0x01
    9.65 -#define ELO_STREAM_MODE		0x02
    9.66 -#define ELO_UNTOUCH_MODE	0x04
    9.67 -#define ELO_RANGE_CHECK_MODE	0x40
    9.68 -#define ELO_TRIM_MODE		0x02
    9.69 -#define ELO_CALIB_MODE		0x04
    9.70 -#define ELO_SCALING_MODE	0x08
    9.71 -#define ELO_TRACKING_MODE	0x40
    9.72 -
    9.73 -#define ELO_SERIAL_MASK		0xF8
    9.74 -
    9.75 -#define ELO_SERIAL_IO		'0'
    9.76 -
    9.77 -#define ELO_MAX_TRIALS	3
    9.78 -#define ELO_MAX_WAIT		100000
    9.79 -#define ELO_UNTOUCH_DELAY	5
    9.80 -#define ELO_REPORT_DELAY	1
    9.81 -
    9.82 -/*	eloParsePacket
    9.83 -*/
    9.84 -int
    9.85 -eloParsePacket(unsigned char *mousebuf, int *dx, int *dy, int *button_state)
    9.86 -{
    9.87 -    static int elo_button = 0;
    9.88 -    static int last_x = 0;
    9.89 -    static int last_y = 0;
    9.90 -    int x, y;
    9.91 -
    9.92 -    /* Check if we have a touch packet */
    9.93 -    if (mousebuf[1] != ELO_TOUCH_BYTE) {
    9.94 -        return 0;
    9.95 -    }
    9.96 -
    9.97 -    x = ((mousebuf[4] << 8) | mousebuf[3]);
    9.98 -    y = ((mousebuf[6] << 8) | mousebuf[5]);
    9.99 -
   9.100 -    if ((SDL_abs(x - last_x) > ELO_SNAP_SIZE)
   9.101 -        || (SDL_abs(y - last_y) > ELO_SNAP_SIZE)) {
   9.102 -        *dx = ((mousebuf[4] << 8) | mousebuf[3]);
   9.103 -        *dy = ((mousebuf[6] << 8) | mousebuf[5]);
   9.104 -    } else {
   9.105 -        *dx = last_x;
   9.106 -        *dy = last_y;
   9.107 -    }
   9.108 -
   9.109 -    last_x = *dx;
   9.110 -    last_y = *dy;
   9.111 -
   9.112 -    if ((mousebuf[2] & 0x07) == ELO_BTN_PRESS) {
   9.113 -        elo_button = 1;
   9.114 -    }
   9.115 -    if ((mousebuf[2] & 0x07) == ELO_BTN_RELEASE) {
   9.116 -        elo_button = 0;
   9.117 -    }
   9.118 -
   9.119 -    *button_state = elo_button;
   9.120 -    return 1;
   9.121 -}
   9.122 -
   9.123 -/*	Convert the raw coordinates from the ELO controller
   9.124 -	to a screen position.
   9.125 -*/
   9.126 -void
   9.127 -eloConvertXY(_THIS, int *dx, int *dy)
   9.128 -{
   9.129 -    int input_x = *dx;
   9.130 -    int input_y = *dy;
   9.131 -    int width = ELO_MAX_X - ELO_MIN_X;
   9.132 -    int height = ELO_MAX_Y - ELO_MIN_Y;
   9.133 -
   9.134 -    *dx =
   9.135 -        ((int) cache_vinfo.xres -
   9.136 -         ((int) cache_vinfo.xres * (input_x - ELO_MIN_X)) / width);
   9.137 -    *dy = (cache_vinfo.yres * (input_y - ELO_MIN_Y)) / height;
   9.138 -}
   9.139 -
   9.140 -
   9.141 -/*	eloGetPacket
   9.142 -*/
   9.143 -int
   9.144 -eloGetPacket(unsigned char *buffer, int *buffer_p, int *checksum, int fd)
   9.145 -{
   9.146 -    int num_bytes;
   9.147 -    int ok;
   9.148 -
   9.149 -    if (fd == 0) {
   9.150 -        num_bytes = ELO_PACKET_SIZE;
   9.151 -    } else {
   9.152 -        num_bytes = read(fd,
   9.153 -                         (char *) (buffer + *buffer_p),
   9.154 -                         ELO_PACKET_SIZE - *buffer_p);
   9.155 -    }
   9.156 -
   9.157 -    if (num_bytes < 0) {
   9.158 -#ifdef DEBUG_MOUSE
   9.159 -        fprintf(stderr,
   9.160 -                "System error while reading from Elographics touchscreen.\n");
   9.161 -#endif
   9.162 -        return 0;
   9.163 -    }
   9.164 -
   9.165 -    while (num_bytes) {
   9.166 -        if ((*buffer_p == 0) && (buffer[0] != ELO_START_BYTE)) {
   9.167 -            SDL_memcpy(&buffer[0], &buffer[1], num_bytes - 1);
   9.168 -        } else {
   9.169 -            if (*buffer_p < ELO_PACKET_SIZE - 1) {
   9.170 -                *checksum = *checksum + buffer[*buffer_p];
   9.171 -                *checksum = *checksum % 256;
   9.172 -            }
   9.173 -            (*buffer_p)++;
   9.174 -        }
   9.175 -        num_bytes--;
   9.176 -    }
   9.177 -
   9.178 -    if (*buffer_p == ELO_PACKET_SIZE) {
   9.179 -        ok = (*checksum == buffer[ELO_PACKET_SIZE - 1]);
   9.180 -        *checksum = ELO_INIT_CHECKSUM;
   9.181 -        *buffer_p = 0;
   9.182 -
   9.183 -        if (!ok) {
   9.184 -            return 0;
   9.185 -        }
   9.186 -
   9.187 -        return 1;
   9.188 -    } else {
   9.189 -        return 0;
   9.190 -    }
   9.191 -}
   9.192 -
   9.193 -/* eloSendPacket
   9.194 -*/
   9.195 -
   9.196 -int
   9.197 -eloSendPacket(unsigned char *packet, int fd)
   9.198 -{
   9.199 -    int i, result;
   9.200 -    int sum = ELO_INIT_CHECKSUM;
   9.201 -
   9.202 -    packet[0] = ELO_START_BYTE;
   9.203 -    for (i = 0; i < ELO_PACKET_SIZE - 1; i++) {
   9.204 -        sum += packet[i];
   9.205 -        sum &= 0xFF;
   9.206 -    }
   9.207 -    packet[ELO_PACKET_SIZE - 1] = sum;
   9.208 -
   9.209 -    result = write(fd, packet, ELO_PACKET_SIZE);
   9.210 -
   9.211 -    if (result != ELO_PACKET_SIZE) {
   9.212 -#ifdef DEBUG_MOUSE
   9.213 -        printf("System error while sending to Elographics touchscreen.\n");
   9.214 -#endif
   9.215 -        return 0;
   9.216 -    } else {
   9.217 -        return 1;
   9.218 -    }
   9.219 -}
   9.220 -
   9.221 -
   9.222 -/*	eloWaitForInput
   9.223 - */
   9.224 -int
   9.225 -eloWaitForInput(int fd, int timeout)
   9.226 -{
   9.227 -    fd_set readfds;
   9.228 -    struct timeval to;
   9.229 -    int r;
   9.230 -
   9.231 -    FD_ZERO(&readfds);
   9.232 -    FD_SET(fd, &readfds);
   9.233 -    to.tv_sec = 0;
   9.234 -    to.tv_usec = timeout;
   9.235 -
   9.236 -    r = select(FD_SETSIZE, &readfds, NULL, NULL, &to);
   9.237 -    return r;
   9.238 -}
   9.239 -
   9.240 -/*	eloWaitReply
   9.241 - */
   9.242 -int
   9.243 -eloWaitReply(unsigned char type, unsigned char *reply, int fd)
   9.244 -{
   9.245 -    int ok;
   9.246 -    int i, result;
   9.247 -    int reply_p = 0;
   9.248 -    int sum = ELO_INIT_CHECKSUM;
   9.249 -
   9.250 -    i = ELO_MAX_TRIALS;
   9.251 -    do {
   9.252 -        ok = 0;
   9.253 -
   9.254 -        result = eloWaitForInput(fd, ELO_MAX_WAIT);
   9.255 -
   9.256 -        if (result > 0) {
   9.257 -            ok = eloGetPacket(reply, &reply_p, &sum, fd);
   9.258 -
   9.259 -            if (ok && reply[1] != type && type != ELO_PARAMETER) {
   9.260 -#ifdef DEBUG_MOUSE
   9.261 -                fprintf(stderr, "Wrong reply received\n");
   9.262 -#endif
   9.263 -                ok = 0;
   9.264 -            }
   9.265 -        } else {
   9.266 -#ifdef DEBUG_MOUSE
   9.267 -            fprintf(stderr, "No input!\n");
   9.268 -#endif
   9.269 -        }
   9.270 -
   9.271 -        if (result == 0) {
   9.272 -            i--;
   9.273 -        }
   9.274 -    } while (!ok && (i > 0));
   9.275 -
   9.276 -    return ok;
   9.277 -}
   9.278 -
   9.279 -
   9.280 -/*	eloWaitAck
   9.281 - */
   9.282 -
   9.283 -int
   9.284 -eloWaitAck(int fd)
   9.285 -{
   9.286 -    unsigned char packet[ELO_PACKET_SIZE];
   9.287 -    int i, nb_errors;
   9.288 -
   9.289 -    if (eloWaitReply(ELO_ACK, packet, fd)) {
   9.290 -        for (i = 0, nb_errors = 0; i < 4; i++) {
   9.291 -            if (packet[2 + i] != '0') {
   9.292 -                nb_errors++;
   9.293 -            }
   9.294 -        }
   9.295 -
   9.296 -        if (nb_errors != 0) {
   9.297 -#ifdef DEBUG_MOUSE
   9.298 -            fprintf(stderr,
   9.299 -                    "Elographics acknowledge packet reports %d errors\n",
   9.300 -                    nb_errors);
   9.301 -#endif
   9.302 -        }
   9.303 -        return 1;
   9.304 -    } else {
   9.305 -        return 0;
   9.306 -    }
   9.307 -}
   9.308 -
   9.309 -
   9.310 -/*	eloSendQuery --
   9.311 -*/
   9.312 -int
   9.313 -eloSendQuery(unsigned char *request, unsigned char *reply, int fd)
   9.314 -{
   9.315 -    int ok;
   9.316 -
   9.317 -    if (eloSendPacket(request, fd)) {
   9.318 -        ok = eloWaitReply(toupper(request[1]), reply, fd);
   9.319 -        if (ok) {
   9.320 -            ok = eloWaitAck(fd);
   9.321 -        }
   9.322 -        return ok;
   9.323 -    } else {
   9.324 -        return 0;
   9.325 -    }
   9.326 -}
   9.327 -
   9.328 -
   9.329 -/*	eloSendControl
   9.330 -*/
   9.331 -int
   9.332 -eloSendControl(unsigned char *control, int fd)
   9.333 -{
   9.334 -    if (eloSendPacket(control, fd)) {
   9.335 -        return eloWaitAck(fd);
   9.336 -    } else {
   9.337 -        return 0;
   9.338 -    }
   9.339 -}
   9.340 -
   9.341 -/*	eloInitController
   9.342 -*/
   9.343 -int
   9.344 -eloInitController(int fd)
   9.345 -{
   9.346 -    unsigned char req[ELO_PACKET_SIZE];
   9.347 -    unsigned char reply[ELO_PACKET_SIZE];
   9.348 -    const char *buffer = NULL;
   9.349 -    int result = 0;
   9.350 -
   9.351 -    struct termios mouse_termios;
   9.352 -
   9.353 -    /* try to read the calibration values */
   9.354 -    buffer = SDL_getenv("SDL_ELO_MIN_X");
   9.355 -    if (buffer) {
   9.356 -        ELO_MIN_X = SDL_atoi(buffer);
   9.357 -    }
   9.358 -    buffer = SDL_getenv("SDL_ELO_MAX_X");
   9.359 -    if (buffer) {
   9.360 -        ELO_MAX_X = SDL_atoi(buffer);
   9.361 -    }
   9.362 -    buffer = SDL_getenv("SDL_ELO_MIN_Y");
   9.363 -    if (buffer) {
   9.364 -        ELO_MIN_Y = SDL_atoi(buffer);
   9.365 -    }
   9.366 -    buffer = SDL_getenv("SDL_ELO_MAX_Y");
   9.367 -    if (buffer) {
   9.368 -        ELO_MAX_Y = SDL_atoi(buffer);
   9.369 -    }
   9.370 -#ifdef DEBUG_MOUSE
   9.371 -    fprintf(stderr,
   9.372 -            "ELO calibration values:\nmin_x: %i\nmax_x: %i\nmin_y: %i\nmax_y: %i\n",
   9.373 -            ELO_MIN_X, ELO_MAX_X, ELO_MIN_Y, ELO_MAX_Y);
   9.374 -#endif
   9.375 -
   9.376 -    /* set comm params */
   9.377 -    SDL_memset(&mouse_termios, 0, sizeof(mouse_termios));
   9.378 -    mouse_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL;
   9.379 -    mouse_termios.c_cc[VMIN] = 1;
   9.380 -    result = tcsetattr(fd, TCSANOW, &mouse_termios);
   9.381 -
   9.382 -    if (result < 0) {
   9.383 -#ifdef DEBUG_MOUSE
   9.384 -        fprintf(stderr, "Unable to configure Elographics touchscreen port\n");
   9.385 -#endif
   9.386 -        return 0;
   9.387 -    }
   9.388 -
   9.389 -    SDL_memset(req, 0, ELO_PACKET_SIZE);
   9.390 -    req[1] = tolower(ELO_PARAMETER);
   9.391 -    if (!eloSendQuery(req, reply, fd)) {
   9.392 -#ifdef DEBUG_MOUSE
   9.393 -        fprintf(stderr,
   9.394 -                "Not at the specified rate or model 2310, will continue\n");
   9.395 -#endif
   9.396 -    }
   9.397 -
   9.398 -    SDL_memset(req, 0, ELO_PACKET_SIZE);
   9.399 -    req[1] = tolower(ELO_ID);
   9.400 -    if (eloSendQuery(req, reply, fd)) {
   9.401 -#ifdef DEBUG_MOUSE
   9.402 -        fprintf(stderr, "Ok, controller configured!\n");
   9.403 -#endif
   9.404 -    } else {
   9.405 -#ifdef DEBUG_MOUSE
   9.406 -        fprintf(stderr,
   9.407 -                "Unable to ask Elographics touchscreen identification\n");
   9.408 -#endif
   9.409 -        return 0;
   9.410 -    }
   9.411 -
   9.412 -    SDL_memset(req, 0, ELO_PACKET_SIZE);
   9.413 -    req[1] = ELO_MODE;
   9.414 -    req[3] = ELO_TOUCH_MODE | ELO_STREAM_MODE | ELO_UNTOUCH_MODE;
   9.415 -    req[4] = ELO_TRACKING_MODE;
   9.416 -    if (!eloSendControl(req, fd)) {
   9.417 -#ifdef DEBUG_MOUSE
   9.418 -        fprintf(stderr,
   9.419 -                "Unable to change Elographics touchscreen operating mode\n");
   9.420 -#endif
   9.421 -        return 0;
   9.422 -    }
   9.423 -
   9.424 -    SDL_memset(req, 0, ELO_PACKET_SIZE);
   9.425 -    req[1] = ELO_REPORT;
   9.426 -    req[2] = ELO_UNTOUCH_DELAY;
   9.427 -    req[3] = ELO_REPORT_DELAY;
   9.428 -    if (!eloSendControl(req, fd)) {
   9.429 -#ifdef DEBUG_MOUSE
   9.430 -        fprintf(stderr,
   9.431 -                "Unable to change Elographics touchscreen reports timings\n");
   9.432 -#endif
   9.433 -        return 0;
   9.434 -    }
   9.435 -
   9.436 -    return 1;
   9.437 -}
   9.438 -
   9.439 -int
   9.440 -eloReadPosition(_THIS, int fd, int *x, int *y, int *button_state, int *realx,
   9.441 -                int *realy)
   9.442 -{
   9.443 -    unsigned char buffer[ELO_PACKET_SIZE];
   9.444 -    int pointer = 0;
   9.445 -    int checksum = ELO_INIT_CHECKSUM;
   9.446 -
   9.447 -    while (pointer < ELO_PACKET_SIZE) {
   9.448 -        if (eloGetPacket(buffer, &pointer, &checksum, fd)) {
   9.449 -            break;
   9.450 -        }
   9.451 -    }
   9.452 -
   9.453 -    if (!eloParsePacket(buffer, realx, realy, button_state)) {
   9.454 -        return 0;
   9.455 -    }
   9.456 -
   9.457 -    *x = *realx;
   9.458 -    *y = *realy;
   9.459 -
   9.460 -    eloConvertXY(this, x, y);
   9.461 -
   9.462 -    return 1;
   9.463 -}
   9.464 -
   9.465 -/* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/video/fbcon/SDL_fbelo.h	Wed Jan 19 19:51:04 2011 -0800
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,58 +0,0 @@
    10.4 -/*
    10.5 -    SDL - Simple DirectMedia Layer
    10.6 -    Copyright (C) 1997-2010 Sam Lantinga
    10.7 -
    10.8 -    This library is free software; you can redistribute it and/or
    10.9 -    modify it under the terms of the GNU Lesser General Public
   10.10 -    License as published by the Free Software Foundation; either
   10.11 -    version 2.1 of the License, or (at your option) any later version.
   10.12 -
   10.13 -    This library is distributed in the hope that it will be useful,
   10.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.16 -    Lesser General Public License for more details.
   10.17 -
   10.18 -    You should have received a copy of the GNU Lesser General Public
   10.19 -    License along with this library; if not, write to the Free Software
   10.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   10.21 -
   10.22 -    Sam Lantinga
   10.23 -    slouken@libsdl.org
   10.24 -*/
   10.25 -#include "SDL_config.h"
   10.26 -
   10.27 -#ifndef SDL_fbelo_h
   10.28 -#define SDL_fbelo_h
   10.29 -
   10.30 -#include "SDL_fbvideo.h"
   10.31 -
   10.32 -/* ELO */
   10.33 -#define ELO_PACKET_SIZE	10
   10.34 -#define ELO_START_BYTE		'U'
   10.35 -
   10.36 -/*	eloConvertXY
   10.37 -	Convert the raw coordinates from the ELO controller
   10.38 -	to a screen position.
   10.39 -*/
   10.40 -void eloConvertXY(_THIS, int *dx, int *dy);
   10.41 -
   10.42 -/*	eloInitController(int fd)
   10.43 -	Initialize the ELO serial touchscreen controller
   10.44 -*/
   10.45 -int eloInitController(int fd);
   10.46 -
   10.47 -/*	eloParsePacket
   10.48 -	extract position and button state from a packet
   10.49 -*/
   10.50 -int eloParsePacket(unsigned char *mousebuf, int *dx, int *dy,
   10.51 -                   int *button_state);
   10.52 -
   10.53 -/*	eloReadPosition
   10.54 -	read a packet and get the cursor position
   10.55 -*/
   10.56 -
   10.57 -int eloReadPosition(_THIS, int fd, int *x, int *y, int *button_state,
   10.58 -                    int *realx, int *realy);
   10.59 -
   10.60 -#endif /* SDL_fbelo_h */
   10.61 -/* vi: set ts=4 sw=4 expandtab: */
    11.1 --- a/src/video/fbcon/SDL_fbevents.c	Wed Jan 19 19:51:04 2011 -0800
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,1391 +0,0 @@
    11.4 -/*
    11.5 -    SDL - Simple DirectMedia Layer
    11.6 -    Copyright (C) 1997-2010 Sam Lantinga
    11.7 -
    11.8 -    This library is free software; you can redistribute it and/or
    11.9 -    modify it under the terms of the GNU Lesser General Public
   11.10 -    License as published by the Free Software Foundation; either
   11.11 -    version 2.1 of the License, or (at your option) any later version.
   11.12 -
   11.13 -    This library is distributed in the hope that it will be useful,
   11.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.16 -    Lesser General Public License for more details.
   11.17 -
   11.18 -    You should have received a copy of the GNU Lesser General Public
   11.19 -    License along with this library; if not, write to the Free Software
   11.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   11.21 -
   11.22 -    Sam Lantinga
   11.23 -    slouken@libsdl.org
   11.24 -*/
   11.25 -#include "SDL_config.h"
   11.26 -
   11.27 -/* Handle the event stream, converting console events into SDL events */
   11.28 -
   11.29 -#include <stdio.h>
   11.30 -#include <sys/types.h>
   11.31 -#include <sys/time.h>
   11.32 -#include <sys/ioctl.h>
   11.33 -#include <unistd.h>
   11.34 -#include <fcntl.h>
   11.35 -#include <errno.h>
   11.36 -#include <limits.h>
   11.37 -
   11.38 -/* For parsing /proc */
   11.39 -#include <dirent.h>
   11.40 -#include <ctype.h>
   11.41 -
   11.42 -#include <linux/vt.h>
   11.43 -#include <linux/kd.h>
   11.44 -#include <linux/keyboard.h>
   11.45 -
   11.46 -#include "SDL_timer.h"
   11.47 -#include "SDL_mutex.h"
   11.48 -#include "../SDL_sysvideo.h"
   11.49 -#include "../../events/SDL_sysevents.h"
   11.50 -#include "../../events/SDL_events_c.h"
   11.51 -#include "SDL_fbvideo.h"
   11.52 -#include "SDL_fbevents_c.h"
   11.53 -#include "SDL_fbkeys.h"
   11.54 -
   11.55 -#include "SDL_fbelo.h"
   11.56 -
   11.57 -#ifndef GPM_NODE_FIFO
   11.58 -#define GPM_NODE_FIFO	"/dev/gpmdata"
   11.59 -#endif
   11.60 -
   11.61 -/*#define DEBUG_KEYBOARD*/
   11.62 -/*#define DEBUG_MOUSE*/
   11.63 -
   11.64 -/* The translation tables from a console scancode to a SDL keysym */
   11.65 -#define NUM_VGAKEYMAPS	(1<<KG_CAPSSHIFT)
   11.66 -static Uint16 vga_keymap[NUM_VGAKEYMAPS][NR_KEYS];
   11.67 -static SDLKey keymap[128];
   11.68 -static Uint16 keymap_temp[128]; /* only used at startup */
   11.69 -static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym);
   11.70 -
   11.71 -/* Ugh, we have to duplicate the kernel's keysym mapping code...
   11.72 -   Oh, it's not so bad. :-)
   11.73 -
   11.74 -   FIXME: Add keyboard LED handling code
   11.75 - */
   11.76 -static void
   11.77 -FB_vgainitkeymaps(int fd)
   11.78 -{
   11.79 -    struct kbentry entry;
   11.80 -    int map, i;
   11.81 -
   11.82 -    /* Don't do anything if we are passed a closed keyboard */
   11.83 -    if (fd < 0) {
   11.84 -        return;
   11.85 -    }
   11.86 -
   11.87 -    /* Load all the keysym mappings */
   11.88 -    for (map = 0; map < NUM_VGAKEYMAPS; ++map) {
   11.89 -        SDL_memset(vga_keymap[map], 0, NR_KEYS * sizeof(Uint16));
   11.90 -        for (i = 0; i < NR_KEYS; ++i) {
   11.91 -            entry.kb_table = map;
   11.92 -            entry.kb_index = i;
   11.93 -            if (ioctl(fd, KDGKBENT, &entry) == 0) {
   11.94 -                /* fill keytemp. This replaces SDL_fbkeys.h */
   11.95 -                if ((map == 0) && (i < 128)) {
   11.96 -                    keymap_temp[i] = entry.kb_value;
   11.97 -                }
   11.98 -                /* The "Enter" key is a special case */
   11.99 -                if (entry.kb_value == K_ENTER) {
  11.100 -                    entry.kb_value = K(KT_ASCII, 13);
  11.101 -                }
  11.102 -                /* Handle numpad specially as well */
  11.103 -                if (KTYP(entry.kb_value) == KT_PAD) {
  11.104 -                    switch (entry.kb_value) {
  11.105 -                    case K_P0:
  11.106 -                    case K_P1:
  11.107 -                    case K_P2:
  11.108 -                    case K_P3:
  11.109 -                    case K_P4:
  11.110 -                    case K_P5:
  11.111 -                    case K_P6:
  11.112 -                    case K_P7:
  11.113 -                    case K_P8:
  11.114 -                    case K_P9:
  11.115 -                        vga_keymap[map][i] = entry.kb_value;
  11.116 -                        vga_keymap[map][i] += '0';
  11.117 -                        break;
  11.118 -                    case K_PPLUS:
  11.119 -                        vga_keymap[map][i] = K(KT_ASCII, '+');
  11.120 -                        break;
  11.121 -                    case K_PMINUS:
  11.122 -                        vga_keymap[map][i] = K(KT_ASCII, '-');
  11.123 -                        break;
  11.124 -                    case K_PSTAR:
  11.125 -                        vga_keymap[map][i] = K(KT_ASCII, '*');
  11.126 -                        break;
  11.127 -                    case K_PSLASH:
  11.128 -                        vga_keymap[map][i] = K(KT_ASCII, '/');
  11.129 -                        break;
  11.130 -                    case K_PENTER:
  11.131 -                        vga_keymap[map][i] = K(KT_ASCII, '\r');
  11.132 -                        break;
  11.133 -                    case K_PCOMMA:
  11.134 -                        vga_keymap[map][i] = K(KT_ASCII, ',');
  11.135 -                        break;
  11.136 -                    case K_PDOT:
  11.137 -                        vga_keymap[map][i] = K(KT_ASCII, '.');
  11.138 -                        break;
  11.139 -                    default:
  11.140 -                        break;
  11.141 -                    }
  11.142 -                }
  11.143 -                /* Do the normal key translation */
  11.144 -                if ((KTYP(entry.kb_value) == KT_LATIN) ||
  11.145 -                    (KTYP(entry.kb_value) == KT_ASCII) ||
  11.146 -                    (KTYP(entry.kb_value) == KT_LETTER)) {
  11.147 -                    vga_keymap[map][i] = entry.kb_value;
  11.148 -                }
  11.149 -            }
  11.150 -        }
  11.151 -    }
  11.152 -}
  11.153 -
  11.154 -int
  11.155 -FB_InGraphicsMode(_THIS)
  11.156 -{
  11.157 -    return ((keyboard_fd >= 0) && (saved_kbd_mode >= 0));
  11.158 -}
  11.159 -
  11.160 -int
  11.161 -FB_EnterGraphicsMode(_THIS)
  11.162 -{
  11.163 -    struct termios keyboard_termios;
  11.164 -
  11.165 -    /* Set medium-raw keyboard mode */
  11.166 -    if ((keyboard_fd >= 0) && !FB_InGraphicsMode(this)) {
  11.167 -
  11.168 -        /* Switch to the correct virtual terminal */
  11.169 -        if (current_vt > 0) {
  11.170 -            struct vt_stat vtstate;
  11.171 -
  11.172 -            if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) {
  11.173 -                saved_vt = vtstate.v_active;
  11.174 -            }
  11.175 -            if (ioctl(keyboard_fd, VT_ACTIVATE, current_vt) == 0) {
  11.176 -                ioctl(keyboard_fd, VT_WAITACTIVE, current_vt);
  11.177 -            }
  11.178 -        }
  11.179 -
  11.180 -        /* Set the terminal input mode */
  11.181 -        if (tcgetattr(keyboard_fd, &saved_kbd_termios) < 0) {
  11.182 -            SDL_SetError("Unable to get terminal attributes");
  11.183 -            if (keyboard_fd > 0) {
  11.184 -                close(keyboard_fd);
  11.185 -            }
  11.186 -            keyboard_fd = -1;
  11.187 -            return (-1);
  11.188 -        }
  11.189 -        if (ioctl(keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0) {
  11.190 -            SDL_SetError("Unable to get current keyboard mode");
  11.191 -            if (keyboard_fd > 0) {
  11.192 -                close(keyboard_fd);
  11.193 -            }
  11.194 -            keyboard_fd = -1;
  11.195 -            return (-1);
  11.196 -        }
  11.197 -        keyboard_termios = saved_kbd_termios;
  11.198 -        keyboard_termios.c_lflag &= ~(ICANON | ECHO | ISIG);
  11.199 -        keyboard_termios.c_iflag &=
  11.200 -            ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
  11.201 -        keyboard_termios.c_cc[VMIN] = 0;
  11.202 -        keyboard_termios.c_cc[VTIME] = 0;
  11.203 -        if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) {
  11.204 -            FB_CloseKeyboard(this);
  11.205 -            SDL_SetError("Unable to set terminal attributes");
  11.206 -            return (-1);
  11.207 -        }
  11.208 -        /* This will fail if we aren't root or this isn't our tty */
  11.209 -        if (ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0) {
  11.210 -            FB_CloseKeyboard(this);
  11.211 -            SDL_SetError("Unable to set keyboard in raw mode");
  11.212 -            return (-1);
  11.213 -        }
  11.214 -        if (ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0) {
  11.215 -            FB_CloseKeyboard(this);
  11.216 -            SDL_SetError("Unable to set keyboard in graphics mode");
  11.217 -            return (-1);
  11.218 -        }
  11.219 -        /* Prevent switching the virtual terminal */
  11.220 -        ioctl(keyboard_fd, VT_LOCKSWITCH, 1);
  11.221 -    }
  11.222 -    return (keyboard_fd);
  11.223 -}
  11.224 -
  11.225 -void
  11.226 -FB_LeaveGraphicsMode(_THIS)
  11.227 -{
  11.228 -    if (FB_InGraphicsMode(this)) {
  11.229 -        ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
  11.230 -        ioctl(keyboard_fd, KDSKBMODE, saved_kbd_mode);
  11.231 -        tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios);
  11.232 -        saved_kbd_mode = -1;
  11.233 -
  11.234 -        /* Head back over to the original virtual terminal */
  11.235 -        ioctl(keyboard_fd, VT_UNLOCKSWITCH, 1);
  11.236 -        if (saved_vt > 0) {
  11.237 -            ioctl(keyboard_fd, VT_ACTIVATE, saved_vt);
  11.238 -        }
  11.239 -    }
  11.240 -}
  11.241 -
  11.242 -void
  11.243 -FB_CloseKeyboard(_THIS)
  11.244 -{
  11.245 -    if (keyboard_fd >= 0) {
  11.246 -        FB_LeaveGraphicsMode(this);
  11.247 -        if (keyboard_fd > 0) {
  11.248 -            close(keyboard_fd);
  11.249 -        }
  11.250 -    }
  11.251 -    keyboard_fd = -1;
  11.252 -}
  11.253 -
  11.254 -int
  11.255 -FB_OpenKeyboard(_THIS)
  11.256 -{
  11.257 -    /* Open only if not already opened */
  11.258 -    if (keyboard_fd < 0) {
  11.259 -        static const char *const tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
  11.260 -        static const char *const vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
  11.261 -        int i, tty0_fd;
  11.262 -
  11.263 -        /* Try to query for a free virtual terminal */
  11.264 -        tty0_fd = -1;
  11.265 -        for (i = 0; tty0[i] && (tty0_fd < 0); ++i) {
  11.266 -            tty0_fd = open(tty0[i], O_WRONLY, 0);
  11.267 -        }
  11.268 -        if (tty0_fd < 0) {
  11.269 -            tty0_fd = dup(0);   /* Maybe stdin is a VT? */
  11.270 -        }
  11.271 -        ioctl(tty0_fd, VT_OPENQRY, &current_vt);
  11.272 -        close(tty0_fd);
  11.273 -        if ((geteuid() == 0) && (current_vt > 0)) {
  11.274 -            for (i = 0; vcs[i] && (keyboard_fd < 0); ++i) {
  11.275 -                char vtpath[12];
  11.276 -
  11.277 -                SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i],
  11.278 -                             current_vt);
  11.279 -                keyboard_fd = open(vtpath, O_RDWR, 0);
  11.280 -#ifdef DEBUG_KEYBOARD
  11.281 -                fprintf(stderr, "vtpath = %s, fd = %d\n",
  11.282 -                        vtpath, keyboard_fd);
  11.283 -#endif /* DEBUG_KEYBOARD */
  11.284 -
  11.285 -                /* This needs to be our controlling tty
  11.286 -                   so that the kernel ioctl() calls work
  11.287 -                 */
  11.288 -                if (keyboard_fd >= 0) {
  11.289 -                    tty0_fd = open("/dev/tty", O_RDWR, 0);
  11.290 -                    if (tty0_fd >= 0) {
  11.291 -                        ioctl(tty0_fd, TIOCNOTTY, 0);
  11.292 -                        close(tty0_fd);
  11.293 -                    }
  11.294 -                }
  11.295 -            }
  11.296 -        }
  11.297 -        if (keyboard_fd < 0) {
  11.298 -            /* Last resort, maybe our tty is a usable VT */
  11.299 -            struct vt_stat vtstate;
  11.300 -
  11.301 -            keyboard_fd = open("/dev/tty", O_RDWR);
  11.302 -
  11.303 -            if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) {
  11.304 -                current_vt = vtstate.v_active;
  11.305 -            } else {
  11.306 -                current_vt = 0;
  11.307 -            }
  11.308 -        }
  11.309 -#ifdef DEBUG_KEYBOARD
  11.310 -        fprintf(stderr, "Current VT: %d\n", current_vt);
  11.311 -#endif
  11.312 -        saved_kbd_mode = -1;
  11.313 -
  11.314 -        /* Make sure that our input is a console terminal */
  11.315 -        {
  11.316 -            int dummy;
  11.317 -            if (ioctl(keyboard_fd, KDGKBMODE, &dummy) < 0) {
  11.318 -                close(keyboard_fd);
  11.319 -                keyboard_fd = -1;
  11.320 -                SDL_SetError("Unable to open a console terminal");
  11.321 -            }
  11.322 -        }
  11.323 -
  11.324 -        /* Set up keymap */
  11.325 -        FB_vgainitkeymaps(keyboard_fd);
  11.326 -    }
  11.327 -    return (keyboard_fd);
  11.328 -}
  11.329 -
  11.330 -static enum
  11.331 -{
  11.332 -    MOUSE_NONE = -1,
  11.333 -    MOUSE_MSC,                  /* Note: GPM uses the MSC protocol */
  11.334 -    MOUSE_PS2,
  11.335 -    MOUSE_IMPS2,
  11.336 -    MOUSE_MS,
  11.337 -    MOUSE_BM,
  11.338 -    MOUSE_ELO,
  11.339 -    MOUSE_TSLIB,
  11.340 -    NUM_MOUSE_DRVS
  11.341 -} mouse_drv = MOUSE_NONE;
  11.342 -
  11.343 -void
  11.344 -FB_CloseMouse(_THIS)
  11.345 -{
  11.346 -#if SDL_INPUT_TSLIB
  11.347 -    if (ts_dev != NULL) {
  11.348 -        ts_close(ts_dev);
  11.349 -        ts_dev = NULL;
  11.350 -        mouse_fd = -1;
  11.351 -    }
  11.352 -#endif /* SDL_INPUT_TSLIB */
  11.353 -    if (mouse_fd > 0) {
  11.354 -        close(mouse_fd);
  11.355 -    }
  11.356 -    mouse_fd = -1;
  11.357 -}
  11.358 -
  11.359 -/* Returns processes listed in /proc with the desired name */
  11.360 -static int
  11.361 -find_pid(DIR * proc, const char *wanted_name)
  11.362 -{
  11.363 -    struct dirent *entry;
  11.364 -    int pid;
  11.365 -
  11.366 -    /* First scan proc for the gpm process */
  11.367 -    pid = 0;
  11.368 -    while ((pid == 0) && ((entry = readdir(proc)) != NULL)) {
  11.369 -        if (isdigit(entry->d_name[0])) {
  11.370 -            FILE *status;
  11.371 -            char path[PATH_MAX];
  11.372 -            char name[PATH_MAX];
  11.373 -
  11.374 -            SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status",
  11.375 -                         entry->d_name);
  11.376 -            status = fopen(path, "r");
  11.377 -            if (status) {
  11.378 -                name[0] = '\0';
  11.379 -                fscanf(status, "Name: %s", name);
  11.380 -                if (SDL_strcmp(name, wanted_name) == 0) {
  11.381 -                    pid = SDL_atoi(entry->d_name);
  11.382 -                }
  11.383 -                fclose(status);
  11.384 -            }
  11.385 -        }
  11.386 -    }
  11.387 -    return pid;
  11.388 -}
  11.389 -
  11.390 -/* Returns true if /dev/gpmdata is being written to by gpm */
  11.391 -static int
  11.392 -gpm_available(char *proto, size_t protolen)
  11.393 -{
  11.394 -    int available;
  11.395 -    DIR *proc;
  11.396 -    int pid;
  11.397 -    int cmdline, len, arglen;
  11.398 -    char path[PATH_MAX];
  11.399 -    char args[PATH_MAX], *arg;
  11.400 -
  11.401 -    /* Don't bother looking if the fifo isn't there */
  11.402 -#ifdef DEBUG_MOUSE
  11.403 -    fprintf(stderr, "testing gpm\n");
  11.404 -#endif
  11.405 -    if (access(GPM_NODE_FIFO, F_OK) < 0) {
  11.406 -        return (0);
  11.407 -    }
  11.408 -
  11.409 -    available = 0;
  11.410 -    proc = opendir("/proc");
  11.411 -    if (proc) {
  11.412 -        char raw_proto[10] = { '\0' };
  11.413 -        char repeat_proto[10] = { '\0' };
  11.414 -        while (!available && (pid = find_pid(proc, "gpm")) > 0) {
  11.415 -            SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid);
  11.416 -            cmdline = open(path, O_RDONLY, 0);
  11.417 -            if (cmdline >= 0) {
  11.418 -                len = read(cmdline, args, sizeof(args));
  11.419 -                arg = args;
  11.420 -                while (len > 0) {
  11.421 -                    arglen = SDL_strlen(arg) + 1;
  11.422 -#ifdef DEBUG_MOUSE
  11.423 -                    fprintf(stderr, "gpm arg %s len %d\n", arg, arglen);
  11.424 -#endif
  11.425 -                    if (SDL_strcmp(arg, "-t") == 0) {
  11.426 -                        /* protocol string, keep it for later */
  11.427 -                        char *t, *s;
  11.428 -                        t = arg + arglen;
  11.429 -                        s = SDL_strchr(t, ' ');
  11.430 -                        if (s)
  11.431 -                            *s = 0;
  11.432 -                        SDL_strlcpy(raw_proto, t, SDL_arraysize(raw_proto));
  11.433 -                        if (s)
  11.434 -                            *s = ' ';
  11.435 -                    }
  11.436 -                    if (SDL_strncmp(arg, "-R", 2) == 0) {
  11.437 -                        char *t, *s;
  11.438 -                        available = 1;
  11.439 -                        t = arg + 2;
  11.440 -                        s = SDL_strchr(t, ' ');
  11.441 -                        if (s)
  11.442 -                            *s = 0;
  11.443 -                        SDL_strlcpy(repeat_proto, t,
  11.444 -                                    SDL_arraysize(repeat_proto));
  11.445 -                        if (s)
  11.446 -                            *s = ' ';
  11.447 -                    }
  11.448 -                    len -= arglen;
  11.449 -                    arg += arglen;
  11.450 -                }
  11.451 -                close(cmdline);
  11.452 -            }
  11.453 -        }
  11.454 -        closedir(proc);
  11.455 -
  11.456 -        if (available) {
  11.457 -            if (SDL_strcmp(repeat_proto, "raw") == 0) {
  11.458 -                SDL_strlcpy(proto, raw_proto, protolen);
  11.459 -            } else if (*repeat_proto) {
  11.460 -                SDL_strlcpy(proto, repeat_proto, protolen);
  11.461 -            } else {
  11.462 -                SDL_strlcpy(proto, "msc", protolen);
  11.463 -            }
  11.464 -        }
  11.465 -    }
  11.466 -    return available;
  11.467 -}
  11.468 -
  11.469 -
  11.470 -/* rcg06112001 Set up IMPS/2 mode, if possible. This gives
  11.471 - *  us access to the mousewheel, etc. Returns zero if
  11.472 - *  writes to device failed, but you still need to query the
  11.473 - *  device to see which mode it's actually in.
  11.474 - */
  11.475 -static int
  11.476 -set_imps2_mode(int fd)
  11.477 -{
  11.478 -    /* If you wanted to control the mouse mode (and we do :)  ) ...
  11.479 -       Set IMPS/2 protocol:
  11.480 -       {0xf3,200,0xf3,100,0xf3,80}
  11.481 -       Reset mouse device:
  11.482 -       {0xFF}
  11.483 -     */
  11.484 -    Uint8 set_imps2[] = { 0xf3, 200, 0xf3, 100, 0xf3, 80 };
  11.485 -    /*Uint8 reset = 0xff; */
  11.486 -    fd_set fdset;
  11.487 -    struct timeval tv;
  11.488 -    int retval = 0;
  11.489 -
  11.490 -    if (write(fd, &set_imps2, sizeof(set_imps2)) == sizeof(set_imps2)) {
  11.491 -        /* Don't reset it, that'll clear IMPS/2 mode on some mice
  11.492 -           if (write(fd, &reset, sizeof (reset)) == sizeof (reset) ) {
  11.493 -           retval = 1;
  11.494 -           }
  11.495 -         */
  11.496 -    }
  11.497 -
  11.498 -    /* Get rid of any chatter from the above */
  11.499 -    FD_ZERO(&fdset);
  11.500 -    FD_SET(fd, &fdset);
  11.501 -    tv.tv_sec = 0;
  11.502 -    tv.tv_usec = 0;
  11.503 -    while (select(fd + 1, &fdset, 0, 0, &tv) > 0) {
  11.504 -        char temp[32];
  11.505 -        read(fd, temp, sizeof(temp));
  11.506 -    }
  11.507 -
  11.508 -    return retval;
  11.509 -}
  11.510 -
  11.511 -
  11.512 -/* Returns true if the mouse uses the IMPS/2 protocol */
  11.513 -static int
  11.514 -detect_imps2(int fd)
  11.515 -{
  11.516 -    int imps2;
  11.517 -
  11.518 -    imps2 = 0;
  11.519 -
  11.520 -    if (SDL_getenv("SDL_MOUSEDEV_IMPS2")) {
  11.521 -        imps2 = 1;
  11.522 -    }
  11.523 -    if (!imps2) {
  11.524 -        Uint8 query_ps2 = 0xF2;
  11.525 -        fd_set fdset;
  11.526 -        struct timeval tv;
  11.527 -
  11.528 -        /* Get rid of any mouse motion noise */
  11.529 -        FD_ZERO(&fdset);
  11.530 -        FD_SET(fd, &fdset);
  11.531 -        tv.tv_sec = 0;
  11.532 -        tv.tv_usec = 0;
  11.533 -        while (select(fd + 1, &fdset, 0, 0, &tv) > 0) {
  11.534 -            char temp[32];
  11.535 -            read(fd, temp, sizeof(temp));
  11.536 -        }
  11.537 -
  11.538 -        /* Query for the type of mouse protocol */
  11.539 -        if (write(fd, &query_ps2, sizeof(query_ps2)) == sizeof(query_ps2)) {
  11.540 -            Uint8 ch = 0;
  11.541 -
  11.542 -            /* Get the mouse protocol response */
  11.543 -            do {
  11.544 -                FD_ZERO(&fdset);
  11.545 -                FD_SET(fd, &fdset);
  11.546 -                tv.tv_sec = 1;
  11.547 -                tv.tv_usec = 0;
  11.548 -                if (select(fd + 1, &fdset, 0, 0, &tv) < 1) {
  11.549 -                    break;
  11.550 -                }
  11.551 -            } while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) &&
  11.552 -                     ((ch == 0xFA) || (ch == 0xAA)));
  11.553 -
  11.554 -            /* Experimental values (Logitech wheelmouse) */
  11.555 -#ifdef DEBUG_MOUSE
  11.556 -            fprintf(stderr, "Last mouse mode: 0x%x\n", ch);
  11.557 -#endif
  11.558 -            if ((ch == 3) || (ch == 4)) {
  11.559 -                imps2 = 1;
  11.560 -            }
  11.561 -        }
  11.562 -    }
  11.563 -    return imps2;
  11.564 -}
  11.565 -
  11.566 -int
  11.567 -FB_OpenMouse(_THIS)
  11.568 -{
  11.569 -    int i;
  11.570 -    const char *mousedev;
  11.571 -    const char *mousedrv;
  11.572 -
  11.573 -    mousedrv = SDL_getenv("SDL_MOUSEDRV");
  11.574 -    mousedev = SDL_getenv("SDL_MOUSEDEV");
  11.575 -    mouse_fd = -1;
  11.576 -
  11.577 -#if SDL_INPUT_TSLIB
  11.578 -    if (mousedrv && (SDL_strcmp(mousedrv, "TSLIB") == 0)) {
  11.579 -        if (mousedev == NULL)
  11.580 -            mousedev = SDL_getenv("TSLIB_TSDEVICE");
  11.581 -        if (mousedev != NULL) {
  11.582 -            ts_dev = ts_open(mousedev, 1);
  11.583 -            if ((ts_dev != NULL) && (ts_config(ts_dev) >= 0)) {
  11.584 -#ifdef DEBUG_MOUSE
  11.585 -                fprintf(stderr, "Using tslib touchscreen\n");
  11.586 -#endif
  11.587 -                mouse_drv = MOUSE_TSLIB;
  11.588 -                mouse_fd = ts_fd(ts_dev);
  11.589 -                return mouse_fd;
  11.590 -            }
  11.591 -        }
  11.592 -        mouse_drv = MOUSE_NONE;
  11.593 -        return mouse_fd;
  11.594 -    }
  11.595 -#endif /* SDL_INPUT_TSLIB */
  11.596 -
  11.597 -    /* ELO TOUCHSCREEN SUPPORT */
  11.598 -
  11.599 -    if (mousedrv && (SDL_strcmp(mousedrv, "ELO") == 0)) {
  11.600 -        mouse_fd = open(mousedev, O_RDWR);
  11.601 -        if (mouse_fd >= 0) {
  11.602 -            if (eloInitController(mouse_fd)) {
  11.603 -#ifdef DEBUG_MOUSE
  11.604 -                fprintf(stderr, "Using ELO touchscreen\n");
  11.605 -#endif
  11.606 -                mouse_drv = MOUSE_ELO;
  11.607 -            }
  11.608 -
  11.609 -        } else if (mouse_fd < 0) {
  11.610 -            mouse_drv = MOUSE_NONE;
  11.611 -        }
  11.612 -
  11.613 -        return (mouse_fd);
  11.614 -    }
  11.615 -
  11.616 -    /* STD MICE */
  11.617 -
  11.618 -    if (mousedev == NULL) {
  11.619 -        /* FIXME someday... allow multiple mice in this driver */
  11.620 -        static const char *ps2mice[] = {
  11.621 -            "/dev/input/mice", "/dev/usbmouse", "/dev/psaux", NULL
  11.622 -        };
  11.623 -        /* First try to use GPM in repeater mode */
  11.624 -        if (mouse_fd < 0) {
  11.625 -            char proto[10];
  11.626 -            if (gpm_available(proto, SDL_arraysize(proto))) {
  11.627 -                mouse_fd = open(GPM_NODE_FIFO, O_RDONLY, 0);
  11.628 -                if (mouse_fd >= 0) {
  11.629 -                    if (SDL_strcmp(proto, "msc") == 0) {
  11.630 -                        mouse_drv = MOUSE_MSC;
  11.631 -                    } else if (SDL_strcmp(proto, "ps2") == 0) {
  11.632 -                        mouse_drv = MOUSE_PS2;
  11.633 -                    } else if (SDL_strcmp(proto, "imps2") == 0) {
  11.634 -                        mouse_drv = MOUSE_IMPS2;
  11.635 -                    } else if (SDL_strcmp(proto, "ms") == 0 ||
  11.636 -                               SDL_strcmp(proto, "bare") == 0) {
  11.637 -                        mouse_drv = MOUSE_MS;
  11.638 -                    } else if (SDL_strcmp(proto, "bm") == 0) {
  11.639 -                        mouse_drv = MOUSE_BM;
  11.640 -                    } else {
  11.641 -                        /* Unknown protocol... */
  11.642 -#ifdef DEBUG_MOUSE
  11.643 -                        fprintf(stderr,
  11.644 -                                "GPM mouse using unknown protocol = %s\n",
  11.645 -                                proto);
  11.646 -#endif
  11.647 -                        close(mouse_fd);
  11.648 -                        mouse_fd = -1;
  11.649 -                    }
  11.650 -                }
  11.651 -#ifdef DEBUG_MOUSE
  11.652 -                if (mouse_fd >= 0) {
  11.653 -                    fprintf(stderr,
  11.654 -                            "Using GPM mouse, protocol = %s\n", proto);
  11.655 -                }
  11.656 -#endif /* DEBUG_MOUSE */
  11.657 -            }
  11.658 -        }
  11.659 -        /* Now try to use a modern PS/2 mouse */
  11.660 -        for (i = 0; (mouse_fd < 0) && ps2mice[i]; ++i) {
  11.661 -            mouse_fd = open(ps2mice[i], O_RDWR, 0);
  11.662 -            if (mouse_fd < 0) {
  11.663 -                mouse_fd = open(ps2mice[i], O_RDONLY, 0);
  11.664 -            }
  11.665 -            if (mouse_fd >= 0) {
  11.666 -                /* rcg06112001 Attempt to set IMPS/2 mode */
  11.667 -                set_imps2_mode(mouse_fd);
  11.668 -                if (detect_imps2(mouse_fd)) {
  11.669 -#ifdef DEBUG_MOUSE
  11.670 -                    fprintf(stderr, "Using IMPS2 mouse\n");
  11.671 -#endif
  11.672 -                    mouse_drv = MOUSE_IMPS2;
  11.673 -                } else {
  11.674 -#ifdef DEBUG_MOUSE
  11.675 -                    fprintf(stderr, "Using PS2 mouse\n");
  11.676 -#endif
  11.677 -                    mouse_drv = MOUSE_PS2;
  11.678 -                }
  11.679 -            }
  11.680 -        }
  11.681 -        /* Next try to use a PPC ADB port mouse */
  11.682 -        if (mouse_fd < 0) {
  11.683 -            mouse_fd = open("/dev/adbmouse", O_RDONLY, 0);
  11.684 -            if (mouse_fd >= 0) {
  11.685 -#ifdef DEBUG_MOUSE
  11.686 -                fprintf(stderr, "Using ADB mouse\n");
  11.687 -#endif
  11.688 -                mouse_drv = MOUSE_BM;
  11.689 -            }
  11.690 -        }
  11.691 -    }
  11.692 -    /* Default to a serial Microsoft mouse */
  11.693 -    if (mouse_fd < 0) {
  11.694 -        if (mousedev == NULL) {
  11.695 -            mousedev = "/dev/mouse";
  11.696 -        }
  11.697 -        mouse_fd = open(mousedev, O_RDONLY, 0);
  11.698 -        if (mouse_fd >= 0) {
  11.699 -            struct termios mouse_termios;
  11.700 -
  11.701 -            /* Set the sampling speed to 1200 baud */
  11.702 -            tcgetattr(mouse_fd, &mouse_termios);
  11.703 -            mouse_termios.c_iflag = IGNBRK | IGNPAR;
  11.704 -            mouse_termios.c_oflag = 0;
  11.705 -            mouse_termios.c_lflag = 0;
  11.706 -            mouse_termios.c_line = 0;
  11.707 -            mouse_termios.c_cc[VTIME] = 0;
  11.708 -            mouse_termios.c_cc[VMIN] = 1;
  11.709 -            mouse_termios.c_cflag = CREAD | CLOCAL | HUPCL;
  11.710 -            mouse_termios.c_cflag |= CS8;
  11.711 -            mouse_termios.c_cflag |= B1200;
  11.712 -            tcsetattr(mouse_fd, TCSAFLUSH, &mouse_termios);
  11.713 -            if (mousedrv && (SDL_strcmp(mousedrv, "PS2") == 0)) {
  11.714 -#ifdef DEBUG_MOUSE
  11.715 -                fprintf(stderr,
  11.716 -                        "Using (user specified) PS2 mouse on %s\n", mousedev);
  11.717 -#endif
  11.718 -                mouse_drv = MOUSE_PS2;
  11.719 -            } else {
  11.720 -#ifdef DEBUG_MOUSE
  11.721 -                fprintf(stderr, "Using (default) MS mouse on %s\n", mousedev);
  11.722 -#endif
  11.723 -                mouse_drv = MOUSE_MS;
  11.724 -            }
  11.725 -        }
  11.726 -    }
  11.727 -    if (mouse_fd < 0) {
  11.728 -        mouse_drv = MOUSE_NONE;
  11.729 -    }
  11.730 -    return (mouse_fd);
  11.731 -}
  11.732 -
  11.733 -static int posted = 0;
  11.734 -
  11.735 -void
  11.736 -FB_vgamousecallback(int button, int relative, int dx, int dy)
  11.737 -{
  11.738 -    int button_1, button_3;
  11.739 -    int button_state;
  11.740 -    int state_changed;
  11.741 -    int i;
  11.742 -    Uint8 state;
  11.743 -
  11.744 -    if (dx || dy) {
  11.745 -        posted += SDL_PrivateMouseMotion(0, relative, dx, dy);
  11.746 -    }
  11.747 -
  11.748 -    /* Swap button 1 and 3 */
  11.749 -    button_1 = (button & 0x04) >> 2;
  11.750 -    button_3 = (button & 0x01) << 2;
  11.751 -    button &= ~0x05;
  11.752 -    button |= (button_1 | button_3);
  11.753 -
  11.754 -    /* See what changed */
  11.755 -    button_state = SDL_GetMouseState(NULL, NULL);
  11.756 -    state_changed = button_state ^ button;
  11.757 -    for (i = 0; i < 8; ++i) {
  11.758 -        if (state_changed & (1 << i)) {
  11.759 -            if (button & (1 << i)) {
  11.760 -                state = SDL_PRESSED;
  11.761 -            } else {
  11.762 -                state = SDL_RELEASED;
  11.763 -            }
  11.764 -            posted += SDL_PrivateMouseButton(state, i + 1, 0, 0);
  11.765 -        }
  11.766 -    }
  11.767 -}
  11.768 -
  11.769 -/* Handle input from tslib */
  11.770 -#if SDL_INPUT_TSLIB
  11.771 -static void
  11.772 -handle_tslib(_THIS)
  11.773 -{
  11.774 -    struct ts_sample sample;
  11.775 -    int button;
  11.776 -
  11.777 -    while (ts_read(ts_dev, &sample, 1) > 0) {
  11.778 -        button = (sample.pressure > 0) ? 1 : 0;
  11.779 -        button <<= 2;           /* must report it as button 3 */
  11.780 -        FB_vgamousecallback(button, 0, sample.x, sample.y);
  11.781 -    }
  11.782 -    return;
  11.783 -}
  11.784 -#endif /* SDL_INPUT_TSLIB */
  11.785 -
  11.786 -/* For now, use MSC, PS/2, and MS protocols
  11.787 -   Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
  11.788 - */
  11.789 -static void
  11.790 -handle_mouse(_THIS)
  11.791 -{
  11.792 -    static int start = 0;
  11.793 -    static unsigned char mousebuf[BUFSIZ];
  11.794 -    static int relative = 1;
  11.795 -
  11.796 -    int i, nread;
  11.797 -    int button = 0;
  11.798 -    int dx = 0, dy = 0;
  11.799 -    int packetsize = 0;
  11.800 -    int realx, realy;
  11.801 -
  11.802 -    /* Figure out the mouse packet size */
  11.803 -    switch (mouse_drv) {
  11.804 -    case MOUSE_NONE:
  11.805 -        /* Ack! */
  11.806 -        read(mouse_fd, mousebuf, BUFSIZ);
  11.807 -        return;
  11.808 -    case MOUSE_MSC:
  11.809 -        packetsize = 5;
  11.810 -        break;
  11.811 -    case MOUSE_IMPS2:
  11.812 -        packetsize = 4;
  11.813 -        break;
  11.814 -    case MOUSE_PS2:
  11.815 -    case MOUSE_MS:
  11.816 -    case MOUSE_BM:
  11.817 -        packetsize = 3;
  11.818 -        break;
  11.819 -    case MOUSE_ELO:
  11.820 -        /* try to read the next packet */
  11.821 -        if (eloReadPosition
  11.822 -            (this, mouse_fd, &dx, &dy, &button, &realx, &realy)) {
  11.823 -            button = (button & 0x01) << 2;
  11.824 -            FB_vgamousecallback(button, 0, dx, dy);
  11.825 -        }
  11.826 -        return;                 /* nothing left to do */
  11.827 -    case MOUSE_TSLIB:
  11.828 -#if SDL_INPUT_TSLIB
  11.829 -        handle_tslib(this);
  11.830 -#endif
  11.831 -        return;                 /* nothing left to do */
  11.832 -    default:
  11.833 -        /* Uh oh.. */
  11.834 -        packetsize = 0;
  11.835 -        break;
  11.836 -    }
  11.837 -
  11.838 -    /* Special handling for the quite sensitive ELO controller */
  11.839 -    if (mouse_drv == MOUSE_ELO) {
  11.840 -
  11.841 -    }
  11.842 -
  11.843 -    /* Read as many packets as possible */
  11.844 -    nread = read(mouse_fd, &mousebuf[start], BUFSIZ - start);
  11.845 -    if (nread < 0) {
  11.846 -        return;
  11.847 -    }
  11.848 -    nread += start;
  11.849 -#ifdef DEBUG_MOUSE
  11.850 -    fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start);
  11.851 -#endif
  11.852 -    for (i = 0; i < (nread - (packetsize - 1)); i += packetsize) {
  11.853 -        switch (mouse_drv) {
  11.854 -        case MOUSE_NONE:
  11.855 -            break;
  11.856 -        case MOUSE_MSC:
  11.857 -            /* MSC protocol has 0x80 in high byte */
  11.858 -            if ((mousebuf[i] & 0xF8) != 0x80) {
  11.859 -                /* Go to next byte */
  11.860 -                i -= (packetsize - 1);
  11.861 -                continue;
  11.862 -            }
  11.863 -            /* Get current mouse state */
  11.864 -            button = (~mousebuf[i]) & 0x07;
  11.865 -            dx = (signed char) (mousebuf[i + 1]) +
  11.866 -                (signed char) (mousebuf[i + 3]);
  11.867 -            dy = -((signed char) (mousebuf[i + 2]) +
  11.868 -                   (signed char) (mousebuf[i + 4]));
  11.869 -            break;
  11.870 -        case MOUSE_PS2:
  11.871 -            /* PS/2 protocol has nothing in high byte */
  11.872 -            if ((mousebuf[i] & 0xC0) != 0) {
  11.873 -                /* Go to next byte */
  11.874 -                i -= (packetsize - 1);
  11.875 -                continue;
  11.876 -            }
  11.877 -            /* Get current mouse state */
  11.878 -            button = (mousebuf[i] & 0x04) >> 1 |        /*Middle */
  11.879 -                (mousebuf[i] & 0x02) >> 1 |     /*Right */
  11.880 -                (mousebuf[i] & 0x01) << 2;      /*Left */
  11.881 -            dx = (mousebuf[i] & 0x10) ?
  11.882 -                mousebuf[i + 1] - 256 : mousebuf[i + 1];
  11.883 -            dy = (mousebuf[i] & 0x20) ?
  11.884 -                -(mousebuf[i + 2] - 256) : -mousebuf[i + 2];
  11.885 -            break;
  11.886 -        case MOUSE_IMPS2:
  11.887 -            /* Get current mouse state */
  11.888 -            button = (mousebuf[i] & 0x04) >> 1 |        /*Middle */
  11.889 -                (mousebuf[i] & 0x02) >> 1 |     /*Right */
  11.890 -                (mousebuf[i] & 0x01) << 2 |     /*Left */
  11.891 -                (mousebuf[i] & 0x40) >> 3 |     /* 4 */
  11.892 -                (mousebuf[i] & 0x80) >> 3;      /* 5 */
  11.893 -            dx = (mousebuf[i] & 0x10) ?
  11.894 -                mousebuf[i + 1] - 256 : mousebuf[i + 1];
  11.895 -            dy = (mousebuf[i] & 0x20) ?
  11.896 -                -(mousebuf[i + 2] - 256) : -mousebuf[i + 2];
  11.897 -            switch (mousebuf[i + 3] & 0x0F) {
  11.898 -            case 0x0E:         /* DX = +1 */
  11.899 -            case 0x02:         /* DX = -1 */
  11.900 -                break;
  11.901 -            case 0x0F:         /* DY = +1 (map button 4) */
  11.902 -                FB_vgamousecallback(button | (1 << 3), 1, 0, 0);
  11.903 -                break;
  11.904 -            case 0x01:         /* DY = -1 (map button 5) */
  11.905 -                FB_vgamousecallback(button | (1 << 4), 1, 0, 0);
  11.906 -                break;
  11.907 -            }
  11.908 -            break;
  11.909 -        case MOUSE_MS:
  11.910 -            /* Microsoft protocol has 0x40 in high byte */
  11.911 -            if ((mousebuf[i] & 0x40) != 0x40) {
  11.912 -                /* Go to next byte */
  11.913 -                i -= (packetsize - 1);
  11.914 -                continue;
  11.915 -            }
  11.916 -            /* Get current mouse state */
  11.917 -            button = ((mousebuf[i] & 0x20) >> 3) |
  11.918 -                ((mousebuf[i] & 0x10) >> 4);
  11.919 -            dx = (signed char) (((mousebuf[i] & 0x03) << 6) |
  11.920 -                                (mousebuf[i + 1] & 0x3F));
  11.921 -            dy = (signed char) (((mousebuf[i] & 0x0C) << 4) |
  11.922 -                                (mousebuf[i + 2] & 0x3F));
  11.923 -            break;
  11.924 -        case MOUSE_BM:
  11.925 -            /* BusMouse protocol has 0xF8 in high byte */
  11.926 -            if ((mousebuf[i] & 0xF8) != 0x80) {
  11.927 -                /* Go to next byte */
  11.928 -                i -= (packetsize - 1);
  11.929 -                continue;
  11.930 -            }
  11.931 -            /* Get current mouse state */
  11.932 -            button = (~mousebuf[i]) & 0x07;
  11.933 -            dx = (signed char) mousebuf[i + 1];
  11.934 -            dy = -(signed char) mousebuf[i + 2];
  11.935 -            break;
  11.936 -        default:
  11.937 -            /* Uh oh.. */
  11.938 -            dx = 0;
  11.939 -            dy = 0;
  11.940 -            break;
  11.941 -        }
  11.942 -        FB_vgamousecallback(button, relative, dx, dy);
  11.943 -    }
  11.944 -    if (i < nread) {
  11.945 -        SDL_memcpy(mousebuf, &mousebuf[i], (nread - i));
  11.946 -        start = (nread - i);
  11.947 -    } else {
  11.948 -        start = 0;
  11.949 -    }
  11.950 -    return;
  11.951 -}
  11.952 -
  11.953 -/* Handle switching to another VC, returns when our VC is back */
  11.954 -static void
  11.955 -switch_vt_prep(_THIS)
  11.956 -{
  11.957 -    SDL_Surface *screen = SDL_VideoSurface;
  11.958 -
  11.959 -    SDL_PrivateAppActive(0,
  11.960 -                         (SDL_APPACTIVE | SDL_APPINPUTFOCUS |
  11.961 -                          SDL_APPMOUSEFOCUS));
  11.962 -
  11.963 -    /* Save the contents of the screen, and go to text mode */
  11.964 -    wait_idle(this);
  11.965 -    screen_arealen = ((screen->h + (2 * this->offset_y)) * screen->pitch);
  11.966 -    screen_contents = (Uint8 *) SDL_malloc(screen_arealen);
  11.967 -    if (screen_contents) {
  11.968 -        SDL_memcpy(screen_contents, screen->pixels, screen_arealen);
  11.969 -    }
  11.970 -    FB_SavePaletteTo(this, 256, screen_palette);
  11.971 -    ioctl(console_fd, FBIOGET_VSCREENINFO, &screen_vinfo);
  11.972 -    ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
  11.973 -    ioctl(keyboard_fd, VT_UNLOCKSWITCH, 1);
  11.974 -}
  11.975 -
  11.976 -static void
  11.977 -switch_vt_done(_THIS)
  11.978 -{
  11.979 -    SDL_Surface *screen = SDL_VideoSurface;
  11.980 -
  11.981 -    /* Restore graphics mode and the contents of the screen */
  11.982 -    ioctl(keyboard_fd, VT_LOCKSWITCH, 1);
  11.983 -    ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS);
  11.984 -    ioctl(console_fd, FBIOPUT_VSCREENINFO, &screen_vinfo);
  11.985 -    FB_RestorePaletteFrom(this, 256, screen_palette);
  11.986 -    if (screen_contents) {
  11.987 -        SDL_memcpy(screen->pixels, screen_contents, screen_arealen);
  11.988 -        SDL_free(screen_contents);
  11.989 -        screen_contents = NULL;
  11.990 -    }
  11.991 -
  11.992 -    /* Get updates to the shadow surface while switched away */
  11.993 -    if (SDL_ShadowSurface) {
  11.994 -        SDL_UpdateRect(SDL_ShadowSurface, 0, 0, 0, 0);
  11.995 -    }
  11.996 -
  11.997 -    SDL_PrivateAppActive(1,
  11.998 -                         (SDL_APPACTIVE | SDL_APPINPUTFOCUS |
  11.999 -                          SDL_APPMOUSEFOCUS));
 11.1000 -}
 11.1001 -
 11.1002 -static void
 11.1003 -switch_vt(_THIS, unsigned short which)
 11.1004 -{
 11.1005 -    struct vt_stat vtstate;
 11.1006 -
 11.1007 -    /* Figure out whether or not we're switching to a new console */
 11.1008 -    if ((ioctl(keyboard_fd, VT_GETSTATE, &vtstate) < 0) ||
 11.1009 -        (which == vtstate.v_active)) {
 11.1010 -        return;
 11.1011 -    }
 11.1012 -
 11.1013 -    /* New console, switch to it */
 11.1014 -    SDL_mutexP(hw_lock);
 11.1015 -    switch_vt_prep(this);
 11.1016 -    if (ioctl(keyboard_fd, VT_ACTIVATE, which) == 0) {
 11.1017 -        ioctl(keyboard_fd, VT_WAITACTIVE, which);
 11.1018 -        switched_away = 1;
 11.1019 -    } else {
 11.1020 -        switch_vt_done(this);
 11.1021 -    }
 11.1022 -    SDL_mutexV(hw_lock);
 11.1023 -}
 11.1024 -
 11.1025 -static void
 11.1026 -handle_keyboard(_THIS)
 11.1027 -{
 11.1028 -    unsigned char keybuf[BUFSIZ];
 11.1029 -    int i, nread;
 11.1030 -    int pressed;
 11.1031 -    int scancode;
 11.1032 -    SDL_keysym keysym;
 11.1033 -
 11.1034 -    nread = read(keyboard_fd, keybuf, BUFSIZ);
 11.1035 -    for (i = 0; i < nread; ++i) {
 11.1036 -        scancode = keybuf[i] & 0x7F;
 11.1037 -        if (keybuf[i] & 0x80) {
 11.1038 -            pressed = SDL_RELEASED;
 11.1039 -        } else {
 11.1040 -            pressed = SDL_PRESSED;
 11.1041 -        }
 11.1042 -        TranslateKey(scancode, &keysym);
 11.1043 -        /* Handle Ctrl-Alt-FN for vt switch */
 11.1044 -        switch (keysym.sym) {
 11.1045 -        case SDLK_F1:
 11.1046 -        case SDLK_F2:
 11.1047 -        case SDLK_F3:
 11.1048 -        case SDLK_F4:
 11.1049 -        case SDLK_F5:
 11.1050 -        case SDLK_F6:
 11.1051 -        case SDLK_F7:
 11.1052 -        case SDLK_F8:
 11.1053 -        case SDLK_F9:
 11.1054 -        case SDLK_F10:
 11.1055 -        case SDLK_F11:
 11.1056 -        case SDLK_F12:
 11.1057 -            if ((SDL_GetModState() & KMOD_CTRL) &&
 11.1058 -                (SDL_GetModState() & KMOD_ALT)) {
 11.1059 -                if (pressed) {
 11.1060 -                    switch_vt(this, (keysym.sym - SDLK_F1) + 1);
 11.1061 -                }
 11.1062 -                break;
 11.1063 -            }
 11.1064 -            /* Fall through to normal processing */
 11.1065 -        default:
 11.1066 -            posted += SDL_PrivateKeyboard(pressed, &keysym);
 11.1067 -            break;
 11.1068 -        }
 11.1069 -    }
 11.1070 -}
 11.1071 -
 11.1072 -void
 11.1073 -FB_PumpEvents(_THIS)
 11.1074 -{
 11.1075 -    fd_set fdset;
 11.1076 -    int max_fd;
 11.1077 -    static struct timeval zero;
 11.1078 -
 11.1079 -    do {
 11.1080 -        if (switched_away) {
 11.1081 -            struct vt_stat vtstate;
 11.1082 -
 11.1083 -            SDL_mutexP(hw_lock);
 11.1084 -            if ((ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) &&
 11.1085 -                vtstate.v_active == current_vt) {
 11.1086 -                switched_away = 0;
 11.1087 -                switch_vt_done(this);
 11.1088 -            }
 11.1089 -            SDL_mutexV(hw_lock);
 11.1090 -        }
 11.1091 -
 11.1092 -        posted = 0;
 11.1093 -
 11.1094 -        FD_ZERO(&fdset);
 11.1095 -        max_fd = 0;
 11.1096 -        if (keyboard_fd >= 0) {
 11.1097 -            FD_SET(keyboard_fd, &fdset);
 11.1098 -            if (max_fd < keyboard_fd) {
 11.1099 -                max_fd = keyboard_fd;
 11.1100 -            }
 11.1101 -        }
 11.1102 -        if (mouse_fd >= 0) {
 11.1103 -            FD_SET(mouse_fd, &fdset);
 11.1104 -            if (max_fd < mouse_fd) {
 11.1105 -                max_fd = mouse_fd;
 11.1106 -            }
 11.1107 -        }
 11.1108 -        if (select(max_fd + 1, &fdset, NULL, NULL, &zero) > 0) {
 11.1109 -            if (keyboard_fd >= 0) {
 11.1110 -                if (FD_ISSET(keyboard_fd, &fdset)) {
 11.1111 -                    handle_keyboard(this);
 11.1112 -                }
 11.1113 -            }
 11.1114 -            if (mouse_fd >= 0) {
 11.1115 -                if (FD_ISSET(mouse_fd, &fdset)) {
 11.1116 -                    handle_mouse(this);
 11.1117 -                }
 11.1118 -            }
 11.1119 -        }
 11.1120 -    } while (posted);
 11.1121 -}
 11.1122 -
 11.1123 -void
 11.1124 -FB_InitOSKeymap(_THIS)
 11.1125 -{
 11.1126 -    int i;
 11.1127 -
 11.1128 -    /* Initialize the Linux key translation table */
 11.1129 -
 11.1130 -    /* First get the ascii keys and others not well handled */
 11.1131 -    for (i = 0; i < SDL_arraysize(keymap); ++i) {
 11.1132 -        switch (i) {
 11.1133 -            /* These aren't handled by the x86 kernel keymapping (?) */
 11.1134 -        case SCANCODE_PRINTSCREEN:
 11.1135 -            keymap[i] = SDLK_PRINT;
 11.1136 -            break;
 11.1137 -        case SCANCODE_BREAK:
 11.1138 -            keymap[i] = SDLK_BREAK;
 11.1139 -            break;
 11.1140 -        case SCANCODE_BREAK_ALTERNATIVE:
 11.1141 -            keymap[i] = SDLK_PAUSE;
 11.1142 -            break;
 11.1143 -        case SCANCODE_LEFTSHIFT:
 11.1144 -            keymap[i] = SDLK_LSHIFT;
 11.1145 -            break;
 11.1146 -        case SCANCODE_RIGHTSHIFT:
 11.1147 -            keymap[i] = SDLK_RSHIFT;
 11.1148 -            break;
 11.1149 -        case SCANCODE_LEFTCONTROL:
 11.1150 -            keymap[i] = SDLK_LCTRL;
 11.1151 -            break;
 11.1152 -        case SCANCODE_RIGHTCONTROL:
 11.1153 -            keymap[i] = SDLK_RCTRL;
 11.1154 -            break;
 11.1155 -        case SCANCODE_RIGHTWIN:
 11.1156 -            keymap[i] = SDLK_RSUPER;
 11.1157 -            break;
 11.1158 -        case SCANCODE_LEFTWIN:
 11.1159 -            keymap[i] = SDLK_LSUPER;
 11.1160 -            break;
 11.1161 -        case SCANCODE_LEFTALT:
 11.1162 -            keymap[i] = SDLK_LALT;
 11.1163 -            break;
 11.1164 -        case SCANCODE_RIGHTALT:
 11.1165 -            keymap[i] = SDLK_RALT;
 11.1166 -            break;
 11.1167 -        case 127:
 11.1168 -            keymap[i] = SDLK_MENU;
 11.1169 -            break;
 11.1170 -            /* this should take care of all standard ascii keys */
 11.1171 -        default:
 11.1172 -            keymap[i] = KVAL(vga_keymap[0][i]);
 11.1173 -            break;
 11.1174 -        }
 11.1175 -    }
 11.1176 -    for (i = 0; i < SDL_arraysize(keymap); ++i) {
 11.1177 -        switch (keymap_temp[i]) {
 11.1178 -        case K_F1:
 11.1179 -            keymap[i] = SDLK_F1;
 11.1180 -            break;
 11.1181 -        case K_F2:
 11.1182 -            keymap[i] = SDLK_F2;
 11.1183 -            break;
 11.1184 -        case K_F3:
 11.1185 -            keymap[i] = SDLK_F3;
 11.1186 -            break;
 11.1187 -        case K_F4:
 11.1188 -            keymap[i] = SDLK_F4;
 11.1189 -            break;
 11.1190 -        case K_F5:
 11.1191 -            keymap[i] = SDLK_F5;
 11.1192 -            break;
 11.1193 -        case K_F6:
 11.1194 -            keymap[i] = SDLK_F6;
 11.1195 -            break;
 11.1196 -        case K_F7:
 11.1197 -            keymap[i] = SDLK_F7;
 11.1198 -            break;
 11.1199 -        case K_F8:
 11.1200 -            keymap[i] = SDLK_F8;
 11.1201 -            break;
 11.1202 -        case K_F9:
 11.1203 -            keymap[i] = SDLK_F9;
 11.1204 -            break;
 11.1205 -        case K_F10:
 11.1206 -            keymap[i] = SDLK_F10;
 11.1207 -            break;
 11.1208 -        case K_F11:
 11.1209 -            keymap[i] = SDLK_F11;
 11.1210 -            break;
 11.1211 -        case K_F12:
 11.1212 -            keymap[i] = SDLK_F12;
 11.1213 -            break;
 11.1214 -
 11.1215 -        case K_DOWN:
 11.1216 -            keymap[i] = SDLK_DOWN;
 11.1217 -            break;
 11.1218 -        case K_LEFT:
 11.1219 -            keymap[i] = SDLK_LEFT;
 11.1220 -            break;
 11.1221 -        case K_RIGHT:
 11.1222 -            keymap[i] = SDLK_RIGHT;
 11.1223 -            break;
 11.1224 -        case K_UP:
 11.1225 -            keymap[i] = SDLK_UP;
 11.1226 -            break;
 11.1227 -
 11.1228 -        case K_P0:
 11.1229 -            keymap[i] = SDLK_KP0;
 11.1230 -            break;
 11.1231 -        case K_P1:
 11.1232 -            keymap[i] = SDLK_KP1;
 11.1233 -            break;
 11.1234 -        case K_P2:
 11.1235 -            keymap[i] = SDLK_KP2;
 11.1236 -            break;
 11.1237 -        case K_P3:
 11.1238 -            keymap[i] = SDLK_KP3;
 11.1239 -            break;
 11.1240 -        case K_P4:
 11.1241 -            keymap[i] = SDLK_KP4;
 11.1242 -            break;
 11.1243 -        case K_P5:
 11.1244 -            keymap[i] = SDLK_KP5;
 11.1245 -            break;
 11.1246 -        case K_P6:
 11.1247 -            keymap[i] = SDLK_KP6;
 11.1248 -            break;
 11.1249 -        case K_P7:
 11.1250 -            keymap[i] = SDLK_KP7;
 11.1251 -            break;
 11.1252 -        case K_P8:
 11.1253 -            keymap[i] = SDLK_KP8;
 11.1254 -            break;
 11.1255 -        case K_P9:
 11.1256 -            keymap[i] = SDLK_KP9;
 11.1257 -            break;
 11.1258 -        case K_PPLUS:
 11.1259 -            keymap[i] = SDLK_KP_PLUS;
 11.1260 -            break;
 11.1261 -        case K_PMINUS:
 11.1262 -            keymap[i] = SDLK_KP_MINUS;
 11.1263 -            break;
 11.1264 -        case K_PSTAR:
 11.1265 -            keymap[i] = SDLK_KP_MULTIPLY;
 11.1266 -            break;
 11.1267 -        case K_PSLASH:
 11.1268 -            keymap[i] = SDLK_KP_DIVIDE;
 11.1269 -            break;
 11.1270 -        case K_PENTER:
 11.1271 -            keymap[i] = SDLK_KP_ENTER;
 11.1272 -            break;
 11.1273 -        case K_PDOT:
 11.1274 -            keymap[i] = SDLK_KP_PERIOD;
 11.1275 -            break;
 11.1276 -
 11.1277 -        case K_SHIFT:
 11.1278 -            if (keymap[i] != SDLK_RSHIFT)
 11.1279 -                keymap[i] = SDLK_LSHIFT;
 11.1280 -            break;
 11.1281 -        case K_SHIFTL:
 11.1282 -            keymap[i] = SDLK_LSHIFT;
 11.1283 -            break;
 11.1284 -        case K_SHIFTR:
 11.1285 -            keymap[i] = SDLK_RSHIFT;
 11.1286 -            break;
 11.1287 -        case K_CTRL:
 11.1288 -            if (keymap[i] != SDLK_RCTRL)
 11.1289 -                keymap[i] = SDLK_LCTRL;
 11.1290 -            break;
 11.1291 -        case K_CTRLL:
 11.1292 -            keymap[i] = SDLK_LCTRL;
 11.1293 -            break;
 11.1294 -        case K_CTRLR:
 11.1295 -            keymap[i] = SDLK_RCTRL;
 11.1296 -            break;
 11.1297 -        case K_ALT:
 11.1298 -            keymap[i] = SDLK_LALT;
 11.1299 -            break;
 11.1300 -        case K_ALTGR:
 11.1301 -            keymap[i] = SDLK_RALT;
 11.1302 -            break;
 11.1303 -
 11.1304 -        case K_INSERT:
 11.1305 -            keymap[i] = SDLK_INSERT;
 11.1306 -            break;
 11.1307 -        case K_REMOVE:
 11.1308 -            keymap[i] = SDLK_DELETE;
 11.1309 -            break;
 11.1310 -        case K_PGUP:
 11.1311 -            keymap[i] = SDLK_PAGEUP;
 11.1312 -            break;
 11.1313 -        case K_PGDN:
 11.1314 -            keymap[i] = SDLK_PAGEDOWN;
 11.1315 -            break;
 11.1316 -        case K_FIND:
 11.1317 -            keymap[i] = SDLK_HOME;
 11.1318 -            break;
 11.1319 -        case K_SELECT:
 11.1320 -            keymap[i] = SDLK_END;
 11.1321 -            break;
 11.1322 -
 11.1323 -        case K_NUM:
 11.1324 -            keymap[i] = SDLK_NUMLOCK;
 11.1325 -            break;
 11.1326 -        case K_CAPS:
 11.1327 -            keymap[i] = SDLK_CAPSLOCK;
 11.1328 -            break;
 11.1329 -
 11.1330 -        case K_F13:
 11.1331 -            keymap[i] = SDLK_PRINT;
 11.1332 -            break;
 11.1333 -        case K_HOLD:
 11.1334 -            keymap[i] = SDLK_SCROLLOCK;
 11.1335 -            break;
 11.1336 -        case K_PAUSE:
 11.1337 -            keymap[i] = SDLK_PAUSE;
 11.1338 -            break;
 11.1339 -
 11.1340 -        case 127:
 11.1341 -            keymap[i] = SDLK_BACKSPACE;
 11.1342 -            break;
 11.1343 -
 11.1344 -        default:
 11.1345 -            break;
 11.1346 -        }
 11.1347 -    }
 11.1348 -}
 11.1349 -
 11.1350 -static SDL_keysym *
 11.1351 -TranslateKey(int scancode, SDL_keysym * keysym)
 11.1352 -{
 11.1353 -    /* Set the keysym information */
 11.1354 -    keysym->scancode = scancode;
 11.1355 -    keysym->sym = keymap[scancode];
 11.1356 -    keysym->mod = KMOD_NONE;
 11.1357 -
 11.1358 -    /* If UNICODE is on, get the UNICODE value for the key */
 11.1359 -    keysym->unicode = 0;
 11.1360 -    if (SDL_TranslateUNICODE) {
 11.1361 -        int map;
 11.1362 -        SDLMod modstate;
 11.1363 -
 11.1364 -        modstate = SDL_GetModState();
 11.1365 -        map = 0;
 11.1366 -        if (modstate & KMOD_SHIFT) {
 11.1367 -            map |= (1 << KG_SHIFT);
 11.1368 -        }
 11.1369 -        if (modstate & KMOD_CTRL) {
 11.1370 -            map |= (1 << KG_CTRL);
 11.1371 -        }
 11.1372 -        if (modstate & KMOD_LALT) {
 11.1373 -            map |= (1 << KG_ALT);
 11.1374 -        }
 11.1375 -        if (modstate & KMOD_RALT) {
 11.1376 -            map |= (1 << KG_ALTGR);
 11.1377 -        }
 11.1378 -        if (KTYP(vga_keymap[map][scancode]) == KT_LETTER) {
 11.1379 -            if (modstate & KMOD_CAPS) {
 11.1380 -                map ^= (1 << KG_SHIFT);
 11.1381 -            }
 11.1382 -        }
 11.1383 -        if (KTYP(vga_keymap[map][scancode]) == KT_PAD) {
 11.1384 -            if (modstate & KMOD_NUM) {
 11.1385 -                keysym->unicode = KVAL(vga_keymap[map][scancode]);
 11.1386 -            }
 11.1387 -        } else {
 11.1388 -            keysym->unicode = KVAL(vga_keymap[map][scancode]);
 11.1389 -        }
 11.1390 -    }
 11.1391 -    return (keysym);
 11.1392 -}
 11.1393 -
 11.1394 -/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/video/fbcon/SDL_fbevents_c.h	Wed Jan 19 19:51:04 2011 -0800
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,39 +0,0 @@
    12.4 -/*
    12.5 -    SDL - Simple DirectMedia Layer
    12.6 -    Copyright (C) 1997-2010 Sam Lantinga
    12.7 -
    12.8 -    This library is free software; you can redistribute it and/or
    12.9 -    modify it under the terms of the GNU Lesser General Public
   12.10 -    License as published by the Free Software Foundation; either
   12.11 -    version 2.1 of the License, or (at your option) any later version.
   12.12 -
   12.13 -    This library is distributed in the hope that it will be useful,
   12.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.16 -    Lesser General Public License for more details.
   12.17 -
   12.18 -    You should have received a copy of the GNU Lesser General Public
   12.19 -    License along with this library; if not, write to the Free Software
   12.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.21 -
   12.22 -    Sam Lantinga
   12.23 -    slouken@libsdl.org
   12.24 -*/
   12.25 -#include "SDL_config.h"
   12.26 -
   12.27 -#include "SDL_fbvideo.h"
   12.28 -
   12.29 -/* Variables and functions exported by SDL_sysevents.c to other parts 
   12.30 -   of the native video subsystem (SDL_sysvideo.c)
   12.31 -*/
   12.32 -extern int FB_OpenKeyboard(_THIS);
   12.33 -extern void FB_CloseKeyboard(_THIS);
   12.34 -extern int FB_OpenMouse(_THIS);
   12.35 -extern void FB_CloseMouse(_THIS);
   12.36 -extern int FB_EnterGraphicsMode(_THIS);
   12.37 -extern int FB_InGraphicsMode(_THIS);
   12.38 -extern void FB_LeaveGraphicsMode(_THIS);
   12.39 -
   12.40 -extern void FB_InitOSKeymap(_THIS);
   12.41 -extern void FB_PumpEvents(_THIS);
   12.42 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/video/fbcon/SDL_fbkeys.h	Wed Jan 19 19:51:04 2011 -0800
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,139 +0,0 @@
    13.4 -
    13.5 -/* Scancodes for the Linux framebuffer console
    13.6 -   - Taken with thanks from SVGAlib 1.4.0
    13.7 -*/
    13.8 -
    13.9 -#define SCANCODE_ESCAPE			1
   13.10 -
   13.11 -#define SCANCODE_1			2
   13.12 -#define SCANCODE_2			3
   13.13 -#define SCANCODE_3			4
   13.14 -#define SCANCODE_4			5
   13.15 -#define SCANCODE_5			6
   13.16 -#define SCANCODE_6			7
   13.17 -#define SCANCODE_7			8
   13.18 -#define SCANCODE_8			9
   13.19 -#define SCANCODE_9			10
   13.20 -#define SCANCODE_0			11
   13.21 -
   13.22 -#define SCANCODE_MINUS			12
   13.23 -#define SCANCODE_EQUAL			13
   13.24 -
   13.25 -#define SCANCODE_BACKSPACE		14
   13.26 -#define SCANCODE_TAB			15
   13.27 -
   13.28 -#define SCANCODE_Q			16
   13.29 -#define SCANCODE_W			17
   13.30 -#define SCANCODE_E			18
   13.31 -#define SCANCODE_R			19
   13.32 -#define SCANCODE_T			20
   13.33 -#define SCANCODE_Y			21
   13.34 -#define SCANCODE_U			22
   13.35 -#define SCANCODE_I			23
   13.36 -#define SCANCODE_O			24
   13.37 -#define SCANCODE_P			25
   13.38 -#define SCANCODE_BRACKET_LEFT		26
   13.39 -#define SCANCODE_BRACKET_RIGHT		27
   13.40 -
   13.41 -#define SCANCODE_ENTER			28
   13.42 -
   13.43 -#define SCANCODE_LEFTCONTROL		29
   13.44 -
   13.45 -#define SCANCODE_A			30
   13.46 -#define SCANCODE_S			31
   13.47 -#define SCANCODE_D			32
   13.48 -#define SCANCODE_F			33
   13.49 -#define SCANCODE_G			34
   13.50 -#define SCANCODE_H			35
   13.51 -#define SCANCODE_J			36
   13.52 -#define SCANCODE_K			37
   13.53 -#define SCANCODE_L			38
   13.54 -#define SCANCODE_SEMICOLON		39
   13.55 -#define SCANCODE_APOSTROPHE		40
   13.56 -#define SCANCODE_GRAVE			41
   13.57 -
   13.58 -#define SCANCODE_LEFTSHIFT		42
   13.59 -#define SCANCODE_BACKSLASH		43
   13.60 -
   13.61 -#define SCANCODE_Z			44
   13.62 -#define SCANCODE_X			45
   13.63 -#define SCANCODE_C			46
   13.64 -#define SCANCODE_V			47
   13.65 -#define SCANCODE_B			48
   13.66 -#define SCANCODE_N			49
   13.67 -#define SCANCODE_M			50
   13.68 -#define SCANCODE_COMMA			51
   13.69 -#define SCANCODE_PERIOD			52
   13.70 -#define SCANCODE_SLASH			53
   13.71 -
   13.72 -#define SCANCODE_RIGHTSHIFT		54
   13.73 -#define SCANCODE_KEYPADMULTIPLY		55
   13.74 -
   13.75 -#define SCANCODE_LEFTALT		56
   13.76 -#define SCANCODE_SPACE			57
   13.77 -#define SCANCODE_CAPSLOCK		58
   13.78 -
   13.79 -#define SCANCODE_F1			59
   13.80 -#define SCANCODE_F2			60
   13.81 -#define SCANCODE_F3			61
   13.82 -#define SCANCODE_F4			62
   13.83 -#define SCANCODE_F5			63
   13.84 -#define SCANCODE_F6			64
   13.85 -#define SCANCODE_F7			65
   13.86 -#define SCANCODE_F8			66
   13.87 -#define SCANCODE_F9			67
   13.88 -#define SCANCODE_F10			68
   13.89 -
   13.90 -#define SCANCODE_NUMLOCK		69
   13.91 -#define SCANCODE_SCROLLLOCK		70
   13.92 -
   13.93 -#define SCANCODE_KEYPAD7		71
   13.94 -#define SCANCODE_CURSORUPLEFT		71
   13.95 -#define SCANCODE_KEYPAD8		72
   13.96 -#define SCANCODE_CURSORUP		72
   13.97 -#define SCANCODE_KEYPAD9		73
   13.98 -#define SCANCODE_CURSORUPRIGHT		73
   13.99 -#define SCANCODE_KEYPADMINUS		74
  13.100 -#define SCANCODE_KEYPAD4		75
  13.101 -#define SCANCODE_CURSORLEFT		75
  13.102 -#define SCANCODE_KEYPAD5		76
  13.103 -#define SCANCODE_KEYPAD6		77
  13.104 -#define SCANCODE_CURSORRIGHT		77
  13.105 -#define SCANCODE_KEYPADPLUS		78
  13.106 -#define SCANCODE_KEYPAD1		79
  13.107 -#define SCANCODE_CURSORDOWNLEFT		79
  13.108 -#define SCANCODE_KEYPAD2		80
  13.109 -#define SCANCODE_CURSORDOWN		80
  13.110 -#define SCANCODE_KEYPAD3		81
  13.111 -#define SCANCODE_CURSORDOWNRIGHT	81
  13.112 -#define SCANCODE_KEYPAD0		82
  13.113 -#define SCANCODE_KEYPADPERIOD		83
  13.114 -
  13.115 -#define SCANCODE_LESS			86
  13.116 -
  13.117 -#define SCANCODE_F11			87
  13.118 -#define SCANCODE_F12			88
  13.119 -
  13.120 -#define SCANCODE_KEYPADENTER		96
  13.121 -#define SCANCODE_RIGHTCONTROL		97
  13.122 -#define SCANCODE_CONTROL		97
  13.123 -#define SCANCODE_KEYPADDIVIDE		98
  13.124 -#define SCANCODE_PRINTSCREEN		99
  13.125 -#define SCANCODE_RIGHTALT		100
  13.126 -#define SCANCODE_BREAK			101     /* Beware: is 119     */
  13.127 -#define SCANCODE_BREAK_ALTERNATIVE	119     /* on some keyboards! */
  13.128 -
  13.129 -#define SCANCODE_HOME			102
  13.130 -#define SCANCODE_CURSORBLOCKUP		103     /* Cursor key block */
  13.131 -#define SCANCODE_PAGEUP			104
  13.132 -#define SCANCODE_CURSORBLOCKLEFT	105     /* Cursor key block */
  13.133 -#define SCANCODE_CURSORBLOCKRIGHT	106     /* Cursor key block */
  13.134 -#define SCANCODE_END			107
  13.135 -#define SCANCODE_CURSORBLOCKDOWN	108     /* Cursor key block */
  13.136 -#define SCANCODE_PAGEDOWN		109
  13.137 -#define SCANCODE_INSERT			110
  13.138 -#define SCANCODE_REMOVE			111
  13.139 -
  13.140 -#define SCANCODE_RIGHTWIN		126
  13.141 -#define SCANCODE_LEFTWIN		125
  13.142 -/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/video/fbcon/SDL_fbmatrox.c	Wed Jan 19 19:51:04 2011 -0800
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,285 +0,0 @@
    14.4 -/*
    14.5 -    SDL - Simple DirectMedia Layer
    14.6 -    Copyright (C) 1997-2010 Sam Lantinga
    14.7 -
    14.8 -    This library is free software; you can redistribute it and/or
    14.9 -    modify it under the terms of the GNU Lesser General Public
   14.10 -    License as published by the Free Software Foundation; either
   14.11 -    version 2.1 of the License, or (at your option) any later version.
   14.12 -
   14.13 -    This library is distributed in the hope that it will be useful,
   14.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14.16 -    Lesser General Public License for more details.
   14.17 -
   14.18 -    You should have received a copy of the GNU Lesser General Public
   14.19 -    License along with this library; if not, write to the Free Software
   14.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   14.21 -
   14.22 -    Sam Lantinga
   14.23 -    slouken@libsdl.org
   14.24 -*/
   14.25 -#include "SDL_config.h"
   14.26 -
   14.27 -#include "SDL_video.h"
   14.28 -#include "../SDL_blit.h"
   14.29 -#include "SDL_fbmatrox.h"
   14.30 -#include "matrox_mmio.h"
   14.31 -
   14.32 -
   14.33 -/* Wait for vertical retrace - taken from the XFree86 Matrox driver */
   14.34 -static void
   14.35 -WaitVBL(_THIS)
   14.36 -{
   14.37 -    int count;
   14.38 -
   14.39 -    /* find start of retrace */
   14.40 -    mga_waitidle();
   14.41 -    while ((mga_in8(0x1FDA) & 0x08));
   14.42 -    while (!(mga_in8(0x1FDA) & 0x08));
   14.43 -    /* wait until we're past the start */
   14.44 -    count = mga_in32(0x1E20) + 2;
   14.45 -    while (mga_in32(0x1E20) < count);
   14.46 -}
   14.47 -
   14.48 -static void
   14.49 -WaitIdle(_THIS)
   14.50 -{
   14.51 -    mga_waitidle();
   14.52 -}
   14.53 -
   14.54 -/* Sets video mem colorkey and accelerated blit function */
   14.55 -static int
   14.56 -SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key)
   14.57 -{
   14.58 -    return (0);
   14.59 -}
   14.60 -
   14.61 -/* Sets per surface hardware alpha value */
   14.62 -#if 0
   14.63 -static int
   14.64 -SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 value)
   14.65 -{
   14.66 -    return (0);
   14.67 -}
   14.68 -#endif
   14.69 -
   14.70 -static int
   14.71 -FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
   14.72 -{
   14.73 -    int dstX, dstY;
   14.74 -    Uint32 fxbndry;
   14.75 -    Uint32 ydstlen;
   14.76 -    Uint32 fillop;
   14.77 -
   14.78 -    /* Don't blit to the display surface when switched away */
   14.79 -    if (switched_away) {
   14.80 -        return -2;              /* no hardware access */
   14.81 -    }
   14.82 -    if (dst == this->screen) {
   14.83 -        SDL_mutexP(hw_lock);
   14.84 -    }
   14.85 -
   14.86 -    switch (dst->format->BytesPerPixel) {
   14.87 -    case 1:
   14.88 -        color |= (color << 8);
   14.89 -    case 2:
   14.90 -        color |= (color << 16);
   14.91 -        break;
   14.92 -    }
   14.93 -
   14.94 -    /* Set up the X/Y base coordinates */
   14.95 -    FB_dst_to_xy(this, dst, &dstX, &dstY);
   14.96 -
   14.97 -    /* Adjust for the current rectangle */
   14.98 -    dstX += rect->x;
   14.99 -    dstY += rect->y;
  14.100 -
  14.101 -    /* Set up the X boundaries */
  14.102 -    fxbndry = (dstX | ((dstX + rect->w) << 16));
  14.103 -
  14.104 -    /* Set up the Y boundaries */
  14.105 -    ydstlen = (rect->h | (dstY << 16));
  14.106 -
  14.107 -    /* Set up for color fill operation */
  14.108 -    fillop = MGADWG_TRAP | MGADWG_SOLID |
  14.109 -        MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO;
  14.110 -
  14.111 -    /* Execute the operations! */
  14.112 -    mga_wait(5);
  14.113 -    mga_out32(MGAREG_DWGCTL, fillop | MGADWG_REPLACE);
  14.114 -    mga_out32(MGAREG_FCOL, color);
  14.115 -    mga_out32(MGAREG_FXBNDRY, fxbndry);
  14.116 -    mga_out32(MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen);
  14.117 -
  14.118 -    FB_AddBusySurface(dst);
  14.119 -
  14.120 -    if (dst == this->screen) {
  14.121 -        SDL_mutexV(hw_lock);
  14.122 -    }
  14.123 -    return (0);
  14.124 -}
  14.125 -
  14.126 -static int
  14.127 -HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
  14.128 -            SDL_Surface * dst, SDL_Rect * dstrect)
  14.129 -{
  14.130 -    SDL_VideoDevice *this = current_video;
  14.131 -    int pitch, w, h;
  14.132 -    int srcX, srcY;
  14.133 -    int dstX, dstY;
  14.134 -    Uint32 sign;
  14.135 -    Uint32 start, stop;
  14.136 -    int skip;
  14.137 -    Uint32 blitop;
  14.138 -
  14.139 -    /* FIXME: For now, only blit to display surface */
  14.140 -    if (dst->pitch != SDL_VideoSurface->pitch) {
  14.141 -        return (src->map->sw_blit(src, srcrect, dst, dstrect));
  14.142 -    }
  14.143 -
  14.144 -    /* Don't blit to the display surface when switched away */
  14.145 -    if (switched_away) {
  14.146 -        return -2;              /* no hardware access */
  14.147 -    }
  14.148 -    if (dst == this->screen) {
  14.149 -        SDL_mutexP(hw_lock);
  14.150 -    }
  14.151 -
  14.152 -    /* Calculate source and destination base coordinates (in pixels) */
  14.153 -    w = dstrect->w;
  14.154 -    h = dstrect->h;
  14.155 -    FB_dst_to_xy(this, src, &srcX, &srcY);
  14.156 -    FB_dst_to_xy(this, dst, &dstX, &dstY);
  14.157 -
  14.158 -    /* Adjust for the current blit rectangles */
  14.159 -    srcX += srcrect->x;
  14.160 -    srcY += srcrect->y;
  14.161 -    dstX += dstrect->x;
  14.162 -    dstY += dstrect->y;
  14.163 -    pitch = dst->pitch / dst->format->BytesPerPixel;
  14.164 -
  14.165 -    /* Set up the blit direction (sign) flags */
  14.166 -    sign = 0;
  14.167 -    if (srcX < dstX) {
  14.168 -        sign |= 1;
  14.169 -    }
  14.170 -    if (srcY < dstY) {
  14.171 -        sign |= 4;
  14.172 -        srcY += (h - 1);
  14.173 -        dstY += (h - 1);
  14.174 -    }
  14.175 -
  14.176 -    /* Set up the blit source row start, end, and skip (in pixels) */
  14.177 -    stop = start = (srcY * pitch) + srcX;
  14.178 -    if (srcX < dstX) {
  14.179 -        start += (w - 1);
  14.180 -    } else {
  14.181 -        stop += (w - 1);
  14.182 -    }
  14.183 -    if (srcY < dstY) {
  14.184 -        skip = -pitch;
  14.185 -    } else {
  14.186 -        skip = pitch;
  14.187 -    }
  14.188 -
  14.189 -    /* Set up the blit operation */
  14.190 -    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
  14.191 -        Uint32 colorkey;
  14.192 -
  14.193 -        blitop = MGADWG_BFCOL | MGADWG_BITBLT |
  14.194 -            MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16) | MGADWG_TRANSC;
  14.195 -
  14.196 -        colorkey = src->format->colorkey;
  14.197 -        switch (dst->format->BytesPerPixel) {
  14.198 -        case 1:
  14.199 -            colorkey |= (colorkey << 8);
  14.200 -        case 2:
  14.201 -            colorkey |= (colorkey << 16);
  14.202 -            break;
  14.203 -        }
  14.204 -        mga_wait(2);
  14.205 -        mga_out32(MGAREG_FCOL, colorkey);
  14.206 -        mga_out32(MGAREG_BCOL, 0xFFFFFFFF);
  14.207 -    } else {
  14.208 -        blitop = MGADWG_BFCOL | MGADWG_BITBLT |
  14.209 -            MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16);
  14.210 -    }
  14.211 -    mga_wait(7);
  14.212 -    mga_out32(MGAREG_SGN, sign);
  14.213 -    mga_out32(MGAREG_AR3, start);
  14.214 -    mga_out32(MGAREG_AR0, stop);
  14.215 -    mga_out32(MGAREG_AR5, skip);
  14.216 -    mga_out32(MGAREG_FXBNDRY, (dstX | ((dstX + w - 1) << 16)));
  14.217 -    mga_out32(MGAREG_YDSTLEN, (dstY << 16) | h);
  14.218 -    mga_out32(MGAREG_DWGCTL + MGAREG_EXEC, blitop);
  14.219 -
  14.220 -    FB_AddBusySurface(src);
  14.221 -    FB_AddBusySurface(dst);
  14.222 -
  14.223 -    if (dst == this->screen) {
  14.224 -        SDL_mutexV(hw_lock);
  14.225 -    }
  14.226 -    return (0);
  14.227 -}
  14.228 -
  14.229 -static int
  14.230 -CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
  14.231 -{
  14.232 -    int accelerated;
  14.233 -
  14.234 -    /* Set initial acceleration on */
  14.235 -    src->flags |= SDL_HWACCEL;
  14.236 -
  14.237 -    /* Set the surface attributes */
  14.238 -    if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
  14.239 -        if (!this->info.blit_hw_A) {
  14.240 -            src->flags &= ~SDL_HWACCEL;
  14.241 -        }
  14.242 -    }
  14.243 -    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
  14.244 -        if (!this->info.blit_hw_CC) {
  14.245 -            src->flags &= ~SDL_HWACCEL;
  14.246 -        }
  14.247 -    }
  14.248 -
  14.249 -    /* Check to see if final surface blit is accelerated */
  14.250 -    accelerated = !!(src->flags & SDL_HWACCEL);
  14.251 -    if (accelerated) {
  14.252 -        src->map->hw_blit = HWAccelBlit;
  14.253 -    }
  14.254 -    return (accelerated);
  14.255 -}
  14.256 -
  14.257 -void
  14.258 -FB_MatroxAccel(_THIS, __u32 card)
  14.259 -{
  14.260 -    /* We have hardware accelerated surface functions */
  14.261 -    this->CheckHWBlit = CheckHWBlit;
  14.262 -    wait_vbl = WaitVBL;
  14.263 -    wait_idle = WaitIdle;
  14.264 -
  14.265 -    /* The Matrox has an accelerated color fill */
  14.266 -    this->info.blit_fill = 1;
  14.267 -    this->FillHWRect = FillHWRect;
  14.268 -
  14.269 -    /* The Matrox has accelerated normal and colorkey blits. */
  14.270 -    this->info.blit_hw = 1;
  14.271 -    /* The Millenium I appears to do the colorkey test a word
  14.272 -       at a time, and the transparency is intverted. (?)
  14.273 -     */
  14.274 -    if (card != FB_ACCEL_MATROX_MGA2064W) {
  14.275 -        this->info.blit_hw_CC = 1;
  14.276 -        this->SetHWColorKey = SetHWColorKey;
  14.277 -    }
  14.278 -#if 0                           /* Not yet implemented? */
  14.279 -    /* The Matrox G200/G400 has an accelerated alpha blit */
  14.280 -    if ((card == FB_ACCEL_MATROX_MGAG200)
  14.281 -        || (card == FB_ACCEL_MATROX_MGAG400)) {
  14.282 -        this->info.blit_hw_A = 1;
  14.283 -        this->SetHWAlpha = SetHWAlpha;
  14.284 -    }
  14.285 -#endif
  14.286 -}
  14.287 -
  14.288 -/* vi: set ts=4 sw=4 expandtab: */
    15.1 --- a/src/video/fbcon/SDL_fbmatrox.h	Wed Jan 19 19:51:04 2011 -0800
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,30 +0,0 @@
    15.4 -/*
    15.5 -    SDL - Simple DirectMedia Layer
    15.6 -    Copyright (C) 1997-2010 Sam Lantinga
    15.7 -
    15.8 -    This library is free software; you can redistribute it and/or
    15.9 -    modify it under the terms of the GNU Lesser General Public
   15.10 -    License as published by the Free Software Foundation; either
   15.11 -    version 2.1 of the License, or (at your option) any later version.
   15.12 -
   15.13 -    This library is distributed in the hope that it will be useful,
   15.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15.16 -    Lesser General Public License for more details.
   15.17 -
   15.18 -    You should have received a copy of the GNU Lesser General Public
   15.19 -    License along with this library; if not, write to the Free Software
   15.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   15.21 -
   15.22 -    Sam Lantinga
   15.23 -    slouken@libsdl.org
   15.24 -*/
   15.25 -#include "SDL_config.h"
   15.26 -
   15.27 -/* Matrox hardware acceleration for the SDL framebuffer console driver */
   15.28 -
   15.29 -#include "SDL_fbvideo.h"
   15.30 -
   15.31 -/* Set up the driver for Matrox acceleration */
   15.32 -extern void FB_MatroxAccel(_THIS, __u32 card);
   15.33 -/* vi: set ts=4 sw=4 expandtab: */
    16.1 --- a/src/video/fbcon/SDL_fbmouse.c	Wed Jan 19 19:51:04 2011 -0800
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,35 +0,0 @@
    16.4 -/*
    16.5 -    SDL - Simple DirectMedia Layer
    16.6 -    Copyright (C) 1997-2010 Sam Lantinga
    16.7 -
    16.8 -    This library is free software; you can redistribute it and/or
    16.9 -    modify it under the terms of the GNU Lesser General Public
   16.10 -    License as published by the Free Software Foundation; either
   16.11 -    version 2.1 of the License, or (at your option) any later version.
   16.12 -
   16.13 -    This library is distributed in the hope that it will be useful,
   16.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   16.16 -    Lesser General Public License for more details.
   16.17 -
   16.18 -    You should have received a copy of the GNU Lesser General Public
   16.19 -    License along with this library; if not, write to the Free Software
   16.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   16.21 -
   16.22 -    Sam Lantinga
   16.23 -    slouken@libsdl.org
   16.24 -*/
   16.25 -#include "SDL_config.h"
   16.26 -
   16.27 -#include "SDL_mouse.h"
   16.28 -#include "../../events/SDL_events_c.h"
   16.29 -#include "SDL_fbvideo.h"
   16.30 -#include "SDL_fbmouse_c.h"
   16.31 -
   16.32 -
   16.33 -/* The implementation dependent data for the window manager cursor */
   16.34 -struct WMcursor
   16.35 -{
   16.36 -    int unused;
   16.37 -};
   16.38 -/* vi: set ts=4 sw=4 expandtab: */
    17.1 --- a/src/video/fbcon/SDL_fbmouse_c.h	Wed Jan 19 19:51:04 2011 -0800
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,27 +0,0 @@
    17.4 -/*
    17.5 -    SDL - Simple DirectMedia Layer
    17.6 -    Copyright (C) 1997-2010 Sam Lantinga
    17.7 -
    17.8 -    This library is free software; you can redistribute it and/or
    17.9 -    modify it under the terms of the GNU Lesser General Public
   17.10 -    License as published by the Free Software Foundation; either
   17.11 -    version 2.1 of the License, or (at your option) any later version.
   17.12 -
   17.13 -    This library is distributed in the hope that it will be useful,
   17.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.16 -    Lesser General Public License for more details.
   17.17 -
   17.18 -    You should have received a copy of the GNU Lesser General Public
   17.19 -    License along with this library; if not, write to the Free Software
   17.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   17.21 -
   17.22 -    Sam Lantinga
   17.23 -    slouken@libsdl.org
   17.24 -*/
   17.25 -#include "SDL_config.h"
   17.26 -
   17.27 -#include "SDL_fbvideo.h"
   17.28 -
   17.29 -/* Functions to be exported */
   17.30 -/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- a/src/video/fbcon/SDL_fbriva.c	Wed Jan 19 19:51:04 2011 -0800
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,231 +0,0 @@
    18.4 -/*
    18.5 -    SDL - Simple DirectMedia Layer
    18.6 -    Copyright (C) 1997-2010 Sam Lantinga
    18.7 -
    18.8 -    This library is free software; you can redistribute it and/or
    18.9 -    modify it under the terms of the GNU Lesser General Public
   18.10 -    License as published by the Free Software Foundation; either
   18.11 -    version 2.1 of the License, or (at your option) any later version.
   18.12 -
   18.13 -    This library is distributed in the hope that it will be useful,
   18.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18.16 -    Lesser General Public License for more details.
   18.17 -
   18.18 -    You should have received a copy of the GNU Lesser General Public
   18.19 -    License along with this library; if not, write to the Free Software
   18.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   18.21 -
   18.22 -    Sam Lantinga
   18.23 -    slouken@libsdl.org
   18.24 -*/
   18.25 -#include "SDL_config.h"
   18.26 -
   18.27 -#include "SDL_video.h"
   18.28 -#include "../SDL_blit.h"
   18.29 -#include "SDL_fbriva.h"
   18.30 -#include "riva_mmio.h"
   18.31 -#include "riva_regs.h"
   18.32 -
   18.33 -
   18.34 -static int FifoEmptyCount = 0;
   18.35 -static int FifoFreeCount = 0;
   18.36 -
   18.37 -/* Wait for vertical retrace */
   18.38 -static void
   18.39 -WaitVBL(_THIS)
   18.40 -{
   18.41 -    volatile Uint8 *port = (Uint8 *) (mapped_io + PCIO_OFFSET + 0x3DA);
   18.42 -
   18.43 -    while ((*port & 0x08));
   18.44 -    while (!(*port & 0x08));
   18.45 -}
   18.46 -
   18.47 -static void
   18.48 -NV3WaitIdle(_THIS)
   18.49 -{
   18.50 -    RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET);
   18.51 -    while ((Rop->FifoFree < FifoEmptyCount) ||
   18.52 -           (*(mapped_io + PGRAPH_OFFSET + 0x000006B0) & 0x01));
   18.53 -}
   18.54 -
   18.55 -static void
   18.56 -NV4WaitIdle(_THIS)
   18.57 -{
   18.58 -    RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET);
   18.59 -    while ((Rop->FifoFree < FifoEmptyCount) ||
   18.60 -           (*(mapped_io + PGRAPH_OFFSET + 0x00000700) & 0x01));
   18.61 -}
   18.62 -
   18.63 -#if 0                           /* Not yet implemented? */
   18.64 -/* Sets video mem colorkey and accelerated blit function */
   18.65 -static int
   18.66 -SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key)
   18.67 -{
   18.68 -    return (0);
   18.69 -}
   18.70 -
   18.71 -/* Sets per surface hardware alpha value */
   18.72 -static int
   18.73 -SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 value)
   18.74 -{
   18.75 -    return (0);
   18.76 -}
   18.77 -#endif /* Not yet implemented */
   18.78 -
   18.79 -static int
   18.80 -FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
   18.81 -{
   18.82 -    int dstX, dstY;
   18.83 -    int dstW, dstH;
   18.84 -    RivaBitmap *Bitmap = (RivaBitmap *) (mapped_io + BITMAP_OFFSET);
   18.85 -
   18.86 -    /* Don't blit to the display surface when switched away */
   18.87 -    if (switched_away) {
   18.88 -        return -2;              /* no hardware access */
   18.89 -    }
   18.90 -    if (dst == this->screen) {
   18.91 -        SDL_mutexP(hw_lock);
   18.92 -    }
   18.93 -
   18.94 -    /* Set up the X/Y base coordinates */
   18.95 -    dstW = rect->w;
   18.96 -    dstH = rect->h;
   18.97 -    FB_dst_to_xy(this, dst, &dstX, &dstY);
   18.98 -
   18.99 -    /* Adjust for the current rectangle */
  18.100 -    dstX += rect->x;
  18.101 -    dstY += rect->y;
  18.102 -
  18.103 -    RIVA_FIFO_FREE(Bitmap, 1);
  18.104 -    Bitmap->Color1A = color;
  18.105 -
  18.106 -    RIVA_FIFO_FREE(Bitmap, 2);
  18.107 -    Bitmap->UnclippedRectangle[0].TopLeft = (dstX << 16) | dstY;
  18.108 -    Bitmap->UnclippedRectangle[0].WidthHeight = (dstW << 16) | dstH;
  18.109 -
  18.110 -    FB_AddBusySurface(dst);
  18.111 -
  18.112 -    if (dst == this->screen) {
  18.113 -        SDL_mutexV(hw_lock);
  18.114 -    }
  18.115 -    return (0);
  18.116 -}
  18.117 -
  18.118 -static int
  18.119 -HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
  18.120 -            SDL_Surface * dst, SDL_Rect * dstrect)
  18.121 -{
  18.122 -    SDL_VideoDevice *this = current_video;
  18.123 -    int srcX, srcY;
  18.124 -    int dstX, dstY;
  18.125 -    int dstW, dstH;
  18.126 -    RivaScreenBlt *Blt = (RivaScreenBlt *) (mapped_io + BLT_OFFSET);
  18.127 -
  18.128 -    /* FIXME: For now, only blit to display surface */
  18.129 -    if (dst->pitch != SDL_VideoSurface->pitch) {
  18.130 -        return (src->map->sw_blit(src, srcrect, dst, dstrect));
  18.131 -    }
  18.132 -
  18.133 -    /* Don't blit to the display surface when switched away */
  18.134 -    if (switched_away) {
  18.135 -        return -2;              /* no hardware access */
  18.136 -    }
  18.137 -    if (dst == this->screen) {
  18.138 -        SDL_mutexP(hw_lock);
  18.139 -    }
  18.140 -
  18.141 -    /* Calculate source and destination base coordinates (in pixels) */
  18.142 -    dstW = dstrect->w;
  18.143 -    dstH = dstrect->h;
  18.144 -    FB_dst_to_xy(this, src, &srcX, &srcY);
  18.145 -    FB_dst_to_xy(this, dst, &dstX, &dstY);
  18.146 -
  18.147 -    /* Adjust for the current blit rectangles */
  18.148 -    srcX += srcrect->x;
  18.149 -    srcY += srcrect->y;
  18.150 -    dstX += dstrect->x;
  18.151 -    dstY += dstrect->y;
  18.152 -
  18.153 -    RIVA_FIFO_FREE(Blt, 3);
  18.154 -    Blt->TopLeftSrc = (srcY << 16) | srcX;
  18.155 -    Blt->TopLeftDst = (dstY << 16) | dstX;
  18.156 -    Blt->WidthHeight = (dstH << 16) | dstW;
  18.157 -
  18.158 -    FB_AddBusySurface(src);
  18.159 -    FB_AddBusySurface(dst);
  18.160 -
  18.161 -    if (dst == this->screen) {
  18.162 -        SDL_mutexV(hw_lock);
  18.163 -    }
  18.164 -    return (0);
  18.165 -}
  18.166 -
  18.167 -static int
  18.168 -CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
  18.169 -{
  18.170 -    int accelerated;
  18.171 -
  18.172 -    /* Set initial acceleration on */
  18.173 -    src->flags |= SDL_HWACCEL;
  18.174 -
  18.175 -    /* Set the surface attributes */
  18.176 -    if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
  18.177 -        if (!this->info.blit_hw_A) {
  18.178 -            src->flags &= ~SDL_HWACCEL;
  18.179 -        }
  18.180 -    }
  18.181 -    if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
  18.182 -        if (!this->info.blit_hw_CC) {
  18.183 -            src->flags &= ~SDL_HWACCEL;
  18.184 -        }
  18.185 -    }
  18.186 -
  18.187 -    /* Check to see if final surface blit is accelerated */
  18.188 -    accelerated = !!(src->flags & SDL_HWACCEL);
  18.189 -    if (accelerated) {
  18.190 -        src->map->hw_blit = HWAccelBlit;
  18.191 -    }
  18.192 -    return (accelerated);
  18.193 -}
  18.194 -
  18.195 -void
  18.196 -FB_RivaAccel(_THIS, __u32 card)
  18.197 -{
  18.198 -    RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET);
  18.199 -
  18.200 -    /* We have hardware accelerated surface functions */
  18.201 -    this->CheckHWBlit = CheckHWBlit;
  18.202 -    wait_vbl = WaitVBL;
  18.203 -    switch (card) {
  18.204 -    case FB_ACCEL_NV3:
  18.205 -        wait_idle = NV3WaitIdle;
  18.206 -        break;
  18.207 -    case FB_ACCEL_NV4:
  18.208 -        wait_idle = NV4WaitIdle;
  18.209 -        break;
  18.210 -    default:
  18.211 -        /* Hmm... FIXME */
  18.212 -        break;
  18.213 -    }
  18.214 -    FifoEmptyCount = Rop->FifoFree;
  18.215 -
  18.216 -    /* The Riva has an accelerated color fill */
  18.217 -    this->info.blit_fill = 1;
  18.218 -    this->FillHWRect = FillHWRect;
  18.219 -
  18.220 -    /* The Riva has accelerated normal and colorkey blits. */
  18.221 -    this->info.blit_hw = 1;
  18.222 -#if 0                           /* Not yet implemented? */
  18.223 -    this->info.blit_hw_CC = 1;
  18.224 -    this->SetHWColorKey = SetHWColorKey;
  18.225 -#endif
  18.226 -
  18.227 -#if 0                           /* Not yet implemented? */
  18.228 -    /* The Riva has an accelerated alpha blit */
  18.229 -    this->info.blit_hw_A = 1;
  18.230 -    this->SetHWAlpha = SetHWAlpha;
  18.231 -#endif
  18.232 -}
  18.233 -
  18.234 -/* vi: set ts=4 sw=4 expandtab: */
    19.1 --- a/src/video/fbcon/SDL_fbriva.h	Wed Jan 19 19:51:04 2011 -0800
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,37 +0,0 @@
    19.4 -/*
    19.5 -    SDL - Simple DirectMedia Layer
    19.6 -    Copyright (C) 1997-2010 Sam Lantinga
    19.7 -
    19.8 -    This library is free software; you can redistribute it and/or
    19.9 -    modify it under the terms of the GNU Lesser General Public
   19.10 -    License as published by the Free Software Foundation; either
   19.11 -    version 2.1 of the License, or (at your option) any later version.
   19.12 -
   19.13 -    This library is distributed in the hope that it will be useful,
   19.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   19.16 -    Lesser General Public License for more details.
   19.17 -
   19.18 -    You should have received a copy of the GNU Lesser General Public
   19.19 -    License along with this library; if not, write to the Free Software
   19.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   19.21 -
   19.22 -    Sam Lantinga
   19.23 -    slouken@libsdl.org
   19.24 -*/
   19.25 -#include "SDL_config.h"
   19.26 -
   19.27 -/* Riva hardware acceleration for the SDL framebuffer console driver */
   19.28 -
   19.29 -#include "SDL_fbvideo.h"
   19.30 -
   19.31 -#ifndef FB_ACCEL_NV3
   19.32 -#define FB_ACCEL_NV3	27
   19.33 -#endif
   19.34 -#ifndef FB_ACCEL_NV4
   19.35 -#define FB_ACCEL_NV4	28
   19.36 -#endif
   19.37 -
   19.38 -/* Set up the driver for Riva acceleration */
   19.39 -extern void FB_RivaAccel(_THIS, __u32 card);
   19.40 -/* vi: set ts=4 sw=4 expandtab: */
    20.1 --- a/src/video/fbcon/SDL_fbvideo.c	Wed Jan 19 19:51:04 2011 -0800
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,1815 +0,0 @@
    20.4 -/*
    20.5 -    SDL - Simple DirectMedia Layer
    20.6 -    Copyright (C) 1997-2010 Sam Lantinga
    20.7 -
    20.8 -    This library is free software; you can redistribute it and/or
    20.9 -    modify it under the terms of the GNU Lesser General Public
   20.10 -    License as published by the Free Software Foundation; either
   20.11 -    version 2.1 of the License, or (at your option) any later version.
   20.12 -
   20.13 -    This library is distributed in the hope that it will be useful,
   20.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.16 -    Lesser General Public License for more details.
   20.17 -
   20.18 -    You should have received a copy of the GNU Lesser General Public
   20.19 -    License along with this library; if not, write to the Free Software
   20.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   20.21 -
   20.22 -    Sam Lantinga
   20.23 -    slouken@libsdl.org
   20.24 -*/
   20.25 -#include "SDL_config.h"
   20.26 -
   20.27 -/* Framebuffer console based SDL video driver implementation.
   20.28 -*/
   20.29 -
   20.30 -#include <stdio.h>
   20.31 -#include <fcntl.h>
   20.32 -#include <unistd.h>
   20.33 -#include <sys/ioctl.h>
   20.34 -#include <sys/mman.h>
   20.35 -
   20.36 -#ifndef HAVE_GETPAGESIZE
   20.37 -#include <asm/page.h>           /* For definition of PAGE_SIZE */
   20.38 -#endif
   20.39 -
   20.40 -#include <linux/vt.h>
   20.41 -
   20.42 -#include "SDL_video.h"
   20.43 -#include "SDL_mouse.h"
   20.44 -#include "../SDL_sysvideo.h"
   20.45 -#include "../SDL_pixels_c.h"
   20.46 -#include "../../events/SDL_events_c.h"
   20.47 -#include "SDL_fbvideo.h"
   20.48 -#include "SDL_fbmouse_c.h"
   20.49 -#include "SDL_fbevents_c.h"
   20.50 -#include "SDL_fb3dfx.h"
   20.51 -#include "SDL_fbmatrox.h"
   20.52 -#include "SDL_fbriva.h"
   20.53 -
   20.54 -/*#define FBCON_DEBUG*/
   20.55 -
   20.56 -#if defined(i386) && defined(FB_TYPE_VGA_PLANES)
   20.57 -#define VGA16_FBCON_SUPPORT
   20.58 -#include <sys/io.h>             /* For ioperm() */
   20.59 -#ifndef FB_AUX_VGA_PLANES_VGA4
   20.60 -#define FB_AUX_VGA_PLANES_VGA4	0
   20.61 -#endif
   20.62 -/*
   20.63 -static inline void outb (unsigned char value, unsigned short port)
   20.64 -{
   20.65 -  __asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "Nd" (port));
   20.66 -} 
   20.67 -*/
   20.68 -#endif /* FB_TYPE_VGA_PLANES */
   20.69 -
   20.70 -/* A list of video resolutions that we query for (sorted largest to smallest) */
   20.71 -static const SDL_Rect checkres[] = {
   20.72 -    {0, 0, 1600, 1200},         /* 16 bpp: 0x11E, or 286 */
   20.73 -    {0, 0, 1408, 1056},         /* 16 bpp: 0x19A, or 410 */
   20.74 -    {0, 0, 1280, 1024},         /* 16 bpp: 0x11A, or 282 */
   20.75 -    {0, 0, 1152, 864},          /* 16 bpp: 0x192, or 402 */
   20.76 -    {0, 0, 1024, 768},          /* 16 bpp: 0x117, or 279 */
   20.77 -    {0, 0, 960, 720},           /* 16 bpp: 0x18A, or 394 */
   20.78 -    {0, 0, 800, 600},           /* 16 bpp: 0x114, or 276 */
   20.79 -    {0, 0, 768, 576},           /* 16 bpp: 0x182, or 386 */
   20.80 -    {0, 0, 720, 576},           /* PAL */
   20.81 -    {0, 0, 720, 480},           /* NTSC */
   20.82 -    {0, 0, 640, 480},           /* 16 bpp: 0x111, or 273 */
   20.83 -    {0, 0, 640, 400},           /*  8 bpp: 0x100, or 256 */
   20.84 -    {0, 0, 512, 384},
   20.85 -    {0, 0, 320, 240},
   20.86 -    {0, 0, 320, 200}
   20.87 -};
   20.88 -
   20.89 -static const struct
   20.90 -{
   20.91 -    int xres;
   20.92 -    int yres;
   20.93 -    int pixclock;
   20.94 -    int left;
   20.95 -    int right;
   20.96 -    int upper;
   20.97 -    int lower;
   20.98 -    int hslen;
   20.99 -    int vslen;
  20.100 -    int sync;
  20.101 -    int vmode;
  20.102 -} vesa_timings[] = {
  20.103 -#ifdef USE_VESA_TIMINGS         /* Only tested on Matrox Millenium I */
  20.104 -    {
  20.105 -    640, 400, 39771, 48, 16, 39, 8, 96, 2, 2, 0},       /* 70 Hz */
  20.106 -    {
  20.107 -    640, 480, 39683, 48, 16, 33, 10, 96, 2, 0, 0},      /* 60 Hz */
  20.108 -    {
  20.109 -    768, 576, 26101, 144, 16, 28, 6, 112, 4, 0, 0},     /* 60 Hz */
  20.110 -    {
  20.111 -    800, 600, 24038, 144, 24, 28, 8, 112, 6, 0, 0},     /* 60 Hz */
  20.112 -    {
  20.113 -    960, 720, 17686, 144, 24, 28, 8, 112, 4, 0, 0},     /* 60 Hz */
  20.114 -    {
  20.115 -    1024, 768, 15386, 160, 32, 30, 4, 128, 4, 0, 0},    /* 60 Hz */
  20.116 -    {
  20.117 -    1152, 864, 12286, 192, 32, 30, 4, 128, 4, 0, 0},    /* 60 Hz */
  20.118 -    {
  20.119 -    1280, 1024, 9369, 224, 32, 32, 4, 136, 4, 0, 0},    /* 60 Hz */
  20.120 -    {
  20.121 -    1408, 1056, 8214, 256, 40, 32, 5, 144, 5, 0, 0},    /* 60 Hz */
  20.122 -    {
  20.123 -    1600, 1200, /*? */ 0, 272, 48, 32, 5, 152, 5, 0, 0},        /* 60 Hz */
  20.124 -#else
  20.125 -    /* You can generate these timings from your XF86Config file using
  20.126 -       the 'modeline2fb' perl script included with the fbset package.
  20.127 -       These timings were generated for Matrox Millenium I, 15" monitor.
  20.128 -     */
  20.129 -    {
  20.130 -    320, 200, 79440, 16, 16, 20, 4, 48, 1, 0, 2},       /* 70 Hz */
  20.131 -    {
  20.132 -    320, 240, 63492, 16, 16, 16, 4, 48, 2, 0, 2},       /* 72 Hz */
  20.133 -    {
  20.134 -    512, 384, 49603, 48, 16, 16, 1, 64, 3, 0, 0},       /* 78 Hz */
  20.135 -    {
  20.136 -    640, 400, 31746, 96, 32, 41, 1, 64, 3, 2, 0},       /* 85 Hz */
  20.137 -    {
  20.138 -    640, 480, 31746, 120, 16, 16, 1, 64, 3, 0, 0},      /* 75 Hz */
  20.139 -    {
  20.140 -    768, 576, 26101, 144, 16, 28, 6, 112, 4, 0, 0},     /* 60 Hz */
  20.141 -    {
  20.142 -    800, 600, 20000, 64, 56, 23, 37, 120, 6, 3, 0},     /* 72 Hz */
  20.143 -    {
  20.144 -    960, 720, 17686, 144, 24, 28, 8, 112, 4, 0, 0},     /* 60 Hz */
  20.145 -    {
  20.146 -    1024, 768, 13333, 144, 24, 29, 3, 136, 6, 0, 0},    /* 70 Hz */
  20.147 -    {
  20.148 -    1152, 864, 12286, 192, 32, 30, 4, 128, 4, 0, 0},    /* 60 Hz */
  20.149 -    {
  20.150 -    1280, 1024, 9369, 224, 32, 32, 4, 136, 4, 0, 0},    /* 60 Hz */
  20.151 -    {
  20.152 -    1408, 1056, 8214, 256, 40, 32, 5, 144, 5, 0, 0},    /* 60 Hz */
  20.153 -    {
  20.154 -    1600, 1200, /*? */ 0, 272, 48, 32, 5, 152, 5, 0, 0},        /* 60 Hz */
  20.155 -#endif
  20.156 -};
  20.157 -
  20.158 -/* Initialization/Query functions */
  20.159 -static int FB_VideoInit(_THIS, SDL_PixelFormat * vformat);
  20.160 -static SDL_Rect **FB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags);
  20.161 -static SDL_Surface *FB_SetVideoMode(_THIS, SDL_Surface * current, int width,
  20.162 -                                    int height, int bpp, Uint32 flags);
  20.163 -#ifdef VGA16_FBCON_SUPPORT
  20.164 -static SDL_Surface *FB_SetVGA16Mode(_THIS, SDL_Surface * current, int width,
  20.165 -                                    int height, int bpp, Uint32 flags);
  20.166 -#endif
  20.167 -static int FB_SetColors(_THIS, int firstcolor, int ncolors,
  20.168 -                        SDL_Color * colors);
  20.169 -static void FB_VideoQuit(_THIS);
  20.170 -
  20.171 -/* Hardware surface functions */
  20.172 -static int FB_InitHWSurfaces(_THIS, SDL_Surface * screen, char *base,
  20.173 -                             int size);
  20.174 -static void FB_FreeHWSurfaces(_THIS);
  20.175 -static int FB_AllocHWSurface(_THIS, SDL_Surface * surface);
  20.176 -static int FB_LockHWSurface(_THIS, SDL_Surface * surface);
  20.177 -static void FB_UnlockHWSurface(_THIS, SDL_Surface * surface);
  20.178 -static void FB_FreeHWSurface(_THIS, SDL_Surface * surface);
  20.179 -static void FB_WaitVBL(_THIS);
  20.180 -static void FB_WaitIdle(_THIS);
  20.181 -static int FB_FlipHWSurface(_THIS, SDL_Surface * surface);
  20.182 -
  20.183 -/* Internal palette functions */
  20.184 -static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
  20.185 -                           struct fb_var_screeninfo *vinfo);
  20.186 -static void FB_RestorePalette(_THIS);
  20.187 -
  20.188 -static int
  20.189 -SDL_getpagesize(void)
  20.190 -{
  20.191 -#ifdef HAVE_GETPAGESIZE
  20.192 -    return getpagesize();
  20.193 -#elif defined(PAGE_SIZE)
  20.194 -    return PAGE_SIZE;
  20.195 -#else
  20.196 -#error Can not determine system page size.
  20.197 -    /* this is what it USED to be in Linux... */
  20.198 -    return 4096;
  20.199 -#endif
  20.200 -}
  20.201 -
  20.202 -
  20.203 -/* Small wrapper for mmap() so we can play nicely with no-mmu hosts
  20.204 - * (non-mmu hosts disallow the MAP_SHARED flag) */
  20.205 -
  20.206 -static void *
  20.207 -do_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
  20.208 -{
  20.209 -    void *ret;
  20.210 -    ret = mmap(start, length, prot, flags, fd, offset);
  20.211 -    if (ret == (char *) -1 && (flags & MAP_SHARED)) {
  20.212 -        ret = mmap(start, length, prot,
  20.213 -                   (flags & ~MAP_SHARED) | MAP_PRIVATE, fd, offset);
  20.214 -    }
  20.215 -    return ret;
  20.216 -}
  20.217 -
  20.218 -/* FB driver bootstrap functions */
  20.219 -
  20.220 -static int
  20.221 -FB_Available(void)
  20.222 -{
  20.223 -    int console = -1;
  20.224 -    /* Added check for /fb/0 (devfs) */
  20.225 -    /* but - use environment variable first... if it fails, still check defaults */
  20.226 -    int idx = 0;
  20.227 -    const char *SDL_fbdevs[4] = { NULL, "/dev/fb0", "/dev/fb/0", NULL };
  20.228 -
  20.229 -    SDL_fbdevs[0] = SDL_getenv("SDL_FBDEV");
  20.230 -    if (!SDL_fbdevs[0])
  20.231 -        idx++;
  20.232 -    for (; SDL_fbdevs[idx]; idx++) {
  20.233 -        console = open(SDL_fbdevs[idx], O_RDWR, 0);
  20.234 -        if (console >= 0) {
  20.235 -            close(console);
  20.236 -            break;
  20.237 -        }
  20.238 -    }
  20.239 -    return (console >= 0);
  20.240 -}
  20.241 -
  20.242 -static void
  20.243 -FB_DeleteDevice(SDL_VideoDevice * device)
  20.244 -{
  20.245 -    SDL_free(device->hidden);
  20.246 -    SDL_free(device);
  20.247 -}
  20.248 -
  20.249 -static SDL_VideoDevice *
  20.250 -FB_CreateDevice(int devindex)
  20.251 -{
  20.252 -    SDL_VideoDevice *this;
  20.253 -
  20.254 -    /* Initialize all variables that we clean on shutdown */
  20.255 -    this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
  20.256 -    if (this) {
  20.257 -        SDL_memset(this, 0, (sizeof *this));
  20.258 -        this->hidden = (struct SDL_PrivateVideoData *)
  20.259 -            SDL_malloc((sizeof *this->hidden));
  20.260 -    }
  20.261 -    if ((this == NULL) || (this->hidden == NULL)) {
  20.262 -        SDL_OutOfMemory();
  20.263 -        if (this) {
  20.264 -            SDL_free(this);
  20.265 -        }
  20.266 -        return (0);
  20.267 -    }
  20.268 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
  20.269 -    wait_vbl = FB_WaitVBL;
  20.270 -    wait_idle = FB_WaitIdle;
  20.271 -    mouse_fd = -1;
  20.272 -    keyboard_fd = -1;
  20.273 -
  20.274 -    /* Set the function pointers */
  20.275 -    this->VideoInit = FB_VideoInit;
  20.276 -    this->ListModes = FB_ListModes;
  20.277 -    this->SetVideoMode = FB_SetVideoMode;
  20.278 -    this->SetColors = FB_SetColors;
  20.279 -    this->UpdateRects = NULL;
  20.280 -    this->VideoQuit = FB_VideoQuit;
  20.281 -    this->AllocHWSurface = FB_AllocHWSurface;
  20.282 -    this->CheckHWBlit = NULL;
  20.283 -    this->FillHWRect = NULL;
  20.284 -    this->SetHWColorKey = NULL;
  20.285 -    this->SetHWAlpha = NULL;
  20.286 -    this->LockHWSurface = FB_LockHWSurface;
  20.287 -    this->UnlockHWSurface = FB_UnlockHWSurface;
  20.288 -    this->FlipHWSurface = FB_FlipHWSurface;
  20.289 -    this->FreeHWSurface = FB_FreeHWSurface;
  20.290 -    this->SetCaption = NULL;
  20.291 -    this->SetIcon = NULL;
  20.292 -    this->IconifyWindow = NULL;
  20.293 -    this->GrabInput = NULL;
  20.294 -    this->GetWMInfo = NULL;
  20.295 -    this->InitOSKeymap = FB_InitOSKeymap;
  20.296 -    this->PumpEvents = FB_PumpEvents;
  20.297 -
  20.298 -    this->free = FB_DeleteDevice;
  20.299 -
  20.300 -    return this;
  20.301 -}
  20.302 -
  20.303 -VideoBootStrap FBCON_bootstrap = {
  20.304 -    "fbcon", "Linux Framebuffer Console",
  20.305 -    FB_Available, FB_CreateDevice
  20.306 -};
  20.307 -
  20.308 -#define FB_MODES_DB	"/etc/fb.modes"
  20.309 -
  20.310 -static int
  20.311 -read_fbmodes_line(FILE * f, char *line, int length)
  20.312 -{
  20.313 -    int blank;
  20.314 -    char *c;
  20.315 -    int i;
  20.316 -
  20.317 -    blank = 0;
  20.318 -    /* find a relevant line */
  20.319 -    do {
  20.320 -        if (!fgets(line, length, f))
  20.321 -            return 0;
  20.322 -        c = line;
  20.323 -        while (((*c == '\t') || (*c == ' ')) && (*c != 0))
  20.324 -            c++;
  20.325 -
  20.326 -        if ((*c == '\n') || (*c == '#') || (*c == 0))
  20.327 -            blank = 1;
  20.328 -        else
  20.329 -            blank = 0;
  20.330 -    } while (blank);
  20.331 -    /* remove whitespace at the begining of the string */
  20.332 -    i = 0;
  20.333 -    do {
  20.334 -        line[i] = c[i];
  20.335 -        i++;
  20.336 -    } while (c[i] != 0);
  20.337 -    return 1;
  20.338 -}
  20.339 -
  20.340 -static int
  20.341 -read_fbmodes_mode(FILE * f, struct fb_var_screeninfo *vinfo)
  20.342 -{
  20.343 -    char line[1024];
  20.344 -    char option[256];
  20.345 -
  20.346 -    /* Find a "geometry" */
  20.347 -    do {
  20.348 -        if (read_fbmodes_line(f, line, sizeof(line)) == 0)
  20.349 -            return 0;
  20.350 -        if (SDL_strncmp(line, "geometry", 8) == 0)
  20.351 -            break;
  20.352 -    } while (1);
  20.353 -
  20.354 -    SDL_sscanf(line, "geometry %d %d %d %d %d", &vinfo->xres, &vinfo->yres,
  20.355 -               &vinfo->xres_virtual, &vinfo->yres_virtual,
  20.356 -               &vinfo->bits_per_pixel);
  20.357 -    if (read_fbmodes_line(f, line, sizeof(line)) == 0)
  20.358 -        return 0;
  20.359 -
  20.360 -    SDL_sscanf(line, "timings %d %d %d %d %d %d %d", &vinfo->pixclock,
  20.361 -               &vinfo->left_margin, &vinfo->right_margin,
  20.362 -               &vinfo->upper_margin, &vinfo->lower_margin, &vinfo->hsync_len,
  20.363 -               &vinfo->vsync_len);
  20.364 -
  20.365 -    vinfo->sync = 0;
  20.366 -    vinfo->vmode = FB_VMODE_NONINTERLACED;
  20.367 -
  20.368 -    /* Parse misc options */
  20.369 -    do {
  20.370 -        if (read_fbmodes_line(f, line, sizeof(line)) == 0)
  20.371 -            return 0;
  20.372 -
  20.373 -        if (SDL_strncmp(line, "hsync", 5) == 0) {
  20.374 -            SDL_sscanf(line, "hsync %s", option);
  20.375 -            if (SDL_strncmp(option, "high", 4) == 0)
  20.376 -                vinfo->sync |= FB_SYNC_HOR_HIGH_ACT;
  20.377 -        } else if (SDL_strncmp(line, "vsync", 5) == 0) {
  20.378 -            SDL_sscanf(line, "vsync %s", option);
  20.379 -            if (SDL_strncmp(option, "high", 4) == 0)
  20.380 -                vinfo->sync |= FB_SYNC_VERT_HIGH_ACT;
  20.381 -        } else if (SDL_strncmp(line, "csync", 5) == 0) {
  20.382 -            SDL_sscanf(line, "csync %s", option);
  20.383 -            if (SDL_strncmp(option, "high", 4) == 0)
  20.384 -                vinfo->sync |= FB_SYNC_COMP_HIGH_ACT;
  20.385 -        } else if (SDL_strncmp(line, "extsync", 5) == 0) {
  20.386 -            SDL_sscanf(line, "extsync %s", option);
  20.387 -            if (SDL_strncmp(option, "true", 4) == 0)
  20.388 -                vinfo->sync |= FB_SYNC_EXT;
  20.389 -        } else if (SDL_strncmp(line, "laced", 5) == 0) {
  20.390 -            SDL_sscanf(line, "laced %s", option);
  20.391 -            if (SDL_strncmp(option, "true", 4) == 0)
  20.392 -                vinfo->vmode |= FB_VMODE_INTERLACED;
  20.393 -        } else if (SDL_strncmp(line, "double", 6) == 0) {
  20.394 -            SDL_sscanf(line, "double %s", option);
  20.395 -            if (SDL_strncmp(option, "true", 4) == 0)
  20.396 -                vinfo->vmode |= FB_VMODE_DOUBLE;
  20.397 -        }
  20.398 -    } while (SDL_strncmp(line, "endmode", 7) != 0);
  20.399 -
  20.400 -    return 1;
  20.401 -}
  20.402 -
  20.403 -static int
  20.404 -FB_CheckMode(_THIS, struct fb_var_screeninfo *vinfo,
  20.405 -             int index, unsigned int *w, unsigned int *h)
  20.406 -{
  20.407 -    int mode_okay;
  20.408 -
  20.409 -    mode_okay = 0;
  20.410 -    vinfo->bits_per_pixel = (index + 1) * 8;
  20.411 -    vinfo->xres = *w;
  20.412 -    vinfo->xres_virtual = *w;
  20.413 -    vinfo->yres = *h;
  20.414 -    vinfo->yres_virtual = *h;
  20.415 -    vinfo->activate = FB_ACTIVATE_TEST;
  20.416 -    if (ioctl(console_fd, FBIOPUT_VSCREENINFO, vinfo) == 0) {
  20.417 -#ifdef FBCON_DEBUG
  20.418 -        fprintf(stderr,
  20.419 -                "Checked mode %dx%d at %d bpp, got mode %dx%d at %d bpp\n",
  20.420 -                *w, *h, (index + 1) * 8, vinfo->xres, vinfo->yres,
  20.421 -                vinfo->bits_per_pixel);
  20.422 -#endif
  20.423 -        if ((((vinfo->bits_per_pixel + 7) / 8) - 1) == index) {
  20.424 -            *w = vinfo->xres;
  20.425 -            *h = vinfo->yres;
  20.426 -            mode_okay = 1;
  20.427 -        }
  20.428 -    }
  20.429 -    return mode_okay;
  20.430 -}
  20.431 -
  20.432 -static int
  20.433 -FB_AddMode(_THIS, int index, unsigned int w, unsigned int h,
  20.434 -           int check_timings)
  20.435 -{
  20.436 -    SDL_Rect *mode;
  20.437 -    int i;
  20.438 -    int next_mode;
  20.439 -
  20.440 -    /* Check to see if we already have this mode */
  20.441 -    if (SDL_nummodes[index] > 0) {
  20.442 -        mode = SDL_modelist[index][SDL_nummodes[index] - 1];
  20.443 -        if ((mode->w == w) && (mode->h == h)) {
  20.444 -#ifdef FBCON_DEBUG
  20.445 -            fprintf(stderr,
  20.446 -                    "We already have mode %dx%d at %d bytes per pixel\n",
  20.447 -                    w, h, index + 1);
  20.448 -#endif
  20.449 -            return (0);
  20.450 -        }
  20.451 -    }
  20.452 -
  20.453 -    /* Only allow a mode if we have a valid timing for it */
  20.454 -    if (check_timings) {
  20.455 -        int found_timing = 0;
  20.456 -        for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) {
  20.457 -            if ((w == vesa_timings[i].xres) &&
  20.458 -                (h == vesa_timings[i].yres) && vesa_timings[i].pixclock) {
  20.459 -                found_timing = 1;
  20.460 -                break;
  20.461 -            }
  20.462 -        }
  20.463 -        if (!found_timing) {
  20.464 -#ifdef FBCON_DEBUG
  20.465 -            fprintf(stderr, "No valid timing line for mode %dx%d\n", w, h);
  20.466 -#endif
  20.467 -            return (0);
  20.468 -        }
  20.469 -    }
  20.470 -
  20.471 -    /* Set up the new video mode rectangle */
  20.472 -    mode = (SDL_Rect *) SDL_malloc(sizeof *mode);
  20.473 -    if (mode == NULL) {
  20.474 -        SDL_OutOfMemory();
  20.475 -        return (-1);
  20.476 -    }
  20.477 -    mode->x = 0;
  20.478 -    mode->y = 0;
  20.479 -    mode->w = w;
  20.480 -    mode->h = h;
  20.481 -#ifdef FBCON_DEBUG
  20.482 -    fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h,
  20.483 -            index + 1);
  20.484 -#endif
  20.485 -
  20.486 -    /* Allocate the new list of modes, and fill in the new mode */
  20.487 -    next_mode = SDL_nummodes[index];
  20.488 -    SDL_modelist[index] = (SDL_Rect **)
  20.489 -        SDL_realloc(SDL_modelist[index],
  20.490 -                    (1 + next_mode + 1) * sizeof(SDL_Rect *));
  20.491 -    if (SDL_modelist[index] == NULL) {
  20.492 -        SDL_OutOfMemory();
  20.493 -        SDL_nummodes[index] = 0;
  20.494 -        SDL_free(mode);
  20.495 -        return (-1);
  20.496 -    }
  20.497 -    SDL_modelist[index][next_mode] = mode;
  20.498 -    SDL_modelist[index][next_mode + 1] = NULL;
  20.499 -    SDL_nummodes[index]++;
  20.500 -
  20.501 -    return (0);
  20.502 -}
  20.503 -
  20.504 -static int
  20.505 -cmpmodes(const void *va, const void *vb)
  20.506 -{
  20.507 -    const SDL_Rect *a = *(const SDL_Rect **) va;
  20.508 -    const SDL_Rect *b = *(const SDL_Rect **) vb;
  20.509 -    if (a->h == b->h)
  20.510 -        return b->w - a->w;
  20.511 -    else
  20.512 -        return b->h - a->h;
  20.513 -}
  20.514 -
  20.515 -static void
  20.516 -FB_SortModes(_THIS)
  20.517 -{
  20.518 -    int i;
  20.519 -    for (i = 0; i < NUM_MODELISTS; ++i) {
  20.520 -        if (SDL_nummodes[i] > 0) {
  20.521 -            SDL_qsort(SDL_modelist[i], SDL_nummodes[i],
  20.522 -                      sizeof *SDL_modelist[i], cmpmodes);
  20.523 -        }
  20.524 -    }
  20.525 -}
  20.526 -
  20.527 -static int
  20.528 -FB_VideoInit(_THIS, SDL_PixelFormat * vformat)
  20.529 -{
  20.530 -    const int pagesize = SDL_getpagesize();
  20.531 -    struct fb_fix_screeninfo finfo;
  20.532 -    struct fb_var_screeninfo vinfo;
  20.533 -    int i, j;
  20.534 -    int current_index;
  20.535 -    unsigned int current_w;
  20.536 -    unsigned int current_h;
  20.537 -    const char *SDL_fbdev;
  20.538 -    FILE *modesdb;
  20.539 -
  20.540 -    /* Initialize the library */
  20.541 -    SDL_fbdev = SDL_getenv("SDL_FBDEV");
  20.542 -    if (SDL_fbdev == NULL) {
  20.543 -        SDL_fbdev = "/dev/fb0";
  20.544 -    }
  20.545 -    console_fd = open(SDL_fbdev, O_RDWR, 0);
  20.546 -    if (console_fd < 0) {
  20.547 -        SDL_SetError("Unable to open %s", SDL_fbdev);
  20.548 -        return (-1);
  20.549 -    }
  20.550 -#if !SDL_THREADS_DISABLED
  20.551 -    /* Create the hardware surface lock mutex */
  20.552 -    hw_lock = SDL_CreateMutex();
  20.553 -    if (hw_lock == NULL) {
  20.554 -        SDL_SetError("Unable to create lock mutex");
  20.555 -        FB_VideoQuit(this);
  20.556 -        return (-1);
  20.557 -    }
  20.558 -#endif
  20.559 -
  20.560 -    /* Get the type of video hardware */
  20.561 -    if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
  20.562 -        SDL_SetError("Couldn't get console hardware info");
  20.563 -        FB_VideoQuit(this);
  20.564 -        return (-1);
  20.565 -    }
  20.566 -    switch (finfo.type) {
  20.567 -    case FB_TYPE_PACKED_PIXELS:
  20.568 -        /* Supported, no worries.. */
  20.569 -        break;
  20.570 -#ifdef VGA16_FBCON_SUPPORT
  20.571 -    case FB_TYPE_VGA_PLANES:
  20.572 -        /* VGA16 is supported, but that's it */
  20.573 -        if (finfo.type_aux == FB_AUX_VGA_PLANES_VGA4) {
  20.574 -            if (ioperm(0x3b4, 0x3df - 0x3b4 + 1, 1) < 0) {
  20.575 -                SDL_SetError("No I/O port permissions");
  20.576 -                FB_VideoQuit(this);
  20.577 -                return (-1);
  20.578 -            }
  20.579 -            this->SetVideoMode = FB_SetVGA16Mode;
  20.580 -            break;
  20.581 -        }
  20.582 -        /* Fall through to unsupported case */
  20.583 -#endif /* VGA16_FBCON_SUPPORT */
  20.584 -    default:
  20.585 -        SDL_SetError("Unsupported console hardware");
  20.586 -        FB_VideoQuit(this);
  20.587 -        return (-1);
  20.588 -    }
  20.589 -    switch (finfo.visual) {
  20.590 -    case FB_VISUAL_TRUECOLOR:
  20.591 -    case FB_VISUAL_PSEUDOCOLOR:
  20.592 -    case FB_VISUAL_STATIC_PSEUDOCOLOR:
  20.593 -    case FB_VISUAL_DIRECTCOLOR:
  20.594 -        break;
  20.595 -    default:
  20.596 -        SDL_SetError("Unsupported console hardware");
  20.597 -        FB_VideoQuit(this);
  20.598 -        return (-1);
  20.599 -    }
  20.600 -
  20.601 -    /* Check if the user wants to disable hardware acceleration */
  20.602 -    {
  20.603 -        const char *fb_accel;
  20.604 -        fb_accel = SDL_getenv("SDL_FBACCEL");
  20.605 -        if (fb_accel) {
  20.606 -            finfo.accel = SDL_atoi(fb_accel);
  20.607 -        }
  20.608 -    }
  20.609 -
  20.610 -    /* Memory map the device, compensating for buggy PPC mmap() */
  20.611 -    mapped_offset = (((long) finfo.smem_start) -
  20.612 -                     (((long) finfo.smem_start) & ~(pagesize - 1)));
  20.613 -    mapped_memlen = finfo.smem_len + mapped_offset;
  20.614 -    mapped_mem = do_mmap(NULL, mapped_memlen,
  20.615 -                         PROT_READ | PROT_WRITE, MAP_SHARED, console_fd, 0);
  20.616 -    if (mapped_mem == (char *) -1) {
  20.617 -        SDL_SetError("Unable to memory map the video hardware");
  20.618 -        mapped_mem = NULL;
  20.619 -        FB_VideoQuit(this);
  20.620 -        return (-1);
  20.621 -    }
  20.622 -
  20.623 -    /* Determine the current screen depth */
  20.624 -    if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) {
  20.625 -        SDL_SetError("Couldn't get console pixel format");
  20.626 -        FB_VideoQuit(this);
  20.627 -        return (-1);
  20.628 -    }
  20.629 -    vformat->BitsPerPixel = vinfo.bits_per_pixel;
  20.630 -    if (vformat->BitsPerPixel < 8) {
  20.631 -        /* Assuming VGA16, we handle this via a shadow framebuffer */
  20.632 -        vformat->BitsPerPixel = 8;
  20.633 -    }
  20.634 -    for (i = 0; i < vinfo.red.length; ++i) {
  20.635 -        vformat->Rmask <<= 1;
  20.636 -        vformat->Rmask |= (0x00000001 << vinfo.red.offset);
  20.637 -    }
  20.638 -    for (i = 0; i < vinfo.green.length; ++i) {
  20.639 -        vformat->Gmask <<= 1;
  20.640 -        vformat->Gmask |= (0x00000001 << vinfo.green.offset);
  20.641 -    }
  20.642 -    for (i = 0; i < vinfo.blue.length; ++i) {
  20.643 -        vformat->Bmask <<= 1;
  20.644 -        vformat->Bmask |= (0x00000001 << vinfo.blue.offset);
  20.645 -    }
  20.646 -    saved_vinfo = vinfo;
  20.647 -
  20.648 -    /* Save hardware palette, if needed */
  20.649 -    FB_SavePalette(this, &finfo, &vinfo);
  20.650 -
  20.651 -    /* If the I/O registers are available, memory map them so we
  20.652 -       can take advantage of any supported hardware acceleration.
  20.653 -     */
  20.654 -    vinfo.accel_flags = 0;      /* Temporarily reserve registers */
  20.655 -    ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo);
  20.656 -    if (finfo.accel && finfo.mmio_len) {
  20.657 -        mapped_iolen = finfo.mmio_len;
  20.658 -        mapped_io = do_mmap(NULL, mapped_iolen, PROT_READ | PROT_WRITE,
  20.659 -                            MAP_SHARED, console_fd, mapped_memlen);
  20.660 -        if (mapped_io == (char *) -1) {
  20.661 -            /* Hmm, failed to memory map I/O registers */
  20.662 -            mapped_io = NULL;
  20.663 -        }
  20.664 -    }
  20.665 -
  20.666 -    /* Query for the list of available video modes */
  20.667 -    current_w = vinfo.xres;
  20.668 -    current_h = vinfo.yres;
  20.669 -    current_index = ((vinfo.bits_per_pixel + 7) / 8) - 1;
  20.670 -    modesdb = fopen(FB_MODES_DB, "r");
  20.671 -    for (i = 0; i < NUM_MODELISTS; ++i) {
  20.672 -        SDL_nummodes[i] = 0;
  20.673 -        SDL_modelist[i] = NULL;
  20.674 -    }
  20.675 -    if (SDL_getenv("SDL_FB_BROKEN_MODES") != NULL) {
  20.676 -        FB_AddMode(this, current_index, current_w, current_h, 0);
  20.677 -    } else if (modesdb) {
  20.678 -        while (read_fbmodes_mode(modesdb, &vinfo)) {
  20.679 -            for (i = 0; i < NUM_MODELISTS; ++i) {
  20.680 -                unsigned int w, h;
  20.681 -
  20.682 -                /* See if we are querying for the current mode */
  20.683 -                w = vinfo.xres;
  20.684 -                h = vinfo.yres;
  20.685 -                if (i == current_index) {
  20.686 -                    if ((current_w > w) || (current_h > h)) {
  20.687 -                        /* Only check once */
  20.688 -                        FB_AddMode(this, i, current_w, current_h, 0);
  20.689 -                        current_index = -1;
  20.690 -                    }
  20.691 -                }
  20.692 -                if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
  20.693 -                    FB_AddMode(this, i, w, h, 0);
  20.694 -                }
  20.695 -            }
  20.696 -        }
  20.697 -        fclose(modesdb);
  20.698 -        FB_SortModes(this);
  20.699 -    } else {
  20.700 -        for (i = 0; i < NUM_MODELISTS; ++i) {
  20.701 -            for (j = 0; j < (sizeof(checkres) / sizeof(checkres[0])); ++j) {
  20.702 -                unsigned int w, h;
  20.703 -
  20.704 -                /* See if we are querying for the current mode */
  20.705 -                w = checkres[j].w;
  20.706 -                h = checkres[j].h;
  20.707 -                if (i == current_index) {
  20.708 -                    if ((current_w > w) || (current_h > h)) {
  20.709 -                        /* Only check once */
  20.710 -                        FB_AddMode(this, i, current_w, current_h, 0);
  20.711 -                        current_index = -1;
  20.712 -                    }
  20.713 -                }
  20.714 -                if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
  20.715 -                    FB_AddMode(this, i, w, h, 1);
  20.716 -                }
  20.717 -            }
  20.718 -        }
  20.719 -    }
  20.720 -
  20.721 -    /* Fill in our hardware acceleration capabilities */
  20.722 -    this->info.current_w = current_w;
  20.723 -    this->info.current_h = current_h;
  20.724 -    this->info.wm_available = 0;
  20.725 -    this->info.hw_available = 1;
  20.726 -    this->info.video_mem = finfo.smem_len / 1024;
  20.727 -    if (mapped_io) {
  20.728 -        switch (finfo.accel) {
  20.729 -        case FB_ACCEL_MATROX_MGA2064W:
  20.730 -        case FB_ACCEL_MATROX_MGA1064SG:
  20.731 -        case FB_ACCEL_MATROX_MGA2164W:
  20.732 -        case FB_ACCEL_MATROX_MGA2164W_AGP:
  20.733 -        case FB_ACCEL_MATROX_MGAG100:
  20.734 -            /*case FB_ACCEL_MATROX_MGAG200: G200 acceleration broken! */
  20.735 -        case FB_ACCEL_MATROX_MGAG400:
  20.736 -#ifdef FBACCEL_DEBUG
  20.737 -            printf("Matrox hardware accelerator!\n");
  20.738 -#endif
  20.739 -            FB_MatroxAccel(this, finfo.accel);
  20.740 -            break;
  20.741 -        case FB_ACCEL_3DFX_BANSHEE:
  20.742 -#ifdef FBACCEL_DEBUG
  20.743 -            printf("3DFX hardware accelerator!\n");
  20.744 -#endif
  20.745 -            FB_3DfxAccel(this, finfo.accel);
  20.746 -            break;
  20.747 -        case FB_ACCEL_NV3:
  20.748 -        case FB_ACCEL_NV4:
  20.749 -#ifdef FBACCEL_DEBUG
  20.750 -            printf("NVidia hardware accelerator!\n");
  20.751 -#endif
  20.752 -            FB_RivaAccel(this, finfo.accel);
  20.753 -            break;
  20.754 -        default:
  20.755 -#ifdef FBACCEL_DEBUG
  20.756 -            printf("Unknown hardware accelerator.\n");
  20.757 -#endif
  20.758 -            break;
  20.759 -        }
  20.760 -    }
  20.761 -
  20.762 -    /* Enable mouse and keyboard support */
  20.763 -    if (FB_OpenKeyboard(this) < 0) {
  20.764 -        FB_VideoQuit(this);
  20.765 -        return (-1);
  20.766 -    }
  20.767 -    if (FB_OpenMouse(this) < 0) {
  20.768 -        const char *sdl_nomouse;
  20.769 -
  20.770 -        sdl_nomouse = SDL_getenv("SDL_NOMOUSE");
  20.771 -        if (!sdl_nomouse) {
  20.772 -            SDL_SetError("Unable to open mouse");
  20.773 -            FB_VideoQuit(this);
  20.774 -            return (-1);
  20.775 -        }
  20.776 -    }
  20.777 -
  20.778 -    /* We're done! */
  20.779 -    return (0);
  20.780 -}
  20.781 -
  20.782 -static SDL_Rect **
  20.783 -FB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
  20.784 -{
  20.785 -    return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]);
  20.786 -}
  20.787 -
  20.788 -/* Various screen update functions available */
  20.789 -static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
  20.790 -#ifdef VGA16_FBCON_SUPPORT
  20.791 -static void FB_VGA16Update(_THIS, int numrects, SDL_Rect * rects);
  20.792 -#endif
  20.793 -
  20.794 -#ifdef FBCON_DEBUG
  20.795 -static void
  20.796 -print_vinfo(struct fb_var_screeninfo *vinfo)
  20.797 -{
  20.798 -    fprintf(stderr, "Printing vinfo:\n");
  20.799 -    fprintf(stderr, "\txres: %d\n", vinfo->xres);
  20.800 -    fprintf(stderr, "\tyres: %d\n", vinfo->yres);
  20.801 -    fprintf(stderr, "\txres_virtual: %d\n", vinfo->xres_virtual);
  20.802 -    fprintf(stderr, "\tyres_virtual: %d\n", vinfo->yres_virtual);
  20.803 -    fprintf(stderr, "\txoffset: %d\n", vinfo->xoffset);
  20.804 -    fprintf(stderr, "\tyoffset: %d\n", vinfo->yoffset);
  20.805 -    fprintf(stderr, "\tbits_per_pixel: %d\n", vinfo->bits_per_pixel);
  20.806 -    fprintf(stderr, "\tgrayscale: %d\n", vinfo->grayscale);
  20.807 -    fprintf(stderr, "\tnonstd: %d\n", vinfo->nonstd);
  20.808 -    fprintf(stderr, "\tactivate: %d\n", vinfo->activate);
  20.809 -    fprintf(stderr, "\theight: %d\n", vinfo->height);
  20.810 -    fprintf(stderr, "\twidth: %d\n", vinfo->width);
  20.811 -    fprintf(stderr, "\taccel_flags: %d\n", vinfo->accel_flags);
  20.812 -    fprintf(stderr, "\tpixclock: %d\n", vinfo->pixclock);
  20.813 -    fprintf(stderr, "\tleft_margin: %d\n", vinfo->left_margin);
  20.814 -    fprintf(stderr, "\tright_margin: %d\n", vinfo->right_margin);
  20.815 -    fprintf(stderr, "\tupper_margin: %d\n", vinfo->upper_margin);
  20.816 -    fprintf(stderr, "\tlower_margin: %d\n", vinfo->lower_margin);
  20.817 -    fprintf(stderr, "\thsync_len: %d\n", vinfo->hsync_len);
  20.818 -    fprintf(stderr, "\tvsync_len: %d\n", vinfo->vsync_len);
  20.819 -    fprintf(stderr, "\tsync: %d\n", vinfo->sync);
  20.820 -    fprintf(stderr, "\tvmode: %d\n", vinfo->vmode);
  20.821 -    fprintf(stderr, "\tred: %d/%d\n", vinfo->red.length, vinfo->red.offset);
  20.822 -    fprintf(stderr, "\tgreen: %d/%d\n", vinfo->green.length,
  20.823 -            vinfo->green.offset);
  20.824 -    fprintf(stderr, "\tblue: %d/%d\n", vinfo->blue.length,
  20.825 -            vinfo->blue.offset);
  20.826 -    fprintf(stderr, "\talpha: %d/%d\n", vinfo->transp.length,
  20.827 -            vinfo->transp.offset);
  20.828 -}
  20.829 -
  20.830 -static void
  20.831 -print_finfo(struct fb_fix_screeninfo *finfo)
  20.832 -{
  20.833 -    fprintf(stderr, "Printing finfo:\n");
  20.834 -    fprintf(stderr, "\tsmem_start = %p\n", (char *) finfo->smem_start);
  20.835 -    fprintf(stderr, "\tsmem_len = %d\n", finfo->smem_len);
  20.836 -    fprintf(stderr, "\ttype = %d\n", finfo->type);
  20.837 -    fprintf(stderr, "\ttype_aux = %d\n", finfo->type_aux);
  20.838 -    fprintf(stderr, "\tvisual = %d\n", finfo->visual);
  20.839 -    fprintf(stderr, "\txpanstep = %d\n", finfo->xpanstep);
  20.840 -    fprintf(stderr, "\typanstep = %d\n", finfo->ypanstep);
  20.841 -    fprintf(stderr, "\tywrapstep = %d\n", finfo->ywrapstep);
  20.842 -    fprintf(stderr, "\tline_length = %d\n", finfo->line_length);
  20.843 -    fprintf(stderr, "\tmmio_start = %p\n", (char *) finfo->mmio_start);
  20.844 -    fprintf(stderr, "\tmmio_len = %d\n", finfo->mmio_len);
  20.845 -    fprintf(stderr, "\taccel = %d\n", finfo->accel);
  20.846 -}
  20.847 -#endif
  20.848 -
  20.849 -static int
  20.850 -choose_fbmodes_mode(struct fb_var_screeninfo *vinfo)
  20.851 -{
  20.852 -    int matched;
  20.853 -    FILE *modesdb;
  20.854 -    struct fb_var_screeninfo cinfo;
  20.855 -
  20.856 -    matched = 0;
  20.857 -    modesdb = fopen(FB_MODES_DB, "r");
  20.858 -    if (modesdb) {
  20.859 -        /* Parse the mode definition file */
  20.860 -        while (read_fbmodes_mode(modesdb, &cinfo)) {
  20.861 -            if ((vinfo->xres == cinfo.xres && vinfo->yres == cinfo.yres)
  20.862 -                && (!matched
  20.863 -                    || (vinfo->bits_per_pixel == cinfo.bits_per_pixel))) {
  20.864 -                vinfo->pixclock = cinfo.pixclock;
  20.865 -                vinfo->left_margin = cinfo.left_margin;
  20.866 -                vinfo->right_margin = cinfo.right_margin;
  20.867 -                vinfo->upper_margin = cinfo.upper_margin;
  20.868 -                vinfo->lower_margin = cinfo.lower_margin;
  20.869 -                vinfo->hsync_len = cinfo.hsync_len;
  20.870 -                vinfo->vsync_len = cinfo.vsync_len;
  20.871 -                if (matched) {
  20.872 -                    break;
  20.873 -                }
  20.874 -                matched = 1;
  20.875 -            }
  20.876 -        }
  20.877 -        fclose(modesdb);
  20.878 -    }
  20.879 -    return (matched);
  20.880 -}
  20.881 -
  20.882 -static int
  20.883 -choose_vesa_mode(struct fb_var_screeninfo *vinfo)
  20.884 -{
  20.885 -    int matched;
  20.886 -    int i;
  20.887 -
  20.888 -    /* Check for VESA timings */
  20.889 -    matched = 0;
  20.890 -    for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) {
  20.891 -        if ((vinfo->xres == vesa_timings[i].xres) &&
  20.892 -            (vinfo->yres == vesa_timings[i].yres)) {
  20.893 -#ifdef FBCON_DEBUG
  20.894 -            fprintf(stderr, "Using VESA timings for %dx%d\n",
  20.895 -                    vinfo->xres, vinfo->yres);
  20.896 -#endif
  20.897 -            if (vesa_timings[i].pixclock) {
  20.898 -                vinfo->pixclock = vesa_timings[i].pixclock;
  20.899 -            }
  20.900 -            vinfo->left_margin = vesa_timings[i].left;
  20.901 -            vinfo->right_margin = vesa_timings[i].right;
  20.902 -            vinfo->upper_margin = vesa_timings[i].upper;
  20.903 -            vinfo->lower_margin = vesa_timings[i].lower;
  20.904 -            vinfo->hsync_len = vesa_timings[i].hslen;
  20.905 -            vinfo->vsync_len = vesa_timings[i].vslen;
  20.906 -            vinfo->sync = vesa_timings[i].sync;
  20.907 -            vinfo->vmode = vesa_timings[i].vmode;
  20.908 -            matched = 1;
  20.909 -            break;
  20.910 -        }
  20.911 -    }
  20.912 -    return (matched);
  20.913 -}
  20.914 -
  20.915 -#ifdef VGA16_FBCON_SUPPORT
  20.916 -static SDL_Surface *
  20.917 -FB_SetVGA16Mode(_THIS, SDL_Surface * current,
  20.918 -                int width, int height, int bpp, Uint32 flags)
  20.919 -{
  20.920 -    struct fb_fix_screeninfo finfo;
  20.921 -    struct fb_var_screeninfo vinfo;
  20.922 -
  20.923 -    /* Set the terminal into graphics mode */
  20.924 -    if (FB_EnterGraphicsMode(this) < 0) {
  20.925 -        return (NULL);
  20.926 -    }
  20.927 -
  20.928 -    /* Restore the original palette */
  20.929 -    FB_RestorePalette(this);
  20.930 -
  20.931 -    /* Set the video mode and get the final screen format */
  20.932 -    if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) {
  20.933 -        SDL_SetError("Couldn't get console screen info");
  20.934 -        return (NULL);
  20.935 -    }
  20.936 -    cache_vinfo = vinfo;
  20.937 -#ifdef FBCON_DEBUG
  20.938 -    fprintf(stderr, "Printing actual vinfo:\n");
  20.939 -    print_vinfo(&vinfo);
  20.940 -#endif
  20.941 -    if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) {
  20.942 -        return (NULL);
  20.943 -    }
  20.944 -    current->format->palette->ncolors = 16;
  20.945 -
  20.946 -    /* Get the fixed information about the console hardware.
  20.947 -       This is necessary since finfo.line_length changes.
  20.948 -     */
  20.949 -    if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
  20.950 -        SDL_SetError("Couldn't get console hardware info");
  20.951 -        return (NULL);
  20.952 -    }
  20.953 -#ifdef FBCON_DEBUG
  20.954 -    fprintf(stderr, "Printing actual finfo:\n");
  20.955 -    print_finfo(&finfo);
  20.956 -#endif
  20.957 -
  20.958 -    /* Save hardware palette, if needed */
  20.959 -    FB_SavePalette(this, &finfo, &vinfo);
  20.960 -
  20.961 -    /* Set up the new mode framebuffer */
  20.962 -    current->flags = SDL_FULLSCREEN;
  20.963 -    current->w = vinfo.xres;
  20.964 -    current->h = vinfo.yres;
  20.965 -    current->pitch = current->w;
  20.966 -    current->pixels = SDL_malloc(current->h * current->pitch);
  20.967 -
  20.968 -    /* Set the update rectangle function */
  20.969 -    this->UpdateRects = FB_VGA16Update;
  20.970 -
  20.971 -    /* We're done */
  20.972 -    return (current);
  20.973 -}
  20.974 -#endif /* VGA16_FBCON_SUPPORT */
  20.975 -
  20.976 -static SDL_Surface *
  20.977 -FB_SetVideoMode(_THIS, SDL_Surface * current,
  20.978 -                int width, int height, int bpp, Uint32 flags)
  20.979 -{
  20.980 -    struct fb_fix_screeninfo finfo;
  20.981 -    struct fb_var_screeninfo vinfo;
  20.982 -    int i;
  20.983 -    Uint32 Rmask;
  20.984 -    Uint32 Gmask;
  20.985 -    Uint32 Bmask;
  20.986 -    char *surfaces_mem;
  20.987 -    int surfaces_len;
  20.988 -
  20.989 -    /* Set the terminal into graphics mode */
  20.990 -    if (FB_EnterGraphicsMode(this) < 0) {
  20.991 -        return (NULL);
  20.992 -    }
  20.993 -
  20.994 -    /* Restore the original palette */
  20.995 -    FB_RestorePalette(this);
  20.996 -
  20.997 -    /* Set the video mode and get the final screen format */
  20.998 -    if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) {
  20.999 -        SDL_SetError("Couldn't get console screen info");
 20.1000 -        return (NULL);
 20.1001 -    }
 20.1002 -#ifdef FBCON_DEBUG
 20.1003 -    fprintf(stderr, "Printing original vinfo:\n");
 20.1004 -    print_vinfo(&vinfo);
 20.1005 -#endif
 20.1006 -    if ((vinfo.xres != width) || (vinfo.yres != height) ||
 20.1007 -        (vinfo.bits_per_pixel != bpp) || (flags & SDL_DOUBLEBUF)) {
 20.1008 -        vinfo.activate = FB_ACTIVATE_NOW;
 20.1009 -        vinfo.accel_flags = 0;
 20.1010 -        vinfo.bits_per_pixel = bpp;
 20.1011 -        vinfo.xres = width;
 20.1012 -        vinfo.xres_virtual = width;
 20.1013 -        vinfo.yres = height;
 20.1014 -        if (flags & SDL_DOUBLEBUF) {
 20.1015 -            vinfo.yres_virtual = height * 2;
 20.1016 -        } else {
 20.1017 -            vinfo.yres_virtual = height;
 20.1018 -        }
 20.1019 -        vinfo.xoffset = 0;
 20.1020 -        vinfo.yoffset = 0;
 20.1021 -        vinfo.red.length = vinfo.red.offset = 0;
 20.1022 -        vinfo.green.length = vinfo.green.offset = 0;
 20.1023 -        vinfo.blue.length = vinfo.blue.offset = 0;
 20.1024 -        vinfo.transp.length = vinfo.transp.offset = 0;
 20.1025 -        if (!choose_fbmodes_mode(&vinfo)) {
 20.1026 -            choose_vesa_mode(&vinfo);
 20.1027 -        }
 20.1028 -#ifdef FBCON_DEBUG
 20.1029 -        fprintf(stderr, "Printing wanted vinfo:\n");
 20.1030 -        print_vinfo(&vinfo);
 20.1031 -#endif
 20.1032 -        if (ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) {
 20.1033 -            vinfo.yres_virtual = height;
 20.1034 -            if (ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) {
 20.1035 -                SDL_SetError("Couldn't set console screen info");
 20.1036 -                return (NULL);
 20.1037 -            }
 20.1038 -        }
 20.1039 -    } else {
 20.1040 -        int maxheight;
 20.1041 -
 20.1042 -        /* Figure out how much video memory is available */
 20.1043 -        if (flags & SDL_DOUBLEBUF) {
 20.1044 -            maxheight = height * 2;
 20.1045 -        } else {
 20.1046 -            maxheight = height;
 20.1047 -        }
 20.1048 -        if (vinfo.yres_virtual > maxheight) {
 20.1049 -            vinfo.yres_virtual = maxheight;
 20.1050 -        }
 20.1051 -    }
 20.1052 -    cache_vinfo = vinfo;
 20.1053 -#ifdef FBCON_DEBUG
 20.1054 -    fprintf(stderr, "Printing actual vinfo:\n");
 20.1055 -    print_vinfo(&vinfo);
 20.1056 -#endif
 20.1057 -    Rmask = 0;
 20.1058 -    for (i = 0; i < vinfo.red.length; ++i) {
 20.1059 -        Rmask <<= 1;
 20.1060 -        Rmask |= (0x00000001 << vinfo.red.offset);
 20.1061 -    }
 20.1062 -    Gmask = 0;
 20.1063 -    for (i = 0; i < vinfo.green.length; ++i) {
 20.1064 -        Gmask <<= 1;
 20.1065 -        Gmask |= (0x00000001 << vinfo.green.offset);
 20.1066 -    }
 20.1067 -    Bmask = 0;
 20.1068 -    for (i = 0; i < vinfo.blue.length; ++i) {
 20.1069 -        Bmask <<= 1;
 20.1070 -        Bmask |= (0x00000001 << vinfo.blue.offset);
 20.1071 -    }
 20.1072 -    if (!SDL_ReallocFormat(current, vinfo.bits_per_pixel,
 20.1073 -                           Rmask, Gmask, Bmask, 0)) {
 20.1074 -        return (NULL);
 20.1075 -    }
 20.1076 -
 20.1077 -    /* Get the fixed information about the console hardware.
 20.1078 -       This is necessary since finfo.line_length changes.
 20.1079 -     */
 20.1080 -    if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
 20.1081 -        SDL_SetError("Couldn't get console hardware info");
 20.1082 -        return (NULL);
 20.1083 -    }
 20.1084 -
 20.1085 -    /* Save hardware palette, if needed */
 20.1086 -    FB_SavePalette(this, &finfo, &vinfo);
 20.1087 -
 20.1088 -    /* Set up the new mode framebuffer */
 20.1089 -    current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);
 20.1090 -    current->w = vinfo.xres;
 20.1091 -    current->h = vinfo.yres;
 20.1092 -    current->pitch = finfo.line_length;
 20.1093 -    current->pixels = mapped_mem + mapped_offset;
 20.1094 -
 20.1095 -    /* Set up the information for hardware surfaces */
 20.1096 -    surfaces_mem = (char *) current->pixels +
 20.1097 -        vinfo.yres_virtual * current->pitch;
 20.1098 -    surfaces_len = (mapped_memlen - (surfaces_mem - mapped_mem));
 20.1099 -    FB_FreeHWSurfaces(this);
 20.1100 -    FB_InitHWSurfaces(this, current, surfaces_mem, surfaces_len);
 20.1101 -
 20.1102 -    /* Let the application know we have a hardware palette */
 20.1103 -    switch (finfo.visual) {
 20.1104 -    case FB_VISUAL_PSEUDOCOLOR:
 20.1105 -        current->flags |= SDL_HWPALETTE;
 20.1106 -        break;
 20.1107 -    default:
 20.1108 -        break;
 20.1109 -    }
 20.1110 -
 20.1111 -    /* Update for double-buffering, if we can */
 20.1112 -    if (flags & SDL_DOUBLEBUF) {
 20.1113 -        if (vinfo.yres_virtual == (height * 2)) {
 20.1114 -            current->flags |= SDL_DOUBLEBUF;
 20.1115 -            flip_page = 0;
 20.1116 -            flip_address[0] = (char *) current->pixels;
 20.1117 -            flip_address[1] = (char *) current->pixels +
 20.1118 -                current->h * current->pitch;
 20.1119 -            this->screen = current;
 20.1120 -            FB_FlipHWSurface(this, current);
 20.1121 -            this->screen = NULL;
 20.1122 -        }
 20.1123 -    }
 20.1124 -
 20.1125 -    /* Set the update rectangle function */
 20.1126 -    this->UpdateRects = FB_DirectUpdate;
 20.1127 -
 20.1128 -    /* We're done */
 20.1129 -    return (current);
 20.1130 -}
 20.1131 -
 20.1132 -#ifdef FBCON_DEBUG
 20.1133 -void
 20.1134 -FB_DumpHWSurfaces(_THIS)
 20.1135 -{
 20.1136 -    vidmem_bucket *bucket;
 20.1137 -
 20.1138 -    printf("Memory left: %d (%d total)\n", surfaces_memleft,
 20.1139 -           surfaces_memtotal);
 20.1140 -    printf("\n");
 20.1141 -    printf("         Base  Size\n");
 20.1142 -    for (bucket = &surfaces; bucket; bucket = bucket->next) {
 20.1143 -        printf("Bucket:  %p, %d (%s)\n", bucket->base, bucket->size,
 20.1144 -               bucket->used ? "used" : "free");
 20.1145 -        if (bucket->prev) {
 20.1146 -            if (bucket->base != bucket->prev->base + bucket->prev->size) {
 20.1147 -                printf("Warning, corrupt bucket list! (prev)\n");
 20.1148 -            }
 20.1149 -        } else {
 20.1150 -            if (bucket != &surfaces) {
 20.1151 -                printf("Warning, corrupt bucket list! (!prev)\n");
 20.1152 -            }
 20.1153 -        }
 20.1154 -        if (bucket->next) {
 20.1155 -            if (bucket->next->base != bucket->base + bucket->size) {
 20.1156 -                printf("Warning, corrupt bucket list! (next)\n");
 20.1157 -            }
 20.1158 -        }
 20.1159 -    }
 20.1160 -    printf("\n");
 20.1161 -}
 20.1162 -#endif
 20.1163 -
 20.1164 -static int
 20.1165 -FB_InitHWSurfaces(_THIS, SDL_Surface * screen, char *base, int size)
 20.1166 -{
 20.1167 -    vidmem_bucket *bucket;
 20.1168 -
 20.1169 -    surfaces_memtotal = size;
 20.1170 -    surfaces_memleft = size;
 20.1171 -
 20.1172 -    if (surfaces_memleft > 0) {
 20.1173 -        bucket = (vidmem_bucket *) SDL_malloc(sizeof(*bucket));
 20.1174 -        if (bucket == NULL) {
 20.1175 -            SDL_OutOfMemory();
 20.1176 -            return (-1);
 20.1177 -        }
 20.1178 -        bucket->prev = &surfaces;
 20.1179 -        bucket->used = 0;
 20.1180 -        bucket->dirty = 0;
 20.1181 -        bucket->base = base;
 20.1182 -        bucket->size = size;
 20.1183 -        bucket->next = NULL;
 20.1184 -    } else {
 20.1185 -        bucket = NULL;
 20.1186 -    }
 20.1187 -
 20.1188 -    surfaces.prev = NULL;
 20.1189 -    surfaces.used = 1;
 20.1190 -    surfaces.dirty = 0;
 20.1191 -    surfaces.base = screen->pixels;
 20.1192 -    surfaces.size = (unsigned int) ((long) base - (long) surfaces.base);
 20.1193 -    surfaces.next = bucket;
 20.1194 -    screen->hwdata = (struct private_hwdata *) &surfaces;
 20.1195 -    return (0);
 20.1196 -}
 20.1197 -
 20.1198 -static void
 20.1199 -FB_FreeHWSurfaces(_THIS)
 20.1200 -{
 20.1201 -    vidmem_bucket *bucket, *freeable;
 20.1202 -
 20.1203 -    bucket = surfaces.next;
 20.1204 -    while (bucket) {
 20.1205 -        freeable = bucket;
 20.1206 -        bucket = bucket->next;
 20.1207 -        SDL_free(freeable);
 20.1208 -    }
 20.1209 -    surfaces.next = NULL;
 20.1210 -}
 20.1211 -
 20.1212 -static int
 20.1213 -FB_AllocHWSurface(_THIS, SDL_Surface * surface)
 20.1214 -{
 20.1215 -    vidmem_bucket *bucket;
 20.1216 -    int size;
 20.1217 -    int extra;
 20.1218 -
 20.1219 -/* Temporarily, we only allow surfaces the same width as display.
 20.1220 -   Some blitters require the pitch between two hardware surfaces
 20.1221 -   to be the same.  Others have interesting alignment restrictions.
 20.1222 -   Until someone who knows these details looks at the code...
 20.1223 -*/
 20.1224 -    if (surface->pitch > SDL_VideoSurface->pitch) {
 20.1225 -        SDL_SetError("Surface requested wider than screen");
 20.1226 -        return (-1);
 20.1227 -    }
 20.1228 -    surface->pitch = SDL_VideoSurface->pitch;
 20.1229 -    size = surface->h * surface->pitch;
 20.1230 -#ifdef FBCON_DEBUG
 20.1231 -    fprintf(stderr, "Allocating bucket of %d bytes\n", size);
 20.1232 -#endif
 20.1233 -
 20.1234 -    /* Quick check for available mem */
 20.1235 -    if (size > surfaces_memleft) {
 20.1236 -        SDL_SetError("Not enough video memory");
 20.1237 -        return (-1);
 20.1238 -    }
 20.1239 -
 20.1240 -    /* Search for an empty bucket big enough */
 20.1241 -    for (bucket = &surfaces; bucket; bucket = bucket->next) {
 20.1242 -        if (!bucket->used && (size <= bucket->size)) {
 20.1243 -            break;
 20.1244 -        }
 20.1245 -    }
 20.1246 -    if (bucket == NULL) {
 20.1247 -        SDL_SetError("Video memory too fragmented");
 20.1248 -        return (-1);
 20.1249 -    }
 20.1250 -
 20.1251 -    /* Create a new bucket for left-over memory */
 20.1252 -    extra = (bucket->size - size);
 20.1253 -    if (extra) {
 20.1254 -        vidmem_bucket *newbucket;
 20.1255 -
 20.1256 -#ifdef FBCON_DEBUG
 20.1257 -        fprintf(stderr, "Adding new free bucket of %d bytes\n", extra);
 20.1258 -#endif
 20.1259 -        newbucket = (vidmem_bucket *) SDL_malloc(sizeof(*newbucket));
 20.1260 -        if (newbucket == NULL) {
 20.1261 -            SDL_OutOfMemory();
 20.1262 -            return (-1);
 20.1263 -        }
 20.1264 -        newbucket->prev = bucket;
 20.1265 -        newbucket->used = 0;
 20.1266 -        newbucket->base = bucket->base + size;
 20.1267 -        newbucket->size = extra;
 20.1268 -        newbucket->next = bucket->next;
 20.1269 -        if (bucket->next) {
 20.1270 -            bucket->next->prev = newbucket;
 20.1271 -        }
 20.1272 -        bucket->next = newbucket;
 20.1273 -    }
 20.1274 -
 20.1275 -    /* Set the current bucket values and return it! */
 20.1276 -    bucket->used = 1;
 20.1277 -    bucket->size = size;
 20.1278 -    bucket->dirty = 0;
 20.1279 -#ifdef FBCON_DEBUG
 20.1280 -    fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base);
 20.1281 -#endif
 20.1282 -    surfaces_memleft -= size;
 20.1283 -    surface->flags |= SDL_HWSURFACE;
 20.1284 -    surface->pixels = bucket->base;
 20.1285 -    surface->hwdata = (struct private_hwdata *) bucket;
 20.1286 -    return (0);
 20.1287 -}
 20.1288 -
 20.1289 -static void
 20.1290 -FB_FreeHWSurface(_THIS, SDL_Surface * surface)
 20.1291 -{
 20.1292 -    vidmem_bucket *bucket, *freeable;
 20.1293 -
 20.1294 -    /* Look for the bucket in the current list */
 20.1295 -    for (bucket = &surfaces; bucket; bucket = bucket->next) {
 20.1296 -        if (bucket == (vidmem_bucket *) surface->hwdata) {
 20.1297 -            break;
 20.1298 -        }
 20.1299 -    }
 20.1300 -    if (bucket && bucket->used) {
 20.1301 -        /* Add the memory back to the total */
 20.1302 -#ifdef DGA_DEBUG
 20.1303 -        printf("Freeing bucket of %d bytes\n", bucket->size);
 20.1304 -#endif
 20.1305 -        surfaces_memleft += bucket->size;
 20.1306 -
 20.1307 -        /* Can we merge the space with surrounding buckets? */
 20.1308 -        bucket->used = 0;
 20.1309 -        if (bucket->next && !bucket->next->used) {
 20.1310 -#ifdef DGA_DEBUG
 20.1311 -            printf("Merging with next bucket, for %d total bytes\n",
 20.1312 -                   bucket->size + bucket->next->size);
 20.1313 -#endif
 20.1314 -            freeable = bucket->next;
 20.1315 -            bucket->size += bucket->next->size;
 20.1316 -            bucket->next = bucket->next->next;
 20.1317 -            if (bucket->next) {
 20.1318 -                bucket->next->prev = bucket;
 20.1319 -            }
 20.1320 -            SDL_free(freeable);
 20.1321 -        }
 20.1322 -        if (bucket->prev && !bucket->prev->used) {
 20.1323 -#ifdef DGA_DEBUG
 20.1324 -            printf("Merging with previous bucket, for %d total bytes\n",
 20.1325 -                   bucket->prev->size + bucket->size);
 20.1326 -#endif
 20.1327 -            freeable = bucket;
 20.1328 -            bucket->prev->size += bucket->size;
 20.1329 -            bucket->prev->next = bucket->next;
 20.1330 -            if (bucket->next) {
 20.1331 -                bucket->next->prev = bucket->prev;
 20.1332 -            }
 20.1333 -            SDL_free(freeable);
 20.1334 -        }
 20.1335 -    }
 20.1336 -    surface->pixels = NULL;
 20.1337 -    surface->hwdata = NULL;
 20.1338 -}
 20.1339 -
 20.1340 -static int
 20.1341 -FB_LockHWSurface(_THIS, SDL_Surface * surface)
 20.1342 -{
 20.1343 -    if (switched_away) {
 20.1344 -        return -2;              /* no hardware access */
 20.1345 -    }
 20.1346 -    if (surface == this->screen) {
 20.1347 -        SDL_mutexP(hw_lock);
 20.1348 -        if (FB_IsSurfaceBusy(surface)) {
 20.1349 -            FB_WaitBusySurfaces(this);
 20.1350 -        }
 20.1351 -    } else {
 20.1352 -        if (FB_IsSurfaceBusy(surface)) {
 20.1353 -            FB_WaitBusySurfaces(this);
 20.1354 -        }
 20.1355 -    }
 20.1356 -    return (0);
 20.1357 -}
 20.1358 -
 20.1359 -static void
 20.1360 -FB_UnlockHWSurface(_THIS, SDL_Surface * surface)
 20.1361 -{
 20.1362 -    if (surface == this->screen) {
 20.1363 -        SDL_mutexV(hw_lock);
 20.1364 -    }
 20.1365 -}
 20.1366 -
 20.1367 -static void
 20.1368 -FB_WaitVBL(_THIS)
 20.1369 -{
 20.1370 -#ifdef FBIOWAITRETRACE          /* Heheh, this didn't make it into the main kernel */
 20.1371 -    ioctl(console_fd, FBIOWAITRETRACE, 0);
 20.1372 -#endif
 20.1373 -    return;
 20.1374 -}
 20.1375 -
 20.1376 -static void
 20.1377 -FB_WaitIdle(_THIS)
 20.1378 -{
 20.1379 -    return;
 20.1380 -}
 20.1381 -
 20.1382 -static int
 20.1383 -FB_FlipHWSurface(_THIS, SDL_Surface * surface)
 20.1384 -{
 20.1385 -    if (switched_away) {
 20.1386 -        return -2;              /* no hardware access */
 20.1387 -    }
 20.1388 -
 20.1389 -    /* Wait for vertical retrace and then flip display */
 20.1390 -    cache_vinfo.yoffset = flip_page * surface->h;
 20.1391 -    if (FB_IsSurfaceBusy(this->screen)) {
 20.1392 -        FB_WaitBusySurfaces(this);
 20.1393 -    }
 20.1394 -    wait_vbl(this);
 20.1395 -    if (ioctl(console_fd, FBIOPAN_DISPLAY, &cache_vinfo) < 0) {
 20.1396 -        SDL_SetError("ioctl(FBIOPAN_DISPLAY) failed");
 20.1397 -        return (-1);
 20.1398 -    }
 20.1399 -    flip_page = !flip_page;
 20.1400 -
 20.1401 -    surface->pixels = flip_address[flip_page];
 20.1402 -    return (0);
 20.1403 -}
 20.1404 -
 20.1405 -static void
 20.1406 -FB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects)
 20.1407 -{
 20.1408 -    /* The application is already updating the visible video memory */
 20.1409 -    return;
 20.1410 -}
 20.1411 -
 20.1412 -#ifdef VGA16_FBCON_SUPPORT
 20.1413 -/* Code adapted with thanks from the XFree86 VGA16 driver! :) */
 20.1414 -#define writeGr(index, value) \
 20.1415 -outb(index, 0x3CE);           \
 20.1416 -outb(value, 0x3CF);
 20.1417 -#define writeSeq(index, value) \
 20.1418 -outb(index, 0x3C4);            \
 20.1419 -outb(value, 0x3C5);
 20.1420 -
 20.1421 -static void
 20.1422 -FB_VGA16Update(_THIS, int numrects, SDL_Rect * rects)
 20.1423 -{
 20.1424 -    SDL_Surface *screen;
 20.1425 -    int width, height, FBPitch, left, i, j, SRCPitch, phase;
 20.1426 -    register Uint32 m;
 20.1427 -    Uint8 s1, s2, s3, s4;
 20.1428 -    Uint32 *src, *srcPtr;
 20.1429 -    Uint8 *dst, *dstPtr;
 20.1430 -
 20.1431 -    if (switched_away) {
 20.1432 -        return;                 /* no hardware access */
 20.1433 -    }
 20.1434 -
 20.1435 -    screen = this->screen;
 20.1436 -    FBPitch = screen->w >> 3;
 20.1437 -    SRCPitch = screen->pitch >> 2;
 20.1438 -
 20.1439 -    writeGr(0x03, 0x00);
 20.1440 -    writeGr(0x05, 0x00);
 20.1441 -    writeGr(0x01, 0x00);
 20.1442 -    writeGr(0x08, 0xFF);
 20.1443 -
 20.1444 -    while (numrects--) {
 20.1445 -        left = rects->x & ~7;
 20.1446 -        width = (rects->w + 7) >> 3;
 20.1447 -        height = rects->h;
 20.1448 -        src = (Uint32 *) screen->pixels + (rects->y * SRCPitch) + (left >> 2);
 20.1449 -        dst = (Uint8 *) mapped_mem + (rects->y * FBPitch) + (left >> 3);
 20.1450 -
 20.1451 -        if ((phase = (long) dst & 3L)) {
 20.1452 -            phase = 4 - phase;
 20.1453 -            if (phase > width)
 20.1454 -                phase = width;
 20.1455 -            width -= phase;
 20.1456 -        }
 20.1457 -
 20.1458 -        while (height--) {
 20.1459 -            writeSeq(0x02, 1 << 0);
 20.1460 -            dstPtr = dst;
 20.1461 -            srcPtr = src;
 20.1462 -            i = width;
 20.1463 -            j = phase;
 20.1464 -            while (j--) {
 20.1465 -                m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101)
 20.1466 -                                                << 4);
 20.1467 -                *dstPtr++ = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
 20.1468 -                srcPtr += 2;
 20.1469 -            }
 20.1470 -            while (i >= 4) {
 20.1471 -                m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101)
 20.1472 -                                                << 4);
 20.1473 -                s1 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
 20.1474 -                m = (srcPtr[3] & 0x01010101) | ((srcPtr[2] & 0x01010101)
 20.1475 -                                                << 4);
 20.1476 -                s2 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
 20.1477 -                m = (srcPtr[5] & 0x01010101) | ((srcPtr[4] & 0x01010101)
 20.1478 -                                                << 4);
 20.1479 -                s3 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
 20.1480 -                m = (srcPtr[7] & 0x01010101) | ((srcPtr[6] & 0x01010101)
 20.1481 -                                                << 4);
 20.1482 -                s4 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
 20.1483 -                *((Uint32 *) dstPtr) =
 20.1484 -                    s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
 20.1485 -                srcPtr += 8;
 20.1486 -                dstPtr += 4;
 20.1487 -                i -= 4;
 20.1488 -            }
 20.1489 -            while (i--) {
 20.1490 -                m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101)
 20.1491 -                                                << 4);
 20.1492 -                *dstPtr++ = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
 20.1493 -                srcPtr += 2;
 20.1494 -            }
 20.1495 -
 20.1496 -            writeSeq(0x02, 1 << 1);
 20.1497 -            dstPtr = dst;
 20.1498 -            srcPtr = src;
 20.1499 -            i = width;
 20.1500 -            j = phase;
 20.1501 -            while (j--) {
 20.1502 -                m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202)
 20.1503 -                                                << 4);
 20.1504 -                *dstPtr++ = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
 20.1505 -                srcPtr += 2;
 20.1506 -            }
 20.1507 -            while (i >= 4) {
 20.1508 -                m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202)
 20.1509 -                                                << 4);
 20.1510 -                s1 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
 20.1511 -                m = (srcPtr[3] & 0x02020202) | ((srcPtr[2] & 0x02020202)
 20.1512 -                                                << 4);
 20.1513 -                s2 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
 20.1514 -                m = (srcPtr[5] & 0x02020202) | ((srcPtr[4] & 0x02020202)
 20.1515 -                                                << 4);
 20.1516 -                s3 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
 20.1517 -                m = (srcPtr[7] & 0x02020202) | ((srcPtr[6] & 0x02020202)
 20.1518 -                                                << 4);
 20.1519 -                s4 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
 20.1520 -                *((Uint32 *) dstPtr) =
 20.1521 -                    s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
 20.1522 -                srcPtr += 8;
 20.1523 -                dstPtr += 4;
 20.1524 -                i -= 4;
 20.1525 -            }
 20.1526 -            while (i--) {
 20.1527 -                m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202)
 20.1528 -                                                << 4);
 20.1529 -                *dstPtr++ = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
 20.1530 -                srcPtr += 2;
 20.1531 -            }
 20.1532 -
 20.1533 -            writeSeq(0x02, 1 << 2);
 20.1534 -            dstPtr = dst;
 20.1535 -            srcPtr = src;
 20.1536 -            i = width;
 20.1537 -            j = phase;
 20.1538 -            while (j--) {
 20.1539 -                m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404)
 20.1540 -                                                << 4);
 20.1541 -                *dstPtr++ = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
 20.1542 -                srcPtr += 2;
 20.1543 -            }
 20.1544 -            while (i >= 4) {
 20.1545 -                m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404)
 20.1546 -                                                << 4);
 20.1547 -                s1 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
 20.1548 -                m = (srcPtr[3] & 0x04040404) | ((srcPtr[2] & 0x04040404)
 20.1549 -                                                << 4);
 20.1550 -                s2 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
 20.1551 -                m = (srcPtr[5] & 0x04040404) | ((srcPtr[4] & 0x04040404)
 20.1552 -                                                << 4);
 20.1553 -                s3 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
 20.1554 -                m = (srcPtr[7] & 0x04040404) | ((srcPtr[6] & 0x04040404)
 20.1555 -                                                << 4);
 20.1556 -                s4 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
 20.1557 -                *((Uint32 *) dstPtr) =
 20.1558 -                    s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
 20.1559 -                srcPtr += 8;
 20.1560 -                dstPtr += 4;
 20.1561 -                i -= 4;
 20.1562 -            }
 20.1563 -            while (i--) {
 20.1564 -                m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404)
 20.1565 -                                                << 4);
 20.1566 -                *dstPtr++ = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
 20.1567 -                srcPtr += 2;
 20.1568 -            }
 20.1569 -
 20.1570 -            writeSeq(0x02, 1 << 3);
 20.1571 -            dstPtr = dst;
 20.1572 -            srcPtr = src;
 20.1573 -            i = width;
 20.1574 -            j = phase;
 20.1575 -            while (j--) {
 20.1576 -                m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808)
 20.1577 -                                                << 4);
 20.1578 -                *dstPtr++ = (m >> 27) | (m >> 18) | (m >> 9) | m;
 20.1579 -                srcPtr += 2;
 20.1580 -            }
 20.1581 -            while (i >= 4) {
 20.1582 -                m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808)
 20.1583 -                                                << 4);
 20.1584 -                s1 = (m >> 27) | (m >> 18) | (m >> 9) | m;
 20.1585 -                m = (srcPtr[3] & 0x08080808) | ((srcPtr[2] & 0x08080808)
 20.1586 -                                                << 4);
 20.1587 -                s2 = (m >> 27) | (m >> 18) | (m >> 9) | m;
 20.1588 -                m = (srcPtr[5] & 0x08080808) | ((srcPtr[4] & 0x08080808)
 20.1589 -                                                << 4);
 20.1590 -                s3 = (m >> 27) | (m >> 18) | (m >> 9) | m;
 20.1591 -                m = (srcPtr[7] & 0x08080808) | ((srcPtr[6] & 0x08080808)
 20.1592 -                                                << 4);
 20.1593 -                s4 = (m >> 27) | (m >> 18) | (m >> 9) | m;
 20.1594 -                *((Uint32 *) dstPtr) =
 20.1595 -                    s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
 20.1596 -                srcPtr += 8;
 20.1597 -                dstPtr += 4;
 20.1598 -                i -= 4;
 20.1599 -            }
 20.1600 -            while (i--) {
 20.1601 -                m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808)
 20.1602 -                                                << 4);
 20.1603 -                *dstPtr++ = (m >> 27) | (m >> 18) | (m >> 9) | m;
 20.1604 -                srcPtr += 2;
 20.1605 -            }
 20.1606 -
 20.1607 -            dst += FBPitch;
 20.1608 -            src += SRCPitch;
 20.1609 -        }
 20.1610 -        rects++;
 20.1611 -    }
 20.1612 -}
 20.1613 -#endif /* VGA16_FBCON_SUPPORT */
 20.1614 -
 20.1615 -void
 20.1616 -FB_SavePaletteTo(_THIS, int palette_len, __u16 * area)
 20.1617 -{
 20.1618 -    struct fb_cmap cmap;
 20.1619 -
 20.1620 -    cmap.start = 0;
 20.1621 -    cmap.len = palette_len;
 20.1622 -    cmap.red = &area[0 * palette_len];
 20.1623 -    cmap.green = &area[1 * palette_len];
 20.1624 -    cmap.blue = &area[2 * palette_len];
 20.1625 -    cmap.transp = NULL;
 20.1626 -    ioctl(console_fd, FBIOGETCMAP, &cmap);
 20.1627 -}
 20.1628 -
 20.1629 -void
 20.1630 -FB_RestorePaletteFrom(_THIS, int palette_len, __u16 * area)
 20.1631 -{
 20.1632 -    struct fb_cmap cmap;
 20.1633 -
 20.1634 -    cmap.start = 0;
 20.1635 -    cmap.len = palette_len;
 20.1636 -    cmap.red = &area[0 * palette_len];
 20.1637 -    cmap.green = &area[1 * palette_len];
 20.1638 -    cmap.blue = &area[2 * palette_len];
 20.1639 -    cmap.transp = NULL;
 20.1640 -    ioctl(console_fd, FBIOPUTCMAP, &cmap);
 20.1641 -}
 20.1642 -
 20.1643 -static void
 20.1644 -FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
 20.1645 -               struct fb_var_screeninfo *vinfo)
 20.1646 -{
 20.1647 -    int i;
 20.1648 -
 20.1649 -    /* Save hardware palette, if needed */
 20.1650 -    if (finfo->visual == FB_VISUAL_PSEUDOCOLOR) {
 20.1651 -        saved_cmaplen = 1 << vinfo->bits_per_pixel;
 20.1652 -        saved_cmap =
 20.1653 -            (__u16 *) SDL_malloc(3 * saved_cmaplen * sizeof(*saved_cmap));
 20.1654 -        if (saved_cmap != NULL) {
 20.1655 -            FB_SavePaletteTo(this, saved_cmaplen, saved_cmap);
 20.1656 -        }
 20.1657 -    }
 20.1658 -
 20.1659 -    /* Added support for FB_VISUAL_DIRECTCOLOR.
 20.1660 -       With this mode pixel information is passed through the palette...
 20.1661 -       Neat fading and gamma correction effects can be had by simply
 20.1662 -       fooling around with the palette instead of changing the pixel
 20.1663 -       values themselves... Very neat!
 20.1664 -
 20.1665 -       Adam Meyerowitz 1/19/2000
 20.1666 -       ameyerow@optonline.com
 20.1667 -     */
 20.1668 -    if (finfo->visual == FB_VISUAL_DIRECTCOLOR) {
 20.1669 -        __u16 new_entries[3 * 256];
 20.1670 -
 20.1671 -        /* Save the colormap */
 20.1672 -        saved_cmaplen = 256;
 20.1673 -        saved_cmap =
 20.1674 -            (__u16 *) SDL_malloc(3 * saved_cmaplen * sizeof(*saved_cmap));
 20.1675 -        if (saved_cmap != NULL) {
 20.1676 -            FB_SavePaletteTo(this, saved_cmaplen, saved_cmap);
 20.1677 -        }
 20.1678 -
 20.1679 -        /* Allocate new identity colormap */
 20.1680 -        for (i = 0; i < 256; ++i) {
 20.1681 -            new_entries[(0 * 256) + i] =
 20.1682 -                new_entries[(1 * 256) + i] =
 20.1683 -                new_entries[(2 * 256) + i] = (i << 8) | i;
 20.1684 -        }
 20.1685 -        FB_RestorePaletteFrom(this, 256, new_entries);
 20.1686 -    }
 20.1687 -}
 20.1688 -
 20.1689 -static void
 20.1690 -FB_RestorePalette(_THIS)
 20.1691 -{
 20.1692 -    /* Restore the original palette */
 20.1693 -    if (saved_cmap) {
 20.1694 -        FB_RestorePaletteFrom(this, saved_cmaplen, saved_cmap);
 20.1695 -        SDL_free(saved_cmap);
 20.1696 -        saved_cmap = NULL;
 20.1697 -    }
 20.1698 -}
 20.1699 -
 20.1700 -static int
 20.1701 -FB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
 20.1702 -{
 20.1703 -    int i;
 20.1704 -    __u16 r[256];
 20.1705 -    __u16 g[256];
 20.1706 -    __u16 b[256];
 20.1707 -    struct fb_cmap cmap;
 20.1708 -
 20.1709 -    /* Set up the colormap */
 20.1710 -    for (i = 0; i < ncolors; i++) {
 20.1711 -        r[i] = colors[i].r << 8;
 20.1712 -        g[i] = colors[i].g << 8;
 20.1713 -        b[i] = colors[i].b << 8;
 20.1714 -    }
 20.1715 -    cmap.start = firstcolor;
 20.1716 -    cmap.len = ncolors;
 20.1717 -    cmap.red = r;
 20.1718 -    cmap.green = g;
 20.1719 -    cmap.blue = b;
 20.1720 -    cmap.transp = NULL;
 20.1721 -
 20.1722 -    if ((ioctl(console_fd, FBIOPUTCMAP, &cmap) < 0) ||
 20.1723 -        !(this->screen->flags & SDL_HWPALETTE)) {
 20.1724 -        colors = this->screen->format->palette->colors;
 20.1725 -        ncolors = this->screen->format->palette->ncolors;
 20.1726 -        cmap.start = 0;
 20.1727 -        cmap.len = ncolors;
 20.1728 -        SDL_memset(r, 0, sizeof(r));
 20.1729 -        SDL_memset(g, 0, sizeof(g));
 20.1730 -        SDL_memset(b, 0, sizeof(b));
 20.1731 -        if (ioctl(console_fd, FBIOGETCMAP, &cmap) == 0) {
 20.1732 -            for (i = ncolors - 1; i >= 0; --i) {
 20.1733 -                colors[i].r = (r[i] >> 8);
 20.1734 -                colors[i].g = (g[i] >> 8);
 20.1735 -                colors[i].b = (b[i] >> 8);
 20.1736 -            }
 20.1737 -        }
 20.1738 -        return (0);
 20.1739 -    }
 20.1740 -    return (1);
 20.1741 -}
 20.1742 -
 20.1743 -/* Note:  If we are terminated, this could be called in the middle of
 20.1744 -   another SDL video routine -- notably UpdateRects.
 20.1745 -*/
 20.1746 -static void
 20.1747 -FB_VideoQuit(_THIS)
 20.1748 -{
 20.1749 -    int i, j;
 20.1750 -
 20.1751 -    if (this->screen) {
 20.1752 -        /* Clear screen and tell SDL not to free the pixels */
 20.1753 -        if (this->screen->pixels && FB_InGraphicsMode(this)) {
 20.1754 -#if defined(__powerpc__) || defined(__ia64__)   /* SIGBUS when using SDL_memset() ?? */
 20.1755 -            Uint8 *rowp = (Uint8 *) this->screen->pixels;
 20.1756 -            int left = this->screen->pitch * this->screen->h;
 20.1757 -            while (left--) {
 20.1758 -                *rowp++ = 0;
 20.1759 -            }
 20.1760 -#else
 20.1761 -            SDL_memset(this->screen->pixels, 0,
 20.1762 -                       this->screen->h * this->screen->pitch);
 20.1763 -#endif
 20.1764 -        }
 20.1765 -        /* This test fails when using the VGA16 shadow memory */
 20.1766 -        if (((char *) this->screen->pixels >= mapped_mem) &&
 20.1767 -            ((char *) this->screen->pixels < (mapped_mem + mapped_memlen))) {
 20.1768 -            this->screen->pixels = NULL;
 20.1769 -        }
 20.1770 -    }
 20.1771 -
 20.1772 -    /* Clear the lock mutex */
 20.1773 -    if (hw_lock) {
 20.1774 -        SDL_DestroyMutex(hw_lock);
 20.1775 -        hw_lock = NULL;
 20.1776 -    }
 20.1777 -
 20.1778 -    /* Clean up defined video modes */
 20.1779 -    for (i = 0; i < NUM_MODELISTS; ++i) {
 20.1780 -        if (SDL_modelist[i] != NULL) {
 20.1781 -            for (j = 0; SDL_modelist[i][j]; ++j) {
 20.1782 -                SDL_free(SDL_modelist[i][j]);
 20.1783 -            }
 20.1784 -            SDL_free(SDL_modelist[i]);
 20.1785 -            SDL_modelist[i] = NULL;
 20.1786 -        }
 20.1787 -    }
 20.1788 -
 20.1789 -    /* Clean up the memory bucket list */
 20.1790 -    FB_FreeHWSurfaces(this);
 20.1791 -
 20.1792 -    /* Close console and input file descriptors */
 20.1793 -    if (console_fd > 0) {
 20.1794 -        /* Unmap the video framebuffer and I/O registers */
 20.1795 -        if (mapped_mem) {
 20.1796 -            munmap(mapped_mem, mapped_memlen);
 20.1797 -            mapped_mem = NULL;
 20.1798 -        }
 20.1799 -        if (mapped_io) {
 20.1800 -            munmap(mapped_io, mapped_iolen);
 20.1801 -            mapped_io = NULL;
 20.1802 -        }
 20.1803 -
 20.1804 -        /* Restore the original video mode and palette */
 20.1805 -        if (FB_InGraphicsMode(this)) {
 20.1806 -            FB_RestorePalette(this);
 20.1807 -            ioctl(console_fd, FBIOPUT_VSCREENINFO, &saved_vinfo);
 20.1808 -        }
 20.1809 -
 20.1810 -        /* We're all done with the framebuffer */
 20.1811 -        close(console_fd);
 20.1812 -        console_fd = -1;
 20.1813 -    }
 20.1814 -    FB_CloseMouse(this);
 20.1815 -    FB_CloseKeyboard(this);
 20.1816 -}
 20.1817 -
 20.1818 -/* vi: set ts=4 sw=4 expandtab: */
    21.1 --- a/src/video/fbcon/SDL_fbvideo.h	Wed Jan 19 19:51:04 2011 -0800
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,189 +0,0 @@
    21.4 -/*
    21.5 -    SDL - Simple DirectMedia Layer
    21.6 -    Copyright (C) 1997-2010 Sam Lantinga
    21.7 -
    21.8 -    This library is free software; you can redistribute it and/or
    21.9 -    modify it under the terms of the GNU Lesser General Public
   21.10 -    License as published by the Free Software Foundation; either
   21.11 -    version 2.1 of the License, or (at your option) any later version.
   21.12 -
   21.13 -    This library is distributed in the hope that it will be useful,
   21.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   21.16 -    Lesser General Public License for more details.
   21.17 -
   21.18 -    You should have received a copy of the GNU Lesser General Public
   21.19 -    License along with this library; if not, write to the Free Software
   21.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   21.21 -
   21.22 -    Sam Lantinga
   21.23 -    slouken@libsdl.org
   21.24 -*/
   21.25 -#include "SDL_config.h"
   21.26 -
   21.27 -#ifndef _SDL_fbvideo_h
   21.28 -#define _SDL_fbvideo_h
   21.29 -
   21.30 -#include <sys/types.h>
   21.31 -#include <termios.h>
   21.32 -#include <linux/fb.h>
   21.33 -
   21.34 -#include "SDL_mouse.h"
   21.35 -#include "SDL_mutex.h"
   21.36 -#include "../SDL_sysvideo.h"
   21.37 -#if SDL_INPUT_TSLIB
   21.38 -#include "tslib.h"
   21.39 -#endif
   21.40 -
   21.41 -/* Hidden "this" pointer for the video functions */
   21.42 -#define _THIS	SDL_VideoDevice *this
   21.43 -
   21.44 -
   21.45 -/* This is the structure we use to keep track of video memory */
   21.46 -typedef struct vidmem_bucket
   21.47 -{
   21.48 -    struct vidmem_bucket *prev;
   21.49 -    int used;
   21.50 -    int dirty;
   21.51 -    char *base;
   21.52 -    unsigned int size;
   21.53 -    struct vidmem_bucket *next;
   21.54 -} vidmem_bucket;
   21.55 -
   21.56 -/* Private display data */
   21.57 -struct SDL_PrivateVideoData
   21.58 -{
   21.59 -    int console_fd;
   21.60 -    struct fb_var_screeninfo cache_vinfo;
   21.61 -    struct fb_var_screeninfo saved_vinfo;
   21.62 -    int saved_cmaplen;
   21.63 -    __u16 *saved_cmap;
   21.64 -
   21.65 -    int current_vt;
   21.66 -    int saved_vt;
   21.67 -    int keyboard_fd;
   21.68 -    int saved_kbd_mode;
   21.69 -    struct termios saved_kbd_termios;
   21.70 -
   21.71 -    int mouse_fd;
   21.72 -#if SDL_INPUT_TSLIB
   21.73 -    struct tsdev *ts_dev;
   21.74 -#endif
   21.75 -
   21.76 -    char *mapped_mem;
   21.77 -    int mapped_memlen;
   21.78 -    int mapped_offset;
   21.79 -    char *mapped_io;
   21.80 -    long mapped_iolen;
   21.81 -    int flip_page;
   21.82 -    char *flip_address[2];
   21.83 -
   21.84 -#define NUM_MODELISTS	4       /* 8, 16, 24, and 32 bits-per-pixel */
   21.85 -    int SDL_nummodes[NUM_MODELISTS];
   21.86 -    SDL_Rect **SDL_modelist[NUM_MODELISTS];
   21.87 -
   21.88 -    vidmem_bucket surfaces;
   21.89 -    int surfaces_memtotal;
   21.90 -    int surfaces_memleft;
   21.91 -
   21.92 -    SDL_mutex *hw_lock;
   21.93 -    int switched_away;
   21.94 -    struct fb_var_screeninfo screen_vinfo;
   21.95 -    Uint32 screen_arealen;
   21.96 -    Uint8 *screen_contents;
   21.97 -    __u16 screen_palette[3 * 256];
   21.98 -
   21.99 -    void (*wait_vbl) (_THIS);
  21.100 -    void (*wait_idle) (_THIS);
  21.101 -};
  21.102 -/* Old variable names */
  21.103 -#define console_fd		(this->hidden->console_fd)
  21.104 -#define current_vt		(this->hidden->current_vt)
  21.105 -#define saved_vt		(this->hidden->saved_vt)
  21.106 -#define keyboard_fd		(this->hidden->keyboard_fd)
  21.107 -#define saved_kbd_mode		(this->hidden->saved_kbd_mode)
  21.108 -#define saved_kbd_termios	(this->hidden->saved_kbd_termios)
  21.109 -#define mouse_fd		(this->hidden->mouse_fd)
  21.110 -#if SDL_INPUT_TSLIB
  21.111 -#define ts_dev			(this->hidden->ts_dev)
  21.112 -#endif
  21.113 -#define cache_vinfo		(this->hidden->cache_vinfo)
  21.114 -#define saved_vinfo		(this->hidden->saved_vinfo)
  21.115 -#define saved_cmaplen		(this->hidden->saved_cmaplen)
  21.116 -#define saved_cmap		(this->hidden->saved_cmap)
  21.117 -#define mapped_mem		(this->hidden->mapped_mem)
  21.118 -#define mapped_memlen		(this->hidden->mapped_memlen)
  21.119 -#define mapped_offset		(this->hidden->mapped_offset)
  21.120 -#define mapped_io		(this->hidden->mapped_io)
  21.121 -#define mapped_iolen		(this->hidden->mapped_iolen)
  21.122 -#define flip_page		(this->hidden->flip_page)
  21.123 -#define flip_address		(this->hidden->flip_address)
  21.124 -#define SDL_nummodes		(this->hidden->SDL_nummodes)
  21.125 -#define SDL_modelist		(this->hidden->SDL_modelist)
  21.126 -#define surfaces		(this->hidden->surfaces)
  21.127 -#define surfaces_memtotal	(this->hidden->surfaces_memtotal)
  21.128 -#define surfaces_memleft	(this->hidden->surfaces_memleft)
  21.129 -#define hw_lock			(this->hidden->hw_lock)
  21.130 -#define switched_away		(this->hidden->switched_away)
  21.131 -#define screen_vinfo		(this->hidden->screen_vinfo)
  21.132 -#define screen_arealen		(this->hidden->screen_arealen)
  21.133 -#define screen_contents		(this->hidden->screen_contents)
  21.134 -#define screen_palette		(this->hidden->screen_palette)
  21.135 -#define wait_vbl		(this->hidden->wait_vbl)
  21.136 -#define wait_idle		(this->hidden->wait_idle)
  21.137 -
  21.138 -/* Accelerator types that are supported by the driver, but are not
  21.139 -   necessarily in the kernel headers on the system we compile on.
  21.140 -*/
  21.141 -#ifndef FB_ACCEL_MATROX_MGAG400
  21.142 -#define FB_ACCEL_MATROX_MGAG400	26      /* Matrox G400                  */
  21.143 -#endif
  21.144 -#ifndef FB_ACCEL_3DFX_BANSHEE
  21.145 -#define FB_ACCEL_3DFX_BANSHEE	31      /* 3Dfx Banshee                 */
  21.146 -#endif
  21.147 -
  21.148 -/* These functions are defined in SDL_fbvideo.c */
  21.149 -extern void FB_SavePaletteTo(_THIS, int palette_len, __u16 * area);
  21.150 -extern void FB_RestorePaletteFrom(_THIS, int palette_len, __u16 * area);
  21.151 -
  21.152 -/* These are utility functions for working with video surfaces */
  21.153 -
  21.154 -static __inline__ void
  21.155 -FB_AddBusySurface(SDL_Surface * surface)
  21.156 -{
  21.157 -    ((vidmem_bucket *) surface->hwdata)->dirty = 1;
  21.158 -}
  21.159 -
  21.160 -static __inline__ int
  21.161 -FB_IsSurfaceBusy(SDL_Surface * surface)
  21.162 -{
  21.163 -    return ((vidmem_bucket *) surface->hwdata)->dirty;
  21.164 -}
  21.165 -
  21.166 -static __inline__ void
  21.167 -FB_WaitBusySurfaces(_THIS)
  21.168 -{
  21.169 -    vidmem_bucket *bucket;
  21.170 -
  21.171 -    /* Wait for graphic operations to complete */
  21.172 -    wait_idle(this);
  21.173 -
  21.174 -    /* Clear all surface dirty bits */
  21.175 -    for (bucket = &surfaces; bucket; bucket = bucket->next) {
  21.176 -        bucket->dirty = 0;
  21.177 -    }
  21.178 -}
  21.179 -
  21.180 -static __inline__ void
  21.181 -FB_dst_to_xy(_THIS, SDL_Surface * dst, int *x, int *y)
  21.182 -{
  21.183 -    *x = (long) ((char *) dst->pixels - mapped_mem) % this->screen->pitch;
  21.184 -    *y = (long) ((char *) dst->pixels - mapped_mem) / this->screen->pitch;
  21.185 -    if (dst == this->screen) {
  21.186 -        *x += this->offset_x;
  21.187 -        *y += this->offset_y;
  21.188 -    }
  21.189 -}
  21.190 -
  21.191 -#endif /* _SDL_fbvideo_h */
  21.192 -/* vi: set ts=4 sw=4 expandtab: */
    22.1 --- a/src/video/fbcon/matrox_mmio.h	Wed Jan 19 19:51:04 2011 -0800
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,51 +0,0 @@
    22.4 -/*
    22.5 -    SDL - Simple DirectMedia Layer
    22.6 -    Copyright (C) 1997-2010 Sam Lantinga
    22.7 -
    22.8 -    This library is free software; you can redistribute it and/or
    22.9 -    modify it under the terms of the GNU Lesser General Public
   22.10 -    License as published by the Free Software Foundation; either
   22.11 -    version 2.1 of the License, or (at your option) any later version.
   22.12 -
   22.13 -    This library is distributed in the hope that it will be useful,
   22.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22.16 -    Lesser General Public License for more details.
   22.17 -
   22.18 -    You should have received a copy of the GNU Lesser General Public
   22.19 -    License along with this library; if not, write to the Free Software
   22.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   22.21 -
   22.22 -    Sam Lantinga
   22.23 -    slouken@libsdl.org
   22.24 -*/
   22.25 -#include "SDL_config.h"
   22.26 -
   22.27 -/* MGA register definitions */
   22.28 -
   22.29 -#include "matrox_regs.h"
   22.30 -
   22.31 -/* MGA control macros */
   22.32 -
   22.33 -#define mga_in8(reg)		*(volatile Uint8  *)(mapped_io + (reg))
   22.34 -#define mga_in32(reg)		*(volatile Uint32 *)(mapped_io + (reg))
   22.35 -
   22.36 -#define mga_out8(reg,v)		*(volatile Uint8  *)(mapped_io + (reg)) = v;
   22.37 -#define mga_out32(reg,v)	*(volatile Uint32 *)(mapped_io + (reg)) = v;
   22.38 -
   22.39 -
   22.40 -/* Wait for fifo space */
   22.41 -#define mga_wait(space)							\
   22.42 -{									\
   22.43 -	while ( mga_in8(MGAREG_FIFOSTATUS) < space )			\
   22.44 -		;							\
   22.45 -}
   22.46 -
   22.47 -
   22.48 -/* Wait for idle accelerator */
   22.49 -#define mga_waitidle()							\
   22.50 -{									\
   22.51 -	while ( mga_in32(MGAREG_STATUS) & 0x10000 )			\
   22.52 -		;							\
   22.53 -}
   22.54 -/* vi: set ts=4 sw=4 expandtab: */
    23.1 --- a/src/video/fbcon/matrox_regs.h	Wed Jan 19 19:51:04 2011 -0800
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,376 +0,0 @@
    23.4 -
    23.5 -/*
    23.6 - * MGA Millennium (MGA2064W) functions
    23.7 - * MGA Mystique (MGA1064SG) functions
    23.8 - *
    23.9 - * Copyright 1996 The XFree86 Project, Inc.
   23.10 - *
   23.11 - * Authors
   23.12 - *		Dirk Hohndel
   23.13 - *			hohndel@XFree86.Org
   23.14 - *		David Dawes
   23.15 - *			dawes@XFree86.Org
   23.16 - * Contributors:
   23.17 - *		Guy DESBIEF, Aix-en-provence, France
   23.18 - *			g.desbief@aix.pacwan.net
   23.19 - *		MGA1064SG Mystique register file
   23.20 - */
   23.21 -
   23.22 -
   23.23 -#ifndef _MGA_REG_H_
   23.24 -#define _MGA_REG_H_
   23.25 -
   23.26 -#define	MGAREG_DWGCTL		0x1c00
   23.27 -#define	MGAREG_MACCESS		0x1c04
   23.28 -/* the following is a mystique only register */
   23.29 -#define MGAREG_MCTLWTST		0x1c08
   23.30 -#define	MGAREG_ZORG		0x1c0c
   23.31 -
   23.32 -#define	MGAREG_PAT0		0x1c10
   23.33 -#define	MGAREG_PAT1		0x1c14
   23.34 -#define	MGAREG_PLNWT		0x1c1c
   23.35 -
   23.36 -#define	MGAREG_BCOL		0x1c20
   23.37 -#define	MGAREG_FCOL		0x1c24
   23.38 -
   23.39 -#define	MGAREG_SRC0		0x1c30
   23.40 -#define	MGAREG_SRC1		0x1c34
   23.41 -#define	MGAREG_SRC2		0x1c38
   23.42 -#define	MGAREG_SRC3		0x1c3c
   23.43 -
   23.44 -#define	MGAREG_XYSTRT		0x1c40
   23.45 -#define	MGAREG_XYEND		0x1c44
   23.46 -
   23.47 -#define	MGAREG_SHIFT		0x1c50
   23.48 -/* the following is a mystique only register */
   23.49 -#define MGAREG_DMAPAD		0x1c54
   23.50 -#define	MGAREG_SGN		0x1c58
   23.51 -#define	MGAREG_LEN		0x1c5c
   23.52 -
   23.53 -#define	MGAREG_AR0		0x1c60
   23.54 -#define	MGAREG_AR1		0x1c64
   23.55 -#define	MGAREG_AR2		0x1c68
   23.56 -#define	MGAREG_AR3		0x1c6c
   23.57 -#define	MGAREG_AR4		0x1c70
   23.58 -#define	MGAREG_AR5		0x1c74
   23.59 -#define	MGAREG_AR6		0x1c78
   23.60 -
   23.61 -#define	MGAREG_CXBNDRY		0x1c80
   23.62 -#define	MGAREG_FXBNDRY		0x1c84
   23.63 -#define	MGAREG_YDSTLEN		0x1c88
   23.64 -#define	MGAREG_PITCH		0x1c8c
   23.65 -
   23.66 -#define	MGAREG_YDST		0x1c90
   23.67 -#define	MGAREG_YDSTORG		0x1c94
   23.68 -#define	MGAREG_YTOP		0x1c98
   23.69 -#define	MGAREG_YBOT		0x1c9c
   23.70 -
   23.71 -#define	MGAREG_CXLEFT		0x1ca0
   23.72 -#define	MGAREG_CXRIGHT		0x1ca4
   23.73 -#define	MGAREG_FXLEFT		0x1ca8
   23.74 -#define	MGAREG_FXRIGHT		0x1cac
   23.75 -
   23.76 -#define	MGAREG_XDST		0x1cb0
   23.77 -
   23.78 -#define	MGAREG_DR0		0x1cc0
   23.79 -#define	MGAREG_DR1		0x1cc4
   23.80 -#define	MGAREG_DR2		0x1cc8
   23.81 -#define	MGAREG_DR3		0x1ccc
   23.82 -
   23.83 -#define	MGAREG_DR4		0x1cd0
   23.84 -#define	MGAREG_DR5		0x1cd4
   23.85 -#define	MGAREG_DR6		0x1cd8
   23.86 -#define	MGAREG_DR7		0x1cdc
   23.87 -
   23.88 -#define	MGAREG_DR8		0x1ce0
   23.89 -#define	MGAREG_DR9		0x1ce4
   23.90 -#define	MGAREG_DR10		0x1ce8
   23.91 -#define	MGAREG_DR11		0x1cec
   23.92 -
   23.93 -#define	MGAREG_DR12		0x1cf0
   23.94 -#define	MGAREG_DR13		0x1cf4
   23.95 -#define	MGAREG_DR14		0x1cf8
   23.96 -#define	MGAREG_DR15		0x1cfc
   23.97 -
   23.98 -#define MGAREG_SRCORG		0x2cb4
   23.99 -#define MGAREG_DSTORG		0x2cb8
  23.100 -
  23.101 -/* add or or this to one of the previous "power registers" to start
  23.102 -   the drawing engine */
  23.103 -
  23.104 -#define MGAREG_EXEC		0x0100
  23.105 -
  23.106 -#define	MGAREG_FIFOSTATUS	0x1e10
  23.107 -#define	MGAREG_STATUS		0x1e14
  23.108 -#define	MGAREG_ICLEAR		0x1e18
  23.109 -#define	MGAREG_IEN		0x1e1c
  23.110 -
  23.111 -#define	MGAREG_VCOUNT		0x1e20
  23.112 -
  23.113 -#define	MGAREG_Reset		0x1e40
  23.114 -
  23.115 -#define	MGAREG_OPMODE		0x1e54
  23.116 -
  23.117 -/* OPMODE register additives */
  23.118 -
  23.119 -#define MGAOPM_DMA_GENERAL	(0x00 << 2)
  23.120 -#define MGAOPM_DMA_BLIT		(0x01 << 2)
  23.121 -#define MGAOPM_DMA_VECTOR	(0x10 << 2)
  23.122 -
  23.123 -/* DWGCTL register additives */
  23.124 -
  23.125 -/* Lines */
  23.126 -
  23.127 -#define MGADWG_LINE_OPEN	0x00
  23.128 -#define MGADWG_AUTOLINE_OPEN	0x01
  23.129 -#define MGADWG_LINE_CLOSE	0x02
  23.130 -#define MGADWG_AUTOLINE_CLOSE	0x03
  23.131 -
  23.132 -/* Trapezoids */
  23.133 -#define MGADWG_TRAP		0x04
  23.134 -#define MGADWG_TEXTURE_TRAP	0x05
  23.135 -
  23.136 -/* BitBlts */
  23.137 -
  23.138 -#define MGADWG_BITBLT		0x08
  23.139 -#define MGADWG_FBITBLT		0x0c
  23.140 -#define MGADWG_ILOAD		0x09
  23.141 -#define MGADWG_ILOAD_SCALE	0x0d
  23.142 -#define MGADWG_ILOAD_FILTER	0x0f
  23.143 -#define MGADWG_IDUMP		0x0a
  23.144 -
  23.145 -/* atype access to WRAM */
  23.146 -
  23.147 -#define MGADWG_RPL		( 0x00 << 4 )
  23.148 -#define MGADWG_RSTR		( 0x01 << 4 )
  23.149 -#define MGADWG_ZI		( 0x03 << 4 )
  23.150 -#define MGADWG_BLK 		( 0x04 << 4 )
  23.151 -#define MGADWG_I		( 0x07 << 4 )
  23.152 -
  23.153 -/* specifies whether bit blits are linear or xy */
  23.154 -#define MGADWG_LINEAR		( 0x01 << 7 )
  23.155 -
  23.156 -/* z drawing mode. use MGADWG_NOZCMP for always */
  23.157 -
  23.158 -#define MGADWG_NOZCMP		( 0x00 << 8 )
  23.159 -#define MGADWG_ZE		( 0x02 << 8 )
  23.160 -#define MGADWG_ZNE		( 0x03 << 8 )
  23.161 -#define MGADWG_ZLT		( 0x04 << 8 )
  23.162 -#define MGADWG_ZLTE		( 0x05 << 8 )
  23.163 -#define MGADWG_GT		( 0x06 << 8 )
  23.164 -#define MGADWG_GTE		( 0x07 << 8 )
  23.165 -
  23.166 -/* use this to force colour expansion circuitry to do its stuff */
  23.167 -
  23.168 -#define MGADWG_SOLID		( 0x01 << 11 )
  23.169 -
  23.170 -/* ar register at zero */
  23.171 -
  23.172 -#define MGADWG_ARZERO		( 0x01 << 12 )
  23.173 -
  23.174 -#define MGADWG_SGNZERO		( 0x01 << 13 )
  23.175 -
  23.176 -#define MGADWG_SHIFTZERO	( 0x01 << 14 )
  23.177 -
  23.178 -/* See table on 4-43 for bop ALU operations */
  23.179 -
  23.180 -/* See table on 4-44 for translucidity masks */
  23.181 -
  23.182 -#define MGADWG_BMONOLEF		( 0x00 << 25 )
  23.183 -#define MGADWG_BMONOWF		( 0x04 << 25 )
  23.184 -#define MGADWG_BPLAN		( 0x01 << 25 )
  23.185 -
  23.186 -/* note that if bfcol is specified and you're doing a bitblt, it causes
  23.187 -   a fbitblt to be performed, so check that you obey the fbitblt rules */
  23.188 -
  23.189 -#define MGADWG_BFCOL   		( 0x02 << 25 )
  23.190 -#define MGADWG_BUYUV		( 0x0e << 25 )
  23.191 -#define MGADWG_BU32BGR		( 0x03 << 25 )
  23.192 -#define MGADWG_BU32RGB		( 0x07 << 25 )
  23.193 -#define MGADWG_BU24BGR		( 0x0b << 25 )
  23.194 -#define MGADWG_BU24RGB		( 0x0f << 25 )
  23.195 -
  23.196 -#define MGADWG_REPLACE		0x000C0000      /* From Linux kernel sources */
  23.197 -#define MGADWG_PATTERN		( 0x01 << 29 )
  23.198 -#define MGADWG_TRANSC		( 0x01 << 30 )
  23.199 -#define MGADWG_NOCLIP		( 0x01 << 31 )
  23.200 -#define MGAREG_MISC_WRITE	0x3c2
  23.201 -#define MGAREG_MISC_READ	0x3cc
  23.202 -#define MGAREG_MISC_IOADSEL	(0x1 << 0)
  23.203 -#define MGAREG_MISC_RAMMAPEN	(0x1 << 1)
  23.204 -#define MGAREG_MISC_CLK_SEL_VGA25	(0x0 << 2)
  23.205 -#define MGAREG_MISC_CLK_SEL_VGA28	(0x1 << 2)
  23.206 -#define MGAREG_MISC_CLK_SEL_MGA_PIX	(0x2 << 2)
  23.207 -#define MGAREG_MISC_CLK_SEL_MGA_MSK	(0x3 << 2)
  23.208 -#define MGAREG_MISC_VIDEO_DIS	(0x1 << 4)
  23.209 -#define MGAREG_MISC_HIGH_PG_SEL	(0x1 << 5)
  23.210 -
  23.211 -/* MMIO VGA registers */
  23.212 -#define MGAREG_CRTC_INDEX	0x1fd4
  23.213 -#define MGAREG_CRTC_DATA	0x1fd5
  23.214 -#define MGAREG_CRTCEXT_INDEX	0x1fde
  23.215 -#define MGAREG_CRTCEXT_DATA	0x1fdf
  23.216 -
  23.217 -
  23.218 -/* MGA bits for registers PCI_OPTION_REG */
  23.219 -#define MGA1064_OPT_SYS_CLK_PCI   		( 0x00 << 0 )
  23.220 -#define MGA1064_OPT_SYS_CLK_PLL   		( 0x01 << 0 )
  23.221 -#define MGA1064_OPT_SYS_CLK_EXT   		( 0x02 << 0 )
  23.222 -#define MGA1064_OPT_SYS_CLK_MSK   		( 0x03 << 0 )
  23.223 -
  23.224 -#define MGA1064_OPT_SYS_CLK_DIS   		( 0x01 << 2 )
  23.225 -#define MGA1064_OPT_G_CLK_DIV_1   		( 0x01 << 3 )
  23.226 -#define MGA1064_OPT_M_CLK_DIV_1   		( 0x01 << 4 )
  23.227 -
  23.228 -#define MGA1064_OPT_SYS_PLL_PDN   		( 0x01 << 5 )
  23.229 -#define MGA1064_OPT_VGA_ION   		( 0x01 << 8 )
  23.230 -
  23.231 -/* MGA registers in PCI config space */
  23.232 -#define PCI_MGA_INDEX		0x44
  23.233 -#define PCI_MGA_DATA		0x48
  23.234 -#define PCI_MGA_OPTION2		0x50
  23.235 -#define PCI_MGA_OPTION3		0x54
  23.236 -
  23.237 -#define RAMDAC_OFFSET		0x3c00
  23.238 -
  23.239 -/* TVP3026 direct registers */
  23.240 -
  23.241 -#define TVP3026_INDEX		0x00
  23.242 -#define TVP3026_WADR_PAL	0x00
  23.243 -#define TVP3026_COL_PAL		0x01
  23.244 -#define TVP3026_PIX_RD_MSK	0x02
  23.245 -#define TVP3026_RADR_PAL	0x03
  23.246 -#define TVP3026_CUR_COL_ADDR	0x04
  23.247 -#define TVP3026_CUR_COL_DATA	0x05
  23.248 -#define TVP3026_DATA		0x0a
  23.249 -#define TVP3026_CUR_RAM		0x0b
  23.250 -#define TVP3026_CUR_XLOW	0x0c
  23.251 -#define TVP3026_CUR_XHI		0x0d
  23.252 -#define TVP3026_CUR_YLOW	0x0e
  23.253 -#define TVP3026_CUR_YHI		0x0f
  23.254 -
  23.255 -/* TVP3026 indirect registers */
  23.256 -
  23.257 -#define TVP3026_SILICON_REV	0x01
  23.258 -#define TVP3026_CURSOR_CTL	0x06
  23.259 -#define TVP3026_LATCH_CTL	0x0f
  23.260 -#define TVP3026_TRUE_COLOR_CTL	0x18
  23.261 -#define TVP3026_MUX_CTL		0x19
  23.262 -#define TVP3026_CLK_SEL		0x1a
  23.263 -#define TVP3026_PAL_PAGE	0x1c
  23.264 -#define TVP3026_GEN_CTL		0x1d
  23.265 -#define TVP3026_MISC_CTL	0x1e
  23.266 -#define TVP3026_GEN_IO_CTL	0x2a
  23.267 -#define TVP3026_GEN_IO_DATA	0x2b
  23.268 -#define TVP3026_PLL_ADDR	0x2c
  23.269 -#define TVP3026_PIX_CLK_DATA	0x2d
  23.270 -#define TVP3026_MEM_CLK_DATA	0x2e
  23.271 -#define TVP3026_LOAD_CLK_DATA	0x2f
  23.272 -#define TVP3026_KEY_RED_LOW	0x32
  23.273 -#define TVP3026_KEY_RED_HI	0x33
  23.274 -#define TVP3026_KEY_GREEN_LOW	0x34
  23.275 -#define TVP3026_KEY_GREEN_HI	0x35
  23.276 -#define TVP3026_KEY_BLUE_LOW	0x36
  23.277 -#define TVP3026_KEY_BLUE_HI	0x37
  23.278 -#define TVP3026_KEY_CTL		0x38
  23.279 -#define TVP3026_MCLK_CTL	0x39
  23.280 -#define TVP3026_SENSE_TEST	0x3a
  23.281 -#define TVP3026_TEST_DATA	0x3b
  23.282 -#define TVP3026_CRC_LSB		0x3c
  23.283 -#define TVP3026_CRC_MSB		0x3d
  23.284 -#define TVP3026_CRC_CTL		0x3e
  23.285 -#define TVP3026_ID		0x3f
  23.286 -#define TVP3026_RESET		0xff
  23.287 -
  23.288 -
  23.289 -/* MGA1064 DAC Register file */
  23.290 -/* MGA1064 direct registers */
  23.291 -
  23.292 -#define MGA1064_INDEX		0x00
  23.293 -#define MGA1064_WADR_PAL	0x00
  23.294 -#define MGA1064_COL_PAL		0x01
  23.295 -#define MGA1064_PIX_RD_MSK	0x02
  23.296 -#define MGA1064_RADR_PAL	0x03
  23.297 -#define MGA1064_DATA		0x0a
  23.298 -
  23.299 -#define MGA1064_CUR_XLOW	0x0c
  23.300 -#define MGA1064_CUR_XHI		0x0d
  23.301 -#define MGA1064_CUR_YLOW	0x0e
  23.302 -#define MGA1064_CUR_YHI		0x0f
  23.303 -
  23.304 -/* MGA1064 indirect registers */
  23.305 -#define MGA1064_CURSOR_BASE_ADR_LOW	0x04
  23.306 -#define MGA1064_CURSOR_BASE_ADR_HI	0x05
  23.307 -#define MGA1064_CURSOR_CTL	0x06
  23.308 -#define MGA1064_CURSOR_COL0_RED	0x08
  23.309 -#define MGA1064_CURSOR_COL0_GREEN	0x09
  23.310 -#define MGA1064_CURSOR_COL0_BLUE	0x0a
  23.311 -
  23.312 -#define MGA1064_CURSOR_COL1_RED	0x0c
  23.313 -#define MGA1064_CURSOR_COL1_GREEN	0x0d
  23.314 -#define MGA1064_CURSOR_COL1_BLUE	0x0e
  23.315 -
  23.316 -#define MGA1064_CURSOR_COL2_RED	0x010
  23.317 -#define MGA1064_CURSOR_COL2_GREEN	0x011
  23.318 -#define MGA1064_CURSOR_COL2_BLUE	0x012
  23.319 -
  23.320 -#define MGA1064_VREF_CTL	0x018
  23.321 -
  23.322 -#define MGA1064_MUL_CTL		0x19
  23.323 -#define MGA1064_MUL_CTL_8bits		0x0
  23.324 -#define MGA1064_MUL_CTL_15bits		0x01
  23.325 -#define MGA1064_MUL_CTL_16bits		0x02
  23.326 -#define MGA1064_MUL_CTL_24bits		0x03
  23.327 -#define MGA1064_MUL_CTL_32bits		0x04
  23.328 -#define MGA1064_MUL_CTL_2G8V16bits		0x05
  23.329 -#define MGA1064_MUL_CTL_G16V16bits		0x06
  23.330 -#define MGA1064_MUL_CTL_32_24bits		0x07
  23.331 -
  23.332 -#define MGAGDAC_XVREFCTRL		0x18
  23.333 -#define MGA1064_PIX_CLK_CTL		0x1a
  23.334 -#define MGA1064_PIX_CLK_CTL_CLK_DIS   		( 0x01 << 2 )
  23.335 -#define MGA1064_PIX_CLK_CTL_CLK_POW_DOWN   	( 0x01 << 3 )
  23.336 -#define MGA1064_PIX_CLK_CTL_SEL_PCI   		( 0x00 << 0 )
  23.337 -#define MGA1064_PIX_CLK_CTL_SEL_PLL   		( 0x01 << 0 )
  23.338 -#define MGA1064_PIX_CLK_CTL_SEL_EXT   		( 0x02 << 0 )
  23.339 -#define MGA1064_PIX_CLK_CTL_SEL_MSK   		( 0x03 << 0 )
  23.340 -
  23.341 -#define MGA1064_GEN_CTL		0x1d
  23.342 -#define MGA1064_MISC_CTL	0x1e
  23.343 -#define MGA1064_MISC_CTL_DAC_POW_DN   		( 0x01 << 0 )
  23.344 -#define MGA1064_MISC_CTL_VGA   		( 0x01 << 1 )
  23.345 -#define MGA1064_MISC_CTL_DIS_CON   		( 0x03 << 1 )
  23.346 -#define MGA1064_MISC_CTL_MAFC   		( 0x02 << 1 )
  23.347 -#define MGA1064_MISC_CTL_VGA8   		( 0x01 << 3 )
  23.348 -#define MGA1064_MISC_CTL_DAC_RAM_CS   		( 0x01 << 4 )
  23.349 -
  23.350 -#define MGA1064_GEN_IO_CTL	0x2a
  23.351 -#define MGA1064_GEN_IO_DATA	0x2b
  23.352 -#define MGA1064_SYS_PLL_M	0x2c
  23.353 -#define MGA1064_SYS_PLL_N	0x2d
  23.354 -#define MGA1064_SYS_PLL_P	0x2e
  23.355 -#define MGA1064_SYS_PLL_STAT	0x2f
  23.356 -#define MGA1064_ZOOM_CTL	0x38
  23.357 -#define MGA1064_SENSE_TST	0x3a
  23.358 -
  23.359 -#define MGA1064_CRC_LSB		0x3c
  23.360 -#define MGA1064_CRC_MSB		0x3d
  23.361 -#define MGA1064_CRC_CTL		0x3e
  23.362 -#define MGA1064_COL_KEY_MSK_LSB		0x40
  23.363 -#define MGA1064_COL_KEY_MSK_MSB		0x41
  23.364 -#define MGA1064_COL_KEY_LSB		0x42
  23.365 -#define MGA1064_COL_KEY_MSB		0x43
  23.366 -#define MGA1064_PIX_PLLA_M	0x44
  23.367 -#define MGA1064_PIX_PLLA_N	0x45
  23.368 -#define MGA1064_PIX_PLLA_P	0x46
  23.369 -#define MGA1064_PIX_PLLB_M	0x48
  23.370 -#define MGA1064_PIX_PLLB_N	0x49
  23.371 -#define MGA1064_PIX_PLLB_P	0x4a
  23.372 -#define MGA1064_PIX_PLLC_M	0x4c
  23.373 -#define MGA1064_PIX_PLLC_N	0x4d
  23.374 -#define MGA1064_PIX_PLLC_P	0x4e
  23.375 -
  23.376 -#define MGA1064_PIX_PLL_STAT	0x4f
  23.377 -
  23.378 -#endif
  23.379 -/* vi: set ts=4 sw=4 expandtab: */
    24.1 --- a/src/video/fbcon/riva_mmio.h	Wed Jan 19 19:51:04 2011 -0800
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,455 +0,0 @@
    24.4 -/***************************************************************************\
    24.5 -|*                                                                           *|
    24.6 -|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
    24.7 -|*                                                                           *|
    24.8 -|*     NOTICE TO USER:   The source code  is copyrighted under  U.S. and     *|
    24.9 -|*     international laws.  Users and possessors of this source code are     *|
   24.10 -|*     hereby granted a nonexclusive,  royalty-free copyright license to     *|
   24.11 -|*     use this code in individual and commercial software.                  *|
   24.12 -|*                                                                           *|
   24.13 -|*     Any use of this source code must include,  in the user documenta-     *|
   24.14 -|*     tion and  internal comments to the code,  notices to the end user     *|
   24.15 -|*     as follows:                                                           *|
   24.16 -|*                                                                           *|
   24.17 -|*       Copyright 1993-1999 NVIDIA, Corporation.  All rights reserved.      *|
   24.18 -|*                                                                           *|
   24.19 -|*     NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY     *|
   24.20 -|*     OF  THIS SOURCE  CODE  FOR ANY PURPOSE.  IT IS  PROVIDED  "AS IS"     *|
   24.21 -|*     WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA, CORPOR-     *|
   24.22 -|*     ATION DISCLAIMS ALL WARRANTIES  WITH REGARD  TO THIS SOURCE CODE,     *|
   24.23 -|*     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE-     *|
   24.24 -|*     MENT,  AND FITNESS  FOR A PARTICULAR PURPOSE.   IN NO EVENT SHALL     *|
   24.25 -|*     NVIDIA, CORPORATION  BE LIABLE FOR ANY SPECIAL,  INDIRECT,  INCI-     *|
   24.26 -|*     DENTAL, OR CONSEQUENTIAL DAMAGES,  OR ANY DAMAGES  WHATSOEVER RE-     *|
   24.27 -|*     SULTING FROM LOSS OF USE,  DATA OR PROFITS,  WHETHER IN AN ACTION     *|
   24.28 -|*     OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,  ARISING OUT OF     *|
   24.29 -|*     OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.     *|
   24.30 -|*                                                                           *|
   24.31 -|*     U.S. Government  End  Users.   This source code  is a "commercial     *|
   24.32 -|*     item,"  as that  term is  defined at  48 C.F.R. 2.101 (OCT 1995),     *|
   24.33 -|*     consisting  of "commercial  computer  software"  and  "commercial     *|
   24.34 -|*     computer  software  documentation,"  as such  terms  are  used in     *|
   24.35 -|*     48 C.F.R. 12.212 (SEPT 1995)  and is provided to the U.S. Govern-     *|
   24.36 -|*     ment only as  a commercial end item.   Consistent with  48 C.F.R.     *|
   24.37 -|*     12.212 and  48 C.F.R. 227.7202-1 through  227.7202-4 (JUNE 1995),     *|
   24.38 -|*     all U.S. Government End Users  acquire the source code  with only     *|
   24.39 -|*     those rights set forth herein.                                        *|
   24.40 -|*                                                                           *|
   24.41 -\***************************************************************************/
   24.42 -
   24.43 -#ifndef __RIVA_HW_H__
   24.44 -#define __RIVA_HW_H__
   24.45 -#define RIVA_SW_VERSION 0x00010003
   24.46 -
   24.47 -/*
   24.48 - * Typedefs to force certain sized values.
   24.49 - */
   24.50 -typedef Uint8 U008;
   24.51 -typedef Uint16 U016;
   24.52 -typedef Uint32 U032;
   24.53 -
   24.54 -/*
   24.55 - * HW access macros.
   24.56 - */
   24.57 -#define NV_WR08(p,i,d)  (((U008 *)(p))[i]=(d))
   24.58 -#define NV_RD08(p,i)    (((U008 *)(p))[i])
   24.59 -#define NV_WR16(p,i,d)  (((U016 *)(p))[(i)/2]=(d))
   24.60 -#define NV_RD16(p,i)    (((U016 *)(p))[(i)/2])
   24.61 -#define NV_WR32(p,i,d)  (((U032 *)(p))[(i)/4]=(d))
   24.62 -#define NV_RD32(p,i)    (((U032 *)(p))[(i)/4])
   24.63 -#define VGA_WR08(p,i,d) NV_WR08(p,i,d)
   24.64 -#define VGA_RD08(p,i)   NV_RD08(p,i)
   24.65 -
   24.66 -/*
   24.67 - * Define supported architectures.
   24.68 - */
   24.69 -#define NV_ARCH_03  0x03
   24.70 -#define NV_ARCH_04  0x04
   24.71 -#define NV_ARCH_10  0x10
   24.72 -/***************************************************************************\
   24.73 -*                                                                           *
   24.74 -*                             FIFO registers.                               *
   24.75 -*                                                                           *
   24.76 -\***************************************************************************/
   24.77 -
   24.78 -/*
   24.79 - * Raster OPeration. Windows style ROP3.
   24.80 - */
   24.81 -typedef volatile struct
   24.82 -{
   24.83 -    U032 reserved00[4];
   24.84 -    U016 FifoFree;
   24.85 -    U016 Nop;
   24.86 -    U032 reserved01[0x0BB];
   24.87 -    U032 Rop3;
   24.88 -} RivaRop;
   24.89 -/*
   24.90 - * 8X8 Monochrome pattern.
   24.91 - */
   24.92 -typedef volatile struct
   24.93 -{
   24.94 -    U032 reserved00[4];
   24.95 -    U016 FifoFree;
   24.96 -    U016 Nop;
   24.97 -    U032 reserved01[0x0BD];
   24.98 -    U032 Shape;
   24.99 -    U032 reserved03[0x001];
  24.100 -    U032 Color0;
  24.101 -    U032 Color1;
  24.102 -    U032 Monochrome[2];
  24.103 -} RivaPattern;
  24.104 -/*
  24.105 - * Scissor clip rectangle.
  24.106 - */
  24.107 -typedef volatile struct
  24.108 -{
  24.109 -    U032 reserved00[4];
  24.110 -    U016 FifoFree;
  24.111 -    U016 Nop;
  24.112 -    U032 reserved01[0x0BB];
  24.113 -    U032 TopLeft;
  24.114 -    U032 WidthHeight;
  24.115 -} RivaClip;
  24.116 -/*
  24.117 - * 2D filled rectangle.
  24.118 - */
  24.119 -typedef volatile struct
  24.120 -{
  24.121 -    U032 reserved00[4];
  24.122 -    U016 FifoFree;
  24.123 -    U016 Nop[1];
  24.124 -    U032 reserved01[0x0BC];
  24.125 -    U032 Color;
  24.126 -    U032 reserved03[0x03E];
  24.127 -    U032 TopLeft;
  24.128 -    U032 WidthHeight;
  24.129 -} RivaRectangle;
  24.130 -/*
  24.131 - * 2D screen-screen BLT.
  24.132 - */
  24.133 -typedef volatile struct
  24.134 -{
  24.135 -    U032 reserved00[4];
  24.136 -    U016 FifoFree;
  24.137 -    U016 Nop;
  24.138 -    U032 reserved01[0x0BB];
  24.139 -    U032 TopLeftSrc;
  24.140 -    U032 TopLeftDst;
  24.141 -    U032 WidthHeight;
  24.142 -} RivaScreenBlt;
  24.143 -/*
  24.144 - * 2D pixel BLT.
  24.145 - */
  24.146 -typedef volatile struct
  24.147 -{
  24.148 -    U032 reserved00[4];
  24.149 -    U016 FifoFree;
  24.150 -    U016 Nop[1];
  24.151 -    U032 reserved01[0x0BC];
  24.152 -    U032 TopLeft;
  24.153 -    U032 WidthHeight;
  24.154 -    U032 WidthHeightIn;
  24.155 -    U032 reserved02[0x03C];
  24.156 -    U032 Pixels;
  24.157 -} RivaPixmap;
  24.158 -/*
  24.159 - * Filled rectangle combined with monochrome expand.  Useful for glyphs.
  24.160 - */
  24.161 -typedef volatile struct
  24.162 -{
  24.163 -    U032 reserved00[4];
  24.164 -    U016 FifoFree;
  24.165 -    U016 Nop;
  24.166 -    U032 reserved01[0x0BB];
  24.167 -    U032 reserved03[(0x040) - 1];
  24.168 -    U032 Color1A;
  24.169 -    struct
  24.170 -    {
  24.171 -        U032 TopLeft;
  24.172 -        U032 WidthHeight;
  24.173 -    } UnclippedRectangle[64];
  24.174 -    U032 reserved04[(0x080) - 3];
  24.175 -    struct
  24.176 -    {
  24.177 -        U032 TopLeft;
  24.178 -        U032 BottomRight;
  24.179 -    } ClipB;
  24.180 -    U032 Color1B;
  24.181 -    struct
  24.182 -    {
  24.183 -        U032 TopLeft;
  24.184 -        U032 BottomRight;
  24.185 -    } ClippedRectangle[64];
  24.186 -    U032 reserved05[(0x080) - 5];
  24.187 -    struct
  24.188 -    {
  24.189 -        U032 TopLeft;
  24.190 -        U032 BottomRight;
  24.191 -    } ClipC;
  24.192 -    U032 Color1C;
  24.193 -    U032 WidthHeightC;
  24.194 -    U032 PointC;
  24.195 -    U032 MonochromeData1C;
  24.196 -    U032 reserved06[(0x080) + 121];
  24.197 -    struct
  24.198 -    {
  24.199 -        U032 TopLeft;
  24.200 -        U032 BottomRight;
  24.201 -    } ClipD;
  24.202 -    U032 Color1D;
  24.203 -    U032 WidthHeightInD;
  24.204 -    U032 WidthHeightOutD;
  24.205 -    U032 PointD;
  24.206 -    U032 MonochromeData1D;
  24.207 -    U032 reserved07[(0x080) + 120];
  24.208 -    struct
  24.209 -    {
  24.210 -        U032 TopLeft;
  24.211 -        U032 BottomRight;
  24.212 -    } ClipE;
  24.213 -    U032 Color0E;
  24.214 -    U032 Color1E;
  24.215 -    U032 WidthHeightInE;
  24.216 -    U032 WidthHeightOutE;
  24.217 -    U032 PointE;
  24.218 -    U032 MonochromeData01E;
  24.219 -} RivaBitmap;
  24.220 -/*
  24.221 - * 3D textured, Z buffered triangle.
  24.222 - */
  24.223 -typedef volatile struct
  24.224 -{
  24.225 -    U032 reserved00[4];
  24.226 -    U016 FifoFree;
  24.227 -    U016 Nop;
  24.228 -    U032 reserved01[0x0BC];
  24.229 -    U032 TextureOffset;
  24.230 -    U032 TextureFormat;
  24.231 -    U032 TextureFilter;
  24.232 -    U032 FogColor;
  24.233 -/* This is a problem on LynxOS */
  24.234 -#ifdef Control
  24.235 -#undef Control
  24.236 -#endif
  24.237 -    U032 Control;
  24.238 -    U032 AlphaTest;
  24.239 -    U032 reserved02[0x339];
  24.240 -    U032 FogAndIndex;
  24.241 -    U032 Color;
  24.242 -    float ScreenX;
  24.243 -    float ScreenY;
  24.244 -    float ScreenZ;
  24.245 -    float EyeM;
  24.246 -    float TextureS;
  24.247 -    float TextureT;
  24.248 -} RivaTexturedTriangle03;
  24.249 -typedef volatile struct
  24.250 -{
  24.251 -    U032 reserved00[4];
  24.252 -    U016 FifoFree;
  24.253 -    U016 Nop;
  24.254 -    U032 reserved01[0x0BB];
  24.255 -    U032 ColorKey;
  24.256 -    U032 TextureOffset;
  24.257 -    U032 TextureFormat;
  24.258 -    U032 TextureFilter;
  24.259 -    U032 Blend;
  24.260 -/* This is a problem on LynxOS */
  24.261 -#ifdef Control
  24.262 -#undef Control
  24.263 -#endif
  24.264 -    U032 Control;
  24.265 -    U032 FogColor;
  24.266 -    U032 reserved02[0x39];
  24.267 -    struct
  24.268 -    {
  24.269 -        float ScreenX;
  24.270 -        float ScreenY;
  24.271 -        float ScreenZ;
  24.272 -        float EyeM;
  24.273 -        U032 Color;
  24.274 -        U032 Specular;
  24.275 -        float TextureS;
  24.276 -        float TextureT;
  24.277 -    } Vertex[16];
  24.278 -    U032 DrawTriangle3D;
  24.279 -} RivaTexturedTriangle05;
  24.280 -/*
  24.281 - * 2D line.
  24.282 - */
  24.283 -typedef volatile struct
  24.284 -{
  24.285 -    U032 reserved00[4];
  24.286 -    U016 FifoFree;
  24.287 -    U016 Nop[1];
  24.288 -    U032 reserved01[0x0BC];
  24.289 -    U032 Color;                 /* source color               0304-0307 */
  24.290 -    U032 Reserved02[0x03e];
  24.291 -    struct
  24.292 -    {                           /* start aliased methods in array   0400-    */
  24.293 -        U032 point0;            /* y_x S16_S16 in pixels            0-   3 */
  24.294 -        U032 point1;            /* y_x S16_S16 in pixels            4-   7 */
  24.295 -    } Lin[16];                  /* end of aliased methods in array      -047f */
  24.296 -    struct
  24.297 -    {                           /* start aliased methods in array   0480-    */
  24.298 -        U032 point0X;           /* in pixels, 0 at left                0-   3 */
  24.299 -        U032 point0Y;           /* in pixels, 0 at top                 4-   7 */
  24.300 -        U032 point1X;           /* in pixels, 0 at left                8-   b */
  24.301 -        U032 point1Y;           /* in pixels, 0 at top                 c-   f */
  24.302 -    } Lin32[8];                 /* end of aliased methods in array      -04ff */
  24.303 -    U032 PolyLin[32];           /* y_x S16_S16 in pixels         0500-057f */
  24.304 -    struct
  24.305 -    {                           /* start aliased methods in array   0580-    */
  24.306 -        U032 x;                 /* in pixels, 0 at left                0-   3 */
  24.307 -        U032 y;                 /* in pixels, 0 at top                 4-   7 */
  24.308 -    } PolyLin32[16];            /* end of aliased methods in array      -05ff */
  24.309 -    struct
  24.310 -    {                           /* start aliased methods in array   0600-    */
  24.311 -        U032 color;             /* source color                     0-   3 */
  24.312 -        U032 point;             /* y_x S16_S16 in pixels            4-   7 */
  24.313 -    } ColorPolyLin[16];         /* end of aliased methods in array      -067f */
  24.314 -} RivaLine;
  24.315 -/*
  24.316 - * 2D/3D surfaces
  24.317 - */
  24.318 -typedef volatile struct
  24.319 -{
  24.320 -    U032 reserved00[4];
  24.321 -    U016 FifoFree;
  24.322 -    U016 Nop;
  24.323 -    U032 reserved01[0x0BE];
  24.324 -    U032 Offset;
  24.325 -} RivaSurface;
  24.326 -typedef volatile struct
  24.327 -{
  24.328 -    U032 reserved00[4];
  24.329 -    U016 FifoFree;
  24.330 -    U016 Nop;
  24.331 -    U032 reserved01[0x0BD];
  24.332 -    U032 Pitch;
  24.333 -    U032 RenderBufferOffset;
  24.334 -    U032 ZBufferOffset;
  24.335 -} RivaSurface3D;
  24.336 -
  24.337 -/***************************************************************************\
  24.338 -*                                                                           *
  24.339 -*                        Virtualized RIVA H/W interface.                    *
  24.340 -*                                                                           *
  24.341 -\***************************************************************************/
  24.342 -
  24.343 -struct _riva_hw_inst;
  24.344 -struct _riva_hw_state;
  24.345 -/*
  24.346 - * Virtialized chip interface. Makes RIVA 128 and TNT look alike.
  24.347 - */
  24.348 -typedef struct _riva_hw_inst
  24.349 -{
  24.350 -    /*
  24.351 -     * Chip specific settings.
  24.352 -     */
  24.353 -    U032 Architecture;
  24.354 -    U032 Version;
  24.355 -    U032 CrystalFreqKHz;
  24.356 -    U032 RamAmountKBytes;
  24.357 -    U032 MaxVClockFreqKHz;
  24.358 -    U032 RamBandwidthKBytesPerSec;
  24.359 -    U032 EnableIRQ;
  24.360 -    U032 IO;
  24.361 -    U032 VBlankBit;
  24.362 -    U032 FifoFreeCount;
  24.363 -    U032 FifoEmptyCount;
  24.364 -    /*
  24.365 -     * Non-FIFO registers.
  24.366 -     */
  24.367 -    volatile U032 *PCRTC;
  24.368 -    volatile U032 *PRAMDAC;
  24.369 -    volatile U032 *PFB;
  24.370 -    volatile U032 *PFIFO;
  24.371 -    volatile U032 *PGRAPH;
  24.372 -    volatile U032 *PEXTDEV;
  24.373 -    volatile U032 *PTIMER;
  24.374 -    volatile U032 *PMC;
  24.375 -    volatile U032 *PRAMIN;
  24.376 -    volatile U032 *FIFO;
  24.377 -    volatile U032 *CURSOR;
  24.378 -    volatile U032 *CURSORPOS;
  24.379 -    volatile U032 *VBLANKENABLE;
  24.380 -    volatile U032 *VBLANK;
  24.381 -    volatile U008 *PCIO;
  24.382 -    volatile U008 *PVIO;
  24.383 -    volatile U008 *PDIO;
  24.384 -    /*
  24.385 -     * Common chip functions.
  24.386 -     */
  24.387 -    int (*Busy) (struct _riva_hw_inst *);
  24.388 -    void (*CalcStateExt) (struct _riva_hw_inst *, struct _riva_hw_state *,
  24.389 -                          int, int, int, int, int, int, int, int, int, int,
  24.390 -                          int, int, int);
  24.391 -    void (*LoadStateExt) (struct _riva_hw_inst *, struct _riva_hw_state *);
  24.392 -    void (*UnloadStateExt) (struct _riva_hw_inst *, struct _riva_hw_state *);
  24.393 -    void (*SetStartAddress) (struct _riva_hw_inst *, U032);
  24.394 -    void (*SetSurfaces2D) (struct _riva_hw_inst *, U032, U032);
  24.395 -    void (*SetSurfaces3D) (struct _riva_hw_inst *, U032, U032);
  24.396 -    int (*ShowHideCursor) (struct _riva_hw_inst *, int);
  24.397 -    void (*LockUnlock) (struct _riva_hw_inst *, int);
  24.398 -    /*
  24.399 -     * Current extended mode settings.
  24.400 -     */
  24.401 -    struct _riva_hw_state *CurrentState;
  24.402 -    /*
  24.403 -     * FIFO registers.
  24.404 -     */
  24.405 -    RivaRop *Rop;
  24.406 -    RivaPattern *Patt;
  24.407 -    RivaClip *Clip;
  24.408 -    RivaPixmap *Pixmap;
  24.409 -    RivaScreenBlt *Blt;
  24.410 -    RivaBitmap *Bitmap;
  24.411 -    RivaLine *Line;
  24.412 -    RivaTexturedTriangle03 *Tri03;
  24.413 -    RivaTexturedTriangle05 *Tri05;
  24.414 -} RIVA_HW_INST;
  24.415 -/*
  24.416 - * Extended mode state information.
  24.417 - */
  24.418 -typedef struct _riva_hw_state
  24.419 -{
  24.420 -    U032 bpp;
  24.421 -    U032 width;
  24.422 -    U032 height;
  24.423 -    U032 repaint0;
  24.424 -    U032 repaint1;
  24.425 -    U032 screen;
  24.426 -    U032 pixel;
  24.427 -    U032 horiz;
  24.428 -    U032 arbitration0;
  24.429 -    U032 arbitration1;
  24.430 -    U032 vpll;
  24.431 -    U032 pllsel;
  24.432 -    U032 general;
  24.433 -    U032 config;
  24.434 -    U032 cursor0;
  24.435 -    U032 cursor1;
  24.436 -    U032 cursor2;
  24.437 -    U032 offset0;
  24.438 -    U032 offset1;
  24.439 -    U032 offset2;
  24.440 -    U032 offset3;
  24.441 -    U032 pitch0;
  24.442 -    U032 pitch1;
  24.443 -    U032 pitch2;
  24.444 -    U032 pitch3;
  24.445 -} RIVA_HW_STATE;
  24.446 -
  24.447 -/*
  24.448 - * FIFO Free Count. Should attempt to yield processor if RIVA is busy.
  24.449 - */
  24.450 -
  24.451 -#define RIVA_FIFO_FREE(hwptr,cnt)                                  \
  24.452 -{                                                                  \
  24.453 -   while (FifoFreeCount < (cnt))                                   \
  24.454 -	FifoFreeCount = hwptr->FifoFree >> 2;                      \
  24.455 -   FifoFreeCount -= (cnt);                                         \
  24.456 -}
  24.457 -#endif /* __RIVA_HW_H__ */
  24.458 -/* vi: set ts=4 sw=4 expandtab: */
    25.1 --- a/src/video/fbcon/riva_regs.h	Wed Jan 19 19:51:04 2011 -0800
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,43 +0,0 @@
    25.4 -/*
    25.5 -    SDL - Simple DirectMedia Layer
    25.6 -    Copyright (C) 1997-2010 Sam Lantinga
    25.7 -
    25.8 -    This library is free software; you can redistribute it and/or
    25.9 -    modify it under the terms of the GNU Lesser General Public
   25.10 -    License as published by the Free Software Foundation; either
   25.11 -    version 2.1 of the License, or (at your option) any later version.
   25.12 -
   25.13 -    This library is distributed in the hope that it will be useful,
   25.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   25.16 -    Lesser General Public License for more details.
   25.17 -
   25.18 -    You should have received a copy of the GNU Lesser General Public
   25.19 -    License along with this library; if not, write to the Free Software
   25.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   25.21 -
   25.22 -    Sam Lantinga
   25.23 -    slouken@libsdl.org
   25.24 -*/
   25.25 -#include "SDL_config.h"
   25.26 -
   25.27 -#ifndef _RIVA_REGS_H
   25.28 -#define _RIVA_REGS_H
   25.29 -
   25.30 -/* This information comes from the XFree86 NVidia hardware driver */
   25.31 -
   25.32 -/* mapped_io register offsets */
   25.33 -#define PGRAPH_OFFSET	0x00400000
   25.34 -#define FIFO_OFFSET	0x00800000
   25.35 -#define ROP_OFFSET	FIFO_OFFSET+0x00000000
   25.36 -#define CLIP_OFFSET	FIFO_OFFSET+0x00002000
   25.37 -#define PATT_OFFSET	FIFO_OFFSET+0x00004000
   25.38 -#define PIXMAP_OFFSET	FIFO_OFFSET+0x00006000
   25.39 -#define BLT_OFFSET	FIFO_OFFSET+0x00008000
   25.40 -#define BITMAP_OFFSET	FIFO_OFFSET+0x0000A000
   25.41 -#define LINE_OFFSET	FIFO_OFFSET+0x0000C000
   25.42 -#define TRI03_OFFSET	FIFO_OFFSET+0x0000E000
   25.43 -#define PCIO_OFFSET	0x00601000
   25.44 -
   25.45 -#endif /* _RIVA_REGS_H */
   25.46 -/* vi: set ts=4 sw=4 expandtab: */