From patchwork Wed Aug 8 15:21:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1296461 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 83DA33FC23 for ; Wed, 8 Aug 2012 15:24:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74B20A09F9 for ; Wed, 8 Aug 2012 08:24:29 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [95.142.166.194]) by gabe.freedesktop.org (Postfix) with ESMTP id 01273A0A16 for ; Wed, 8 Aug 2012 08:21:13 -0700 (PDT) Received: from avalon.ideasonboard.com (unknown [91.178.164.81]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 17E1735A88; Wed, 8 Aug 2012 17:21:12 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 3/7] sh_mobile_meram: Add direct MERAM allocation API Date: Wed, 8 Aug 2012 17:21:04 +0200 Message-Id: <1344439268-7343-4-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1344439268-7343-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1344439268-7343-1-git-send-email-laurent.pinchart@ideasonboard.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org The API can be used to allocate and free MERAM blocks directly, without going through ICBs. Signed-off-by: Laurent Pinchart --- drivers/video/sh_mobile_meram.c | 41 +++++++++++++++++++++++++++++++++++--- include/video/sh_mobile_meram.h | 16 +++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/drivers/video/sh_mobile_meram.c b/drivers/video/sh_mobile_meram.c index fdb6fc1..7a0ba8b 100644 --- a/drivers/video/sh_mobile_meram.c +++ b/drivers/video/sh_mobile_meram.c @@ -195,6 +195,21 @@ static inline unsigned long meram_read_reg(void __iomem *base, unsigned int off) } /* ----------------------------------------------------------------------------- + * MERAM allocation and free + */ + +static unsigned long meram_alloc(struct sh_mobile_meram_priv *priv, size_t size) +{ + return gen_pool_alloc(priv->pool, size); +} + +static void meram_free(struct sh_mobile_meram_priv *priv, unsigned long mem, + size_t size) +{ + gen_pool_free(priv->pool, mem, size); +} + +/* ----------------------------------------------------------------------------- * LCDC cache planes allocation, init, cleanup and free */ @@ -216,7 +231,7 @@ static int meram_plane_alloc(struct sh_mobile_meram_priv *priv, return -ENOMEM; plane->marker = &priv->icbs[idx]; - mem = gen_pool_alloc(priv->pool, size * 1024); + mem = meram_alloc(priv, size * 1024); if (mem == 0) return -ENOMEM; @@ -233,8 +248,8 @@ static int meram_plane_alloc(struct sh_mobile_meram_priv *priv, static void meram_plane_free(struct sh_mobile_meram_priv *priv, struct sh_mobile_meram_fb_plane *plane) { - gen_pool_free(priv->pool, priv->meram + plane->marker->offset, - plane->marker->size * 1024); + meram_free(priv, priv->meram + plane->marker->offset, + plane->marker->size * 1024); __clear_bit(plane->marker->index, &priv->used_icb); __clear_bit(plane->cache->index, &priv->used_icb); @@ -386,9 +401,27 @@ static void meram_plane_cleanup(struct sh_mobile_meram_priv *priv, } /* ----------------------------------------------------------------------------- - * LCDC cache operations + * MERAM operations */ +unsigned long sh_mobile_meram_alloc(struct sh_mobile_meram_info *pdata, + size_t size) +{ + struct sh_mobile_meram_priv *priv = pdata->priv; + + return meram_alloc(priv, size); +} +EXPORT_SYMBOL_GPL(sh_mobile_meram_alloc); + +void sh_mobile_meram_free(struct sh_mobile_meram_info *pdata, unsigned long mem, + size_t size) +{ + struct sh_mobile_meram_priv *priv = pdata->priv; + + meram_free(priv, mem, size); +} +EXPORT_SYMBOL_GPL(sh_mobile_meram_free); + /* Allocate memory for the ICBs and mark them as used. */ static struct sh_mobile_meram_fb_cache * meram_cache_alloc(struct sh_mobile_meram_priv *priv, diff --git a/include/video/sh_mobile_meram.h b/include/video/sh_mobile_meram.h index 1134837..062e6e7 100644 --- a/include/video/sh_mobile_meram.h +++ b/include/video/sh_mobile_meram.h @@ -38,6 +38,10 @@ struct sh_mobile_meram_cfg { #if defined(CONFIG_FB_SH_MOBILE_MERAM) || \ defined(CONFIG_FB_SH_MOBILE_MERAM_MODULE) +unsigned long sh_mobile_meram_alloc(struct sh_mobile_meram_info *meram_dev, + size_t size); +void sh_mobile_meram_free(struct sh_mobile_meram_info *meram_dev, + unsigned long mem, size_t size); void *sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev, const struct sh_mobile_meram_cfg *cfg, unsigned int xres, unsigned int yres, @@ -50,6 +54,18 @@ void sh_mobile_meram_cache_update(struct sh_mobile_meram_info *dev, void *data, unsigned long *icb_addr_y, unsigned long *icb_addr_c); #else +static inline unsigned long +sh_mobile_meram_alloc(struct sh_mobile_meram_info *meram_dev, size_t size) +{ + return 0; +} + +static inline void +sh_mobile_meram_free(struct sh_mobile_meram_info *meram_dev, + unsigned long mem, size_t size) +{ +} + static inline void * sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev, const struct sh_mobile_meram_cfg *cfg,