mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
backend/drm: remove wlr_drm_crtc.pending_modeset
Replace it with a new drm_connector_state_is_modeset function that decides whether a modeset is necessary directly from the wlr_output_state which is going to be applied.
This commit is contained in:
parent
c9c2d7539c
commit
485ecc11a6
4 changed files with 14 additions and 11 deletions
|
@ -169,8 +169,10 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
|
||||||
struct wlr_output *output = &conn->output;
|
struct wlr_output *output = &conn->output;
|
||||||
struct wlr_drm_crtc *crtc = conn->crtc;
|
struct wlr_drm_crtc *crtc = conn->crtc;
|
||||||
|
|
||||||
|
bool modeset = drm_connector_state_is_modeset(state);
|
||||||
|
|
||||||
uint32_t mode_id = crtc->mode_id;
|
uint32_t mode_id = crtc->mode_id;
|
||||||
if (crtc->pending_modeset) {
|
if (modeset) {
|
||||||
if (!create_mode_blob(drm, crtc, &mode_id)) {
|
if (!create_mode_blob(drm, crtc, &mode_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +205,7 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
|
||||||
vrr_enabled = state->adaptive_sync_enabled;
|
vrr_enabled = state->adaptive_sync_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crtc->pending_modeset) {
|
if (modeset) {
|
||||||
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||||
} else if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
|
} else if (!(flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
|
||||||
flags |= DRM_MODE_ATOMIC_NONBLOCK;
|
flags |= DRM_MODE_ATOMIC_NONBLOCK;
|
||||||
|
@ -213,7 +215,7 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm,
|
||||||
atomic_begin(&atom);
|
atomic_begin(&atom);
|
||||||
atomic_add(&atom, conn->id, conn->props.crtc_id,
|
atomic_add(&atom, conn->id, conn->props.crtc_id,
|
||||||
crtc->pending.active ? crtc->id : 0);
|
crtc->pending.active ? crtc->id : 0);
|
||||||
if (crtc->pending_modeset && crtc->pending.active &&
|
if (modeset && crtc->pending.active &&
|
||||||
conn->props.link_status != 0) {
|
conn->props.link_status != 0) {
|
||||||
atomic_add(&atom, conn->id, conn->props.link_status,
|
atomic_add(&atom, conn->id, conn->props.link_status,
|
||||||
DRM_MODE_LINK_STATUS_GOOD);
|
DRM_MODE_LINK_STATUS_GOOD);
|
||||||
|
|
|
@ -345,7 +345,6 @@ static bool drm_crtc_commit(struct wlr_drm_connector *conn,
|
||||||
drm_fb_clear(&crtc->cursor->pending_fb);
|
drm_fb_clear(&crtc->cursor->pending_fb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
crtc->pending_modeset = false;
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +357,7 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn,
|
||||||
// page-flip, either a blocking modeset. When performing a blocking modeset
|
// page-flip, either a blocking modeset. When performing a blocking modeset
|
||||||
// we'll wait for all queued page-flips to complete, so we don't need this
|
// we'll wait for all queued page-flips to complete, so we don't need this
|
||||||
// safeguard.
|
// safeguard.
|
||||||
if (conn->pending_page_flip_crtc && !crtc->pending_modeset) {
|
if (conn->pending_page_flip_crtc && !drm_connector_state_is_modeset(state)) {
|
||||||
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to page-flip output: "
|
wlr_drm_conn_log(conn, WLR_ERROR, "Failed to page-flip output: "
|
||||||
"a page-flip is already pending");
|
"a page-flip is already pending");
|
||||||
return false;
|
return false;
|
||||||
|
@ -681,7 +680,6 @@ static bool drm_connector_init_renderer(struct wlr_drm_connector *conn,
|
||||||
}
|
}
|
||||||
struct wlr_drm_plane *plane = crtc->primary;
|
struct wlr_drm_plane *plane = crtc->primary;
|
||||||
|
|
||||||
crtc->pending_modeset = true;
|
|
||||||
crtc->pending.active = true;
|
crtc->pending.active = true;
|
||||||
crtc->pending.mode = mode;
|
crtc->pending.mode = mode;
|
||||||
|
|
||||||
|
@ -705,7 +703,6 @@ static bool drm_connector_init_renderer(struct wlr_drm_connector *conn,
|
||||||
"retrying without modifiers");
|
"retrying without modifiers");
|
||||||
modifiers = false;
|
modifiers = false;
|
||||||
|
|
||||||
crtc->pending_modeset = true;
|
|
||||||
crtc->pending.active = true;
|
crtc->pending.active = true;
|
||||||
crtc->pending.mode = mode;
|
crtc->pending.mode = mode;
|
||||||
|
|
||||||
|
@ -755,7 +752,6 @@ bool drm_connector_set_mode(struct wlr_drm_connector *conn,
|
||||||
|
|
||||||
if (wlr_mode == NULL) {
|
if (wlr_mode == NULL) {
|
||||||
if (conn->crtc != NULL) {
|
if (conn->crtc != NULL) {
|
||||||
conn->crtc->pending_modeset = true;
|
|
||||||
conn->crtc->pending.active = false;
|
conn->crtc->pending.active = false;
|
||||||
if (!drm_crtc_commit(conn, state, 0)) {
|
if (!drm_crtc_commit(conn, state, 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1041,6 +1037,11 @@ uint32_t wlr_drm_connector_get_id(struct wlr_output *output) {
|
||||||
return conn->id;
|
return conn->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool drm_connector_state_is_modeset(const struct wlr_output_state *state) {
|
||||||
|
return state->committed &
|
||||||
|
(WLR_OUTPUT_STATE_ENABLED | WLR_OUTPUT_STATE_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
static const int32_t subpixel_map[] = {
|
static const int32_t subpixel_map[] = {
|
||||||
[DRM_MODE_SUBPIXEL_UNKNOWN] = WL_OUTPUT_SUBPIXEL_UNKNOWN,
|
[DRM_MODE_SUBPIXEL_UNKNOWN] = WL_OUTPUT_SUBPIXEL_UNKNOWN,
|
||||||
[DRM_MODE_SUBPIXEL_HORIZONTAL_RGB] = WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB,
|
[DRM_MODE_SUBPIXEL_HORIZONTAL_RGB] = WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB,
|
||||||
|
@ -1059,7 +1060,6 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) {
|
||||||
wlr_drm_conn_log(conn, WLR_DEBUG, "De-allocating CRTC %zu",
|
wlr_drm_conn_log(conn, WLR_DEBUG, "De-allocating CRTC %zu",
|
||||||
conn->crtc - drm->crtcs);
|
conn->crtc - drm->crtcs);
|
||||||
|
|
||||||
conn->crtc->pending_modeset = true;
|
|
||||||
conn->crtc->pending.active = false;
|
conn->crtc->pending.active = false;
|
||||||
struct wlr_output_state state = {
|
struct wlr_output_state state = {
|
||||||
.committed = WLR_OUTPUT_STATE_ENABLED,
|
.committed = WLR_OUTPUT_STATE_ENABLED,
|
||||||
|
|
|
@ -26,7 +26,7 @@ static bool legacy_crtc_commit(struct wlr_drm_backend *drm,
|
||||||
fb_id = fb->id;
|
fb_id = fb->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crtc->pending_modeset) {
|
if (drm_connector_state_is_modeset(state)) {
|
||||||
uint32_t *conns = NULL;
|
uint32_t *conns = NULL;
|
||||||
size_t conns_len = 0;
|
size_t conns_len = 0;
|
||||||
drmModeModeInfo *mode = NULL;
|
drmModeModeInfo *mode = NULL;
|
||||||
|
|
|
@ -49,7 +49,6 @@ struct wlr_drm_crtc_state {
|
||||||
struct wlr_drm_crtc {
|
struct wlr_drm_crtc {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
bool pending_modeset;
|
|
||||||
struct wlr_drm_crtc_state pending, current;
|
struct wlr_drm_crtc_state pending, current;
|
||||||
|
|
||||||
// Atomic modesetting only
|
// Atomic modesetting only
|
||||||
|
@ -160,6 +159,8 @@ size_t drm_crtc_get_gamma_lut_size(struct wlr_drm_backend *drm,
|
||||||
|
|
||||||
struct wlr_drm_fb *plane_get_next_fb(struct wlr_drm_plane *plane);
|
struct wlr_drm_fb *plane_get_next_fb(struct wlr_drm_plane *plane);
|
||||||
|
|
||||||
|
bool drm_connector_state_is_modeset(const struct wlr_output_state *state);
|
||||||
|
|
||||||
#define wlr_drm_conn_log(conn, verb, fmt, ...) \
|
#define wlr_drm_conn_log(conn, verb, fmt, ...) \
|
||||||
wlr_log(verb, "connector %s: " fmt, conn->name, ##__VA_ARGS__)
|
wlr_log(verb, "connector %s: " fmt, conn->name, ##__VA_ARGS__)
|
||||||
#define wlr_drm_conn_log_errno(conn, verb, fmt, ...) \
|
#define wlr_drm_conn_log_errno(conn, verb, fmt, ...) \
|
||||||
|
|
Loading…
Reference in a new issue