00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef MMSFBDEV_H_
00034 #define MMSFBDEV_H_
00035
00036 #ifdef __HAVE_FBDEV__
00037
00038 #include "mmsgui/fb/mmsfbconv.h"
00039 #include "mmsgui/fb/fb.h"
00040 #include <termios.h>
00041
00042
00043 #define MMSFBDEV_QUERY_CONSOLE -1
00044
00045
00046 #define MMSFBDEV_NO_CONSOLE -2
00047
00048
00049 #ifndef FBIO_WAITFORVSYNC
00050 #define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t)
00051 #endif
00052
00053 #define MMSFBDEV_MAX_MODES 128
00054 #define MMSFBDEV_MAX_LAYERS 32
00055
00056
00057 class MMSFBDev {
00058 private:
00059
00060 bool isinitialized;
00061
00062
00063 string device_file;
00064
00065
00066 char device[8];
00067
00068
00069 int fd;
00070
00071
00072 void *framebuffer_base;
00073
00074
00075 bool reset_console_accel;
00076
00077
00078 struct termios saved_ts;
00079
00080
00081 struct fb_fix_screeninfo fix_screeninfo;
00082
00083
00084 struct fb_var_screeninfo var_screeninfo;
00085
00086
00087 struct fb_var_screeninfo org_var_screeninfo;
00088
00089
00090 struct fb_var_screeninfo modes[MMSFBDEV_MAX_MODES];
00091
00092
00093 int modes_cnt;
00094
00095 typedef struct {
00096
00097 bool isinitialized;
00098
00099 int width;
00100
00101 int height;
00102
00103 MMSFBSurfacePlanesBuffer buffers;
00104
00105 MMSFBSurfacePixelFormat pixelformat;
00106 } MMSFBDEV_LAYER;
00107
00108
00109 MMSFBDEV_LAYER layers[MMSFBDEV_MAX_LAYERS];
00110
00111
00112 int layers_cnt;
00113
00114
00115 int active_screen;
00116
00117 void printFixScreenInfo();
00118 void printVarScreenInfo();
00119 bool buildPixelFormat();
00120
00121 bool readModes();
00122
00123 void genFBPixelFormat(MMSFBSurfacePixelFormat pf, unsigned int *nonstd_format, MMSFBPixelDef *pixeldef);
00124 void disable(int fd, string device_file);
00125 bool activate(int fd, string device_file, struct fb_var_screeninfo *var_screeninfo,
00126 int width, int height, MMSFBSurfacePixelFormat pixelformat, bool switch_mode = true);
00127
00128 public:
00129 MMSFBDev();
00130 virtual ~MMSFBDev();
00131
00132 virtual bool openDevice(char *device_file = NULL, int console = MMSFBDEV_QUERY_CONSOLE);
00133 virtual void closeDevice();
00134 bool isInitialized();
00135
00136 virtual bool waitForVSync();
00137 virtual bool panDisplay(int buffer_id, void *framebuffer_base = NULL);
00138
00139 virtual bool testLayer(int layer_id);
00140 virtual bool initLayer(int layer_id, int width, int height, MMSFBSurfacePixelFormat pixelformat, int backbuffer = 0);
00141
00142 virtual bool releaseLayer(int layer_id);
00143 virtual bool restoreLayer(int layer_id);
00144
00145 bool getPixelFormat(int layer_id, MMSFBSurfacePixelFormat *pf);
00146 bool getPhysicalMemory(unsigned long *mem);
00147 bool getFrameBufferBase(unsigned char **base);
00148 bool getFrameBufferPtr(int layer_id, MMSFBSurfacePlanesBuffer buffers, int *width, int *height);
00149
00150 bool mapMmio(unsigned char **mmio);
00151 bool unmapMmio(unsigned char *mmio);
00152
00153 bool setMode(int width, int height, MMSFBSurfacePixelFormat pixelformat, int backbuffer = 0);
00154
00155 sigc::signal<bool, MMSFBSurfacePixelFormat, unsigned int*, MMSFBPixelDef*>::accumulated<neg_bool_accumulator> onGenFBPixelFormat;
00156 sigc::signal<bool, int, string>::accumulated<neg_bool_accumulator> onDisable;
00157 sigc::signal<bool, int, string, fb_var_screeninfo *, int, int, MMSFBSurfacePixelFormat, bool>::accumulated<neg_bool_accumulator> onActivate;
00158
00159 private:
00160 typedef struct {
00161
00162 int fd0;
00163
00164
00165 int fd;
00166
00167
00168 int number;
00169
00170
00171 int previous;
00172
00173
00174 int org_fb;
00175 } VT;
00176
00177 VT vt;
00178
00179 bool vtOpen(int console = MMSFBDEV_QUERY_CONSOLE);
00180 void vtClose();
00181 virtual bool vtGetFd(int *fd);
00182
00183 friend class MMSFBDevVesa;
00184 friend class MMSFBDevMatrox;
00185 friend class MMSFBDevDavinci;
00186 friend class MMSFBDevOmap;
00187 friend class MMSInputLISHandler;
00188
00189 };
00190
00191 #endif
00192
00193 #endif