Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_object_connector.cpp
Show All 12 Lines | |||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "drm_object_connector.h" | 20 | #include "drm_object_connector.h" | ||
21 | #include "drm_backend.h" | ||||
21 | #include "drm_pointer.h" | 22 | #include "drm_pointer.h" | ||
22 | #include "logging.h" | 23 | #include "logging.h" | ||
23 | 24 | | |||
24 | namespace KWin | 25 | namespace KWin | ||
25 | { | 26 | { | ||
26 | 27 | | |||
27 | DrmConnector::DrmConnector(uint32_t connector_id, int fd) | 28 | DrmConnector::DrmConnector(uint32_t connector_id, DrmBackend *backend) | ||
28 | : DrmObject(connector_id, fd) | 29 | : DrmObject(connector_id, backend) | ||
29 | { | 30 | { | ||
30 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> con(drmModeGetConnector(fd, connector_id)); | 31 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> con(drmModeGetConnector(backend->fd(), connector_id)); | ||
31 | if (!con) { | 32 | if (!con) { | ||
32 | return; | 33 | return; | ||
33 | } | 34 | } | ||
34 | for (int i = 0; i < con->count_encoders; ++i) { | 35 | for (int i = 0; i < con->count_encoders; ++i) { | ||
35 | m_encoders << con->encoders[i]; | 36 | m_encoders << con->encoders[i]; | ||
36 | } | 37 | } | ||
37 | } | 38 | } | ||
38 | 39 | | |||
39 | DrmConnector::~DrmConnector() = default; | 40 | DrmConnector::~DrmConnector() = default; | ||
40 | 41 | | |||
41 | bool DrmConnector::init() | 42 | bool DrmConnector::atomicInit() | ||
42 | { | 43 | { | ||
43 | qCDebug(KWIN_DRM) << "Creating connector" << m_id; | 44 | qCDebug(KWIN_DRM) << "Creating connector" << m_id; | ||
44 | 45 | | |||
45 | if (!initProps()) { | 46 | if (!initProps()) { | ||
46 | return false; | 47 | return false; | ||
47 | } | 48 | } | ||
48 | return true; | 49 | return true; | ||
49 | } | 50 | } | ||
50 | 51 | | |||
51 | bool DrmConnector::initProps() | 52 | bool DrmConnector::initProps() | ||
52 | { | 53 | { | ||
53 | m_propsNames = { | 54 | m_propsNames = { | ||
54 | QByteArrayLiteral("CRTC_ID"), | 55 | QByteArrayLiteral("CRTC_ID"), | ||
55 | }; | 56 | }; | ||
56 | 57 | | |||
57 | drmModeObjectProperties *properties = drmModeObjectGetProperties(m_fd, m_id, DRM_MODE_OBJECT_CONNECTOR); | 58 | drmModeObjectProperties *properties = drmModeObjectGetProperties(m_backend->fd(), m_id, DRM_MODE_OBJECT_CONNECTOR); | ||
58 | if (!properties) { | 59 | if (!properties) { | ||
59 | qCWarning(KWIN_DRM) << "Failed to get properties for connector " << m_id ; | 60 | qCWarning(KWIN_DRM) << "Failed to get properties for connector " << m_id ; | ||
60 | return false; | 61 | return false; | ||
61 | } | 62 | } | ||
62 | 63 | | |||
63 | int propCount = int(PropertyIndex::Count); | 64 | int propCount = int(PropertyIndex::Count); | ||
64 | for (int j = 0; j < propCount; ++j) { | 65 | for (int j = 0; j < propCount; ++j) { | ||
65 | initProp(j, properties); | 66 | initProp(j, properties); | ||
66 | } | 67 | } | ||
67 | drmModeFreeObjectProperties(properties); | 68 | drmModeFreeObjectProperties(properties); | ||
68 | return true; | 69 | return true; | ||
69 | } | 70 | } | ||
70 | 71 | | |||
71 | bool DrmConnector::isConnected() | 72 | bool DrmConnector::isConnected() | ||
72 | { | 73 | { | ||
73 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> con(drmModeGetConnector(m_fd, m_id)); | 74 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> con(drmModeGetConnector(m_backend->fd(), m_id)); | ||
74 | if (!con) { | 75 | if (!con) { | ||
75 | return false; | 76 | return false; | ||
76 | } | 77 | } | ||
77 | return con->connection == DRM_MODE_CONNECTED; | 78 | return con->connection == DRM_MODE_CONNECTED; | ||
78 | } | 79 | } | ||
79 | 80 | | |||
80 | } | 81 | } |