1 | // Copyright (C) 2019 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QEGLFSKKMSEVENTREADER_H |
5 | #define QEGLFSKKMSEVENTREADER_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include "private/qeglfsglobal_p.h" |
19 | #include <QObject> |
20 | #include <QThread> |
21 | #include <QMutex> |
22 | #include <QWaitCondition> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QEglFSKmsDevice; |
27 | |
28 | struct QEglFSKmsEventHost : public QObject |
29 | { |
30 | struct PendingFlipWait { |
31 | void *key; |
32 | QMutex *mutex; |
33 | QWaitCondition *cond; |
34 | }; |
35 | |
36 | static const int MAX_FLIPS = 32; |
37 | void *completedFlips[MAX_FLIPS] = {}; |
38 | QEglFSKmsEventHost::PendingFlipWait pendingFlipWaits[MAX_FLIPS] = {}; |
39 | |
40 | bool event(QEvent *event) override; |
41 | void updateStatus(); |
42 | void handlePageFlipCompleted(void *key); |
43 | }; |
44 | |
45 | class QEglFSKmsEventReaderThread : public QThread |
46 | { |
47 | public: |
48 | QEglFSKmsEventReaderThread(int fd) : m_fd(fd) { } |
49 | void run() override; |
50 | QEglFSKmsEventHost *eventHost() { return &m_ev; } |
51 | |
52 | private: |
53 | int m_fd; |
54 | QEglFSKmsEventHost m_ev; |
55 | }; |
56 | |
57 | class Q_EGLFS_EXPORT QEglFSKmsEventReader |
58 | { |
59 | public: |
60 | ~QEglFSKmsEventReader(); |
61 | |
62 | void create(QEglFSKmsDevice *device); |
63 | void destroy(); |
64 | |
65 | void startWaitFlip(void *key, QMutex *mutex, QWaitCondition *cond); |
66 | |
67 | private: |
68 | QEglFSKmsDevice *m_device = nullptr; |
69 | QEglFSKmsEventReaderThread *m_thread = nullptr; |
70 | }; |
71 | |
72 | QT_END_NAMESPACE |
73 | |
74 | #endif // QEGLFSKKMSEVENTREADER_H |
75 | |