diff options
author | Simon Ser <contact@emersion.fr> | 2020-05-09 16:50:50 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-10 09:20:46 +0200 |
commit | 06d5aa57809864e45e4c59460ab4e064fd1e2df7 (patch) | |
tree | d467756e1b6eb33651e550882e8114d076095ae5 | |
parent | da63d11d341e9e1bc3c0dcb040e2cc5d82a3959e (diff) |
backend/drm: GAMMA_LUT_SIZE isn't atomic
GAMMA_LUT_SIZE isn't an atomic property. It can be used with the legacy
interface too. So we can unify both codepaths and remove
wlr_drm_interface.crtc_get_gamma_size.
It's no guaranteed to exist though, so we still need to keep the
fallback.
-rw-r--r-- | backend/drm/atomic.c | 17 | ||||
-rw-r--r-- | backend/drm/drm.c | 18 | ||||
-rw-r--r-- | backend/drm/legacy.c | 6 | ||||
-rw-r--r-- | include/backend/drm/iface.h | 3 | ||||
-rw-r--r-- | include/backend/drm/properties.h | 4 |
5 files changed, 17 insertions, 31 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index d4f033f0..3060d671 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -240,23 +240,6 @@ static bool atomic_crtc_commit(struct wlr_drm_backend *drm, return true; } -static size_t atomic_crtc_get_gamma_size(struct wlr_drm_backend *drm, - struct wlr_drm_crtc *crtc) { - if (crtc->props.gamma_lut_size == 0) { - return legacy_iface.crtc_get_gamma_size(drm, crtc); - } - - uint64_t gamma_lut_size; - if (!get_drm_prop(drm->fd, crtc->id, crtc->props.gamma_lut_size, - &gamma_lut_size)) { - wlr_log(WLR_ERROR, "Unable to get gamma lut size"); - return 0; - } - - return (size_t)gamma_lut_size; -} - const struct wlr_drm_interface atomic_iface = { .crtc_commit = atomic_crtc_commit, - .crtc_get_gamma_size = atomic_crtc_get_gamma_size, }; diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 60df4348..8482b368 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -581,12 +581,24 @@ static void fill_empty_gamma_table(size_t size, static size_t drm_connector_get_gamma_size(struct wlr_output *output) { struct wlr_drm_connector *conn = get_drm_connector_from_output(output); struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend); + struct wlr_drm_crtc *crtc = conn->crtc; - if (conn->crtc) { - return drm->iface->crtc_get_gamma_size(drm, conn->crtc); + if (crtc == NULL) { + return 0; } - return 0; + if (crtc->props.gamma_lut_size == 0) { + return (size_t)crtc->legacy_crtc->gamma_size; + } + + uint64_t gamma_lut_size; + if (!get_drm_prop(drm->fd, crtc->id, crtc->props.gamma_lut_size, + &gamma_lut_size)) { + wlr_log(WLR_ERROR, "Unable to get gamma lut size"); + return 0; + } + + return gamma_lut_size; } bool set_drm_connector_gamma(struct wlr_output *output, size_t size, diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c index 09e7df16..c32d0399 100644 --- a/backend/drm/legacy.c +++ b/backend/drm/legacy.c @@ -117,12 +117,6 @@ bool drm_legacy_crtc_set_gamma(struct wlr_drm_backend *drm, return true; } -static size_t legacy_crtc_get_gamma_size(struct wlr_drm_backend *drm, - struct wlr_drm_crtc *crtc) { - return (size_t)crtc->legacy_crtc->gamma_size; -} - const struct wlr_drm_interface legacy_iface = { .crtc_commit = legacy_crtc_commit, - .crtc_get_gamma_size = legacy_crtc_get_gamma_size, }; diff --git a/include/backend/drm/iface.h b/include/backend/drm/iface.h index 6393579c..9377af03 100644 --- a/include/backend/drm/iface.h +++ b/include/backend/drm/iface.h @@ -16,9 +16,6 @@ struct wlr_drm_interface { // Commit al pending changes on a CRTC. bool (*crtc_commit)(struct wlr_drm_backend *drm, struct wlr_drm_connector *conn, uint32_t flags); - // Get the gamma lut size of a crtc - size_t (*crtc_get_gamma_size)(struct wlr_drm_backend *drm, - struct wlr_drm_crtc *crtc); }; extern const struct wlr_drm_interface atomic_iface; diff --git a/include/backend/drm/properties.h b/include/backend/drm/properties.h index 810a03a3..fba444aa 100644 --- a/include/backend/drm/properties.h +++ b/include/backend/drm/properties.h @@ -31,13 +31,13 @@ union wlr_drm_crtc_props { uint32_t rotation; uint32_t scaling_mode; uint32_t vrr_enabled; + uint32_t gamma_lut; + uint32_t gamma_lut_size; // atomic-modesetting only uint32_t active; uint32_t mode_id; - uint32_t gamma_lut; - uint32_t gamma_lut_size; }; uint32_t props[6]; }; |