Qt 4.8
qscreenintegrityfb_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 #ifndef QT_NO_QWS_INTEGRITYFB
43 
44 #include <qscreenintegrityfb_qws.h>
45 #include <qwindowsystem_qws.h>
46 #include <qsocketnotifier.h>
47 #include <qapplication.h>
48 #include <qscreen_qws.h>
49 #include "qmouseintegrity_qws.h"
50 #include "qkbdintegrity_qws.h"
52 #include <qkbddriverfactory_qws.h>
53 #include <qdebug.h>
54 
55 #include <INTEGRITY.h>
56 #include <device/fbdriver.h>
57 
59 
61 {
62 public:
65 
66  FBHandle handle;
67  FBInfo fbinfo;
68  FBDriver *fbdrv;
69 
71 #ifndef QT_NO_QWS_KEYBOARD
73 #endif
74 };
75 
77  : mouse(0)
78 
79 {
80 #ifndef QT_NO_QWS_KEYBOARD
81  keyboard = 0;
82 #endif
83 }
84 
86 {
87  delete mouse;
88 #ifndef QT_NO_QWS_KEYBOARD
89  delete keyboard;
90 #endif
91 }
92 
164  : QScreen(display_id, IntfbClass), d_ptr(new QIntfbScreenPrivate)
165 {
166  d_ptr->handle = 0;
167  data = 0;
168 }
169 
174 {
175  delete d_ptr;
176 }
177 
179 
180 bool QIntfbScreen::connect(const QString &displaySpec)
181 {
182  CheckSuccess(gh_FB_get_driver(0, &d_ptr->fbdrv));
183  CheckSuccess(gh_FB_check_info(d_ptr->fbdrv, &d_ptr->fbinfo));
184  CheckSuccess(gh_FB_open(d_ptr->fbdrv, &d_ptr->fbinfo, &d_ptr->handle));
185  CheckSuccess(gh_FB_get_info(d_ptr->handle, &d_ptr->fbinfo));
186 
187  data = (uchar *)d_ptr->fbinfo.Start;
188 
189  d = d_ptr->fbinfo.BitsPerPixel;
190  switch (d) {
191  case 1:
193  break;
194  case 8:
196  break;
197  case 12:
199  break;
200  case 15:
202  break;
203  case 16:
205  break;
206  case 18:
208  break;
209  case 24:
211 #ifdef QT_QWS_DEPTH_GENERIC
212 #if Q_BYTE_ORDER != Q_BIG_ENDIAN
213  qt_set_generic_blit(this, 24,
214  d_ptr->fbinfo.Red.Bits,
215  d_ptr->fbinfo.Green.Bits,
216  d_ptr->fbinfo.Blue.Bits,
217  d_ptr->fbinfo.Alpha.Bits,
218  d_ptr->fbinfo.Red.Offset,
219  d_ptr->fbinfo.Green.Offset,
220  d_ptr->fbinfo.Blue.Offset,
221  d_ptr->fbinfo.Alpha.Offset);
222 #else
223  qt_set_generic_blit(this, 24,
224  d_ptr->fbinfo.Red.Bits,
225  d_ptr->fbinfo.Green.Bits,
226  d_ptr->fbinfo.Blue.Bits,
227  d_ptr->fbinfo.Alpha.Bits,
228  16 - d_ptr->fbinfo.Red.Offset,
229  16 - d_ptr->fbinfo.Green.Offset,
230  16 - d_ptr->fbinfo.Blue.Offset,
231  16 - d_ptr->fbinfo.Alpha.Offset);
232 #endif
233 #endif
234  break;
235  case 32:
237 #ifdef QT_QWS_DEPTH_GENERIC
238 #if Q_BYTE_ORDER != Q_BIG_ENDIAN
239  qt_set_generic_blit(this, 32,
240  d_ptr->fbinfo.Red.Bits,
241  d_ptr->fbinfo.Green.Bits,
242  d_ptr->fbinfo.Blue.Bits,
243  d_ptr->fbinfo.Alpha.Bits,
244  d_ptr->fbinfo.Red.Offset,
245  d_ptr->fbinfo.Green.Offset,
246  d_ptr->fbinfo.Blue.Offset,
247  d_ptr->fbinfo.Alpha.Offset);
248 #else
249  qt_set_generic_blit(this, 32,
250  d_ptr->fbinfo.Red.Bits,
251  d_ptr->fbinfo.Green.Bits,
252  d_ptr->fbinfo.Blue.Bits,
253  d_ptr->fbinfo.Alpha.Bits,
254  24 - d_ptr->fbinfo.Red.Offset,
255  24 - d_ptr->fbinfo.Green.Offset,
256  24 - d_ptr->fbinfo.Blue.Offset,
257  24 - d_ptr->fbinfo.Alpha.Offset);
258 #endif
259 #endif
260  break;
261  }
262 
263  dw = w = d_ptr->fbinfo.Width;
264  dh = h = d_ptr->fbinfo.Height;
265 
266  /* assumes no padding */
267  lstep = w * ((d + 7) >> 3);
268 
269  mapsize = size = h * lstep;
270 
271  /* default values */
272  int dpi = 72;
273  physWidth = qRound(dw * 25.4 / dpi);
274  physHeight = qRound(dh * 25.4 / dpi);
275 
276  qDebug("Connected to INTEGRITYfb server: %d x %d x %d %dx%dmm (%dx%ddpi)",
277  w, h, d, physWidth, physHeight, qRound(dw*25.4/physWidth), qRound(dh*25.4/physHeight) );
278 
279 
280  QWSServer::setDefaultMouse("integrity");
281  QWSServer::setDefaultKeyboard("integrity");
282 
283  connected = this;
284 
285  return true;
286 }
287 
289 {
290  connected = 0;
291 }
292 
294 {
295 #ifndef QT_NO_QWS_CURSOR
297 #endif
298  return true;
299 }
300 
302 {
303  gh_FB_close(d_ptr->handle);
304 }
305 
306 void QIntfbScreen::setMode(int ,int ,int)
307 {
308 }
309 
310 // save the state of the graphics card
311 // This is needed so that e.g. we can restore the palette when switching
312 // between linux virtual consoles.
314 {
315  // nothing to do.
316 }
317 
318 // restore the state of the graphics card.
320 {
321 }
322 void QIntfbScreen::setDirty(const QRect& rect)
323 {
324  FBRect fbrect;
325  fbrect.dx = rect.x();
326  fbrect.dy = rect.y();
327  fbrect.Width = rect.width();
328  fbrect.Height = rect.height();
329  gh_FB_expose(d_ptr->handle, &fbrect, 0);
330 }
331 
333 {
334  if (connected) {
335  }
336 }
337 
338 void QIntfbScreen::blank(bool on)
339 {
340 }
341 
342 #endif // QT_NO_QWS_INTEGRITYFB
343 
345 
virtual bool initDevice()
Reimplemented Function
virtual void blank(bool)
Prevents the screen driver form displaying any content on the screen.
The QWSKeyboardHandler class is a base class for keyboard drivers in Qt for Embedded Linux...
Definition: qkbd_qws.h:57
virtual void disconnect()
Reimplemented Function
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int d
the pixel depth
Definition: qscreen_qws.h:327
static void setDefaultMouse(const char *)
Sets the mouse driver that will be used if the QWS_MOUSE_PROTO environment variable is not defined...
The QWSMouseHandler class is a base class for mouse drivers in Qt for Embedded Linux.
Definition: qmouse_qws.h:66
QWSKeyboardHandler * keyboard
virtual void setDirty(const QRect &r)
Reimplemented Function
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QIntfbScreenPrivate * d_ptr
int physHeight
the physical height of the screen in millimeters.
Definition: qscreen_qws.h:340
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
static void initSoftwareCursor()
Initializes the screen cursor.
int physWidth
the physical width of the screen in millimeters.
Definition: qscreen_qws.h:339
void setPixelFormat(QImage::Format format)
Sets the screen&#39;s pixel format to format.
Q_CORE_EXPORT void qDebug(const char *,...)
unsigned char uchar
Definition: qglobal.h:994
uchar * data
points to the first visible pixel in the frame buffer.
Definition: qscreen_qws.h:311
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QIntfbScreen * connected
int w
the logical width of the screen.
Definition: qscreen_qws.h:324
virtual void setMode(int nw, int nh, int nd)
Reimplemented Function
The QIntfbScreen class implements a screen driver for the INTEGRITY framebuffer drivers.
virtual ~QIntfbScreen()
Destroys this QIntfbScreen object.
virtual void save()
Reimplemented Function
static void setDefaultKeyboard(const char *)
Sets the keyboard driver that will be used if the QWS_KEYBOARD environment variable is not defined...
int dw
the device width
Definition: qscreen_qws.h:331
int dh
the device height
Definition: qscreen_qws.h:332
virtual void shutdownDevice()
Reimplemented Function
virtual bool connect(const QString &displaySpec)
Reimplemented Function
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QIntfbScreen(int display_id)
Constructs a QVNCScreen object.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
static void setBrightness(int b)
virtual void restore()
Reimplemented Function
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
int mapsize
the total number of bytes in the frame buffer
Definition: qscreen_qws.h:335
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203