mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jan Weitzel <j.weitzel@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH] omap4-fb: use uncached screen_base
Date: Thu, 2 May 2013 11:45:06 +0200	[thread overview]
Message-ID: <1367487906-25318-1-git-send-email-j.weitzel@phytec.de> (raw)

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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2013-05-02  9:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1367487906-25318-1-git-send-email-j.weitzel@phytec.de \
    --to=j.weitzel@phytec.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox