[PATCH 1/2] drm: add plane support
Chris Wilson
chris at chris-wilson.co.uk
Tue Nov 8 09:46:35 PST 2011
On Tue, 8 Nov 2011 09:38:52 -0800, Jesse Barnes <jbarnes at virtuousgeek.org> wrote:
> Planes are a bit like half-CRTCs. They have a location and fb, but
> don't drive outputs directly. Add support for handling them to the core
> KMS code.
>
> Acked-by: Alan Cox <alan at lxorguk.ukuu.org.uk>
> Reviewed-by: Rob Clark <rob.clark at linaro.org>
> Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
> ---
> drivers/gpu/drm/drm_crtc.c | 251 +++++++++++++++++++++++++++++++++++++++++++-
> drivers/gpu/drm/drm_drv.c | 3 +
> include/drm/drm.h | 3 +
> include/drm/drm_crtc.h | 75 +++++++++++++-
> include/drm/drm_mode.h | 33 ++++++
> 5 files changed, 362 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index fe738f0..fac8043 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -321,6 +321,7 @@ void drm_framebuffer_cleanup(struct drm_framebuffer *fb)
> {
> struct drm_device *dev = fb->dev;
> struct drm_crtc *crtc;
> + struct drm_plane *plane;
> struct drm_mode_set set;
> int ret;
>
> @@ -337,6 +338,15 @@ void drm_framebuffer_cleanup(struct drm_framebuffer *fb)
> }
> }
>
> + list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
> + if (plane->fb == fb) {
> + /* should turn off the crtc */
> + ret = plane->funcs->disable_plane(plane);
> + if (ret)
> + DRM_ERROR("failed to disable plane with busy fb\n");
> + }
> + }
> +
> drm_mode_object_put(dev, &fb->base);
> list_del(&fb->head);
> dev->mode_config.num_fb--;
> @@ -535,6 +545,48 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
> }
> EXPORT_SYMBOL(drm_encoder_cleanup);
>
> +void drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
> + unsigned long possible_crtcs,
> + const struct drm_plane_funcs *funcs,
> + uint32_t *formats, uint32_t format_count)
> +{
> + mutex_lock(&dev->mode_config.mutex);
> +
> + plane->dev = dev;
> + drm_mode_object_get(dev, &plane->base, DRM_MODE_OBJECT_PLANE);
> + plane->funcs = funcs;
> + plane->format_types = kmalloc(sizeof(uint32_t) * format_count,
> + GFP_KERNEL);
> + if (!plane->format_types) {
> + DRM_DEBUG_KMS("out of memory when allocating plane\n");
> + drm_mode_object_put(dev, &plane->base);
> + return;
This can fail, report it back to the caller so that he can tear down his
allocations and propagate onwards. Kthxbye.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the dri-devel
mailing list