|
|
@ -991,36 +991,43 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static uint32_t get_possible_crtcs(int fd, uint32_t conn_id) {
|
|
|
|
static uint32_t get_possible_crtcs(int fd, drmModeRes *res,
|
|
|
|
drmModeConnector *conn = drmModeGetConnector(fd, conn_id);
|
|
|
|
drmModeConnector *conn, bool is_mst) {
|
|
|
|
if (!conn) {
|
|
|
|
uint32_t ret = 0;
|
|
|
|
wlr_log_errno(WLR_ERROR, "Failed to get DRM connector");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (conn->connection != DRM_MODE_CONNECTED || conn->count_modes == 0) {
|
|
|
|
for (int i = 0; i < conn->count_encoders; ++i) {
|
|
|
|
wlr_log(WLR_ERROR, "Output is not connected");
|
|
|
|
drmModeEncoder *enc = drmModeGetEncoder(fd, conn->encoders[i]);
|
|
|
|
goto error_conn;
|
|
|
|
if (!enc) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ret |= enc->possible_crtcs;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drmModeFreeEncoder(enc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
drmModeEncoder *enc = NULL;
|
|
|
|
// Sometimes DP MST connectors report no encoders, so we'll loop though
|
|
|
|
for (int i = 0; !enc && i < conn->count_encoders; ++i) {
|
|
|
|
// all of the encoders of the MST type instead.
|
|
|
|
enc = drmModeGetEncoder(fd, conn->encoders[i]);
|
|
|
|
// TODO: See if there is a better solution.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_mst || ret) {
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!enc) {
|
|
|
|
for (int i = 0; i < res->count_encoders; ++i) {
|
|
|
|
wlr_log(WLR_ERROR, "Failed to get DRM encoder");
|
|
|
|
drmModeEncoder *enc = drmModeGetEncoder(fd, res->encoders[i]);
|
|
|
|
goto error_conn;
|
|
|
|
if (!enc) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (enc->encoder_type == DRM_MODE_ENCODER_DPMST) {
|
|
|
|
|
|
|
|
ret |= enc->possible_crtcs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drmModeFreeEncoder(enc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t ret = enc->possible_crtcs;
|
|
|
|
|
|
|
|
drmModeFreeEncoder(enc);
|
|
|
|
|
|
|
|
drmModeFreeConnector(conn);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
|
|
|
|
error_conn:
|
|
|
|
|
|
|
|
drmModeFreeConnector(conn);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
|
|
|
void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
|
|
@ -1050,7 +1057,7 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
|
|
|
drmModeEncoder *curr_enc = drmModeGetEncoder(drm->fd,
|
|
|
|
drmModeEncoder *curr_enc = drmModeGetEncoder(drm->fd,
|
|
|
|
drm_conn->encoder_id);
|
|
|
|
drm_conn->encoder_id);
|
|
|
|
|
|
|
|
|
|
|
|
int index = -1;
|
|
|
|
ssize_t index = -1;
|
|
|
|
struct wlr_drm_connector *c, *wlr_conn = NULL;
|
|
|
|
struct wlr_drm_connector *c, *wlr_conn = NULL;
|
|
|
|
wl_list_for_each(c, &drm->outputs, link) {
|
|
|
|
wl_list_for_each(c, &drm->outputs, link) {
|
|
|
|
index++;
|
|
|
|
index++;
|
|
|
@ -1086,7 +1093,7 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
|
|
|
wlr_conn->old_crtc = drmModeGetCrtc(drm->fd, curr_enc->crtc_id);
|
|
|
|
wlr_conn->old_crtc = drmModeGetCrtc(drm->fd, curr_enc->crtc_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wl_list_insert(&drm->outputs, &wlr_conn->link);
|
|
|
|
wl_list_insert(drm->outputs.prev, &wlr_conn->link);
|
|
|
|
wlr_log(WLR_INFO, "Found connector '%s'", wlr_conn->output.name);
|
|
|
|
wlr_log(WLR_INFO, "Found connector '%s'", wlr_conn->output.name);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
seen[index] = true;
|
|
|
|
seen[index] = true;
|
|
|
@ -1167,7 +1174,8 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
|
|
|
wl_list_insert(&wlr_conn->output.modes, &mode->wlr_mode.link);
|
|
|
|
wl_list_insert(&wlr_conn->output.modes, &mode->wlr_mode.link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_conn->possible_crtc = get_possible_crtcs(drm->fd, wlr_conn->id);
|
|
|
|
wlr_conn->possible_crtc = get_possible_crtcs(drm->fd, res, drm_conn,
|
|
|
|
|
|
|
|
wlr_conn->props.path != 0);
|
|
|
|
if (wlr_conn->possible_crtc == 0) {
|
|
|
|
if (wlr_conn->possible_crtc == 0) {
|
|
|
|
wlr_log(WLR_ERROR, "No CRTC possible for connector '%s'",
|
|
|
|
wlr_log(WLR_ERROR, "No CRTC possible for connector '%s'",
|
|
|
|
wlr_conn->output.name);
|
|
|
|
wlr_conn->output.name);
|
|
|
@ -1178,7 +1186,8 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
|
|
|
|
|
|
|
|
|
|
|
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
|
|
|
|
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
|
|
|
|
new_outputs[new_outputs_len++] = wlr_conn;
|
|
|
|
new_outputs[new_outputs_len++] = wlr_conn;
|
|
|
|
} else if (wlr_conn->state == WLR_DRM_CONN_CONNECTED &&
|
|
|
|
} else if ((wlr_conn->state == WLR_DRM_CONN_CONNECTED ||
|
|
|
|
|
|
|
|
wlr_conn->state == WLR_DRM_CONN_NEEDS_MODESET) &&
|
|
|
|
drm_conn->connection != DRM_MODE_CONNECTED) {
|
|
|
|
drm_conn->connection != DRM_MODE_CONNECTED) {
|
|
|
|
wlr_log(WLR_INFO, "'%s' disconnected", wlr_conn->output.name);
|
|
|
|
wlr_log(WLR_INFO, "'%s' disconnected", wlr_conn->output.name);
|
|
|
|
|
|
|
|
|
|
|
@ -1191,9 +1200,11 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
|
|
|
|
|
|
|
|
|
|
|
|
drmModeFreeResources(res);
|
|
|
|
drmModeFreeResources(res);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate in reverse order because we'll remove items from the list and
|
|
|
|
|
|
|
|
// still want indices to remain correct.
|
|
|
|
struct wlr_drm_connector *conn, *tmp_conn;
|
|
|
|
struct wlr_drm_connector *conn, *tmp_conn;
|
|
|
|
size_t index = wl_list_length(&drm->outputs);
|
|
|
|
size_t index = wl_list_length(&drm->outputs);
|
|
|
|
wl_list_for_each_safe(conn, tmp_conn, &drm->outputs, link) {
|
|
|
|
wl_list_for_each_reverse_safe(conn, tmp_conn, &drm->outputs, link) {
|
|
|
|
index--;
|
|
|
|
index--;
|
|
|
|
if (index >= seen_len || seen[index]) {
|
|
|
|
if (index >= seen_len || seen[index]) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|