mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fb: added flush() method to synchronize the used DMA buffer
@ 2012-03-06 19:09 Enrico Scholz
  0 siblings, 0 replies; only message in thread
From: Enrico Scholz @ 2012-03-06 19:09 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Scholz

Patch adds an fb_flush() method which drains DMA buffers allocated by
the framebuffer driver. This allows to use non-coherent memory which
can be flushed by tools like 'bmp' or 'mw' by calling flush().

Unfortunately, DMA stuff is very specific to the architecture so that
patch has an effect to ARM only.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 drivers/video/Kconfig |    8 ++++++++
 drivers/video/fb.c    |   24 ++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 509ba64..a38e472 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -5,6 +5,14 @@ menuconfig VIDEO
 
 if VIDEO
 
+config DRIVER_FB_ENABLE_FLUSH
+	bool
+	depends on ARM
+	default y if MMU
+	help
+	  Drain DMA buffers with flush().  For ARM, this is required
+	  for setups with enabled MMU only
+
 config DRIVER_VIDEO_IMX
 	bool "i.MX framebuffer driver"
 	depends on ARCH_IMX1 || ARCH_IMX21 || ARCH_IMX25 || ARCH_IMX27
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 338d182..235e2e3 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -7,6 +7,10 @@
 #include <fs.h>
 #include <init.h>
 
+#ifdef CONFIG_ARM
+#  include <asm/mmu.h>
+#endif
+
 static int fb_ioctl(struct cdev* cdev, int req, void *data)
 {
 	struct fb_info *info = cdev->priv;
@@ -94,12 +98,32 @@ static int fb_setup_mode(struct device_d *dev, struct param_d *param,
 	return ret;
 }
 
+#ifdef CONFIG_DRIVER_FB_ENABLE_FLUSH
+static int fb_flush(struct cdev *cdev)
+{
+	struct fb_info *info = cdev->priv;
+
+	if (info->dev.resource[0].size > 0) {
+#ifdef CONFIG_ARM
+		dma_flush_range(info->dev.resource[0].start,
+				info->dev.resource[0].start +
+				info->dev.resource[0].size);
+#endif
+	}
+
+	return 0;
+}
+#else
+#  define fb_flush	NULL
+#endif	/* CONFIG_DRIVER_FB_ENABLE_FLUSH */
+
 static struct file_operations fb_ops = {
 	.read	= mem_read,
 	.write	= mem_write,
 	.memmap	= generic_memmap_rw,
 	.lseek	= dev_lseek_default,
 	.ioctl	= fb_ioctl,
+	.flush  = fb_flush,
 };
 
 int register_framebuffer(struct fb_info *info)
-- 
1.7.7.6


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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-03-06 19:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-06 19:09 [PATCH] fb: added flush() method to synchronize the used DMA buffer Enrico Scholz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox