27 #include <linux/module.h>
28 #include <linux/kernel.h>
30 #include <linux/slab.h>
33 #include <linux/device.h>
43 #define CFAG12864B_NAME "cfag12864b"
49 static unsigned int cfag12864b_rate = CONFIG_CFAG12864B_RATE;
52 "Refresh rate (hertz)");
56 return cfag12864b_rate;
78 #define bit(n) (((unsigned char)1)<<(n))
80 #define CFAG12864B_BIT_E (0)
81 #define CFAG12864B_BIT_CS1 (2)
82 #define CFAG12864B_BIT_CS2 (1)
83 #define CFAG12864B_BIT_DI (3)
85 static unsigned char cfag12864b_state;
87 static void cfag12864b_set(
void)
92 static void cfag12864b_setbit(
unsigned char state,
unsigned char n)
95 cfag12864b_state |=
bit(n);
97 cfag12864b_state &= ~
bit(n);
100 static void cfag12864b_e(
unsigned char state)
106 static void cfag12864b_cs1(
unsigned char state)
111 static void cfag12864b_cs2(
unsigned char state)
116 static void cfag12864b_di(
unsigned char state)
121 static void cfag12864b_setcontrollers(
unsigned char first,
135 static void cfag12864b_controller(
unsigned char which)
138 cfag12864b_setcontrollers(1, 0);
140 cfag12864b_setcontrollers(0, 1);
143 static void cfag12864b_displaystate(
unsigned char state)
151 static void cfag12864b_address(
unsigned char address)
159 static void cfag12864b_page(
unsigned char page)
167 static void cfag12864b_startline(
unsigned char startline)
175 static void cfag12864b_writebyte(
unsigned char byte)
183 static void cfag12864b_nop(
void)
185 cfag12864b_startline(0);
192 static void cfag12864b_on(
void)
194 cfag12864b_setcontrollers(1, 1);
195 cfag12864b_displaystate(1);
198 static void cfag12864b_off(
void)
200 cfag12864b_setcontrollers(1, 1);
201 cfag12864b_displaystate(0);
204 static void cfag12864b_clear(
void)
208 cfag12864b_setcontrollers(1, 1);
211 cfag12864b_address(0);
213 cfag12864b_writebyte(0);
222 static unsigned char *cfag12864b_cache;
224 static unsigned char cfag12864b_updating;
229 static void cfag12864b_queue(
void)
232 HZ / cfag12864b_rate);
241 if (!cfag12864b_updating) {
242 cfag12864b_updating = 1;
257 if (cfag12864b_updating) {
258 cfag12864b_updating = 0;
268 return cfag12864b_updating;
274 unsigned short i,
j,
k,
b;
278 cfag12864b_controller(i);
283 cfag12864b_address(0);
286 for (c = 0, b = 0; b < 8; b++)
287 if (cfag12864b_buffer
288 [i * CFAG12864B_ADDRESSES / 8
289 + k / 8 + (j * 8 + b) *
293 cfag12864b_writebyte(c);
301 if (cfag12864b_updating)
319 static unsigned char cfag12864b_inited;
322 return cfag12864b_inited;
330 static int __init cfag12864b_init(
void)
337 "ks0108 is not initialized\n");
343 if (cfag12864b_buffer ==
NULL) {
345 "can't get a free page\n");
350 cfag12864b_cache =
kmalloc(
sizeof(
unsigned char) *
352 if (cfag12864b_cache ==
NULL) {
354 "can't alloc cache buffer (%i bytes)\n",
361 if (cfag12864b_workqueue ==
NULL)
367 cfag12864b_inited = 1;
371 kfree(cfag12864b_cache);
374 free_page((
unsigned long) cfag12864b_buffer);
380 static void __exit cfag12864b_exit(
void)
385 kfree(cfag12864b_cache);
386 free_page((
unsigned long) cfag12864b_buffer);