src/video/fbcon/SDL_fbvideo.h
author Edgar Simo <bobbens@gmail.com>
Sun, 06 Jul 2008 17:06:37 +0000
branchgsoc2008_force_feedback
changeset 2498 ab567bd667bf
parent 1895 c121d94672cb
child 2859 99210400e8b9
permissions -rw-r--r--
Fixed various mistakes in the doxygen.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #ifndef _SDL_fbvideo_h
    25 #define _SDL_fbvideo_h
    26 
    27 #include <sys/types.h>
    28 #include <termios.h>
    29 #include <linux/fb.h>
    30 
    31 #include "SDL_mouse.h"
    32 #include "SDL_mutex.h"
    33 #include "../SDL_sysvideo.h"
    34 #if SDL_INPUT_TSLIB
    35 #include "tslib.h"
    36 #endif
    37 
    38 /* Hidden "this" pointer for the video functions */
    39 #define _THIS	SDL_VideoDevice *this
    40 
    41 
    42 /* This is the structure we use to keep track of video memory */
    43 typedef struct vidmem_bucket
    44 {
    45     struct vidmem_bucket *prev;
    46     int used;
    47     int dirty;
    48     char *base;
    49     unsigned int size;
    50     struct vidmem_bucket *next;
    51 } vidmem_bucket;
    52 
    53 /* Private display data */
    54 struct SDL_PrivateVideoData
    55 {
    56     int console_fd;
    57     struct fb_var_screeninfo cache_vinfo;
    58     struct fb_var_screeninfo saved_vinfo;
    59     int saved_cmaplen;
    60     __u16 *saved_cmap;
    61 
    62     int current_vt;
    63     int saved_vt;
    64     int keyboard_fd;
    65     int saved_kbd_mode;
    66     struct termios saved_kbd_termios;
    67 
    68     int mouse_fd;
    69 #if SDL_INPUT_TSLIB
    70     struct tsdev *ts_dev;
    71 #endif
    72 
    73     char *mapped_mem;
    74     int mapped_memlen;
    75     int mapped_offset;
    76     char *mapped_io;
    77     long mapped_iolen;
    78     int flip_page;
    79     char *flip_address[2];
    80 
    81 #define NUM_MODELISTS	4       /* 8, 16, 24, and 32 bits-per-pixel */
    82     int SDL_nummodes[NUM_MODELISTS];
    83     SDL_Rect **SDL_modelist[NUM_MODELISTS];
    84 
    85     vidmem_bucket surfaces;
    86     int surfaces_memtotal;
    87     int surfaces_memleft;
    88 
    89     SDL_mutex *hw_lock;
    90     int switched_away;
    91     struct fb_var_screeninfo screen_vinfo;
    92     Uint32 screen_arealen;
    93     Uint8 *screen_contents;
    94     __u16 screen_palette[3 * 256];
    95 
    96     void (*wait_vbl) (_THIS);
    97     void (*wait_idle) (_THIS);
    98 };
    99 /* Old variable names */
   100 #define console_fd		(this->hidden->console_fd)
   101 #define current_vt		(this->hidden->current_vt)
   102 #define saved_vt		(this->hidden->saved_vt)
   103 #define keyboard_fd		(this->hidden->keyboard_fd)
   104 #define saved_kbd_mode		(this->hidden->saved_kbd_mode)
   105 #define saved_kbd_termios	(this->hidden->saved_kbd_termios)
   106 #define mouse_fd		(this->hidden->mouse_fd)
   107 #if SDL_INPUT_TSLIB
   108 #define ts_dev			(this->hidden->ts_dev)
   109 #endif
   110 #define cache_vinfo		(this->hidden->cache_vinfo)
   111 #define saved_vinfo		(this->hidden->saved_vinfo)
   112 #define saved_cmaplen		(this->hidden->saved_cmaplen)
   113 #define saved_cmap		(this->hidden->saved_cmap)
   114 #define mapped_mem		(this->hidden->mapped_mem)
   115 #define mapped_memlen		(this->hidden->mapped_memlen)
   116 #define mapped_offset		(this->hidden->mapped_offset)
   117 #define mapped_io		(this->hidden->mapped_io)
   118 #define mapped_iolen		(this->hidden->mapped_iolen)
   119 #define flip_page		(this->hidden->flip_page)
   120 #define flip_address		(this->hidden->flip_address)
   121 #define SDL_nummodes		(this->hidden->SDL_nummodes)
   122 #define SDL_modelist		(this->hidden->SDL_modelist)
   123 #define surfaces		(this->hidden->surfaces)
   124 #define surfaces_memtotal	(this->hidden->surfaces_memtotal)
   125 #define surfaces_memleft	(this->hidden->surfaces_memleft)
   126 #define hw_lock			(this->hidden->hw_lock)
   127 #define switched_away		(this->hidden->switched_away)
   128 #define screen_vinfo		(this->hidden->screen_vinfo)
   129 #define screen_arealen		(this->hidden->screen_arealen)
   130 #define screen_contents		(this->hidden->screen_contents)
   131 #define screen_palette		(this->hidden->screen_palette)
   132 #define wait_vbl		(this->hidden->wait_vbl)
   133 #define wait_idle		(this->hidden->wait_idle)
   134 
   135 /* Accelerator types that are supported by the driver, but are not
   136    necessarily in the kernel headers on the system we compile on.
   137 */
   138 #ifndef FB_ACCEL_MATROX_MGAG400
   139 #define FB_ACCEL_MATROX_MGAG400	26      /* Matrox G400                  */
   140 #endif
   141 #ifndef FB_ACCEL_3DFX_BANSHEE
   142 #define FB_ACCEL_3DFX_BANSHEE	31      /* 3Dfx Banshee                 */
   143 #endif
   144 
   145 /* These functions are defined in SDL_fbvideo.c */
   146 extern void FB_SavePaletteTo(_THIS, int palette_len, __u16 * area);
   147 extern void FB_RestorePaletteFrom(_THIS, int palette_len, __u16 * area);
   148 
   149 /* These are utility functions for working with video surfaces */
   150 
   151 static __inline__ void
   152 FB_AddBusySurface(SDL_Surface * surface)
   153 {
   154     ((vidmem_bucket *) surface->hwdata)->dirty = 1;
   155 }
   156 
   157 static __inline__ int
   158 FB_IsSurfaceBusy(SDL_Surface * surface)
   159 {
   160     return ((vidmem_bucket *) surface->hwdata)->dirty;
   161 }
   162 
   163 static __inline__ void
   164 FB_WaitBusySurfaces(_THIS)
   165 {
   166     vidmem_bucket *bucket;
   167 
   168     /* Wait for graphic operations to complete */
   169     wait_idle(this);
   170 
   171     /* Clear all surface dirty bits */
   172     for (bucket = &surfaces; bucket; bucket = bucket->next) {
   173         bucket->dirty = 0;
   174     }
   175 }
   176 
   177 static __inline__ void
   178 FB_dst_to_xy(_THIS, SDL_Surface * dst, int *x, int *y)
   179 {
   180     *x = (long) ((char *) dst->pixels - mapped_mem) % this->screen->pitch;
   181     *y = (long) ((char *) dst->pixels - mapped_mem) / this->screen->pitch;
   182     if (dst == this->screen) {
   183         *x += this->offset_x;
   184         *y += this->offset_y;
   185     }
   186 }
   187 
   188 #endif /* _SDL_fbvideo_h */
   189 /* vi: set ts=4 sw=4 expandtab: */