src/video/directfb/SDL_DirectFB_video.c
changeset 1895 c121d94672cb
parent 1777 402d5ff1cf88
child 2113 6264c973814a
     1.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Thu Jul 06 18:01:37 2006 +0000
     1.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Mon Jul 10 21:04:37 2006 +0000
     1.3 @@ -45,41 +45,47 @@
     1.4  #include "SDL_DirectFB_yuv.h"
     1.5  
     1.6  /* The implementation dependent data for the window manager cursor */
     1.7 -struct WMcursor {
     1.8 -	int unused;
     1.9 +struct WMcursor
    1.10 +{
    1.11 +    int unused;
    1.12  };
    1.13  
    1.14  
    1.15  /* Initialization/Query functions */
    1.16 -static int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat);
    1.17 -static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
    1.18 -static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
    1.19 +static int DirectFB_VideoInit(_THIS, SDL_PixelFormat * vformat);
    1.20 +static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat * format,
    1.21 +                                     Uint32 flags);
    1.22 +static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface * current,
    1.23 +                                          int width, int height, int bpp,
    1.24 +                                          Uint32 flags);
    1.25  static int DirectFB_SetColors(_THIS, int firstcolor, int ncolors,
    1.26 -			 SDL_Color *colors);
    1.27 +                              SDL_Color * colors);
    1.28  static void DirectFB_VideoQuit(_THIS);
    1.29  
    1.30  /* Hardware surface functions */
    1.31 -static int DirectFB_AllocHWSurface(_THIS, SDL_Surface *surface);
    1.32 -static int DirectFB_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
    1.33 -static int DirectFB_LockHWSurface(_THIS, SDL_Surface *surface);
    1.34 -static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface *surface);
    1.35 -static void DirectFB_FreeHWSurface(_THIS, SDL_Surface *surface);
    1.36 -static int DirectFB_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst);
    1.37 -static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
    1.38 -                                SDL_Surface *dst, SDL_Rect *dstrect);
    1.39 -static int DirectFB_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key);
    1.40 -static int DirectFB_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha);
    1.41 -static int DirectFB_FlipHWSurface(_THIS, SDL_Surface *surface);
    1.42 -static int DirectFB_ShowWMCursor(_THIS, WMcursor *cursor);
    1.43 +static int DirectFB_AllocHWSurface(_THIS, SDL_Surface * surface);
    1.44 +static int DirectFB_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect,
    1.45 +                               Uint32 color);
    1.46 +static int DirectFB_LockHWSurface(_THIS, SDL_Surface * surface);
    1.47 +static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface * surface);
    1.48 +static void DirectFB_FreeHWSurface(_THIS, SDL_Surface * surface);
    1.49 +static int DirectFB_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst);
    1.50 +static int DirectFB_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
    1.51 +                                SDL_Surface * dst, SDL_Rect * dstrect);
    1.52 +static int DirectFB_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key);
    1.53 +static int DirectFB_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha);
    1.54 +static int DirectFB_FlipHWSurface(_THIS, SDL_Surface * surface);
    1.55 +static int DirectFB_ShowWMCursor(_THIS, WMcursor * cursor);
    1.56  
    1.57  /* Various screen update functions available */
    1.58 -static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
    1.59 -static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects);
    1.60 +static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
    1.61 +static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect * rects);
    1.62  
    1.63  /* This is the rect EnumModes2 uses */
    1.64 -struct DirectFBEnumRect {
    1.65 -	SDL_Rect r;
    1.66 -	struct DirectFBEnumRect* next;
    1.67 +struct DirectFBEnumRect
    1.68 +{
    1.69 +    SDL_Rect r;
    1.70 +    struct DirectFBEnumRect *next;
    1.71  };
    1.72  
    1.73  static struct DirectFBEnumRect *enumlist = NULL;
    1.74 @@ -87,943 +93,953 @@
    1.75  
    1.76  /* DirectFB driver bootstrap functions */
    1.77  
    1.78 -static int DirectFB_Available(void)
    1.79 +static int
    1.80 +DirectFB_Available(void)
    1.81  {
    1.82 -  return 1;
    1.83 +    return 1;
    1.84  }
    1.85  
    1.86 -static void DirectFB_DeleteDevice(SDL_VideoDevice *device)
    1.87 +static void
    1.88 +DirectFB_DeleteDevice(SDL_VideoDevice * device)
    1.89  {
    1.90 -  SDL_free(device->hidden);
    1.91 -  SDL_free(device);
    1.92 +    SDL_free(device->hidden);
    1.93 +    SDL_free(device);
    1.94  }
    1.95  
    1.96 -static SDL_VideoDevice *DirectFB_CreateDevice(int devindex)
    1.97 +static SDL_VideoDevice *
    1.98 +DirectFB_CreateDevice(int devindex)
    1.99  {
   1.100 -  SDL_VideoDevice *device;
   1.101 +    SDL_VideoDevice *device;
   1.102  
   1.103 -  /* Initialize all variables that we clean on shutdown */
   1.104 -  device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
   1.105 -  if (device)
   1.106 -    {
   1.107 -      SDL_memset (device, 0, (sizeof *device));
   1.108 -      device->hidden = (struct SDL_PrivateVideoData *) malloc (sizeof (*device->hidden));
   1.109 +    /* Initialize all variables that we clean on shutdown */
   1.110 +    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
   1.111 +    if (device) {
   1.112 +        SDL_memset(device, 0, (sizeof *device));
   1.113 +        device->hidden = (struct SDL_PrivateVideoData *)
   1.114 +            malloc(sizeof(*device->hidden));
   1.115      }
   1.116 -  if (device == NULL  ||  device->hidden == NULL)
   1.117 -    {
   1.118 -      SDL_OutOfMemory();
   1.119 -      if (device)
   1.120 -        {
   1.121 -          free (device);
   1.122 +    if (device == NULL || device->hidden == NULL) {
   1.123 +        SDL_OutOfMemory();
   1.124 +        if (device) {
   1.125 +            free(device);
   1.126          }
   1.127 -      return(0);
   1.128 +        return (0);
   1.129      }
   1.130 -  SDL_memset (device->hidden, 0, sizeof (*device->hidden));
   1.131 +    SDL_memset(device->hidden, 0, sizeof(*device->hidden));
   1.132  
   1.133 -  /* Set the function pointers */
   1.134 -  device->VideoInit = DirectFB_VideoInit;
   1.135 -  device->ListModes = DirectFB_ListModes;
   1.136 -  device->SetVideoMode = DirectFB_SetVideoMode;
   1.137 -  device->SetColors = DirectFB_SetColors;
   1.138 -  device->UpdateRects = NULL;
   1.139 -  device->CreateYUVOverlay = DirectFB_CreateYUVOverlay;
   1.140 -  device->VideoQuit = DirectFB_VideoQuit;
   1.141 -  device->AllocHWSurface = DirectFB_AllocHWSurface;
   1.142 -  device->CheckHWBlit = DirectFB_CheckHWBlit;
   1.143 -  device->FillHWRect = DirectFB_FillHWRect;
   1.144 -  device->SetHWColorKey = DirectFB_SetHWColorKey;
   1.145 -  device->SetHWAlpha = DirectFB_SetHWAlpha;
   1.146 -  device->LockHWSurface = DirectFB_LockHWSurface;
   1.147 -  device->UnlockHWSurface = DirectFB_UnlockHWSurface;
   1.148 -  device->FlipHWSurface = DirectFB_FlipHWSurface;
   1.149 -  device->FreeHWSurface = DirectFB_FreeHWSurface;
   1.150 -  device->ShowWMCursor = DirectFB_ShowWMCursor;
   1.151 -  device->SetCaption = NULL;
   1.152 -  device->SetIcon = NULL;
   1.153 -  device->IconifyWindow = NULL;
   1.154 -  device->GrabInput = NULL;
   1.155 -  device->GetWMInfo = NULL;
   1.156 -  device->InitOSKeymap = DirectFB_InitOSKeymap;
   1.157 -  device->PumpEvents = DirectFB_PumpEvents;
   1.158 +    /* Set the function pointers */
   1.159 +    device->VideoInit = DirectFB_VideoInit;
   1.160 +    device->ListModes = DirectFB_ListModes;
   1.161 +    device->SetVideoMode = DirectFB_SetVideoMode;
   1.162 +    device->SetColors = DirectFB_SetColors;
   1.163 +    device->UpdateRects = NULL;
   1.164 +    device->CreateYUVOverlay = DirectFB_CreateYUVOverlay;
   1.165 +    device->VideoQuit = DirectFB_VideoQuit;
   1.166 +    device->AllocHWSurface = DirectFB_AllocHWSurface;
   1.167 +    device->CheckHWBlit = DirectFB_CheckHWBlit;
   1.168 +    device->FillHWRect = DirectFB_FillHWRect;
   1.169 +    device->SetHWColorKey = DirectFB_SetHWColorKey;
   1.170 +    device->SetHWAlpha = DirectFB_SetHWAlpha;
   1.171 +    device->LockHWSurface = DirectFB_LockHWSurface;
   1.172 +    device->UnlockHWSurface = DirectFB_UnlockHWSurface;
   1.173 +    device->FlipHWSurface = DirectFB_FlipHWSurface;
   1.174 +    device->FreeHWSurface = DirectFB_FreeHWSurface;
   1.175 +    device->ShowWMCursor = DirectFB_ShowWMCursor;
   1.176 +    device->SetCaption = NULL;
   1.177 +    device->SetIcon = NULL;
   1.178 +    device->IconifyWindow = NULL;
   1.179 +    device->GrabInput = NULL;
   1.180 +    device->GetWMInfo = NULL;
   1.181 +    device->InitOSKeymap = DirectFB_InitOSKeymap;
   1.182 +    device->PumpEvents = DirectFB_PumpEvents;
   1.183  
   1.184 -  device->free = DirectFB_DeleteDevice;
   1.185 +    device->free = DirectFB_DeleteDevice;
   1.186  
   1.187 -  return device;
   1.188 +    return device;
   1.189  }
   1.190  
   1.191  VideoBootStrap DirectFB_bootstrap = {
   1.192 -  "directfb", "DirectFB",
   1.193 -  DirectFB_Available, DirectFB_CreateDevice
   1.194 +    "directfb", "DirectFB",
   1.195 +    DirectFB_Available, DirectFB_CreateDevice
   1.196  };
   1.197  
   1.198 -static DFBSurfacePixelFormat GetFormatForBpp (int bpp, IDirectFBDisplayLayer *layer)
   1.199 +static DFBSurfacePixelFormat
   1.200 +GetFormatForBpp(int bpp, IDirectFBDisplayLayer * layer)
   1.201  {
   1.202 -  DFBDisplayLayerConfig dlc;
   1.203 -  int                   bytes = (bpp + 7) / 8;
   1.204 +    DFBDisplayLayerConfig dlc;
   1.205 +    int bytes = (bpp + 7) / 8;
   1.206  
   1.207 -  layer->GetConfiguration (layer, &dlc);
   1.208 -
   1.209 -  if (bytes == DFB_BYTES_PER_PIXEL(dlc.pixelformat) && bytes > 1)
   1.210 -    return dlc.pixelformat;
   1.211 +    layer->GetConfiguration(layer, &dlc);
   1.212  
   1.213 -  switch (bytes)
   1.214 -    {
   1.215 +    if (bytes == DFB_BYTES_PER_PIXEL(dlc.pixelformat) && bytes > 1)
   1.216 +        return dlc.pixelformat;
   1.217 +
   1.218 +    switch (bytes) {
   1.219      case 1:
   1.220 -      return DSPF_LUT8;
   1.221 +        return DSPF_LUT8;
   1.222      case 2:
   1.223 -      return DSPF_RGB16;
   1.224 +        return DSPF_RGB16;
   1.225      case 3:
   1.226 -      return DSPF_RGB24;
   1.227 +        return DSPF_RGB24;
   1.228      case 4:
   1.229 -      return DSPF_RGB32;
   1.230 +        return DSPF_RGB32;
   1.231      }
   1.232  
   1.233 -  return DSPF_UNKNOWN;
   1.234 +    return DSPF_UNKNOWN;
   1.235  }
   1.236  
   1.237 -static DFBEnumerationResult EnumModesCallback (int  width,
   1.238 -                                               int  height,
   1.239 -                                               int  bpp,
   1.240 -                                               void *data)
   1.241 +static DFBEnumerationResult
   1.242 +EnumModesCallback(int width, int height, int bpp, void *data)
   1.243  {
   1.244 -  SDL_VideoDevice *this = (SDL_VideoDevice *)data;
   1.245 -  struct DirectFBEnumRect *enumrect;
   1.246 +    SDL_VideoDevice *this = (SDL_VideoDevice *) data;
   1.247 +    struct DirectFBEnumRect *enumrect;
   1.248 +
   1.249 +    HIDDEN->nummodes++;
   1.250  
   1.251 -  HIDDEN->nummodes++;
   1.252 -
   1.253 -  if (enumlist && enumlist->r.w == width && enumlist->r.h == height)
   1.254 -    return DFENUM_OK;
   1.255 +    if (enumlist && enumlist->r.w == width && enumlist->r.h == height)
   1.256 +        return DFENUM_OK;
   1.257  
   1.258 -  enumrect = SDL_calloc(1, sizeof(struct DirectFBEnumRect));
   1.259 -  if (!enumrect)
   1.260 -    {
   1.261 -      SDL_OutOfMemory();
   1.262 -      return DFENUM_CANCEL;
   1.263 +    enumrect = SDL_calloc(1, sizeof(struct DirectFBEnumRect));
   1.264 +    if (!enumrect) {
   1.265 +        SDL_OutOfMemory();
   1.266 +        return DFENUM_CANCEL;
   1.267      }
   1.268  
   1.269 -  enumrect->r.w  = (Uint16)width;
   1.270 -  enumrect->r.h  = (Uint16)height;
   1.271 -  enumrect->next = enumlist;
   1.272 +    enumrect->r.w = (Uint16) width;
   1.273 +    enumrect->r.h = (Uint16) height;
   1.274 +    enumrect->next = enumlist;
   1.275  
   1.276 -  enumlist = enumrect;
   1.277 +    enumlist = enumrect;
   1.278  
   1.279 -  return DFENUM_OK;
   1.280 +    return DFENUM_OK;
   1.281  }
   1.282  
   1.283 -struct private_hwdata {
   1.284 -  IDirectFBSurface *surface;
   1.285 -  IDirectFBPalette *palette;
   1.286 +struct private_hwdata
   1.287 +{
   1.288 +    IDirectFBSurface *surface;
   1.289 +    IDirectFBPalette *palette;
   1.290  };
   1.291  
   1.292 -void SetDirectFBerror (const char *function, DFBResult code)
   1.293 +void
   1.294 +SetDirectFBerror(const char *function, DFBResult code)
   1.295  {
   1.296 -  const char *error = DirectFBErrorString (code);
   1.297 +    const char *error = DirectFBErrorString(code);
   1.298  
   1.299 -  if (error)
   1.300 -    SDL_SetError("%s: %s", function, error);
   1.301 -  else
   1.302 -    SDL_SetError("Unknown error code from %s", function);
   1.303 +    if (error)
   1.304 +        SDL_SetError("%s: %s", function, error);
   1.305 +    else
   1.306 +        SDL_SetError("Unknown error code from %s", function);
   1.307  }
   1.308  
   1.309 -static DFBSurfacePixelFormat SDLToDFBPixelFormat (SDL_PixelFormat *format)
   1.310 +static DFBSurfacePixelFormat
   1.311 +SDLToDFBPixelFormat(SDL_PixelFormat * format)
   1.312  {
   1.313 -  if (format->Rmask && format->Gmask && format->Bmask)
   1.314 -    {
   1.315 -      switch (format->BitsPerPixel)
   1.316 -        {
   1.317 +    if (format->Rmask && format->Gmask && format->Bmask) {
   1.318 +        switch (format->BitsPerPixel) {
   1.319          case 8:
   1.320 -          return DSPF_LUT8;
   1.321 -          
   1.322 +            return DSPF_LUT8;
   1.323 +
   1.324          case 16:
   1.325 -          if (format->Rmask == 0xF800 &&
   1.326 -              format->Gmask == 0x07E0 &&
   1.327 -              format->Bmask == 0x001F)
   1.328 -            return DSPF_RGB16;
   1.329 -          /* fall through */
   1.330 -          
   1.331 +            if (format->Rmask == 0xF800 &&
   1.332 +                format->Gmask == 0x07E0 && format->Bmask == 0x001F)
   1.333 +                return DSPF_RGB16;
   1.334 +            /* fall through */
   1.335 +
   1.336          case 15:
   1.337 -          if (format->Rmask == 0x7C00 &&
   1.338 -              format->Gmask == 0x03E0 &&
   1.339 -              format->Bmask == 0x001F)
   1.340 -            return DSPF_ARGB1555;
   1.341 -          break;
   1.342 -          
   1.343 +            if (format->Rmask == 0x7C00 &&
   1.344 +                format->Gmask == 0x03E0 && format->Bmask == 0x001F)
   1.345 +                return DSPF_ARGB1555;
   1.346 +            break;
   1.347 +
   1.348          case 24:
   1.349 -          if (format->Rmask == 0xFF0000 &&
   1.350 -              format->Gmask == 0x00FF00 &&
   1.351 -              format->Bmask == 0x0000FF)
   1.352 -            return DSPF_RGB24;
   1.353 -          break;
   1.354 +            if (format->Rmask == 0xFF0000 &&
   1.355 +                format->Gmask == 0x00FF00 && format->Bmask == 0x0000FF)
   1.356 +                return DSPF_RGB24;
   1.357 +            break;
   1.358  
   1.359          case 32:
   1.360 -          if (format->Rmask == 0xFF0000 &&
   1.361 -              format->Gmask == 0x00FF00 &&
   1.362 -              format->Bmask == 0x0000FF)
   1.363 -            {
   1.364 -              if (format->Amask == 0xFF000000)
   1.365 -                return DSPF_ARGB;
   1.366 -              else
   1.367 -                return DSPF_RGB32;
   1.368 +            if (format->Rmask == 0xFF0000 &&
   1.369 +                format->Gmask == 0x00FF00 && format->Bmask == 0x0000FF) {
   1.370 +                if (format->Amask == 0xFF000000)
   1.371 +                    return DSPF_ARGB;
   1.372 +                else
   1.373 +                    return DSPF_RGB32;
   1.374              }
   1.375 -          break;
   1.376 +            break;
   1.377 +        }
   1.378 +    } else {
   1.379 +        switch (format->BitsPerPixel) {
   1.380 +        case 8:
   1.381 +            return DSPF_LUT8;
   1.382 +        case 15:
   1.383 +            return DSPF_ARGB1555;
   1.384 +        case 16:
   1.385 +            return DSPF_RGB16;
   1.386 +        case 24:
   1.387 +            return DSPF_RGB24;
   1.388 +        case 32:
   1.389 +            return DSPF_RGB32;
   1.390          }
   1.391      }
   1.392 -  else
   1.393 -    {
   1.394 -      switch (format->BitsPerPixel)
   1.395 -	{
   1.396 -        case 8:
   1.397 -          return DSPF_LUT8;
   1.398 -	case 15:
   1.399 -	  return DSPF_ARGB1555;
   1.400 -	case 16:
   1.401 -	  return DSPF_RGB16;
   1.402 -	case 24:
   1.403 -	  return DSPF_RGB24;
   1.404 -	case 32:
   1.405 -	  return DSPF_RGB32;
   1.406 -	}
   1.407 +
   1.408 +    return DSPF_UNKNOWN;
   1.409 +}
   1.410 +
   1.411 +static SDL_Palette *
   1.412 +AllocatePalette(int size)
   1.413 +{
   1.414 +    SDL_Palette *palette;
   1.415 +    SDL_Color *colors;
   1.416 +
   1.417 +    palette = SDL_calloc(1, sizeof(SDL_Palette));
   1.418 +    if (!palette) {
   1.419 +        SDL_OutOfMemory();
   1.420 +        return NULL;
   1.421      }
   1.422  
   1.423 -  return DSPF_UNKNOWN;
   1.424 -}
   1.425 -
   1.426 -static SDL_Palette *AllocatePalette(int size)
   1.427 -{
   1.428 -  SDL_Palette *palette;
   1.429 -  SDL_Color   *colors;
   1.430 -
   1.431 -  palette = SDL_calloc (1, sizeof(SDL_Palette));
   1.432 -  if (!palette)
   1.433 -    {
   1.434 -      SDL_OutOfMemory();
   1.435 -      return NULL;
   1.436 -    }
   1.437 -
   1.438 -  colors = SDL_calloc (size, sizeof(SDL_Color));
   1.439 -  if (!colors)
   1.440 -    {
   1.441 -      SDL_OutOfMemory();
   1.442 -      return NULL;
   1.443 +    colors = SDL_calloc(size, sizeof(SDL_Color));
   1.444 +    if (!colors) {
   1.445 +        SDL_OutOfMemory();
   1.446 +        return NULL;
   1.447      }
   1.448  
   1.449 -  palette->ncolors = size;
   1.450 -  palette->colors  = colors;
   1.451 +    palette->ncolors = size;
   1.452 +    palette->colors = colors;
   1.453  
   1.454 -  return palette;
   1.455 +    return palette;
   1.456  }
   1.457  
   1.458 -static int DFBToSDLPixelFormat (DFBSurfacePixelFormat pixelformat, SDL_PixelFormat *format)
   1.459 +static int
   1.460 +DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat,
   1.461 +                    SDL_PixelFormat * format)
   1.462  {
   1.463 -  format->Amask = format->Rmask = format->Gmask = format->Bmask = 0;
   1.464 -  format->BitsPerPixel = format->BytesPerPixel = 0;
   1.465 +    format->Amask = format->Rmask = format->Gmask = format->Bmask = 0;
   1.466 +    format->BitsPerPixel = format->BytesPerPixel = 0;
   1.467  
   1.468 -  switch (pixelformat)
   1.469 -    {
   1.470 +    switch (pixelformat) {
   1.471      case DSPF_A8:
   1.472 -      format->Amask = 0x000000FF;
   1.473 -      break;
   1.474 +        format->Amask = 0x000000FF;
   1.475 +        break;
   1.476  
   1.477      case DSPF_ARGB1555:
   1.478 -      format->Rmask = 0x00007C00;
   1.479 -      format->Gmask = 0x000003E0;
   1.480 -      format->Bmask = 0x0000001F;
   1.481 -      break;
   1.482 +        format->Rmask = 0x00007C00;
   1.483 +        format->Gmask = 0x000003E0;
   1.484 +        format->Bmask = 0x0000001F;
   1.485 +        break;
   1.486  
   1.487      case DSPF_RGB16:
   1.488 -      format->Rmask = 0x0000F800;
   1.489 -      format->Gmask = 0x000007E0;
   1.490 -      format->Bmask = 0x0000001F;
   1.491 -      break;
   1.492 +        format->Rmask = 0x0000F800;
   1.493 +        format->Gmask = 0x000007E0;
   1.494 +        format->Bmask = 0x0000001F;
   1.495 +        break;
   1.496  
   1.497      case DSPF_ARGB:
   1.498 -      format->Amask = 0; /* apps don't seem to like that:  0xFF000000; */
   1.499 -      /* fall through */
   1.500 +        format->Amask = 0;      /* apps don't seem to like that:  0xFF000000; */
   1.501 +        /* fall through */
   1.502      case DSPF_RGB24:
   1.503      case DSPF_RGB32:
   1.504 -      format->Rmask = 0x00FF0000;
   1.505 -      format->Gmask = 0x0000FF00;
   1.506 -      format->Bmask = 0x000000FF;
   1.507 -      break;
   1.508 +        format->Rmask = 0x00FF0000;
   1.509 +        format->Gmask = 0x0000FF00;
   1.510 +        format->Bmask = 0x000000FF;
   1.511 +        break;
   1.512  
   1.513      case DSPF_LUT8:
   1.514 -      format->Rmask = 0x000000FF;
   1.515 -      format->Gmask = 0x000000FF;
   1.516 -      format->Bmask = 0x000000FF;
   1.517 +        format->Rmask = 0x000000FF;
   1.518 +        format->Gmask = 0x000000FF;
   1.519 +        format->Bmask = 0x000000FF;
   1.520  
   1.521 -      if (!format->palette)
   1.522 -        format->palette = AllocatePalette(256);
   1.523 -      break;
   1.524 +        if (!format->palette)
   1.525 +            format->palette = AllocatePalette(256);
   1.526 +        break;
   1.527  
   1.528      default:
   1.529 -      fprintf (stderr, "SDL_DirectFB: Unsupported pixelformat (0x%08x)!\n", pixelformat);
   1.530 -      return -1;
   1.531 +        fprintf(stderr,
   1.532 +                "SDL_DirectFB: Unsupported pixelformat (0x%08x)!\n",
   1.533 +                pixelformat);
   1.534 +        return -1;
   1.535      }
   1.536  
   1.537 -  format->BitsPerPixel  = DFB_BYTES_PER_PIXEL(pixelformat) * 8;
   1.538 -  format->BytesPerPixel = DFB_BYTES_PER_PIXEL(pixelformat);
   1.539 +    format->BitsPerPixel = DFB_BYTES_PER_PIXEL(pixelformat) * 8;
   1.540 +    format->BytesPerPixel = DFB_BYTES_PER_PIXEL(pixelformat);
   1.541  
   1.542 -  return 0;
   1.543 +    return 0;
   1.544  }
   1.545  
   1.546  
   1.547 -int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat)
   1.548 +int
   1.549 +DirectFB_VideoInit(_THIS, SDL_PixelFormat * vformat)
   1.550  {
   1.551 -  int                      i;
   1.552 -  DFBResult                ret;
   1.553 +    int i;
   1.554 +    DFBResult ret;
   1.555  #if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
   1.556 -  DFBCardCapabilities      caps;
   1.557 +    DFBCardCapabilities caps;
   1.558  #else
   1.559 -  DFBGraphicsDeviceDescription caps;
   1.560 +    DFBGraphicsDeviceDescription caps;
   1.561  #endif
   1.562 -  DFBDisplayLayerConfig    dlc;
   1.563 -  struct DirectFBEnumRect *rect;
   1.564 -  IDirectFB               *dfb    = NULL;
   1.565 -  IDirectFBDisplayLayer   *layer  = NULL;
   1.566 -  IDirectFBEventBuffer    *events = NULL;
   1.567 +    DFBDisplayLayerConfig dlc;
   1.568 +    struct DirectFBEnumRect *rect;
   1.569 +    IDirectFB *dfb = NULL;
   1.570 +    IDirectFBDisplayLayer *layer = NULL;
   1.571 +    IDirectFBEventBuffer *events = NULL;
   1.572  
   1.573 -  HIDDEN->c2layer = NULL, HIDDEN->c2frame = NULL;
   1.574 -  HIDDEN->enable_mga_crtc2 = 0;
   1.575 -  HIDDEN->mga_crtc2_stretch_overscan = 1;
   1.576 +    HIDDEN->c2layer = NULL, HIDDEN->c2frame = NULL;
   1.577 +    HIDDEN->enable_mga_crtc2 = 0;
   1.578 +    HIDDEN->mga_crtc2_stretch_overscan = 1;
   1.579  
   1.580 -  ret = DirectFBInit (NULL, NULL);
   1.581 -  if (ret)
   1.582 -    {
   1.583 -      SetDirectFBerror ("DirectFBInit", ret);
   1.584 -      goto error;
   1.585 +    ret = DirectFBInit(NULL, NULL);
   1.586 +    if (ret) {
   1.587 +        SetDirectFBerror("DirectFBInit", ret);
   1.588 +        goto error;
   1.589      }
   1.590  
   1.591 -  ret = DirectFBCreate (&dfb);
   1.592 -  if (ret)
   1.593 -    {
   1.594 -      SetDirectFBerror ("DirectFBCreate", ret);
   1.595 -      goto error;
   1.596 +    ret = DirectFBCreate(&dfb);
   1.597 +    if (ret) {
   1.598 +        SetDirectFBerror("DirectFBCreate", ret);
   1.599 +        goto error;
   1.600 +    }
   1.601 +
   1.602 +    ret = dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer);
   1.603 +    if (ret) {
   1.604 +        SetDirectFBerror("dfb->GetDisplayLayer", ret);
   1.605 +        goto error;
   1.606      }
   1.607  
   1.608 -  ret = dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer);
   1.609 -  if (ret)
   1.610 -    {
   1.611 -      SetDirectFBerror ("dfb->GetDisplayLayer", ret);
   1.612 -      goto error;
   1.613 +    ret = dfb->CreateInputEventBuffer(dfb, DICAPS_ALL, DFB_FALSE, &events);
   1.614 +    if (ret) {
   1.615 +        SetDirectFBerror("dfb->CreateEventBuffer", ret);
   1.616 +        goto error;
   1.617 +    }
   1.618 +
   1.619 +    layer->EnableCursor(layer, 1);
   1.620 +
   1.621 +    /* Query layer configuration to determine the current mode and pixelformat */
   1.622 +    layer->GetConfiguration(layer, &dlc);
   1.623 +
   1.624 +    /* If current format is not supported use LUT8 as the default */
   1.625 +    if (DFBToSDLPixelFormat(dlc.pixelformat, vformat))
   1.626 +        DFBToSDLPixelFormat(DSPF_LUT8, vformat);
   1.627 +
   1.628 +    /* Enumerate the available fullscreen modes */
   1.629 +    ret = dfb->EnumVideoModes(dfb, EnumModesCallback, this);
   1.630 +    if (ret) {
   1.631 +        SetDirectFBerror("dfb->EnumVideoModes", ret);
   1.632 +        goto error;
   1.633      }
   1.634  
   1.635 -  ret = dfb->CreateInputEventBuffer (dfb, DICAPS_ALL, DFB_FALSE, &events);
   1.636 -  if (ret)
   1.637 -    {
   1.638 -      SetDirectFBerror ("dfb->CreateEventBuffer", ret);
   1.639 -      goto error;
   1.640 -    }
   1.641 -  
   1.642 -  layer->EnableCursor (layer, 1);
   1.643 -
   1.644 -  /* Query layer configuration to determine the current mode and pixelformat */
   1.645 -  layer->GetConfiguration (layer, &dlc);
   1.646 -
   1.647 -  /* If current format is not supported use LUT8 as the default */
   1.648 -  if (DFBToSDLPixelFormat (dlc.pixelformat, vformat))
   1.649 -    DFBToSDLPixelFormat (DSPF_LUT8, vformat);
   1.650 -
   1.651 -  /* Enumerate the available fullscreen modes */
   1.652 -  ret = dfb->EnumVideoModes (dfb, EnumModesCallback, this);
   1.653 -  if (ret)
   1.654 -    {
   1.655 -      SetDirectFBerror ("dfb->EnumVideoModes", ret);
   1.656 -      goto error;
   1.657 +    HIDDEN->modelist = SDL_calloc(HIDDEN->nummodes + 1, sizeof(SDL_Rect *));
   1.658 +    if (!HIDDEN->modelist) {
   1.659 +        SDL_OutOfMemory();
   1.660 +        goto error;
   1.661      }
   1.662  
   1.663 -  HIDDEN->modelist = SDL_calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *));
   1.664 -  if (!HIDDEN->modelist)
   1.665 -    {
   1.666 -      SDL_OutOfMemory();
   1.667 -      goto error;
   1.668 +    for (i = 0, rect = enumlist; rect; ++i, rect = rect->next) {
   1.669 +        HIDDEN->modelist[i] = &rect->r;
   1.670      }
   1.671  
   1.672 -  for (i = 0, rect = enumlist; rect; ++i, rect = rect->next )
   1.673 -    {
   1.674 -      HIDDEN->modelist[i] = &rect->r;
   1.675 -    }
   1.676 -
   1.677 -  HIDDEN->modelist[i] = NULL;
   1.678 +    HIDDEN->modelist[i] = NULL;
   1.679  
   1.680  
   1.681 -  /* Query card capabilities to get the video memory size */
   1.682 +    /* Query card capabilities to get the video memory size */
   1.683  #if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
   1.684 -  dfb->GetCardCapabilities (dfb, &caps);
   1.685 +    dfb->GetCardCapabilities(dfb, &caps);
   1.686  #else
   1.687 -  dfb->GetDeviceDescription (dfb, &caps);
   1.688 +    dfb->GetDeviceDescription(dfb, &caps);
   1.689  #endif
   1.690  
   1.691 -  this->info.wm_available = 1;
   1.692 -  this->info.hw_available = 1;
   1.693 -  this->info.blit_hw      = 1;
   1.694 -  this->info.blit_hw_CC   = 1;
   1.695 -  this->info.blit_hw_A    = 1;
   1.696 -  this->info.blit_fill    = 1;
   1.697 -  this->info.video_mem    = caps.video_memory / 1024;
   1.698 -
   1.699 -  HIDDEN->initialized = 1;
   1.700 -  HIDDEN->dfb         = dfb;
   1.701 -  HIDDEN->layer       = layer;
   1.702 -  HIDDEN->eventbuffer = events;
   1.703 +    this->info.wm_available = 1;
   1.704 +    this->info.hw_available = 1;
   1.705 +    this->info.blit_hw = 1;
   1.706 +    this->info.blit_hw_CC = 1;
   1.707 +    this->info.blit_hw_A = 1;
   1.708 +    this->info.blit_fill = 1;
   1.709 +    this->info.video_mem = caps.video_memory / 1024;
   1.710  
   1.711 -  if (SDL_getenv("SDL_DIRECTFB_MGA_CRTC2") != NULL)
   1.712 -    HIDDEN->enable_mga_crtc2 = 1;
   1.713 -  
   1.714 -  if (HIDDEN->enable_mga_crtc2)
   1.715 -    {
   1.716 -      DFBDisplayLayerConfig      dlc;
   1.717 -      DFBDisplayLayerConfigFlags failed;
   1.718 +    HIDDEN->initialized = 1;
   1.719 +    HIDDEN->dfb = dfb;
   1.720 +    HIDDEN->layer = layer;
   1.721 +    HIDDEN->eventbuffer = events;
   1.722 +
   1.723 +    if (SDL_getenv("SDL_DIRECTFB_MGA_CRTC2") != NULL)
   1.724 +        HIDDEN->enable_mga_crtc2 = 1;
   1.725  
   1.726 -      ret = dfb->GetDisplayLayer (dfb, 2, &HIDDEN->c2layer);
   1.727 -      if (ret)
   1.728 -        {
   1.729 -          SetDirectFBerror ("dfb->GetDisplayLayer(CRTC2)", ret);
   1.730 -          goto error;
   1.731 +    if (HIDDEN->enable_mga_crtc2) {
   1.732 +        DFBDisplayLayerConfig dlc;
   1.733 +        DFBDisplayLayerConfigFlags failed;
   1.734 +
   1.735 +        ret = dfb->GetDisplayLayer(dfb, 2, &HIDDEN->c2layer);
   1.736 +        if (ret) {
   1.737 +            SetDirectFBerror("dfb->GetDisplayLayer(CRTC2)", ret);
   1.738 +            goto error;
   1.739          }
   1.740  
   1.741 -      ret = HIDDEN->layer->SetCooperativeLevel(HIDDEN->layer, DLSCL_EXCLUSIVE);
   1.742 -      if (ret)
   1.743 -        {
   1.744 -          SetDirectFBerror ("layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
   1.745 -          goto error;
   1.746 +        ret =
   1.747 +            HIDDEN->layer->SetCooperativeLevel(HIDDEN->layer,
   1.748 +                                               DLSCL_EXCLUSIVE);
   1.749 +        if (ret) {
   1.750 +            SetDirectFBerror
   1.751 +                ("layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
   1.752 +            goto error;
   1.753          }
   1.754 - 
   1.755 -      ret = HIDDEN->c2layer->SetCooperativeLevel(HIDDEN->c2layer, DLSCL_EXCLUSIVE);
   1.756 -      if (ret)
   1.757 -        {
   1.758 -          SetDirectFBerror ("c2layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
   1.759 -          goto error;
   1.760 +
   1.761 +        ret =
   1.762 +            HIDDEN->c2layer->SetCooperativeLevel(HIDDEN->c2layer,
   1.763 +                                                 DLSCL_EXCLUSIVE);
   1.764 +        if (ret) {
   1.765 +            SetDirectFBerror
   1.766 +                ("c2layer->SetCooperativeLevel(CRTC2, EXCLUSIVE)", ret);
   1.767 +            goto error;
   1.768          }
   1.769  
   1.770 -      HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0x0);
   1.771 +        HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0x0);
   1.772 +
   1.773 +        /* Init the surface here as it got a fixed size */
   1.774 +        dlc.flags = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
   1.775 +        dlc.buffermode = DLBM_BACKVIDEO;
   1.776 +        dlc.pixelformat = DSPF_RGB32;
   1.777  
   1.778 -      /* Init the surface here as it got a fixed size */
   1.779 -      dlc.flags      = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
   1.780 -      dlc.buffermode = DLBM_BACKVIDEO;
   1.781 -      dlc.pixelformat = DSPF_RGB32;
   1.782 -      
   1.783 -      ret = HIDDEN->c2layer->TestConfiguration( HIDDEN->c2layer, &dlc, &failed );
   1.784 -      if (ret)
   1.785 -        {
   1.786 -          SetDirectFBerror ("c2layer->TestConfiguration", ret);
   1.787 -          goto error;
   1.788 +        ret =
   1.789 +            HIDDEN->c2layer->TestConfiguration(HIDDEN->c2layer, &dlc,
   1.790 +                                               &failed);
   1.791 +        if (ret) {
   1.792 +            SetDirectFBerror("c2layer->TestConfiguration", ret);
   1.793 +            goto error;
   1.794          }
   1.795 -    
   1.796 -      ret = HIDDEN->c2layer->SetConfiguration( HIDDEN->c2layer, &dlc );
   1.797 -      if (ret)
   1.798 -        {
   1.799 -          SetDirectFBerror ("c2layer->SetConfiguration", ret);
   1.800 -          goto error;
   1.801 +
   1.802 +        ret = HIDDEN->c2layer->SetConfiguration(HIDDEN->c2layer, &dlc);
   1.803 +        if (ret) {
   1.804 +            SetDirectFBerror("c2layer->SetConfiguration", ret);
   1.805 +            goto error;
   1.806          }
   1.807 -    
   1.808 -      ret = HIDDEN->c2layer->GetSurface( HIDDEN->c2layer, &HIDDEN->c2frame );
   1.809 -      if (ret)
   1.810 -        {
   1.811 -          SetDirectFBerror ("c2layer->GetSurface", ret);
   1.812 -          goto error;
   1.813 +
   1.814 +        ret = HIDDEN->c2layer->GetSurface(HIDDEN->c2layer, &HIDDEN->c2frame);
   1.815 +        if (ret) {
   1.816 +            SetDirectFBerror("c2layer->GetSurface", ret);
   1.817 +            goto error;
   1.818          }
   1.819  
   1.820 -      HIDDEN->c2framesize.x = 0;
   1.821 -      HIDDEN->c2framesize.y = 0;
   1.822 -      HIDDEN->c2frame->GetSize( HIDDEN->c2frame, &HIDDEN->c2framesize.w, &HIDDEN->c2framesize.h);
   1.823 +        HIDDEN->c2framesize.x = 0;
   1.824 +        HIDDEN->c2framesize.y = 0;
   1.825 +        HIDDEN->c2frame->GetSize(HIDDEN->c2frame, &HIDDEN->c2framesize.w,
   1.826 +                                 &HIDDEN->c2framesize.h);
   1.827  
   1.828 -      HIDDEN->c2frame->SetBlittingFlags( HIDDEN->c2frame, DSBLIT_NOFX );
   1.829 -      HIDDEN->c2frame->SetColor( HIDDEN->c2frame, 0, 0, 0, 0xff );
   1.830 -    
   1.831 -      /* Clear CRTC2 */
   1.832 -      HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff );
   1.833 -      HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0 );
   1.834 -      HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff );
   1.835 -      HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0 );
   1.836 -      HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff );
   1.837 +        HIDDEN->c2frame->SetBlittingFlags(HIDDEN->c2frame, DSBLIT_NOFX);
   1.838 +        HIDDEN->c2frame->SetColor(HIDDEN->c2frame, 0, 0, 0, 0xff);
   1.839 +
   1.840 +        /* Clear CRTC2 */
   1.841 +        HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff);
   1.842 +        HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0);
   1.843 +        HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff);
   1.844 +        HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, 0);
   1.845 +        HIDDEN->c2frame->Clear(HIDDEN->c2frame, 0, 0, 0, 0xff);
   1.846  
   1.847 -      HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0xFF );
   1.848 -    
   1.849 -      /* Check if overscan is possibly set */
   1.850 -      if (SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN") != NULL)
   1.851 -        {
   1.852 -	    float overscan = 0;
   1.853 -	    if (SDL_sscanf(SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN"), "%f", &overscan) == 1)
   1.854 -               if (overscan > 0 && overscan < 2)
   1.855 -		  HIDDEN->mga_crtc2_stretch_overscan = overscan;
   1.856 -	}
   1.857 +        HIDDEN->c2layer->SetOpacity(HIDDEN->c2layer, 0xFF);
   1.858  
   1.859 -      #ifdef DIRECTFB_CRTC2_DEBUG
   1.860 -      printf("CRTC2 overscan: %f\n", HIDDEN->mga_crtc2_stretch_overscan);
   1.861 -      #endif
   1.862 +        /* Check if overscan is possibly set */
   1.863 +        if (SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN") != NULL) {
   1.864 +            float overscan = 0;
   1.865 +            if (SDL_sscanf
   1.866 +                (SDL_getenv("SDL_DIRECTFB_MGA_OVERSCAN"), "%f",
   1.867 +                 &overscan) == 1)
   1.868 +                if (overscan > 0 && overscan < 2)
   1.869 +                    HIDDEN->mga_crtc2_stretch_overscan = overscan;
   1.870 +        }
   1.871 +#ifdef DIRECTFB_CRTC2_DEBUG
   1.872 +        printf("CRTC2 overscan: %f\n", HIDDEN->mga_crtc2_stretch_overscan);
   1.873 +#endif
   1.874      }
   1.875  
   1.876 -  return 0;
   1.877 +    return 0;
   1.878  
   1.879 - error:
   1.880 -  if (events)
   1.881 -    events->Release (events);
   1.882 -  
   1.883 -  if (HIDDEN->c2frame)
   1.884 -    HIDDEN->c2frame->Release (HIDDEN->c2frame);
   1.885 +  error:
   1.886 +    if (events)
   1.887 +        events->Release(events);
   1.888 +
   1.889 +    if (HIDDEN->c2frame)
   1.890 +        HIDDEN->c2frame->Release(HIDDEN->c2frame);
   1.891  
   1.892 -  if (HIDDEN->c2layer)
   1.893 -    HIDDEN->c2layer->Release (HIDDEN->c2layer);
   1.894 +    if (HIDDEN->c2layer)
   1.895 +        HIDDEN->c2layer->Release(HIDDEN->c2layer);
   1.896  
   1.897 -  if (layer)
   1.898 -    layer->Release (layer);
   1.899 +    if (layer)
   1.900 +        layer->Release(layer);
   1.901  
   1.902 -  if (dfb)
   1.903 -    dfb->Release (dfb);
   1.904 +    if (dfb)
   1.905 +        dfb->Release(dfb);
   1.906  
   1.907 -  return -1;
   1.908 +    return -1;
   1.909  }
   1.910  
   1.911 -static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
   1.912 +static SDL_Rect **
   1.913 +DirectFB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
   1.914  {
   1.915 -  if (flags & SDL_FULLSCREEN)
   1.916 -    return HIDDEN->modelist;
   1.917 -  else
   1.918 -    if (SDLToDFBPixelFormat (format) != DSPF_UNKNOWN)
   1.919 -      return (SDL_Rect**) -1;
   1.920 +    if (flags & SDL_FULLSCREEN)
   1.921 +        return HIDDEN->modelist;
   1.922 +    else if (SDLToDFBPixelFormat(format) != DSPF_UNKNOWN)
   1.923 +        return (SDL_Rect **) - 1;
   1.924  
   1.925 -  return NULL;
   1.926 +    return NULL;
   1.927  }
   1.928  
   1.929 -static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
   1.930 +static SDL_Surface *
   1.931 +DirectFB_SetVideoMode(_THIS, SDL_Surface * current, int width, int height,
   1.932 +                      int bpp, Uint32 flags)
   1.933  {
   1.934 -  DFBResult              ret;
   1.935 -  DFBSurfaceDescription  dsc;
   1.936 -  DFBSurfacePixelFormat  pixelformat;
   1.937 -  IDirectFBSurface      *surface;
   1.938 +    DFBResult ret;
   1.939 +    DFBSurfaceDescription dsc;
   1.940 +    DFBSurfacePixelFormat pixelformat;
   1.941 +    IDirectFBSurface *surface;
   1.942  
   1.943 -  fprintf (stderr, "SDL DirectFB_SetVideoMode: %dx%d@%d, flags: 0x%08x\n",
   1.944 -           width, height, bpp, flags);
   1.945 +    fprintf(stderr, "SDL DirectFB_SetVideoMode: %dx%d@%d, flags: 0x%08x\n",
   1.946 +            width, height, bpp, flags);
   1.947  
   1.948 -  flags |= SDL_FULLSCREEN;
   1.949 +    flags |= SDL_FULLSCREEN;
   1.950  
   1.951 -  /* Release previous primary surface */
   1.952 -  if (current->hwdata && current->hwdata->surface)
   1.953 -    {
   1.954 -      current->hwdata->surface->Release (current->hwdata->surface);
   1.955 -      current->hwdata->surface = NULL;
   1.956 +    /* Release previous primary surface */
   1.957 +    if (current->hwdata && current->hwdata->surface) {
   1.958 +        current->hwdata->surface->Release(current->hwdata->surface);
   1.959 +        current->hwdata->surface = NULL;
   1.960  
   1.961 -      /* And its palette if present */
   1.962 -      if (current->hwdata->palette)
   1.963 -        {
   1.964 -          current->hwdata->palette->Release (current->hwdata->palette);
   1.965 -          current->hwdata->palette = NULL;
   1.966 +        /* And its palette if present */
   1.967 +        if (current->hwdata->palette) {
   1.968 +            current->hwdata->palette->Release(current->hwdata->palette);
   1.969 +            current->hwdata->palette = NULL;
   1.970 +        }
   1.971 +    } else if (!current->hwdata) {
   1.972 +        /* Allocate the hardware acceleration data */
   1.973 +        current->hwdata =
   1.974 +            (struct private_hwdata *) SDL_calloc(1, sizeof(*current->hwdata));
   1.975 +        if (!current->hwdata) {
   1.976 +            SDL_OutOfMemory();
   1.977 +            return NULL;
   1.978          }
   1.979      }
   1.980 -  else if (!current->hwdata)
   1.981 -    {
   1.982 -      /* Allocate the hardware acceleration data */
   1.983 -      current->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*current->hwdata));
   1.984 -      if (!current->hwdata)
   1.985 -        {
   1.986 -          SDL_OutOfMemory();
   1.987 -          return NULL;
   1.988 -	}
   1.989 -    }
   1.990  
   1.991 -  /* Set cooperative level depending on flag SDL_FULLSCREEN */
   1.992 -  if (flags & SDL_FULLSCREEN)
   1.993 -    {
   1.994 -      ret = HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_FULLSCREEN);
   1.995 -      if (ret && !HIDDEN->enable_mga_crtc2)
   1.996 -        {
   1.997 -          DirectFBError ("dfb->SetCooperativeLevel", ret);
   1.998 -          flags &= ~SDL_FULLSCREEN;
   1.999 +    /* Set cooperative level depending on flag SDL_FULLSCREEN */
  1.1000 +    if (flags & SDL_FULLSCREEN) {
  1.1001 +        ret = HIDDEN->dfb->SetCooperativeLevel(HIDDEN->dfb, DFSCL_FULLSCREEN);
  1.1002 +        if (ret && !HIDDEN->enable_mga_crtc2) {
  1.1003 +            DirectFBError("dfb->SetCooperativeLevel", ret);
  1.1004 +            flags &= ~SDL_FULLSCREEN;
  1.1005          }
  1.1006 -    }
  1.1007 -  else
  1.1008 -    HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
  1.1009 +    } else
  1.1010 +        HIDDEN->dfb->SetCooperativeLevel(HIDDEN->dfb, DFSCL_NORMAL);
  1.1011  
  1.1012 -  /* Set video mode */
  1.1013 -  ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
  1.1014 -  if (ret)
  1.1015 -    {
  1.1016 -      if (flags & SDL_FULLSCREEN)
  1.1017 -        {
  1.1018 -          flags &= ~SDL_FULLSCREEN;
  1.1019 -          HIDDEN->dfb->SetCooperativeLevel (HIDDEN->dfb, DFSCL_NORMAL);
  1.1020 -          ret = HIDDEN->dfb->SetVideoMode (HIDDEN->dfb, width, height, bpp);
  1.1021 +    /* Set video mode */
  1.1022 +    ret = HIDDEN->dfb->SetVideoMode(HIDDEN->dfb, width, height, bpp);
  1.1023 +    if (ret) {
  1.1024 +        if (flags & SDL_FULLSCREEN) {
  1.1025 +            flags &= ~SDL_FULLSCREEN;
  1.1026 +            HIDDEN->dfb->SetCooperativeLevel(HIDDEN->dfb, DFSCL_NORMAL);
  1.1027 +            ret = HIDDEN->dfb->SetVideoMode(HIDDEN->dfb, width, height, bpp);
  1.1028          }
  1.1029  
  1.1030 -      if (ret)
  1.1031 -        {
  1.1032 -          SetDirectFBerror ("dfb->SetVideoMode", ret);
  1.1033 -          return NULL;
  1.1034 +        if (ret) {
  1.1035 +            SetDirectFBerror("dfb->SetVideoMode", ret);
  1.1036 +            return NULL;
  1.1037          }
  1.1038      }
  1.1039  
  1.1040 -  /* Create primary surface */
  1.1041 -  dsc.flags       = DSDESC_CAPS | DSDESC_PIXELFORMAT;
  1.1042 -  dsc.caps        = DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0);
  1.1043 -  dsc.pixelformat = GetFormatForBpp (bpp, HIDDEN->layer);
  1.1044 +    /* Create primary surface */
  1.1045 +    dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT;
  1.1046 +    dsc.caps =
  1.1047 +        DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0);
  1.1048 +    dsc.pixelformat = GetFormatForBpp(bpp, HIDDEN->layer);
  1.1049  
  1.1050 -  ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
  1.1051 -  if (ret && (flags & SDL_DOUBLEBUF))
  1.1052 -    {
  1.1053 -      /* Try without double buffering */
  1.1054 -      dsc.caps &= ~DSCAPS_FLIPPING;
  1.1055 -      ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface);
  1.1056 +    ret = HIDDEN->dfb->CreateSurface(HIDDEN->dfb, &dsc, &surface);
  1.1057 +    if (ret && (flags & SDL_DOUBLEBUF)) {
  1.1058 +        /* Try without double buffering */
  1.1059 +        dsc.caps &= ~DSCAPS_FLIPPING;
  1.1060 +        ret = HIDDEN->dfb->CreateSurface(HIDDEN->dfb, &dsc, &surface);
  1.1061      }
  1.1062 -  if (ret)
  1.1063 -    {
  1.1064 -      SetDirectFBerror ("dfb->CreateSurface", ret);
  1.1065 -      return NULL;
  1.1066 +    if (ret) {
  1.1067 +        SetDirectFBerror("dfb->CreateSurface", ret);
  1.1068 +        return NULL;
  1.1069      }
  1.1070  
  1.1071 -  current->w     = width;
  1.1072 -  current->h     = height;
  1.1073 -  current->flags = SDL_HWSURFACE | SDL_PREALLOC;
  1.1074 +    current->w = width;
  1.1075 +    current->h = height;
  1.1076 +    current->flags = SDL_HWSURFACE | SDL_PREALLOC;
  1.1077  
  1.1078 -  if (flags & SDL_FULLSCREEN)
  1.1079 -    {
  1.1080 -      current->flags |= SDL_FULLSCREEN;
  1.1081 -      this->UpdateRects = DirectFB_DirectUpdate;
  1.1082 -    }
  1.1083 -  else
  1.1084 -    this->UpdateRects = DirectFB_WindowedUpdate;
  1.1085 +    if (flags & SDL_FULLSCREEN) {
  1.1086 +        current->flags |= SDL_FULLSCREEN;
  1.1087 +        this->UpdateRects = DirectFB_DirectUpdate;
  1.1088 +    } else
  1.1089 +        this->UpdateRects = DirectFB_WindowedUpdate;
  1.1090  
  1.1091 -  if (dsc.caps & DSCAPS_FLIPPING)
  1.1092 -    current->flags |= SDL_DOUBLEBUF;
  1.1093 +    if (dsc.caps & DSCAPS_FLIPPING)
  1.1094 +        current->flags |= SDL_DOUBLEBUF;
  1.1095  
  1.1096 -  surface->GetPixelFormat (surface, &pixelformat);
  1.1097 -
  1.1098 -  DFBToSDLPixelFormat (pixelformat, current->format);
  1.1099 +    surface->GetPixelFormat(surface, &pixelformat);
  1.1100  
  1.1101 -  /* Get the surface palette (if supported) */
  1.1102 -  if (DFB_PIXELFORMAT_IS_INDEXED( pixelformat ))
  1.1103 -    {
  1.1104 -      surface->GetPalette (surface, &current->hwdata->palette);
  1.1105 +    DFBToSDLPixelFormat(pixelformat, current->format);
  1.1106  
  1.1107 -      current->flags |= SDL_HWPALETTE;
  1.1108 +    /* Get the surface palette (if supported) */
  1.1109 +    if (DFB_PIXELFORMAT_IS_INDEXED(pixelformat)) {
  1.1110 +        surface->GetPalette(surface, &current->hwdata->palette);
  1.1111 +
  1.1112 +        current->flags |= SDL_HWPALETTE;
  1.1113      }
  1.1114  
  1.1115 -  current->hwdata->surface = surface;
  1.1116 +    current->hwdata->surface = surface;
  1.1117  
  1.1118 -  /* MGA CRTC2 stuff */
  1.1119 -  if (HIDDEN->enable_mga_crtc2)
  1.1120 -    {
  1.1121 -      /* no stretching if c2ssize == c2framesize */
  1.1122 -      HIDDEN->c2ssize.x = 0, HIDDEN->c2ssize.y = 0;
  1.1123 -      HIDDEN->c2ssize.w = width;
  1.1124 -      HIDDEN->c2ssize.h = height;
  1.1125 +    /* MGA CRTC2 stuff */
  1.1126 +    if (HIDDEN->enable_mga_crtc2) {
  1.1127 +        /* no stretching if c2ssize == c2framesize */
  1.1128 +        HIDDEN->c2ssize.x = 0, HIDDEN->c2ssize.y = 0;
  1.1129 +        HIDDEN->c2ssize.w = width;
  1.1130 +        HIDDEN->c2ssize.h = height;
  1.1131  
  1.1132 -      HIDDEN->c2dsize.x = 0, HIDDEN->c2dsize.y = 0;
  1.1133 -      HIDDEN->c2dsize.w = width;
  1.1134 -      HIDDEN->c2dsize.h = height;
  1.1135 +        HIDDEN->c2dsize.x = 0, HIDDEN->c2dsize.y = 0;
  1.1136 +        HIDDEN->c2dsize.w = width;
  1.1137 +        HIDDEN->c2dsize.h = height;
  1.1138 +
  1.1139 +        HIDDEN->mga_crtc2_stretch = 0;
  1.1140  
  1.1141 -      HIDDEN->mga_crtc2_stretch = 0;
  1.1142 +        if (SDL_getenv("SDL_DIRECTFB_MGA_STRETCH") != NULL) {
  1.1143 +            /* Normally assume a picture aspect ratio of 4:3 */
  1.1144 +            int zoom_aspect_x = 4, zoom_aspect_y = 3, i, j;
  1.1145  
  1.1146 -      if (SDL_getenv("SDL_DIRECTFB_MGA_STRETCH") != NULL)
  1.1147 -        {
  1.1148 -	    /* Normally assume a picture aspect ratio of 4:3 */
  1.1149 -	    int zoom_aspect_x = 4, zoom_aspect_y = 3, i, j;
  1.1150 +            for (i = 1; i < 20; i++) {
  1.1151 +                for (j = 1; j < 10; j++) {
  1.1152 +                    if ((float) width / (float) i * (float) j == height) {
  1.1153 +                        zoom_aspect_x = i;
  1.1154 +                        zoom_aspect_y = j;
  1.1155  
  1.1156 -	    for (i = 1; i < 20; i++)
  1.1157 -	      {
  1.1158 -		for (j = 1; j < 10; j++)
  1.1159 -		  {
  1.1160 -		    if ((float)width/(float)i*(float)j == height) 
  1.1161 -		      {
  1.1162 -			zoom_aspect_x = i;
  1.1163 -			zoom_aspect_y = j;
  1.1164 -			
  1.1165 -			/* break the loop */
  1.1166 -			i = 21;
  1.1167 -			break;
  1.1168 -		      }
  1.1169 -		  }
  1.1170 -	      }
  1.1171 -	
  1.1172 -            #ifdef DIRECTFB_CRTC2_DEBUG
  1.1173 -            printf("Source resolution: X: %d, Y: %d, Aspect ratio: %d:%d\n", width, height, zoom_aspect_x, zoom_aspect_y);
  1.1174 -            printf("CRTC2 resolution: X: %d, Y: %d\n", HIDDEN->c2framesize.w, HIDDEN->c2framesize.h);
  1.1175 -            #endif
  1.1176 -	
  1.1177 -          /* don't stretch only slightly smaller/larger images */
  1.1178 -          if ((float)width < (float)HIDDEN->c2framesize.w*0.95 || (float)height < (float)HIDDEN->c2framesize.h*0.95)
  1.1179 -            {
  1.1180 -              while ((float)HIDDEN->c2dsize.w < (float)HIDDEN->c2framesize.w*HIDDEN->mga_crtc2_stretch_overscan && (float)HIDDEN->c2dsize.h < (float)HIDDEN->c2framesize.h*HIDDEN->mga_crtc2_stretch_overscan)
  1.1181 -                {
  1.1182 -                   HIDDEN->c2dsize.w+=zoom_aspect_x;
  1.1183 -                   HIDDEN->c2dsize.h+=zoom_aspect_y;
  1.1184 +                        /* break the loop */
  1.1185 +                        i = 21;
  1.1186 +                        break;
  1.1187 +                    }
  1.1188 +                }
  1.1189 +            }
  1.1190 +
  1.1191 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1192 +            printf
  1.1193 +                ("Source resolution: X: %d, Y: %d, Aspect ratio: %d:%d\n",
  1.1194 +                 width, height, zoom_aspect_x, zoom_aspect_y);
  1.1195 +            printf("CRTC2 resolution: X: %d, Y: %d\n",
  1.1196 +                   HIDDEN->c2framesize.w, HIDDEN->c2framesize.h);
  1.1197 +#endif
  1.1198 +
  1.1199 +            /* don't stretch only slightly smaller/larger images */
  1.1200 +            if ((float) width < (float) HIDDEN->c2framesize.w * 0.95
  1.1201 +                || (float) height < (float) HIDDEN->c2framesize.h * 0.95) {
  1.1202 +                while ((float) HIDDEN->c2dsize.w <
  1.1203 +                       (float) HIDDEN->c2framesize.w *
  1.1204 +                       HIDDEN->mga_crtc2_stretch_overscan
  1.1205 +                       && (float) HIDDEN->c2dsize.h <
  1.1206 +                       (float) HIDDEN->c2framesize.h *
  1.1207 +                       HIDDEN->mga_crtc2_stretch_overscan) {
  1.1208 +                    HIDDEN->c2dsize.w += zoom_aspect_x;
  1.1209 +                    HIDDEN->c2dsize.h += zoom_aspect_y;
  1.1210                  }
  1.1211  
  1.1212 -              /* one step down */
  1.1213 -                HIDDEN->c2dsize.w-=zoom_aspect_x;
  1.1214 -                HIDDEN->c2dsize.h-=zoom_aspect_y;
  1.1215 +                /* one step down */
  1.1216 +                HIDDEN->c2dsize.w -= zoom_aspect_x;
  1.1217 +                HIDDEN->c2dsize.h -= zoom_aspect_y;
  1.1218  
  1.1219 -              #ifdef DIRECTFB_CRTC2_DEBUG
  1.1220 -              printf("Stretched resolution: X: %d, Y: %d\n", HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
  1.1221 -              #endif
  1.1222 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1223 +                printf("Stretched resolution: X: %d, Y: %d\n",
  1.1224 +                       HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
  1.1225 +#endif
  1.1226  
  1.1227 -              HIDDEN->mga_crtc2_stretch = 1;
  1.1228 -            } 
  1.1229 -          else if ((float)width > (float)HIDDEN->c2framesize.w*0.95 || (float)height > (float)HIDDEN->c2framesize.h*0.95)
  1.1230 -            {
  1.1231 -               while ((float)HIDDEN->c2dsize.w > (float)HIDDEN->c2framesize.w*HIDDEN->mga_crtc2_stretch_overscan || (float)HIDDEN->c2dsize.h > (float)HIDDEN->c2framesize.h*HIDDEN->mga_crtc2_stretch_overscan)
  1.1232 -                {
  1.1233 -              HIDDEN->c2dsize.w-=zoom_aspect_x;
  1.1234 -              HIDDEN->c2dsize.h-=zoom_aspect_y;
  1.1235 +                HIDDEN->mga_crtc2_stretch = 1;
  1.1236 +            } else if ((float) width > (float) HIDDEN->c2framesize.w * 0.95
  1.1237 +                       || (float) height >
  1.1238 +                       (float) HIDDEN->c2framesize.h * 0.95) {
  1.1239 +                while ((float) HIDDEN->c2dsize.w >
  1.1240 +                       (float) HIDDEN->c2framesize.w *
  1.1241 +                       HIDDEN->mga_crtc2_stretch_overscan
  1.1242 +                       || (float) HIDDEN->c2dsize.h >
  1.1243 +                       (float) HIDDEN->c2framesize.h *
  1.1244 +                       HIDDEN->mga_crtc2_stretch_overscan) {
  1.1245 +                    HIDDEN->c2dsize.w -= zoom_aspect_x;
  1.1246 +                    HIDDEN->c2dsize.h -= zoom_aspect_y;
  1.1247                  }
  1.1248 -              
  1.1249 -              #ifdef DIRECTFB_CRTC2_DEBUG
  1.1250 -              printf("Down-Stretched resolution: X: %d, Y: %d\n", HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
  1.1251 -              #endif
  1.1252 +
  1.1253 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1254 +                printf("Down-Stretched resolution: X: %d, Y: %d\n",
  1.1255 +                       HIDDEN->c2dsize.w, HIDDEN->c2dsize.h);
  1.1256 +#endif
  1.1257  
  1.1258 -              HIDDEN->mga_crtc2_stretch = 1;
  1.1259 -             } else {
  1.1260 -          #ifdef DIRECTFB_CRTC2_DEBUG
  1.1261 -          printf("Not stretching image\n");
  1.1262 -          #endif
  1.1263 -        }
  1.1264 +                HIDDEN->mga_crtc2_stretch = 1;
  1.1265 +            } else {
  1.1266 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1267 +                printf("Not stretching image\n");
  1.1268 +#endif
  1.1269 +            }
  1.1270  
  1.1271 -      /* Panning */
  1.1272 -      if (HIDDEN->c2framesize.w > HIDDEN->c2dsize.w)
  1.1273 -        HIDDEN->c2dsize.x = (HIDDEN->c2framesize.w - HIDDEN->c2dsize.w)  / 2;
  1.1274 -      else
  1.1275 -        HIDDEN->c2dsize.x = (HIDDEN->c2dsize.w - HIDDEN->c2framesize.w)  / 2;
  1.1276 +            /* Panning */
  1.1277 +            if (HIDDEN->c2framesize.w > HIDDEN->c2dsize.w)
  1.1278 +                HIDDEN->c2dsize.x =
  1.1279 +                    (HIDDEN->c2framesize.w - HIDDEN->c2dsize.w) / 2;
  1.1280 +            else
  1.1281 +                HIDDEN->c2dsize.x =
  1.1282 +                    (HIDDEN->c2dsize.w - HIDDEN->c2framesize.w) / 2;
  1.1283  
  1.1284 -      if (HIDDEN->c2framesize.h > HIDDEN->c2dsize.h)
  1.1285 -        HIDDEN->c2dsize.y = (HIDDEN->c2framesize.h - HIDDEN->c2dsize.h)  / 2;
  1.1286 -      else
  1.1287 -        HIDDEN->c2dsize.y = (HIDDEN->c2dsize.h - HIDDEN->c2framesize.h)  / 2;
  1.1288 +            if (HIDDEN->c2framesize.h > HIDDEN->c2dsize.h)
  1.1289 +                HIDDEN->c2dsize.y =
  1.1290 +                    (HIDDEN->c2framesize.h - HIDDEN->c2dsize.h) / 2;
  1.1291 +            else
  1.1292 +                HIDDEN->c2dsize.y =
  1.1293 +                    (HIDDEN->c2dsize.h - HIDDEN->c2framesize.h) / 2;
  1.1294  
  1.1295 -      #ifdef DIRECTFB_CRTC2_DEBUG
  1.1296 -    printf("CRTC2 position X: %d, Y: %d\n", HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1297 -      #endif
  1.1298 -   }
  1.1299 -  }
  1.1300 +#ifdef DIRECTFB_CRTC2_DEBUG
  1.1301 +            printf("CRTC2 position X: %d, Y: %d\n", HIDDEN->c2dsize.x,
  1.1302 +                   HIDDEN->c2dsize.y);
  1.1303 +#endif
  1.1304 +        }
  1.1305 +    }
  1.1306  
  1.1307 -  return current;
  1.1308 +    return current;
  1.1309  }
  1.1310  
  1.1311 -static int DirectFB_AllocHWSurface(_THIS, SDL_Surface *surface)
  1.1312 +static int
  1.1313 +DirectFB_AllocHWSurface(_THIS, SDL_Surface * surface)
  1.1314  {
  1.1315 -  DFBResult             ret;
  1.1316 -  DFBSurfaceDescription dsc;
  1.1317 +    DFBResult ret;
  1.1318 +    DFBSurfaceDescription dsc;
  1.1319  
  1.1320 -  /*  fprintf(stderr, "SDL: DirectFB_AllocHWSurface (%dx%d@%d, flags: 0x%08x)\n",
  1.1321 -      surface->w, surface->h, surface->format->BitsPerPixel, surface->flags);*/
  1.1322 +    /*  fprintf(stderr, "SDL: DirectFB_AllocHWSurface (%dx%d@%d, flags: 0x%08x)\n",
  1.1323 +       surface->w, surface->h, surface->format->BitsPerPixel, surface->flags); */
  1.1324  
  1.1325 -  if (surface->w < 8 || surface->h < 8)
  1.1326 -    return -1;
  1.1327 +    if (surface->w < 8 || surface->h < 8)
  1.1328 +        return -1;
  1.1329  
  1.1330 -  /* fill surface description */
  1.1331 -  dsc.flags  = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
  1.1332 -  dsc.width  = surface->w;
  1.1333 -  dsc.height = surface->h;
  1.1334 -  dsc.caps   = (surface->flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0;
  1.1335 +    /* fill surface description */
  1.1336 +    dsc.flags =
  1.1337 +        DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS;
  1.1338 +    dsc.width = surface->w;
  1.1339 +    dsc.height = surface->h;
  1.1340 +    dsc.caps = (surface->flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0;
  1.1341  
  1.1342 -  /* find the right pixelformat */
  1.1343 -  dsc.pixelformat = SDLToDFBPixelFormat (surface->format);
  1.1344 -  if (dsc.pixelformat == DSPF_UNKNOWN)
  1.1345 -    return -1;
  1.1346 +    /* find the right pixelformat */
  1.1347 +    dsc.pixelformat = SDLToDFBPixelFormat(surface->format);
  1.1348 +    if (dsc.pixelformat == DSPF_UNKNOWN)
  1.1349 +        return -1;
  1.1350  
  1.1351 -  /* Allocate the hardware acceleration data */
  1.1352 -  surface->hwdata = (struct private_hwdata *) SDL_calloc (1, sizeof(*surface->hwdata));
  1.1353 -  if (surface->hwdata == NULL)
  1.1354 -    {
  1.1355 -      SDL_OutOfMemory();
  1.1356 -      return -1;
  1.1357 +    /* Allocate the hardware acceleration data */
  1.1358 +    surface->hwdata =
  1.1359 +        (struct private_hwdata *) SDL_calloc(1, sizeof(*surface->hwdata));
  1.1360 +    if (surface->hwdata == NULL) {
  1.1361 +        SDL_OutOfMemory();
  1.1362 +        return -1;
  1.1363      }
  1.1364  
  1.1365 -  /* Create the surface */
  1.1366 -  ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, &surface->hwdata->surface);
  1.1367 -  if (ret)
  1.1368 -    {
  1.1369 -      SetDirectFBerror ("dfb->CreateSurface", ret);
  1.1370 -      free (surface->hwdata);
  1.1371 -      surface->hwdata = NULL;
  1.1372 -      return -1;
  1.1373 +    /* Create the surface */
  1.1374 +    ret =
  1.1375 +        HIDDEN->dfb->CreateSurface(HIDDEN->dfb, &dsc,
  1.1376 +                                   &surface->hwdata->surface);
  1.1377 +    if (ret) {
  1.1378 +        SetDirectFBerror("dfb->CreateSurface", ret);
  1.1379 +        free(surface->hwdata);
  1.1380 +        surface->hwdata = NULL;
  1.1381 +        return -1;
  1.1382      }
  1.1383  
  1.1384 -  surface->flags |= SDL_HWSURFACE | SDL_PREALLOC;
  1.1385 +    surface->flags |= SDL_HWSURFACE | SDL_PREALLOC;
  1.1386  
  1.1387 -  return 0;
  1.1388 +    return 0;
  1.1389  }
  1.1390  
  1.1391 -static void DirectFB_FreeHWSurface(_THIS, SDL_Surface *surface)
  1.1392 +static void
  1.1393 +DirectFB_FreeHWSurface(_THIS, SDL_Surface * surface)
  1.1394  {
  1.1395 -  if (surface->hwdata && HIDDEN->initialized)
  1.1396 -    {
  1.1397 -      surface->hwdata->surface->Release (surface->hwdata->surface);
  1.1398 -      free (surface->hwdata);
  1.1399 -      surface->hwdata = NULL;
  1.1400 +    if (surface->hwdata && HIDDEN->initialized) {
  1.1401 +        surface->hwdata->surface->Release(surface->hwdata->surface);
  1.1402 +        free(surface->hwdata);
  1.1403 +        surface->hwdata = NULL;
  1.1404      }
  1.1405  }
  1.1406  
  1.1407 -static int DirectFB_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
  1.1408 +static int
  1.1409 +DirectFB_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst)
  1.1410  {
  1.1411 -  /*  fprintf(stderr, "SDL: DirectFB_CheckHWBlit (src->hwdata: %p, dst->hwdata: %p)\n",
  1.1412 -      src->hwdata, dst->hwdata);*/
  1.1413 +    /*  fprintf(stderr, "SDL: DirectFB_CheckHWBlit (src->hwdata: %p, dst->hwdata: %p)\n",
  1.1414 +       src->hwdata, dst->hwdata); */
  1.1415  
  1.1416 -  if (!src->hwdata || !dst->hwdata)
  1.1417 -    return 0;
  1.1418 +    if (!src->hwdata || !dst->hwdata)
  1.1419 +        return 0;
  1.1420  
  1.1421 -  src->flags |= SDL_HWACCEL;
  1.1422 -  src->map->hw_blit = DirectFB_HWAccelBlit;
  1.1423 +    src->flags |= SDL_HWACCEL;
  1.1424 +    src->map->hw_blit = DirectFB_HWAccelBlit;
  1.1425  
  1.1426 -  return 1;
  1.1427 +    return 1;
  1.1428  }
  1.1429  
  1.1430 -static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
  1.1431 -                                SDL_Surface *dst, SDL_Rect *dstrect)
  1.1432 +static int
  1.1433 +DirectFB_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect,
  1.1434 +                     SDL_Surface * dst, SDL_Rect * dstrect)
  1.1435  {
  1.1436 -  DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
  1.1437 +    DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
  1.1438  
  1.1439 -  DFBRectangle sr = { srcrect->x, srcrect->y, srcrect->w, srcrect->h };
  1.1440 -  DFBRectangle dr = { dstrect->x, dstrect->y, dstrect->w, dstrect->h };
  1.1441 -
  1.1442 -  IDirectFBSurface *surface = dst->hwdata->surface;
  1.1443 +    DFBRectangle sr = { srcrect->x, srcrect->y, srcrect->w, srcrect->h };
  1.1444 +    DFBRectangle dr = { dstrect->x, dstrect->y, dstrect->w, dstrect->h };
  1.1445  
  1.1446 -  if (src->flags & SDL_SRCCOLORKEY)
  1.1447 -    {
  1.1448 -      flags |= DSBLIT_SRC_COLORKEY;
  1.1449 -      DirectFB_SetHWColorKey (NULL, src, src->format->colorkey);
  1.1450 +    IDirectFBSurface *surface = dst->hwdata->surface;
  1.1451 +
  1.1452 +    if (src->flags & SDL_SRCCOLORKEY) {
  1.1453 +        flags |= DSBLIT_SRC_COLORKEY;
  1.1454 +        DirectFB_SetHWColorKey(NULL, src, src->format->colorkey);
  1.1455      }
  1.1456  
  1.1457 -  if (src->flags & SDL_SRCALPHA)
  1.1458 -    {
  1.1459 -      flags |= DSBLIT_BLEND_COLORALPHA;
  1.1460 -      surface->SetColor (surface, 0xff, 0xff, 0xff, src->format->alpha);
  1.1461 +    if (src->flags & SDL_SRCALPHA) {
  1.1462 +        flags |= DSBLIT_BLEND_COLORALPHA;
  1.1463 +        surface->SetColor(surface, 0xff, 0xff, 0xff, src->format->alpha);
  1.1464      }
  1.1465  
  1.1466 -  surface->SetBlittingFlags (surface, flags);
  1.1467 +    surface->SetBlittingFlags(surface, flags);
  1.1468  
  1.1469 -  if (sr.w == dr.w && sr.h == dr.h)
  1.1470 -    surface->Blit (surface, src->hwdata->surface, &sr, dr.x, dr.y);
  1.1471 -  else
  1.1472 -    surface->StretchBlit (surface, src->hwdata->surface, &sr, &dr);
  1.1473 +    if (sr.w == dr.w && sr.h == dr.h)
  1.1474 +        surface->Blit(surface, src->hwdata->surface, &sr, dr.x, dr.y);
  1.1475 +    else
  1.1476 +        surface->StretchBlit(surface, src->hwdata->surface, &sr, &dr);
  1.1477  
  1.1478 -  return 0;
  1.1479 +    return 0;
  1.1480  }
  1.1481  
  1.1482 -static int DirectFB_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
  1.1483 +static int
  1.1484 +DirectFB_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect,
  1.1485 +                    Uint32 color)
  1.1486  {
  1.1487 -  SDL_PixelFormat  *fmt     = dst->format;
  1.1488 -  IDirectFBSurface *surface = dst->hwdata->surface;
  1.1489 +    SDL_PixelFormat *fmt = dst->format;
  1.1490 +    IDirectFBSurface *surface = dst->hwdata->surface;
  1.1491  
  1.1492 -  /* ugly */
  1.1493 -  surface->SetColor (surface,
  1.1494 -                     (color & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
  1.1495 -                     (color & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
  1.1496 -                     (color & fmt->Bmask) << (fmt->Bloss - fmt->Bshift), 0xFF);
  1.1497 -  surface->FillRectangle (surface, dstrect->x, dstrect->y, dstrect->w, dstrect->h);
  1.1498 +    /* ugly */
  1.1499 +    surface->SetColor(surface,
  1.1500 +                      (color & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
  1.1501 +                      (color & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
  1.1502 +                      (color & fmt->Bmask) << (fmt->Bloss - fmt->Bshift),
  1.1503 +                      0xFF);
  1.1504 +    surface->FillRectangle(surface, dstrect->x, dstrect->y, dstrect->w,
  1.1505 +                           dstrect->h);
  1.1506  
  1.1507 -  return 0;
  1.1508 +    return 0;
  1.1509  }
  1.1510  
  1.1511 -static int DirectFB_SetHWColorKey(_THIS, SDL_Surface *src, Uint32 key)
  1.1512 +static int
  1.1513 +DirectFB_SetHWColorKey(_THIS, SDL_Surface * src, Uint32 key)
  1.1514  {
  1.1515 -  SDL_PixelFormat  *fmt     = src->format;
  1.1516 -  IDirectFBSurface *surface = src->hwdata->surface;
  1.1517 +    SDL_PixelFormat *fmt = src->format;
  1.1518 +    IDirectFBSurface *surface = src->hwdata->surface;
  1.1519  
  1.1520 -  if (fmt->BitsPerPixel == 8)
  1.1521 -    surface->SetSrcColorKeyIndex (surface, key);
  1.1522 -  else
  1.1523 -    /* ugly */
  1.1524 -    surface->SetSrcColorKey (surface,
  1.1525 -                             (key & fmt->Rmask) >> (fmt->Rshift - fmt->Rloss),
  1.1526 -                             (key & fmt->Gmask) >> (fmt->Gshift - fmt->Gloss),
  1.1527 -                             (key & fmt->Bmask) << (fmt->Bloss - fmt->Bshift));
  1.1528 +    if (fmt->BitsPerPixel == 8)
  1.1529 +        surface->SetSrcColorKeyIndex(surface, key);
  1.1530 +    else
  1.1531 +        /* ugly */
  1.1532 +        surface->SetSrcColorKey(surface,
  1.1533 +                                (key & fmt->Rmask) >> (fmt->Rshift -
  1.1534 +                                                       fmt->Rloss),
  1.1535 +                                (key & fmt->Gmask) >> (fmt->Gshift -
  1.1536 +                                                       fmt->Gloss),
  1.1537 +                                (key & fmt->Bmask) << (fmt->Bloss -
  1.1538 +                                                       fmt->Bshift));
  1.1539  
  1.1540 -  return 0;
  1.1541 +    return 0;
  1.1542  }
  1.1543  
  1.1544 -static int DirectFB_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha)
  1.1545 +static int
  1.1546 +DirectFB_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha)
  1.1547  {
  1.1548 -  return 0;
  1.1549 +    return 0;
  1.1550  }
  1.1551  
  1.1552 -static int DirectFB_FlipHWSurface(_THIS, SDL_Surface *surface)
  1.1553 +static int
  1.1554 +DirectFB_FlipHWSurface(_THIS, SDL_Surface * surface)
  1.1555  {
  1.1556 -  if (HIDDEN->enable_mga_crtc2)
  1.1557 -    {
  1.1558 -       int rtn = surface->hwdata->surface->Flip (surface->hwdata->surface, NULL, 0);
  1.1559 -       if (HIDDEN->mga_crtc2_stretch)
  1.1560 -         HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, surface->hwdata->surface, &HIDDEN->c2ssize, &HIDDEN->c2dsize);
  1.1561 -       else
  1.1562 -         HIDDEN->c2frame->Blit(HIDDEN->c2frame, surface->hwdata->surface, NULL, HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1563 -     
  1.1564 -       HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1565 -       return rtn;
  1.1566 -    } 
  1.1567 -  else 
  1.1568 -     return surface->hwdata->surface->Flip (surface->hwdata->surface, NULL, DSFLIP_WAITFORSYNC);
  1.1569 +    if (HIDDEN->enable_mga_crtc2) {
  1.1570 +        int rtn =
  1.1571 +            surface->hwdata->surface->Flip(surface->hwdata->surface, NULL,
  1.1572 +                                           0);
  1.1573 +        if (HIDDEN->mga_crtc2_stretch)
  1.1574 +            HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame,
  1.1575 +                                         surface->hwdata->surface,
  1.1576 +                                         &HIDDEN->c2ssize, &HIDDEN->c2dsize);
  1.1577 +        else
  1.1578 +            HIDDEN->c2frame->Blit(HIDDEN->c2frame,
  1.1579 +                                  surface->hwdata->surface, NULL,
  1.1580 +                                  HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1581 +
  1.1582 +        HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1583 +        return rtn;
  1.1584 +    } else
  1.1585 +        return surface->hwdata->surface->Flip(surface->hwdata->surface, NULL,
  1.1586 +                                              DSFLIP_WAITFORSYNC);
  1.1587  }
  1.1588  
  1.1589 -static int DirectFB_LockHWSurface(_THIS, SDL_Surface *surface)
  1.1590 +static int
  1.1591 +DirectFB_LockHWSurface(_THIS, SDL_Surface * surface)
  1.1592  {
  1.1593 -  DFBResult  ret;
  1.1594 -  void      *data;
  1.1595 -  int        pitch;
  1.1596 +    DFBResult ret;
  1.1597 +    void *data;
  1.1598 +    int pitch;
  1.1599  
  1.1600 -  ret = surface->hwdata->surface->Lock (surface->hwdata->surface,
  1.1601 -                                        DSLF_WRITE, &data, &pitch);
  1.1602 -  if (ret)
  1.1603 -    {
  1.1604 -      SetDirectFBerror ("surface->Lock", ret);
  1.1605 -      return -1;
  1.1606 +    ret = surface->hwdata->surface->Lock(surface->hwdata->surface,
  1.1607 +                                         DSLF_WRITE, &data, &pitch);
  1.1608 +    if (ret) {
  1.1609 +        SetDirectFBerror("surface->Lock", ret);
  1.1610 +        return -1;
  1.1611      }
  1.1612  
  1.1613 -  surface->pixels = data;
  1.1614 -  surface->pitch  = pitch;
  1.1615 +    surface->pixels = data;
  1.1616 +    surface->pitch = pitch;
  1.1617 +
  1.1618 +    return 0;
  1.1619 +}
  1.1620  
  1.1621 -  return 0;
  1.1622 +static void
  1.1623 +DirectFB_UnlockHWSurface(_THIS, SDL_Surface * surface)
  1.1624 +{
  1.1625 +    surface->hwdata->surface->Unlock(surface->hwdata->surface);
  1.1626 +    surface->pixels = NULL;
  1.1627  }
  1.1628  
  1.1629 -static void DirectFB_UnlockHWSurface(_THIS, SDL_Surface *surface)
  1.1630 -{
  1.1631 -  surface->hwdata->surface->Unlock (surface->hwdata->surface);
  1.1632 -  surface->pixels = NULL;
  1.1633 -}
  1.1634 -
  1.1635 -static void DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
  1.1636 +static void
  1.1637 +DirectFB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects)
  1.1638  {
  1.1639 -  if (HIDDEN->enable_mga_crtc2)
  1.1640 -    {
  1.1641 -       if (HIDDEN->mga_crtc2_stretch)
  1.1642 -         HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, this->screen->hwdata->surface, &HIDDEN->c2ssize, &HIDDEN->c2dsize); 
  1.1643 -       else
  1.1644 -         HIDDEN->c2frame->Blit(HIDDEN->c2frame, this->screen->hwdata->surface, NULL, HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); 
  1.1645 +    if (HIDDEN->enable_mga_crtc2) {
  1.1646 +        if (HIDDEN->mga_crtc2_stretch)
  1.1647 +            HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame,
  1.1648 +                                         this->screen->hwdata->surface,
  1.1649 +                                         &HIDDEN->c2ssize, &HIDDEN->c2dsize);
  1.1650 +        else
  1.1651 +            HIDDEN->c2frame->Blit(HIDDEN->c2frame,
  1.1652 +                                  this->screen->hwdata->surface, NULL,
  1.1653 +                                  HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1654  
  1.1655 -       HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1656 +        HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1657      }
  1.1658  }
  1.1659  
  1.1660 -static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects)
  1.1661 +static void
  1.1662 +DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect * rects)
  1.1663  {
  1.1664 -  DFBRegion         region;
  1.1665 -  int               i;
  1.1666 -  int               region_valid = 0;
  1.1667 -  IDirectFBSurface *surface = this->screen->hwdata->surface;
  1.1668 +    DFBRegion region;
  1.1669 +    int i;
  1.1670 +    int region_valid = 0;
  1.1671 +    IDirectFBSurface *surface = this->screen->hwdata->surface;
  1.1672  
  1.1673 -  for (i=0; i<numrects; ++i)
  1.1674 -    {
  1.1675 -      int x2, y2;
  1.1676 +    for (i = 0; i < numrects; ++i) {
  1.1677 +        int x2, y2;
  1.1678  
  1.1679 -      if ( ! rects[i].w ) /* Clipped? */
  1.1680 -        continue;
  1.1681 -
  1.1682 -      x2 = rects[i].x + rects[i].w - 1;
  1.1683 -      y2 = rects[i].y + rects[i].h - 1;
  1.1684 +        if (!rects[i].w)        /* Clipped? */
  1.1685 +            continue;
  1.1686  
  1.1687 -      if (region_valid)
  1.1688 -        {
  1.1689 -          if (rects[i].x < region.x1)
  1.1690 -            region.x1 = rects[i].x;
  1.1691 +        x2 = rects[i].x + rects[i].w - 1;
  1.1692 +        y2 = rects[i].y + rects[i].h - 1;
  1.1693  
  1.1694 -          if (rects[i].y < region.y1)
  1.1695 -            region.y1 = rects[i].y;
  1.1696 +        if (region_valid) {
  1.1697 +            if (rects[i].x < region.x1)
  1.1698 +                region.x1 = rects[i].x;
  1.1699  
  1.1700 -          if (x2 > region.x2)
  1.1701 -            region.x2 = x2;
  1.1702 +            if (rects[i].y < region.y1)
  1.1703 +                region.y1 = rects[i].y;
  1.1704  
  1.1705 -          if (y2 > region.y2)
  1.1706 -            region.y2 = y2;
  1.1707 -        }
  1.1708 -      else
  1.1709 -        {
  1.1710 +            if (x2 > region.x2)
  1.1711 +                region.x2 = x2;
  1.1712 +
  1.1713 +            if (y2 > region.y2)
  1.1714 +                region.y2 = y2;
  1.1715 +        } else {
  1.1716              region.x1 = rects[i].x;
  1.1717              region.y1 = rects[i].y;
  1.1718              region.x2 = x2;
  1.1719 @@ -1033,137 +1049,130 @@
  1.1720          }
  1.1721      }
  1.1722  
  1.1723 -  if (region_valid)
  1.1724 -    {
  1.1725 -      if (HIDDEN->enable_mga_crtc2)
  1.1726 -        {
  1.1727 -          if (HIDDEN->mga_crtc2_stretch)
  1.1728 -            HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, surface, &HIDDEN->c2ssize, &HIDDEN->c2dsize);
  1.1729 -          else
  1.1730 -            HIDDEN->c2frame->Blit(HIDDEN->c2frame, surface, NULL, HIDDEN->c2dsize.x, HIDDEN->c2dsize.y); 
  1.1731 -      
  1.1732 -          HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1733 -        }
  1.1734 -      else 
  1.1735 -        surface->Flip (surface, &region, DSFLIP_WAITFORSYNC);
  1.1736 +    if (region_valid) {
  1.1737 +        if (HIDDEN->enable_mga_crtc2) {
  1.1738 +            if (HIDDEN->mga_crtc2_stretch)
  1.1739 +                HIDDEN->c2frame->StretchBlit(HIDDEN->c2frame, surface,
  1.1740 +                                             &HIDDEN->c2ssize,
  1.1741 +                                             &HIDDEN->c2dsize);
  1.1742 +            else
  1.1743 +                HIDDEN->c2frame->Blit(HIDDEN->c2frame, surface, NULL,
  1.1744 +                                      HIDDEN->c2dsize.x, HIDDEN->c2dsize.y);
  1.1745 +
  1.1746 +            HIDDEN->c2frame->Flip(HIDDEN->c2frame, NULL, DSFLIP_WAITFORSYNC);
  1.1747 +        } else
  1.1748 +            surface->Flip(surface, &region, DSFLIP_WAITFORSYNC);
  1.1749      }
  1.1750  }
  1.1751  
  1.1752 -int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
  1.1753 +int
  1.1754 +DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  1.1755  {
  1.1756 -  IDirectFBPalette *palette = this->screen->hwdata->palette;
  1.1757 +    IDirectFBPalette *palette = this->screen->hwdata->palette;
  1.1758  
  1.1759 -  if (!palette)
  1.1760 -    return 0;
  1.1761 +    if (!palette)
  1.1762 +        return 0;
  1.1763  
  1.1764 -  if (firstcolor > 255)
  1.1765 -    return 0;
  1.1766 +    if (firstcolor > 255)
  1.1767 +        return 0;
  1.1768  
  1.1769 -  if (firstcolor + ncolors > 256)
  1.1770 -    ncolors = 256 - firstcolor;
  1.1771 +    if (firstcolor + ncolors > 256)
  1.1772 +        ncolors = 256 - firstcolor;
  1.1773  
  1.1774 -  if (ncolors > 0)
  1.1775 -    {
  1.1776 -      int      i;
  1.1777 -      DFBColor entries[ncolors];
  1.1778 +    if (ncolors > 0) {
  1.1779 +        int i;
  1.1780 +        DFBColor entries[ncolors];
  1.1781  
  1.1782 -      for (i=0; i<ncolors; i++)
  1.1783 -        {
  1.1784 -          entries[i].a = 0xff;
  1.1785 -          entries[i].r = colors[i].r;
  1.1786 -          entries[i].g = colors[i].g;
  1.1787 -          entries[i].b = colors[i].b;
  1.1788 +        for (i = 0; i < ncolors; i++) {
  1.1789 +            entries[i].a = 0xff;
  1.1790 +            entries[i].r = colors[i].r;
  1.1791 +            entries[i].g = colors[i].g;
  1.1792 +            entries[i].b = colors[i].b;
  1.1793          }
  1.1794  
  1.1795 -      palette->SetEntries (palette, entries, ncolors, firstcolor);
  1.1796 +        palette->SetEntries(palette, entries, ncolors, firstcolor);
  1.1797      }
  1.1798  
  1.1799 -  return 1;
  1.1800 +    return 1;
  1.1801  }
  1.1802 -	
  1.1803 -void DirectFB_VideoQuit(_THIS)
  1.1804 +
  1.1805 +void
  1.1806 +DirectFB_VideoQuit(_THIS)
  1.1807  {
  1.1808 -  struct DirectFBEnumRect *rect    = enumlist;
  1.1809 +    struct DirectFBEnumRect *rect = enumlist;
  1.1810  
  1.1811 -  if (this->screen && this->screen->hwdata)
  1.1812 -    {
  1.1813 -      IDirectFBSurface        *surface = this->screen->hwdata->surface;
  1.1814 -      IDirectFBPalette        *palette = this->screen->hwdata->palette;
  1.1815 +    if (this->screen && this->screen->hwdata) {
  1.1816 +        IDirectFBSurface *surface = this->screen->hwdata->surface;
  1.1817 +        IDirectFBPalette *palette = this->screen->hwdata->palette;
  1.1818  
  1.1819 -      if (palette)
  1.1820 -        palette->Release (palette);
  1.1821 +        if (palette)
  1.1822 +            palette->Release(palette);
  1.1823  
  1.1824 -      if (surface)
  1.1825 -        surface->Release (surface);
  1.1826 +        if (surface)
  1.1827 +            surface->Release(surface);
  1.1828  
  1.1829 -      this->screen->hwdata->surface = NULL;
  1.1830 -      this->screen->hwdata->palette = NULL;
  1.1831 +        this->screen->hwdata->surface = NULL;
  1.1832 +        this->screen->hwdata->palette = NULL;
  1.1833      }
  1.1834  
  1.1835 -  if (HIDDEN->c2frame)
  1.1836 -    {
  1.1837 -      HIDDEN->c2frame->Release (HIDDEN->c2frame);
  1.1838 -      HIDDEN->c2frame = NULL;
  1.1839 -    }
  1.1840 -
  1.1841 -  if (HIDDEN->eventbuffer)
  1.1842 -    {
  1.1843 -      HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer);
  1.1844 -      HIDDEN->eventbuffer = NULL;
  1.1845 +    if (HIDDEN->c2frame) {
  1.1846 +        HIDDEN->c2frame->Release(HIDDEN->c2frame);
  1.1847 +        HIDDEN->c2frame = NULL;
  1.1848      }
  1.1849  
  1.1850 -  if (HIDDEN->c2layer)
  1.1851 -    {
  1.1852 -      HIDDEN->c2layer->Release (HIDDEN->c2layer);
  1.1853 -      HIDDEN->c2layer = NULL;
  1.1854 +    if (HIDDEN->eventbuffer) {
  1.1855 +        HIDDEN->eventbuffer->Release(HIDDEN->eventbuffer);
  1.1856 +        HIDDEN->eventbuffer = NULL;
  1.1857      }
  1.1858  
  1.1859 -  if (HIDDEN->layer)
  1.1860 -    {
  1.1861 -      HIDDEN->layer->Release (HIDDEN->layer);
  1.1862 -      HIDDEN->layer = NULL;
  1.1863 +    if (HIDDEN->c2layer) {
  1.1864 +        HIDDEN->c2layer->Release(HIDDEN->c2layer);
  1.1865 +        HIDDEN->c2layer = NULL;
  1.1866      }
  1.1867  
  1.1868 -  if (HIDDEN->dfb)
  1.1869 -    {
  1.1870 -      HIDDEN->dfb->Release (HIDDEN->dfb);
  1.1871 -      HIDDEN->dfb = NULL;
  1.1872 +    if (HIDDEN->layer) {
  1.1873 +        HIDDEN->layer->Release(HIDDEN->layer);
  1.1874 +        HIDDEN->layer = NULL;
  1.1875      }
  1.1876  
  1.1877 -  /* Free video mode list */
  1.1878 -  if (HIDDEN->modelist)
  1.1879 -    {
  1.1880 -      free (HIDDEN->modelist);
  1.1881 -      HIDDEN->modelist = NULL;
  1.1882 +    if (HIDDEN->dfb) {
  1.1883 +        HIDDEN->dfb->Release(HIDDEN->dfb);
  1.1884 +        HIDDEN->dfb = NULL;
  1.1885      }
  1.1886  
  1.1887 -  /* Free mode enumeration list */
  1.1888 -  while (rect)
  1.1889 -    {
  1.1890 -      struct DirectFBEnumRect *next = rect->next;
  1.1891 -      free (rect);
  1.1892 -      rect = next;
  1.1893 +    /* Free video mode list */
  1.1894 +    if (HIDDEN->modelist) {
  1.1895 +        free(HIDDEN->modelist);
  1.1896 +        HIDDEN->modelist = NULL;
  1.1897      }
  1.1898 -  enumlist = NULL;
  1.1899  
  1.1900 -  HIDDEN->initialized = 0;
  1.1901 +    /* Free mode enumeration list */
  1.1902 +    while (rect) {
  1.1903 +        struct DirectFBEnumRect *next = rect->next;
  1.1904 +        free(rect);
  1.1905 +        rect = next;
  1.1906 +    }
  1.1907 +    enumlist = NULL;
  1.1908 +
  1.1909 +    HIDDEN->initialized = 0;
  1.1910  }
  1.1911  
  1.1912  
  1.1913 -int DirectFB_ShowWMCursor(_THIS, WMcursor *cursor)
  1.1914 +int
  1.1915 +DirectFB_ShowWMCursor(_THIS, WMcursor * cursor)
  1.1916  {
  1.1917 -  /* We can only hide or show the default cursor */
  1.1918 -  if ( cursor == NULL )
  1.1919 -    {
  1.1920 -      HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0x00);
  1.1921 +    /* We can only hide or show the default cursor */
  1.1922 +    if (cursor == NULL) {
  1.1923 +        HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0x00);
  1.1924 +    } else {
  1.1925 +        HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0xFF);
  1.1926      }
  1.1927 -    else
  1.1928 -    {
  1.1929 -      HIDDEN->layer->SetCursorOpacity(HIDDEN->layer, 0xFF);
  1.1930 -    }
  1.1931 -  return 1;
  1.1932 +    return 1;
  1.1933  }
  1.1934  
  1.1935 -void DirectFB_FinalQuit(void) 
  1.1936 +void
  1.1937 +DirectFB_FinalQuit(void)
  1.1938  {
  1.1939  }
  1.1940 +
  1.1941 +/* vi: set ts=4 sw=4 expandtab: */