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" | | |||
22 | #include "drm_pointer.h" | 21 | #include "drm_pointer.h" | ||
23 | #include "logging.h" | 22 | #include "logging.h" | ||
24 | 23 | | |||
25 | namespace KWin | 24 | namespace KWin | ||
26 | { | 25 | { | ||
27 | 26 | | |||
28 | DrmConnector::DrmConnector(uint32_t connector_id, DrmBackend *backend) | 27 | DrmConnector::DrmConnector(uint32_t connector_id, int fd) | ||
29 | : DrmObject(connector_id, backend) | 28 | : DrmObject(connector_id, fd) | ||
30 | { | 29 | { | ||
31 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> con(drmModeGetConnector(backend->fd(), connector_id)); | 30 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> con(drmModeGetConnector(fd, connector_id)); | ||
32 | if (!con) { | 31 | if (!con) { | ||
33 | return; | 32 | return; | ||
34 | } | 33 | } | ||
35 | for (int i = 0; i < con->count_encoders; ++i) { | 34 | for (int i = 0; i < con->count_encoders; ++i) { | ||
36 | m_encoders << con->encoders[i]; | 35 | m_encoders << con->encoders[i]; | ||
37 | } | 36 | } | ||
38 | } | 37 | } | ||
39 | 38 | | |||
Show All 10 Lines | |||||
50 | } | 49 | } | ||
51 | 50 | | |||
52 | bool DrmConnector::initProps() | 51 | bool DrmConnector::initProps() | ||
53 | { | 52 | { | ||
54 | setPropertyNames( { | 53 | setPropertyNames( { | ||
55 | QByteArrayLiteral("CRTC_ID"), | 54 | QByteArrayLiteral("CRTC_ID"), | ||
56 | }); | 55 | }); | ||
57 | 56 | | |||
58 | drmModeObjectProperties *properties = drmModeObjectGetProperties(m_backend->fd(), m_id, DRM_MODE_OBJECT_CONNECTOR); | 57 | drmModeObjectProperties *properties = drmModeObjectGetProperties(fd(), m_id, DRM_MODE_OBJECT_CONNECTOR); | ||
59 | if (!properties) { | 58 | if (!properties) { | ||
60 | qCWarning(KWIN_DRM) << "Failed to get properties for connector " << m_id ; | 59 | qCWarning(KWIN_DRM) << "Failed to get properties for connector " << m_id ; | ||
61 | return false; | 60 | return false; | ||
62 | } | 61 | } | ||
63 | 62 | | |||
64 | int propCount = int(PropertyIndex::Count); | 63 | int propCount = int(PropertyIndex::Count); | ||
65 | for (int j = 0; j < propCount; ++j) { | 64 | for (int j = 0; j < propCount; ++j) { | ||
66 | initProp(j, properties); | 65 | initProp(j, properties); | ||
67 | } | 66 | } | ||
68 | drmModeFreeObjectProperties(properties); | 67 | drmModeFreeObjectProperties(properties); | ||
69 | return true; | 68 | return true; | ||
70 | } | 69 | } | ||
71 | 70 | | |||
72 | bool DrmConnector::isConnected() | 71 | bool DrmConnector::isConnected() | ||
73 | { | 72 | { | ||
74 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> con(drmModeGetConnector(m_backend->fd(), m_id)); | 73 | ScopedDrmPointer<_drmModeConnector, &drmModeFreeConnector> con(drmModeGetConnector(fd(), m_id)); | ||
75 | if (!con) { | 74 | if (!con) { | ||
76 | return false; | 75 | return false; | ||
77 | } | 76 | } | ||
78 | return con->connection == DRM_MODE_CONNECTED; | 77 | return con->connection == DRM_MODE_CONNECTED; | ||
79 | } | 78 | } | ||
80 | 79 | | |||
81 | } | 80 | } |