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