All pastes #797256 Raw Edit

Something

public text v1 · immutable
#797256 ·published 2007-11-25 21:26 UTC
rendered paste body
---
 drivers/video/Kconfig  |   14 ++++++
 drivers/video/Makefile |    1 +
 drivers/video/vsfb.c   |  117
++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/vsfb.h   |   23 +++++++++
 4 files changed, 155 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/vsfb.c
 create mode 100644 include/linux/vsfb.h

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 7d86e9e..302fb8d 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1892,6 +1892,20 @@ config FB_VIRTUAL

 	  If unsure, say N.

+config FB_VSFB
+	tristate "Very Simple FrameBuffer (vsfb) driver"
+	depends on FB
+	select FB_CFB_FILLRECT
+	select FB_CFB_COPYAREA
+	select FB_CFB_IMAGEBLIT
+	---help---
+	  This is a very simple framebuffer device intended for either
+	  testing devices for which no proper video driver exists or for
+	  use on very simple framebuffers that have been set up by 'bios like'
+	  bootloaders that reserve a block of linear memory for a framebuffer.
+
+	  If unsure, say N.
+
 source "drivers/video/omap/Kconfig"

 source "drivers/video/backlight/Kconfig"
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 59d6c45..80f9d2a 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -124,6 +124,7 @@ obj-$(CONFIG_FB_BF54X_LQ043)	  += bf54x-lq043fb.o

 # the test framebuffer is last
 obj-$(CONFIG_FB_VIRTUAL)          += vfb.o
+obj-$(CONFIG_FB_VSFB)             += vsfb.o

 #video output switch sysfs driver
 obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) += output.o
diff --git a/drivers/video/vsfb.c b/drivers/video/vsfb.c
new file mode 100644
index 0000000..973441d
--- /dev/null
+++ b/drivers/video/vsfb.c
@@ -0,0 +1,117 @@
+/*
+ *  linux/drivers/video/vsfb.c
+ *
+ *  Copyright (C) 2003 Ian Molton
+ *
+ * Based on acornfb by Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Frame buffer code for Simple platforms
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/mm.h>
+#include <linux/tty.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/fb.h>
+#include <linux/vsfb.h>
+#include <linux/ioport.h>
+#include <linux/platform_device.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+#include <asm/uaccess.h>
+
+static struct fb_info fb_info;
+static u32 colreg[17];
+
+
+static int
+vsfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
+		  u_int trans, struct fb_info *info)
+{
+        if (regno > 16)
+                return 1;
+        
+        ((u32 *)(info->pseudo_palette))[regno] = (red & 0xf800) |
((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11);
+
+	return 0;
+}
+
+static struct fb_ops vsfb_ops = {
+	.owner		= THIS_MODULE,
+	.fb_setcolreg	= vsfb_setcolreg,
+	.fb_fillrect	= cfb_fillrect,
+	.fb_copyarea	= cfb_copyarea,
+	.fb_imageblit	= cfb_imageblit,
+};
+
+static int vsfb_probe(struct platform_device *pdev) {
+	struct vsfb_deviceinfo *vsfb;
+	
+	vsfb = pdev->dev.platform_data;
+	if(!vsfb)
+		return -ENODEV;
+
+        memcpy (&fb_info.fix, vsfb->fix, sizeof(struct
fb_fix_screeninfo));
+        memcpy (&fb_info.var, vsfb->var, sizeof(struct
fb_var_screeninfo));
+
+        fb_info.fbops           = &vsfb_ops;
+        fb_info.flags           = FBINFO_FLAG_DEFAULT;
+        fb_info.pseudo_palette  = colreg;
+        fb_alloc_cmap(&fb_info.cmap, 16, 0);
+                                                                                 
+	/* Try to grab our phys memory space... */
+	if (!(request_mem_region(fb_info.fix.smem_start, fb_info.fix.smem_len,
"vsfb"))){
+                return -ENOMEM;
+	}
+
+	/* Try to map this so we can access it */
+	fb_info.screen_base    = ioremap(fb_info.fix.smem_start,
fb_info.fix.smem_len);
+	if (!fb_info.screen_base) {
+		release_mem_region(fb_info.fix.smem_start, fb_info.fix.smem_len);
+		return -EIO;
+	}
+
+	printk(KERN_INFO "vsfb: framebuffer at 0x%lx, mapped to 0x%p, size %dk
\n", fb_info.fix.smem_start, fb_info.screen_base,
fb_info.fix.smem_len/1024);
+
+	if (register_framebuffer(&fb_info) < 0){
+		iounmap(fb_info.screen_base);
+		release_mem_region(fb_info.fix.smem_start, fb_info.fix.smem_len);
+
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+struct platform_driver vsfb_driver = {
+        .driver = {
+                .name = "vsfb",
+        },
+        .probe = vsfb_probe,
+};
+
+static int __init vsfb_init(void)
+{
+        return platform_driver_register (&vsfb_driver);
+        return 0;
+}
+
+module_init(vsfb_init);
+
+MODULE_AUTHOR("Ian Molton <spyro <at> f2s.com>");
+MODULE_DESCRIPTION("Very Simple framebuffer driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/vsfb.h b/include/linux/vsfb.h
new file mode 100644
index 0000000..1d4a872
--- /dev/null
+++ b/include/linux/vsfb.h
@@ -0,0 +1,23 @@
+/*
+ * vsfb.h
+ *
+ * (c) 2006 Ian Molton <spyro <at> f2s.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _VSFB_H_INCLUDED
+#define _VSFB_H_INCLUDED
+
+#include <linux/fb.h>
+
+struct vsfb_deviceinfo
+{
+	struct fb_var_screeninfo *var;
+	struct fb_fix_screeninfo *fix;
+};
+
+#endif
-- 
1.5.3.5.737.gdee1b