Qt 4.8
Public Types | Public Slots | Public Functions | Public Variables | Protected Functions | Static Protected Functions | Protected Variables | Private Functions | Properties | List of all members
QLinuxFbScreen Class Reference

The QLinuxFbScreen class implements a screen driver for the Linux framebuffer. More...

#include <qscreenlinuxfb_qws.h>

Inheritance diagram for QLinuxFbScreen:
QFbScreen QScreen QPlatformScreen QObject

Public Types

enum  DriverTypes { GenericDriver, EInk8Track }
 This enum describes the driver type. More...
 
- Public Types inherited from QScreen
enum  ClassId {
  LinuxFBClass, TransformedClass, VNCClass, MultiClass,
  VFbClass, DirectFBClass, SvgalibClass, ProxyClass,
  GLClass, IntfbClass, CustomClass = 1024
}
 This enum defines the class identifiers for the known screen subclasses. More...
 
enum  PixelType { NormalPixel, BGRPixel }
 This enum describes the pixel storage format of the screen, i. More...
 

Public Slots

QRegion doRedraw ()
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Public Functions

virtual void blank (bool on)
 Reimplemented Function More...
 
virtual ucharcache (int)
 Requests the specified amount of offscreen graphics card memory from the memory manager, and returns a pointer to the data within the framebuffer (or 0 if there is no free memory). More...
 
virtual bool connect (const QString &displaySpec)
 This is called by Qt for Embedded Linux clients to map in the framebuffer. More...
 
virtual void disconnect ()
 This unmaps the framebuffer. More...
 
virtual bool initDevice ()
 This is called by the Qt for Embedded Linux server at startup time. More...
 
 QLinuxFbScreen (uchar *d, int w, int h, int lstep, QImage::Format screenFormat)
 
 QLinuxFbScreen (int display_id)
 Constructs a QLinuxFbScreen object. More...
 
virtual void restore ()
 This is called when the virtual console is switched back to Qt for Embedded Linux and restores the palette. More...
 
virtual void save ()
 This doesn't do anything; accelerated drivers may wish to reimplement it to save graphics cards registers. More...
 
virtual void set (unsigned int, unsigned int, unsigned int, unsigned int)
 Sets the specified color index to the specified RGB value, (red, green, blue), when in paletted graphics modes. More...
 
virtual void setDirty (const QRect &)
 Reimplemented Function More...
 
void setFormat (QImage::Format format)
 
void setGeometry (QRect rect)
 
virtual void setMode (int, int, int)
 Sets the framebuffer to a new resolution and bit depth. More...
 
virtual int sharedRamSize (void *)
 
virtual void shutdownDevice ()
 This is called by the Qt for Embedded Linux server when it shuts down, and should be inherited if you need to do any card-specific cleanup. More...
 
virtual void uncache (uchar *)
 Deletes the specified memoryBlock allocated from the graphics card memory. More...
 
virtual bool useOffscreen ()
 
virtual ~QLinuxFbScreen ()
 Destroys this QLinuxFbScreen object. More...
 
- Public Functions inherited from QFbScreen
virtual void addWindow (QFbWindow *surface)
 
virtual int depth () const
 Reimplement in subclass to return current depth of the screen. More...
 
virtual QImage::Format format () const
 Reimplement in subclass to return the image format which corresponds to the screen format. More...
 
virtual QRect geometry () const
 Reimplement in subclass to return the pixel geometry of the screen. More...
 
QImageimage () const
 
virtual void lower (QPlatformWindow *surface)
 
QPaintDevicepaintDevice () const
 
virtual QSize physicalSize () const
 Reimplement this function in subclass to return the physical size of the screen. More...
 
 QFbScreen ()
 
virtual void raise (QPlatformWindow *surface)
 
virtual void removeWindow (QFbWindow *surface)
 
virtual void setDepth (int depth)
 
virtual void setPhysicalSize (QSize size)
 
virtual QWidgettopLevelAt (const QPoint &p) const
 Return the given top level widget for a given position. More...
 
 ~QFbScreen ()
 
- Public Functions inherited from QPlatformScreen
virtual QRect availableGeometry () const
 Reimplement in subclass to return the pixel geometry of the available space This normally is the desktop screen minus the task manager, global menubar etc. More...
 
virtual ~QPlatformScreen ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QScreen
virtual int alloc (unsigned int, unsigned int, unsigned int)
 Returns the index in the screen's palette which is the closest match to the given RGB value (red, green, blue). More...
 
ucharbase () const
 Returns a pointer to the beginning of the framebuffer. More...
 
virtual void blit (const QImage &img, const QPoint &topLeft, const QRegion &region)
 Copies the given region in the given image to the point specified by topLeft using device coordinates. More...
 
void blit (QWSWindow *bs, const QRegion &clip)
 
ClassId classId () const
 Returns the class identifier for the screen object. More...
 
QRgbclut ()
 Returns a pointer to the screen's color lookup table (i. More...
 
int colorCount ()
 Returns the number of entries in the screen's color lookup table (i. More...
 
virtual QWSWindowSurfacecreateSurface (QWidget *widget) const
 Creates and returns a new window surface for the given widget. More...
 
virtual QWSWindowSurfacecreateSurface (const QString &key) const
 Creates and returns a new window surface matching the given key. More...
 
int depth () const
 Returns the depth of the framebuffer, in bits per pixel. More...
 
int deviceHeight () const
 Returns the full height of the framebuffer device in pixels. More...
 
int deviceWidth () const
 Returns the physical width of the framebuffer device in pixels. More...
 
virtual void exposeRegion (QRegion r, int changing)
 This function is called by the Qt for Embedded Linux server whenever a screen update is required. More...
 
QGraphicsSystemgraphicsSystem () const
 
virtual void haltUpdates ()
 
int height () const
 Returns the logical height of the framebuffer in pixels. More...
 
