drm: do not pageflip when enabling output

This commit is contained in:
emersion 2018-01-15 21:49:37 +01:00
parent 33c427a6aa
commit 0eebaf98d0
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 17 additions and 11 deletions

View file

@ -33,7 +33,6 @@ static bool atomic_end(int drm_fd, struct atomic *atom) {
} }
uint32_t flags = DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_NONBLOCK; uint32_t flags = DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_NONBLOCK;
if (drmModeAtomicCommit(drm_fd, atom->req, flags, NULL)) { if (drmModeAtomicCommit(drm_fd, atom->req, flags, NULL)) {
wlr_log_errno(L_ERROR, "Atomic test failed"); wlr_log_errno(L_ERROR, "Atomic test failed");
drmModeAtomicSetCursor(atom->req, atom->cursor); drmModeAtomicSetCursor(atom->req, atom->cursor);
@ -44,13 +43,11 @@ static bool atomic_end(int drm_fd, struct atomic *atom) {
} }
static bool atomic_commit(int drm_fd, struct atomic *atom, static bool atomic_commit(int drm_fd, struct atomic *atom,
struct wlr_drm_connector *conn, uint32_t flag, bool modeset) { struct wlr_drm_connector *conn, uint32_t flags, bool modeset) {
if (atom->failed) { if (atom->failed) {
return false; return false;
} }
uint32_t flags = DRM_MODE_PAGE_FLIP_EVENT | flag;
int ret = drmModeAtomicCommit(drm_fd, atom->req, flags, conn); int ret = drmModeAtomicCommit(drm_fd, atom->req, flags, conn);
if (ret) { if (ret) {
wlr_log_errno(L_ERROR, "%s: Atomic commit failed (%s)", wlr_log_errno(L_ERROR, "%s: Atomic commit failed (%s)",
@ -59,7 +56,8 @@ static bool atomic_commit(int drm_fd, struct atomic *atom,
// Try to commit without new changes // Try to commit without new changes
drmModeAtomicSetCursor(atom->req, atom->cursor); drmModeAtomicSetCursor(atom->req, atom->cursor);
if (drmModeAtomicCommit(drm_fd, atom->req, flags, conn)) { if (drmModeAtomicCommit(drm_fd, atom->req, flags, conn)) {
wlr_log_errno(L_ERROR, "%s: Atomic commit failed (%s)", wlr_log_errno(L_ERROR,
"%s: Atomic commit without new changes failed (%s)",
conn->output.name, modeset ? "modeset" : "pageflip"); conn->output.name, modeset ? "modeset" : "pageflip");
} }
} }
@ -100,8 +98,8 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *drm,
struct wlr_drm_connector *conn, struct wlr_drm_connector *conn,
struct wlr_drm_crtc *crtc, struct wlr_drm_crtc *crtc,
uint32_t fb_id, drmModeModeInfo *mode) { uint32_t fb_id, drmModeModeInfo *mode) {
if (mode) { if (mode != NULL) {
if (crtc->mode_id) { if (crtc->mode_id != 0) {
drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id); drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id);
} }
@ -111,16 +109,20 @@ static bool atomic_crtc_pageflip(struct wlr_drm_backend *drm,
} }
} }
struct atomic atom; uint32_t flags = DRM_MODE_PAGE_FLIP_EVENT;
if (mode != NULL) {
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
} else {
flags |= DRM_MODE_ATOMIC_NONBLOCK;
}
struct atomic atom;
atomic_begin(crtc, &atom); atomic_begin(crtc, &atom);
atomic_add(&atom, conn->id, conn->props.crtc_id, crtc->id); atomic_add(&atom, conn->id, conn->props.crtc_id, crtc->id);
atomic_add(&atom, crtc->id, crtc->props.mode_id, crtc->mode_id); atomic_add(&atom, crtc->id, crtc->props.mode_id, crtc->mode_id);
atomic_add(&atom, crtc->id, crtc->props.active, 1); atomic_add(&atom, crtc->id, crtc->props.active, 1);
set_plane_props(&atom, crtc->primary, crtc->id, fb_id, true); set_plane_props(&atom, crtc->primary, crtc->id, fb_id, true);
return atomic_commit(drm->fd, &atom, conn, return atomic_commit(drm->fd, &atom, conn, flags, mode);
mode ? DRM_MODE_ATOMIC_ALLOW_MODESET : DRM_MODE_ATOMIC_NONBLOCK,
mode);
} }
static bool atomic_conn_enable(struct wlr_drm_backend *drm, static bool atomic_conn_enable(struct wlr_drm_backend *drm,

View file

@ -156,6 +156,10 @@ static void wlr_output_update_matrix(struct wlr_output *output) {
} }
void wlr_output_enable(struct wlr_output *output, bool enable) { void wlr_output_enable(struct wlr_output *output, bool enable) {
if (output->enabled == enable) {
return;
}
if (output->impl->enable) { if (output->impl->enable) {
output->impl->enable(output, enable); output->impl->enable(output, enable);
} }