43 #include "../fb_base/fb_base.h" 45 #include <QtGui/private/qpixmap_raster_p.h> 46 #include <private/qcore_unix_p.h> 52 #include <sys/ioctl.h> 53 #include <sys/types.h> 63 #if !defined(Q_OS_DARWIN) && !defined(Q_OS_FREEBSD) 89 #ifdef QT_QWS_DEPTH_GENERIC 100 #ifdef QT_QWS_DEPTH_GENERIC
101 doGenericColors(false),
114 const char *
const devs[] = {
"/dev/tty0",
"/dev/tty",
"/dev/console", 0};
117 for (
const char *
const *dev = devs; *dev; ++dev) {
132 int ret = ioctl(
ttyfd, KDSETMODE, KD_GRAPHICS);
139 const char termctl[] =
"\033[9;0]\033[?33l\033[?25l\033[?1c";
152 const char termctl[] =
"\033[9;15]\033[?33h\033[?25h\033[?0c";
168 qFatal(
"QLinuxFbIntegration: could not initialize screen");
192 #ifdef QT_QWS_DEPTH_GENERIC
194 d_ptr->doGenericColors =
true;
198 if (args.
indexOf(ttyRegExp) != -1)
202 #if Q_BYTE_ORDER == Q_BIG_ENDIAN 203 #ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN 216 dev = displaySpec.
mid(m, len);
231 fb_fix_screeninfo finfo;
232 fb_var_screeninfo vinfo;
235 memset(&vinfo, 0,
sizeof(vinfo));
236 memset(&finfo, 0,
sizeof(finfo));
240 if (
d_ptr->
fd != -1 && ioctl(
d_ptr->
fd, FBIOGET_FSCREENINFO, &finfo)) {
241 perror(
"QLinuxFbIntegration::connect");
242 qWarning(
"Error reading fixed information");
246 if (finfo.type == FB_TYPE_VGA_PLANES) {
247 qWarning(
"VGA16 video mode not supported");
252 if (
d_ptr->
fd != -1 && ioctl(
d_ptr->
fd, FBIOGET_VSCREENINFO, &vinfo)) {
253 perror(
"QLinuxFbIntegration::connect");
254 qWarning(
"Error reading variable information");
259 d = vinfo.bits_per_pixel;
261 d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
264 }
else if (
d == 16) {
265 d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
269 lstep = finfo.line_length;
271 int xoff = vinfo.xoffset;
272 int yoff = vinfo.yoffset;
274 if((qwssize=::getenv(
"QWS_SIZE")) && sscanf(qwssize,
"%dx%d",&
w,&
h)==2) {
276 if ((
uint)
w > vinfo.xres)
w = vinfo.xres;
277 if ((
uint)
h > vinfo.yres)
h = vinfo.yres;
282 if (sscanf(qwssize,
"%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) {
283 if (xxoff < 0 || xxoff + w > (
int)(vinfo.xres))
284 xxoff = vinfo.xres -
w;
285 if (yyoff < 0 || yyoff + h > (
int)(vinfo.yres))
286 yyoff = vinfo.yres -
h;
290 xoff += (vinfo.xres -
w)/2;
291 yoff += (vinfo.yres -
h)/2;
298 if (
w == 0 ||
h == 0) {
299 qWarning(
"QLinuxFbIntegration::connect(): Unable to find screen geometry, " 300 "will use 320x240.");
310 int dimIdxW = displayArgs.
indexOf(mmWidthRx);
312 int dimIdxH = displayArgs.
indexOf(mmHeightRx);
325 if (dimIdxW < 0 && dimIdxH < 0) {
326 if (vinfo.width != 0 && vinfo.height != 0
327 && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) {
345 data = (
unsigned char *)-1;
347 data = (
unsigned char *)mmap(0,
mapsize, PROT_READ | PROT_WRITE,
350 if ((
long)
data == -1) {
351 perror(
"QLinuxFbIntegration::connect");
352 qWarning(
"Error: failed to map framebuffer device to memory.");
366 if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
367 screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
372 startcmap.red=(
unsigned short int *)
373 malloc(
sizeof(
unsigned short int)*
screencols);
374 startcmap.green=(
unsigned short int *)
375 malloc(
sizeof(
unsigned short int)*
screencols);
376 startcmap.blue=(
unsigned short int *)
377 malloc(
sizeof(
unsigned short int)*
screencols);
378 startcmap.transp=(
unsigned short int *)
379 malloc(
sizeof(
unsigned short int)*
screencols);
380 if (
d_ptr->
fd == -1 || ioctl(
d_ptr->
fd, FBIOGETCMAP, &startcmap)) {
381 perror(
"QLinuxFbIntegration::connect");
382 qWarning(
"Error reading palette from framebuffer, using default palette");
388 startcmap.green[loopc] >> 8,
389 startcmap.blue[loopc] >> 8);
390 bits_used |= startcmap.red[loopc]
391 | startcmap.green[loopc]
392 | startcmap.blue[loopc];
396 if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) {
399 startcmap.green[loopc],
400 startcmap.blue[loopc]);
402 qWarning(
"8 bits cmap returned due to faulty FB driver, colors corrected");
405 free(startcmap.green);
406 free(startcmap.blue);
407 free(startcmap.transp);
420 fb_var_screeninfo vinfo;
421 fb_fix_screeninfo finfo;
424 memset(&vinfo, 0,
sizeof(vinfo));
425 memset(&finfo, 0,
sizeof(finfo));
428 if (ioctl(
d_ptr->
fd, FBIOGET_VSCREENINFO, &vinfo)) {
429 perror(
"QLinuxFbScreen::initDevice");
430 qFatal(
"Error reading variable information in card init");
435 qDebug(
"Greyscale %d",vinfo.grayscale);
436 qDebug(
"Nonstd %d",vinfo.nonstd);
437 qDebug(
"Red %d %d %d",vinfo.red.offset,vinfo.red.length,
438 vinfo.red.msb_right);
439 qDebug(
"Green %d %d %d",vinfo.green.offset,vinfo.green.length,
440 vinfo.green.msb_right);
441 qDebug(
"Blue %d %d %d",vinfo.blue.offset,vinfo.blue.length,
442 vinfo.blue.msb_right);
443 qDebug(
"Transparent %d %d %d",vinfo.transp.offset,vinfo.transp.length,
444 vinfo.transp.msb_right);
452 if (ioctl(
d_ptr->
fd, FBIOGET_FSCREENINFO, &finfo)) {
453 perror(
"QLinuxFbScreen::initDevice");
454 qCritical(
"Error reading fixed information in card init");
462 if(!::getenv(
"QWS_NOMTRR")) {
468 sentry.base=(
unsigned long int)finfo.smem_start;
474 unsigned int size=finfo.smem_len;
478 sentry.type=MTRR_TYPE_WRCOMB;
479 if(ioctl(mfd,MTRRIOC_ADD_ENTRY,&sentry)==-1) {
489 if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR))
493 if (ioctl(
d_ptr->
fd, FBIOPUTCMAP, &cmap)) {
494 perror(
"QLinuxFbScreen::initDevice");
495 qWarning(
"Error writing palette to framebuffer");
507 insert_entry(*entryp, *lowest, *lowest);
510 shared->fifocount = 0;
511 shared->buffer_offset = 0xffffffff;
512 shared->linestep = 0;
513 shared->cliptop = 0xffffffff;
514 shared->clipleft = 0xffffffff;
515 shared->clipright = 0xffffffff;
516 shared->clipbottom = 0xffffffff;
517 shared->rop = 0xffffffff;
520 #ifdef QT_QWS_DEPTH_GENERIC 522 &&
d_ptr->doGenericColors)
524 qt_set_generic_blit(
this, vinfo.bits_per_pixel,
525 vinfo.red.length, vinfo.green.length,
526 vinfo.blue.length, vinfo.transp.length,
527 vinfo.red.offset, vinfo.green.offset,
528 vinfo.blue.offset, vinfo.transp.offset);
533 #ifndef QT_NO_QWS_CURSOR 544 const fb_bitfield rgba[4] = { info.red, info.green,
545 info.blue, info.transp };
551 const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0},
552 {0, 8, 0}, {24, 8, 0}};
553 const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0},
554 {16, 8, 0}, {24, 8, 0}};
555 if (memcmp(rgba, argb8888, 4 *
sizeof(fb_bitfield)) == 0) {
557 }
else if (memcmp(rgba, argb8888, 3 *
sizeof(fb_bitfield)) == 0) {
559 }
else if (memcmp(rgba, abgr8888, 3 *
sizeof(fb_bitfield)) == 0) {
566 const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0},
567 {0, 8, 0}, {0, 0, 0}};
568 const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0},
569 {16, 8, 0}, {0, 0, 0}};
570 if (memcmp(rgba, rgb888, 3 *
sizeof(fb_bitfield)) == 0) {
572 }
else if (memcmp(rgba, bgr888, 3 *
sizeof(fb_bitfield)) == 0) {
579 const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0},
580 {0, 6, 0}, {0, 0, 0}};
581 if (memcmp(rgba, rgb666, 3 *
sizeof(fb_bitfield)) == 0)
586 const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0},
587 {0, 5, 0}, {0, 0, 0}};
588 const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0},
589 {11, 5, 0}, {0, 0, 0}};
590 if (memcmp(rgba, rgb565, 3 *
sizeof(fb_bitfield)) == 0) {
592 }
else if (memcmp(rgba, bgr565, 3 *
sizeof(fb_bitfield)) == 0) {
599 const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0},
600 {0, 5, 0}, {15, 1, 0}};
601 const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0},
602 {10, 5, 0}, {15, 1, 0}};
603 if (memcmp(rgba, rgb1555, 3 *
sizeof(fb_bitfield)) == 0) {
605 }
else if (memcmp(rgba, bgr1555, 3 *
sizeof(fb_bitfield)) == 0) {
612 const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0},
613 {0, 4, 0}, {0, 0, 0}};
614 if (memcmp(rgba, rgb444, 3 *
sizeof(fb_bitfield)) == 0)
632 if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
633 screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
636 cmap.red=(
unsigned short int *)
637 malloc(
sizeof(
unsigned short int)*
screencols);
638 cmap.green=(
unsigned short int *)
639 malloc(
sizeof(
unsigned short int)*
screencols);
640 cmap.blue=(
unsigned short int *)
641 malloc(
sizeof(
unsigned short int)*
screencols);
642 cmap.transp=(
unsigned short int *)
643 malloc(
sizeof(
unsigned short int)*
screencols);
646 if (finfo.type == FB_TYPE_PACKED_PIXELS) {
649 for (
int idx = 0; idx < 16; ++idx, val += 17) {
650 cmap.red[idx] = (val<<8)|val;
651 cmap.green[idx] = (val<<8)|val;
652 cmap.blue[idx] = (val<<8)|val;
659 unsigned char reds[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0xFF, 0xA2, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x82 };
660 unsigned char greens[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0xC5, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F };
661 unsigned char blues[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0x11, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00 };
663 for (
int idx = 0; idx < 16; ++idx) {
664 cmap.red[idx] = ((reds[idx]) << 8)|reds[idx];
665 cmap.green[idx] = ((greens[idx]) << 8)|greens[idx];
666 cmap.blue[idx] = ((blues[idx]) << 8)|blues[idx];
667 cmap.transp[idx] = 0;
676 int bval = screencols == 256 ? i : (i << 4);
677 ushort val = (bval << 8) | bval;
687 for(
int ir = 0x0; ir <= 0xff; ir+=0x33) {
688 for(
int ig = 0x0; ig <= 0xff; ig+=0x33) {
689 for(
int ib = 0x0; ib <= 0xff; ib+=0x33) {
690 cmap.red[idx] = (ir << 8)|ir;
691 cmap.green[idx] = (ig << 8)|ig;
692 cmap.blue[idx] = (ib << 8)|ib;
693 cmap.transp[idx] = 0;
700 for (
int loopc=0; loopc<40; ++loopc) {
707 }
else if(finfo.visual==FB_VISUAL_DIRECTCOLOR) {
709 int rbits=0,gbits=0,bbits=0;
710 switch (vinfo.bits_per_pixel) {
712 rbits=vinfo.red.length;
713 gbits=vinfo.green.length;
714 bbits=vinfo.blue.length;
715 if(rbits==0 && gbits==0 && bbits==0) {
743 cmap.red=(
unsigned short int *)
744 malloc(
sizeof(
unsigned short int)*256);
745 cmap.green=(
unsigned short int *)
746 malloc(
sizeof(
unsigned short int)*256);
747 cmap.blue=(
unsigned short int *)
748 malloc(
sizeof(
unsigned short int)*256);
749 cmap.transp=(
unsigned short int *)
750 malloc(
sizeof(
unsigned short int)*256);
751 for(
unsigned int i = 0x0; i < cmap.len; i++) {
752 cmap.red[i] = i*65535/((1<<rbits)-1);
753 cmap.green[i] = i*65535/((1<<gbits)-1);
754 cmap.blue[i] = i*65535/((1<<bbits)-1);
765 #if defined(QT_QWS_IPAQ) 767 system(
"apm -suspend");
773 #if defined(FBIOBLANK) 774 #if defined(VESA_POWERDOWN) && defined(VESA_NO_BLANKING) 775 ioctl(
d_ptr->
fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING);
777 ioctl(
d_ptr->
fd, FBIOBLANK, on ? 1 : 0);
842 compositePainter = 0;
856 compositePainter = 0;
873 for (
int i = 0; i < rects.
size(); i++)
The QPainter class performs low-level painting on widgets and other paint devices.
Format
The following image formats are available in Qt.
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
QLinuxFbIntegrationPrivate * d_ptr
static mach_timebase_info_data_t info
QString cap(int nth=0) const
Returns the text captured by the nth subexpression.
#define QT_END_NAMESPACE
This macro expands to.
virtual QRegion doRedraw()
QPointer< QWidget > widget
The QRegExp class provides pattern matching using regular expressions.
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
bool hasCapability(QPlatformIntegration::Capability cap) const
QList< QPlatformScreen * > mScreens
QPlatformWindow * createPlatformWindow(QWidget *widget, WId WinId) const
Factory function for QPlatformWindow.
int width() const
Returns the width of the rectangle.
bool connect(const QString &displaySpec)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int height() const
Returns the height of the rectangle.
The QString class provides a Unicode character string.
QImage::Format screenFormat
static void initSoftwareCursor()
Initializes the screen cursor.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Q_CORE_EXPORT void qDebug(const char *,...)
void append(const T &t)
Inserts value at the end of the list.
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...
#define QT_BEGIN_NAMESPACE
This macro expands to.
QPlatformFontDatabase * fontDb
virtual void addWindow(QFbWindow *surface)
QPlatformFontDatabase * fontDatabase() const
Accessor for the platform integrations fontdatabase.
int access(const char *, int)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
~QLinuxFbIntegrationPrivate()
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
void setPixelFormat(struct fb_var_screeninfo)
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
The QRegion class specifies a clip region for a painter.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
QWindowSurface * createWindowSurface(QWidget *widget, WId WinId) const
Factory function for QWindowSurface.
QLinuxFbIntegrationPrivate()
The QWindowSurface class provides the drawing area for top-level windows.
QPlatformSoftwareCursor * cursor
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Q_CORE_EXPORT void qFatal(const char *,...)
void setFormat(QImage::Format format)
QLinuxFbScreen(int display_id)
Constructs a QLinuxFbScreen object.
QPainter * compositePainter
void setFrameBufferLittleEndian(bool littleEndian)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
virtual QImage::Format format() const
Reimplement in subclass to return the image format which corresponds to the screen format...
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
virtual void setPhysicalSize(QSize size)
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
bool exactMatch(const QString &str) const
Returns true if str is matched exactly by this regular expression; otherwise returns false...
int lstep
the number of bytes representing a line in the frame buffer.
The QSize class defines the size of a two-dimensional object using integer point precision.
QPixmapData * createPixmapData(QPixmapData::PixelType type) const
Factory function for QPixmapData.
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...
QLinuxFbScreen * mPrimaryScreen
void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo)
The QLinuxFbScreen class implements a screen driver for the Linux framebuffer.
#define qPrintable(string)
int size() const
Returns the number of items in the vector.
void setGeometry(QRect rect)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Q_DECL_CONSTEXPR int qRound(qreal d)
Q_CORE_EXPORT void qCritical(const char *,...)