virtual bool isInterlaced () const
 Returns true if the display is interlaced (i. More...
 
virtual bool isTransformed () const
 Returns true if the screen is transformed (for instance, rotated 90 degrees); otherwise returns false. More...
 
int linestep () const
 Returns the length of each scanline of the framebuffer in bytes. More...
 
virtual QSize mapFromDevice (const QSize &) const
 Maps the given size from the framebuffer coordinate system to the coordinate space used by the application. More...
 
virtual QPoint mapFromDevice (const QPoint &, const QSize &) const
 Maps the given point from the framebuffer coordinate system to the coordinate space used by the application, passing the device's screenSize as argument. More...
 
virtual QRect mapFromDevice (const QRect &, const QSize &) const
 Maps the given rectangle from the framebuffer coordinate system to the coordinate space used by the application, passing the device's screenSize as argument. More...
 
virtual QImage mapFromDevice (const QImage &) const
 Maps the given image from the framebuffer coordinate system to the coordinate space used by the application. More...
 
virtual QRegion mapFromDevice (const QRegion &, const QSize &) const
 Maps the given region from the framebuffer coordinate system to the coordinate space used by the application, passing the device's screenSize as argument. More...
 
virtual QSize mapToDevice (const QSize &) const
 Maps the given size from the coordinate space used by the application to the framebuffer coordinate system. More...
 
virtual QPoint mapToDevice (const QPoint &, const QSize &) const
 Maps the given point from the coordinate space used by the application to the framebuffer coordinate system, passing the device's screenSize as argument. More...
 
virtual QRect mapToDevice (const QRect &, const QSize &) const
 Maps the given rectangle from the coordinate space used by the application to the framebuffer coordinate system, passing the device's screenSize as argument. More...
 
virtual QImage mapToDevice (const QImage &) const
 Maps the given image from the coordinate space used by the application to the framebuffer coordinate system. More...
 
virtual QRegion mapToDevice (const QRegion &, const QSize &) const
 Maps the given region from the coordinate space used by the application to the framebuffer coordinate system, passing the device's screenSize as argument. More...
 
virtual int memoryNeeded (const QString &)
 
QT_DEPRECATED int numCols ()
 
QPoint offset () const
 Returns the logical offset of the screen, i. More...
 
virtual bool onCard (const unsigned char *) const
 Returns true if the specified buffer is within the graphics card's memory; otherwise returns false (i.e. More...
 
virtual bool onCard (const unsigned char *, ulong &out_offset) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.If the specified buffer is within the graphics card's memory, this function stores the offset from the start of graphics card memory (in bytes), in the location specified by the offset parameter. More...
 
int physicalHeight () const
 Returns the physical height of the screen in millimeters. More...
 
int physicalWidth () const
 Returns the physical width of the screen in millimeters. More...
 
QImage::Format pixelFormat () const
 Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a supported image format. More...
 
PixelType pixelType () const
 Returns the pixel storage format of the screen. More...
 
QPixmapDataFactorypixmapDataFactory () const
 
virtual int pixmapDepth () const
 Returns the preferred depth for pixmaps, in bits per pixel. More...
 
virtual int pixmapLinestepAlignment ()
 Returns the value (in bits) to which individual scanlines of pixmaps held in the graphics card's memory, should be aligned. More...
 
virtual int pixmapOffsetAlignment ()
 Returns the value (in bits) to which the start address of pixmaps held in the graphics card's memory, should be aligned. More...
 
 QScreen (int display_id, ClassId classId)
 Constructs a new screen driver. More...
 
 QScreen (int display_id)
 Constructs a new screen driver. More...
 
virtual QRegion region () const
 Returns the region covered by this screen driver. More...
 
virtual void resumeUpdates ()
 
int screenSize () const
 Returns the size of the screen in bytes. More...
 
void setOffset (const QPoint &p)
 
virtual void solidFill (const QColor &color, const QRegion &region)
 Fills the given region of the screen with the specified color. More...
 
int subScreenIndexAt (const QPoint &p) const
 Returns the index of the subscreen at the given position; returns -1 if no screen is found. More...
 
virtual QList< QScreen * > subScreens () const
 
virtual bool supportsDepth (int) const
 Returns true if the screen supports the specified color depth; otherwise returns false. More...
 
int totalSize () const
 Returns the size of the available graphics card memory (including the screen) in bytes. More...
 
virtual int transformOrientation () const
 Returns the current rotation as an integer value. More...
 
int width () const
 Returns the logical width of the framebuffer in pixels. More...
 
virtual ~QScreen ()
 Destroys this screen driver. More...
 

Public Variables

QLinuxFb_Sharedshared
 

Protected Functions

void deleteEntry (uchar *)
 Deletes the specified memoryBlock allocated from the graphics card memory. More...
 
virtual void fixupScreenInfo (fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo)
 Adjust the values returned by the framebuffer driver, to work around driver bugs or nonstandard behavior in certain drivers. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Functions inherited from QScreen
void setGraphicsSystem (QGraphicsSystem *system)
 
void setPixelFormat (QImage::Format format)
 Sets the screen's pixel format to format. More...
 
void setPixmapDataFactory (QPixmapDataFactory *factory)
 

Static Protected Functions

static void clearCache (QScreen *instance, int)
 Removes all entries from the cache for the specified screen instance and client identified by the given clientId. More...
 

Protected Variables

int cacheStart
 
bool canaccel
 
int dataoffset
 
- Protected Variables inherited from QFbScreen
QPlatformSoftwareCursorcursor
 
int mDepth
 
QImage::Format mFormat
 
QRect mGeometry
 
QSize mPhysicalSize
 
QImagemScreenImage
 
QTimer redrawTimer
 
QRegion repaintRegion
 
QList< QFbWindow * > windowStack
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QScreen
int d
 the pixel depth More...
 
uchardata
 points to the first visible pixel in the frame buffer. More...
 
int dh
 the device height More...
 
int displayId
 
int dw
 the device width More...
 
QPoolEntryentries
 
int * entryp
 
bool grayscale
 the gray scale screen mode flag More...
 
int h
 the logical height of the screen. More...
 
unsigned int * lowest
 
int lstep
 the number of bytes representing a line in the frame buffer. More...
 
int mapsize
 the total number of bytes in the frame buffer More...
 
int physHeight
 the physical height of the screen in millimeters. More...
 
int physWidth
 the physical width of the screen in millimeters. More...
 
PixelType pixeltype
 set to BGRPixel More...
 
QRgb screenclut [256]
 the color table More...
 
int screencols
 the number of entries in the color table More...
 
int size
 the number of bytes in the visible region of the frame buffer More...
 
int w
 the logical width of the screen. More...
 

Private Functions

void createPalette (fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo)
 
void delete_entry (int)
 
void insert_entry (int, int, int)
 
void setPixelFormat (struct fb_var_screeninfo)
 
void setupOffScreen ()
 

Properties

int bytesPerLine
 
QPaintercompositePainter
 
QLinuxFbScreenPrivated_ptr
 
uchardata
 
QImagemFbScreenImage
 

Additional Inherited Members

- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QPlatformScreen
static QPlatformScreenplatformScreenForWidget (const QWidget *widget)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QScreen
static QScreeninstance ()
 Returns a pointer to the application's QScreen instance. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QFbScreen
virtual QRegion doRedraw ()
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 
- Static Protected Variables inherited from QScreen
static ClearCacheFunc clearCacheFunc = 0
 

Detailed Description

The QLinuxFbScreen class implements a screen driver for the Linux framebuffer.

Warning
This function is not part of the public interface.

Note that this class is only available in Qt for Embedded Linux. Custom screen drivers can be added by subclassing the QScreenDriverPlugin class, using the QScreenDriverFactory class to dynamically load the driver into the application, but there should only be one screen object per application.

The QLinuxFbScreen class provides the cache() function allocating off-screen graphics memory, and the complementary uncache() function releasing the allocated memory. The latter function will first sync the graphics card to ensure the memory isn't still being used by a command in the graphics card FIFO queue. The deleteEntry() function deletes the given memory block without such synchronization. Given the screen instance and client id, the memory can also be released using the clearCache() function, but this should only be necessary if a client exits abnormally.

In addition, when in paletted graphics modes, the set() function provides the possibility of setting a specified color index to a given RGB value.

The QLinuxFbScreen class also acts as a factory for the unaccelerated screen cursor and the unaccelerated raster-based implementation of QPaintEngine (QRasterPaintEngine); accelerated drivers for Linux should derive from this class.

See also
QScreen, QScreenDriverPlugin, {Running Applications}

Definition at line 80 of file qscreenlinuxfb_qws.h.

Enumerations

◆ DriverTypes

This enum describes the driver type.

  • GenericDriver Generic Linux framebuffer driver
  • EInk8Track e-Ink framebuffer driver using the 8Track chipset
Enumerator
GenericDriver 
EInk8Track 

Definition at line 91 of file qscreenlinuxfb_qws.h.

Constructors and Destructors

◆ QLinuxFbScreen() [1/2]

QLinuxFbScreen::QLinuxFbScreen ( int  displayId)
explicit

Constructs a QLinuxFbScreen object.

The displayId argument identifies the Qt for Embedded Linux server to connect to.

Definition at line 264 of file qscreenlinuxfb_qws.cpp.

265  : QScreen(display_id, LinuxFBClass), d_ptr(new QLinuxFbScreenPrivate)
266 {
267  canaccel=false;
269 #ifdef QT_QWS_CLIENTBLIT
270  setSupportsBlitInClients(true);
271 #endif
272 }
QLinuxFbScreenPrivate * d_ptr
static ClearCacheFunc clearCacheFunc
Definition: qscreen_qws.h:344
QScreen(int display_id, ClassId classId)
Constructs a new screen driver.
static void clearCache(QScreen *instance, int)
Removes all entries from the cache for the specified screen instance and client identified by the giv...

◆ ~QLinuxFbScreen()

QLinuxFbScreen::~QLinuxFbScreen ( )
virtual

Destroys this QLinuxFbScreen object.

Definition at line 278 of file qscreenlinuxfb_qws.cpp.

279 {
280 #ifdef QT_NO_QWS_SIGNALHANDLER
281  delete d_ptr;
282 #endif
283 }
QLinuxFbScreenPrivate * d_ptr

◆ QLinuxFbScreen() [2/2]

QLinuxFbScreen::QLinuxFbScreen ( uchar d,
int  w,
int  h,
int  lstep,
QImage::Format  screenFormat 
)

Definition at line 818 of file qlinuxfbintegration.cpp.

819  : compositePainter(0)
820 {
821  data = d;
822  mGeometry = QRect(0,0,w,h);
824  mFormat = screenFormat;
825  mDepth = 16;
827  mFormat);
830 #ifndef QT_NO_CURSOR
831  cursor = new QPlatformSoftwareCursor(this);
832 #endif
833 }
QImage * mScreenImage
Definition: fb_base.h:197
int d
the pixel depth
Definition: qscreen_qws.h:327
QImage::Format mFormat
Definition: fb_base.h:195
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int w
the logical width of the screen.
Definition: qscreen_qws.h:324
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QRect mGeometry
Definition: fb_base.h:193
int mDepth
Definition: fb_base.h:194
QPlatformSoftwareCursor * cursor
Definition: fb_base.h:186
QPainter * compositePainter
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int lstep
the number of bytes representing a line in the frame buffer.
Definition: qscreen_qws.h:325
int h
the logical height of the screen.
Definition: qscreen_qws.h:326

Functions

◆ blank()

void QLinuxFbScreen::blank ( bool  on)
virtual

Reimplemented Function

Reimplemented from QScreen.

Definition at line 1302 of file qscreenlinuxfb_qws.cpp.

Referenced by initDevice().

