2022-05-27 14:54:43 +02:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
2023-01-25 16:07:06 +01:00
|
|
|
#include <drm_fourcc.h>
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <stdlib.h>
|
2022-05-27 14:54:43 +02:00
|
|
|
#include <stdio.h>
|
2018-02-12 21:29:23 +01:00
|
|
|
#include <wlr/util/log.h>
|
2017-08-09 10:43:01 +02:00
|
|
|
#include <xf86drm.h>
|
|
|
|
#include <xf86drmMode.h>
|
2017-09-30 08:03:34 +02:00
|
|
|
#include "backend/drm/drm.h"
|
2017-09-30 08:11:41 +02:00
|
|
|
#include "backend/drm/iface.h"
|
2017-09-30 08:03:34 +02:00
|
|
|
#include "backend/drm/util.h"
|
2017-08-09 10:43:01 +02:00
|
|
|
|
2022-05-27 14:54:43 +02:00
|
|
|
static char *atomic_commit_flags_str(uint32_t flags) {
|
|
|
|
const char *const l[] = {
|
|
|
|
(flags & DRM_MODE_PAGE_FLIP_EVENT) ? "PAGE_FLIP_EVENT" : NULL,
|
|
|
|
(flags & DRM_MODE_PAGE_FLIP_ASYNC) ? "PAGE_FLIP_ASYNC" : NULL,
|
|
|
|
(flags & DRM_MODE_ATOMIC_TEST_ONLY) ? "ATOMIC_TEST_ONLY" : NULL,
|
|
|
|
(flags & DRM_MODE_ATOMIC_NONBLOCK) ? "ATOMIC_NONBLOCK" : NULL,
|
|
|
|
(flags & DRM_MODE_ATOMIC_ALLOW_MODESET) ? "ATOMIC_ALLOW_MODESET" : NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
char *buf = NULL;
|
|
|
|
size_t size = 0;
|
|
|
|
FILE *f = open_memstream(&buf, &size);
|
|
|
|
if (f == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < sizeof(l) / sizeof(l[0]); i++) {
|
|
|
|
if (l[i] == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (ftell(f) > 0) {
|
|
|
|
fprintf(f, " | ");
|
|
|
|
}
|
|
|
|
fprintf(f, "%s", l[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ftell(f) == 0) {
|
|
|
|
fprintf(f, "none");
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2017-08-09 10:43:01 +02:00
|
|
|
struct atomic {
|
|
|
|
drmModeAtomicReq *req;
|
|
|
|
bool failed;
|
|
|
|
};
|
|
|
|
|
2020-05-09 18:46:17 +02:00
|
|
|
static void atomic_begin(struct atomic *atom) {
|
2023-07-07 14:34:56 +02:00
|
|
|
*atom = (struct atomic){0};
|
2017-08-09 10:43:01 +02:00
|
|
|
|
2020-05-09 18:46:17 +02:00
|
|
|
atom->req = drmModeAtomicAlloc();
|
|
|
|
if (!atom->req) {
|
|
|
|
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
|
|
|
atom->failed = true;
|
|
|
|
return;
|
2017-08-09 10:43:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-09 18:46:17 +02:00
|
|
|
static bool atomic_commit(struct atomic *atom,
|
|
|
|
struct wlr_drm_connector *conn, uint32_t flags) {
|
2020-12-09 14:31:06 +01:00
|
|
|
struct wlr_drm_backend *drm = conn->backend;
|
2017-08-09 10:43:01 +02:00
|
|
|
if (atom->failed) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-05-09 18:46:17 +02:00
|
|
|
int ret = drmModeAtomicCommit(drm->fd, atom->req, flags, drm);
|
2021-04-06 15:44:32 +02:00
|
|
|
if (ret != 0) {
|
|
|
|
wlr_drm_conn_log_errno(conn,
|
|
|
|
(flags & DRM_MODE_ATOMIC_TEST_ONLY) ? WLR_DEBUG : WLR_ERROR,
|
2022-05-27 14:54:43 +02:00
|
|
|
"Atomic commit failed");
|
|
|
|
char *flags_str = atomic_commit_flags_str(flags);
|
|
|
|
wlr_log(WLR_DEBUG, "(Atomic commit flags: %s)",
|
|
|
|
flags_str ? flags_str : "<error>");
|
|
|
|
free(flags_str);
|
2020-05-09 18:46:17 +02:00
|
|
|
return false;
|
2017-08-09 10:43:01 +02:00
|
|
|
}
|
|
|
|
|
2020-05-09 18:46:17 +02:00
|
|
|
return true;
|
|
|
|
}
|
2017-08-09 10:43:01 +02:00
|
|
|
|
2020-05-09 18:46:17 +02:00
|
|
|
static void atomic_finish(struct atomic *atom) {
|
|
|
|
drmModeAtomicFree(atom->req);
|
2017-08-09 10:43:01 +02:00
|
|
|
}
|
|
|
|
|
2020-02-11 00:38:43 +01:00
|
|
|
static void atomic_add(struct atomic *atom, uint32_t id, uint32_t prop, uint64_t val) {
|
2017-08-09 10:43:01 +02:00
|
|
|
if (!atom->failed && drmModeAtomicAddProperty(atom->req, id, prop, val) < 0) {
|
2018-07-09 23:49:54 +02:00
|
|
|
wlr_log_errno(WLR_ERROR, "Failed to add atomic DRM property");
|
2017-08-09 10:43:01 +02:00
|
|
|
atom->failed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-18 19:17:33 +02:00
|
|
|
bool create_mode_blob(struct wlr_drm_backend *drm,
|
2021-08-10 18:47:14 +02:00
|
|
|
struct wlr_drm_connector *conn,
|
|
|
|
const struct wlr_drm_connector_state *state, uint32_t *blob_id) {
|
|
|
|
if (!state->active) {
|
2020-05-07 21:11:43 +02:00
|
|
|
*blob_id = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-08-10 18:47:14 +02:00
|
|
|
if (drmModeCreatePropertyBlob(drm->fd, &state->mode,
|
2020-05-07 21:11:43 +02:00
|
|
|
sizeof(drmModeModeInfo), blob_id)) {
|
|
|
|
wlr_log_errno(WLR_ERROR, "Unable to create mode property blob");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-08-18 19:17:33 +02:00
|
|
|
bool create_gamma_lut_blob(struct wlr_drm_backend *drm,
|
2020-05-14 18:27:02 +02:00
|
|
|
size_t size, const uint16_t *lut, uint32_t *blob_id) {
|
|
|
|
if (size == 0) {
|
2020-05-07 17:50:40 +02:00
|
|
|
*blob_id = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-10-03 07:51:07 +02:00
|
|
|
struct drm_color_lut *gamma = malloc(size * sizeof(*gamma));
|
2020-05-07 17:50:40 +02:00
|
|
|
if (gamma == NULL) {
|
|
|
|
wlr_log(WLR_ERROR, "Failed to allocate gamma table");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-05-14 18:27:02 +02:00
|
|
|
const uint16_t *r = lut;
|
|
|
|
const uint16_t *g = lut + size;
|
|
|
|
const uint16_t *b = lut + 2 * size;
|
2020-05-07 17:50:40 +02:00
|
|
|
for (size_t i = 0; i < size; i++) {
|
|
|
|
gamma[i].red = r[i];
|
|
|
|
gamma[i].green = g[i];
|
|
|
|
gamma[i].blue = b[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drmModeCreatePropertyBlob(drm->fd, gamma,
|
2023-10-03 07:51:07 +02:00
|
|
|
size * sizeof(*gamma), blob_id) != 0) {
|
2020-05-14 18:27:02 +02:00
|
|
|
wlr_log_errno(WLR_ERROR, "Unable to create gamma LUT property blob");
|
2020-05-07 17:50:40 +02:00
|
|
|
free(gamma);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
free(gamma);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-06-12 12:13:21 +02:00
|
|
|
bool create_fb_damage_clips_blob(struct wlr_drm_backend *drm,
|
2023-02-21 10:21:37 +01:00
|
|
|
int width, int height, const pixman_region32_t *damage, uint32_t *blob_id) {
|
2023-06-12 12:13:21 +02:00
|
|
|
if (!pixman_region32_not_empty(damage)) {
|
|
|
|
*blob_id = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_t clipped;
|
|
|
|
pixman_region32_init(&clipped);
|
|
|
|
pixman_region32_intersect_rect(&clipped, damage, 0, 0, width, height);
|
|
|
|
|
|
|
|
int rects_len;
|
|
|
|
const pixman_box32_t *rects = pixman_region32_rectangles(&clipped, &rects_len);
|
|
|
|
int ret = drmModeCreatePropertyBlob(drm->fd, rects, sizeof(*rects) * rects_len, blob_id);
|
|
|
|
pixman_region32_fini(&clipped);
|
|
|
|
if (ret != 0) {
|
|
|
|
wlr_log_errno(WLR_ERROR, "Failed to create FB_DAMAGE_CLIPS property blob");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-01-25 16:07:06 +01:00
|
|
|
static uint64_t max_bpc_for_format(uint32_t format) {
|
|
|
|
switch (format) {
|
|
|
|
case DRM_FORMAT_XRGB2101010:
|
|
|
|
case DRM_FORMAT_ARGB2101010:
|
|
|
|
case DRM_FORMAT_XBGR2101010:
|
|
|
|
case DRM_FORMAT_ABGR2101010:
|
|
|
|
return 10;
|
|
|
|
case DRM_FORMAT_XBGR16161616F:
|
|
|
|
case DRM_FORMAT_ABGR16161616F:
|
|
|
|
case DRM_FORMAT_XBGR16161616:
|
|
|
|
case DRM_FORMAT_ABGR16161616:
|
|
|
|
return 16;
|
|
|
|
default:
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint64_t pick_max_bpc(struct wlr_drm_connector *conn, struct wlr_drm_fb *fb) {
|
|
|
|
uint32_t format = DRM_FORMAT_INVALID;
|
|
|
|
struct wlr_dmabuf_attributes attribs = {0};
|
|
|
|
if (wlr_buffer_get_dmabuf(fb->wlr_buf, &attribs)) {
|
|
|
|
format = attribs.format;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t target_bpc = max_bpc_for_format(format);
|
|
|
|
if (target_bpc < conn->max_bpc_bounds[0]) {
|
|
|
|
target_bpc = conn->max_bpc_bounds[0];
|
|
|
|
}
|
|
|
|
if (target_bpc > conn->max_bpc_bounds[1]) {
|
|
|
|
target_bpc = conn->max_bpc_bounds[1];
|
|
|
|
}
|
|
|
|
return target_bpc;
|
|
|
|
}
|
|
|
|
|
2020-05-18 10:34:24 +02:00
|
|
|
static void commit_blob(struct wlr_drm_backend *drm,
|
|
|
|
uint32_t *current, uint32_t next) {
|
|
|
|
if (*current == next) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*current != 0) {
|
|
|
|
drmModeDestroyPropertyBlob(drm->fd, *current);
|
|
|
|
}
|
|
|
|
*current = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rollback_blob(struct wlr_drm_backend *drm,
|
|
|
|
uint32_t *current, uint32_t next) {
|
|
|
|
if (*current == next) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (next != 0) {
|
|
|
|
drmModeDestroyPropertyBlob(drm->fd, next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-12 09:25:40 +01:00
|
|
|
static void plane_disable(struct atomic *atom, struct wlr_drm_plane *plane) {
|
2017-08-09 10:43:01 +02:00
|
|
|
uint32_t id = plane->id;
|
|
|
|
const union wlr_drm_plane_props *props = &plane->props;
|
2020-02-12 09:25:40 +01:00
|
|
|
atomic_add(atom, id, props->fb_id, 0);
|
|
|
|
atomic_add(atom, id, props->crtc_id, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_plane_props(struct atomic *atom, struct wlr_drm_backend *drm,
|
2022-12-06 17:28:08 +01:00
|
|
|
struct wlr_drm_plane *plane, struct wlr_drm_fb *fb, uint32_t crtc_id,
|
|
|
|
int32_t x, int32_t y) {
|
2020-02-12 09:25:40 +01:00
|
|
|
uint32_t id = plane->id;
|
|
|
|
const union wlr_drm_plane_props *props = &plane->props;
|
2022-12-06 17:28:08 +01:00
|
|
|
|
2020-12-22 17:07:29 +01:00
|
|
|
if (fb == NULL) {
|
2022-12-06 17:23:18 +01:00
|
|
|
wlr_log(WLR_ERROR, "Failed to acquire FB for plane %"PRIu32, plane->id);
|
|
|
|
atom->failed = true;
|
|
|
|
return;
|
2020-02-12 09:25:40 +01:00
|
|
|
}
|
2017-08-09 10:43:01 +02:00
|
|
|
|
2021-08-23 17:41:08 +02:00
|
|
|
uint32_t width = fb->wlr_buf->width;
|
|
|
|
uint32_t height = fb->wlr_buf->height;
|
2020-12-18 16:24:36 +01:00
|
|
|
|
2017-08-09 10:43:01 +02:00
|
|
|
// The src_* properties are in 16.16 fixed point
|
|
|
|
atomic_add(atom, id, props->src_x, 0);
|
|
|
|
atomic_add(atom, id, props->src_y, 0);
|
2020-12-18 16:24:36 +01:00
|
|
|
atomic_add(atom, id, props->src_w, (uint64_t)width << 16);
|
|
|
|
atomic_add(atom, id, props->src_h, (uint64_t)height << 16);
|
|
|
|
atomic_add(atom, id, props->crtc_w, width);
|
|
|
|
atomic_add(atom, id, props->crtc_h, height);
|
2020-12-15 12:21:40 +01:00
|
|
|
atomic_add(atom, id, props->fb_id, fb->id);
|
2017-08-09 10:43:01 +02:00
|
|
|
atomic_add(atom, id, props->crtc_id, crtc_id);
|
2020-02-12 09:25:40 +01:00
|
|
|
atomic_add(atom, id, props->crtc_x, (uint64_t)x);
|
|
|
|
atomic_add(atom, id, props->crtc_y, (uint64_t)y);
|
2017-08-09 10:43:01 +02:00
|
|
|
}
|
|
|
|
|
2021-07-08 16:31:09 +02:00
|
|
|
static bool atomic_crtc_commit(struct wlr_drm_connector *conn,
|
2021-08-10 18:47:14 +02:00
|
|
|
const struct wlr_drm_connector_state *state, uint32_t flags,
|
|
|
|
bool test_only) {
|
2021-07-08 16:31:09 +02:00
|
|
|
struct wlr_drm_backend *drm = conn->backend;
|
2020-05-14 18:27:02 +02:00
|
|
|
struct wlr_output *output = &conn->output;
|
2020-02-12 09:25:40 +01:00
|
|
|
struct wlr_drm_crtc *crtc = conn->crtc;
|
|
|
|
|
2021-08-10 18:47:14 +02:00
|
|
|
bool modeset = state->modeset;
|
|
|
|
bool active = state->active;
|
2021-04-06 17:06:37 +02:00
|
|
|
|
2020-05-18 10:34:24 +02:00
|
|
|
uint32_t mode_id = crtc->mode_id;
|
2021-04-06 17:06:37 +02:00
|
|
|
if (modeset) {
|
2021-04-06 17:14:17 +02:00
|
|
|
if (!create_mode_blob(drm, conn, state, &mode_id)) {
|
2017-08-09 10:43:01 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-18 10:34:24 +02:00
|
|
|
uint32_t gamma_lut = crtc->gamma_lut;
|
2021-08-10 18:47:14 +02:00
|
|
|
if (state->base->committed & WLR_OUTPUT_STATE_GAMMA_LUT) {
|
2020-05-14 18:27:02 +02:00
|
|
|
// Fallback to legacy gamma interface when gamma properties are not
|
|
|
|
// available (can happen on older Intel GPUs that support gamma but not
|
|
|
|
// degamma).
|
2020-05-07 17:50:40 +02:00
|
|
|
if (crtc->props.gamma_lut == 0) {
|
2020-05-14 18:27:02 +02:00
|
|
|
if (!drm_legacy_crtc_set_gamma(drm, crtc,
|
2021-08-10 18:47:14 +02:00
|
|
|
state->base->gamma_lut_size,
|
|
|
|
state->base->gamma_lut)) {
|
2020-05-07 17:50:40 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
2021-08-10 18:47:14 +02:00
|
|
|
if (!create_gamma_lut_blob(drm, state->base->gamma_lut_size,
|
|
|
|
state->base->gamma_lut, &gamma_lut)) {
|
2020-05-07 17:50:40 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-21 15:58:01 +02:00
|
|
|
uint32_t fb_damage_clips = 0;
|
2021-08-10 18:47:14 +02:00
|
|
|
if ((state->base->committed & WLR_OUTPUT_STATE_DAMAGE) &&
|
2021-07-21 15:58:01 +02:00
|
|
|
crtc->primary->props.fb_damage_clips != 0) {
|
2023-02-21 10:21:37 +01:00
|
|
|
create_fb_damage_clips_blob(drm, state->primary_fb->wlr_buf->width,
|
|
|
|
state->primary_fb->wlr_buf->height, &state->base->damage, &fb_damage_clips);
|
2021-07-21 15:58:01 +02:00
|
|
|
}
|
|
|
|
|
2020-05-27 16:43:19 +02:00
|
|
|
bool prev_vrr_enabled =
|
|
|
|
output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED;
|
|
|
|
bool vrr_enabled = prev_vrr_enabled;
|
2021-06-18 12:40:07 +02:00
|
|
|
if ((state->base->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED)) {
|
|
|
|
if (!drm_connector_supports_vrr(conn)) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-08-10 18:47:14 +02:00
|
|
|
vrr_enabled = state->base->adaptive_sync_enabled;
|
2020-05-27 16:43:19 +02:00
|
|
|
}
|
|
|
|
|
2021-07-08 15:56:01 +02:00
|
|
|
if (test_only) {
|
|
|
|
flags |= DRM_MODE_ATOMIC_TEST_ONLY;
|
|
|
|
}
|
2021-04-06 17:06:37 +02:00
|
|
|
if (modeset) {
|
2018-01-15 21:49:37 +01:00
|
|
|
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
2022-05-27 13:21:55 +02:00
|
|
|
} else if (!test_only && (state->base->committed & WLR_OUTPUT_STATE_BUFFER)) {
|
|
|
|
// The wlr_output API requires non-modeset commits with a new buffer to
|
|
|
|
// wait for the frame event. However compositors often perform
|
|
|
|
// non-modesets commits without a new buffer without waiting for the
|
|
|
|
// frame event. In that case we need to make the KMS commit blocking,
|
|
|
|
// otherwise the kernel will error out with EBUSY.
|
2018-01-15 21:49:37 +01:00
|
|
|
flags |= DRM_MODE_ATOMIC_NONBLOCK;
|
|
|
|
}
|
2017-08-09 10:43:01 +02:00
|
|
|
|
2018-01-15 21:49:37 +01:00
|
|
|
struct atomic atom;
|
2020-05-09 18:46:17 +02:00
|
|
|
atomic_begin(&atom);
|
2021-04-06 17:14:17 +02:00
|
|
|
atomic_add(&atom, conn->id, conn->props.crtc_id, active ? crtc->id : 0);
|
|
|
|
if (modeset && active && conn->props.link_status != 0) {
|
2018-10-04 14:11:37 +02:00
|
|
|
atomic_add(&atom, conn->id, conn->props.link_status,
|
|
|
|
DRM_MODE_LINK_STATUS_GOOD);
|
|
|
|
}
|
2022-06-03 16:02:40 +02:00
|
|
|
if (active && conn->props.content_type != 0) {
|
|
|
|
atomic_add(&atom, conn->id, conn->props.content_type,
|
|
|
|
DRM_MODE_CONTENT_TYPE_GRAPHICS);
|
|
|
|
}
|
2023-01-25 16:07:06 +01:00
|
|
|
if (modeset && active && conn->props.max_bpc != 0 && conn->max_bpc_bounds[1] != 0) {
|
|
|
|
atomic_add(&atom, conn->id, conn->props.max_bpc, pick_max_bpc(conn, state->primary_fb));
|
2022-06-07 15:03:39 +02:00
|
|
|
}
|
2020-05-18 10:34:24 +02:00
|
|
|
atomic_add(&atom, crtc->id, crtc->props.mode_id, mode_id);
|
2021-04-06 17:14:17 +02:00
|
|
|
atomic_add(&atom, crtc->id, crtc->props.active, active);
|
|
|
|
if (active) {
|
2020-05-14 17:26:30 +02:00
|
|
|
if (crtc->props.gamma_lut != 0) {
|
2020-05-18 10:34:24 +02:00
|
|
|
atomic_add(&atom, crtc->id, crtc->props.gamma_lut, gamma_lut);
|
2020-05-14 17:26:30 +02:00
|
|
|
}
|
2020-05-27 16:43:19 +02:00
|
|
|
if (crtc->props.vrr_enabled != 0) {
|
|
|
|
atomic_add(&atom, crtc->id, crtc->props.vrr_enabled, vrr_enabled);
|
|
|
|
}
|
2022-12-06 17:39:23 +01:00
|
|
|
set_plane_props(&atom, drm, crtc->primary, state->primary_fb, crtc->id,
|
|
|
|
0, 0);
|
2021-07-21 15:58:01 +02:00
|
|
|
if (crtc->primary->props.fb_damage_clips != 0) {
|
|
|
|
atomic_add(&atom, crtc->primary->id,
|
|
|
|
crtc->primary->props.fb_damage_clips, fb_damage_clips);
|
|
|
|
}
|
2020-05-07 21:11:43 +02:00
|
|
|
if (crtc->cursor) {
|
2020-05-27 18:16:03 +02:00
|
|
|
if (drm_connector_is_cursor_visible(conn)) {
|
2022-12-06 17:34:05 +01:00
|
|
|
set_plane_props(&atom, drm, crtc->cursor, get_next_cursor_fb(conn),
|
2022-12-06 17:28:08 +01:00
|
|
|
crtc->id, conn->cursor_x, conn->cursor_y);
|
2020-05-07 21:11:43 +02:00
|
|
|
} else {
|
|
|
|
plane_disable(&atom, crtc->cursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
plane_disable(&atom, crtc->primary);
|
|
|
|
if (crtc->cursor) {
|
2020-02-12 09:25:40 +01:00
|
|
|
plane_disable(&atom, crtc->cursor);
|
|
|
|
}
|
|
|
|
}
|
2020-02-11 00:38:43 +01:00
|
|
|
|
2020-05-09 18:46:17 +02:00
|
|
|
bool ok = atomic_commit(&atom, conn, flags);
|
|
|
|
atomic_finish(&atom);
|
2020-05-18 10:34:24 +02:00
|
|
|
|
2021-07-08 15:56:01 +02:00
|
|
|
if (ok && !test_only) {
|
2020-05-18 10:34:24 +02:00
|
|
|
commit_blob(drm, &crtc->mode_id, mode_id);
|
|
|
|
commit_blob(drm, &crtc->gamma_lut, gamma_lut);
|
2020-05-27 16:43:19 +02:00
|
|
|
|
|
|
|
if (vrr_enabled != prev_vrr_enabled) {
|
|
|
|
output->adaptive_sync_status = vrr_enabled ?
|
|
|
|
WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED :
|
|
|
|
WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED;
|
2020-12-24 17:55:45 +01:00
|
|
|
wlr_drm_conn_log(conn, WLR_DEBUG, "VRR %s",
|
|
|
|
vrr_enabled ? "enabled" : "disabled");
|
2020-05-27 16:43:19 +02:00
|
|
|
}
|
2020-05-18 10:34:24 +02:00
|
|
|
} else {
|
|
|
|
rollback_blob(drm, &crtc->mode_id, mode_id);
|
|
|
|
rollback_blob(drm, &crtc->gamma_lut, gamma_lut);
|
|
|
|
}
|
|
|
|
|
2021-07-21 15:58:01 +02:00
|
|
|
if (fb_damage_clips != 0 &&
|
|
|
|
drmModeDestroyPropertyBlob(drm->fd, fb_damage_clips) != 0) {
|
|
|
|
wlr_log_errno(WLR_ERROR, "Failed to destroy FB_DAMAGE_CLIPS property blob");
|
|
|
|
}
|
|
|
|
|
2020-05-09 18:46:17 +02:00
|
|
|
return ok;
|
2017-08-09 10:43:01 +02:00
|
|
|
}
|
|
|
|
|
2017-10-02 10:44:33 +02:00
|
|
|
const struct wlr_drm_interface atomic_iface = {
|
2020-05-07 19:20:56 +02:00
|
|
|
.crtc_commit = atomic_crtc_commit,
|
2017-08-09 10:43:01 +02:00
|
|
|
};
|