[PATCH] omap4-fb: use uncached screen_base
Jan Weitzel
j.weitzel at phytec.de
Thu May 2 05:45:06 EDT 2013
If the buffer is cached the image on the LCD is broken. Only some small
lines on the last rows. Flushing the cache "repairs" the image.
Use remap_range for preallocated screen and dma_alloc_coherent for
dynamic.
based on '[PATCH] omap4-fb: add driver' could be squashed in.
Signed-off-by: Jan Weitzel <j.weitzel at phytec.de>
---
drivers/video/omap4.c | 32 +++++++++++++++++++++++++-------
1 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/drivers/video/omap4.c b/drivers/video/omap4.c
index 5642f25..f510cb3 100644
--- a/drivers/video/omap4.c
+++ b/drivers/video/omap4.c
@@ -32,6 +32,8 @@
#include <mach/omap4-silicon.h>
#include <mach/omap4-fb.h>
+#include <asm/mmu.h>
+
#include "omap4.h"
struct omap4fb_device {
@@ -63,7 +65,7 @@ struct omap4fb_device {
unsigned int lckd;
unsigned int pckd;
} divisor;
-
+ size_t dma_size;
void (*enable_fn)(int);
struct fb_videomode video_modes[];
@@ -133,10 +135,12 @@ static void omap4fb_disable(struct fb_info *info)
~(DSS_DISPC_VIDn_ATTRIBUTES_VIDENABLE),
&dispc->vid1.attributes);
- if (fbi->prealloc_screen.addr == NULL)
+ if (fbi->prealloc_screen.addr == NULL) {
/* free frame buffer; but only when screen is not
* preallocated */
- free(info->screen_base);
+ if (info->screen_base)
+ dma_free_coherent(info->screen_base, fbi->dma_size);
+ }
info->screen_base = NULL;
@@ -285,15 +289,20 @@ static int omap4fb_activate_var(struct fb_info *info)
goto out;
}
+ /*Free old screen buf*/
+ if (!fbi->prealloc_screen.addr && info->screen_base)
+ dma_free_coherent(info->screen_base, fbi->dma_size);
+
+ fbi->dma_size = PAGE_ALIGN(size);
+
if (fbi->prealloc_screen.addr == NULL) {
/* case 1: no preallocated screen */
- free(info->screen_base);
- info->screen_base = memalign(0x100, size);
- } else if (fbi->prealloc_screen.size < size) {
+ info->screen_base = dma_alloc_coherent(size);
+ } else if (fbi->prealloc_screen.size < fbi->dma_size) {
/* case 2: preallocated screen, but too small */
dev_err(fbi->dev,
"allocated framebuffer too small (%zu < %zu)\n",
- fbi->prealloc_screen.size, size);
+ fbi->prealloc_screen.size, fbi->dma_size);
rc = -ENOMEM;
goto out;
} else {
@@ -486,9 +495,18 @@ static int omap4fb_probe(struct device_d *dev)
info->bits_per_pixel = pdata->bpp;
if (pdata->screen) {
+ if (!IS_ALIGNED(pdata->screen->start, PAGE_SIZE) ||
+ !IS_ALIGNED(resource_size(pdata->screen), PAGE_SIZE)) {
+ dev_err(dev, "screen resource not aligned\n");
+ rc = -EINVAL;
+ goto out;
+ }
fbi->prealloc_screen.addr =
(void __iomem *)pdata->screen->start;
fbi->prealloc_screen.size = resource_size(pdata->screen);
+ remap_range(fbi->prealloc_screen.addr,
+ fbi->prealloc_screen.size,
+ mmu_get_pte_uncached_flags());
}
omap4fb_reset(fbi);
--
1.7.0.4
More information about the barebox
mailing list