1303 {
1304  if (d_ptr->blank == on)
1305  return;
1306 
1307 #if defined(QT_QWS_IPAQ)
1308  if (on)
1309  system("apm -suspend");
1310 #else
1311  if (d_ptr->fd == -1)
1312  return;
1313 // Some old kernel versions don't have this. These defines should go
1314 // away eventually
1315 #if defined(FBIOBLANK)
1316 #if defined(VESA_POWERDOWN) && defined(VESA_NO_BLANKING)
1317  ioctl(d_ptr->fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING);
1318 #else
1319  ioctl(d_ptr->fd, FBIOBLANK, on ? 1 : 0);
1320 #endif
1321 #endif
1322 #endif
1323 
1324  d_ptr->blank = on;
1325 }
QLinuxFbScreenPrivate * d_ptr

◆ cache()

uchar * QLinuxFbScreen::cache ( int  amount)
virtual

Requests the specified amount of offscreen graphics card memory from the memory manager, and returns a pointer to the data within the framebuffer (or 0 if there is no free memory).

Note that the display is locked while memory is allocated in order to preserve the memory pool's integrity.

Use the QScreen::onCard() function to retrieve an offset (in bytes) from the start of graphics card memory for the returned pointer.

See also
uncache(), clearCache(), deleteEntry()

Reimplemented from QScreen.

Definition at line 915 of file qscreenlinuxfb_qws.cpp.

916 {
917  if (!canaccel || entryp == 0)
918  return 0;
919 
920  qt_fbdpy->grab();
921 
922  int startp = cacheStart + (*entryp+1) * sizeof(QPoolEntry);
923  if (startp >= (int)*lowest) {
924  // We don't have room for another cache QPoolEntry.
925 #ifdef DEBUG_CACHE
926  qDebug("No room for pool entry in VRAM");
927 #endif
928  qt_fbdpy->ungrab();
929  return 0;
930  }
931 
932  int align = pixmapOffsetAlignment();
933 
934  if (*entryp > 1) {
935  // Try to find a gap in the allocated blocks.
936  for (int loopc = 0; loopc < *entryp-1; loopc++) {
937  int freestart = entries[loopc+1].end;
938  int freeend = entries[loopc].start;
939  if (freestart != freeend) {
940  while (freestart % align) {
941  freestart++;
942  }
943  int len=freeend-freestart;
944  if (len >= amount) {
945  insert_entry(loopc+1, freestart, freestart+amount);
946  qt_fbdpy->ungrab();
947  return data+freestart;
948  }
949  }
950  }
951  }
952 
953  // No free blocks in already-taken memory; get some more
954  // if we can
955  int newlowest = (*lowest)-amount;
956  if (newlowest % align) {
957  newlowest -= align;
958  while (newlowest % align) {
959  newlowest++;
960  }
961  }
962  if (startp >= newlowest) {
963  qt_fbdpy->ungrab();
964 #ifdef DEBUG_CACHE
965  qDebug("No VRAM available for %d bytes", amount);
966 #endif
967  return 0;
968  }
969  insert_entry(*entryp, newlowest, *lowest);
970  qt_fbdpy->ungrab();
971 
972  return data + newlowest;
973 }
int * entryp
Definition: qscreen_qws.h:321
unsigned int * lowest
Definition: qscreen_qws.h:322
Q_GUI_EXPORT QWSDisplay * qt_fbdpy
unsigned int start
Definition: qscreen_qws.h:179
virtual int pixmapOffsetAlignment()
Returns the value (in bits) to which the start address of pixmaps held in the graphics card&#39;s memory...
Definition: qscreen_qws.h:213
unsigned int end
Definition: qscreen_qws.h:180
Q_CORE_EXPORT void qDebug(const char *,...)
static void grab()
QPoolEntry * entries
Definition: qscreen_qws.h:320
static void ungrab()
void insert_entry(int, int, int)

◆ clearCache()

void QLinuxFbScreen::clearCache ( QScreen instance,
int  clientId 
)
staticprotected

Removes all entries from the cache for the specified screen instance and client identified by the given clientId.

Calling this function should only be necessary if a client exits abnormally.

See also
cache(), uncache(), deleteEntry()

Definition at line 1040 of file qscreenlinuxfb_qws.cpp.

Referenced by QLinuxFbScreen().

1041 {
1042  QLinuxFbScreen *screen = (QLinuxFbScreen *)instance;
1043  if (!screen->canaccel || !screen->entryp)
1044  return;
1045  qt_fbdpy->grab();
1046  for (int loopc = 0; loopc < *(screen->entryp); loopc++) {
1047  if (screen->entries[loopc].clientId == clientId) {
1048  screen->delete_entry(loopc);
1049  loopc--;
1050  }
1051  }
1052  qt_fbdpy->ungrab();
1053 }
int * entryp
Definition: qscreen_qws.h:321
Q_GUI_EXPORT QWSDisplay * qt_fbdpy
static void grab()
QPoolEntry * entries
Definition: qscreen_qws.h:320
const QString clientId
static void ungrab()
The QLinuxFbScreen class implements a screen driver for the Linux framebuffer.

◆ connect()

bool QLinuxFbScreen::connect ( const QString displaySpec)
virtual

This is called by Qt for Embedded Linux clients to map in the framebuffer.

Reimplemented Function

It should be reimplemented by accelerated drivers to map in graphics card registers; those drivers should then call this function in order to set up offscreen memory management. The device is specified in displaySpec; e.g. "/dev/fb".

See also
disconnect()

Implements QScreen.

Definition at line 300 of file qscreenlinuxfb_qws.cpp.

Referenced by setMode().

