From: Luca Tettamanti Subject: Re: [PATCH libdrm] omap: add omapdrm support Date: Wed, 28 Mar 2012 16:39:49 +0200 Message-ID: <20120328143949.GA10662@nb-core2.darkstar.lan> References: <1332352836-18685-1-git-send-email-rob.clark@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ey0-f177.google.com (mail-ey0-f177.google.com [209.85.215.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B7409EF3E for ; Wed, 28 Mar 2012 07:39:57 -0700 (PDT) Received: by eaak13 with SMTP id k13so343793eaa.36 for ; Wed, 28 Mar 2012 07:39:56 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1332352836-18685-1-git-send-email-rob.clark@linaro.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: Rob Clark Cc: Rob Clark , dri-devel@lists.freedesktop.org, patches@linaro.org List-Id: dri-devel@lists.freedesktop.org Hi Rob, I've a couple of (minor) comments: On Wed, Mar 21, 2012 at 01:00:36PM -0500, Rob Clark wrote: > --- /dev/null > +++ b/omap/omap_drm.c [...] > +/* allocate a new (un-tiled) buffer object */ > +struct omap_bo * omap_bo_new(struct omap_device *dev, > + uint32_t size, uint32_t flags) > +{ > + if (flags & OMAP_BO_TILED) { > + return NULL; > + } > + return omap_bo_new_impl(dev, (union omap_gem_size){ > + .bytes = size, > + }, flags); Hum, the indentation of the anonymous union looks weird (but maybe it's just me...) > +} > + > +/* allocate a new buffer object */ > +struct omap_bo * omap_bo_new_tiled(struct omap_device *dev, > + uint32_t width, uint32_t height, uint32_t flags) > +{ > + if (!(flags & OMAP_BO_TILED)) { > + return NULL; > + } > + return omap_bo_new_impl(dev, (union omap_gem_size){ > + .tiled = { > + .width = width, > + .height = height, > + }, > + }, flags); > +} Here too :-) What about this: return omap_bo_new_impl(dev, (union omap_gem_size) { .stuff = blah, }); Or just use a temp var? > + > +/* get buffer info */ > +static int get_buffer_info(struct omap_bo *bo) > +{ > + struct drm_omap_gem_info req = { > + .handle = bo->handle, > + }; > + int ret = drmCommandWriteRead(bo->dev->fd, DRM_OMAP_GEM_INFO, > + &req, sizeof(req)); > + if (ret) { > + return ret; > + } > + > + /* really all we need for now is mmap offset */ > + bo->offset = req.offset; > + bo->size = req.size; > + > + return 0; > +} > + > +/* import a buffer object from DRI2 name */ > +struct omap_bo * omap_bo_from_name(struct omap_device *dev, uint32_t name) > +{ > + struct omap_bo *bo = calloc(sizeof(*bo), 1); > + struct drm_gem_open req = { > + .name = name, > + }; > + > + if (drmIoctl(dev->fd, DRM_IOCTL_GEM_OPEN, &req)) { > + goto fail; > + } bo may be NULL here: > + > + bo->dev = dev; > + bo->name = name; > + bo->handle = req.handle; I also woundn't use the calloc in the initialization block, I prefer to keep the allocation and the check together: bo = alloc_stuff(); if (!bo) oh_crap(); I find it more easy to check visually. Luca