aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-12-15 19:31:06 +0100
committerSimon Ser <contact@emersion.fr>2022-12-15 19:31:06 +0100
commit8b8921d57b9dfb733757d338c354014f41e86d59 (patch)
treef2501be4d67ce3a14d41fc183e3f4364d7ead3ae
parent8b18352318056a034257150fa29e49d117492173 (diff)
backend/drm: remove wlr_drm_crtc.legacy_crtc
We only need it for one thing: gamma size. Moreover, some bits in the drmModeCrtc will become out-of-date, for instance the current mode, so let's avoid caching the whole struct and only keep what we know won't change.
-rw-r--r--backend/drm/drm.c14
-rw-r--r--include/backend/drm/drm.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index a869e935..c2eec809 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -267,7 +267,15 @@ bool init_drm_resources(struct wlr_drm_backend *drm) {
for (size_t i = 0; i < drm->num_crtcs; ++i) {
struct wlr_drm_crtc *crtc = &drm->crtcs[i];
crtc->id = res->crtcs[i];
- crtc->legacy_crtc = drmModeGetCrtc(drm->fd, crtc->id);
+
+ drmModeCrtc *drm_crtc = drmModeGetCrtc(drm->fd, crtc->id);
+ if (drm_crtc == NULL) {
+ wlr_log_errno(WLR_ERROR, "drmModeGetCrtc failed");
+ goto error_res;
+ }
+ crtc->legacy_gamma_size = drm_crtc->gamma_size;
+ drmModeFreeCrtc(drm_crtc);
+
get_drm_crtc_props(drm->fd, crtc->id, &crtc->props);
}
@@ -294,8 +302,6 @@ void finish_drm_resources(struct wlr_drm_backend *drm) {
for (size_t i = 0; i < drm->num_crtcs; ++i) {
struct wlr_drm_crtc *crtc = &drm->crtcs[i];
- drmModeFreeCrtc(crtc->legacy_crtc);
-
if (crtc->mode_id) {
drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id);
}
@@ -669,7 +675,7 @@ static bool drm_connector_commit(struct wlr_output *output,
size_t drm_crtc_get_gamma_lut_size(struct wlr_drm_backend *drm,
struct wlr_drm_crtc *crtc) {
if (crtc->props.gamma_lut_size == 0 || drm->iface == &legacy_iface) {
- return (size_t)crtc->legacy_crtc->gamma_size;
+ return (size_t)crtc->legacy_gamma_size;
}
uint64_t gamma_lut_size;
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
index 16126ec2..e93b5eaf 100644
--- a/include/backend/drm/drm.h
+++ b/include/backend/drm/drm.h
@@ -41,7 +41,7 @@ struct wlr_drm_crtc {
uint32_t gamma_lut;
// Legacy only
- drmModeCrtc *legacy_crtc;
+ int legacy_gamma_size;
struct wlr_drm_plane *primary;
struct wlr_drm_plane *cursor;