2 * Front panel driver for Linux
3 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
10 * This code drives an LCD module (/dev/lcd), and a keypad (/dev/keypad)
11 * connected to a parallel printer port.
13 * The LCD module may either be an HD44780-like 8-bit parallel LCD, or a 1-bit
14 * serial module compatible with Samsung's KS0074. The pins may be connected in
15 * any combination, everything is programmable.
17 * The keypad consists in a matrix of push buttons connecting input pins to
18 * data output pins or to the ground. The combinations have to be hard-coded
19 * in the driver, though several profiles exist and adding new ones is easy.
21 * Several profiles are provided for commonly found LCD+keypad modules on the
22 * market, such as those found in Nexcom's appliances.
25 * - the initialization/deinitialization process is very dirty and should
26 * be rewritten. It may even be buggy.
29 * - document 24 keys keyboard (3 rows of 8 cols, 32 diodes + 2 inputs)
30 * - make the LCD a part of a virtual screen of Vx*Vy
31 * - make the inputs list smp-safe
32 * - change the keyboard to a double mapping : signals -> key_id -> values
33 * so that applications can change values without knowing signals
37 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
39 #include <linux/module.h>
41 #include <linux/types.h>
42 #include <linux/errno.h>
43 #include <linux/signal.h>
44 #include <linux/sched.h>
45 #include <linux/spinlock.h>
46 #include <linux/interrupt.h>
47 #include <linux/miscdevice.h>
48 #include <linux/slab.h>
49 #include <linux/ioport.h>
50 #include <linux/fcntl.h>
51 #include <linux/init.h>
52 #include <linux/delay.h>
53 #include <linux/kernel.h>
54 #include <linux/ctype.h>
55 #include <linux/parport.h>
56 #include <linux/list.h>
57 #include <linux/notifier.h>
58 #include <linux/reboot.h>
59 #include <generated/utsrelease.h>
62 #include <linux/uaccess.h>
65 #define KEYPAD_MINOR 185
67 #define PANEL_VERSION "0.9.5"
69 #define LCD_MAXBYTES 256 /* max burst write */
71 #define KEYPAD_BUFFER 64
73 /* poll the keyboard this every second */
74 #define INPUT_POLL_TIME (HZ/50)
75 /* a key starts to repeat after this times INPUT_POLL_TIME */
76 #define KEYPAD_REP_START (10)
77 /* a key repeats this times INPUT_POLL_TIME */
78 #define KEYPAD_REP_DELAY (2)
80 /* keep the light on this times INPUT_POLL_TIME for each flash */
81 #define FLASH_LIGHT_TEMPO (200)
83 /* converts an r_str() input to an active high, bits string : 000BAOSE */
84 #define PNL_PINPUT(a) ((((unsigned char)(a)) ^ 0x7F) >> 3)
86 #define PNL_PBUSY 0x80 /* inverted input, active low */
87 #define PNL_PACK 0x40 /* direct input, active low */
88 #define PNL_POUTPA 0x20 /* direct input, active high */
89 #define PNL_PSELECD 0x10 /* direct input, active high */
90 #define PNL_PERRORP 0x08 /* direct input, active low */
92 #define PNL_PBIDIR 0x20 /* bi-directional ports */
93 /* high to read data in or-ed with data out */
94 #define PNL_PINTEN 0x10
95 #define PNL_PSELECP 0x08 /* inverted output, active low */
96 #define PNL_PINITP 0x04 /* direct output, active low */
97 #define PNL_PAUTOLF 0x02 /* inverted output, active low */
98 #define PNL_PSTROBE 0x01 /* inverted output */
119 #define PIN_AUTOLF 14
121 #define PIN_SELECP 17
122 #define PIN_NOT_SET 127
124 #define LCD_FLAG_S 0x0001
125 #define LCD_FLAG_ID 0x0002
126 #define LCD_FLAG_B 0x0004 /* blink on */
127 #define LCD_FLAG_C 0x0008 /* cursor on */
128 #define LCD_FLAG_D 0x0010 /* display on */
129 #define LCD_FLAG_F 0x0020 /* large font mode */
130 #define LCD_FLAG_N 0x0040 /* 2-rows mode */
131 #define LCD_FLAG_L 0x0080 /* backlight enabled */
133 #define LCD_ESCAPE_LEN 24 /* max chars for LCD escape command */
134 #define LCD_ESCAPE_CHAR 27 /* use char 27 for escape command */
136 /* macros to simplify use of the parallel port */
137 #define r_ctr(x) (parport_read_control((x)->port))
138 #define r_dtr(x) (parport_read_data((x)->port))
139 #define r_str(x) (parport_read_status((x)->port))
140 #define w_ctr(x, y) (parport_write_control((x)->port, (y)))
141 #define w_dtr(x, y) (parport_write_data((x)->port, (y)))
143 /* this defines which bits are to be used and which ones to be ignored */
144 /* logical or of the output bits involved in the scan matrix */
145 static __u8 scan_mask_o
;
146 /* logical or of the input bits involved in the scan matrix */
147 static __u8 scan_mask_i
;
149 typedef __u64 pmask_t
;
163 struct logical_input
{
164 struct list_head list
;
167 enum input_type type
;
168 enum input_state state
;
169 __u8 rise_time
, fall_time
;
170 __u8 rise_timer
, fall_timer
, high_timer
;
173 struct { /* valid when type == INPUT_TYPE_STD */
174 void (*press_fct
) (int);
175 void (*release_fct
) (int);
179 struct { /* valid when type == INPUT_TYPE_KBD */
180 /* strings can be non null-terminated */
181 char press_str
[sizeof(void *) + sizeof(int)];
182 char repeat_str
[sizeof(void *) + sizeof(int)];
183 char release_str
[sizeof(void *) + sizeof(int)];
188 static LIST_HEAD(logical_inputs
); /* list of all defined logical inputs */
190 /* physical contacts history
191 * Physical contacts are a 45 bits string of 9 groups of 5 bits each.
192 * The 8 lower groups correspond to output bits 0 to 7, and the 9th group
193 * corresponds to the ground.
194 * Within each group, bits are stored in the same order as read on the port :
195 * BAPSE (busy=4, ack=3, paper empty=2, select=1, error=0).
196 * So, each __u64 (or pmask_t) is represented like this :
197 * 0000000000000000000BAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSE
198 * <-----unused------><gnd><d07><d06><d05><d04><d03><d02><d01><d00>
201 /* what has just been read from the I/O ports */
202 static pmask_t phys_read
;
203 /* previous phys_read */
204 static pmask_t phys_read_prev
;
205 /* stabilized phys_read (phys_read|phys_read_prev) */
206 static pmask_t phys_curr
;
207 /* previous phys_curr */
208 static pmask_t phys_prev
;
209 /* 0 means that at least one logical signal needs be computed */
210 static char inputs_stable
;
212 /* these variables are specific to the keypad */
213 static char keypad_buffer
[KEYPAD_BUFFER
];
214 static int keypad_buflen
;
215 static int keypad_start
;
216 static char keypressed
;
217 static wait_queue_head_t keypad_read_wait
;
219 /* lcd-specific variables */
221 /* contains the LCD config state */
222 static unsigned long int lcd_flags
;
223 /* contains the LCD X offset */
224 static unsigned long int lcd_addr_x
;
225 /* contains the LCD Y offset */
226 static unsigned long int lcd_addr_y
;
227 /* current escape sequence, 0 terminated */
228 static char lcd_escape
[LCD_ESCAPE_LEN
+ 1];
229 /* not in escape state. >=0 = escape cmd len */
230 static int lcd_escape_len
= -1;
233 * Bit masks to convert LCD signals to parallel port outputs.
234 * _d_ are values for data port, _c_ are for control port.
235 * [0] = signal OFF, [1] = signal ON, [2] = mask
242 * one entry for each bit on the LCD
253 * each bit can be either connected to a DATA or CTRL port
259 static unsigned char lcd_bits
[LCD_PORTS
][LCD_BITS
][BIT_STATES
];
264 #define LCD_PROTO_PARALLEL 0
265 #define LCD_PROTO_SERIAL 1
266 #define LCD_PROTO_TI_DA8XX_LCD 2
271 #define LCD_CHARSET_NORMAL 0
272 #define LCD_CHARSET_KS0074 1
277 #define LCD_TYPE_NONE 0
278 #define LCD_TYPE_OLD 1
279 #define LCD_TYPE_KS0074 2
280 #define LCD_TYPE_HANTRONIX 3
281 #define LCD_TYPE_NEXCOM 4
282 #define LCD_TYPE_CUSTOM 5
287 #define KEYPAD_TYPE_NONE 0
288 #define KEYPAD_TYPE_OLD 1
289 #define KEYPAD_TYPE_NEW 2
290 #define KEYPAD_TYPE_NEXCOM 3
295 #define PANEL_PROFILE_CUSTOM 0
296 #define PANEL_PROFILE_OLD 1
297 #define PANEL_PROFILE_NEW 2
298 #define PANEL_PROFILE_HANTRONIX 3
299 #define PANEL_PROFILE_NEXCOM 4
300 #define PANEL_PROFILE_LARGE 5
303 * Construct custom config from the kernel's configuration
305 #define DEFAULT_PROFILE PANEL_PROFILE_LARGE
306 #define DEFAULT_PARPORT 0
307 #define DEFAULT_LCD LCD_TYPE_OLD
308 #define DEFAULT_KEYPAD KEYPAD_TYPE_OLD
309 #define DEFAULT_LCD_WIDTH 40
310 #define DEFAULT_LCD_BWIDTH 40
311 #define DEFAULT_LCD_HWIDTH 64
312 #define DEFAULT_LCD_HEIGHT 2
313 #define DEFAULT_LCD_PROTO LCD_PROTO_PARALLEL
315 #define DEFAULT_LCD_PIN_E PIN_AUTOLF
316 #define DEFAULT_LCD_PIN_RS PIN_SELECP
317 #define DEFAULT_LCD_PIN_RW PIN_INITP
318 #define DEFAULT_LCD_PIN_SCL PIN_STROBE
319 #define DEFAULT_LCD_PIN_SDA PIN_D0
320 #define DEFAULT_LCD_PIN_BL PIN_NOT_SET
321 #define DEFAULT_LCD_CHARSET LCD_CHARSET_NORMAL
323 #ifdef CONFIG_PANEL_PROFILE
324 #undef DEFAULT_PROFILE
325 #define DEFAULT_PROFILE CONFIG_PANEL_PROFILE
328 #ifdef CONFIG_PANEL_PARPORT
329 #undef DEFAULT_PARPORT
330 #define DEFAULT_PARPORT CONFIG_PANEL_PARPORT
333 #if DEFAULT_PROFILE == 0 /* custom */
334 #ifdef CONFIG_PANEL_KEYPAD
335 #undef DEFAULT_KEYPAD
336 #define DEFAULT_KEYPAD CONFIG_PANEL_KEYPAD
339 #ifdef CONFIG_PANEL_LCD
341 #define DEFAULT_LCD CONFIG_PANEL_LCD
344 #ifdef CONFIG_PANEL_LCD_WIDTH
345 #undef DEFAULT_LCD_WIDTH
346 #define DEFAULT_LCD_WIDTH CONFIG_PANEL_LCD_WIDTH
349 #ifdef CONFIG_PANEL_LCD_BWIDTH
350 #undef DEFAULT_LCD_BWIDTH
351 #define DEFAULT_LCD_BWIDTH CONFIG_PANEL_LCD_BWIDTH
354 #ifdef CONFIG_PANEL_LCD_HWIDTH
355 #undef DEFAULT_LCD_HWIDTH
356 #define DEFAULT_LCD_HWIDTH CONFIG_PANEL_LCD_HWIDTH
359 #ifdef CONFIG_PANEL_LCD_HEIGHT
360 #undef DEFAULT_LCD_HEIGHT
361 #define DEFAULT_LCD_HEIGHT CONFIG_PANEL_LCD_HEIGHT
364 #ifdef CONFIG_PANEL_LCD_PROTO
365 #undef DEFAULT_LCD_PROTO
366 #define DEFAULT_LCD_PROTO CONFIG_PANEL_LCD_PROTO
369 #ifdef CONFIG_PANEL_LCD_PIN_E
370 #undef DEFAULT_LCD_PIN_E
371 #define DEFAULT_LCD_PIN_E CONFIG_PANEL_LCD_PIN_E
374 #ifdef CONFIG_PANEL_LCD_PIN_RS
375 #undef DEFAULT_LCD_PIN_RS
376 #define DEFAULT_LCD_PIN_RS CONFIG_PANEL_LCD_PIN_RS
379 #ifdef CONFIG_PANEL_LCD_PIN_RW
380 #undef DEFAULT_LCD_PIN_RW
381 #define DEFAULT_LCD_PIN_RW CONFIG_PANEL_LCD_PIN_RW
384 #ifdef CONFIG_PANEL_LCD_PIN_SCL
385 #undef DEFAULT_LCD_PIN_SCL
386 #define DEFAULT_LCD_PIN_SCL CONFIG_PANEL_LCD_PIN_SCL
389 #ifdef CONFIG_PANEL_LCD_PIN_SDA
390 #undef DEFAULT_LCD_PIN_SDA
391 #define DEFAULT_LCD_PIN_SDA CONFIG_PANEL_LCD_PIN_SDA
394 #ifdef CONFIG_PANEL_LCD_PIN_BL
395 #undef DEFAULT_LCD_PIN_BL
396 #define DEFAULT_LCD_PIN_BL CONFIG_PANEL_LCD_PIN_BL
399 #ifdef CONFIG_PANEL_LCD_CHARSET
400 #undef DEFAULT_LCD_CHARSET
401 #define DEFAULT_LCD_CHARSET CONFIG_PANEL_LCD_CHARSET
404 #endif /* DEFAULT_PROFILE == 0 */
406 /* global variables */
407 static int keypad_open_cnt
; /* #times opened */
408 static int lcd_open_cnt
; /* #times opened */
409 static struct pardevice
*pprt
;
411 static int lcd_initialized
;
412 static int keypad_initialized
;
414 static int light_tempo
;
416 static char lcd_must_clear
;
417 static char lcd_left_shift
;
418 static char init_in_progress
;
420 static void (*lcd_write_cmd
) (int);
421 static void (*lcd_write_data
) (int);
422 static void (*lcd_clear_fast
) (void);
424 static DEFINE_SPINLOCK(pprt_lock
);
425 static struct timer_list scan_timer
;
427 MODULE_DESCRIPTION("Generic parallel port LCD/Keypad driver");
429 static int parport
= -1;
430 module_param(parport
, int, 0000);
431 MODULE_PARM_DESC(parport
, "Parallel port index (0=lpt1, 1=lpt2, ...)");
433 static int lcd_height
= -1;
434 module_param(lcd_height
, int, 0000);
435 MODULE_PARM_DESC(lcd_height
, "Number of lines on the LCD");
437 static int lcd_width
= -1;
438 module_param(lcd_width
, int, 0000);
439 MODULE_PARM_DESC(lcd_width
, "Number of columns on the LCD");
441 static int lcd_bwidth
= -1; /* internal buffer width (usually 40) */
442 module_param(lcd_bwidth
, int, 0000);
443 MODULE_PARM_DESC(lcd_bwidth
, "Internal LCD line width (40)");
445 static int lcd_hwidth
= -1; /* hardware buffer width (usually 64) */
446 module_param(lcd_hwidth
, int, 0000);
447 MODULE_PARM_DESC(lcd_hwidth
, "LCD line hardware address (64)");
449 static int lcd_enabled
= -1;
450 module_param(lcd_enabled
, int, 0000);
451 MODULE_PARM_DESC(lcd_enabled
, "Deprecated option, use lcd_type instead");
453 static int keypad_enabled
= -1;
454 module_param(keypad_enabled
, int, 0000);
455 MODULE_PARM_DESC(keypad_enabled
, "Deprecated option, use keypad_type instead");
457 static int lcd_type
= -1;
458 module_param(lcd_type
, int, 0000);
459 MODULE_PARM_DESC(lcd_type
,
460 "LCD type: 0=none, 1=old //, 2=serial ks0074, "
461 "3=hantronix //, 4=nexcom //, 5=compiled-in");
463 static int lcd_proto
= -1;
464 module_param(lcd_proto
, int, 0000);
465 MODULE_PARM_DESC(lcd_proto
,
466 "LCD communication: 0=parallel (//), 1=serial,"
467 "2=TI LCD Interface");
469 static int lcd_charset
= -1;
470 module_param(lcd_charset
, int, 0000);
471 MODULE_PARM_DESC(lcd_charset
, "LCD character set: 0=standard, 1=KS0074");
473 static int keypad_type
= -1;
474 module_param(keypad_type
, int, 0000);
475 MODULE_PARM_DESC(keypad_type
,
476 "Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, "
479 static int profile
= DEFAULT_PROFILE
;
480 module_param(profile
, int, 0000);
481 MODULE_PARM_DESC(profile
,
482 "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; "
483 "4=16x2 nexcom; default=40x2, old kp");
486 * These are the parallel port pins the LCD control signals are connected to.
487 * Set this to 0 if the signal is not used. Set it to its opposite value
488 * (negative) if the signal is negated. -MAXINT is used to indicate that the
489 * pin has not been explicitly specified.
491 * WARNING! no check will be performed about collisions with keypad !
494 static int lcd_e_pin
= PIN_NOT_SET
;
495 module_param(lcd_e_pin
, int, 0000);
496 MODULE_PARM_DESC(lcd_e_pin
,
497 "# of the // port pin connected to LCD 'E' signal, "
498 "with polarity (-17..17)");
500 static int lcd_rs_pin
= PIN_NOT_SET
;
501 module_param(lcd_rs_pin
, int, 0000);
502 MODULE_PARM_DESC(lcd_rs_pin
,
503 "# of the // port pin connected to LCD 'RS' signal, "
504 "with polarity (-17..17)");
506 static int lcd_rw_pin
= PIN_NOT_SET
;
507 module_param(lcd_rw_pin
, int, 0000);
508 MODULE_PARM_DESC(lcd_rw_pin
,
509 "# of the // port pin connected to LCD 'RW' signal, "
510 "with polarity (-17..17)");
512 static int lcd_bl_pin
= PIN_NOT_SET
;
513 module_param(lcd_bl_pin
, int, 0000);
514 MODULE_PARM_DESC(lcd_bl_pin
,
515 "# of the // port pin connected to LCD backlight, "
516 "with polarity (-17..17)");
518 static int lcd_da_pin
= PIN_NOT_SET
;
519 module_param(lcd_da_pin
, int, 0000);
520 MODULE_PARM_DESC(lcd_da_pin
,
521 "# of the // port pin connected to serial LCD 'SDA' "
522 "signal, with polarity (-17..17)");
524 static int lcd_cl_pin
= PIN_NOT_SET
;
525 module_param(lcd_cl_pin
, int, 0000);
526 MODULE_PARM_DESC(lcd_cl_pin
,
527 "# of the // port pin connected to serial LCD 'SCL' "
528 "signal, with polarity (-17..17)");
530 static const unsigned char *lcd_char_conv
;
532 /* for some LCD drivers (ks0074) we need a charset conversion table. */
533 static const unsigned char lcd_char_conv_ks0074
[256] = {
534 /* 0|8 1|9 2|A 3|B 4|C 5|D 6|E 7|F */
535 /* 0x00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
536 /* 0x08 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
537 /* 0x10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
538 /* 0x18 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
539 /* 0x20 */ 0x20, 0x21, 0x22, 0x23, 0xa2, 0x25, 0x26, 0x27,
540 /* 0x28 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
541 /* 0x30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
542 /* 0x38 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
543 /* 0x40 */ 0xa0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
544 /* 0x48 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
545 /* 0x50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
546 /* 0x58 */ 0x58, 0x59, 0x5a, 0xfa, 0xfb, 0xfc, 0x1d, 0xc4,
547 /* 0x60 */ 0x96, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
548 /* 0x68 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
549 /* 0x70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
550 /* 0x78 */ 0x78, 0x79, 0x7a, 0xfd, 0xfe, 0xff, 0xce, 0x20,
551 /* 0x80 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
552 /* 0x88 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
553 /* 0x90 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
554 /* 0x98 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
555 /* 0xA0 */ 0x20, 0x40, 0xb1, 0xa1, 0x24, 0xa3, 0xfe, 0x5f,
556 /* 0xA8 */ 0x22, 0xc8, 0x61, 0x14, 0x97, 0x2d, 0xad, 0x96,
557 /* 0xB0 */ 0x80, 0x8c, 0x82, 0x83, 0x27, 0x8f, 0x86, 0xdd,
558 /* 0xB8 */ 0x2c, 0x81, 0x6f, 0x15, 0x8b, 0x8a, 0x84, 0x60,
559 /* 0xC0 */ 0xe2, 0xe2, 0xe2, 0x5b, 0x5b, 0xae, 0xbc, 0xa9,
560 /* 0xC8 */ 0xc5, 0xbf, 0xc6, 0xf1, 0xe3, 0xe3, 0xe3, 0xe3,
561 /* 0xD0 */ 0x44, 0x5d, 0xa8, 0xe4, 0xec, 0xec, 0x5c, 0x78,
562 /* 0xD8 */ 0xab, 0xa6, 0xe5, 0x5e, 0x5e, 0xe6, 0xaa, 0xbe,
563 /* 0xE0 */ 0x7f, 0xe7, 0xaf, 0x7b, 0x7b, 0xaf, 0xbd, 0xc8,
564 /* 0xE8 */ 0xa4, 0xa5, 0xc7, 0xf6, 0xa7, 0xe8, 0x69, 0x69,
565 /* 0xF0 */ 0xed, 0x7d, 0xa8, 0xe4, 0xec, 0x5c, 0x5c, 0x25,
566 /* 0xF8 */ 0xac, 0xa6, 0xea, 0xef, 0x7e, 0xeb, 0xb2, 0x79,
569 static const char old_keypad_profile
[][4][9] = {
570 {"S0", "Left\n", "Left\n", ""},
571 {"S1", "Down\n", "Down\n", ""},
572 {"S2", "Up\n", "Up\n", ""},
573 {"S3", "Right\n", "Right\n", ""},
574 {"S4", "Esc\n", "Esc\n", ""},
575 {"S5", "Ret\n", "Ret\n", ""},
579 /* signals, press, repeat, release */
580 static const char new_keypad_profile
[][4][9] = {
581 {"S0", "Left\n", "Left\n", ""},
582 {"S1", "Down\n", "Down\n", ""},
583 {"S2", "Up\n", "Up\n", ""},
584 {"S3", "Right\n", "Right\n", ""},
585 {"S4s5", "", "Esc\n", "Esc\n"},
586 {"s4S5", "", "Ret\n", "Ret\n"},
587 {"S4S5", "Help\n", "", ""},
588 /* add new signals above this line */
592 /* signals, press, repeat, release */
593 static const char nexcom_keypad_profile
[][4][9] = {
594 {"a-p-e-", "Down\n", "Down\n", ""},
595 {"a-p-E-", "Ret\n", "Ret\n", ""},
596 {"a-P-E-", "Esc\n", "Esc\n", ""},
597 {"a-P-e-", "Up\n", "Up\n", ""},
598 /* add new signals above this line */
602 static const char (*keypad_profile
)[4][9] = old_keypad_profile
;
604 /* FIXME: this should be converted to a bit array containing signals states */
606 unsigned char e
; /* parallel LCD E (data latch on falling edge) */
607 unsigned char rs
; /* parallel LCD RS (0 = cmd, 1 = data) */
608 unsigned char rw
; /* parallel LCD R/W (0 = W, 1 = R) */
609 unsigned char bl
; /* parallel LCD backlight (0 = off, 1 = on) */
610 unsigned char cl
; /* serial LCD clock (latch on rising edge) */
611 unsigned char da
; /* serial LCD data */
614 static void init_scan_timer(void);
616 /* sets data port bits according to current signals values */
617 static int set_data_bits(void)
622 for (bit
= 0; bit
< LCD_BITS
; bit
++)
623 val
&= lcd_bits
[LCD_PORT_D
][bit
][BIT_MSK
];
625 val
|= lcd_bits
[LCD_PORT_D
][LCD_BIT_E
][bits
.e
]
626 | lcd_bits
[LCD_PORT_D
][LCD_BIT_RS
][bits
.rs
]
627 | lcd_bits
[LCD_PORT_D
][LCD_BIT_RW
][bits
.rw
]
628 | lcd_bits
[LCD_PORT_D
][LCD_BIT_BL
][bits
.bl
]
629 | lcd_bits
[LCD_PORT_D
][LCD_BIT_CL
][bits
.cl
]
630 | lcd_bits
[LCD_PORT_D
][LCD_BIT_DA
][bits
.da
];
636 /* sets ctrl port bits according to current signals values */
637 static int set_ctrl_bits(void)
642 for (bit
= 0; bit
< LCD_BITS
; bit
++)
643 val
&= lcd_bits
[LCD_PORT_C
][bit
][BIT_MSK
];
645 val
|= lcd_bits
[LCD_PORT_C
][LCD_BIT_E
][bits
.e
]
646 | lcd_bits
[LCD_PORT_C
][LCD_BIT_RS
][bits
.rs
]
647 | lcd_bits
[LCD_PORT_C
][LCD_BIT_RW
][bits
.rw
]
648 | lcd_bits
[LCD_PORT_C
][LCD_BIT_BL
][bits
.bl
]
649 | lcd_bits
[LCD_PORT_C
][LCD_BIT_CL
][bits
.cl
]
650 | lcd_bits
[LCD_PORT_C
][LCD_BIT_DA
][bits
.da
];
656 /* sets ctrl & data port bits according to current signals values */
657 static void panel_set_bits(void)
664 * Converts a parallel port pin (from -25 to 25) to data and control ports
665 * masks, and data and control port bits. The signal will be considered
666 * unconnected if it's on pin 0 or an invalid pin (<-25 or >25).
668 * Result will be used this way :
669 * out(dport, in(dport) & d_val[2] | d_val[signal_state])
670 * out(cport, in(cport) & c_val[2] | c_val[signal_state])
672 static void pin_to_bits(int pin
, unsigned char *d_val
, unsigned char *c_val
)
674 int d_bit
, c_bit
, inv
;
676 d_val
[0] = c_val
[0] = d_val
[1] = c_val
[1] = 0;
677 d_val
[2] = c_val
[2] = 0xFF;
689 case PIN_STROBE
: /* strobe, inverted */
693 case PIN_D0
...PIN_D7
: /* D0 - D7 = 2 - 9 */
694 d_bit
= 1 << (pin
- 2);
696 case PIN_AUTOLF
: /* autofeed, inverted */
700 case PIN_INITP
: /* init, direct */
703 case PIN_SELECP
: /* select_in, inverted */
707 default: /* unknown pin, ignore */
720 /* sleeps that many milliseconds with a reschedule */
721 static void long_sleep(int ms
)
727 current
->state
= TASK_INTERRUPTIBLE
;
728 schedule_timeout((ms
* HZ
+ 999) / 1000);
732 /* send a serial byte to the LCD panel. The caller is responsible for locking
734 static void lcd_send_serial(int byte
)
738 /* the data bit is set on D0, and the clock on STROBE.
739 * LCD reads D0 on STROBE's rising edge. */
740 for (bit
= 0; bit
< 8; bit
++) {
741 bits
.cl
= BIT_CLR
; /* CLK low */
745 udelay(2); /* maintain the data during 2 us before CLK up */
746 bits
.cl
= BIT_SET
; /* CLK high */
748 udelay(1); /* maintain the strobe during 1 us */
753 /* turn the backlight on or off */
754 static void lcd_backlight(int on
)
756 if (lcd_bl_pin
== PIN_NONE
)
759 /* The backlight is activated by setting the AUTOFEED line to +5V */
760 spin_lock_irq(&pprt_lock
);
763 spin_unlock_irq(&pprt_lock
);
766 /* send a command to the LCD panel in serial mode */
767 static void lcd_write_cmd_s(int cmd
)
769 spin_lock_irq(&pprt_lock
);
770 lcd_send_serial(0x1F); /* R/W=W, RS=0 */
771 lcd_send_serial(cmd
& 0x0F);
772 lcd_send_serial((cmd
>> 4) & 0x0F);
773 udelay(40); /* the shortest command takes at least 40 us */
774 spin_unlock_irq(&pprt_lock
);
777 /* send data to the LCD panel in serial mode */
778 static void lcd_write_data_s(int data
)
780 spin_lock_irq(&pprt_lock
);
781 lcd_send_serial(0x5F); /* R/W=W, RS=1 */
782 lcd_send_serial(data
& 0x0F);
783 lcd_send_serial((data
>> 4) & 0x0F);
784 udelay(40); /* the shortest data takes at least 40 us */
785 spin_unlock_irq(&pprt_lock
);
788 /* send a command to the LCD panel in 8 bits parallel mode */
789 static void lcd_write_cmd_p8(int cmd
)
791 spin_lock_irq(&pprt_lock
);
792 /* present the data to the data port */
794 udelay(20); /* maintain the data during 20 us before the strobe */
801 udelay(40); /* maintain the strobe during 40 us */
806 udelay(120); /* the shortest command takes at least 120 us */
807 spin_unlock_irq(&pprt_lock
);
810 /* send data to the LCD panel in 8 bits parallel mode */
811 static void lcd_write_data_p8(int data
)
813 spin_lock_irq(&pprt_lock
);
814 /* present the data to the data port */
816 udelay(20); /* maintain the data during 20 us before the strobe */
823 udelay(40); /* maintain the strobe during 40 us */
828 udelay(45); /* the shortest data takes at least 45 us */
829 spin_unlock_irq(&pprt_lock
);
832 /* send a command to the TI LCD panel */
833 static void lcd_write_cmd_tilcd(int cmd
)
835 spin_lock_irq(&pprt_lock
);
836 /* present the data to the control port */
839 spin_unlock_irq(&pprt_lock
);
842 /* send data to the TI LCD panel */
843 static void lcd_write_data_tilcd(int data
)
845 spin_lock_irq(&pprt_lock
);
846 /* present the data to the data port */
849 spin_unlock_irq(&pprt_lock
);
852 static void lcd_gotoxy(void)
854 lcd_write_cmd(0x80 /* set DDRAM address */
855 | (lcd_addr_y
? lcd_hwidth
: 0)
856 /* we force the cursor to stay at the end of the
857 line if it wants to go farther */
858 | ((lcd_addr_x
< lcd_bwidth
) ? lcd_addr_x
&
859 (lcd_hwidth
- 1) : lcd_bwidth
- 1));
862 static void lcd_print(char c
)
864 if (lcd_addr_x
< lcd_bwidth
) {
865 if (lcd_char_conv
!= NULL
)
866 c
= lcd_char_conv
[(unsigned char)c
];
870 /* prevents the cursor from wrapping onto the next line */
871 if (lcd_addr_x
== lcd_bwidth
)
875 /* fills the display with spaces and resets X/Y */
876 static void lcd_clear_fast_s(void)
879 lcd_addr_x
= lcd_addr_y
= 0;
882 spin_lock_irq(&pprt_lock
);
883 for (pos
= 0; pos
< lcd_height
* lcd_hwidth
; pos
++) {
884 lcd_send_serial(0x5F); /* R/W=W, RS=1 */
885 lcd_send_serial(' ' & 0x0F);
886 lcd_send_serial((' ' >> 4) & 0x0F);
887 udelay(40); /* the shortest data takes at least 40 us */
889 spin_unlock_irq(&pprt_lock
);
891 lcd_addr_x
= lcd_addr_y
= 0;
895 /* fills the display with spaces and resets X/Y */
896 static void lcd_clear_fast_p8(void)
899 lcd_addr_x
= lcd_addr_y
= 0;
902 spin_lock_irq(&pprt_lock
);
903 for (pos
= 0; pos
< lcd_height
* lcd_hwidth
; pos
++) {
904 /* present the data to the data port */
907 /* maintain the data during 20 us before the strobe */
915 /* maintain the strobe during 40 us */
921 /* the shortest data takes at least 45 us */
924 spin_unlock_irq(&pprt_lock
);
926 lcd_addr_x
= lcd_addr_y
= 0;
930 /* fills the display with spaces and resets X/Y */
931 static void lcd_clear_fast_tilcd(void)
934 lcd_addr_x
= lcd_addr_y
= 0;
937 spin_lock_irq(&pprt_lock
);
938 for (pos
= 0; pos
< lcd_height
* lcd_hwidth
; pos
++) {
939 /* present the data to the data port */
944 spin_unlock_irq(&pprt_lock
);
946 lcd_addr_x
= lcd_addr_y
= 0;
950 /* clears the display and resets X/Y */
951 static void lcd_clear_display(void)
953 lcd_write_cmd(0x01); /* clear display */
954 lcd_addr_x
= lcd_addr_y
= 0;
955 /* we must wait a few milliseconds (15) */
959 static void lcd_init_display(void)
962 lcd_flags
= ((lcd_height
> 1) ? LCD_FLAG_N
: 0)
963 | LCD_FLAG_D
| LCD_FLAG_C
| LCD_FLAG_B
;
965 long_sleep(20); /* wait 20 ms after power-up for the paranoid */
967 lcd_write_cmd(0x30); /* 8bits, 1 line, small fonts */
969 lcd_write_cmd(0x30); /* 8bits, 1 line, small fonts */
971 lcd_write_cmd(0x30); /* 8bits, 1 line, small fonts */
974 lcd_write_cmd(0x30 /* set font height and lines number */
975 | ((lcd_flags
& LCD_FLAG_F
) ? 4 : 0)
976 | ((lcd_flags
& LCD_FLAG_N
) ? 8 : 0)
980 lcd_write_cmd(0x08); /* display off, cursor off, blink off */
983 lcd_write_cmd(0x08 /* set display mode */
984 | ((lcd_flags
& LCD_FLAG_D
) ? 4 : 0)
985 | ((lcd_flags
& LCD_FLAG_C
) ? 2 : 0)
986 | ((lcd_flags
& LCD_FLAG_B
) ? 1 : 0)
989 lcd_backlight((lcd_flags
& LCD_FLAG_L
) ? 1 : 0);
993 /* entry mode set : increment, cursor shifting */
1000 * These are the file operation function for user access to /dev/lcd
1001 * This function can also be called from inside the kernel, by
1002 * setting file and ppos to NULL.
1006 static inline int handle_lcd_special_code(void)
1008 /* LCD special codes */
1012 char *esc
= lcd_escape
+ 2;
1013 int oldflags
= lcd_flags
;
1015 /* check for display mode flags */
1017 case 'D': /* Display ON */
1018 lcd_flags
|= LCD_FLAG_D
;
1021 case 'd': /* Display OFF */
1022 lcd_flags
&= ~LCD_FLAG_D
;
1025 case 'C': /* Cursor ON */
1026 lcd_flags
|= LCD_FLAG_C
;
1029 case 'c': /* Cursor OFF */
1030 lcd_flags
&= ~LCD_FLAG_C
;
1033 case 'B': /* Blink ON */
1034 lcd_flags
|= LCD_FLAG_B
;
1037 case 'b': /* Blink OFF */
1038 lcd_flags
&= ~LCD_FLAG_B
;
1041 case '+': /* Back light ON */
1042 lcd_flags
|= LCD_FLAG_L
;
1045 case '-': /* Back light OFF */
1046 lcd_flags
&= ~LCD_FLAG_L
;
1050 /* flash back light using the keypad timer */
1051 if (scan_timer
.function
!= NULL
) {
1052 if (light_tempo
== 0 && ((lcd_flags
& LCD_FLAG_L
) == 0))
1054 light_tempo
= FLASH_LIGHT_TEMPO
;
1058 case 'f': /* Small Font */
1059 lcd_flags
&= ~LCD_FLAG_F
;
1062 case 'F': /* Large Font */
1063 lcd_flags
|= LCD_FLAG_F
;
1066 case 'n': /* One Line */
1067 lcd_flags
&= ~LCD_FLAG_N
;
1070 case 'N': /* Two Lines */
1071 lcd_flags
|= LCD_FLAG_N
;
1073 case 'l': /* Shift Cursor Left */
1074 if (lcd_addr_x
> 0) {
1075 /* back one char if not at end of line */
1076 if (lcd_addr_x
< lcd_bwidth
)
1077 lcd_write_cmd(0x10);
1082 case 'r': /* shift cursor right */
1083 if (lcd_addr_x
< lcd_width
) {
1084 /* allow the cursor to pass the end of the line */
1087 lcd_write_cmd(0x14);
1092 case 'L': /* shift display left */
1094 lcd_write_cmd(0x18);
1097 case 'R': /* shift display right */
1099 lcd_write_cmd(0x1C);
1102 case 'k': { /* kill end of line */
1104 for (x
= lcd_addr_x
; x
< lcd_bwidth
; x
++)
1105 lcd_write_data(' ');
1107 /* restore cursor position */
1112 case 'I': /* reinitialize display */
1118 /* Generator : LGcxxxxx...xx; must have <c> between '0'
1119 * and '7', representing the numerical ASCII code of the
1120 * redefined character, and <xx...xx> a sequence of 16
1121 * hex digits representing 8 bytes for each character.
1122 * Most LCDs will only use 5 lower bits of the 7 first
1126 unsigned char cgbytes
[8];
1127 unsigned char cgaddr
;
1133 if (strchr(esc
, ';') == NULL
)
1138 cgaddr
= *(esc
++) - '0';
1147 while (*esc
&& cgoffset
< 8) {
1149 if (*esc
>= '0' && *esc
<= '9')
1150 value
|= (*esc
- '0') << shift
;
1151 else if (*esc
>= 'A' && *esc
<= 'Z')
1152 value
|= (*esc
- 'A' + 10) << shift
;
1153 else if (*esc
>= 'a' && *esc
<= 'z')
1154 value
|= (*esc
- 'a' + 10) << shift
;
1161 cgbytes
[cgoffset
++] = value
;
1168 lcd_write_cmd(0x40 | (cgaddr
* 8));
1169 for (addr
= 0; addr
< cgoffset
; addr
++)
1170 lcd_write_data(cgbytes
[addr
]);
1172 /* ensures that we stop writing to CGRAM */
1177 case 'x': /* gotoxy : LxXXX[yYYY]; */
1178 case 'y': /* gotoxy : LyYYY[xXXX]; */
1179 if (strchr(esc
, ';') == NULL
)
1185 if (kstrtoul(esc
, 10, &lcd_addr_x
) < 0)
1187 } else if (*esc
== 'y') {
1189 if (kstrtoul(esc
, 10, &lcd_addr_y
) < 0)
1200 /* Check whether one flag was changed */
1201 if (oldflags
!= lcd_flags
) {
1202 /* check whether one of B,C,D flags were changed */
1203 if ((oldflags
^ lcd_flags
) &
1204 (LCD_FLAG_B
| LCD_FLAG_C
| LCD_FLAG_D
))
1205 /* set display mode */
1207 | ((lcd_flags
& LCD_FLAG_D
) ? 4 : 0)
1208 | ((lcd_flags
& LCD_FLAG_C
) ? 2 : 0)
1209 | ((lcd_flags
& LCD_FLAG_B
) ? 1 : 0));
1210 /* check whether one of F,N flags was changed */
1211 else if ((oldflags
^ lcd_flags
) & (LCD_FLAG_F
| LCD_FLAG_N
))
1213 | ((lcd_flags
& LCD_FLAG_F
) ? 4 : 0)
1214 | ((lcd_flags
& LCD_FLAG_N
) ? 8 : 0));
1215 /* check whether L flag was changed */
1216 else if ((oldflags
^ lcd_flags
) & (LCD_FLAG_L
)) {
1217 if (lcd_flags
& (LCD_FLAG_L
))
1219 else if (light_tempo
== 0)
1220 /* switch off the light only when the tempo
1229 static ssize_t
lcd_write(struct file
*file
,
1230 const char *buf
, size_t count
, loff_t
*ppos
)
1232 const char *tmp
= buf
;
1235 for (; count
-- > 0; (ppos
? (*ppos
)++ : 0), ++tmp
) {
1236 if (!in_interrupt() && (((count
+ 1) & 0x1f) == 0))
1237 /* let's be a little nice with other processes
1238 that need some CPU */
1241 if (ppos
== NULL
&& file
== NULL
)
1242 /* let's not use get_user() from the kernel ! */
1244 else if (get_user(c
, tmp
))
1247 /* first, we'll test if we're in escape mode */
1248 if ((c
!= '\n') && lcd_escape_len
>= 0) {
1249 /* yes, let's add this char to the buffer */
1250 lcd_escape
[lcd_escape_len
++] = c
;
1251 lcd_escape
[lcd_escape_len
] = 0;
1253 /* aborts any previous escape sequence */
1254 lcd_escape_len
= -1;
1257 case LCD_ESCAPE_CHAR
:
1258 /* start of an escape sequence */
1260 lcd_escape
[lcd_escape_len
] = 0;
1263 /* go back one char and clear it */
1264 if (lcd_addr_x
> 0) {
1265 /* check if we're not at the
1267 if (lcd_addr_x
< lcd_bwidth
)
1269 lcd_write_cmd(0x10);
1272 /* replace with a space */
1273 lcd_write_data(' ');
1274 /* back one char again */
1275 lcd_write_cmd(0x10);
1278 /* quickly clear the display */
1282 /* flush the remainder of the current line and
1283 go to the beginning of the next line */
1284 for (; lcd_addr_x
< lcd_bwidth
; lcd_addr_x
++)
1285 lcd_write_data(' ');
1287 lcd_addr_y
= (lcd_addr_y
+ 1) % lcd_height
;
1291 /* go to the beginning of the same line */
1296 /* print a space instead of the tab */
1300 /* simply print this char */
1306 /* now we'll see if we're in an escape mode and if the current
1307 escape sequence can be understood. */
1308 if (lcd_escape_len
>= 2) {
1311 if (!strcmp(lcd_escape
, "[2J")) {
1312 /* clear the display */
1315 } else if (!strcmp(lcd_escape
, "[H")) {
1316 /* cursor to home */
1317 lcd_addr_x
= lcd_addr_y
= 0;
1321 /* codes starting with ^[[L */
1322 else if ((lcd_escape_len
>= 3) &&
1323 (lcd_escape
[0] == '[') &&
1324 (lcd_escape
[1] == 'L')) {
1325 processed
= handle_lcd_special_code();
1328 /* LCD special escape codes */
1329 /* flush the escape sequence if it's been processed
1330 or if it is getting too long. */
1331 if (processed
|| (lcd_escape_len
>= LCD_ESCAPE_LEN
))
1332 lcd_escape_len
= -1;
1333 } /* escape codes */
1339 static int lcd_open(struct inode
*inode
, struct file
*file
)
1342 return -EBUSY
; /* open only once at a time */
1344 if (file
->f_mode
& FMODE_READ
) /* device is write-only */
1347 if (lcd_must_clear
) {
1348 lcd_clear_display();
1352 return nonseekable_open(inode
, file
);
1355 static int lcd_release(struct inode
*inode
, struct file
*file
)
1361 static const struct file_operations lcd_fops
= {
1364 .release
= lcd_release
,
1365 .llseek
= no_llseek
,
1368 static struct miscdevice lcd_dev
= {
1374 /* public function usable from the kernel for any purpose */
1375 static void panel_lcd_print(const char *s
)
1377 if (lcd_enabled
&& lcd_initialized
)
1378 lcd_write(NULL
, s
, strlen(s
), NULL
);
1381 /* initialize the LCD driver */
1382 static void lcd_init(void)
1386 /* parallel mode, 8 bits */
1388 lcd_proto
= LCD_PROTO_PARALLEL
;
1389 if (lcd_charset
< 0)
1390 lcd_charset
= LCD_CHARSET_NORMAL
;
1391 if (lcd_e_pin
== PIN_NOT_SET
)
1392 lcd_e_pin
= PIN_STROBE
;
1393 if (lcd_rs_pin
== PIN_NOT_SET
)
1394 lcd_rs_pin
= PIN_AUTOLF
;
1405 case LCD_TYPE_KS0074
:
1406 /* serial mode, ks0074 */
1408 lcd_proto
= LCD_PROTO_SERIAL
;
1409 if (lcd_charset
< 0)
1410 lcd_charset
= LCD_CHARSET_KS0074
;
1411 if (lcd_bl_pin
== PIN_NOT_SET
)
1412 lcd_bl_pin
= PIN_AUTOLF
;
1413 if (lcd_cl_pin
== PIN_NOT_SET
)
1414 lcd_cl_pin
= PIN_STROBE
;
1415 if (lcd_da_pin
== PIN_NOT_SET
)
1416 lcd_da_pin
= PIN_D0
;
1427 case LCD_TYPE_NEXCOM
:
1428 /* parallel mode, 8 bits, generic */
1430 lcd_proto
= LCD_PROTO_PARALLEL
;
1431 if (lcd_charset
< 0)
1432 lcd_charset
= LCD_CHARSET_NORMAL
;
1433 if (lcd_e_pin
== PIN_NOT_SET
)
1434 lcd_e_pin
= PIN_AUTOLF
;
1435 if (lcd_rs_pin
== PIN_NOT_SET
)
1436 lcd_rs_pin
= PIN_SELECP
;
1437 if (lcd_rw_pin
== PIN_NOT_SET
)
1438 lcd_rw_pin
= PIN_INITP
;
1449 case LCD_TYPE_CUSTOM
:
1450 /* customer-defined */
1452 lcd_proto
= DEFAULT_LCD_PROTO
;
1453 if (lcd_charset
< 0)
1454 lcd_charset
= DEFAULT_LCD_CHARSET
;
1455 /* default geometry will be set later */
1457 case LCD_TYPE_HANTRONIX
:
1458 /* parallel mode, 8 bits, hantronix-like */
1461 lcd_proto
= LCD_PROTO_PARALLEL
;
1462 if (lcd_charset
< 0)
1463 lcd_charset
= LCD_CHARSET_NORMAL
;
1464 if (lcd_e_pin
== PIN_NOT_SET
)
1465 lcd_e_pin
= PIN_STROBE
;
1466 if (lcd_rs_pin
== PIN_NOT_SET
)
1467 lcd_rs_pin
= PIN_SELECP
;
1480 /* this is used to catch wrong and default values */
1482 lcd_width
= DEFAULT_LCD_WIDTH
;
1483 if (lcd_bwidth
<= 0)
1484 lcd_bwidth
= DEFAULT_LCD_BWIDTH
;
1485 if (lcd_hwidth
<= 0)
1486 lcd_hwidth
= DEFAULT_LCD_HWIDTH
;
1487 if (lcd_height
<= 0)
1488 lcd_height
= DEFAULT_LCD_HEIGHT
;
1490 if (lcd_proto
== LCD_PROTO_SERIAL
) { /* SERIAL */
1491 lcd_write_cmd
= lcd_write_cmd_s
;
1492 lcd_write_data
= lcd_write_data_s
;
1493 lcd_clear_fast
= lcd_clear_fast_s
;
1495 if (lcd_cl_pin
== PIN_NOT_SET
)
1496 lcd_cl_pin
= DEFAULT_LCD_PIN_SCL
;
1497 if (lcd_da_pin
== PIN_NOT_SET
)
1498 lcd_da_pin
= DEFAULT_LCD_PIN_SDA
;
1500 } else if (lcd_proto
== LCD_PROTO_PARALLEL
) { /* PARALLEL */
1501 lcd_write_cmd
= lcd_write_cmd_p8
;
1502 lcd_write_data
= lcd_write_data_p8
;
1503 lcd_clear_fast
= lcd_clear_fast_p8
;
1505 if (lcd_e_pin
== PIN_NOT_SET
)
1506 lcd_e_pin
= DEFAULT_LCD_PIN_E
;
1507 if (lcd_rs_pin
== PIN_NOT_SET
)
1508 lcd_rs_pin
= DEFAULT_LCD_PIN_RS
;
1509 if (lcd_rw_pin
== PIN_NOT_SET
)
1510 lcd_rw_pin
= DEFAULT_LCD_PIN_RW
;
1512 lcd_write_cmd
= lcd_write_cmd_tilcd
;
1513 lcd_write_data
= lcd_write_data_tilcd
;
1514 lcd_clear_fast
= lcd_clear_fast_tilcd
;
1517 if (lcd_bl_pin
== PIN_NOT_SET
)
1518 lcd_bl_pin
= DEFAULT_LCD_PIN_BL
;
1520 if (lcd_e_pin
== PIN_NOT_SET
)
1521 lcd_e_pin
= PIN_NONE
;
1522 if (lcd_rs_pin
== PIN_NOT_SET
)
1523 lcd_rs_pin
= PIN_NONE
;
1524 if (lcd_rw_pin
== PIN_NOT_SET
)
1525 lcd_rw_pin
= PIN_NONE
;
1526 if (lcd_bl_pin
== PIN_NOT_SET
)
1527 lcd_bl_pin
= PIN_NONE
;
1528 if (lcd_cl_pin
== PIN_NOT_SET
)
1529 lcd_cl_pin
= PIN_NONE
;
1530 if (lcd_da_pin
== PIN_NOT_SET
)
1531 lcd_da_pin
= PIN_NONE
;
1533 if (lcd_charset
< 0)
1534 lcd_charset
= DEFAULT_LCD_CHARSET
;
1536 if (lcd_charset
== LCD_CHARSET_KS0074
)
1537 lcd_char_conv
= lcd_char_conv_ks0074
;
1539 lcd_char_conv
= NULL
;
1541 if (lcd_bl_pin
!= PIN_NONE
)
1544 pin_to_bits(lcd_e_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_E
],
1545 lcd_bits
[LCD_PORT_C
][LCD_BIT_E
]);
1546 pin_to_bits(lcd_rs_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_RS
],
1547 lcd_bits
[LCD_PORT_C
][LCD_BIT_RS
]);
1548 pin_to_bits(lcd_rw_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_RW
],
1549 lcd_bits
[LCD_PORT_C
][LCD_BIT_RW
]);
1550 pin_to_bits(lcd_bl_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_BL
],
1551 lcd_bits
[LCD_PORT_C
][LCD_BIT_BL
]);
1552 pin_to_bits(lcd_cl_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_CL
],
1553 lcd_bits
[LCD_PORT_C
][LCD_BIT_CL
]);
1554 pin_to_bits(lcd_da_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_DA
],
1555 lcd_bits
[LCD_PORT_C
][LCD_BIT_DA
]);
1557 /* before this line, we must NOT send anything to the display.
1558 * Since lcd_init_display() needs to write data, we have to
1559 * enable mark the LCD initialized just before. */
1560 lcd_initialized
= 1;
1563 /* display a short message */
1564 #ifdef CONFIG_PANEL_CHANGE_MESSAGE
1565 #ifdef CONFIG_PANEL_BOOT_MESSAGE
1566 panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*" CONFIG_PANEL_BOOT_MESSAGE
);
1569 panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*Linux-" UTS_RELEASE
"\nPanel-"
1572 lcd_addr_x
= lcd_addr_y
= 0;
1573 /* clear the display on the next device opening */
1579 * These are the file operation function for user access to /dev/keypad
1582 static ssize_t
keypad_read(struct file
*file
,
1583 char *buf
, size_t count
, loff_t
*ppos
)
1589 if (keypad_buflen
== 0) {
1590 if (file
->f_flags
& O_NONBLOCK
)
1593 if (wait_event_interruptible(keypad_read_wait
,
1594 keypad_buflen
!= 0))
1598 for (; count
-- > 0 && (keypad_buflen
> 0);
1599 ++i
, ++tmp
, --keypad_buflen
) {
1600 put_user(keypad_buffer
[keypad_start
], tmp
);
1601 keypad_start
= (keypad_start
+ 1) % KEYPAD_BUFFER
;
1608 static int keypad_open(struct inode
*inode
, struct file
*file
)
1611 if (keypad_open_cnt
)
1612 return -EBUSY
; /* open only once at a time */
1614 if (file
->f_mode
& FMODE_WRITE
) /* device is read-only */
1617 keypad_buflen
= 0; /* flush the buffer on opening */
1622 static int keypad_release(struct inode
*inode
, struct file
*file
)
1628 static const struct file_operations keypad_fops
= {
1629 .read
= keypad_read
, /* read */
1630 .open
= keypad_open
, /* open */
1631 .release
= keypad_release
, /* close */
1632 .llseek
= default_llseek
,
1635 static struct miscdevice keypad_dev
= {
1641 static void keypad_send_key(const char *string
, int max_len
)
1643 if (init_in_progress
)
1646 /* send the key to the device only if a process is attached to it. */
1647 if (keypad_open_cnt
> 0) {
1648 while (max_len
-- && keypad_buflen
< KEYPAD_BUFFER
&& *string
) {
1649 keypad_buffer
[(keypad_start
+ keypad_buflen
++) %
1650 KEYPAD_BUFFER
] = *string
++;
1652 wake_up_interruptible(&keypad_read_wait
);
1656 /* this function scans all the bits involving at least one logical signal,
1657 * and puts the results in the bitfield "phys_read" (one bit per established
1658 * contact), and sets "phys_read_prev" to "phys_read".
1660 * Note: to debounce input signals, we will only consider as switched a signal
1661 * which is stable across 2 measures. Signals which are different between two
1662 * reads will be kept as they previously were in their logical form (phys_prev).
1663 * A signal which has just switched will have a 1 in
1664 * (phys_read ^ phys_read_prev).
1666 static void phys_scan_contacts(void)
1673 phys_prev
= phys_curr
;
1674 phys_read_prev
= phys_read
;
1675 phys_read
= 0; /* flush all signals */
1677 /* keep track of old value, with all outputs disabled */
1678 oldval
= r_dtr(pprt
) | scan_mask_o
;
1679 /* activate all keyboard outputs (active low) */
1680 w_dtr(pprt
, oldval
& ~scan_mask_o
);
1682 /* will have a 1 for each bit set to gnd */
1683 bitmask
= PNL_PINPUT(r_str(pprt
)) & scan_mask_i
;
1684 /* disable all matrix signals */
1685 w_dtr(pprt
, oldval
);
1687 /* now that all outputs are cleared, the only active input bits are
1688 * directly connected to the ground
1691 /* 1 for each grounded input */
1692 gndmask
= PNL_PINPUT(r_str(pprt
)) & scan_mask_i
;
1694 /* grounded inputs are signals 40-44 */
1695 phys_read
|= (pmask_t
) gndmask
<< 40;
1697 if (bitmask
!= gndmask
) {
1698 /* since clearing the outputs changed some inputs, we know
1699 * that some input signals are currently tied to some outputs.
1700 * So we'll scan them.
1702 for (bit
= 0; bit
< 8; bit
++) {
1705 if (!(scan_mask_o
& bitval
)) /* skip unused bits */
1708 w_dtr(pprt
, oldval
& ~bitval
); /* enable this output */
1709 bitmask
= PNL_PINPUT(r_str(pprt
)) & ~gndmask
;
1710 phys_read
|= (pmask_t
) bitmask
<< (5 * bit
);
1712 w_dtr(pprt
, oldval
); /* disable all outputs */
1714 /* this is easy: use old bits when they are flapping,
1715 * use new ones when stable */
1716 phys_curr
= (phys_prev
& (phys_read
^ phys_read_prev
)) |
1717 (phys_read
& ~(phys_read
^ phys_read_prev
));
1720 static inline int input_state_high(struct logical_input
*input
)
1724 * this is an invalid test. It tries to catch
1725 * transitions from single-key to multiple-key, but
1726 * doesn't take into account the contacts polarity.
1727 * The only solution to the problem is to parse keys
1728 * from the most complex to the simplest combinations,
1729 * and mark them as 'caught' once a combination
1730 * matches, then unmatch it for all other ones.
1733 /* try to catch dangerous transitions cases :
1734 * someone adds a bit, so this signal was a false
1735 * positive resulting from a transition. We should
1736 * invalidate the signal immediately and not call the
1738 * eg: 0 -(press A)-> A -(press B)-> AB : don't match A's release.
1740 if (((phys_prev
& input
->mask
) == input
->value
)
1741 && ((phys_curr
& input
->mask
) > input
->value
)) {
1742 input
->state
= INPUT_ST_LOW
; /* invalidate */
1747 if ((phys_curr
& input
->mask
) == input
->value
) {
1748 if ((input
->type
== INPUT_TYPE_STD
) &&
1749 (input
->high_timer
== 0)) {
1750 input
->high_timer
++;
1751 if (input
->u
.std
.press_fct
!= NULL
)
1752 input
->u
.std
.press_fct(input
->u
.std
.press_data
);
1753 } else if (input
->type
== INPUT_TYPE_KBD
) {
1754 /* will turn on the light */
1757 if (input
->high_timer
== 0) {
1758 char *press_str
= input
->u
.kbd
.press_str
;
1760 int s
= sizeof(input
->u
.kbd
.press_str
);
1761 keypad_send_key(press_str
, s
);
1765 if (input
->u
.kbd
.repeat_str
[0]) {
1766 char *repeat_str
= input
->u
.kbd
.repeat_str
;
1767 if (input
->high_timer
>= KEYPAD_REP_START
) {
1768 int s
= sizeof(input
->u
.kbd
.repeat_str
);
1769 input
->high_timer
-= KEYPAD_REP_DELAY
;
1770 keypad_send_key(repeat_str
, s
);
1772 /* we will need to come back here soon */
1776 if (input
->high_timer
< 255)
1777 input
->high_timer
++;
1781 /* else signal falling down. Let's fall through. */
1782 input
->state
= INPUT_ST_FALLING
;
1783 input
->fall_timer
= 0;
1788 static inline void input_state_falling(struct logical_input
*input
)
1791 /* FIXME !!! same comment as in input_state_high */
1792 if (((phys_prev
& input
->mask
) == input
->value
)
1793 && ((phys_curr
& input
->mask
) > input
->value
)) {
1794 input
->state
= INPUT_ST_LOW
; /* invalidate */
1799 if ((phys_curr
& input
->mask
) == input
->value
) {
1800 if (input
->type
== INPUT_TYPE_KBD
) {
1801 /* will turn on the light */
1804 if (input
->u
.kbd
.repeat_str
[0]) {
1805 char *repeat_str
= input
->u
.kbd
.repeat_str
;
1806 if (input
->high_timer
>= KEYPAD_REP_START
) {
1807 int s
= sizeof(input
->u
.kbd
.repeat_str
);
1808 input
->high_timer
-= KEYPAD_REP_DELAY
;
1809 keypad_send_key(repeat_str
, s
);
1811 /* we will need to come back here soon */
1815 if (input
->high_timer
< 255)
1816 input
->high_timer
++;
1818 input
->state
= INPUT_ST_HIGH
;
1819 } else if (input
->fall_timer
>= input
->fall_time
) {
1820 /* call release event */
1821 if (input
->type
== INPUT_TYPE_STD
) {
1822 void (*release_fct
)(int) = input
->u
.std
.release_fct
;
1823 if (release_fct
!= NULL
)
1824 release_fct(input
->u
.std
.release_data
);
1825 } else if (input
->type
== INPUT_TYPE_KBD
) {
1826 char *release_str
= input
->u
.kbd
.release_str
;
1827 if (release_str
[0]) {
1828 int s
= sizeof(input
->u
.kbd
.release_str
);
1829 keypad_send_key(release_str
, s
);
1833 input
->state
= INPUT_ST_LOW
;
1835 input
->fall_timer
++;
1840 static void panel_process_inputs(void)
1842 struct list_head
*item
;
1843 struct logical_input
*input
;
1847 list_for_each(item
, &logical_inputs
) {
1848 input
= list_entry(item
, struct logical_input
, list
);
1850 switch (input
->state
) {
1852 if ((phys_curr
& input
->mask
) != input
->value
)
1854 /* if all needed ones were already set previously,
1855 * this means that this logical signal has been
1856 * activated by the releasing of another combined
1857 * signal, so we don't want to match.
1858 * eg: AB -(release B)-> A -(release A)-> 0 :
1861 if ((phys_prev
& input
->mask
) == input
->value
)
1863 input
->rise_timer
= 0;
1864 input
->state
= INPUT_ST_RISING
;
1865 /* no break here, fall through */
1866 case INPUT_ST_RISING
:
1867 if ((phys_curr
& input
->mask
) != input
->value
) {
1868 input
->state
= INPUT_ST_LOW
;
1871 if (input
->rise_timer
< input
->rise_time
) {
1873 input
->rise_timer
++;
1876 input
->high_timer
= 0;
1877 input
->state
= INPUT_ST_HIGH
;
1878 /* no break here, fall through */
1880 if (input_state_high(input
))
1882 /* no break here, fall through */
1883 case INPUT_ST_FALLING
:
1884 input_state_falling(input
);
1889 static void panel_scan_timer(void)
1891 if (keypad_enabled
&& keypad_initialized
) {
1892 if (spin_trylock_irq(&pprt_lock
)) {
1893 phys_scan_contacts();
1895 /* no need for the parport anymore */
1896 spin_unlock_irq(&pprt_lock
);
1899 if (!inputs_stable
|| phys_curr
!= phys_prev
)
1900 panel_process_inputs();
1903 if (lcd_enabled
&& lcd_initialized
) {
1905 if (light_tempo
== 0 && ((lcd_flags
& LCD_FLAG_L
) == 0))
1907 light_tempo
= FLASH_LIGHT_TEMPO
;
1908 } else if (light_tempo
> 0) {
1910 if (light_tempo
== 0 && ((lcd_flags
& LCD_FLAG_L
) == 0))
1915 mod_timer(&scan_timer
, jiffies
+ INPUT_POLL_TIME
);
1918 static void init_scan_timer(void)
1920 if (scan_timer
.function
!= NULL
)
1921 return; /* already started */
1923 init_timer(&scan_timer
);
1924 scan_timer
.expires
= jiffies
+ INPUT_POLL_TIME
;
1925 scan_timer
.data
= 0;
1926 scan_timer
.function
= (void *)&panel_scan_timer
;
1927 add_timer(&scan_timer
);
1930 /* converts a name of the form "({BbAaPpSsEe}{01234567-})*" to a series of bits.
1931 * if <omask> or <imask> are non-null, they will be or'ed with the bits
1932 * corresponding to out and in bits respectively.
1933 * returns 1 if ok, 0 if error (in which case, nothing is written).
1935 static int input_name2mask(const char *name
, pmask_t
*mask
, pmask_t
*value
,
1936 char *imask
, char *omask
)
1938 static char sigtab
[10] = "EeSsPpAaBb";
1942 om
= im
= m
= v
= 0ULL;
1944 int in
, out
, bit
, neg
;
1945 for (in
= 0; (in
< sizeof(sigtab
)) &&
1946 (sigtab
[in
] != *name
); in
++)
1948 if (in
>= sizeof(sigtab
))
1949 return 0; /* input name not found */
1950 neg
= (in
& 1); /* odd (lower) names are negated */
1955 if (isdigit(*name
)) {
1958 } else if (*name
== '-')
1961 return 0; /* unknown bit name */
1963 bit
= (out
* 5) + in
;
1979 /* tries to bind a key to the signal name <name>. The key will send the
1980 * strings <press>, <repeat>, <release> for these respective events.
1981 * Returns the pointer to the new key if ok, NULL if the key could not be bound.
1983 static struct logical_input
*panel_bind_key(const char *name
, const char *press
,
1985 const char *release
)
1987 struct logical_input
*key
;
1989 key
= kzalloc(sizeof(struct logical_input
), GFP_KERNEL
);
1993 if (!input_name2mask(name
, &key
->mask
, &key
->value
, &scan_mask_i
,
1999 key
->type
= INPUT_TYPE_KBD
;
2000 key
->state
= INPUT_ST_LOW
;
2004 strncpy(key
->u
.kbd
.press_str
, press
, sizeof(key
->u
.kbd
.press_str
));
2005 strncpy(key
->u
.kbd
.repeat_str
, repeat
, sizeof(key
->u
.kbd
.repeat_str
));
2006 strncpy(key
->u
.kbd
.release_str
, release
,
2007 sizeof(key
->u
.kbd
.release_str
));
2008 list_add(&key
->list
, &logical_inputs
);
2013 /* tries to bind a callback function to the signal name <name>. The function
2014 * <press_fct> will be called with the <press_data> arg when the signal is
2015 * activated, and so on for <release_fct>/<release_data>
2016 * Returns the pointer to the new signal if ok, NULL if the signal could not
2019 static struct logical_input
*panel_bind_callback(char *name
,
2020 void (*press_fct
) (int),
2022 void (*release_fct
) (int),
2025 struct logical_input
*callback
;
2027 callback
= kmalloc(sizeof(struct logical_input
), GFP_KERNEL
);
2031 memset(callback
, 0, sizeof(struct logical_input
));
2032 if (!input_name2mask(name
, &callback
->mask
, &callback
->value
,
2033 &scan_mask_i
, &scan_mask_o
))
2036 callback
->type
= INPUT_TYPE_STD
;
2037 callback
->state
= INPUT_ST_LOW
;
2038 callback
->rise_time
= 1;
2039 callback
->fall_time
= 1;
2040 callback
->u
.std
.press_fct
= press_fct
;
2041 callback
->u
.std
.press_data
= press_data
;
2042 callback
->u
.std
.release_fct
= release_fct
;
2043 callback
->u
.std
.release_data
= release_data
;
2044 list_add(&callback
->list
, &logical_inputs
);
2049 static void keypad_init(void)
2052 init_waitqueue_head(&keypad_read_wait
);
2053 keypad_buflen
= 0; /* flushes any eventual noisy keystroke */
2055 /* Let's create all known keys */
2057 for (keynum
= 0; keypad_profile
[keynum
][0][0]; keynum
++) {
2058 panel_bind_key(keypad_profile
[keynum
][0],
2059 keypad_profile
[keynum
][1],
2060 keypad_profile
[keynum
][2],
2061 keypad_profile
[keynum
][3]);
2065 keypad_initialized
= 1;
2068 /**************************************************/
2069 /* device initialization */
2070 /**************************************************/
2072 static int panel_notify_sys(struct notifier_block
*this, unsigned long code
,
2075 if (lcd_enabled
&& lcd_initialized
) {
2079 ("\x0cReloading\nSystem...\x1b[Lc\x1b[Lb\x1b[L+");
2083 ("\x0cSystem Halted.\x1b[Lc\x1b[Lb\x1b[L+");
2086 panel_lcd_print("\x0cPower off.\x1b[Lc\x1b[Lb\x1b[L+");
2095 static struct notifier_block panel_notifier
= {
2101 static void panel_attach(struct parport
*port
)
2103 if (port
->number
!= parport
)
2107 pr_err("%s: port->number=%d parport=%d, already registered!\n",
2108 __func__
, port
->number
, parport
);
2112 pprt
= parport_register_device(port
, "panel", NULL
, NULL
, /* pf, kf */
2114 /*PARPORT_DEV_EXCL */
2117 pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n",
2118 __func__
, port
->number
, parport
);
2122 if (parport_claim(pprt
)) {
2123 pr_err("could not claim access to parport%d. Aborting.\n",
2125 goto err_unreg_device
;
2128 /* must init LCD first, just in case an IRQ from the keypad is
2129 * generated at keypad init
2133 if (misc_register(&lcd_dev
))
2134 goto err_unreg_device
;
2137 if (keypad_enabled
) {
2139 if (misc_register(&keypad_dev
))
2146 misc_deregister(&lcd_dev
);
2148 parport_unregister_device(pprt
);
2152 static void panel_detach(struct parport
*port
)
2154 if (port
->number
!= parport
)
2158 pr_err("%s: port->number=%d parport=%d, nothing to unregister.\n",
2159 __func__
, port
->number
, parport
);
2163 if (keypad_enabled
&& keypad_initialized
) {
2164 misc_deregister(&keypad_dev
);
2165 keypad_initialized
= 0;
2168 if (lcd_enabled
&& lcd_initialized
) {
2169 misc_deregister(&lcd_dev
);
2170 lcd_initialized
= 0;
2173 parport_release(pprt
);
2174 parport_unregister_device(pprt
);
2178 static struct parport_driver panel_driver
= {
2180 .attach
= panel_attach
,
2181 .detach
= panel_detach
,
2185 static int panel_init(void)
2187 /* for backwards compatibility */
2188 if (keypad_type
< 0)
2189 keypad_type
= keypad_enabled
;
2192 lcd_type
= lcd_enabled
;
2195 parport
= DEFAULT_PARPORT
;
2197 /* take care of an eventual profile */
2199 case PANEL_PROFILE_CUSTOM
:
2200 /* custom profile */
2201 if (keypad_type
< 0)
2202 keypad_type
= DEFAULT_KEYPAD
;
2204 lcd_type
= DEFAULT_LCD
;
2206 case PANEL_PROFILE_OLD
:
2207 /* 8 bits, 2*16, old keypad */
2208 if (keypad_type
< 0)
2209 keypad_type
= KEYPAD_TYPE_OLD
;
2211 lcd_type
= LCD_TYPE_OLD
;
2217 case PANEL_PROFILE_NEW
:
2218 /* serial, 2*16, new keypad */
2219 if (keypad_type
< 0)
2220 keypad_type
= KEYPAD_TYPE_NEW
;
2222 lcd_type
= LCD_TYPE_KS0074
;
2224 case PANEL_PROFILE_HANTRONIX
:
2225 /* 8 bits, 2*16 hantronix-like, no keypad */
2226 if (keypad_type
< 0)
2227 keypad_type
= KEYPAD_TYPE_NONE
;
2229 lcd_type
= LCD_TYPE_HANTRONIX
;
2231 case PANEL_PROFILE_NEXCOM
:
2232 /* generic 8 bits, 2*16, nexcom keypad, eg. Nexcom. */
2233 if (keypad_type
< 0)
2234 keypad_type
= KEYPAD_TYPE_NEXCOM
;
2236 lcd_type
= LCD_TYPE_NEXCOM
;
2238 case PANEL_PROFILE_LARGE
:
2239 /* 8 bits, 2*40, old keypad */
2240 if (keypad_type
< 0)
2241 keypad_type
= KEYPAD_TYPE_OLD
;
2243 lcd_type
= LCD_TYPE_OLD
;
2247 lcd_enabled
= (lcd_type
> 0);
2248 keypad_enabled
= (keypad_type
> 0);
2250 switch (keypad_type
) {
2251 case KEYPAD_TYPE_OLD
:
2252 keypad_profile
= old_keypad_profile
;
2254 case KEYPAD_TYPE_NEW
:
2255 keypad_profile
= new_keypad_profile
;
2257 case KEYPAD_TYPE_NEXCOM
:
2258 keypad_profile
= nexcom_keypad_profile
;
2261 keypad_profile
= NULL
;
2265 /* tells various subsystems about the fact that we are initializing */
2266 init_in_progress
= 1;
2268 if (parport_register_driver(&panel_driver
)) {
2269 pr_err("could not register with parport. Aborting.\n");
2273 if (!lcd_enabled
&& !keypad_enabled
) {
2274 /* no device enabled, let's release the parport */
2276 parport_release(pprt
);
2277 parport_unregister_device(pprt
);
2280 parport_unregister_driver(&panel_driver
);
2281 pr_err("driver version " PANEL_VERSION
" disabled.\n");
2285 register_reboot_notifier(&panel_notifier
);
2288 pr_info("driver version " PANEL_VERSION
2289 " registered on parport%d (io=0x%lx).\n", parport
,
2292 pr_info("driver version " PANEL_VERSION
2293 " not yet registered\n");
2294 /* tells various subsystems about the fact that initialization
2296 init_in_progress
= 0;
2300 static int __init
panel_init_module(void)
2302 return panel_init();
2305 static void __exit
panel_cleanup_module(void)
2307 unregister_reboot_notifier(&panel_notifier
);
2309 if (scan_timer
.function
!= NULL
)
2310 del_timer(&scan_timer
);
2313 if (keypad_enabled
) {
2314 misc_deregister(&keypad_dev
);
2315 keypad_initialized
= 0;
2319 panel_lcd_print("\x0cLCD driver " PANEL_VERSION
2320 "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
2321 misc_deregister(&lcd_dev
);
2322 lcd_initialized
= 0;
2325 /* TODO: free all input signals */
2326 parport_release(pprt
);
2327 parport_unregister_device(pprt
);
2330 parport_unregister_driver(&panel_driver
);
2333 module_init(panel_init_module
);
2334 module_exit(panel_cleanup_module
);
2335 MODULE_AUTHOR("Willy Tarreau");
2336 MODULE_LICENSE("GPL");