301 {
302  d_ptr->displaySpec = displaySpec;
303 
304  const QStringList args = displaySpec.split(QLatin1Char(':'));
305 
306  if (args.contains(QLatin1String("nographicsmodeswitch")))
307  d_ptr->doGraphicsMode = false;
308 
309 #ifdef QT_QWS_DEPTH_GENERIC
310  if (args.contains(QLatin1String("genericcolors")))
311  d_ptr->doGenericColors = true;
312 #endif
313 
314  QRegExp ttyRegExp(QLatin1String("tty=(.*)"));
315  if (args.indexOf(ttyRegExp) != -1)
316  d_ptr->ttyDevice = ttyRegExp.cap(1);
317 
318 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
319 #ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN
320  if (args.contains(QLatin1String("littleendian")))
321 #endif
323 #endif
324 
325  QString dev = QLatin1String("/dev/fb0");
326  foreach(QString d, args) {
327  if (d.startsWith(QLatin1Char('/'))) {
328  dev = d;
329  break;
330  }
331  }
332 
333  if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0)
334  d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR);
335  if (d_ptr->fd == -1) {
337  perror("QScreenLinuxFb::connect");
338  qCritical("Error opening framebuffer device %s", qPrintable(dev));
339  return false;
340  }
341  if (access(dev.toLatin1().constData(), R_OK) == 0)
342  d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY);
343  }
344 
345  ::fb_fix_screeninfo finfo;
346  ::fb_var_screeninfo vinfo;
347  //#######################
348  // Shut up Valgrind
349  memset(&vinfo, 0, sizeof(vinfo));
350  memset(&finfo, 0, sizeof(finfo));
351  //#######################
352 
353  /* Get fixed screen information */
354  if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) {
355  perror("QLinuxFbScreen::connect");
356  qWarning("Error reading fixed information");
357  return false;
358  }
359 
360  d_ptr->driverType = strcmp(finfo.id, "8TRACKFB") ? GenericDriver : EInk8Track;
361 
362  if (finfo.type == FB_TYPE_VGA_PLANES) {
363  qWarning("VGA16 video mode not supported");
364  return false;
365  }
366 
367  /* Get variable screen information */
368  if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
369  perror("QLinuxFbScreen::connect");
370  qWarning("Error reading variable information");
371  return false;
372  }
373 
374  fixupScreenInfo(finfo, vinfo);
375 
376  grayscale = vinfo.grayscale;
377  d = vinfo.bits_per_pixel;
378  if (d == 24) {
379  d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
380  if (d <= 0)
381  d = 24; // reset if color component lengths are not reported
382  } else if (d == 16) {
383  d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
384  if (d <= 0)
385  d = 16;
386  }
387  lstep = finfo.line_length;
388 
389  int xoff = vinfo.xoffset;
390  int yoff = vinfo.yoffset;
391  const char* qwssize;
392  if((qwssize=::getenv("QWS_SIZE")) && sscanf(qwssize,"%dx%d",&w,&h)==2) {
393  if (d_ptr->fd != -1) {
394  if ((uint)w > vinfo.xres) w = vinfo.xres;
395  if ((uint)h > vinfo.yres) h = vinfo.yres;
396  }
397  dw=w;
398  dh=h;
399  int xxoff, yyoff;
400  if (sscanf(qwssize, "%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) {
401  if (xxoff < 0 || xxoff + w > (int)vinfo.xres)
402  xxoff = vinfo.xres - w;
403  if (yyoff < 0 || yyoff + h > (int)vinfo.yres)
404  yyoff = vinfo.yres - h;
405  xoff += xxoff;
406  yoff += yyoff;
407  } else {
408  xoff += (vinfo.xres - w)/2;
409  yoff += (vinfo.yres - h)/2;
410  }
411  } else {
412  dw=w=vinfo.xres;
413  dh=h=vinfo.yres;
414  }
415 
416  if (w == 0 || h == 0) {
417  qWarning("QScreenLinuxFb::connect(): Unable to find screen geometry, "
418  "will use 320x240.");
419  dw = w = 320;
420  dh = h = 240;
421  }
422 
423  setPixelFormat(vinfo);
424 
425  // Handle display physical size spec.
426  QStringList displayArgs = displaySpec.split(QLatin1Char(':'));
427  QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)"));
428  int dimIdxW = displayArgs.indexOf(mmWidthRx);
429  QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)"));
430  int dimIdxH = displayArgs.indexOf(mmHeightRx);
431  if (dimIdxW >= 0) {
432  mmWidthRx.exactMatch(displayArgs.at(dimIdxW));
433  physWidth = mmWidthRx.cap(1).toInt();
434  if (dimIdxH < 0)
436  }
437  if (dimIdxH >= 0) {
438  mmHeightRx.exactMatch(displayArgs.at(dimIdxH));
439  physHeight = mmHeightRx.cap(1).toInt();
440  if (dimIdxW < 0)
442  }
443  if (dimIdxW < 0 && dimIdxH < 0) {
444  if (vinfo.width != 0 && vinfo.height != 0
445  && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) {
446  physWidth = vinfo.width;
447  physHeight = vinfo.height;
448  } else {
449  const int dpi = 72;
450  physWidth = qRound(dw * 25.4 / dpi);
451  physHeight = qRound(dh * 25.4 / dpi);
452  }
453  }
454 
455  dataoffset = yoff * lstep + xoff * d / 8;
456  //qDebug("Using %dx%dx%d screen",w,h,d);
457 
458  /* Figure out the size of the screen in bytes */
459  size = h * lstep;
460 
461  mapsize = finfo.smem_len;
462 
463  data = (unsigned char *)-1;
464  if (d_ptr->fd != -1)
465  data = (unsigned char *)mmap(0, mapsize, PROT_READ | PROT_WRITE,
466  MAP_SHARED, d_ptr->fd, 0);
467 
468  if ((long)data == -1) {
470  perror("QLinuxFbScreen::connect");
471  qWarning("Error: failed to map framebuffer device to memory.");
472  return false;
473  }
474  data = 0;
475  } else {
476  data += dataoffset;
477  }
478 
480  if(canaccel)
481  setupOffScreen();
482 
483  // Now read in palette
484  if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
485  screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
486  int loopc;
487  ::fb_cmap startcmap;
488  startcmap.start=0;
489  startcmap.len=screencols;
490  startcmap.red=(unsigned short int *)
491  malloc(sizeof(unsigned short int)*screencols);
492  startcmap.green=(unsigned short int *)
493  malloc(sizeof(unsigned short int)*screencols);
494  startcmap.blue=(unsigned short int *)
495  malloc(sizeof(unsigned short int)*screencols);
496  startcmap.transp=(unsigned short int *)
497  malloc(sizeof(unsigned short int)*screencols);
498  if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) {
499  perror("QLinuxFbScreen::connect");
500  qWarning("Error reading palette from framebuffer, using default palette");
501  createPalette(startcmap, vinfo, finfo);
502  }
503  int bits_used = 0;
504  for(loopc=0;loopc<screencols;loopc++) {
505  screenclut[loopc]=qRgb(startcmap.red[loopc] >> 8,
506  startcmap.green[loopc] >> 8,
507  startcmap.blue[loopc] >> 8);
508  bits_used |= startcmap.red[loopc]
509  | startcmap.green[loopc]
510  | startcmap.blue[loopc];
511  }
512  // WORKAROUND: Some framebuffer drivers only return 8 bit
513  // color values, so we need to not bit shift them..
514  if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) {
515  for(loopc=0;loopc<screencols;loopc++) {
516  screenclut[loopc] = qRgb(startcmap.red[loopc],
517  startcmap.green[loopc],
518  startcmap.blue[loopc]);
519  }
520  qWarning("8 bits cmap returned due to faulty FB driver, colors corrected");
521  }
522  free(startcmap.red);
523  free(startcmap.green);
524  free(startcmap.blue);
525  free(startcmap.transp);
526  } else {
527  screencols=0;
528  }
529 
530  return true;
531 }
QLinuxFbScreen::DriverTypes driverType
int screencols
the number of entries in the color table
Definition: qscreen_qws.h:309
QLinuxFbScreenPrivate * d_ptr
virtual bool useOffscreen()
int d
the pixel depth
Definition: qscreen_qws.h:327
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
#define O_RDONLY
QRgb screenclut[256]
the color table
Definition: qscreen_qws.h:308
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int physHeight
the physical height of the screen in millimeters.
Definition: qscreen_qws.h:340
The QString class provides a Unicode character string.
Definition: qstring.h:83
int size
the number of bytes in the visible region of the frame buffer
Definition: qscreen_qws.h:334
int physWidth
the physical width of the screen in millimeters.
Definition: qscreen_qws.h:339
int indexOf(const QRegExp &rx, int from=0) const
Returns the index position of the first exact match of rx in the list, searching forward from index p...
Definition: qstringlist.h:195
int access(const char *, int)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int w
the logical width of the screen.
Definition: qscreen_qws.h:324
Q_CORE_EXPORT void qWarning(const char *,...)
void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo)
unsigned int uint
Definition: qglobal.h:996
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
virtual void fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo)
Adjust the values returned by the framebuffer driver, to work around driver bugs or nonstandard behav...
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int dw
the device width
Definition: qscreen_qws.h:331
int dh
the device height
Definition: qscreen_qws.h:332
#define QT_OPEN
Definition: qcore_unix_p.h:186
void setFrameBufferLittleEndian(bool littleEndian)
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
if(void) toggleToolbarShown
bool grayscale
the gray scale screen mode flag
Definition: qscreen_qws.h:329
void setPixelFormat(struct fb_var_screeninfo)
int lstep
the number of bytes representing a line in the frame buffer.
Definition: qscreen_qws.h:325
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
int h
the logical height of the screen.
Definition: qscreen_qws.h:326
int mapsize
the total number of bytes in the frame buffer
Definition: qscreen_qws.h:335
#define qPrintable(string)
Definition: qglobal.h:1750
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).
#define O_RDWR
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
Q_CORE_EXPORT void qCritical(const char *,...)

◆ createPalette()

void QLinuxFbScreen::createPalette ( fb_cmap &  cmap,
fb_var_screeninfo &  vinfo,
fb_fix_screeninfo &  finfo 
)
private

Definition at line 554 of file qscreenlinuxfb_qws.cpp.

Referenced by connect(), and initDevice().

