70 lines
2.3 KiB
Diff
70 lines
2.3 KiB
Diff
From 39e8b5f4e5111a2e73b9c9d49481439c5a7eb90f Mon Sep 17 00:00:00 2001
|
|
From: Jeffy Chen <jeffy.chen@rock-chips.com>
|
|
Date: Mon, 1 Apr 2024 16:04:29 +0800
|
|
Subject: [PATCH 2/5] drm: Fallback to the first possible crtc
|
|
|
|
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
|
|
---
|
|
backend/drm/atomic.c | 1 +
|
|
backend/drm/drm.c | 18 ++++++++++++++++--
|
|
2 files changed, 17 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c
|
|
index 618a9f4..df9361a 100644
|
|
--- a/backend/drm/atomic.c
|
|
+++ b/backend/drm/atomic.c
|
|
@@ -322,6 +322,7 @@ static bool atomic_crtc_commit(struct wlr_drm_connector *conn,
|
|
|
|
struct atomic atom;
|
|
atomic_begin(&atom);
|
|
+ if (conn->props.crtc_id)
|
|
atomic_add(&atom, conn->id, conn->props.crtc_id, active ? crtc->id : 0);
|
|
if (modeset && active && conn->props.link_status != 0) {
|
|
atomic_add(&atom, conn->id, conn->props.link_status,
|
|
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
|
|
index 07880c4..6541f76 100644
|
|
--- a/backend/drm/drm.c
|
|
+++ b/backend/drm/drm.c
|
|
@@ -1305,7 +1305,7 @@ static void realloc_crtcs(struct wlr_drm_backend *drm,
|
|
}
|
|
}
|
|
|
|
-static struct wlr_drm_crtc *connector_get_current_crtc(
|
|
+static struct wlr_drm_crtc *connector_get_crtc(
|
|
struct wlr_drm_connector *wlr_conn, const drmModeConnector *drm_conn) {
|
|
struct wlr_drm_backend *drm = wlr_conn->backend;
|
|
|
|
@@ -1329,6 +1329,20 @@ static struct wlr_drm_crtc *connector_get_current_crtc(
|
|
}
|
|
crtc_id = enc->crtc_id;
|
|
drmModeFreeEncoder(enc);
|
|
+ } else {
|
|
+ /* If no active crtc was found, pick the first possible crtc */
|
|
+ uint32_t crtcs_for_connector = 0;
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < drm_conn->count_encoders; i++) {
|
|
+ drmModeEncoder *enc =
|
|
+ drmModeGetEncoder(drm->fd, drm_conn->encoders[i]);
|
|
+ crtcs_for_connector |= enc->possible_crtcs;
|
|
+ drmModeFreeEncoder(enc);
|
|
+ }
|
|
+
|
|
+ if (crtcs_for_connector != 0)
|
|
+ return &drm->crtcs[ffs(crtcs_for_connector) - 1];
|
|
}
|
|
if (crtc_id == 0) {
|
|
return NULL;
|
|
@@ -1372,7 +1386,7 @@ static struct wlr_drm_connector *create_drm_connector(struct wlr_drm_backend *dr
|
|
wlr_drm_conn_log(wlr_conn, WLR_ERROR, "No CRTC possible");
|
|
}
|
|
|
|
- wlr_conn->crtc = connector_get_current_crtc(wlr_conn, drm_conn);
|
|
+ wlr_conn->crtc = connector_get_crtc(wlr_conn, drm_conn);
|
|
|
|
wl_list_insert(drm->connectors.prev, &wlr_conn->link);
|
|
return wlr_conn;
|
|
--
|
|
2.20.1
|
|
|