KWaylandServer

drmleasedevice_v1_interface.h
1 /*
2  SPDX-FileCopyrightText: 2021 Xaver Hugl <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #pragma once
8 
9 #include <KWaylandServer/kwaylandserver_export.h>
10 
11 #include <QObject>
12 #include <QPointer>
13 
14 struct wl_resource;
15 
16 namespace KWaylandServer
17 {
18 
19 class Display;
20 class DrmLeaseDeviceV1InterfacePrivate;
21 class DrmLeaseV1Interface;
22 class DrmLeaseV1InterfacePrivate;
23 class DrmLeaseRequestV1Interface;
24 class DrmLeaseConnectorV1InterfacePrivate;
25 
26 /**
27  * The DrmLeaseV1DeviceInterface allows the wayland compositor to offer unused
28  * drm connectors for lease by clients. The main use for this is VR headsets
29  */
30 class KWAYLANDSERVER_EXPORT DrmLeaseDeviceV1Interface : public QObject
31 {
32  Q_OBJECT
33 public:
34  /**
35  * @param createNonMasterFd a function that creates non-master drm file descriptors for
36  * this device that clients can use to enumerate connectors and their properties
37  */
38  explicit DrmLeaseDeviceV1Interface(Display *display, std::function<int()> createNonMasterFd);
39  ~DrmLeaseDeviceV1Interface() override;
40 
41  /**
42  * Must be called by the compositor when it loses or gains drm master
43  */
44  void setDrmMaster(bool hasDrmMaster);
45 
46 Q_SIGNALS:
47  /**
48  * Emitted when a lease is requested. The compositor needs to either
49  * grant or deny the lease when receiving this signal
50  */
51  void leaseRequested(DrmLeaseV1Interface *leaseRequest);
52 
53  /**
54  * Emitted when a granted lease gets revoked
55  */
56  void leaseRevoked(DrmLeaseV1Interface *lease);
57 
58 private:
59  friend class DrmLeaseDeviceV1InterfacePrivate;
60  DrmLeaseDeviceV1InterfacePrivate *d;
61 };
62 
63 /**
64  * Represents a lease offer from the compositor. Creating the DrmLeaseConnectorV1Interface
65  * will allow clients to requests a lease for the connector, deleting it will result in the
66  * offer and possibly an active lease being revoked
67  */
68 class KWAYLANDSERVER_EXPORT DrmLeaseConnectorV1Interface : public QObject
69 {
70  Q_OBJECT
71 public:
72  explicit DrmLeaseConnectorV1Interface(DrmLeaseDeviceV1Interface *leaseDevice, uint32_t id, const QString &name, const QString &description);
73  ~DrmLeaseConnectorV1Interface() override;
74 
75  static DrmLeaseConnectorV1Interface *get(wl_resource *resource);
76 
77 private:
78  friend class DrmLeaseConnectorV1InterfacePrivate;
80 };
81 
82 /**
83  * Represents a lease request or active lease
84  */
85 class KWAYLANDSERVER_EXPORT DrmLeaseV1Interface : public QObject
86 {
87  Q_OBJECT
88 public:
89  /**
90  * Grant the client requesting the lease access to DRM resources needed to
91  * drive the outputs corresponding to the requested connectors.
92  * Must only be called once in response to DrmLeaseDeviceV1Interface::leaseRequested
93  */
94  void grant(int leaseFd, uint32_t lesseeId);
95 
96  /**
97  * Deny the lease request. The compositor may call this in response to
98  * DrmLeaseDeviceV1Interface::leaseRequested or when it detects a lease being ended with libdrm
99  */
100  void deny();
101 
102  /**
103  * The connectors this lease (request) encompasses
104  */
105  QVector<DrmLeaseConnectorV1Interface *> connectors() const;
106 
107  /**
108  * The lesseeId passed to DrmLeaseV1Interface::grant, or 0 if this lease was not granted
109  */
110  uint32_t lesseeId() const;
111 
112 private:
113  DrmLeaseV1Interface(DrmLeaseDeviceV1InterfacePrivate *device, wl_resource *resource);
115 
116  friend class DrmLeaseDeviceV1InterfacePrivate;
117  friend class DrmLeaseRequestV1Interface;
118  friend class DrmLeaseV1InterfacePrivate;
120 };
121 
122 }
Class holding the Wayland server display loop.
Definition: display.h:47
Represents a lease offer from the compositor.
The DrmLeaseV1DeviceInterface allows the wayland compositor to offer unused drm connectors for lease ...
Represents a lease request or active lease.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:08:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.