555 {
556  if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
557  screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
558  cmap.start=0;
559  cmap.len=screencols;
560  cmap.red=(unsigned short int *)
561  malloc(sizeof(unsigned short int)*screencols);
562  cmap.green=(unsigned short int *)
563  malloc(sizeof(unsigned short int)*screencols);
564  cmap.blue=(unsigned short int *)
565  malloc(sizeof(unsigned short int)*screencols);
566  cmap.transp=(unsigned short int *)
567  malloc(sizeof(unsigned short int)*screencols);
568 
569  if (screencols==16) {
570  if (finfo.type == FB_TYPE_PACKED_PIXELS) {
571  // We'll setup a grayscale cmap for 4bpp linear
572  int val = 0;
573  for (int idx = 0; idx < 16; ++idx, val += 17) {
574  cmap.red[idx] = (val<<8)|val;
575  cmap.green[idx] = (val<<8)|val;
576  cmap.blue[idx] = (val<<8)|val;
577  screenclut[idx]=qRgb(val, val, val);
578  }
579  } else {
580  // Default 16 colour palette
581  // Green is now trolltech green so certain images look nicer
582  // black d_gray l_gray white red green blue cyan magenta yellow
583  unsigned char reds[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0xFF, 0xA2, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x82 };
584  unsigned char greens[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0xC5, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F };
585  unsigned char blues[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0x11, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00 };
586 
587  for (int idx = 0; idx < 16; ++idx) {
588  cmap.red[idx] = ((reds[idx]) << 8)|reds[idx];
589  cmap.green[idx] = ((greens[idx]) << 8)|greens[idx];
590  cmap.blue[idx] = ((blues[idx]) << 8)|blues[idx];
591  cmap.transp[idx] = 0;
592  screenclut[idx]=qRgb(reds[idx], greens[idx], blues[idx]);
593  }
594  }
595  } else {
596  if (grayscale) {
597  // Build grayscale palette
598  int i;
599  for(i=0;i<screencols;++i) {
600  int bval = screencols == 256 ? i : (i << 4);
601  ushort val = (bval << 8) | bval;
602  cmap.red[i] = val;
603  cmap.green[i] = val;
604  cmap.blue[i] = val;
605  cmap.transp[i] = 0;
606  screenclut[i] = qRgb(bval,bval,bval);
607  }
608  } else {
609  // 6x6x6 216 color cube
610  int idx = 0;
611  for(int ir = 0x0; ir <= 0xff; ir+=0x33) {
612  for(int ig = 0x0; ig <= 0xff; ig+=0x33) {
613  for(int ib = 0x0; ib <= 0xff; ib+=0x33) {
614  cmap.red[idx] = (ir << 8)|ir;
615  cmap.green[idx] = (ig << 8)|ig;
616  cmap.blue[idx] = (ib << 8)|ib;
617  cmap.transp[idx] = 0;
618  screenclut[idx]=qRgb(ir, ig, ib);
619  ++idx;
620  }
621  }
622  }
623  // Fill in rest with 0
624  for (int loopc=0; loopc<40; ++loopc) {
625  screenclut[idx]=0;
626  ++idx;
627  }
628  screencols=idx;
629  }
630  }
631  } else if(finfo.visual==FB_VISUAL_DIRECTCOLOR) {
632  cmap.start=0;
633  int rbits=0,gbits=0,bbits=0;
634  switch (vinfo.bits_per_pixel) {
635  case 8:
636  rbits=vinfo.red.length;
637  gbits=vinfo.green.length;
638  bbits=vinfo.blue.length;
639  if(rbits==0 && gbits==0 && bbits==0) {
640  // cyber2000 driver bug hack
641  rbits=3;
642  gbits=3;
643  bbits=2;
644  }
645  break;
646  case 15:
647  rbits=5;
648  gbits=5;
649  bbits=5;
650  break;
651  case 16:
652  rbits=5;
653  gbits=6;
654  bbits=5;
655  break;
656  case 18:
657  case 19:
658  rbits=6;
659  gbits=6;
660  bbits=6;
661  break;
662  case 24: case 32:
663  rbits=gbits=bbits=8;
664  break;
665  }
666  screencols=cmap.len=1<<qMax(rbits,qMax(gbits,bbits));
667  cmap.red=(unsigned short int *)
668  malloc(sizeof(unsigned short int)*256);
669  cmap.green=(unsigned short int *)
670  malloc(sizeof(unsigned short int)*256);
671  cmap.blue=(unsigned short int *)
672  malloc(sizeof(unsigned short int)*256);
673  cmap.transp=(unsigned short int *)
674  malloc(sizeof(unsigned short int)*256);
675  for(unsigned int i = 0x0; i < cmap.len; i++) {
676  cmap.red[i] = i*65535/((1<<rbits)-1);
677  cmap.green[i] = i*65535/((1<<gbits)-1);
678  cmap.blue[i] = i*65535/((1<<bbits)-1);
679  cmap.transp[i] = 0;
680  }
681  }
682 }
int screencols
the number of entries in the color table
Definition: qscreen_qws.h:309
static QColor cmap[256]
Definition: qgl_mac.mm:760
QRgb screenclut[256]
the color table
Definition: qscreen_qws.h:308
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
unsigned short ushort
Definition: qglobal.h:995
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
bool grayscale
the gray scale screen mode flag
Definition: qscreen_qws.h:329
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244

◆ delete_entry()

void QLinuxFbScreen::delete_entry ( int  pos)
private

Definition at line 836 of file qscreenlinuxfb_qws.cpp.

Referenced by clearCache(), and deleteEntry().

837 {
838  if (pos > *entryp || pos < 0) {
839  qWarning("Attempt to delete odd pos! %d %d", pos, *entryp);
840  return;
841  }
842 
843 #ifdef DEBUG_CACHE
844  qDebug("Remove entry: %d", pos);
845 #endif
846 
847  QPoolEntry *qpe = &entries[pos];
848  if (qpe->start <= *lowest) {
849  // Lowest goes up again
850  *lowest = entries[pos-1].start;
851 #ifdef DEBUG_CACHE
852  qDebug(" moved lowest to %d", *lowest);
853 #endif
854  }
855 
856  (*entryp)--;
857  if (pos == *entryp)
858  return;
859 
860  int size = (*entryp)-pos;
861  memmove(&entries[pos], &entries[pos+1], size*sizeof(QPoolEntry));
862 }
int * entryp
Definition: qscreen_qws.h:321
unsigned int * lowest
Definition: qscreen_qws.h:322
unsigned int start
Definition: qscreen_qws.h:179
int size
the number of bytes in the visible region of the frame buffer
Definition: qscreen_qws.h:334
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
QPoolEntry * entries
Definition: qscreen_qws.h:320

◆ deleteEntry()

void QLinuxFbScreen::deleteEntry ( uchar memoryBlock)
protected

Deletes the specified memoryBlock allocated from the graphics card memory.

See also
uncache(), cache(), clearCache()

Definition at line 1010 of file qscreenlinuxfb_qws.cpp.

Referenced by uncache().

1011 {
1012  qt_fbdpy->grab();
1013  unsigned long pos=(unsigned long)c;
1014  pos-=((unsigned long)data);
1015  unsigned int hold=(*entryp);
1016  for(unsigned int loopc=1;loopc<hold;loopc++) {
1017  if (entries[loopc].start==pos) {
1018  if (entries[loopc].clientId == qws_client_id)
1019  delete_entry(loopc);
1020  else
1021  qWarning("Attempt to delete client id %d cache entry",
1022  entries[loopc].clientId);
1023  qt_fbdpy->ungrab();
1024  return;
1025  }
1026  }
1027  qt_fbdpy->ungrab();
1028  qWarning("Attempt to delete unknown offset %ld",pos);
1029 }
unsigned char c[8]
Definition: qnumeric_p.h:62
Q_GUI_EXPORT QWSDisplay * qt_fbdpy
int qws_client_id
Q_CORE_EXPORT void qWarning(const char *,...)
static void grab()
QPoolEntry * entries
Definition: qscreen_qws.h:320
const QString clientId
static void ungrab()

◆ disconnect()

void QLinuxFbScreen::disconnect ( )
virtual

This unmaps the framebuffer.

Reimplemented Function

See also
connect()

Implements QScreen.

Definition at line 544 of file qscreenlinuxfb_qws.cpp.

Referenced by setMode().

545 {
546  data -= dataoffset;
547  if (data)
548  munmap((char*)data,mapsize);
549  close(d_ptr->fd);
550 }
QLinuxFbScreenPrivate * d_ptr
int mapsize
the total number of bytes in the frame buffer
Definition: qscreen_qws.h:335

◆ doRedraw

QRegion QLinuxFbScreen::doRedraw ( )
slot

Definition at line 863 of file qlinuxfbintegration.cpp.

