Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Remove get_presentation_clock from wlr_backend interface #3254

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions backend/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions backend/drm/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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,
};
Expand Down
10 changes: 6 additions & 4 deletions backend/drm/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");
Expand Down
15 changes: 0 additions & 15 deletions backend/multi/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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,
};

Expand Down
1 change: 0 additions & 1 deletion include/backend/drm/drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion include/wlr/backend/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
1 change: 0 additions & 1 deletion include/wlr/types/wlr_presentation_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions types/wlr_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions types/wlr_presentation_time.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#define _POSIX_C_SOURCE 199309L
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/backend.h>
Expand Down Expand Up @@ -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) {
Expand All @@ -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);

Expand Down