Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsfbdev.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
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 //! openDevice() console parameter, use free virtual console
00043 #define MMSFBDEV_QUERY_CONSOLE  -1
00044 
00045 //! openDevice() console parameter, do not open a virtual console
00046 #define MMSFBDEV_NO_CONSOLE     -2
00047 
00048 // added missing ioctl
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         //! is initialized?
00060         bool    isinitialized;
00061 
00062         //! name of the device file
00063         string  device_file;
00064 
00065         //! device abbreviation
00066         char    device[8];
00067 
00068         //! file descriptor of the framebuffer
00069         int     fd;
00070 
00071         //! virtual framebuffer address
00072         void    *framebuffer_base;
00073 
00074         //! have to reset the console acceleration
00075         bool    reset_console_accel;
00076 
00077         //! saved settings from general terminal interface
00078         struct termios saved_ts;
00079 
00080         //! fix screen infos
00081         struct fb_fix_screeninfo    fix_screeninfo;
00082 
00083         //! variable screen infos
00084         struct fb_var_screeninfo    var_screeninfo;
00085 
00086         //! original variable screen infos
00087         struct fb_var_screeninfo    org_var_screeninfo;
00088 
00089         //! available modes read from /etc/fb.modes
00090         struct fb_var_screeninfo    modes[MMSFBDEV_MAX_MODES];
00091 
00092         //! number of loaded modes
00093         int modes_cnt;
00094 
00095         typedef struct {
00096             //! is initialized?
00097             bool    isinitialized;
00098             //! width of the layer
00099             int width;
00100             //! height of the layer
00101             int height;
00102             //! describes the surface buffers
00103             MMSFBSurfacePlanesBuffer buffers;
00104             //! pixelformat of the layer
00105             MMSFBSurfacePixelFormat pixelformat;
00106         } MMSFBDEV_LAYER;
00107 
00108         //! layer infos
00109         MMSFBDEV_LAYER layers[MMSFBDEV_MAX_LAYERS];
00110 
00111         //! number of layers
00112         int layers_cnt;
00113 
00114         //! id of the active screen (this is for fbs != vesa)
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             //! /dev/tty0 file descriptor
00162             int fd0;
00163 
00164             //! file descriptor of the allocated tty
00165             int fd;
00166 
00167             //! number of vt where disko is running
00168             int number;
00169 
00170             //! number of vt from which disko was started
00171             int previous;
00172 
00173             //! save original fb
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 /* MMSFBDEV_H_ */

Generated by doxygen