864 {
865  QRegion touched;
866  touched = QFbScreen::doRedraw();
867 
868  if (!compositePainter) {
870  }
871 
872  QVector<QRect> rects = touched.rects();
873  for (int i = 0; i < rects.size(); i++)
874  compositePainter->drawImage(rects[i], *mScreenImage, rects[i]);
875  return touched;
876 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
QImage * mScreenImage
Definition: fb_base.h:197
virtual QRegion doRedraw()
Definition: fb_base.cpp:229
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QPainter * compositePainter
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition: qpainter.cpp:5936
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ fixupScreenInfo()

void QLinuxFbScreen::fixupScreenInfo ( fb_fix_screeninfo &  finfo,
fb_var_screeninfo &  vinfo 
)
protectedvirtual

Adjust the values returned by the framebuffer driver, to work around driver bugs or nonstandard behavior in certain drivers.

finfo and vinfo specify the fixed and variable screen info returned by the driver.

Definition at line 193 of file qscreenlinuxfb_qws.cpp.

Referenced by connect(), initDevice(), and setMode().

194 {
195  // 8Track e-ink devices (as found in Sony PRS-505) lie
196  // about their bit depth -- they claim they're 1 bit per
197  // pixel while the only supported mode is 8 bit per pixel
198  // grayscale.
199  // Caused by this, they also miscalculate their line length.
200  if(!strcmp(finfo.id, "8TRACKFB") && vinfo.bits_per_pixel == 1) {
201  vinfo.bits_per_pixel = 8;
202  finfo.line_length = vinfo.xres;
203  }
204 }

◆ initDevice()

bool QLinuxFbScreen::initDevice ( )
virtual

This is called by the Qt for Embedded Linux server at startup time.

Reimplemented Function

It turns off console blinking, sets up the color palette, enables write combining on the framebuffer and initialises the off-screen memory manager.

Implements QScreen.

Definition at line 696 of file qscreenlinuxfb_qws.cpp.

697 {
698  d_ptr->openTty();
699 
700  // Grab current mode so we can reset it
701  fb_var_screeninfo vinfo;
702  fb_fix_screeninfo finfo;
703  //#######################
704  // Shut up Valgrind
705  memset(&vinfo, 0, sizeof(vinfo));
706  memset(&finfo, 0, sizeof(finfo));
707  //#######################
708 
709  if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
710  perror("QLinuxFbScreen::initDevice");
711  qFatal("Error reading variable information in card init");
712  return false;
713  }
714 
715 #ifdef DEBUG_VINFO
716  qDebug("Greyscale %d",vinfo.grayscale);
717  qDebug("Nonstd %d",vinfo.nonstd);
718  qDebug("Red %d %d %d",vinfo.red.offset,vinfo.red.length,
719  vinfo.red.msb_right);
720  qDebug("Green %d %d %d",vinfo.green.offset,vinfo.green.length,
721  vinfo.green.msb_right);
722  qDebug("Blue %d %d %d",vinfo.blue.offset,vinfo.blue.length,
723  vinfo.blue.msb_right);
724  qDebug("Transparent %d %d %d",vinfo.transp.offset,vinfo.transp.length,
725  vinfo.transp.msb_right);
726 #endif
727 
728  if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) {
729  perror("QLinuxFbScreen::initDevice");
730  qCritical("Error reading fixed information in card init");
731  // It's not an /error/ as such, though definitely a bad sign
732  // so we return true
733  return true;
734  }
735 
736  fixupScreenInfo(finfo, vinfo);
737 
738  d_ptr->startupw=vinfo.xres;
739  d_ptr->startuph=vinfo.yres;
740  d_ptr->startupd=vinfo.bits_per_pixel;
741  grayscale = vinfo.grayscale;
742 
743 #ifdef __i386__
744  // Now init mtrr
745  if(!::getenv("QWS_NOMTRR")) {
746  int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0);
747  // MTRR entry goes away when file is closed - i.e.
748  // hopefully when QWS is killed
749  if(mfd != -1) {
750  mtrr_sentry sentry;
751  sentry.base=(unsigned long int)finfo.smem_start;
752  //qDebug("Physical framebuffer address %p",(void*)finfo.smem_start);
753  // Size needs to be in 4k chunks, but that's not always
754  // what we get thanks to graphics card registers. Write combining
755  // these is Not Good, so we write combine what we can
756  // (which is not much - 4 megs on an 8 meg card, it seems)
757  unsigned int size=finfo.smem_len;
758  size=size >> 22;
759  size=size << 22;
760  sentry.size=size;
761  sentry.type=MTRR_TYPE_WRCOMB;
762  if(ioctl(mfd,MTRRIOC_ADD_ENTRY,&sentry)==-1) {
763  //printf("Couldn't add mtrr entry for %lx %lx, %s\n",
764  //sentry.base,sentry.size,strerror(errno));
765  }
766  }
767 
768  // Should we close mfd here?
769  //QT_CLOSE(mfd);
770  }
771 #endif
772  if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR))
773  {
774  fb_cmap cmap;
775  createPalette(cmap, vinfo, finfo);
776  if (ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap)) {
777  perror("QLinuxFbScreen::initDevice");
778  qWarning("Error writing palette to framebuffer");
779  }
780  free(cmap.red);
781  free(cmap.green);
782  free(cmap.blue);
783  free(cmap.transp);
784  }
785 
786  if (canaccel) {
787  *entryp=0;
788  *lowest = mapsize;
789  insert_entry(*entryp, *lowest, *lowest); // dummy entry to mark start
790  }
791 
792  shared->fifocount = 0;
793  shared->buffer_offset = 0xffffffff; // 0 would be a sensible offset (screen)
794  shared->linestep = 0;
795  shared->cliptop = 0xffffffff;
796  shared->clipleft = 0xffffffff;
797  shared->clipright = 0xffffffff;
798  shared->clipbottom = 0xffffffff;
799  shared->rop = 0xffffffff;
800 
801 #ifdef QT_QWS_DEPTH_GENERIC
803  && d_ptr->doGenericColors)
804  {
805  qt_set_generic_blit(this, vinfo.bits_per_pixel,
806  vinfo.red.length, vinfo.green.length,
807  vinfo.blue.length, vinfo.transp.length,
808  vinfo.red.offset, vinfo.green.offset,
809  vinfo.blue.offset, vinfo.transp.offset);
810  }
811 #endif
812 
813 #ifndef QT_NO_QWS_CURSOR
815 #endif
816  blank(false);
817 
818  return true;
819 }
int screencols
the number of entries in the color table
Definition: qscreen_qws.h:309
QLinuxFbScreenPrivate * d_ptr
int * entryp
Definition: qscreen_qws.h:321
volatile int fifocount
unsigned int * lowest
Definition: qscreen_qws.h:322
static QColor cmap[256]
Definition: qgl_mac.mm:760
volatile unsigned int rop
int size
the number of bytes in the visible region of the frame buffer
Definition: qscreen_qws.h:334
static void initSoftwareCursor()
Initializes the screen cursor.
volatile int clipbottom
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
virtual void blank(bool on)
Reimplemented Function
void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo)
virtual void fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo)
Adjust the values returned by the framebuffer driver, to work around driver bugs or nonstandard behav...
volatile int cliptop
Q_CORE_EXPORT void qFatal(const char *,...)
#define QT_OPEN
Definition: qcore_unix_p.h:186
QImage::Format pixelFormat() const
Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a suppor...
QLinuxFb_Shared * shared
volatile int clipright
volatile int clipleft
bool grayscale
the gray scale screen mode flag
Definition: qscreen_qws.h:329
void insert_entry(int, int, int)
volatile unsigned int buffer_offset
volatile int linestep
int mapsize
the total number of bytes in the frame buffer
Definition: qscreen_qws.h:335
#define O_WRONLY
Q_CORE_EXPORT void qCritical(const char *,...)

◆ insert_entry()

void QLinuxFbScreen::insert_entry ( int  pos,
int  start,
int  end 
)
private

Definition at line 864 of file qscreenlinuxfb_qws.cpp.

Referenced by cache(), and initDevice().

865 {
866  if (pos > *entryp) {
867  qWarning("Attempt to insert odd pos! %d %d",pos,*entryp);
868  return;
869  }
870 
871 #ifdef DEBUG_CACHE
872  qDebug("Insert entry: %d, %d -> %d", pos, start, end);
873 #endif
874 
875  if (start < (int)*lowest) {
876  *lowest = start;
877 #ifdef DEBUG_CACHE
878  qDebug(" moved lowest to %d", *lowest);
879 #endif
880  }
881 
882  if (pos == *entryp) {
883  entries[pos].start = start;
884  entries[pos].end = end;
886  (*entryp)++;
887  return;
888  }
889 
890  int size=(*entryp)-pos;
891  memmove(&entries[pos+1],&entries[pos],size*sizeof(QPoolEntry));
892  entries[pos].start=start;
893  entries[pos].end=end;
895  (*entryp)++;
896 }
int * entryp
Definition: qscreen_qws.h:321
unsigned int * lowest
Definition: qscreen_qws.h:322
unsigned int start
Definition: qscreen_qws.h:179
int size
the number of bytes in the visible region of the frame buffer
Definition: qscreen_qws.h:334
unsigned int end
Definition: qscreen_qws.h:180
int qws_client_id
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
QPoolEntry * entries
Definition: qscreen_qws.h:320
static const KeyPair *const end

◆ restore()

void QLinuxFbScreen::restore ( )
virtual

This is called when the virtual console is switched back to Qt for Embedded Linux and restores the palette.

Reimplemented Function

Reimplemented from QScreen.

Definition at line 1234 of file qscreenlinuxfb_qws.cpp.

