aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorScott Anderson <ascent12@hotmail.com>2018-10-08 21:01:30 +0200
committerGitHub <noreply@github.com>2018-10-08 21:01:30 +0200
commit885586a831437c1f9b5bff74fc48e64c2ed9669e (patch)
tree68d4a1d6347d1c872501929df0b6afbf8a87bc1f /backend
parent97049576f7d19534aacc685902b582f9d5ad4e83 (diff)
parentf5a147b739ebd33bc61996a179801775192b19ce (diff)
Merge pull request #1280 from emersion/drm-link-status
backend/drm: add support for the link-status property
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/atomic.c7
-rw-r--r--backend/drm/drm.c18
-rw-r--r--backend/drm/properties.c13
3 files changed, 32 insertions, 6 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 272a168c..00525762 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -1083,6 +1083,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;
}