Merge pull request #1280 from emersion/drm-link-status
backend/drm: add support for the link-status property
This commit is contained in:
commit
885586a831
|
@ -104,7 +104,8 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *drm,
|
||||||
drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id);
|
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");
|
wlr_log_errno(WLR_ERROR, "Unable to create property blob");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -120,6 +121,10 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *drm,
|
||||||
struct atomic atom;
|
struct atomic atom;
|
||||||
atomic_begin(crtc, &atom);
|
atomic_begin(crtc, &atom);
|
||||||
atomic_add(&atom, conn->id, conn->props.crtc_id, crtc->id);
|
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.mode_id, crtc->mode_id);
|
||||||
atomic_add(&atom, crtc->id, crtc->props.active, 1);
|
atomic_add(&atom, crtc->id, crtc->props.active, 1);
|
||||||
set_plane_props(&atom, crtc->primary, crtc->id, fb_id, true);
|
set_plane_props(&atom, crtc->primary, crtc->id, fb_id, true);
|
||||||
|
|
|
@ -1083,6 +1083,24 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
||||||
wlr_conn->crtc = NULL;
|
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 &&
|
if (wlr_conn->state == WLR_DRM_CONN_DISCONNECTED &&
|
||||||
drm_conn->connection == DRM_MODE_CONNECTED) {
|
drm_conn->connection == DRM_MODE_CONNECTED) {
|
||||||
wlr_log(WLR_INFO, "'%s' connected", wlr_conn->output.name);
|
wlr_log(WLR_INFO, "'%s' connected", wlr_conn->output.name);
|
||||||
|
|
|
@ -22,6 +22,7 @@ static const struct prop_info connector_info[] = {
|
||||||
{ "CRTC_ID", INDEX(crtc_id) },
|
{ "CRTC_ID", INDEX(crtc_id) },
|
||||||
{ "DPMS", INDEX(dpms) },
|
{ "DPMS", INDEX(dpms) },
|
||||||
{ "EDID", INDEX(edid) },
|
{ "EDID", INDEX(edid) },
|
||||||
|
{ "link-status", INDEX(link_status) },
|
||||||
#undef INDEX
|
#undef INDEX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,7 +88,8 @@ static bool scan_properties(int fd, uint32_t id, uint32_t type, uint32_t *result
|
||||||
return true;
|
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,
|
return scan_properties(fd, id, DRM_MODE_OBJECT_CONNECTOR, out->props,
|
||||||
connector_info, sizeof(connector_info) / sizeof(connector_info[0]));
|
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) {
|
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) {
|
if (!props) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,13 @@ union wlr_drm_connector_props {
|
||||||
struct {
|
struct {
|
||||||
uint32_t edid;
|
uint32_t edid;
|
||||||
uint32_t dpms;
|
uint32_t dpms;
|
||||||
|
uint32_t link_status; // not guaranteed to exist
|
||||||
|
|
||||||
// atomic-modesetting only
|
// atomic-modesetting only
|
||||||
|
|
||||||
uint32_t crtc_id;
|
uint32_t crtc_id;
|
||||||
};
|
};
|
||||||
uint32_t props[3];
|
uint32_t props[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
union wlr_drm_crtc_props {
|
union wlr_drm_crtc_props {
|
||||||
|
|
Loading…
Reference in New Issue