1235 {
1236  if (d_ptr->fd == -1)
1237  return;
1238 
1239  if ((d == 8) || (d == 4)) {
1240  fb_cmap cmap;
1241  cmap.start=0;
1242  cmap.len=screencols;
1243  cmap.red=(unsigned short int *)
1244  malloc(sizeof(unsigned short int)*256);
1245  cmap.green=(unsigned short int *)
1246  malloc(sizeof(unsigned short int)*256);
1247  cmap.blue=(unsigned short int *)
1248  malloc(sizeof(unsigned short int)*256);
1249  cmap.transp=(unsigned short int *)
1250  malloc(sizeof(unsigned short int)*256);
1251  for (int loopc = 0; loopc < screencols; loopc++) {
1252  cmap.red[loopc] = qRed(screenclut[loopc]) << 8;
1253  cmap.green[loopc] = qGreen(screenclut[loopc]) << 8;
1254  cmap.blue[loopc] = qBlue(screenclut[loopc]) << 8;
1255  cmap.transp[loopc] = 0;
1256  }
1257  ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap);
1258  free(cmap.red);
1259  free(cmap.green);
1260  free(cmap.blue);
1261  free(cmap.transp);
1262  }
1263 }
int screencols
the number of entries in the color table
Definition: qscreen_qws.h:309
QLinuxFbScreenPrivate * d_ptr
int d
the pixel depth
Definition: qscreen_qws.h:327
static QColor cmap[256]
Definition: qgl_mac.mm:760
QRgb screenclut[256]
the color table
Definition: qscreen_qws.h:308
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60

◆ save()

void QLinuxFbScreen::save ( )
virtual

This doesn't do anything; accelerated drivers may wish to reimplement it to save graphics cards registers.

Reimplemented Function

It's called by the Qt for Embedded Linux server when the virtual console is switched.

Reimplemented from QScreen.

Definition at line 1218 of file qscreenlinuxfb_qws.cpp.

1219 {
1220  // nothing to do.
1221 }

◆ set()

void QLinuxFbScreen::set ( unsigned int  index,
unsigned int  red,
unsigned int  green,
unsigned int  blue 
)
virtual

Sets the specified color index to the specified RGB value, (red, green, blue), when in paletted graphics modes.

Reimplemented from QScreen.

Definition at line 1119 of file qscreenlinuxfb_qws.cpp.

1120 {
1121  if (d_ptr->fd != -1) {
1122  fb_cmap cmap;
1123  cmap.start=i;
1124  cmap.len=1;
1125  cmap.red=(unsigned short int *)
1126  malloc(sizeof(unsigned short int)*256);
1127  cmap.green=(unsigned short int *)
1128  malloc(sizeof(unsigned short int)*256);
1129  cmap.blue=(unsigned short int *)
1130  malloc(sizeof(unsigned short int)*256);
1131  cmap.transp=(unsigned short int *)
1132  malloc(sizeof(unsigned short int)*256);
1133  cmap.red[0]=r << 8;
1134  cmap.green[0]=g << 8;
1135  cmap.blue[0]=b << 8;
1136  cmap.transp[0]=0;
1137  ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap);
1138  free(cmap.red);
1139  free(cmap.green);
1140  free(cmap.blue);
1141  free(cmap.transp);
1142  }
1143  screenclut[i] = qRgb(r, g, b);
1144 }
QLinuxFbScreenPrivate * d_ptr
static QColor cmap[256]
Definition: qgl_mac.mm:760
QRgb screenclut[256]
the color table
Definition: qscreen_qws.h:308
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69

◆ setDirty()

void QLinuxFbScreen::setDirty ( const QRect r)
virtual

Reimplemented Function

Reimplemented from QScreen.

Definition at line 1282 of file qscreenlinuxfb_qws.cpp.

1283 {
1284  if(d_ptr->driverType == EInk8Track) {
1285  // e-Ink displays need a trigger to actually show what is
1286  // in their framebuffer memory. The 8-Track driver does this
1287  // by adding custom IOCTLs - FBIO_EINK_DISP_PIC (0x46a2) takes
1288  // an argument specifying whether or not to flash the screen
1289  // while updating.
1290  // There doesn't seem to be a way to tell it to just update
1291  // a subset of the screen.
1292  if(r.left() == 0 && r.top() == 0 && r.width() == dw && r.height() == dh)
1293  ioctl(d_ptr->fd, 0x46a2, 1);
1294  else
1295  ioctl(d_ptr->fd, 0x46a2, 0);
1296  }
1297 }
QLinuxFbScreen::DriverTypes driverType
QLinuxFbScreenPrivate * d_ptr
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int dw
the device width
Definition: qscreen_qws.h:331
int dh
the device height
Definition: qscreen_qws.h:332
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243

◆ setFormat()

void QLinuxFbScreen::setFormat ( QImage::Format  format)
virtual

Reimplemented from QFbScreen.

Definition at line 849 of file qlinuxfbintegration.cpp.

850 {
851  mFormat = format;
852  delete mFbScreenImage;
855  delete compositePainter;
856  compositePainter = 0;
857 
858  delete mScreenImage;
860  mFormat);
861 }
QImage * mScreenImage
Definition: fb_base.h:197
QImage::Format mFormat
Definition: fb_base.h:195
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QRect mGeometry
Definition: fb_base.h:193
QPainter * compositePainter
virtual QImage::Format format() const
Reimplement in subclass to return the image format which corresponds to the screen format...
Definition: fb_base.h:164

◆ setGeometry()

void QLinuxFbScreen::setGeometry ( QRect  rect)
virtual

Reimplemented from QFbScreen.

Definition at line 835 of file qlinuxfbintegration.cpp.

836 {
837  mGeometry = rect;
838  delete mFbScreenImage;
841  delete compositePainter;
842  compositePainter = 0;
843 
844  delete mScreenImage;
846  mFormat);
847 }
QImage * mScreenImage
Definition: fb_base.h:197
QImage::Format mFormat
Definition: fb_base.h:195
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QRect mGeometry
Definition: fb_base.h:193
QPainter * compositePainter

◆ setMode()

void QLinuxFbScreen::setMode ( int  nw,
int  nh,
int  nd 
)
virtual

Sets the framebuffer to a new resolution and bit depth.

Reimplemented Function

The width is in nw, the height is in nh, and the depth is in nd. After doing this any currently-existing paint engines will be invalid and the screen should be completely redrawn. In a multiple-process Embedded Qt situation you must signal all other applications to call setMode() to the same mode and redraw.

Implements QScreen.

Definition at line 1160 of file qscreenlinuxfb_qws.cpp.

1161 {
1162  if (d_ptr->fd == -1)
1163  return;
1164 
1165  fb_fix_screeninfo finfo;
1166  fb_var_screeninfo vinfo;
1167  //#######################
1168  // Shut up Valgrind
1169  memset(&vinfo, 0, sizeof(vinfo));
1170  memset(&finfo, 0, sizeof(finfo));
1171  //#######################
1172 
1173  if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
1174  perror("QLinuxFbScreen::setMode");
1175  qFatal("Error reading variable information in mode change");
1176  }
1177 
1178  vinfo.xres=nw;
1179  vinfo.yres=nh;
1180  vinfo.bits_per_pixel=nd;
1181 
1182  if (ioctl(d_ptr->fd, FBIOPUT_VSCREENINFO, &vinfo)) {
1183  perror("QLinuxFbScreen::setMode");
1184  qCritical("Error writing variable information in mode change");
1185  }
1186 
1187  if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
1188  perror("QLinuxFbScreen::setMode");
1189  qFatal("Error reading changed variable information in mode change");
1190  }
1191 
1192  if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) {
1193  perror("QLinuxFbScreen::setMode");
1194  qFatal("Error reading fixed information");
1195  }
1196 
1197  fixupScreenInfo(finfo, vinfo);
1198  disconnect();
1200  exposeRegion(region(), 0);
1201 }
QLinuxFbScreenPrivate * d_ptr
virtual QRegion region() const
Returns the region covered by this screen driver.
Definition: qscreen_qws.h:284
virtual void fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo)
Adjust the values returned by the framebuffer driver, to work around driver bugs or nonstandard behav...
virtual bool connect(const QString &displaySpec)
This is called by Qt for Embedded Linux clients to map in the framebuffer.
Q_CORE_EXPORT void qFatal(const char *,...)
virtual void disconnect()
This unmaps the framebuffer.
virtual void exposeRegion(QRegion r, int changing)
This function is called by the Qt for Embedded Linux server whenever a screen update is required...
Q_CORE_EXPORT void qCritical(const char *,...)

◆ setPixelFormat()

void QLinuxFbScreen::setPixelFormat ( struct fb_var_screeninfo  info)
private

Definition at line 1327 of file qscreenlinuxfb_qws.cpp.

Referenced by connect().

