diff options
-rw-r--r-- | backend/drm/atomic.c | 7 | ||||
-rw-r--r-- | backend/drm/drm.c | 18 | ||||
-rw-r--r-- | backend/drm/properties.c | 13 | ||||
-rw-r--r-- | include/backend/drm/properties.h | 3 |
4 files changed, 34 insertions, 7 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index 5c064ac7..ad80f2fd 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -104,7 +104,8 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *drm, drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id); } - if (drmModeCreatePropertyBlob(drm->fd, mode, sizeof(*mode), &crtc->mode_id)) { + if (drmModeCreatePropertyBlob(drm->fd, mode, sizeof(*mode), + &crtc->mode_id)) { wlr_log_errno(WLR_ERROR, "Unable to create property blob"); return false; } @@ -120,6 +121,10 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *drm, struct atomic atom; atomic_begin(crtc, &atom); atomic_add(&atom, conn->id, conn->props.crtc_id, crtc->id); + if (mode != NULL && conn->props.link_status != 0) { + atomic_add(&atom, conn->id, conn->props.link_status, + DRM_MODE_LINK_STATUS_GOOD); + } atomic_add(&atom, crtc->id, crtc->props.mode_id, crtc->mode_id); atomic_add(&atom, crtc->id, crtc->props.active, 1); set_plane_props(&atom, crtc->primary, crtc->id, fb_id, true); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index fa9a95ae..784a0233 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1034,6 +1034,24 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) { wlr_conn->crtc = NULL; } + // This can only happen *after* hotplug, since we haven't read the + // connector properties yet + if (wlr_conn->props.link_status != 0) { + uint64_t link_status; + if (!get_drm_prop(drm->fd, wlr_conn->id, + wlr_conn->props.link_status, &link_status)) { + wlr_log(WLR_ERROR, "Failed to get link status for '%s'", + wlr_conn->output.name); + continue; + } + + if (link_status == DRM_MODE_LINK_STATUS_BAD) { + // We need to reload our list of modes and force a modeset + wlr_log(WLR_INFO, "Bad link for '%s'", wlr_conn->output.name); + drm_connector_cleanup(wlr_conn); + } + } + if (wlr_conn->state == WLR_DRM_CONN_DISCONNECTED && drm_conn->connection == DRM_MODE_CONNECTED) { wlr_log(WLR_INFO, "'%s' connected", wlr_conn->output.name); diff --git a/backend/drm/properties.c b/backend/drm/properties.c index 372de232..5ca4c8ac 100644 --- a/backend/drm/properties.c +++ b/backend/drm/properties.c @@ -19,9 +19,10 @@ struct prop_info { static const struct prop_info connector_info[] = { #define INDEX(name) (offsetof(union wlr_drm_connector_props, name) / sizeof(uint32_t)) - { "CRTC_ID", INDEX(crtc_id) }, - { "DPMS", INDEX(dpms) }, - { "EDID", INDEX(edid) }, + { "CRTC_ID", INDEX(crtc_id) }, + { "DPMS", INDEX(dpms) }, + { "EDID", INDEX(edid) }, + { "link-status", INDEX(link_status) }, #undef INDEX }; @@ -87,7 +88,8 @@ static bool scan_properties(int fd, uint32_t id, uint32_t type, uint32_t *result return true; } -bool get_drm_connector_props(int fd, uint32_t id, union wlr_drm_connector_props *out) { +bool get_drm_connector_props(int fd, uint32_t id, + union wlr_drm_connector_props *out) { return scan_properties(fd, id, DRM_MODE_OBJECT_CONNECTOR, out->props, connector_info, sizeof(connector_info) / sizeof(connector_info[0])); } @@ -103,7 +105,8 @@ bool get_drm_plane_props(int fd, uint32_t id, union wlr_drm_plane_props *out) { } bool get_drm_prop(int fd, uint32_t obj, uint32_t prop, uint64_t *ret) { - drmModeObjectProperties *props = drmModeObjectGetProperties(fd, obj, DRM_MODE_OBJECT_ANY); + drmModeObjectProperties *props = + drmModeObjectGetProperties(fd, obj, DRM_MODE_OBJECT_ANY); if (!props) { return false; } diff --git a/include/backend/drm/properties.h b/include/backend/drm/properties.h index 5b17e77e..321b4492 100644 --- a/include/backend/drm/properties.h +++ b/include/backend/drm/properties.h @@ -14,12 +14,13 @@ union wlr_drm_connector_props { struct { uint32_t edid; uint32_t dpms; + uint32_t link_status; // not guaranteed to exist // atomic-modesetting only uint32_t crtc_id; }; - uint32_t props[3]; + uint32_t props[4]; }; union wlr_drm_crtc_props { |