aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-05-27 14:54:43 +0200
committerSimon Ser <contact@emersion.fr>2022-05-31 09:31:16 +0200
commit2563b79dc2c200899316d5659b0dd00ca26460b8 (patch)
tree6004817e50e6818c28d5cca17064ae3a1914fe3e /backend/drm
parent43020963d400c8aec0bd24896aab30825fee33e5 (diff)
backend/drm: improve atomic commit flag logging
We weren't logging all of the flags, which made debugging more difficult.
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/atomic.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c
index 53487914..cacb8e87 100644
--- a/backend/drm/atomic.c
+++ b/backend/drm/atomic.c
@@ -1,4 +1,6 @@
+#define _POSIX_C_SOURCE 200809L
#include <stdlib.h>
+#include <stdio.h>
#include <wlr/util/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -6,6 +8,41 @@
#include "backend/drm/iface.h"
#include "backend/drm/util.h"
+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;
+}
+
struct atomic {
drmModeAtomicReq *req;
bool failed;
@@ -33,9 +70,11 @@ static bool atomic_commit(struct atomic *atom,
if (ret != 0) {
wlr_drm_conn_log_errno(conn,
(flags & DRM_MODE_ATOMIC_TEST_ONLY) ? WLR_DEBUG : WLR_ERROR,
- "Atomic %s failed (%s)",
- (flags & DRM_MODE_ATOMIC_TEST_ONLY) ? "test" : "commit",
- (flags & DRM_MODE_ATOMIC_ALLOW_MODESET) ? "modeset" : "pageflip");
+ "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);
return false;
}