diff options
-rw-r--r-- | drivers/video/sh_mobile_lcdcfb.c | 27 | ||||
-rw-r--r-- | drivers/video/sh_mobile_meram.c | 40 | ||||
-rw-r--r-- | include/video/sh_mobile_meram.h | 50 |
3 files changed, 65 insertions, 52 deletions
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c index e593e818872..9da4b1b619e 100644 --- a/drivers/video/sh_mobile_lcdcfb.c +++ b/drivers/video/sh_mobile_lcdcfb.c | |||
@@ -1115,13 +1115,12 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) | |||
1115 | ch->line_size = ch->pitch; | 1115 | ch->line_size = ch->pitch; |
1116 | 1116 | ||
1117 | /* Enable MERAM if possible. */ | 1117 | /* Enable MERAM if possible. */ |
1118 | if (mdev == NULL || mdev->ops == NULL || | 1118 | if (mdev == NULL || ch->cfg->meram_cfg == NULL) |
1119 | ch->cfg->meram_cfg == NULL) | ||
1120 | continue; | 1119 | continue; |
1121 | 1120 | ||
1122 | /* Free the allocated MERAM cache. */ | 1121 | /* Free the allocated MERAM cache. */ |
1123 | if (ch->cache) { | 1122 | if (ch->cache) { |
1124 | mdev->ops->cache_free(mdev, ch->cache); | 1123 | sh_mobile_meram_cache_free(mdev, ch->cache); |
1125 | ch->cache = NULL; | 1124 | ch->cache = NULL; |
1126 | } | 1125 | } |
1127 | 1126 | ||
@@ -1144,11 +1143,11 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) | |||
1144 | break; | 1143 | break; |
1145 | } | 1144 | } |
1146 | 1145 | ||
1147 | cache = mdev->ops->cache_alloc(mdev, ch->cfg->meram_cfg, | 1146 | cache = sh_mobile_meram_cache_alloc(mdev, ch->cfg->meram_cfg, |
1148 | ch->pitch, ch->yres, pixelformat, | 1147 | ch->pitch, ch->yres, pixelformat, |
1149 | &ch->line_size); | 1148 | &ch->line_size); |
1150 | if (!IS_ERR(cache)) { | 1149 | if (!IS_ERR(cache)) { |
1151 | mdev->ops->cache_update(mdev, cache, | 1150 | sh_mobile_meram_cache_update(mdev, cache, |
1152 | ch->base_addr_y, ch->base_addr_c, | 1151 | ch->base_addr_y, ch->base_addr_c, |
1153 | &ch->base_addr_y, &ch->base_addr_c); | 1152 | &ch->base_addr_y, &ch->base_addr_c); |
1154 | ch->cache = cache; | 1153 | ch->cache = cache; |
@@ -1223,9 +1222,7 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv) | |||
1223 | 1222 | ||
1224 | /* Free the MERAM cache. */ | 1223 | /* Free the MERAM cache. */ |
1225 | if (ch->cache) { | 1224 | if (ch->cache) { |
1226 | struct sh_mobile_meram_info *mdev; | 1225 | sh_mobile_meram_cache_free(priv->meram_dev, ch->cache); |
1227 | mdev = priv->meram_dev; | ||
1228 | mdev->ops->cache_free(mdev, ch->cache); | ||
1229 | ch->cache = 0; | 1226 | ch->cache = 0; |
1230 | } | 1227 | } |
1231 | 1228 | ||
@@ -1808,7 +1805,7 @@ static int sh_mobile_lcdc_pan(struct fb_var_screeninfo *var, | |||
1808 | struct sh_mobile_lcdc_priv *priv = ch->lcdc; | 1805 | struct sh_mobile_lcdc_priv *priv = ch->lcdc; |
1809 | unsigned long ldrcntr; | 1806 | unsigned long ldrcntr; |
1810 | unsigned long new_pan_offset; | 1807 | unsigned long new_pan_offset; |
1811 | unsigned long base_addr_y, base_addr_c; | 1808 | unsigned long base_addr_y, base_addr_c = 0; |
1812 | unsigned long c_offset; | 1809 | unsigned long c_offset; |
1813 | 1810 | ||
1814 | if (!ch->format->yuv) | 1811 | if (!ch->format->yuv) |
@@ -1837,14 +1834,10 @@ static int sh_mobile_lcdc_pan(struct fb_var_screeninfo *var, | |||
1837 | base_addr_c += var->xoffset; | 1834 | base_addr_c += var->xoffset; |
1838 | } | 1835 | } |
1839 | 1836 | ||
1840 | if (ch->cache) { | 1837 | if (ch->cache) |
1841 | struct sh_mobile_meram_info *mdev; | 1838 | sh_mobile_meram_cache_update(priv->meram_dev, ch->cache, |
1842 | 1839 | base_addr_y, base_addr_c, | |
1843 | mdev = priv->meram_dev; | 1840 | &base_addr_y, &base_addr_c); |
1844 | mdev->ops->cache_update(mdev, ch->cache, | ||
1845 | base_addr_y, base_addr_c, | ||
1846 | &base_addr_y, &base_addr_c); | ||
1847 | } | ||
1848 | 1841 | ||
1849 | ch->base_addr_y = base_addr_y; | 1842 | ch->base_addr_y = base_addr_y; |
1850 | ch->base_addr_c = base_addr_c; | 1843 | ch->base_addr_c = base_addr_c; |
diff --git a/drivers/video/sh_mobile_meram.c b/drivers/video/sh_mobile_meram.c index 4aa3fcb87f1..fdb6fc1decb 100644 --- a/drivers/video/sh_mobile_meram.c +++ b/drivers/video/sh_mobile_meram.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/device.h> | 12 | #include <linux/device.h> |
13 | #include <linux/err.h> | 13 | #include <linux/err.h> |
14 | #include <linux/export.h> | ||
14 | #include <linux/genalloc.h> | 15 | #include <linux/genalloc.h> |
15 | #include <linux/io.h> | 16 | #include <linux/io.h> |
16 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
@@ -429,11 +430,10 @@ error: | |||
429 | return ERR_PTR(-ENOMEM); | 430 | return ERR_PTR(-ENOMEM); |
430 | } | 431 | } |
431 | 432 | ||
432 | static void *sh_mobile_cache_alloc(struct sh_mobile_meram_info *pdata, | 433 | void *sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *pdata, |
433 | const struct sh_mobile_meram_cfg *cfg, | 434 | const struct sh_mobile_meram_cfg *cfg, |
434 | unsigned int xres, unsigned int yres, | 435 | unsigned int xres, unsigned int yres, |
435 | unsigned int pixelformat, | 436 | unsigned int pixelformat, unsigned int *pitch) |
436 | unsigned int *pitch) | ||
437 | { | 437 | { |
438 | struct sh_mobile_meram_fb_cache *cache; | 438 | struct sh_mobile_meram_fb_cache *cache; |
439 | struct sh_mobile_meram_priv *priv = pdata->priv; | 439 | struct sh_mobile_meram_priv *priv = pdata->priv; |
@@ -441,6 +441,9 @@ static void *sh_mobile_cache_alloc(struct sh_mobile_meram_info *pdata, | |||
441 | unsigned int nplanes = is_nvcolor(pixelformat) ? 2 : 1; | 441 | unsigned int nplanes = is_nvcolor(pixelformat) ? 2 : 1; |
442 | unsigned int out_pitch; | 442 | unsigned int out_pitch; |
443 | 443 | ||
444 | if (priv == NULL) | ||
445 | return ERR_PTR(-ENODEV); | ||
446 | |||
444 | if (pixelformat != SH_MOBILE_MERAM_PF_NV && | 447 | if (pixelformat != SH_MOBILE_MERAM_PF_NV && |
445 | pixelformat != SH_MOBILE_MERAM_PF_NV24 && | 448 | pixelformat != SH_MOBILE_MERAM_PF_NV24 && |
446 | pixelformat != SH_MOBILE_MERAM_PF_RGB) | 449 | pixelformat != SH_MOBILE_MERAM_PF_RGB) |
@@ -485,9 +488,10 @@ err: | |||
485 | mutex_unlock(&priv->lock); | 488 | mutex_unlock(&priv->lock); |
486 | return cache; | 489 | return cache; |
487 | } | 490 | } |
491 | EXPORT_SYMBOL_GPL(sh_mobile_meram_cache_alloc); | ||
488 | 492 | ||
489 | static void | 493 | void |
490 | sh_mobile_cache_free(struct sh_mobile_meram_info *pdata, void *data) | 494 | sh_mobile_meram_cache_free(struct sh_mobile_meram_info *pdata, void *data) |
491 | { | 495 | { |
492 | struct sh_mobile_meram_fb_cache *cache = data; | 496 | struct sh_mobile_meram_fb_cache *cache = data; |
493 | struct sh_mobile_meram_priv *priv = pdata->priv; | 497 | struct sh_mobile_meram_priv *priv = pdata->priv; |
@@ -507,11 +511,14 @@ sh_mobile_cache_free(struct sh_mobile_meram_info *pdata, void *data) | |||
507 | 511 | ||
508 | mutex_unlock(&priv->lock); | 512 | mutex_unlock(&priv->lock); |
509 | } | 513 | } |
510 | 514 | EXPORT_SYMBOL_GPL(sh_mobile_meram_cache_free); | |
511 | static void | 515 | |
512 | sh_mobile_cache_update(struct sh_mobile_meram_info *pdata, void *data, | 516 | void |
513 | unsigned long base_addr_y, unsigned long base_addr_c, | 517 | sh_mobile_meram_cache_update(struct sh_mobile_meram_info *pdata, void *data, |
514 | unsigned long *icb_addr_y, unsigned long *icb_addr_c) | 518 | unsigned long base_addr_y, |
519 | unsigned long base_addr_c, | ||
520 | unsigned long *icb_addr_y, | ||
521 | unsigned long *icb_addr_c) | ||
515 | { | 522 | { |
516 | struct sh_mobile_meram_fb_cache *cache = data; | 523 | struct sh_mobile_meram_fb_cache *cache = data; |
517 | struct sh_mobile_meram_priv *priv = pdata->priv; | 524 | struct sh_mobile_meram_priv *priv = pdata->priv; |
@@ -523,13 +530,7 @@ sh_mobile_cache_update(struct sh_mobile_meram_info *pdata, void *data, | |||
523 | 530 | ||
524 | mutex_unlock(&priv->lock); | 531 | mutex_unlock(&priv->lock); |
525 | } | 532 | } |
526 | 533 | EXPORT_SYMBOL_GPL(sh_mobile_meram_cache_update); | |
527 | static struct sh_mobile_meram_ops sh_mobile_meram_ops = { | ||
528 | .module = THIS_MODULE, | ||
529 | .cache_alloc = sh_mobile_cache_alloc, | ||
530 | .cache_free = sh_mobile_cache_free, | ||
531 | .cache_update = sh_mobile_cache_update, | ||
532 | }; | ||
533 | 534 | ||
534 | /* ----------------------------------------------------------------------------- | 535 | /* ----------------------------------------------------------------------------- |
535 | * Power management | 536 | * Power management |
@@ -620,7 +621,6 @@ static int __devinit sh_mobile_meram_probe(struct platform_device *pdev) | |||
620 | for (i = 0; i < MERAM_ICB_NUM; ++i) | 621 | for (i = 0; i < MERAM_ICB_NUM; ++i) |
621 | priv->icbs[i].index = i; | 622 | priv->icbs[i].index = i; |
622 | 623 | ||
623 | pdata->ops = &sh_mobile_meram_ops; | ||
624 | pdata->priv = priv; | 624 | pdata->priv = priv; |
625 | pdata->pdev = pdev; | 625 | pdata->pdev = pdev; |
626 | 626 | ||
diff --git a/include/video/sh_mobile_meram.h b/include/video/sh_mobile_meram.h index 8a5afaf2c6d..11348379f09 100644 --- a/include/video/sh_mobile_meram.h +++ b/include/video/sh_mobile_meram.h | |||
@@ -15,7 +15,6 @@ enum { | |||
15 | 15 | ||
16 | 16 | ||
17 | struct sh_mobile_meram_priv; | 17 | struct sh_mobile_meram_priv; |
18 | struct sh_mobile_meram_ops; | ||
19 | 18 | ||
20 | /* | 19 | /* |
21 | * struct sh_mobile_meram_info - MERAM platform data | 20 | * struct sh_mobile_meram_info - MERAM platform data |
@@ -24,7 +23,6 @@ struct sh_mobile_meram_ops; | |||
24 | struct sh_mobile_meram_info { | 23 | struct sh_mobile_meram_info { |
25 | int addr_mode; | 24 | int addr_mode; |
26 | u32 reserved_icbs; | 25 | u32 reserved_icbs; |
27 | struct sh_mobile_meram_ops *ops; | ||
28 | struct sh_mobile_meram_priv *priv; | 26 | struct sh_mobile_meram_priv *priv; |
29 | struct platform_device *pdev; | 27 | struct platform_device *pdev; |
30 | }; | 28 | }; |
@@ -38,21 +36,43 @@ struct sh_mobile_meram_cfg { | |||
38 | struct sh_mobile_meram_icb_cfg icb[2]; | 36 | struct sh_mobile_meram_icb_cfg icb[2]; |
39 | }; | 37 | }; |
40 | 38 | ||
41 | struct module; | 39 | #if defined(CONFIG_FB_SH_MOBILE_MERAM) || \ |
42 | struct sh_mobile_meram_ops { | 40 | defined(CONFIG_FB_SH_MOBILE_MERAM_MODULE) |
43 | struct module *module; | 41 | void *sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev, |
44 | 42 | const struct sh_mobile_meram_cfg *cfg, | |
45 | /* LCDC cache management */ | 43 | unsigned int xres, unsigned int yres, |
46 | void *(*cache_alloc)(struct sh_mobile_meram_info *meram_dev, | 44 | unsigned int pixelformat, |
47 | const struct sh_mobile_meram_cfg *cfg, | 45 | unsigned int *pitch); |
48 | unsigned int xres, unsigned int yres, | 46 | void sh_mobile_meram_cache_free(struct sh_mobile_meram_info *dev, void *data); |
49 | unsigned int pixelformat, unsigned int *pitch); | 47 | void sh_mobile_meram_cache_update(struct sh_mobile_meram_info *dev, void *data, |
50 | void (*cache_free)(struct sh_mobile_meram_info *meram_dev, void *data); | 48 | unsigned long base_addr_y, |
51 | void (*cache_update)(struct sh_mobile_meram_info *meram_dev, void *data, | 49 | unsigned long base_addr_c, |
50 | unsigned long *icb_addr_y, | ||
51 | unsigned long *icb_addr_c); | ||
52 | #else | ||
53 | static inline void * | ||
54 | sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev, | ||
55 | const struct sh_mobile_meram_cfg *cfg, | ||
56 | unsigned int xres, unsigned int yres, | ||
57 | unsigned int pixelformat, | ||
58 | unsigned int *pitch) | ||
59 | { | ||
60 | return ERR_PTR(-ENODEV); | ||
61 | } | ||
62 | |||
63 | static inline void | ||
64 | sh_mobile_meram_cache_free(struct sh_mobile_meram_info *dev, void *data) | ||
65 | { | ||
66 | } | ||
67 | |||
68 | static inline void | ||
69 | sh_mobile_meram_cache_update(struct sh_mobile_meram_info *dev, void *data, | ||
52 | unsigned long base_addr_y, | 70 | unsigned long base_addr_y, |
53 | unsigned long base_addr_c, | 71 | unsigned long base_addr_c, |
54 | unsigned long *icb_addr_y, | 72 | unsigned long *icb_addr_y, |
55 | unsigned long *icb_addr_c); | 73 | unsigned long *icb_addr_c) |
56 | }; | 74 | { |
75 | } | ||
76 | #endif | ||
57 | 77 | ||
58 | #endif /* __VIDEO_SH_MOBILE_MERAM_H__ */ | 78 | #endif /* __VIDEO_SH_MOBILE_MERAM_H__ */ |