summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/kms
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/kms')
-rw-r--r--src/plugins/platforms/kms/kms.json3
-rw-r--r--src/plugins/platforms/kms/kms.pro35
-rw-r--r--src/plugins/platforms/kms/main.cpp6
-rw-r--r--src/plugins/platforms/kms/qkmsbuffermanager.cpp2
-rw-r--r--src/plugins/platforms/kms/qkmscontext.cpp7
-rw-r--r--src/plugins/platforms/kms/qkmscontext.h2
-rw-r--r--src/plugins/platforms/kms/qkmsintegration.cpp34
-rw-r--r--src/plugins/platforms/kms/qkmsintegration.h9
-rw-r--r--src/plugins/platforms/kms/qkmsnativeinterface.cpp105
-rw-r--r--src/plugins/platforms/kms/qkmsnativeinterface.h67
-rw-r--r--src/plugins/platforms/kms/qkmsudevdrmhandler.cpp66
-rw-r--r--src/plugins/platforms/kms/qkmsudevdrmhandler.h66
-rw-r--r--src/plugins/platforms/kms/qkmsudevhandler.cpp55
-rw-r--r--src/plugins/platforms/kms/qkmsudevhandler.h64
-rw-r--r--src/plugins/platforms/kms/qkmsudevlistener.cpp101
-rw-r--r--src/plugins/platforms/kms/qkmsudevlistener.h78
16 files changed, 668 insertions, 32 deletions
diff --git a/src/plugins/platforms/kms/kms.json b/src/plugins/platforms/kms/kms.json
new file mode 100644
index 0000000000..be662226ae
--- /dev/null
+++ b/src/plugins/platforms/kms/kms.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "kms" ]
+}
diff --git a/src/plugins/platforms/kms/kms.pro b/src/plugins/platforms/kms/kms.pro
index 73a3fa0418..f97973b1a1 100644
--- a/src/plugins/platforms/kms/kms.pro
+++ b/src/plugins/platforms/kms/kms.pro
@@ -1,13 +1,14 @@
TARGET = qkms
-
load(qt_plugin)
-QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
-QT = core-private gui-private platformsupport-private opengl-private
+QT += core-private gui-private platformsupport-private opengl-private
+DESTDIR = $$QT.gui.plugins/platforms
+
+DEFINES += MESA_EGL_NO_X11_HEADERS
-CONFIG += link_pkgconfig qpa/genericunixfontdatabase
+CONFIG += link_pkgconfig egl qpa/genericunixfontdatabase
-PKGCONFIG += libdrm egl gbm glesv2
+PKGCONFIG += libdrm libudev egl gbm glesv2
SOURCES = main.cpp \
qkmsintegration.cpp \
@@ -17,7 +18,11 @@ SOURCES = main.cpp \
qkmscursor.cpp \
qkmsdevice.cpp \
qkmsbuffermanager.cpp \
- qkmsbackingstore.cpp
+ qkmsbackingstore.cpp \
+ qkmsnativeinterface.cpp \
+ qkmsudevlistener.cpp \
+ qkmsudevhandler.cpp \
+ qkmsudevdrmhandler.cpp
HEADERS = qkmsintegration.h \
qkmsscreen.h \
qkmscontext.h \
@@ -25,18 +30,14 @@ HEADERS = qkmsintegration.h \
qkmscursor.h \
qkmsdevice.h \
qkmsbuffermanager.h \
- qkmsbackingstore.h
+ qkmsbackingstore.h \
+ qkmsnativeinterface.h \
+ qkmsudevlistener.h \
+ qkmsudevhandler.h \
+ qkmsudevdrmhandler.h
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
-
-
-
-
-
-
-
-
-
-
+OTHER_FILES += \
+ kms.json
diff --git a/src/plugins/platforms/kms/main.cpp b/src/plugins/platforms/kms/main.cpp
index d79d0d240f..422fc5fba6 100644
--- a/src/plugins/platforms/kms/main.cpp
+++ b/src/plugins/platforms/kms/main.cpp
@@ -46,6 +46,8 @@ QT_BEGIN_NAMESPACE
class QKmsIntegrationPlugin : public QPlatformIntegrationPlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformIntegrationFactoryInterface" FILE "kms.json")
public:
QStringList keys() const;
QPlatformIntegration *create(const QString&, const QStringList&);
@@ -67,6 +69,6 @@ QPlatformIntegration *QKmsIntegrationPlugin::create(const QString& system, const
return 0;
}
-Q_EXPORT_PLUGIN2(kms, QKmsIntegrationPlugin)
-
QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/platforms/kms/qkmsbuffermanager.cpp b/src/plugins/platforms/kms/qkmsbuffermanager.cpp
index 5c231e6beb..05da957af0 100644
--- a/src/plugins/platforms/kms/qkmsbuffermanager.cpp
+++ b/src/plugins/platforms/kms/qkmsbuffermanager.cpp
@@ -121,6 +121,8 @@ void QKmsBufferManager::setupBuffersForMode(const drmModeModeInfo &mode, int num
GL_COLOR_ATTACHMENT0,
GL_RENDERBUFFER,
this->renderTargetBuffer());
+
+ eglMakeCurrent(m_screen->device()->eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
void QKmsBufferManager::clearBuffers()
diff --git a/src/plugins/platforms/kms/qkmscontext.cpp b/src/plugins/platforms/kms/qkmscontext.cpp
index 66829bc73a..4ae5325ca7 100644
--- a/src/plugins/platforms/kms/qkmscontext.cpp
+++ b/src/plugins/platforms/kms/qkmscontext.cpp
@@ -110,4 +110,11 @@ QSurfaceFormat QKmsContext::format() const
return QSurfaceFormat();
}
+GLuint QKmsContext::defaultFramebufferObject(QPlatformSurface *surface) const
+{
+ QPlatformWindow *window = static_cast<QPlatformWindow *>(surface);
+ QKmsScreen *screen = static_cast<QKmsScreen *> (QPlatformScreen::platformScreenForWindow(window->window()));
+ return screen->framebufferObject();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/kms/qkmscontext.h b/src/plugins/platforms/kms/qkmscontext.h
index 57f3a1a8e5..6378780f34 100644
--- a/src/plugins/platforms/kms/qkmscontext.h
+++ b/src/plugins/platforms/kms/qkmscontext.h
@@ -65,6 +65,8 @@ public:
EGLContext eglContext() const;
+ GLuint defaultFramebufferObject(QPlatformSurface *surface) const;
+
private:
QKmsDevice *m_device;
diff --git a/src/plugins/platforms/kms/qkmsintegration.cpp b/src/plugins/platforms/kms/qkmsintegration.cpp
index c495ca26f9..0405330617 100644
--- a/src/plugins/platforms/kms/qkmsintegration.cpp
+++ b/src/plugins/platforms/kms/qkmsintegration.cpp
@@ -45,6 +45,9 @@
#include "qkmswindow.h"
#include "qkmsbackingstore.h"
#include "qkmscontext.h"
+#include "qkmsnativeinterface.h"
+#include "qkmsudevlistener.h"
+#include "qkmsudevdrmhandler.h"
#include <QtPlatformSupport/private/qgenericunixprintersupport_p.h>
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
@@ -58,14 +61,14 @@ QT_BEGIN_NAMESPACE
QKmsIntegration::QKmsIntegration()
: QPlatformIntegration(),
m_fontDatabase(new QGenericUnixFontDatabase()),
- m_eventDispatcher(createUnixEventDispatcher())
+ m_eventDispatcher(createUnixEventDispatcher()),
+ m_nativeInterface(new QKmsNativeInterface),
+ m_udevListener(new QKmsUdevListener)
{
QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher);
setenv("EGL_PLATFORM", "drm",1);
- QStringList drmDevices = findDrmDevices();
- foreach (QString path, drmDevices) {
- m_devices.append(new QKmsDevice(path, this));
- }
+ m_drmHandler = new QKmsUdevDRMHandler(this);
+ m_udevListener->addHandler(m_drmHandler);
}
QKmsIntegration::~QKmsIntegration()
@@ -77,6 +80,14 @@ QKmsIntegration::~QKmsIntegration()
delete screen;
}
delete m_fontDatabase;
+ delete m_udevListener;
+}
+
+QObject *QKmsIntegration::createDevice(const char *path)
+{
+ QKmsDevice *device = new QKmsDevice(path, this);
+ m_devices.append(device);
+ return device;
}
bool QKmsIntegration::hasCapability(QPlatformIntegration::Capability cap) const
@@ -110,14 +121,6 @@ QPlatformFontDatabase *QKmsIntegration::fontDatabase() const
return m_fontDatabase;
}
-QStringList QKmsIntegration::findDrmDevices()
-{
- //Return a list addresses of DRM supported devices
- //Hardcoded now, but could use udev to return a list
- //of multiple devices.
- return QStringList(QString::fromLatin1("/dev/dri/card0"));
-}
-
void QKmsIntegration::addScreen(QKmsScreen *screen)
{
m_screens.append(screen);
@@ -129,4 +132,9 @@ QAbstractEventDispatcher *QKmsIntegration::guiThreadEventDispatcher() const
return m_eventDispatcher;
}
+QPlatformNativeInterface *QKmsIntegration::nativeInterface() const
+{
+ return m_nativeInterface;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/kms/qkmsintegration.h b/src/plugins/platforms/kms/qkmsintegration.h
index 5724471295..03fc5080a6 100644
--- a/src/plugins/platforms/kms/qkmsintegration.h
+++ b/src/plugins/platforms/kms/qkmsintegration.h
@@ -43,11 +43,14 @@
#define QPLATFORMINTEGRATION_KMS_H
#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformNativeInterface>
QT_BEGIN_NAMESPACE
class QKmsScreen;
class QKmsDevice;
+class QKmsUdevListener;
+class QKmsUdevDRMHandler;
class QKmsIntegration : public QPlatformIntegration
{
@@ -64,7 +67,10 @@ public:
QPlatformFontDatabase *fontDatabase() const;
QAbstractEventDispatcher *guiThreadEventDispatcher() const;
+ QPlatformNativeInterface *nativeInterface() const;
+
void addScreen(QKmsScreen *screen);
+ QObject *createDevice(const char *);
private:
QStringList findDrmDevices();
@@ -73,6 +79,9 @@ private:
QList<QKmsDevice *> m_devices;
QPlatformFontDatabase *m_fontDatabase;
QAbstractEventDispatcher *m_eventDispatcher;
+ QPlatformNativeInterface *m_nativeInterface;
+ QKmsUdevListener *m_udevListener;
+ QKmsUdevDRMHandler *m_drmHandler;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/kms/qkmsnativeinterface.cpp b/src/plugins/platforms/kms/qkmsnativeinterface.cpp
new file mode 100644
index 0000000000..8e026b2503
--- /dev/null
+++ b/src/plugins/platforms/kms/qkmsnativeinterface.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qguiapplication_p.h>
+#include "qkmsnativeinterface.h"
+#include "qkmsdevice.h"
+
+#include "qscreen.h"
+
+class QKmsResourceMap : public QMap<QByteArray, QKmsNativeInterface::ResourceType>
+{
+public:
+ QKmsResourceMap()
+ :QMap<QByteArray, QKmsNativeInterface::ResourceType>()
+ {
+ insert("egldisplay", QKmsNativeInterface::EglDisplay);
+ insert("eglcontext", QKmsNativeInterface::EglContext);
+ }
+};
+
+Q_GLOBAL_STATIC(QKmsResourceMap, qKmsResourceMap)
+
+void *QKmsNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
+{
+ QByteArray lowerCaseResource = resourceString.toLower();
+ ResourceType resource = qKmsResourceMap()->value(lowerCaseResource);
+ void *result = 0;
+ switch (resource) {
+ case EglDisplay:
+ result = eglDisplayForWindow(window);
+ break;
+ case EglContext:
+ result = eglContextForWindow(window);
+ break;
+ default:
+ result = 0;
+ }
+ return result;
+}
+
+void *QKmsNativeInterface::eglDisplayForWindow(QWindow *window)
+{
+ QKmsScreen *screen = qPlatformScreenForWindow(window);
+ if (!screen)
+ return 0;
+ QKmsDevice *device = screen->device();
+ if (!device)
+ return 0;
+ return device->eglDisplay();
+}
+
+void *QKmsNativeInterface::eglContextForWindow(QWindow *window)
+{
+ QKmsScreen *screen = qPlatformScreenForWindow(window);
+ if (!screen)
+ return 0;
+ QKmsDevice *device = screen->device();
+ if (!device)
+ return 0;
+ return device->eglContext();
+}
+
+QKmsScreen *QKmsNativeInterface::qPlatformScreenForWindow(QWindow *window)
+{
+ QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen();
+ return static_cast<QKmsScreen *>(screen->handle());
+}
diff --git a/src/plugins/platforms/kms/qkmsnativeinterface.h b/src/plugins/platforms/kms/qkmsnativeinterface.h
new file mode 100644
index 0000000000..77a9573250
--- /dev/null
+++ b/src/plugins/platforms/kms/qkmsnativeinterface.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QKMSNATIVEINTERFACE_H
+#define QKMSNATIVEINTERFACE_H
+
+#include "qkmsscreen.h"
+
+#include <QtGui/QPlatformNativeInterface>
+
+class QKmsNativeInterface : public QPlatformNativeInterface
+{
+public:
+ enum ResourceType {
+ EglDisplay,
+ EglContext
+ };
+
+ void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
+
+ void *eglDisplayForWindow(QWindow *window);
+ void *eglContextForWindow(QWindow *window);
+
+private:
+ static QKmsScreen *qPlatformScreenForWindow(QWindow *window);
+};
+
+
+#endif // QKMSNATIVEINTERFACE_H
diff --git a/src/plugins/platforms/kms/qkmsudevdrmhandler.cpp b/src/plugins/platforms/kms/qkmsudevdrmhandler.cpp
new file mode 100644
index 0000000000..0f59de4cef
--- /dev/null
+++ b/src/plugins/platforms/kms/qkmsudevdrmhandler.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QRegExp>
+
+#include <qkmsintegration.h>
+#include <qkmsudevdrmhandler.h>
+
+QT_BEGIN_NAMESPACE
+
+QKmsUdevDRMHandler::QKmsUdevDRMHandler(QKmsIntegration *integration)
+ : m_integration(integration)
+{
+}
+
+QObject *QKmsUdevDRMHandler::create(struct udev_device *device)
+{
+ if (strcmp(udev_device_get_subsystem(device), "drm"))
+ return 0;
+
+ QRegExp regexp("^card\\d+$");
+ if (!regexp.exactMatch(udev_device_get_sysname(device)))
+ return 0;
+
+ return m_integration->createDevice(udev_device_get_devnode(device));
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/kms/qkmsudevdrmhandler.h b/src/plugins/platforms/kms/qkmsudevdrmhandler.h
new file mode 100644
index 0000000000..d627fec1c6
--- /dev/null
+++ b/src/plugins/platforms/kms/qkmsudevdrmhandler.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QKMSUDEVDRMHANDLER_H
+#define QKMSUDEVDRMHANDLER_H
+
+#include <QObject>
+
+#include <qkmsudevhandler.h>
+
+QT_BEGIN_NAMESPACE
+
+class QKmsIntegration;
+
+class QKmsUdevDRMHandler : public QKmsUdevHandler
+{
+public:
+ QKmsUdevDRMHandler(QKmsIntegration *integration);
+
+ QObject *create(struct udev_device *device);
+
+private:
+ QKmsIntegration *m_integration;
+};
+
+QT_END_NAMESPACE
+
+#endif // QKMSUDEVDRMHANDLER_H
diff --git a/src/plugins/platforms/kms/qkmsudevhandler.cpp b/src/plugins/platforms/kms/qkmsudevhandler.cpp
new file mode 100644
index 0000000000..c0ec4c4ba1
--- /dev/null
+++ b/src/plugins/platforms/kms/qkmsudevhandler.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qkmsudevhandler.h>
+
+QT_BEGIN_NAMESPACE
+
+QKmsUdevHandler::QKmsUdevHandler(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QKmsUdevHandler::~QKmsUdevHandler()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/kms/qkmsudevhandler.h b/src/plugins/platforms/kms/qkmsudevhandler.h
new file mode 100644
index 0000000000..4870809927
--- /dev/null
+++ b/src/plugins/platforms/kms/qkmsudevhandler.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QKMSUDEVHANDLER_H
+#define QKMSUDEVHANDLER_H
+
+#include <QObject>
+
+#include <libudev.h>
+
+QT_BEGIN_NAMESPACE
+
+class QKmsUdevHandler : public QObject
+{
+ Q_OBJECT
+
+public:
+ QKmsUdevHandler(QObject *parent = 0);
+ virtual ~QKmsUdevHandler();
+
+ virtual QObject *create(struct udev_device *) = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QKMSUDEVHANDLER_H
diff --git a/src/plugins/platforms/kms/qkmsudevlistener.cpp b/src/plugins/platforms/kms/qkmsudevlistener.cpp
new file mode 100644
index 0000000000..c0a933b57b
--- /dev/null
+++ b/src/plugins/platforms/kms/qkmsudevlistener.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qkmsudevlistener.h>
+
+QT_BEGIN_NAMESPACE
+
+QKmsUdevListener::QKmsUdevListener(QObject *parent)
+ : QObject(parent)
+{
+ m_udev = udev_new();
+}
+
+QKmsUdevListener::~QKmsUdevListener()
+{
+ udev_unref(m_udev);
+}
+
+void QKmsUdevListener::addHandler(QKmsUdevHandler *handler)
+{
+ m_handlers.removeAll((QKmsUdevHandler *) 0);
+ m_handlers.removeAll(handler);
+ m_handlers.prepend(handler);
+
+ scan();
+}
+
+bool QKmsUdevListener::create(struct udev_device *device)
+{
+ foreach (QKmsUdevHandler *handler, m_handlers) {
+ if (!handler)
+ continue;
+
+ QObject *obj = handler->create(device);
+ if (obj) {
+ m_devices[udev_device_get_syspath(device)] = obj;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void QKmsUdevListener::scan()
+{
+ struct udev_enumerate *e;
+ struct udev_list_entry *entry;
+
+ e = udev_enumerate_new(m_udev);
+ udev_enumerate_scan_devices(e);
+ udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
+ const char *path = udev_list_entry_get_name(entry);
+ if (m_devices.contains(path))
+ continue;
+
+ struct udev_device *device = udev_device_new_from_syspath(m_udev, path);
+ create(device);
+ udev_device_unref(device);
+ }
+ udev_enumerate_unref(e);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/kms/qkmsudevlistener.h b/src/plugins/platforms/kms/qkmsudevlistener.h
new file mode 100644
index 0000000000..3d87cfe662
--- /dev/null
+++ b/src/plugins/platforms/kms/qkmsudevlistener.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QKMSUDEVLISTENER_H
+#define QKMSUDEVLISTENER_H
+
+#include <QObject>
+#include <QMap>
+#include <QList>
+#include <QPointer>
+#include <QString>
+
+#include <qkmsudevhandler.h>
+
+#include <libudev.h>
+
+QT_BEGIN_NAMESPACE
+
+class QKmsUdevListener : public QObject
+{
+ Q_OBJECT
+
+public:
+ QKmsUdevListener(QObject *parent = 0);
+ ~QKmsUdevListener();
+
+ void addHandler(QKmsUdevHandler *);
+
+private:
+ QList<QPointer<QKmsUdevHandler> > m_handlers;
+ QMap<QString, QPointer<QObject> > m_devices;
+ struct udev *m_udev;
+
+ void scan();
+ bool create(struct udev_device *);
+};
+
+QT_END_NAMESPACE
+
+#endif // QKMSUDEVLISTENER_H