mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
backend/drm: extract create_drm_connector()
Move a bit more logic out of the big loop in scan_drm_connectors().
This commit is contained in:
parent
4d04144b92
commit
92580a2f67
1 changed files with 29 additions and 21 deletions
|
@ -1139,6 +1139,33 @@ static struct wlr_drm_crtc *connector_get_current_crtc(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct wlr_drm_connector *create_drm_connector(struct wlr_drm_backend *drm,
|
||||
const drmModeConnector *drm_conn) {
|
||||
struct wlr_drm_connector *wlr_conn = calloc(1, sizeof(*wlr_conn));
|
||||
if (!wlr_conn) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wlr_conn->backend = drm;
|
||||
wlr_conn->status = DRM_MODE_DISCONNECTED;
|
||||
wlr_conn->id = drm_conn->connector_id;
|
||||
|
||||
const char *conn_name =
|
||||
drmModeGetConnectorTypeName(drm_conn->connector_type);
|
||||
if (conn_name == NULL) {
|
||||
conn_name = "Unknown";
|
||||
}
|
||||
|
||||
snprintf(wlr_conn->name, sizeof(wlr_conn->name),
|
||||
"%s-%"PRIu32, conn_name, drm_conn->connector_type_id);
|
||||
|
||||
wlr_conn->crtc = connector_get_current_crtc(wlr_conn, drm_conn);
|
||||
|
||||
wl_list_insert(drm->outputs.prev, &wlr_conn->link);
|
||||
return wlr_conn;
|
||||
}
|
||||
|
||||
static drmModeModeInfo *connector_get_current_mode(
|
||||
struct wlr_drm_connector *wlr_conn, const drmModeConnector *drm_conn) {
|
||||
struct wlr_drm_backend *drm = wlr_conn->backend;
|
||||
|
@ -1343,29 +1370,10 @@ void scan_drm_connectors(struct wlr_drm_backend *drm,
|
|||
}
|
||||
|
||||
if (!wlr_conn) {
|
||||
wlr_conn = calloc(1, sizeof(*wlr_conn));
|
||||
if (!wlr_conn) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
drmModeFreeConnector(drm_conn);
|
||||
wlr_conn = create_drm_connector(drm, drm_conn);
|
||||
if (wlr_conn == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wlr_conn->backend = drm;
|
||||
wlr_conn->status = DRM_MODE_DISCONNECTED;
|
||||
wlr_conn->id = drm_conn->connector_id;
|
||||
|
||||
const char *conn_name =
|
||||
drmModeGetConnectorTypeName(drm_conn->connector_type);
|
||||
if (conn_name == NULL) {
|
||||
conn_name = "Unknown";
|
||||
}
|
||||
|
||||
snprintf(wlr_conn->name, sizeof(wlr_conn->name),
|
||||
"%s-%"PRIu32, conn_name, drm_conn->connector_type_id);
|
||||
|
||||
wlr_conn->crtc = connector_get_current_crtc(wlr_conn, drm_conn);
|
||||
|
||||
wl_list_insert(drm->outputs.prev, &wlr_conn->link);
|
||||
wlr_log(WLR_INFO, "Found connector '%s'", wlr_conn->name);
|
||||
} else {
|
||||
seen[index] = true;
|
||||
|
|
Loading…
Reference in a new issue