1328 {
1329  const fb_bitfield rgba[4] = { info.red, info.green,
1330  info.blue, info.transp };
1331 
1333 
1334  switch (d) {
1335  case 32: {
1336  const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0},
1337  {0, 8, 0}, {24, 8, 0}};
1338  const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0},
1339  {16, 8, 0}, {24, 8, 0}};
1340  if (memcmp(rgba, argb8888, 4 * sizeof(fb_bitfield)) == 0) {
1341  format = QImage::Format_ARGB32;
1342  } else if (memcmp(rgba, argb8888, 3 * sizeof(fb_bitfield)) == 0) {
1343  format = QImage::Format_RGB32;
1344  } else if (memcmp(rgba, abgr8888, 3 * sizeof(fb_bitfield)) == 0) {
1345  format = QImage::Format_RGB32;
1347  }
1348  break;
1349  }
1350  case 24: {
1351  const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0},
1352  {0, 8, 0}, {0, 0, 0}};
1353  const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0},
1354  {16, 8, 0}, {0, 0, 0}};
1355  if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) {
1356  format = QImage::Format_RGB888;
1357  } else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) {
1358  format = QImage::Format_RGB888;
1360  }
1361  break;
1362  }
1363  case 18: {
1364  const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0},
1365  {0, 6, 0}, {0, 0, 0}};
1366  if (memcmp(rgba, rgb666, 3 * sizeof(fb_bitfield)) == 0)
1367  format = QImage::Format_RGB666;
1368  break;
1369  }
1370  case 16: {
1371  const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0},
1372  {0, 5, 0}, {0, 0, 0}};
1373  const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0},
1374  {11, 5, 0}, {0, 0, 0}};
1375  if (memcmp(rgba, rgb565, 3 * sizeof(fb_bitfield)) == 0) {
1376  format = QImage::Format_RGB16;
1377  } else if (memcmp(rgba, bgr565, 3 * sizeof(fb_bitfield)) == 0) {
1378  format = QImage::Format_RGB16;
1380  }
1381  break;
1382  }
1383  case 15: {
1384  const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0},
1385  {0, 5, 0}, {15, 1, 0}};
1386  const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0},
1387  {10, 5, 0}, {15, 1, 0}};
1388  if (memcmp(rgba, rgb1555, 3 * sizeof(fb_bitfield)) == 0) {
1389  format = QImage::Format_RGB555;
1390  } else if (memcmp(rgba, bgr1555, 3 * sizeof(fb_bitfield)) == 0) {
1391  format = QImage::Format_RGB555;
1393  }
1394  break;
1395  }
1396  case 12: {
1397  const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0},
1398  {0, 4, 0}, {0, 0, 0}};
1399  if (memcmp(rgba, rgb444, 3 * sizeof(fb_bitfield)) == 0)
1400  format = QImage::Format_RGB444;
1401  break;
1402  }
1403  case 8:
1404  break;
1405  case 1:
1406  format = QImage::Format_Mono; //###: LSB???
1407  break;
1408  default:
1409  break;
1410  }
1411 
1412  QScreen::setPixelFormat(format);
1413 }
Format
The following image formats are available in Qt.
Definition: qimage.h:91
static mach_timebase_info_data_t info
int d
the pixel depth
Definition: qscreen_qws.h:327
PixelType pixeltype
set to BGRPixel
Definition: qscreen_qws.h:328
void setPixelFormat(QImage::Format format)
Sets the screen&#39;s pixel format to format.

◆ setupOffScreen()

void QLinuxFbScreen::setupOffScreen ( )
private

Definition at line 1056 of file qscreenlinuxfb_qws.cpp.

Referenced by connect().

1057 {
1058  // Figure out position of offscreen memory
1059  // Set up pool entries pointer table and 64-bit align it
1060  int psize = size;
1061 
1062  // hw: this causes the limitation of cursors to 64x64
1063  // the cursor should rather use the normal pixmap mechanism
1064  psize += 4096; // cursor data
1065  psize += 8; // for alignment
1066  psize &= ~0x7; // align
1067 
1068  unsigned long pos = (unsigned long)data;
1069  pos += psize;
1070  entryp = ((int *)pos);
1071  lowest = ((unsigned int *)pos)+1;
1072  pos += (sizeof(int))*4;
1073  entries = (QPoolEntry *)pos;
1074 
1075  // beginning of offscreen memory available for pixmaps.
1076  cacheStart = psize + 4*sizeof(int) + sizeof(QPoolEntry);
1077 }
int * entryp
Definition: qscreen_qws.h:321
unsigned int * lowest
Definition: qscreen_qws.h:322
int size
the number of bytes in the visible region of the frame buffer
Definition: qscreen_qws.h:334
QPoolEntry * entries
Definition: qscreen_qws.h:320

◆ sharedRamSize()

int QLinuxFbScreen::sharedRamSize ( void *  end)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QScreen.

Definition at line 1272 of file qscreenlinuxfb_qws.cpp.

1273 {
1275  shared--;
1276  return sizeof(QLinuxFb_Shared);
1277 }
QLinuxFb_Shared * shared
static const KeyPair *const end

◆ shutdownDevice()

void QLinuxFbScreen::shutdownDevice ( )
virtual

This is called by the Qt for Embedded Linux server when it shuts down, and should be inherited if you need to do any card-specific cleanup.

Reimplemented Function

The default version hides the screen cursor and reenables the blinking cursor and screen blanking.

Reimplemented from QScreen.

Definition at line 1091 of file qscreenlinuxfb_qws.cpp.

1092 {
1093  // Causing crashes. Not needed.
1094  //setMode(startupw,startuph,startupd);
1095 /*
1096  if (startupd == 8) {
1097  ioctl(fd,FBIOPUTCMAP,startcmap);
1098  free(startcmap->red);
1099  free(startcmap->green);
1100  free(startcmap->blue);
1101  free(startcmap->transp);
1102  delete startcmap;
1103  startcmap = 0;
1104  }
1105 */
1106  d_ptr->closeTty();
1107 }
QLinuxFbScreenPrivate * d_ptr

◆ uncache()

void QLinuxFbScreen::uncache ( uchar memoryBlock)
virtual

Deletes the specified memoryBlock allocated from the graphics card memory.

Note that the display is locked while memory is unallocated in order to preserve the memory pool's integrity.

This function will first sync the graphics card to ensure the memory isn't still being used by a command in the graphics card FIFO queue. It is possible to speed up a driver by overriding this function to avoid syncing. For example, the driver might delay deleting the memory until it detects that all commands dealing with the memory are no longer in the queue. Note that it will then be up to the driver to ensure that the specified memoryBlock no longer is being used.

See also
cache(), deleteEntry(), clearCache()

Reimplemented from QScreen.

Definition at line 995 of file qscreenlinuxfb_qws.cpp.

996 {
997  // need to sync graphics card
998 
999  deleteEntry(c);
1000 }
unsigned char c[8]
Definition: qnumeric_p.h:62
void deleteEntry(uchar *)
Deletes the specified memoryBlock allocated from the graphics card memory.

◆ useOffscreen()

bool QLinuxFbScreen::useOffscreen ( )
virtual
Warning
This function is not part of the public interface.

Definition at line 1415 of file qscreenlinuxfb_qws.cpp.

Referenced by connect().

1416 {
1417  // Not done for 8Track because on e-Ink displays,
1418  // everything is offscreen anyway
1419  if (d_ptr->driverType == EInk8Track || ((mapsize - size) < 16*1024))
1420  return false;
1421 
1422  return true;
1423 }
QLinuxFbScreen::DriverTypes driverType
QLinuxFbScreenPrivate * d_ptr
int size
the number of bytes in the visible region of the frame buffer
Definition: qscreen_qws.h:334
int mapsize
the total number of bytes in the frame buffer
Definition: qscreen_qws.h:335

Properties

◆ bytesPerLine

int QLinuxFbScreen::bytesPerLine
private

Definition at line 64 of file qlinuxfbintegration.h.

Referenced by QLinuxFbScreen(), setFormat(), and setGeometry().

◆ cacheStart

int QLinuxFbScreen::cacheStart
protected

Definition at line 113 of file qscreenlinuxfb_qws.h.

Referenced by cache(), and setupOffScreen().

◆ canaccel

bool QLinuxFbScreen::canaccel
protected

Definition at line 111 of file qscreenlinuxfb_qws.h.

Referenced by cache(), clearCache(), connect(), initDevice(), and QLinuxFbScreen().

◆ compositePainter

QPainter* QLinuxFbScreen::compositePainter
private

Definition at line 66 of file qlinuxfbintegration.h.

Referenced by doRedraw(), setFormat(), and setGeometry().

◆ d_ptr

QLinuxFbScreenPrivate* QLinuxFbScreen::d_ptr
private

◆ data

uchar* QLinuxFbScreen::data
private

◆ dataoffset

int QLinuxFbScreen::dataoffset
protected

Definition at line 112 of file qscreenlinuxfb_qws.h.

Referenced by connect(), and disconnect().

◆ mFbScreenImage

QImage* QLinuxFbScreen::mFbScreenImage
private

Definition at line 62 of file qlinuxfbintegration.h.

Referenced by doRedraw(), QLinuxFbScreen(), setFormat(), and setGeometry().

◆ shared

QLinuxFb_Shared* QLinuxFbScreen::shared

Definition at line 105 of file qscreenlinuxfb_qws.h.

Referenced by initDevice(), and sharedRamSize().


The documentation for this class was generated from the following files: