From: "NĂcolas F. R. A. Prado" <[email protected]> In order to allow for post-blend color pipelines, colorops need to be assigned to a crtc rather than a plane. Add a crtc to the colorop struct to enable this. Either the plane or the crtc will be set for any given colorop depending on whether it is part of a pre- or post-blend color pipeline.
Signed-off-by: NĂcolas F. R. A. Prado <[email protected]> Co-developed-by: Ariel D'Alessandro <[email protected]> Signed-off-by: Ariel D'Alessandro <[email protected]> Reviewed-by: Louis Chauvet <[email protected]> Reviewed-by: Harry Wentland <[email protected]> --- drivers/gpu/drm/drm_atomic.c | 6 +++--- drivers/gpu/drm/drm_colorop.c | 25 +++++++++++++++++++++++++ include/drm/drm_colorop.h | 17 +++++++++++++++-- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 6d3ea8056b603..e9022d7ad04b0 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -620,7 +620,7 @@ drm_atomic_get_colorop_state(struct drm_atomic_state *state, if (colorop_state) return colorop_state; - ret = drm_modeset_lock(&colorop->plane->mutex, state->acquire_ctx); + ret = drm_colorop_modeset_lock(colorop, state->acquire_ctx); if (ret) return ERR_PTR(ret); @@ -2012,10 +2012,10 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p, list_for_each_entry(colorop, &config->colorop_list, head) { if (take_locks) - drm_modeset_lock(&colorop->plane->mutex, NULL); + drm_colorop_modeset_lock(colorop, NULL); drm_atomic_colorop_print_state(p, colorop->state); if (take_locks) - drm_modeset_unlock(&colorop->plane->mutex); + drm_colorop_modeset_unlock(colorop); } list_for_each_entry(plane, &config->plane_list, head) { diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 44eb823585d2e..bf3b8ff51571b 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -24,6 +24,7 @@ * */ +#include <drm/drm_crtc.h> #include <drm/drm_colorop.h> #include <drm/drm_print.h> #include <drm/drm_drv.h> @@ -597,3 +598,27 @@ void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_color colorop->next = next; } EXPORT_SYMBOL(drm_colorop_set_next_property); + +int drm_colorop_modeset_lock(struct drm_colorop *colorop, struct drm_modeset_acquire_ctx *ctx) +{ + if (colorop->plane) + return drm_modeset_lock(&colorop->plane->mutex, ctx); + + if (colorop->crtc) + return drm_modeset_lock(&colorop->crtc->mutex, ctx); + + drm_err(colorop->dev, "Dangling colorop, it must be attached to a plane or a CRTC\n"); + return -EINVAL; +} +EXPORT_SYMBOL(drm_colorop_modeset_lock); + +void drm_colorop_modeset_unlock(struct drm_colorop *colorop) +{ + if (colorop->plane) + drm_modeset_unlock(&colorop->plane->mutex); + else if (colorop->crtc) + drm_modeset_unlock(&colorop->crtc->mutex); + else + drm_err(colorop->dev, "Dangling colorop, it must be attached to a plane or a CRTC\n"); +} +EXPORT_SYMBOL(drm_colorop_modeset_unlock); diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index a3a32f9f918c7..49d342b7f8b0b 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -29,6 +29,7 @@ #include <drm/drm_mode_object.h> #include <drm/drm_mode.h> +#include <drm/drm_modeset_lock.h> #include <drm/drm_property.h> /* DRM colorop flags */ @@ -223,11 +224,21 @@ struct drm_colorop { /** * @plane: * - * The plane on which the colorop sits. A drm_colorop is always unique - * to a plane. + * The plane on which the colorop sits if it is a pre-blend colorop. + * In this case it is unique to the plane. + * NOTE: plane and crtc are mutually exclusive. */ struct drm_plane *plane; + /** + * @crtc: + * + * The CRTC on which the colorop sits if it is a post-blend colorop. + * In this case it is unique to the CRTC. + * NOTE: plane and crtc are mutually exclusive. + */ + struct drm_crtc *crtc; + /** * @state: * @@ -460,5 +471,7 @@ const char * drm_get_colorop_lut3d_interpolation_name(enum drm_colorop_lut3d_interpolation_type type); void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next); +int drm_colorop_modeset_lock(struct drm_colorop *colorop, struct drm_modeset_acquire_ctx *ctx); +void drm_colorop_modeset_unlock(struct drm_colorop *colorop); #endif /* __DRM_COLOROP_H__ */ -- 2.51.0
