From ae0e28265e216dad11d4cbde42fc15e92919af78 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Wed, 11 Apr 2018 09:39:25 +0200 Subject: drm/blend: Add a generic alpha property Some drivers duplicate the logic to create a property to store a per-plane alpha. This is especially useful if we ever want to support extra protocols for Wayland like: https://lists.freedesktop.org/archives/wayland-devel/2017-August/034741.html Let's create a helper in order to move that to the core. Acked-by: Maarten Lankhorst Acked-by: Sean Paul Reviewed-by: Boris Brezillon Reviewed-by: Eric Anholt Reviewed-by: Laurent Pinchart Reviewed-by: Paul Kocialkowski Signed-off-by: Maxime Ripard Link: https://patchwork.freedesktop.org/patch/msgid/6e1ce0db78fcfc407e94913c64819e65109d034d.1523432341.git-series.maxime.ripard@bootlin.com --- drivers/gpu/drm/drm_atomic.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/gpu/drm/drm_atomic.c') diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 7d25c42f22db..3d9ae057a6cd 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -783,6 +783,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, state->src_w = val; } else if (property == config->prop_src_h) { state->src_h = val; + } else if (property == plane->alpha_property) { + state->alpha = val; } else if (property == plane->rotation_property) { if (!is_power_of_2(val & DRM_MODE_ROTATE_MASK)) return -EINVAL; @@ -848,6 +850,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane, *val = state->src_w; } else if (property == config->prop_src_h) { *val = state->src_h; + } else if (property == plane->alpha_property) { + *val = state->alpha; } else if (property == plane->rotation_property) { *val = state->rotation; } else if (property == plane->zpos_property) { -- cgit v1.2.3 From 30d23f220c75cf58584b19929bd8460b4edc9771 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Thu, 5 Apr 2018 17:44:46 +0200 Subject: drm/atomic: better doc for implicit vs explicit fencing Note that a pile of drivers don't seem to take implicit fencing into account, or at least don't call drm_atoimc_set_fence_for_plane(). Cc'ing relevant people, or at least some. Some drivers also look like they don't disable implicit fencing (e.g. amdgpu) because the explicit fences and implicit fences are handled by entirely independent code paths. I also wonder whether we shouldn't just make the recommended helpers the default ones, since a lot of drivers don't bother to handle the implicit fences at all it seems. The helpers won't blow up even for non-GEM drivers or GEM drivers which don't fill out the gem bo pointers in struct drm_framebuffer. v2: Comments from Eric. Cc: Gerd Hoffmann Cc: Alex Deucher Cc: Harry Wentland Cc: Sinclair Yeh Cc: Thomas Hellstrom Cc: Gustavo Padovan Cc: Maarten Lankhorst Cc: Sean Paul Reviewed-by: Eric Anholt Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20180405154449.23038-7-daniel.vetter@ffwll.ch --- drivers/gpu/drm/drm_atomic.c | 8 ++++++++ include/drm/drm_modeset_helper_vtables.h | 5 ++++- include/drm/drm_plane.h | 11 +++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/drm/drm_atomic.c') diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 3d9ae057a6cd..9bdd67781917 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1496,6 +1496,14 @@ EXPORT_SYMBOL(drm_atomic_set_fb_for_plane); * Otherwise, if &drm_plane_state.fence is not set this function we just set it * with the received implicit fence. In both cases this function consumes a * reference for @fence. + * + * This way explicit fencing can be used to overrule implicit fencing, which is + * important to make explicit fencing use-cases work: One example is using one + * buffer for 2 screens with different refresh rates. Implicit fencing will + * clamp rendering to the refresh rate of the slower screen, whereas explicit + * fence allows 2 independent render and display loops on a single buffer. If a + * driver allows obeys both implicit and explicit fences for plane updates, then + * it will break all the benefits of explicit fencing. */ void drm_atomic_set_fence_for_plane(struct drm_plane_state *plane_state, diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index 3e76ca805b0f..35e2a3a79fc5 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h @@ -1004,11 +1004,14 @@ struct drm_plane_helper_funcs { * This function must not block for outstanding rendering, since it is * called in the context of the atomic IOCTL even for async commits to * be able to return any errors to userspace. Instead the recommended - * way is to fill out the fence member of the passed-in + * way is to fill out the &drm_plane_state.fence of the passed-in * &drm_plane_state. If the driver doesn't support native fences then * equivalent functionality should be implemented through private * members in the plane structure. * + * Drivers which always have their buffers pinned should use + * drm_gem_fb_prepare_fb() for this hook. + * * The helpers will call @cleanup_fb with matching arguments for every * successful call to this hook. * diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 9563bd25f19b..26fa50c2a50e 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -80,8 +80,15 @@ struct drm_plane_state { /** * @fence: * - * Optional fence to wait for before scanning out @fb. Do not write this - * directly, use drm_atomic_set_fence_for_plane() + * Optional fence to wait for before scanning out @fb. The core atomic + * code will set this when userspace is using explicit fencing. Do not + * write this directly for a driver's implicit fence, use + * drm_atomic_set_fence_for_plane() to ensure that an explicit fence is + * preserved. + * + * Drivers should store any implicit fence in this from their + * &drm_plane_helper.prepare_fb callback. See drm_gem_fb_prepare_fb() + * and drm_gem_fb_simple_display_pipe_prepare_fb() for suitable helpers. */ struct dma_fence *fence; -- cgit v1.2.3