aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-03-15 08:18:17 -0400
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-07-18 20:05:22 -0400
commit239921ec1d969e904676f444a92e6d68a928d98c (patch)
tree44b8fbf6a560ed526d926c40fec48043d469ff46
parent6e729b416b44296f5ed503b40ac58c2bffb43caf (diff)
sh_mobile_meram: Add direct MERAM allocation API
The API can be used to allocate and free MERAM blocks directly, without going through ICBs. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--drivers/video/sh_mobile_meram.c41
-rw-r--r--include/video/sh_mobile_meram.h16
2 files changed, 53 insertions, 4 deletions
diff --git a/drivers/video/sh_mobile_meram.c b/drivers/video/sh_mobile_meram.c
index fdb6fc1decb..7a0ba8bb3fb 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)
195} 195}
196 196
197/* ----------------------------------------------------------------------------- 197/* -----------------------------------------------------------------------------
198 * MERAM allocation and free
199 */
200
201static unsigned long meram_alloc(struct sh_mobile_meram_priv *priv, size_t size)
202{
203 return gen_pool_alloc(priv->pool, size);
204}
205
206static void meram_free(struct sh_mobile_meram_priv *priv, unsigned long mem,
207 size_t size)
208{
209 gen_pool_free(priv->pool, mem, size);
210}
211
212/* -----------------------------------------------------------------------------
198 * LCDC cache planes allocation, init, cleanup and free 213 * LCDC cache planes allocation, init, cleanup and free
199 */ 214 */
200 215
@@ -216,7 +231,7 @@ static int meram_plane_alloc(struct sh_mobile_meram_priv *priv,
216 return -ENOMEM; 231 return -ENOMEM;
217 plane->marker = &priv->icbs[idx]; 232 plane->marker = &priv->icbs[idx];
218 233
219 mem = gen_pool_alloc(priv->pool, size * 1024); 234 mem = meram_alloc(priv, size * 1024);
220 if (mem == 0) 235 if (mem == 0)
221 return -ENOMEM; 236 return -ENOMEM;
222 237
@@ -233,8 +248,8 @@ static int meram_plane_alloc(struct sh_mobile_meram_priv *priv,
233static void meram_plane_free(struct sh_mobile_meram_priv *priv, 248static void meram_plane_free(struct sh_mobile_meram_priv *priv,
234 struct sh_mobile_meram_fb_plane *plane) 249 struct sh_mobile_meram_fb_plane *plane)
235{ 250{
236 gen_pool_free(priv->pool, priv->meram + plane->marker->offset, 251 meram_free(priv, priv->meram + plane->marker->offset,
237 plane->marker->size * 1024); 252 plane->marker->size * 1024);
238 253
239 __clear_bit(plane->marker->index, &priv->used_icb); 254 __clear_bit(plane->marker->index, &priv->used_icb);
240 __clear_bit(plane->cache->index, &priv->used_icb); 255 __clear_bit(plane->cache->index, &priv->used_icb);
@@ -386,9 +401,27 @@ static void meram_plane_cleanup(struct sh_mobile_meram_priv *priv,
386} 401}
387 402
388/* ----------------------------------------------------------------------------- 403/* -----------------------------------------------------------------------------
389 * LCDC cache operations 404 * MERAM operations
390 */ 405 */
391 406
407unsigned long sh_mobile_meram_alloc(struct sh_mobile_meram_info *pdata,
408 size_t size)
409{
410 struct sh_mobile_meram_priv *priv = pdata->priv;
411
412 return meram_alloc(priv, size);
413}
414EXPORT_SYMBOL_GPL(sh_mobile_meram_alloc);
415
416void sh_mobile_meram_free(struct sh_mobile_meram_info *pdata, unsigned long mem,
417 size_t size)
418{
419 struct sh_mobile_meram_priv *priv = pdata->priv;
420
421 meram_free(priv, mem, size);
422}
423EXPORT_SYMBOL_GPL(sh_mobile_meram_free);
424
392/* Allocate memory for the ICBs and mark them as used. */ 425/* Allocate memory for the ICBs and mark them as used. */
393static struct sh_mobile_meram_fb_cache * 426static struct sh_mobile_meram_fb_cache *
394meram_cache_alloc(struct sh_mobile_meram_priv *priv, 427meram_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 11348379f09..062e6e7f955 100644
--- a/include/video/sh_mobile_meram.h
+++ b/include/video/sh_mobile_meram.h
@@ -38,6 +38,10 @@ struct sh_mobile_meram_cfg {
38 38
39#if defined(CONFIG_FB_SH_MOBILE_MERAM) || \ 39#if defined(CONFIG_FB_SH_MOBILE_MERAM) || \
40 defined(CONFIG_FB_SH_MOBILE_MERAM_MODULE) 40 defined(CONFIG_FB_SH_MOBILE_MERAM_MODULE)
41unsigned long sh_mobile_meram_alloc(struct sh_mobile_meram_info *meram_dev,
42 size_t size);
43void sh_mobile_meram_free(struct sh_mobile_meram_info *meram_dev,
44 unsigned long mem, size_t size);
41void *sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev, 45void *sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev,
42 const struct sh_mobile_meram_cfg *cfg, 46 const struct sh_mobile_meram_cfg *cfg,
43 unsigned int xres, unsigned int yres, 47 unsigned int xres, unsigned int yres,
@@ -50,6 +54,18 @@ void sh_mobile_meram_cache_update(struct sh_mobile_meram_info *dev, void *data,
50 unsigned long *icb_addr_y, 54 unsigned long *icb_addr_y,
51 unsigned long *icb_addr_c); 55 unsigned long *icb_addr_c);
52#else 56#else
57static inline unsigned long
58sh_mobile_meram_alloc(struct sh_mobile_meram_info *meram_dev, size_t size)
59{
60 return 0;
61}
62
63static inline void
64sh_mobile_meram_free(struct sh_mobile_meram_info *meram_dev,
65 unsigned long mem, size_t size)
66{
67}
68
53static inline void * 69static inline void *
54sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev, 70sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev,
55 const struct sh_mobile_meram_cfg *cfg, 71 const struct sh_mobile_meram_cfg *cfg,