Qt 4.8
qscreenlinuxfb_qws.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qscreenlinuxfb_qws.h"
43 
44 #ifndef QT_NO_QWS_LINUXFB
45 //#include "qmemorymanager_qws.h"
46 #include "qwsdisplay_qws.h"
47 #include "qpixmap.h"
48 #include <private/qwssignalhandler_p.h>
49 #include <private/qcore_unix_p.h> // overrides QT_OPEN
50 
51 #include <unistd.h>
52 #include <stdlib.h>
53 #include <sys/ioctl.h>
54 #include <sys/types.h>
55 #include <sys/stat.h>
56 #include <sys/mman.h>
57 #include <sys/kd.h>
58 #include <fcntl.h>
59 #include <errno.h>
60 #include <stdio.h>
61 #include <limits.h>
62 #include <signal.h>
63 
64 #include "qwindowsystem_qws.h"
65 
66 #if !defined(Q_OS_DARWIN) && !defined(Q_OS_FREEBSD)
67 #include <linux/fb.h>
68 
69 #ifdef __i386__
70 #include <asm/mtrr.h>
71 #endif
72 #endif
73 
75 
76 extern int qws_client_id;
77 
78 //#define DEBUG_CACHE
79 
81 {
82 public:
85 
86  void openTty();
87  void closeTty();
88 
89  int fd;
90  int startupw;
91  int startuph;
92  int startupd;
93  bool blank;
95 
97 #ifdef QT_QWS_DEPTH_GENERIC
98  bool doGenericColors;
99 #endif
100  int ttyfd;
101  long oldKdMode;
104 };
105 
107  : fd(-1), blank(true), doGraphicsMode(true),
108 #ifdef QT_QWS_DEPTH_GENERIC
109  doGenericColors(false),
110 #endif
111  ttyfd(-1), oldKdMode(KD_TEXT)
112 {
113 #ifndef QT_NO_QWS_SIGNALHANDLER
115 #endif
116 }
117 
119 {
120  closeTty();
121 }
122 
124 {
125  const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0};
126 
127  if (ttyDevice.isEmpty()) {
128  for (const char * const *dev = devs; *dev; ++dev) {
129  ttyfd = QT_OPEN(*dev, O_RDWR);
130  if (ttyfd != -1)
131  break;
132  }
133  } else {
135  }
136 
137  if (ttyfd == -1)
138  return;
139 
140  if (doGraphicsMode) {
141  ioctl(ttyfd, KDGETMODE, &oldKdMode);
142  if (oldKdMode != KD_GRAPHICS) {
143  int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS);
144  if (ret == -1)
145  doGraphicsMode = false;
146  }
147  }
148 
149  // No blankin' screen, no blinkin' cursor!, no cursor!
150  const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c";
151  QT_WRITE(ttyfd, termctl, sizeof(termctl));
152 }
153 
155 {
156  if (ttyfd == -1)
157  return;
158 
159  if (doGraphicsMode)
160  ioctl(ttyfd, KDSETMODE, oldKdMode);
161 
162  // Blankin' screen, blinkin' cursor!
163  const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c";
164  QT_WRITE(ttyfd, termctl, sizeof(termctl));
165 
166  QT_CLOSE(ttyfd);
167  ttyfd = -1;
168 }
169 
193 void QLinuxFbScreen::fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo)
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 }
205 
251 // Unaccelerated screen/driver setup. Can be overridden by accelerated
252 // drivers
253 
265  : QScreen(display_id, LinuxFBClass), d_ptr(new QLinuxFbScreenPrivate)
266 {
267  canaccel=false;
269 #ifdef QT_QWS_CLIENTBLIT
270  setSupportsBlitInClients(true);
271 #endif
272 }
273 
279 {
280 #ifdef QT_NO_QWS_SIGNALHANDLER
281  delete d_ptr;
282 #endif
283 }
284 
300 bool QLinuxFbScreen::connect(const QString &displaySpec)
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 }
532 
545 {
546  data -= dataoffset;
547  if (data)
548  munmap((char*)data,mapsize);
549  close(d_ptr->fd);
550 }
551 
552 // #define DEBUG_VINFO
553 
554 void QLinuxFbScreen::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo)
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 }
683 
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 }
820 
821 /*
822  The offscreen memory manager's list of entries is stored at the bottom
823  of the offscreen memory area and consistes of a series of QPoolEntry's,
824  each of which keep track of a block of allocated memory. Unallocated memory
825  is implicitly indicated by the gap between blocks indicated by QPoolEntry's.
826  The memory manager looks through any unallocated memory before the end
827  of currently-allocated memory to see if a new block will fit in the gap;
828  if it doesn't it allocated it from the end of currently-allocated memory.
829  Memory is allocated from the top of the framebuffer downwards; if it hits
830  the list of entries then offscreen memory is full and further allocations
831  are made from main RAM (and hence unaccelerated). Allocated memory can
832  be seen as a sort of upside-down stack; lowest keeps track of the
833  bottom of the stack.
834 */
835 
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 }
863 
864 void QLinuxFbScreen::insert_entry(int pos, int start, int end)
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 }
897 
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 }
974 
996 {
997  // need to sync graphics card
998 
999  deleteEntry(c);
1000 }
1001 
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 }
1030 
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 }
1054 
1055 
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 }
1078 
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 }
1108 
1119 void QLinuxFbScreen::set(unsigned int i,unsigned int r,unsigned int g,unsigned int b)
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 }
1145 
1160 void QLinuxFbScreen::setMode(int nw,int nh,int nd)
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 }
1202 
1203 // save the state of the graphics card
1204 // This is needed so that e.g. we can restore the palette when switching
1205 // between linux virtual consoles.
1206 
1219 {
1220  // nothing to do.
1221 }
1222 
1223 
1224 // restore the state of the graphics card.
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 }
1264 
1270 // This works like the QScreenCursor code. end points to the end
1271 // of our shared structure, we return the amount of memory we reserved
1273 {
1274  shared=(QLinuxFb_Shared *)end;
1275  shared--;
1276  return sizeof(QLinuxFb_Shared);
1277 }
1278 
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 }
1298 
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 }
1326 
1327 void QLinuxFbScreen::setPixelFormat(struct fb_var_screeninfo info)
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 }
1414 
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 }
1424 
1426 
1427 #endif // QT_NO_QWS_LINUXFB
QLinuxFbScreen::DriverTypes driverType
int screencols
the number of entries in the color table
Definition: qscreen_qws.h:309
QLinuxFbScreenPrivate * d_ptr
Format
The following image formats are available in Qt.
Definition: qimage.h:91
virtual bool useOffscreen()
int * entryp
Definition: qscreen_qws.h:321
static mach_timebase_info_data_t info
unsigned char c[8]
Definition: qnumeric_p.h:62
QString cap(int nth=0) const
Returns the text captured by the nth subexpression.
Definition: qregexp.cpp:4310
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual void setDirty(const QRect &)
Reimplemented Function
int d
the pixel depth
Definition: qscreen_qws.h:327
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
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 ...
Definition: qstring.cpp:6090
volatile int fifocount
unsigned int * lowest
Definition: qscreen_qws.h:322
Q_GUI_EXPORT QWSDisplay * qt_fbdpy
DriverTypes
This enum describes the driver type.
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
#define O_RDONLY
static QColor cmap[256]
Definition: qgl_mac.mm:760
QRgb screenclut[256]
the color table
Definition: qscreen_qws.h:308
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
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
unsigned int start
Definition: qscreen_qws.h:179
virtual void setMode(int, int, int)
Sets the framebuffer to a new resolution and bit depth.
volatile unsigned int rop
static ClearCacheFunc clearCacheFunc
Definition: qscreen_qws.h:344
int physHeight
the physical height of the screen in millimeters.
Definition: qscreen_qws.h:340
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
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
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static void initSoftwareCursor()
Initializes the screen cursor.
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
virtual ~QLinuxFbScreen()
Destroys this QLinuxFbScreen object.
PixelType pixeltype
set to BGRPixel
Definition: qscreen_qws.h:328
int physWidth
the physical width of the screen in millimeters.
Definition: qscreen_qws.h:339
virtual void save()
This doesn&#39;t do anything; accelerated drivers may wish to reimplement it to save graphics cards regis...
void addObject(QObject *object)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int qws_client_id
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
volatile int clipbottom
void setPixelFormat(QImage::Format format)
Sets the screen&#39;s pixel format to format.
static QWSSignalHandler * instance()
Q_CORE_EXPORT void qDebug(const char *,...)
virtual QRegion region() const
Returns the region covered by this screen driver.
Definition: qscreen_qws.h:284
unsigned char uchar
Definition: qglobal.h:994
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
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int access(const char *, int)
virtual void uncache(uchar *)
Deletes the specified memoryBlock allocated from the graphics card memory.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
virtual uchar * cache(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).
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 *,...)
virtual void blank(bool on)
Reimplemented Function
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
static QScreen * instance()
Returns a pointer to the application&#39;s QScreen instance.
Definition: qscreen_qws.h:201
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...
static void grab()
virtual void restore()
This is called when the virtual console is switched back to Qt for Embedded Linux and restores the pa...
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
virtual bool connect(const QString &displaySpec)
This is called by Qt for Embedded Linux clients to map in the framebuffer.
volatile int cliptop
int dw
the device width
Definition: qscreen_qws.h:331
Q_CORE_EXPORT void qFatal(const char *,...)
QPoolEntry * entries
Definition: qscreen_qws.h:320
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
#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...
QLinuxFbScreen(int display_id)
Constructs a QLinuxFbScreen object.
QLinuxFb_Shared * shared
unsigned short ushort
Definition: qglobal.h:995
const QString clientId
void deleteEntry(uchar *)
Deletes the specified memoryBlock allocated from the graphics card memory.
virtual bool initDevice()
This is called by the Qt for Embedded Linux server at startup time.
static void clearCache(QScreen *instance, int)
Removes all entries from the cache for the specified screen instance and client identified by the giv...
void setFrameBufferLittleEndian(bool littleEndian)
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
virtual void disconnect()
This unmaps the framebuffer.
volatile int clipright
volatile int clipleft
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool grayscale
the gray scale screen mode flag
Definition: qscreen_qws.h:329
void setPixelFormat(struct fb_var_screeninfo)
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60
bool exactMatch(const QString &str) const
Returns true if str is matched exactly by this regular expression; otherwise returns false...
Definition: qregexp.cpp:4094
QScopedPointer< QObjectData > d_ptr
Definition: qobject.h:320
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
static void ungrab()
void insert_entry(int, int, int)
virtual void exposeRegion(QRegion r, int changing)
This function is called by the Qt for Embedded Linux server whenever a screen update is required...
volatile unsigned int buffer_offset
static const KeyPair *const end
volatile int linestep
int mapsize
the total number of bytes in the frame buffer
Definition: qscreen_qws.h:335
#define QT_WRITE
Definition: qcore_unix_p.h:289
The QLinuxFbScreen class implements a screen driver for the Linux framebuffer.
#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
#define O_WRONLY
virtual int sharedRamSize(void *)
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
virtual void shutdownDevice()
This is called by the Qt for Embedded Linux server when it shuts down, and should be inherited if you...
Q_CORE_EXPORT void qCritical(const char *,...)
#define QT_CLOSE
Definition: qcore_unix_p.h:304
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 graph...