diff options
author | Miguel Ojeda Sandonis <maxextreme@gmail.com> | 2007-02-10 04:44:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-11 13:51:24 -0500 |
commit | 70e840499aae90be1de542894062ad2899d23642 (patch) | |
tree | 4d5122672bfb03fec0823540f19c7974979483f4 /Documentation/auxdisplay | |
parent | 81d79bec348ab06cba9ae9fc03eb015b6b83703a (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 'Documentation/auxdisplay')
-rw-r--r-- | Documentation/auxdisplay/cfag12864b | 105 | ||||
-rw-r--r-- | Documentation/auxdisplay/cfag12864b-example.c | 282 | ||||
-rw-r--r-- | Documentation/auxdisplay/ks0108 | 55 |
3 files changed, 442 insertions, 0 deletions
diff --git a/Documentation/auxdisplay/cfag12864b b/Documentation/auxdisplay/cfag12864b new file mode 100644 index 000000000000..3572b98f45b8 --- /dev/null +++ b/Documentation/auxdisplay/cfag12864b | |||
@@ -0,0 +1,105 @@ | |||
1 | =================================== | ||
2 | cfag12864b LCD Driver Documentation | ||
3 | =================================== | ||
4 | |||
5 | License: GPLv2 | ||
6 | Author & Maintainer: Miguel Ojeda Sandonis <maxextreme@gmail.com> | ||
7 | Date: 2006-10-27 | ||
8 | |||
9 | |||
10 | |||
11 | -------- | ||
12 | 0. INDEX | ||
13 | -------- | ||
14 | |||
15 | 1. DRIVER INFORMATION | ||
16 | 2. DEVICE INFORMATION | ||
17 | 3. WIRING | ||
18 | 4. USERSPACE PROGRAMMING | ||
19 | |||
20 | |||
21 | --------------------- | ||
22 | 1. DRIVER INFORMATION | ||
23 | --------------------- | ||
24 | |||
25 | This driver support one cfag12864b display at time. | ||
26 | |||
27 | |||
28 | --------------------- | ||
29 | 2. DEVICE INFORMATION | ||
30 | --------------------- | ||
31 | |||
32 | Manufacturer: Crystalfontz | ||
33 | Device Name: Crystalfontz 12864b LCD Series | ||
34 | Device Code: cfag12864b | ||
35 | Webpage: http://www.crystalfontz.com | ||
36 | Device Webpage: http://www.crystalfontz.com/products/12864b/ | ||
37 | Type: LCD (Liquid Crystal Display) | ||
38 | Width: 128 | ||
39 | Height: 64 | ||
40 | Colors: 2 (B/N) | ||
41 | Controller: ks0108 | ||
42 | Controllers: 2 | ||
43 | Pages: 8 each controller | ||
44 | Addresses: 64 each page | ||
45 | Data size: 1 byte each address | ||
46 | Memory size: 2 * 8 * 64 * 1 = 1024 bytes = 1 Kbyte | ||
47 | |||
48 | |||
49 | --------- | ||
50 | 3. WIRING | ||
51 | --------- | ||
52 | |||
53 | The cfag12864b LCD Series don't have official wiring. | ||
54 | |||
55 | The common wiring is done to the parallel port as shown: | ||
56 | |||
57 | Parallel Port cfag12864b | ||
58 | |||
59 | Name Pin# Pin# Name | ||
60 | |||
61 | Strobe ( 1)------------------------------(17) Enable | ||
62 | Data 0 ( 2)------------------------------( 4) Data 0 | ||
63 | Data 1 ( 3)------------------------------( 5) Data 1 | ||
64 | Data 2 ( 4)------------------------------( 6) Data 2 | ||
65 | Data 3 ( 5)------------------------------( 7) Data 3 | ||
66 | Data 4 ( 6)------------------------------( 8) Data 4 | ||
67 | Data 5 ( 7)------------------------------( 9) Data 5 | ||
68 | Data 6 ( 8)------------------------------(10) Data 6 | ||
69 | Data 7 ( 9)------------------------------(11) Data 7 | ||
70 | (10) [+5v]---( 1) Vdd | ||
71 | (11) [GND]---( 2) Ground | ||
72 | (12) [+5v]---(14) Reset | ||
73 | (13) [GND]---(15) Read / Write | ||
74 | Line (14)------------------------------(13) Controller Select 1 | ||
75 | (15) | ||
76 | Init (16)------------------------------(12) Controller Select 2 | ||
77 | Select (17)------------------------------(16) Data / Instruction | ||
78 | Ground (18)---[GND] [+5v]---(19) LED + | ||
79 | Ground (19)---[GND] | ||
80 | Ground (20)---[GND] E A Values: | ||
81 | Ground (21)---[GND] [GND]---[P1]---(18) Vee · R = Resistor = 22 ohm | ||
82 | Ground (22)---[GND] | · P1 = Preset = 10 Kohm | ||
83 | Ground (23)---[GND] ---- S ------( 3) V0 · P2 = Preset = 1 Kohm | ||
84 | Ground (24)---[GND] | | | ||
85 | Ground (25)---[GND] [GND]---[P2]---[R]---(20) LED - | ||
86 | |||
87 | |||
88 | ------------------------ | ||
89 | 4. USERSPACE PROGRAMMING | ||
90 | ------------------------ | ||
91 | |||
92 | The cfag12864bfb describes a framebuffer device (/dev/fbX). | ||
93 | |||
94 | It has a size of 1024 bytes = 1 Kbyte. | ||
95 | Each bit represents one pixel. If the bit is high, the pixel will | ||
96 | turn on. If the pixel is low, the pixel will turn off. | ||
97 | |||
98 | You can use the framebuffer as a file: fopen, fwrite, fclose... | ||
99 | Although the LCD won't get updated until the next refresh time arrives. | ||
100 | |||
101 | Also, you can mmap the framebuffer: open & mmap, munmap & close... | ||
102 | which is the best option for most uses. | ||
103 | |||
104 | Check Documentation/auxdisplay/cfag12864b-example.c | ||
105 | for a real working userspace complete program with usage examples. | ||
diff --git a/Documentation/auxdisplay/cfag12864b-example.c b/Documentation/auxdisplay/cfag12864b-example.c new file mode 100644 index 000000000000..7bfac354d4c9 --- /dev/null +++ b/Documentation/auxdisplay/cfag12864b-example.c | |||
@@ -0,0 +1,282 @@ | |||
1 | /* | ||
2 | * Filename: cfag12864b-example.c | ||
3 | * Version: 0.1.0 | ||
4 | * Description: cfag12864b LCD userspace example program | ||
5 | * License: GPLv2 | ||
6 | * | ||
7 | * Author: Copyright (C) Miguel Ojeda Sandonis <maxextreme@gmail.com> | ||
8 | * Date: 2006-10-31 | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | /* | ||
26 | * ------------------------ | ||
27 | * start of cfag12864b code | ||
28 | * ------------------------ | ||
29 | */ | ||
30 | |||
31 | #include <string.h> | ||
32 | #include <fcntl.h> | ||
33 | #include <unistd.h> | ||
34 | #include <sys/types.h> | ||
35 | #include <sys/stat.h> | ||
36 | #include <sys/mman.h> | ||
37 | |||
38 | #define CFAG12864B_WIDTH (128) | ||
39 | #define CFAG12864B_HEIGHT (64) | ||
40 | #define CFAG12864B_SIZE (128 * 64 / 8) | ||
41 | #define CFAG12864B_BPB (8) | ||
42 | #define CFAG12864B_ADDRESS(x, y) ((y) * CFAG12864B_WIDTH / \ | ||
43 | CFAG12864B_BPB + (x) / CFAG12864B_BPB) | ||
44 | #define CFAG12864B_BIT(n) (((unsigned char) 1) << (n)) | ||
45 | |||
46 | #undef CFAG12864B_DOCHECK | ||
47 | #ifdef CFAG12864B_DOCHECK | ||
48 | #define CFAG12864B_CHECK(x, y) ((x) < CFAG12864B_WIDTH && \ | ||
49 | (y) < CFAG12864B_HEIGHT) | ||
50 | #else | ||
51 | #define CFAG12864B_CHECK(x, y) (1) | ||
52 | #endif | ||
53 | |||
54 | int cfag12864b_fd; | ||
55 | unsigned char * cfag12864b_mem; | ||
56 | unsigned char cfag12864b_buffer[CFAG12864B_SIZE]; | ||
57 | |||
58 | /* | ||
59 | * init a cfag12864b framebuffer device | ||
60 | * | ||
61 | * No error: return = 0 | ||
62 | * Unable to open: return = -1 | ||
63 | * Unable to mmap: return = -2 | ||
64 | */ | ||
65 | int cfag12864b_init(char *path) | ||
66 | { | ||
67 | cfag12864b_fd = open(path, O_RDWR); | ||
68 | if (cfag12864b_fd == -1) | ||
69 | return -1; | ||
70 | |||
71 | cfag12864b_mem = mmap(0, CFAG12864B_SIZE, PROT_READ | PROT_WRITE, | ||
72 | MAP_SHARED, cfag12864b_fd, 0); | ||
73 | if (cfag12864b_mem == MAP_FAILED) { | ||
74 | close(cfag12864b_fd); | ||
75 | return -2; | ||
76 | } | ||
77 | |||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | /* | ||
82 | * exit a cfag12864b framebuffer device | ||
83 | */ | ||
84 | void cfag12864b_exit(void) | ||
85 | { | ||
86 | munmap(cfag12864b_mem, CFAG12864B_SIZE); | ||
87 | close(cfag12864b_fd); | ||
88 | } | ||
89 | |||
90 | /* | ||
91 | * set (x, y) pixel | ||
92 | */ | ||
93 | void cfag12864b_set(unsigned char x, unsigned char y) | ||
94 | { | ||
95 | if (CFAG12864B_CHECK(x, y)) | ||
96 | cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] |= | ||
97 | CFAG12864B_BIT(x % CFAG12864B_BPB); | ||
98 | } | ||
99 | |||
100 | /* | ||
101 | * unset (x, y) pixel | ||
102 | */ | ||
103 | void cfag12864b_unset(unsigned char x, unsigned char y) | ||
104 | { | ||
105 | if (CFAG12864B_CHECK(x, y)) | ||
106 | cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] &= | ||
107 | ~CFAG12864B_BIT(x % CFAG12864B_BPB); | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * is set (x, y) pixel? | ||
112 | * | ||
113 | * Pixel off: return = 0 | ||
114 | * Pixel on: return = 1 | ||
115 | */ | ||
116 | unsigned char cfag12864b_isset(unsigned char x, unsigned char y) | ||
117 | { | ||
118 | if (CFAG12864B_CHECK(x, y)) | ||
119 | if (cfag12864b_buffer[CFAG12864B_ADDRESS(x, y)] & | ||
120 | CFAG12864B_BIT(x % CFAG12864B_BPB)) | ||
121 | return 1; | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | /* | ||
127 | * not (x, y) pixel | ||
128 | */ | ||
129 | void cfag12864b_not(unsigned char x, unsigned char y) | ||
130 | { | ||
131 | if (cfag12864b_isset(x, y)) | ||
132 | cfag12864b_unset(x, y); | ||
133 | else | ||
134 | cfag12864b_set(x, y); | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * fill (set all pixels) | ||
139 | */ | ||
140 | void cfag12864b_fill(void) | ||
141 | { | ||
142 | unsigned short i; | ||
143 | |||
144 | for (i = 0; i < CFAG12864B_SIZE; i++) | ||
145 | cfag12864b_buffer[i] = 0xFF; | ||
146 | } | ||
147 | |||
148 | /* | ||
149 | * clear (unset all pixels) | ||
150 | */ | ||
151 | void cfag12864b_clear(void) | ||
152 | { | ||
153 | unsigned short i; | ||
154 | |||
155 | for (i = 0; i < CFAG12864B_SIZE; i++) | ||
156 | cfag12864b_buffer[i] = 0; | ||
157 | } | ||
158 | |||
159 | /* | ||
160 | * format a [128*64] matrix | ||
161 | * | ||
162 | * Pixel off: src[i] = 0 | ||
163 | * Pixel on: src[i] > 0 | ||
164 | */ | ||
165 | void cfag12864b_format(unsigned char * matrix) | ||
166 | { | ||
167 | unsigned char i, j, n; | ||
168 | |||
169 | for (i = 0; i < CFAG12864B_HEIGHT; i++) | ||
170 | for (j = 0; j < CFAG12864B_WIDTH / CFAG12864B_BPB; j++) { | ||
171 | cfag12864b_buffer[i * CFAG12864B_WIDTH / CFAG12864B_BPB + | ||
172 | j] = 0; | ||
173 | for (n = 0; n < CFAG12864B_BPB; n++) | ||
174 | if (matrix[i * CFAG12864B_WIDTH + | ||
175 | j * CFAG12864B_BPB + n]) | ||
176 | cfag12864b_buffer[i * CFAG12864B_WIDTH / | ||
177 | CFAG12864B_BPB + j] |= | ||
178 | CFAG12864B_BIT(n); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | /* | ||
183 | * blit buffer to lcd | ||
184 | */ | ||
185 | void cfag12864b_blit(void) | ||
186 | { | ||
187 | memcpy(cfag12864b_mem, cfag12864b_buffer, CFAG12864B_SIZE); | ||
188 | } | ||
189 | |||
190 | /* | ||
191 | * ---------------------- | ||
192 | * end of cfag12864b code | ||
193 | * ---------------------- | ||
194 | */ | ||
195 | |||
196 | #include <stdio.h> | ||
197 | #include <string.h> | ||
198 | |||
199 | #define EXAMPLES 6 | ||
200 | |||
201 | void example(unsigned char n) | ||
202 | { | ||
203 | unsigned short i, j; | ||
204 | unsigned char matrix[CFAG12864B_WIDTH * CFAG12864B_HEIGHT]; | ||
205 | |||
206 | if (n > EXAMPLES) | ||
207 | return; | ||
208 | |||
209 | printf("Example %i/%i - ", n, EXAMPLES); | ||
210 | |||
211 | switch (n) { | ||
212 | case 1: | ||
213 | printf("Draw points setting bits"); | ||
214 | cfag12864b_clear(); | ||
215 | for (i = 0; i < CFAG12864B_WIDTH; i += 2) | ||
216 | for (j = 0; j < CFAG12864B_HEIGHT; j += 2) | ||
217 | cfag12864b_set(i, j); | ||
218 | break; | ||
219 | |||
220 | case 2: | ||
221 | printf("Clear the LCD"); | ||
222 | cfag12864b_clear(); | ||
223 | break; | ||
224 | |||
225 | case 3: | ||
226 | printf("Draw rows formatting a [128*64] matrix"); | ||
227 | memset(matrix, 0, CFAG12864B_WIDTH * CFAG12864B_HEIGHT); | ||
228 | for (i = 0; i < CFAG12864B_WIDTH; i++) | ||
229 | for (j = 0; j < CFAG12864B_HEIGHT; j += 2) | ||
230 | matrix[j * CFAG12864B_WIDTH + i] = 1; | ||
231 | cfag12864b_format(matrix); | ||
232 | break; | ||
233 | |||
234 | case 4: | ||
235 | printf("Fill the lcd"); | ||
236 | cfag12864b_fill(); | ||
237 | break; | ||
238 | |||
239 | case 5: | ||
240 | printf("Draw columns unsetting bits"); | ||
241 | for (i = 0; i < CFAG12864B_WIDTH; i += 2) | ||
242 | for (j = 0; j < CFAG12864B_HEIGHT; j++) | ||
243 | cfag12864b_unset(i, j); | ||
244 | break; | ||
245 | |||
246 | case 6: | ||
247 | printf("Do negative not-ing all bits"); | ||
248 | for (i = 0; i < CFAG12864B_WIDTH; i++) | ||
249 | for (j = 0; j < CFAG12864B_HEIGHT; j ++) | ||
250 | cfag12864b_not(i, j); | ||
251 | break; | ||
252 | } | ||
253 | |||
254 | puts(" - [Press Enter]"); | ||
255 | } | ||
256 | |||
257 | int main(int argc, char *argv[]) | ||
258 | { | ||
259 | unsigned char n; | ||
260 | |||
261 | if (argc != 2) { | ||
262 | printf( | ||
263 | "Sintax: %s fbdev\n" | ||
264 | "Usually: /dev/fb0, /dev/fb1...\n", argv[0]); | ||
265 | return -1; | ||
266 | } | ||
267 | |||
268 | if (cfag12864b_init(argv[1])) { | ||
269 | printf("Can't init %s fbdev\n", argv[1]); | ||
270 | return -2; | ||
271 | } | ||
272 | |||
273 | for (n = 1; n <= EXAMPLES; n++) { | ||
274 | example(n); | ||
275 | cfag12864b_blit(); | ||
276 | while (getchar() != '\n'); | ||
277 | } | ||
278 | |||
279 | cfag12864b_exit(); | ||
280 | |||
281 | return 0; | ||
282 | } | ||
diff --git a/Documentation/auxdisplay/ks0108 b/Documentation/auxdisplay/ks0108 new file mode 100644 index 000000000000..92b03b60c613 --- /dev/null +++ b/Documentation/auxdisplay/ks0108 | |||
@@ -0,0 +1,55 @@ | |||
1 | ========================================== | ||
2 | ks0108 LCD Controller Driver Documentation | ||
3 | ========================================== | ||
4 | |||
5 | License: GPLv2 | ||
6 | Author & Maintainer: Miguel Ojeda Sandonis <maxextreme@gmail.com> | ||
7 | Date: 2006-10-27 | ||
8 | |||
9 | |||
10 | |||
11 | -------- | ||
12 | 0. INDEX | ||
13 | -------- | ||
14 | |||
15 | 1. DRIVER INFORMATION | ||
16 | 2. DEVICE INFORMATION | ||
17 | 3. WIRING | ||
18 | |||
19 | |||
20 | --------------------- | ||
21 | 1. DRIVER INFORMATION | ||
22 | --------------------- | ||
23 | |||
24 | This driver support the ks0108 LCD controller. | ||
25 | |||
26 | |||
27 | --------------------- | ||
28 | 2. DEVICE INFORMATION | ||
29 | --------------------- | ||
30 | |||
31 | Manufacturer: Samsung | ||
32 | Device Name: KS0108 LCD Controller | ||
33 | Device Code: ks0108 | ||
34 | Webpage: - | ||
35 | Device Webpage: - | ||
36 | Type: LCD Controller (Liquid Crystal Display Controller) | ||
37 | Width: 64 | ||
38 | Height: 64 | ||
39 | Colors: 2 (B/N) | ||
40 | Pages: 8 | ||
41 | Addresses: 64 each page | ||
42 | Data size: 1 byte each address | ||
43 | Memory size: 8 * 64 * 1 = 512 bytes | ||
44 | |||
45 | |||
46 | --------- | ||
47 | 3. WIRING | ||
48 | --------- | ||
49 | |||
50 | The driver supports data parallel port wiring. | ||
51 | |||
52 | If you aren't building LCD related hardware, you should check | ||
53 | your LCD specific wiring information in the same folder. | ||
54 | |||
55 | For example, check Documentation/auxdisplay/cfag12864b. | ||