compositor-drm: Remove legacy plane and vblank usage

As of the previous commit, we never create state which uses overlay
planes on non-atomic drivers. We can thus remove the calls to
drmModeSetPlane.

The only time we ever waited for vblank events was when we had called
drmModeSetPlane and needed to make sure we waited until it was active.
We can thus also remove all the vblank event machinery.

Signed-off-by: Daniel Stone <daniels@collabora.com>
dev
Daniel Stone 5 years ago
parent 87fab1ca4e
commit 31838bf17e
  1. 106
      libweston/backend-drm/drm.c

@ -538,7 +538,6 @@ struct drm_output {
/* Holds the properties for the CRTC */ /* Holds the properties for the CRTC */
struct drm_property_info props_crtc[WDRM_CRTC__COUNT]; struct drm_property_info props_crtc[WDRM_CRTC__COUNT];
int vblank_pending;
int page_flip_pending; int page_flip_pending;
int atomic_complete_pending; int atomic_complete_pending;
int destroy_pending; int destroy_pending;
@ -2005,9 +2004,8 @@ drm_output_assign_state(struct drm_output_state *state,
if (b->atomic_modeset) if (b->atomic_modeset)
continue; continue;
if (plane->type == WDRM_PLANE_TYPE_OVERLAY) assert(plane->type != WDRM_PLANE_TYPE_OVERLAY);
output->vblank_pending++; if (plane->type == WDRM_PLANE_TYPE_PRIMARY)
else if (plane->type == WDRM_PLANE_TYPE_PRIMARY)
output->page_flip_pending = 1; output->page_flip_pending = 1;
} }
} }
@ -2254,7 +2252,6 @@ drm_output_apply_state_legacy(struct drm_output_state *state)
struct drm_plane *scanout_plane = output->scanout_plane; struct drm_plane *scanout_plane = output->scanout_plane;
struct drm_property_info *dpms_prop; struct drm_property_info *dpms_prop;
struct drm_plane_state *scanout_state; struct drm_plane_state *scanout_state;
struct drm_plane_state *ps;
struct drm_mode *mode; struct drm_mode *mode;
struct drm_head *head; struct drm_head *head;
const struct pixel_format_info *pinfo = NULL; const struct pixel_format_info *pinfo = NULL;
@ -2281,21 +2278,6 @@ drm_output_apply_state_legacy(struct drm_output_state *state)
} }
if (state->dpms != WESTON_DPMS_ON) { if (state->dpms != WESTON_DPMS_ON) {
wl_list_for_each(ps, &state->plane_list, link) {
struct drm_plane *p = ps->plane;
assert(ps->fb == NULL);
assert(ps->output == NULL);
if (p->type != WDRM_PLANE_TYPE_OVERLAY)
continue;
ret = drmModeSetPlane(backend->drm.fd, p->plane_id,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if (ret)
weston_log("drmModeSetPlane failed disable: %s\n",
strerror(errno));
}
if (output->cursor_plane) { if (output->cursor_plane) {
ret = drmModeSetCursor(backend->drm.fd, output->crtc_id, ret = drmModeSetCursor(backend->drm.fd, output->crtc_id,
0, 0, 0); 0, 0, 0);
@ -2374,56 +2356,6 @@ drm_output_apply_state_legacy(struct drm_output_state *state)
drm_output_set_cursor(state); drm_output_set_cursor(state);
/*
* Now, update all the sprite surfaces
*/
wl_list_for_each(ps, &state->plane_list, link) {
uint32_t flags = 0, fb_id = 0;
drmVBlank vbl = {
.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT,
.request.sequence = 1,
};
struct drm_plane *p = ps->plane;
if (p->type != WDRM_PLANE_TYPE_OVERLAY)
continue;
assert(p->state_cur->complete);
assert(!!p->state_cur->output == !!p->state_cur->fb);
assert(!p->state_cur->output || p->state_cur->output == output);
assert(!ps->complete);
assert(!ps->output || ps->output == output);
assert(!!ps->output == !!ps->fb);
/* The legacy SetPlane API doesn't support fences */
assert(ps->in_fence_fd == -1);
if (ps->fb && !backend->sprites_hidden)
fb_id = ps->fb->fb_id;
ret = drmModeSetPlane(backend->drm.fd, p->plane_id,
output->crtc_id, fb_id, flags,
ps->dest_x, ps->dest_y,
ps->dest_w, ps->dest_h,
ps->src_x, ps->src_y,
ps->src_w, ps->src_h);
if (ret)
weston_log("setplane failed: %d: %s\n",
ret, strerror(errno));
vbl.request.type |= drm_waitvblank_pipe(output);
/*
* Queue a vblank signal so we know when the surface
* becomes active on the display or has been replaced.
*/
vbl.request.signal = (unsigned long) ps;
ret = drmWaitVBlank(backend->drm.fd, &vbl);
if (ret) {
weston_log("vblank event request failed: %d: %s\n",
ret, strerror(errno));
}
}
if (state->dpms != output->state_cur->dpms) { if (state->dpms != output->state_cur->dpms) {
wl_list_for_each(head, &output->base.head_list, base.output_link) { wl_list_for_each(head, &output->base.head_list, base.output_link) {
dpms_prop = &head->props_conn[WDRM_CONNECTOR_DPMS]; dpms_prop = &head->props_conn[WDRM_CONNECTOR_DPMS];
@ -3123,30 +3055,6 @@ drm_output_update_msc(struct drm_output *output, unsigned int seq)
output->base.msc = (msc_hi << 32) + seq; output->base.msc = (msc_hi << 32) + seq;
} }
static void
vblank_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec,
void *data)
{
struct drm_plane_state *ps = (struct drm_plane_state *) data;
struct drm_output_state *os = ps->output_state;
struct drm_output *output = os->output;
struct drm_backend *b = to_drm_backend(output->base.compositor);
uint32_t flags = WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;
assert(!b->atomic_modeset);
drm_output_update_msc(output, frame);
output->vblank_pending--;
assert(output->vblank_pending >= 0);
assert(ps->fb);
if (output->page_flip_pending || output->vblank_pending)
return;
drm_output_update_complete(output, flags, sec, usec);
}
static void static void
page_flip_handler(int fd, unsigned int frame, page_flip_handler(int fd, unsigned int frame,
@ -3164,9 +3072,6 @@ page_flip_handler(int fd, unsigned int frame,
assert(output->page_flip_pending); assert(output->page_flip_pending);
output->page_flip_pending = 0; output->page_flip_pending = 0;
if (output->vblank_pending)
return;
drm_output_update_complete(output, flags, sec, usec); drm_output_update_complete(output, flags, sec, usec);
} }
@ -4152,7 +4057,6 @@ on_drm_input(int fd, uint32_t mask, void *data)
else else
#endif #endif
evctx.page_flip_handler = page_flip_handler; evctx.page_flip_handler = page_flip_handler;
evctx.vblank_handler = vblank_handler;
drmHandleEvent(fd, &evctx); drmHandleEvent(fd, &evctx);
return 1; return 1;
@ -6305,8 +6209,7 @@ drm_output_destroy(struct weston_output *base)
assert(!output->virtual); assert(!output->virtual);
if (output->page_flip_pending || output->vblank_pending || if (output->page_flip_pending || output->atomic_complete_pending) {
output->atomic_complete_pending) {
output->destroy_pending = 1; output->destroy_pending = 1;
weston_log("destroy output while page flip pending\n"); weston_log("destroy output while page flip pending\n");
return; return;
@ -6335,8 +6238,7 @@ drm_output_disable(struct weston_output *base)
assert(!output->virtual); assert(!output->virtual);
if (output->page_flip_pending || output->vblank_pending || if (output->page_flip_pending || output->atomic_complete_pending) {
output->atomic_complete_pending) {
output->disable_pending = 1; output->disable_pending = 1;
return -1; return -1;
} }

Loading…
Cancel
Save