diff --git a/backend/backend.c b/backend/backend.c index ed6ae2d651..63d9cb34f0 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -153,13 +153,6 @@ static struct wlr_session *session_create_and_wait(struct wl_display *disp) { return session; } -clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend) { - if (backend->impl->get_presentation_clock) { - return backend->impl->get_presentation_clock(backend); - } - return CLOCK_MONOTONIC; -} - int wlr_backend_get_drm_fd(struct wlr_backend *backend) { if (!backend->impl->get_drm_fd) { return -1; diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 9ae4dbf0ff..4c59c20e67 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -66,11 +66,6 @@ static void backend_destroy(struct wlr_backend *backend) { free(drm); } -static clockid_t backend_get_presentation_clock(struct wlr_backend *backend) { - struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend); - return drm->clock; -} - static int backend_get_drm_fd(struct wlr_backend *backend) { struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend); @@ -88,7 +83,6 @@ static uint32_t drm_backend_get_buffer_caps(struct wlr_backend *backend) { static const struct wlr_backend_impl backend_impl = { .start = backend_start, .destroy = backend_destroy, - .get_presentation_clock = backend_get_presentation_clock, .get_drm_fd = backend_get_drm_fd, .get_buffer_caps = drm_backend_get_buffer_caps, }; diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 191ad064da..3ae86dbbb9 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -72,6 +72,11 @@ bool check_drm_features(struct wlr_drm_backend *drm) { return false; } + if (drmGetCap(drm->fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap) || !cap) { + wlr_log(WLR_ERROR, "DRM_CAP_TIMESTAMP_MONOTONIC unsupported"); + return false; + } + const char *no_atomic = getenv("WLR_DRM_NO_ATOMIC"); if (no_atomic && strcmp(no_atomic, "1") == 0) { wlr_log(WLR_DEBUG, @@ -86,14 +91,11 @@ bool check_drm_features(struct wlr_drm_backend *drm) { drm->iface = &atomic_iface; } - int ret = drmGetCap(drm->fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap); - drm->clock = (ret == 0 && cap == 1) ? CLOCK_MONOTONIC : CLOCK_REALTIME; - const char *no_modifiers = getenv("WLR_DRM_NO_MODIFIERS"); if (no_modifiers != NULL && strcmp(no_modifiers, "1") == 0) { wlr_log(WLR_DEBUG, "WLR_DRM_NO_MODIFIERS set, disabling modifiers"); } else { - ret = drmGetCap(drm->fd, DRM_CAP_ADDFB2_MODIFIERS, &cap); + int ret = drmGetCap(drm->fd, DRM_CAP_ADDFB2_MODIFIERS, &cap); drm->addfb2_modifiers = ret == 0 && cap == 1; wlr_log(WLR_DEBUG, "ADDFB2 modifiers %s", drm->addfb2_modifiers ? "supported" : "unsupported"); diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 7c74959eb0..e7500e25b8 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -82,20 +82,6 @@ static struct wlr_session *multi_backend_get_session( return backend->session; } -static clockid_t multi_backend_get_presentation_clock( - struct wlr_backend *backend) { - struct wlr_multi_backend *multi = multi_backend_from_backend(backend); - - struct subbackend_state *sub; - wl_list_for_each(sub, &multi->backends, link) { - if (sub->backend->impl->get_presentation_clock) { - return wlr_backend_get_presentation_clock(sub->backend); - } - } - - return CLOCK_MONOTONIC; -} - static int multi_backend_get_drm_fd(struct wlr_backend *backend) { struct wlr_multi_backend *multi = multi_backend_from_backend(backend); @@ -114,7 +100,6 @@ static const struct wlr_backend_impl backend_impl = { .destroy = multi_backend_destroy, .get_renderer = multi_backend_get_renderer, .get_session = multi_backend_get_session, - .get_presentation_clock = multi_backend_get_presentation_clock, .get_drm_fd = multi_backend_get_drm_fd, }; diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 6d70d844df..dc7173e946 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -57,7 +57,6 @@ struct wlr_drm_backend { struct wlr_drm_backend *parent; const struct wlr_drm_interface *iface; - clockid_t clock; bool addfb2_modifiers; int fd; diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h index 529f8f87a7..bb3fb25102 100644 --- a/include/wlr/backend/interface.h +++ b/include/wlr/backend/interface.h @@ -18,7 +18,6 @@ struct wlr_backend_impl { void (*destroy)(struct wlr_backend *backend); struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend); struct wlr_session *(*get_session)(struct wlr_backend *backend); - clockid_t (*get_presentation_clock)(struct wlr_backend *backend); int (*get_drm_fd)(struct wlr_backend *backend); uint32_t (*get_buffer_caps)(struct wlr_backend *backend); }; diff --git a/include/wlr/types/wlr_presentation_time.h b/include/wlr/types/wlr_presentation_time.h index 51570c04e7..7861a1444f 100644 --- a/include/wlr/types/wlr_presentation_time.h +++ b/include/wlr/types/wlr_presentation_time.h @@ -20,7 +20,6 @@ struct wlr_output_event_present; struct wlr_presentation { struct wl_global *global; struct wl_list feedbacks; // wlr_presentation_feedback::link - clockid_t clock; struct { struct wl_signal destroy; diff --git a/types/wlr_output.c b/types/wlr_output.c index b6167d6d02..907786f214 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -961,9 +961,8 @@ void wlr_output_send_present(struct wlr_output *output, if (event->presented && event->when == NULL) { struct timespec now; - clockid_t clock = wlr_backend_get_presentation_clock(output->backend); errno = 0; - if (clock_gettime(clock, &now) != 0) { + if (clock_gettime(CLOCK_MONOTONIC, &now) != 0) { wlr_log_errno(WLR_ERROR, "failed to send output present event: " "failed to read clock"); return; diff --git a/types/wlr_presentation_time.c b/types/wlr_presentation_time.c index 4e3c4919be..6f57af39ff 100644 --- a/types/wlr_presentation_time.c +++ b/types/wlr_presentation_time.c @@ -1,7 +1,8 @@ -#define _POSIX_C_SOURCE 199309L +#define _POSIX_C_SOURCE 200809L #include #include #include +#include #include #include #include @@ -159,7 +160,7 @@ static void presentation_bind(struct wl_client *client, void *data, wl_resource_set_implementation(resource, &presentation_impl, presentation, NULL); - wp_presentation_send_clock_id(resource, (uint32_t)presentation->clock); + wp_presentation_send_clock_id(resource, CLOCK_MONOTONIC); } static void handle_display_destroy(struct wl_listener *listener, void *data) { @@ -186,8 +187,6 @@ struct wlr_presentation *wlr_presentation_create(struct wl_display *display, return NULL; } - presentation->clock = wlr_backend_get_presentation_clock(backend); - wl_list_init(&presentation->feedbacks); wl_signal_init(&presentation->events.destroy);