From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Wilson Subject: Re: [PATCH 1/2] drm: add plane support Date: Tue, 08 Nov 2011 17:46:35 +0000 Message-ID: References: <1320773933-23158-1-git-send-email-jbarnes@virtuousgeek.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 37AF39E75D for ; Tue, 8 Nov 2011 09:46:52 -0800 (PST) In-Reply-To: <1320773933-23158-1-git-send-email-jbarnes@virtuousgeek.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Jesse Barnes , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Tue, 8 Nov 2011 09:38:52 -0800, Jesse Barnes 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 > Reviewed-by: Rob Clark > Reviewed-by: Daniel Vetter > Signed-off-by: Jesse Barnes > --- > 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