aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/auxdisplay/cfag12864bfb.c
diff options
context:
space:
mode:
authorMiguel Ojeda Sandonis <maxextreme@gmail.com>2007-02-10 04:44:32 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 13:51:24 -0500
commit70e840499aae90be1de542894062ad2899d23642 (patch)
tree4d5122672bfb03fec0823540f19c7974979483f4 /drivers/auxdisplay/cfag12864bfb.c
parent81d79bec348ab06cba9ae9fc03eb015b6b83703a (diff)
[PATCH] drivers: add LCD support
Add support for auxiliary displays, the ks0108 LCD controller, the cfag12864b LCD and adds a framebuffer device: cfag12864bfb. - Add a "auxdisplay/" folder in "drivers/" for auxiliary display drivers. - Add support for the ks0108 LCD Controller as a device driver. (uses parport interface) - Add support for the cfag12864b LCD as a device driver. (uses ks0108 LCD Controller driver) - Add a framebuffer device called cfag12864bfb. (uses cfag12864b LCD driver) - Add the usual Documentation, includes, Makefiles, Kconfigs, MAINTAINERS, CREDITS... - Miguel Ojeda will maintain all the stuff above. [rdunlap@xenotime.net: workqueue fixups] [akpm@osdl.org: kconfig fix] Signed-off-by: Miguel Ojeda Sandonis <maxextreme@gmail.com> Cc: Greg KH <greg@kroah.com> Acked-by: Paulo Marques <pmarques@grupopie.com> Cc: "Randy.Dunlap" <rdunlap@xenotime.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/auxdisplay/cfag12864bfb.c')
-rw-r--r--drivers/auxdisplay/cfag12864bfb.c180
1 files changed, 180 insertions, 0 deletions
diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
new file mode 100644
index 000000000000..94765e78315f
--- /dev/null
+++ b/drivers/auxdisplay/cfag12864bfb.c
@@ -0,0 +1,180 @@
1/*
2 * Filename: cfag12864bfb.c
3 * Version: 0.1.0
4 * Description: cfag12864b LCD framebuffer driver
5 * License: GPLv2
6 * Depends: cfag12864b
7 *
8 * Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com>
9 * Date: 2006-10-31
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26#include <linux/init.h>
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/delay.h>
30#include <linux/errno.h>
31#include <linux/fb.h>
32#include <linux/mm.h>
33#include <linux/platform_device.h>
34#include <linux/slab.h>
35#include <linux/string.h>
36#include <linux/uaccess.h>
37#include <linux/cfag12864b.h>
38
39#define CFAG12864BFB_NAME "cfag12864bfb"
40
41static struct fb_fix_screeninfo cfag12864bfb_fix __initdata = {
42 .id = "cfag12864b",
43 .type = FB_TYPE_PACKED_PIXELS,
44 .visual = FB_VISUAL_MONO10,
45 .xpanstep = 0,
46 .ypanstep = 0,
47 .ywrapstep = 0,
48 .line_length = CFAG12864B_WIDTH / 8,
49 .accel = FB_ACCEL_NONE,
50};
51
52static struct fb_var_screeninfo cfag12864bfb_var __initdata = {
53 .xres = CFAG12864B_WIDTH,
54 .yres = CFAG12864B_HEIGHT,
55 .xres_virtual = CFAG12864B_WIDTH,
56 .yres_virtual = CFAG12864B_HEIGHT,
57 .bits_per_pixel = 1,
58 .red = { 0, 1, 0 },
59 .green = { 0, 1, 0 },
60 .blue = { 0, 1, 0 },
61 .left_margin = 0,
62 .right_margin = 0,
63 .upper_margin = 0,
64 .lower_margin = 0,
65 .vmode = FB_VMODE_NONINTERLACED,
66};
67
68static int cfag12864bfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
69{
70 return vm_insert_page(vma, vma->vm_start,
71 virt_to_page(cfag12864b_buffer));
72}
73
74static struct fb_ops cfag12864bfb_ops = {
75 .owner = THIS_MODULE,
76 .fb_fillrect = cfb_fillrect,
77 .fb_copyarea = cfb_copyarea,
78 .fb_imageblit = cfb_imageblit,
79 .fb_mmap = cfag12864bfb_mmap,
80};
81
82static int __init cfag12864bfb_probe(struct platform_device *device)
83{
84 int ret = -EINVAL;
85 struct fb_info *info = framebuffer_alloc(0, &device->dev);
86
87 if (!info)
88 goto none;
89
90 info->screen_base = (char __iomem *) cfag12864b_buffer;
91 info->screen_size = CFAG12864B_SIZE;
92 info->fbops = &cfag12864bfb_ops;
93 info->fix = cfag12864bfb_fix;
94 info->var = cfag12864bfb_var;
95 info->pseudo_palette = NULL;
96 info->par = NULL;
97 info->flags = FBINFO_FLAG_DEFAULT;
98
99 if (register_framebuffer(info) < 0)
100 goto fballoced;
101
102 platform_set_drvdata(device, info);
103
104 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
105 info->fix.id);
106
107 return 0;
108
109fballoced:
110 framebuffer_release(info);
111
112none:
113 return ret;
114}
115
116static int cfag12864bfb_remove(struct platform_device *device)
117{
118 struct fb_info *info = platform_get_drvdata(device);
119
120 if (info) {
121 unregister_framebuffer(info);
122 framebuffer_release(info);
123 }
124
125 return 0;
126}
127
128static struct platform_driver cfag12864bfb_driver = {
129 .probe = cfag12864bfb_probe,
130 .remove = cfag12864bfb_remove,
131 .driver = {
132 .name = CFAG12864BFB_NAME,
133 },
134};
135
136static struct platform_device *cfag12864bfb_device;
137
138static int __init cfag12864bfb_init(void)
139{
140 int ret;
141
142 if (cfag12864b_enable()) {
143 printk(KERN_ERR CFAG12864BFB_NAME ": ERROR: "
144 "can't enable cfag12864b refreshing (being used)\n");
145 return -ENODEV;
146 }
147
148 ret = platform_driver_register(&cfag12864bfb_driver);
149
150 if (!ret) {
151 cfag12864bfb_device =
152 platform_device_alloc(CFAG12864BFB_NAME, 0);
153
154 if (cfag12864bfb_device)
155 ret = platform_device_add(cfag12864bfb_device);
156 else
157 ret = -ENOMEM;
158
159 if (ret) {
160 platform_device_put(cfag12864bfb_device);
161 platform_driver_unregister(&cfag12864bfb_driver);
162 }
163 }
164
165 return ret;
166}
167
168static void __exit cfag12864bfb_exit(void)
169{
170 platform_device_unregister(cfag12864bfb_device);
171 platform_driver_unregister(&cfag12864bfb_driver);
172 cfag12864b_disable();
173}
174
175module_init(cfag12864bfb_init);
176module_exit(cfag12864bfb_exit);
177
178MODULE_LICENSE("GPL v2");
179MODULE_AUTHOR("Miguel Ojeda Sandonis <maxextreme@gmail.com>");
180MODULE_DESCRIPTION("cfag12864b LCD framebuffer driver");