mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
backend/drm: improve atomic commit flag logging
We weren't logging all of the flags, which made debugging more difficult.
This commit is contained in:
parent
43020963d4
commit
2563b79dc2
1 changed files with 42 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
||||||
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
|
@ -6,6 +8,41 @@
|
||||||
#include "backend/drm/iface.h"
|
#include "backend/drm/iface.h"
|
||||||
#include "backend/drm/util.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 {
|
struct atomic {
|
||||||
drmModeAtomicReq *req;
|
drmModeAtomicReq *req;
|
||||||
bool failed;
|
bool failed;
|
||||||
|
@ -33,9 +70,11 @@ static bool atomic_commit(struct atomic *atom,
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
wlr_drm_conn_log_errno(conn,
|
wlr_drm_conn_log_errno(conn,
|
||||||
(flags & DRM_MODE_ATOMIC_TEST_ONLY) ? WLR_DEBUG : WLR_ERROR,
|
(flags & DRM_MODE_ATOMIC_TEST_ONLY) ? WLR_DEBUG : WLR_ERROR,
|
||||||
"Atomic %s failed (%s)",
|
"Atomic commit failed");
|
||||||
(flags & DRM_MODE_ATOMIC_TEST_ONLY) ? "test" : "commit",
|
char *flags_str = atomic_commit_flags_str(flags);
|
||||||
(flags & DRM_MODE_ATOMIC_ALLOW_MODESET) ? "modeset" : "pageflip");
|
wlr_log(WLR_DEBUG, "(Atomic commit flags: %s)",
|
||||||
|
flags_str ? flags_str : "<error>");
|
||||||
|
free(flags_str);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue