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 #include <linux/module.h>
39 #include <linux/types.h>
40 #include <linux/errno.h>
41 #include <linux/signal.h>
42 #include <linux/sched.h>
43 #include <linux/spinlock.h>
44 #include <linux/interrupt.h>
45 #include <linux/miscdevice.h>
46 #include <linux/slab.h>
47 #include <linux/ioport.h>
48 #include <linux/fcntl.h>
49 #include <linux/init.h>
50 #include <linux/delay.h>
51 #include <linux/ctype.h>
52 #include <linux/parport.h>
53 #include <linux/version.h>
54 #include <linux/list.h>
55 #include <linux/notifier.h>
56 #include <linux/reboot.h>
57 #include <generated/utsrelease.h>
60 #include <linux/uaccess.h>
61 #include <asm/system.h>
64 #define KEYPAD_MINOR 185
66 #define PANEL_VERSION "0.9.5"
68 #define LCD_MAXBYTES 256 /* max burst write */
70 #define KEYPAD_BUFFER 64
72 /* poll the keyboard this every second */
73 #define INPUT_POLL_TIME (HZ/50)
74 /* a key starts to repeat after this times INPUT_POLL_TIME */
75 #define KEYPAD_REP_START (10)
76 /* a key repeats this times INPUT_POLL_TIME */
77 #define KEYPAD_REP_DELAY (2)
79 /* keep the light on this times INPUT_POLL_TIME for each flash */
80 #define FLASH_LIGHT_TEMPO (200)
82 /* converts an r_str() input to an active high, bits string : 000BAOSE */
83 #define PNL_PINPUT(a) ((((unsigned char)(a)) ^ 0x7F) >> 3)
85 #define PNL_PBUSY 0x80 /* inverted input, active low */
86 #define PNL_PACK 0x40 /* direct input, active low */
87 #define PNL_POUTPA 0x20 /* direct input, active high */
88 #define PNL_PSELECD 0x10 /* direct input, active high */
89 #define PNL_PERRORP 0x08 /* direct input, active low */
91 #define PNL_PBIDIR 0x20 /* bi-directional ports */
92 /* high to read data in or-ed with data out */
93 #define PNL_PINTEN 0x10
94 #define PNL_PSELECP 0x08 /* inverted output, active low */
95 #define PNL_PINITP 0x04 /* direct output, active low */
96 #define PNL_PAUTOLF 0x02 /* inverted output, active low */
97 #define PNL_PSTROBE 0x01 /* inverted output */
118 #define PIN_AUTOLF 14
120 #define PIN_SELECP 17
121 #define PIN_NOT_SET 127
123 #define LCD_FLAG_S 0x0001
124 #define LCD_FLAG_ID 0x0002
125 #define LCD_FLAG_B 0x0004 /* blink on */
126 #define LCD_FLAG_C 0x0008 /* cursor on */
127 #define LCD_FLAG_D 0x0010 /* display on */
128 #define LCD_FLAG_F 0x0020 /* large font mode */
129 #define LCD_FLAG_N 0x0040 /* 2-rows mode */
130 #define LCD_FLAG_L 0x0080 /* backlight enabled */
132 #define LCD_ESCAPE_LEN 24 /* max chars for LCD escape command */
133 #define LCD_ESCAPE_CHAR 27 /* use char 27 for escape command */
135 /* macros to simplify use of the parallel port */
136 #define r_ctr(x) (parport_read_control((x)->port))
137 #define r_dtr(x) (parport_read_data((x)->port))
138 #define r_str(x) (parport_read_status((x)->port))
139 #define w_ctr(x, y) do { parport_write_control((x)->port, (y)); } while (0)
140 #define w_dtr(x, y) do { parport_write_data((x)->port, (y)); } while (0)
142 /* this defines which bits are to be used and which ones to be ignored */
143 /* logical or of the output bits involved in the scan matrix */
144 static __u8 scan_mask_o
;
145 /* logical or of the input bits involved in the scan matrix */
146 static __u8 scan_mask_i
;
148 typedef __u64 pmask_t
;
162 struct logical_input
{
163 struct list_head list
;
166 enum input_type type
;
167 enum input_state state
;
168 __u8 rise_time
, fall_time
;
169 __u8 rise_timer
, fall_timer
, high_timer
;
172 struct { /* valid when type == INPUT_TYPE_STD */
173 void (*press_fct
) (int);
174 void (*release_fct
) (int);
178 struct { /* valid when type == INPUT_TYPE_KBD */
179 /* strings can be non null-terminated */
180 char press_str
[sizeof(void *) + sizeof(int)];
181 char repeat_str
[sizeof(void *) + sizeof(int)];
182 char release_str
[sizeof(void *) + sizeof(int)];
187 LIST_HEAD(logical_inputs
); /* list of all defined logical inputs */
189 /* physical contacts history
190 * Physical contacts are a 45 bits string of 9 groups of 5 bits each.
191 * The 8 lower groups correspond to output bits 0 to 7, and the 9th group
192 * corresponds to the ground.
193 * Within each group, bits are stored in the same order as read on the port :
194 * BAPSE (busy=4, ack=3, paper empty=2, select=1, error=0).
195 * So, each __u64 (or pmask_t) is represented like this :
196 * 0000000000000000000BAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSE
197 * <-----unused------><gnd><d07><d06><d05><d04><d03><d02><d01><d00>
200 /* what has just been read from the I/O ports */
201 static pmask_t phys_read
;
202 /* previous phys_read */
203 static pmask_t phys_read_prev
;
204 /* stabilized phys_read (phys_read|phys_read_prev) */
205 static pmask_t phys_curr
;
206 /* previous phys_curr */
207 static pmask_t phys_prev
;
208 /* 0 means that at least one logical signal needs be computed */
209 static char inputs_stable
;
211 /* these variables are specific to the keypad */
212 static char keypad_buffer
[KEYPAD_BUFFER
];
213 static int keypad_buflen
;
214 static int keypad_start
;
215 static char keypressed
;
216 static wait_queue_head_t keypad_read_wait
;
218 /* lcd-specific variables */
220 /* contains the LCD config state */
221 static unsigned long int lcd_flags
;
222 /* contains the LCD X offset */
223 static unsigned long int lcd_addr_x
;
224 /* contains the LCD Y offset */
225 static unsigned long int lcd_addr_y
;
226 /* current escape sequence, 0 terminated */
227 static char lcd_escape
[LCD_ESCAPE_LEN
+ 1];
228 /* not in escape state. >=0 = escape cmd len */
229 static int lcd_escape_len
= -1;
232 * Bit masks to convert LCD signals to parallel port outputs.
233 * _d_ are values for data port, _c_ are for control port.
234 * [0] = signal OFF, [1] = signal ON, [2] = mask
241 * one entry for each bit on the LCD
252 * each bit can be either connected to a DATA or CTRL port
258 static unsigned char lcd_bits
[LCD_PORTS
][LCD_BITS
][BIT_STATES
];
263 #define LCD_PROTO_PARALLEL 0
264 #define LCD_PROTO_SERIAL 1
265 #define LCD_PROTO_TI_DA8XX_LCD 2
270 #define LCD_CHARSET_NORMAL 0
271 #define LCD_CHARSET_KS0074 1
276 #define LCD_TYPE_NONE 0
277 #define LCD_TYPE_OLD 1
278 #define LCD_TYPE_KS0074 2
279 #define LCD_TYPE_HANTRONIX 3
280 #define LCD_TYPE_NEXCOM 4
281 #define LCD_TYPE_CUSTOM 5
286 #define KEYPAD_TYPE_NONE 0
287 #define KEYPAD_TYPE_OLD 1
288 #define KEYPAD_TYPE_NEW 2
289 #define KEYPAD_TYPE_NEXCOM 3
294 #define PANEL_PROFILE_CUSTOM 0
295 #define PANEL_PROFILE_OLD 1
296 #define PANEL_PROFILE_NEW 2
297 #define PANEL_PROFILE_HANTRONIX 3
298 #define PANEL_PROFILE_NEXCOM 4
299 #define PANEL_PROFILE_LARGE 5
302 * Construct custom config from the kernel's configuration
304 #define DEFAULT_PROFILE PANEL_PROFILE_LARGE
305 #define DEFAULT_PARPORT 0
306 #define DEFAULT_LCD LCD_TYPE_OLD
307 #define DEFAULT_KEYPAD KEYPAD_TYPE_OLD
308 #define DEFAULT_LCD_WIDTH 40
309 #define DEFAULT_LCD_BWIDTH 40
310 #define DEFAULT_LCD_HWIDTH 64
311 #define DEFAULT_LCD_HEIGHT 2
312 #define DEFAULT_LCD_PROTO LCD_PROTO_PARALLEL
314 #define DEFAULT_LCD_PIN_E PIN_AUTOLF
315 #define DEFAULT_LCD_PIN_RS PIN_SELECP
316 #define DEFAULT_LCD_PIN_RW PIN_INITP
317 #define DEFAULT_LCD_PIN_SCL PIN_STROBE
318 #define DEFAULT_LCD_PIN_SDA PIN_D0
319 #define DEFAULT_LCD_PIN_BL PIN_NOT_SET
320 #define DEFAULT_LCD_CHARSET LCD_CHARSET_NORMAL
322 #ifdef CONFIG_PANEL_PROFILE
323 #undef DEFAULT_PROFILE
324 #define DEFAULT_PROFILE CONFIG_PANEL_PROFILE
327 #ifdef CONFIG_PANEL_PARPORT
328 #undef DEFAULT_PARPORT
329 #define DEFAULT_PARPORT CONFIG_PANEL_PARPORT
332 #if DEFAULT_PROFILE == 0 /* custom */
333 #ifdef CONFIG_PANEL_KEYPAD
334 #undef DEFAULT_KEYPAD
335 #define DEFAULT_KEYPAD CONFIG_PANEL_KEYPAD
338 #ifdef CONFIG_PANEL_LCD
340 #define DEFAULT_LCD CONFIG_PANEL_LCD
343 #ifdef CONFIG_PANEL_LCD_WIDTH
344 #undef DEFAULT_LCD_WIDTH
345 #define DEFAULT_LCD_WIDTH CONFIG_PANEL_LCD_WIDTH
348 #ifdef CONFIG_PANEL_LCD_BWIDTH
349 #undef DEFAULT_LCD_BWIDTH
350 #define DEFAULT_LCD_BWIDTH CONFIG_PANEL_LCD_BWIDTH
353 #ifdef CONFIG_PANEL_LCD_HWIDTH
354 #undef DEFAULT_LCD_HWIDTH
355 #define DEFAULT_LCD_HWIDTH CONFIG_PANEL_LCD_HWIDTH
358 #ifdef CONFIG_PANEL_LCD_HEIGHT
359 #undef DEFAULT_LCD_HEIGHT
360 #define DEFAULT_LCD_HEIGHT CONFIG_PANEL_LCD_HEIGHT
363 #ifdef CONFIG_PANEL_LCD_PROTO
364 #undef DEFAULT_LCD_PROTO
365 #define DEFAULT_LCD_PROTO CONFIG_PANEL_LCD_PROTO
368 #ifdef CONFIG_PANEL_LCD_PIN_E
369 #undef DEFAULT_LCD_PIN_E
370 #define DEFAULT_LCD_PIN_E CONFIG_PANEL_LCD_PIN_E
373 #ifdef CONFIG_PANEL_LCD_PIN_RS
374 #undef DEFAULT_LCD_PIN_RS
375 #define DEFAULT_LCD_PIN_RS CONFIG_PANEL_LCD_PIN_RS
378 #ifdef CONFIG_PANEL_LCD_PIN_RW
379 #undef DEFAULT_LCD_PIN_RW
380 #define DEFAULT_LCD_PIN_RW CONFIG_PANEL_LCD_PIN_RW
383 #ifdef CONFIG_PANEL_LCD_PIN_SCL
384 #undef DEFAULT_LCD_PIN_SCL
385 #define DEFAULT_LCD_PIN_SCL CONFIG_PANEL_LCD_PIN_SCL
388 #ifdef CONFIG_PANEL_LCD_PIN_SDA
389 #undef DEFAULT_LCD_PIN_SDA
390 #define DEFAULT_LCD_PIN_SDA CONFIG_PANEL_LCD_PIN_SDA
393 #ifdef CONFIG_PANEL_LCD_PIN_BL
394 #undef DEFAULT_LCD_PIN_BL
395 #define DEFAULT_LCD_PIN_BL CONFIG_PANEL_LCD_PIN_BL
398 #ifdef CONFIG_PANEL_LCD_CHARSET
399 #undef DEFAULT_LCD_CHARSET
400 #define DEFAULT_LCD_CHARSET CONFIG_PANEL_LCD_CHARSET
403 #endif /* DEFAULT_PROFILE == 0 */
405 /* global variables */
406 static int keypad_open_cnt
; /* #times opened */
407 static int lcd_open_cnt
; /* #times opened */
408 static struct pardevice
*pprt
;
410 static int lcd_initialized
;
411 static int keypad_initialized
;
413 static int light_tempo
;
415 static char lcd_must_clear
;
416 static char lcd_left_shift
;
417 static char init_in_progress
;
419 static void (*lcd_write_cmd
) (int);
420 static void (*lcd_write_data
) (int);
421 static void (*lcd_clear_fast
) (void);
423 static DEFINE_SPINLOCK(pprt_lock
);
424 static struct timer_list scan_timer
;
426 MODULE_DESCRIPTION("Generic parallel port LCD/Keypad driver");
428 static int parport
= -1;
429 module_param(parport
, int, 0000);
430 MODULE_PARM_DESC(parport
, "Parallel port index (0=lpt1, 1=lpt2, ...)");
432 static int lcd_height
= -1;
433 module_param(lcd_height
, int, 0000);
434 MODULE_PARM_DESC(lcd_height
, "Number of lines on the LCD");
436 static int lcd_width
= -1;
437 module_param(lcd_width
, int, 0000);
438 MODULE_PARM_DESC(lcd_width
, "Number of columns on the LCD");
440 static int lcd_bwidth
= -1; /* internal buffer width (usually 40) */
441 module_param(lcd_bwidth
, int, 0000);
442 MODULE_PARM_DESC(lcd_bwidth
, "Internal LCD line width (40)");
444 static int lcd_hwidth
= -1; /* hardware buffer width (usually 64) */
445 module_param(lcd_hwidth
, int, 0000);
446 MODULE_PARM_DESC(lcd_hwidth
, "LCD line hardware address (64)");
448 static int lcd_enabled
= -1;
449 module_param(lcd_enabled
, int, 0000);
450 MODULE_PARM_DESC(lcd_enabled
, "Deprecated option, use lcd_type instead");
452 static int keypad_enabled
= -1;
453 module_param(keypad_enabled
, int, 0000);
454 MODULE_PARM_DESC(keypad_enabled
, "Deprecated option, use keypad_type instead");
456 static int lcd_type
= -1;
457 module_param(lcd_type
, int, 0000);
458 MODULE_PARM_DESC(lcd_type
,
459 "LCD type: 0=none, 1=old //, 2=serial ks0074, "
460 "3=hantronix //, 4=nexcom //, 5=compiled-in");
462 static int lcd_proto
= -1;
463 module_param(lcd_proto
, int, 0000);
464 MODULE_PARM_DESC(lcd_proto
,
465 "LCD communication: 0=parallel (//), 1=serial,"
466 "2=TI LCD Interface");
468 static int lcd_charset
= -1;
469 module_param(lcd_charset
, int, 0000);
470 MODULE_PARM_DESC(lcd_charset
, "LCD character set: 0=standard, 1=KS0074");
472 static int keypad_type
= -1;
473 module_param(keypad_type
, int, 0000);
474 MODULE_PARM_DESC(keypad_type
,
475 "Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, "
478 static int profile
= DEFAULT_PROFILE
;
479 module_param(profile
, int, 0000);
480 MODULE_PARM_DESC(profile
,
481 "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; "
482 "4=16x2 nexcom; default=40x2, old kp");
485 * These are the parallel port pins the LCD control signals are connected to.
486 * Set this to 0 if the signal is not used. Set it to its opposite value
487 * (negative) if the signal is negated. -MAXINT is used to indicate that the
488 * pin has not been explicitly specified.
490 * WARNING! no check will be performed about collisions with keypad !
493 static int lcd_e_pin
= PIN_NOT_SET
;
494 module_param(lcd_e_pin
, int, 0000);
495 MODULE_PARM_DESC(lcd_e_pin
,
496 "# of the // port pin connected to LCD 'E' signal, "
497 "with polarity (-17..17)");
499 static int lcd_rs_pin
= PIN_NOT_SET
;
500 module_param(lcd_rs_pin
, int, 0000);
501 MODULE_PARM_DESC(lcd_rs_pin
,
502 "# of the // port pin connected to LCD 'RS' signal, "
503 "with polarity (-17..17)");
505 static int lcd_rw_pin
= PIN_NOT_SET
;
506 module_param(lcd_rw_pin
, int, 0000);
507 MODULE_PARM_DESC(lcd_rw_pin
,
508 "# of the // port pin connected to LCD 'RW' signal, "
509 "with polarity (-17..17)");
511 static int lcd_bl_pin
= PIN_NOT_SET
;
512 module_param(lcd_bl_pin
, int, 0000);
513 MODULE_PARM_DESC(lcd_bl_pin
,
514 "# of the // port pin connected to LCD backlight, "
515 "with polarity (-17..17)");
517 static int lcd_da_pin
= PIN_NOT_SET
;
518 module_param(lcd_da_pin
, int, 0000);
519 MODULE_PARM_DESC(lcd_da_pin
,
520 "# of the // port pin connected to serial LCD 'SDA' "
521 "signal, with polarity (-17..17)");
523 static int lcd_cl_pin
= PIN_NOT_SET
;
524 module_param(lcd_cl_pin
, int, 0000);
525 MODULE_PARM_DESC(lcd_cl_pin
,
526 "# of the // port pin connected to serial LCD 'SCL' "
527 "signal, with polarity (-17..17)");
529 static unsigned char *lcd_char_conv
;
531 /* for some LCD drivers (ks0074) we need a charset conversion table. */
532 static unsigned char lcd_char_conv_ks0074
[256] = {
533 /* 0|8 1|9 2|A 3|B 4|C 5|D 6|E 7|F */
534 /* 0x00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
535 /* 0x08 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
536 /* 0x10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
537 /* 0x18 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
538 /* 0x20 */ 0x20, 0x21, 0x22, 0x23, 0xa2, 0x25, 0x26, 0x27,
539 /* 0x28 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
540 /* 0x30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
541 /* 0x38 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
542 /* 0x40 */ 0xa0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
543 /* 0x48 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
544 /* 0x50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
545 /* 0x58 */ 0x58, 0x59, 0x5a, 0xfa, 0xfb, 0xfc, 0x1d, 0xc4,
546 /* 0x60 */ 0x96, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
547 /* 0x68 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
548 /* 0x70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
549 /* 0x78 */ 0x78, 0x79, 0x7a, 0xfd, 0xfe, 0xff, 0xce, 0x20,
550 /* 0x80 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
551 /* 0x88 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
552 /* 0x90 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
553 /* 0x98 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
554 /* 0xA0 */ 0x20, 0x40, 0xb1, 0xa1, 0x24, 0xa3, 0xfe, 0x5f,
555 /* 0xA8 */ 0x22, 0xc8, 0x61, 0x14, 0x97, 0x2d, 0xad, 0x96,
556 /* 0xB0 */ 0x80, 0x8c, 0x82, 0x83, 0x27, 0x8f, 0x86, 0xdd,
557 /* 0xB8 */ 0x2c, 0x81, 0x6f, 0x15, 0x8b, 0x8a, 0x84, 0x60,
558 /* 0xC0 */ 0xe2, 0xe2, 0xe2, 0x5b, 0x5b, 0xae, 0xbc, 0xa9,
559 /* 0xC8 */ 0xc5, 0xbf, 0xc6, 0xf1, 0xe3, 0xe3, 0xe3, 0xe3,
560 /* 0xD0 */ 0x44, 0x5d, 0xa8, 0xe4, 0xec, 0xec, 0x5c, 0x78,
561 /* 0xD8 */ 0xab, 0xa6, 0xe5, 0x5e, 0x5e, 0xe6, 0xaa, 0xbe,
562 /* 0xE0 */ 0x7f, 0xe7, 0xaf, 0x7b, 0x7b, 0xaf, 0xbd, 0xc8,
563 /* 0xE8 */ 0xa4, 0xa5, 0xc7, 0xf6, 0xa7, 0xe8, 0x69, 0x69,
564 /* 0xF0 */ 0xed, 0x7d, 0xa8, 0xe4, 0xec, 0x5c, 0x5c, 0x25,
565 /* 0xF8 */ 0xac, 0xa6, 0xea, 0xef, 0x7e, 0xeb, 0xb2, 0x79,
568 char old_keypad_profile
[][4][9] = {
569 {"S0", "Left\n", "Left\n", ""},
570 {"S1", "Down\n", "Down\n", ""},
571 {"S2", "Up\n", "Up\n", ""},
572 {"S3", "Right\n", "Right\n", ""},
573 {"S4", "Esc\n", "Esc\n", ""},
574 {"S5", "Ret\n", "Ret\n", ""},
578 /* signals, press, repeat, release */
579 char new_keypad_profile
[][4][9] = {
580 {"S0", "Left\n", "Left\n", ""},
581 {"S1", "Down\n", "Down\n", ""},
582 {"S2", "Up\n", "Up\n", ""},
583 {"S3", "Right\n", "Right\n", ""},
584 {"S4s5", "", "Esc\n", "Esc\n"},
585 {"s4S5", "", "Ret\n", "Ret\n"},
586 {"S4S5", "Help\n", "", ""},
587 /* add new signals above this line */
591 /* signals, press, repeat, release */
592 char nexcom_keypad_profile
[][4][9] = {
593 {"a-p-e-", "Down\n", "Down\n", ""},
594 {"a-p-E-", "Ret\n", "Ret\n", ""},
595 {"a-P-E-", "Esc\n", "Esc\n", ""},
596 {"a-P-e-", "Up\n", "Up\n", ""},
597 /* add new signals above this line */
601 static char (*keypad_profile
)[4][9] = old_keypad_profile
;
603 /* FIXME: this should be converted to a bit array containing signals states */
605 unsigned char e
; /* parallel LCD E (data latch on falling edge) */
606 unsigned char rs
; /* parallel LCD RS (0 = cmd, 1 = data) */
607 unsigned char rw
; /* parallel LCD R/W (0 = W, 1 = R) */
608 unsigned char bl
; /* parallel LCD backlight (0 = off, 1 = on) */
609 unsigned char cl
; /* serial LCD clock (latch on rising edge) */
610 unsigned char da
; /* serial LCD data */
613 static void init_scan_timer(void);
615 /* sets data port bits according to current signals values */
616 static int set_data_bits(void)
621 for (bit
= 0; bit
< LCD_BITS
; bit
++)
622 val
&= lcd_bits
[LCD_PORT_D
][bit
][BIT_MSK
];
624 val
|= lcd_bits
[LCD_PORT_D
][LCD_BIT_E
][bits
.e
]
625 | lcd_bits
[LCD_PORT_D
][LCD_BIT_RS
][bits
.rs
]
626 | lcd_bits
[LCD_PORT_D
][LCD_BIT_RW
][bits
.rw
]
627 | lcd_bits
[LCD_PORT_D
][LCD_BIT_BL
][bits
.bl
]
628 | lcd_bits
[LCD_PORT_D
][LCD_BIT_CL
][bits
.cl
]
629 | lcd_bits
[LCD_PORT_D
][LCD_BIT_DA
][bits
.da
];
635 /* sets ctrl port bits according to current signals values */
636 static int set_ctrl_bits(void)
641 for (bit
= 0; bit
< LCD_BITS
; bit
++)
642 val
&= lcd_bits
[LCD_PORT_C
][bit
][BIT_MSK
];
644 val
|= lcd_bits
[LCD_PORT_C
][LCD_BIT_E
][bits
.e
]
645 | lcd_bits
[LCD_PORT_C
][LCD_BIT_RS
][bits
.rs
]
646 | lcd_bits
[LCD_PORT_C
][LCD_BIT_RW
][bits
.rw
]
647 | lcd_bits
[LCD_PORT_C
][LCD_BIT_BL
][bits
.bl
]
648 | lcd_bits
[LCD_PORT_C
][LCD_BIT_CL
][bits
.cl
]
649 | lcd_bits
[LCD_PORT_C
][LCD_BIT_DA
][bits
.da
];
655 /* sets ctrl & data port bits according to current signals values */
656 static void panel_set_bits(void)
663 * Converts a parallel port pin (from -25 to 25) to data and control ports
664 * masks, and data and control port bits. The signal will be considered
665 * unconnected if it's on pin 0 or an invalid pin (<-25 or >25).
667 * Result will be used this way :
668 * out(dport, in(dport) & d_val[2] | d_val[signal_state])
669 * out(cport, in(cport) & c_val[2] | c_val[signal_state])
671 void pin_to_bits(int pin
, unsigned char *d_val
, unsigned char *c_val
)
673 int d_bit
, c_bit
, inv
;
675 d_val
[0] = c_val
[0] = d_val
[1] = c_val
[1] = 0;
676 d_val
[2] = c_val
[2] = 0xFF;
688 case PIN_STROBE
: /* strobe, inverted */
692 case PIN_D0
...PIN_D7
: /* D0 - D7 = 2 - 9 */
693 d_bit
= 1 << (pin
- 2);
695 case PIN_AUTOLF
: /* autofeed, inverted */
699 case PIN_INITP
: /* init, direct */
702 case PIN_SELECP
: /* select_in, inverted */
706 default: /* unknown pin, ignore */
719 /* sleeps that many milliseconds with a reschedule */
720 static void long_sleep(int ms
)
726 current
->state
= TASK_INTERRUPTIBLE
;
727 schedule_timeout((ms
* HZ
+ 999) / 1000);
731 /* send a serial byte to the LCD panel. The caller is responsible for locking
733 static void lcd_send_serial(int byte
)
737 /* the data bit is set on D0, and the clock on STROBE.
738 * LCD reads D0 on STROBE's rising edge. */
739 for (bit
= 0; bit
< 8; bit
++) {
740 bits
.cl
= BIT_CLR
; /* CLK low */
744 udelay(2); /* maintain the data during 2 us before CLK up */
745 bits
.cl
= BIT_SET
; /* CLK high */
747 udelay(1); /* maintain the strobe during 1 us */
752 /* turn the backlight on or off */
753 static void lcd_backlight(int on
)
755 if (lcd_bl_pin
== PIN_NONE
)
758 /* The backlight is activated by seting the AUTOFEED line to +5V */
759 spin_lock(&pprt_lock
);
762 spin_unlock(&pprt_lock
);
765 /* send a command to the LCD panel in serial mode */
766 static void lcd_write_cmd_s(int cmd
)
768 spin_lock(&pprt_lock
);
769 lcd_send_serial(0x1F); /* R/W=W, RS=0 */
770 lcd_send_serial(cmd
& 0x0F);
771 lcd_send_serial((cmd
>> 4) & 0x0F);
772 udelay(40); /* the shortest command takes at least 40 us */
773 spin_unlock(&pprt_lock
);
776 /* send data to the LCD panel in serial mode */
777 static void lcd_write_data_s(int data
)
779 spin_lock(&pprt_lock
);
780 lcd_send_serial(0x5F); /* R/W=W, RS=1 */
781 lcd_send_serial(data
& 0x0F);
782 lcd_send_serial((data
>> 4) & 0x0F);
783 udelay(40); /* the shortest data takes at least 40 us */
784 spin_unlock(&pprt_lock
);
787 /* send a command to the LCD panel in 8 bits parallel mode */
788 static void lcd_write_cmd_p8(int cmd
)
790 spin_lock(&pprt_lock
);
791 /* present the data to the data port */
793 udelay(20); /* maintain the data during 20 us before the strobe */
800 udelay(40); /* maintain the strobe during 40 us */
805 udelay(120); /* the shortest command takes at least 120 us */
806 spin_unlock(&pprt_lock
);
809 /* send data to the LCD panel in 8 bits parallel mode */
810 static void lcd_write_data_p8(int data
)
812 spin_lock(&pprt_lock
);
813 /* present the data to the data port */
815 udelay(20); /* maintain the data during 20 us before the strobe */
822 udelay(40); /* maintain the strobe during 40 us */
827 udelay(45); /* the shortest data takes at least 45 us */
828 spin_unlock(&pprt_lock
);
831 /* send a command to the TI LCD panel */
832 static void lcd_write_cmd_tilcd(int cmd
)
834 spin_lock(&pprt_lock
);
835 /* present the data to the control port */
838 spin_unlock(&pprt_lock
);
841 /* send data to the TI LCD panel */
842 static void lcd_write_data_tilcd(int data
)
844 spin_lock(&pprt_lock
);
845 /* present the data to the data port */
848 spin_unlock(&pprt_lock
);
851 static void lcd_gotoxy(void)
853 lcd_write_cmd(0x80 /* set DDRAM address */
854 | (lcd_addr_y
? lcd_hwidth
: 0)
855 /* we force the cursor to stay at the end of the
856 line if it wants to go farther */
857 | ((lcd_addr_x
< lcd_bwidth
) ? lcd_addr_x
&
858 (lcd_hwidth
- 1) : lcd_bwidth
- 1));
861 static void lcd_print(char c
)
863 if (lcd_addr_x
< lcd_bwidth
) {
864 if (lcd_char_conv
!= NULL
)
865 c
= lcd_char_conv
[(unsigned char)c
];
869 /* prevents the cursor from wrapping onto the next line */
870 if (lcd_addr_x
== lcd_bwidth
)
874 /* fills the display with spaces and resets X/Y */
875 static void lcd_clear_fast_s(void)
878 lcd_addr_x
= lcd_addr_y
= 0;
881 spin_lock(&pprt_lock
);
882 for (pos
= 0; pos
< lcd_height
* lcd_hwidth
; pos
++) {
883 lcd_send_serial(0x5F); /* R/W=W, RS=1 */
884 lcd_send_serial(' ' & 0x0F);
885 lcd_send_serial((' ' >> 4) & 0x0F);
886 udelay(40); /* the shortest data takes at least 40 us */
888 spin_unlock(&pprt_lock
);
890 lcd_addr_x
= lcd_addr_y
= 0;
894 /* fills the display with spaces and resets X/Y */
895 static void lcd_clear_fast_p8(void)
898 lcd_addr_x
= lcd_addr_y
= 0;
901 spin_lock(&pprt_lock
);
902 for (pos
= 0; pos
< lcd_height
* lcd_hwidth
; pos
++) {
903 /* present the data to the data port */
906 /* maintain the data during 20 us before the strobe */
914 /* maintain the strobe during 40 us */
920 /* the shortest data takes at least 45 us */
923 spin_unlock(&pprt_lock
);
925 lcd_addr_x
= lcd_addr_y
= 0;
929 /* fills the display with spaces and resets X/Y */
930 static void lcd_clear_fast_tilcd(void)
933 lcd_addr_x
= lcd_addr_y
= 0;
936 spin_lock(&pprt_lock
);
937 for (pos
= 0; pos
< lcd_height
* lcd_hwidth
; pos
++) {
938 /* present the data to the data port */
943 spin_unlock(&pprt_lock
);
945 lcd_addr_x
= lcd_addr_y
= 0;
949 /* clears the display and resets X/Y */
950 static void lcd_clear_display(void)
952 lcd_write_cmd(0x01); /* clear display */
953 lcd_addr_x
= lcd_addr_y
= 0;
954 /* we must wait a few milliseconds (15) */
958 static void lcd_init_display(void)
961 lcd_flags
= ((lcd_height
> 1) ? LCD_FLAG_N
: 0)
962 | LCD_FLAG_D
| LCD_FLAG_C
| LCD_FLAG_B
;
964 long_sleep(20); /* wait 20 ms after power-up for the paranoid */
966 lcd_write_cmd(0x30); /* 8bits, 1 line, small fonts */
968 lcd_write_cmd(0x30); /* 8bits, 1 line, small fonts */
970 lcd_write_cmd(0x30); /* 8bits, 1 line, small fonts */
973 lcd_write_cmd(0x30 /* set font height and lines number */
974 | ((lcd_flags
& LCD_FLAG_F
) ? 4 : 0)
975 | ((lcd_flags
& LCD_FLAG_N
) ? 8 : 0)
979 lcd_write_cmd(0x08); /* display off, cursor off, blink off */
982 lcd_write_cmd(0x08 /* set display mode */
983 | ((lcd_flags
& LCD_FLAG_D
) ? 4 : 0)
984 | ((lcd_flags
& LCD_FLAG_C
) ? 2 : 0)
985 | ((lcd_flags
& LCD_FLAG_B
) ? 1 : 0)
988 lcd_backlight((lcd_flags
& LCD_FLAG_L
) ? 1 : 0);
992 /* entry mode set : increment, cursor shifting */
999 * These are the file operation function for user access to /dev/lcd
1000 * This function can also be called from inside the kernel, by
1001 * setting file and ppos to NULL.
1005 static inline int handle_lcd_special_code(void)
1007 /* LCD special codes */
1011 char *esc
= lcd_escape
+ 2;
1012 int oldflags
= lcd_flags
;
1014 /* check for display mode flags */
1016 case 'D': /* Display ON */
1017 lcd_flags
|= LCD_FLAG_D
;
1020 case 'd': /* Display OFF */
1021 lcd_flags
&= ~LCD_FLAG_D
;
1024 case 'C': /* Cursor ON */
1025 lcd_flags
|= LCD_FLAG_C
;
1028 case 'c': /* Cursor OFF */
1029 lcd_flags
&= ~LCD_FLAG_C
;
1032 case 'B': /* Blink ON */
1033 lcd_flags
|= LCD_FLAG_B
;
1036 case 'b': /* Blink OFF */
1037 lcd_flags
&= ~LCD_FLAG_B
;
1040 case '+': /* Back light ON */
1041 lcd_flags
|= LCD_FLAG_L
;
1044 case '-': /* Back light OFF */
1045 lcd_flags
&= ~LCD_FLAG_L
;
1049 /* flash back light using the keypad timer */
1050 if (scan_timer
.function
!= NULL
) {
1051 if (light_tempo
== 0 && ((lcd_flags
& LCD_FLAG_L
) == 0))
1053 light_tempo
= FLASH_LIGHT_TEMPO
;
1057 case 'f': /* Small Font */
1058 lcd_flags
&= ~LCD_FLAG_F
;
1061 case 'F': /* Large Font */
1062 lcd_flags
|= LCD_FLAG_F
;
1065 case 'n': /* One Line */
1066 lcd_flags
&= ~LCD_FLAG_N
;
1069 case 'N': /* Two Lines */
1070 lcd_flags
|= LCD_FLAG_N
;
1072 case 'l': /* Shift Cursor Left */
1073 if (lcd_addr_x
> 0) {
1074 /* back one char if not at end of line */
1075 if (lcd_addr_x
< lcd_bwidth
)
1076 lcd_write_cmd(0x10);
1081 case 'r': /* shift cursor right */
1082 if (lcd_addr_x
< lcd_width
) {
1083 /* allow the cursor to pass the end of the line */
1086 lcd_write_cmd(0x14);
1091 case 'L': /* shift display left */
1093 lcd_write_cmd(0x18);
1096 case 'R': /* shift display right */
1098 lcd_write_cmd(0x1C);
1101 case 'k': { /* kill end of line */
1103 for (x
= lcd_addr_x
; x
< lcd_bwidth
; x
++)
1104 lcd_write_data(' ');
1106 /* restore cursor position */
1111 case 'I': /* reinitialize display */
1117 /* Generator : LGcxxxxx...xx; must have <c> between '0'
1118 * and '7', representing the numerical ASCII code of the
1119 * redefined character, and <xx...xx> a sequence of 16
1120 * hex digits representing 8 bytes for each character.
1121 * Most LCDs will only use 5 lower bits of the 7 first
1125 unsigned char cgbytes
[8];
1126 unsigned char cgaddr
;
1132 if (strchr(esc
, ';') == NULL
)
1137 cgaddr
= *(esc
++) - '0';
1146 while (*esc
&& cgoffset
< 8) {
1148 if (*esc
>= '0' && *esc
<= '9')
1149 value
|= (*esc
- '0') << shift
;
1150 else if (*esc
>= 'A' && *esc
<= 'Z')
1151 value
|= (*esc
- 'A' + 10) << shift
;
1152 else if (*esc
>= 'a' && *esc
<= 'z')
1153 value
|= (*esc
- 'a' + 10) << shift
;
1160 cgbytes
[cgoffset
++] = value
;
1167 lcd_write_cmd(0x40 | (cgaddr
* 8));
1168 for (addr
= 0; addr
< cgoffset
; addr
++)
1169 lcd_write_data(cgbytes
[addr
]);
1171 /* ensures that we stop writing to CGRAM */
1176 case 'x': /* gotoxy : LxXXX[yYYY]; */
1177 case 'y': /* gotoxy : LyYYY[xXXX]; */
1178 if (strchr(esc
, ';') == NULL
)
1185 while (isdigit(*esc
)) {
1186 lcd_addr_x
= lcd_addr_x
* 10 +
1190 } else if (*esc
== 'y') {
1193 while (isdigit(*esc
)) {
1194 lcd_addr_y
= lcd_addr_y
* 10 +
1207 /* Check wether one flag was changed */
1208 if (oldflags
!= lcd_flags
) {
1209 /* check whether one of B,C,D flags were changed */
1210 if ((oldflags
^ lcd_flags
) &
1211 (LCD_FLAG_B
| LCD_FLAG_C
| LCD_FLAG_D
))
1212 /* set display mode */
1214 | ((lcd_flags
& LCD_FLAG_D
) ? 4 : 0)
1215 | ((lcd_flags
& LCD_FLAG_C
) ? 2 : 0)
1216 | ((lcd_flags
& LCD_FLAG_B
) ? 1 : 0));
1217 /* check whether one of F,N flags was changed */
1218 else if ((oldflags
^ lcd_flags
) & (LCD_FLAG_F
| LCD_FLAG_N
))
1220 | ((lcd_flags
& LCD_FLAG_F
) ? 4 : 0)
1221 | ((lcd_flags
& LCD_FLAG_N
) ? 8 : 0));
1222 /* check wether L flag was changed */
1223 else if ((oldflags
^ lcd_flags
) & (LCD_FLAG_L
)) {
1224 if (lcd_flags
& (LCD_FLAG_L
))
1226 else if (light_tempo
== 0)
1227 /* switch off the light only when the tempo
1236 static ssize_t
lcd_write(struct file
*file
,
1237 const char *buf
, size_t count
, loff_t
*ppos
)
1239 const char *tmp
= buf
;
1242 for (; count
-- > 0; (ppos
? (*ppos
)++ : 0), ++tmp
) {
1243 if (!in_interrupt() && (((count
+ 1) & 0x1f) == 0))
1244 /* let's be a little nice with other processes
1245 that need some CPU */
1248 if (ppos
== NULL
&& file
== NULL
)
1249 /* let's not use get_user() from the kernel ! */
1251 else if (get_user(c
, tmp
))
1254 /* first, we'll test if we're in escape mode */
1255 if ((c
!= '\n') && lcd_escape_len
>= 0) {
1256 /* yes, let's add this char to the buffer */
1257 lcd_escape
[lcd_escape_len
++] = c
;
1258 lcd_escape
[lcd_escape_len
] = 0;
1260 /* aborts any previous escape sequence */
1261 lcd_escape_len
= -1;
1264 case LCD_ESCAPE_CHAR
:
1265 /* start of an escape sequence */
1267 lcd_escape
[lcd_escape_len
] = 0;
1270 /* go back one char and clear it */
1271 if (lcd_addr_x
> 0) {
1272 /* check if we're not at the
1274 if (lcd_addr_x
< lcd_bwidth
)
1276 lcd_write_cmd(0x10);
1279 /* replace with a space */
1280 lcd_write_data(' ');
1281 /* back one char again */
1282 lcd_write_cmd(0x10);
1285 /* quickly clear the display */
1289 /* flush the remainder of the current line and
1290 go to the beginning of the next line */
1291 for (; lcd_addr_x
< lcd_bwidth
; lcd_addr_x
++)
1292 lcd_write_data(' ');
1294 lcd_addr_y
= (lcd_addr_y
+ 1) % lcd_height
;
1298 /* go to the beginning of the same line */
1303 /* print a space instead of the tab */
1307 /* simply print this char */
1313 /* now we'll see if we're in an escape mode and if the current
1314 escape sequence can be understood. */
1315 if (lcd_escape_len
>= 2) {
1318 if (!strcmp(lcd_escape
, "[2J")) {
1319 /* clear the display */
1322 } else if (!strcmp(lcd_escape
, "[H")) {
1323 /* cursor to home */
1324 lcd_addr_x
= lcd_addr_y
= 0;
1328 /* codes starting with ^[[L */
1329 else if ((lcd_escape_len
>= 3) &&
1330 (lcd_escape
[0] == '[') &&
1331 (lcd_escape
[1] == 'L')) {
1332 processed
= handle_lcd_special_code();
1335 /* LCD special escape codes */
1336 /* flush the escape sequence if it's been processed
1337 or if it is getting too long. */
1338 if (processed
|| (lcd_escape_len
>= LCD_ESCAPE_LEN
))
1339 lcd_escape_len
= -1;
1340 } /* escape codes */
1346 static int lcd_open(struct inode
*inode
, struct file
*file
)
1349 return -EBUSY
; /* open only once at a time */
1351 if (file
->f_mode
& FMODE_READ
) /* device is write-only */
1354 if (lcd_must_clear
) {
1355 lcd_clear_display();
1362 static int lcd_release(struct inode
*inode
, struct file
*file
)
1368 static const struct file_operations lcd_fops
= {
1371 .release
= lcd_release
,
1374 static struct miscdevice lcd_dev
= {
1380 /* public function usable from the kernel for any purpose */
1381 void panel_lcd_print(char *s
)
1383 if (lcd_enabled
&& lcd_initialized
)
1384 lcd_write(NULL
, s
, strlen(s
), NULL
);
1387 /* initialize the LCD driver */
1392 /* parallel mode, 8 bits */
1394 lcd_proto
= LCD_PROTO_PARALLEL
;
1395 if (lcd_charset
< 0)
1396 lcd_charset
= LCD_CHARSET_NORMAL
;
1397 if (lcd_e_pin
== PIN_NOT_SET
)
1398 lcd_e_pin
= PIN_STROBE
;
1399 if (lcd_rs_pin
== PIN_NOT_SET
)
1400 lcd_rs_pin
= PIN_AUTOLF
;
1411 case LCD_TYPE_KS0074
:
1412 /* serial mode, ks0074 */
1414 lcd_proto
= LCD_PROTO_SERIAL
;
1415 if (lcd_charset
< 0)
1416 lcd_charset
= LCD_CHARSET_KS0074
;
1417 if (lcd_bl_pin
== PIN_NOT_SET
)
1418 lcd_bl_pin
= PIN_AUTOLF
;
1419 if (lcd_cl_pin
== PIN_NOT_SET
)
1420 lcd_cl_pin
= PIN_STROBE
;
1421 if (lcd_da_pin
== PIN_NOT_SET
)
1422 lcd_da_pin
= PIN_D0
;
1433 case LCD_TYPE_NEXCOM
:
1434 /* parallel mode, 8 bits, generic */
1436 lcd_proto
= LCD_PROTO_PARALLEL
;
1437 if (lcd_charset
< 0)
1438 lcd_charset
= LCD_CHARSET_NORMAL
;
1439 if (lcd_e_pin
== PIN_NOT_SET
)
1440 lcd_e_pin
= PIN_AUTOLF
;
1441 if (lcd_rs_pin
== PIN_NOT_SET
)
1442 lcd_rs_pin
= PIN_SELECP
;
1443 if (lcd_rw_pin
== PIN_NOT_SET
)
1444 lcd_rw_pin
= PIN_INITP
;
1455 case LCD_TYPE_CUSTOM
:
1456 /* customer-defined */
1458 lcd_proto
= DEFAULT_LCD_PROTO
;
1459 if (lcd_charset
< 0)
1460 lcd_charset
= DEFAULT_LCD_CHARSET
;
1461 /* default geometry will be set later */
1463 case LCD_TYPE_HANTRONIX
:
1464 /* parallel mode, 8 bits, hantronix-like */
1467 lcd_proto
= LCD_PROTO_PARALLEL
;
1468 if (lcd_charset
< 0)
1469 lcd_charset
= LCD_CHARSET_NORMAL
;
1470 if (lcd_e_pin
== PIN_NOT_SET
)
1471 lcd_e_pin
= PIN_STROBE
;
1472 if (lcd_rs_pin
== PIN_NOT_SET
)
1473 lcd_rs_pin
= PIN_SELECP
;
1486 /* this is used to catch wrong and default values */
1488 lcd_width
= DEFAULT_LCD_WIDTH
;
1489 if (lcd_bwidth
<= 0)
1490 lcd_bwidth
= DEFAULT_LCD_BWIDTH
;
1491 if (lcd_hwidth
<= 0)
1492 lcd_hwidth
= DEFAULT_LCD_HWIDTH
;
1493 if (lcd_height
<= 0)
1494 lcd_height
= DEFAULT_LCD_HEIGHT
;
1496 if (lcd_proto
== LCD_PROTO_SERIAL
) { /* SERIAL */
1497 lcd_write_cmd
= lcd_write_cmd_s
;
1498 lcd_write_data
= lcd_write_data_s
;
1499 lcd_clear_fast
= lcd_clear_fast_s
;
1501 if (lcd_cl_pin
== PIN_NOT_SET
)
1502 lcd_cl_pin
= DEFAULT_LCD_PIN_SCL
;
1503 if (lcd_da_pin
== PIN_NOT_SET
)
1504 lcd_da_pin
= DEFAULT_LCD_PIN_SDA
;
1506 } else if (lcd_proto
== LCD_PROTO_PARALLEL
) { /* PARALLEL */
1507 lcd_write_cmd
= lcd_write_cmd_p8
;
1508 lcd_write_data
= lcd_write_data_p8
;
1509 lcd_clear_fast
= lcd_clear_fast_p8
;
1511 if (lcd_e_pin
== PIN_NOT_SET
)
1512 lcd_e_pin
= DEFAULT_LCD_PIN_E
;
1513 if (lcd_rs_pin
== PIN_NOT_SET
)
1514 lcd_rs_pin
= DEFAULT_LCD_PIN_RS
;
1515 if (lcd_rw_pin
== PIN_NOT_SET
)
1516 lcd_rw_pin
= DEFAULT_LCD_PIN_RW
;
1518 lcd_write_cmd
= lcd_write_cmd_tilcd
;
1519 lcd_write_data
= lcd_write_data_tilcd
;
1520 lcd_clear_fast
= lcd_clear_fast_tilcd
;
1523 if (lcd_bl_pin
== PIN_NOT_SET
)
1524 lcd_bl_pin
= DEFAULT_LCD_PIN_BL
;
1526 if (lcd_e_pin
== PIN_NOT_SET
)
1527 lcd_e_pin
= PIN_NONE
;
1528 if (lcd_rs_pin
== PIN_NOT_SET
)
1529 lcd_rs_pin
= PIN_NONE
;
1530 if (lcd_rw_pin
== PIN_NOT_SET
)
1531 lcd_rw_pin
= PIN_NONE
;
1532 if (lcd_bl_pin
== PIN_NOT_SET
)
1533 lcd_bl_pin
= PIN_NONE
;
1534 if (lcd_cl_pin
== PIN_NOT_SET
)
1535 lcd_cl_pin
= PIN_NONE
;
1536 if (lcd_da_pin
== PIN_NOT_SET
)
1537 lcd_da_pin
= PIN_NONE
;
1539 if (lcd_charset
< 0)
1540 lcd_charset
= DEFAULT_LCD_CHARSET
;
1542 if (lcd_charset
== LCD_CHARSET_KS0074
)
1543 lcd_char_conv
= lcd_char_conv_ks0074
;
1545 lcd_char_conv
= NULL
;
1547 if (lcd_bl_pin
!= PIN_NONE
)
1550 pin_to_bits(lcd_e_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_E
],
1551 lcd_bits
[LCD_PORT_C
][LCD_BIT_E
]);
1552 pin_to_bits(lcd_rs_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_RS
],
1553 lcd_bits
[LCD_PORT_C
][LCD_BIT_RS
]);
1554 pin_to_bits(lcd_rw_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_RW
],
1555 lcd_bits
[LCD_PORT_C
][LCD_BIT_RW
]);
1556 pin_to_bits(lcd_bl_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_BL
],
1557 lcd_bits
[LCD_PORT_C
][LCD_BIT_BL
]);
1558 pin_to_bits(lcd_cl_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_CL
],
1559 lcd_bits
[LCD_PORT_C
][LCD_BIT_CL
]);
1560 pin_to_bits(lcd_da_pin
, lcd_bits
[LCD_PORT_D
][LCD_BIT_DA
],
1561 lcd_bits
[LCD_PORT_C
][LCD_BIT_DA
]);
1563 /* before this line, we must NOT send anything to the display.
1564 * Since lcd_init_display() needs to write data, we have to
1565 * enable mark the LCD initialized just before. */
1566 lcd_initialized
= 1;
1569 /* display a short message */
1570 #ifdef CONFIG_PANEL_CHANGE_MESSAGE
1571 #ifdef CONFIG_PANEL_BOOT_MESSAGE
1572 panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*" CONFIG_PANEL_BOOT_MESSAGE
);
1575 panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*Linux-" UTS_RELEASE
"\nPanel-"
1578 lcd_addr_x
= lcd_addr_y
= 0;
1579 /* clear the display on the next device opening */
1585 * These are the file operation function for user access to /dev/keypad
1588 static ssize_t
keypad_read(struct file
*file
,
1589 char *buf
, size_t count
, loff_t
*ppos
)
1595 if (keypad_buflen
== 0) {
1596 if (file
->f_flags
& O_NONBLOCK
)
1599 interruptible_sleep_on(&keypad_read_wait
);
1600 if (signal_pending(current
))
1604 for (; count
-- > 0 && (keypad_buflen
> 0);
1605 ++i
, ++tmp
, --keypad_buflen
) {
1606 put_user(keypad_buffer
[keypad_start
], tmp
);
1607 keypad_start
= (keypad_start
+ 1) % KEYPAD_BUFFER
;
1614 static int keypad_open(struct inode
*inode
, struct file
*file
)
1617 if (keypad_open_cnt
)
1618 return -EBUSY
; /* open only once at a time */
1620 if (file
->f_mode
& FMODE_WRITE
) /* device is read-only */
1623 keypad_buflen
= 0; /* flush the buffer on opening */
1628 static int keypad_release(struct inode
*inode
, struct file
*file
)
1634 static const struct file_operations keypad_fops
= {
1635 .read
= keypad_read
, /* read */
1636 .open
= keypad_open
, /* open */
1637 .release
= keypad_release
, /* close */
1640 static struct miscdevice keypad_dev
= {
1646 static void keypad_send_key(char *string
, int max_len
)
1648 if (init_in_progress
)
1651 /* send the key to the device only if a process is attached to it. */
1652 if (keypad_open_cnt
> 0) {
1653 while (max_len
-- && keypad_buflen
< KEYPAD_BUFFER
&& *string
) {
1654 keypad_buffer
[(keypad_start
+ keypad_buflen
++) %
1655 KEYPAD_BUFFER
] = *string
++;
1657 wake_up_interruptible(&keypad_read_wait
);
1661 /* this function scans all the bits involving at least one logical signal,
1662 * and puts the results in the bitfield "phys_read" (one bit per established
1663 * contact), and sets "phys_read_prev" to "phys_read".
1665 * Note: to debounce input signals, we will only consider as switched a signal
1666 * which is stable across 2 measures. Signals which are different between two
1667 * reads will be kept as they previously were in their logical form (phys_prev).
1668 * A signal which has just switched will have a 1 in
1669 * (phys_read ^ phys_read_prev).
1671 static void phys_scan_contacts(void)
1678 phys_prev
= phys_curr
;
1679 phys_read_prev
= phys_read
;
1680 phys_read
= 0; /* flush all signals */
1682 /* keep track of old value, with all outputs disabled */
1683 oldval
= r_dtr(pprt
) | scan_mask_o
;
1684 /* activate all keyboard outputs (active low) */
1685 w_dtr(pprt
, oldval
& ~scan_mask_o
);
1687 /* will have a 1 for each bit set to gnd */
1688 bitmask
= PNL_PINPUT(r_str(pprt
)) & scan_mask_i
;
1689 /* disable all matrix signals */
1690 w_dtr(pprt
, oldval
);
1692 /* now that all outputs are cleared, the only active input bits are
1693 * directly connected to the ground
1696 /* 1 for each grounded input */
1697 gndmask
= PNL_PINPUT(r_str(pprt
)) & scan_mask_i
;
1699 /* grounded inputs are signals 40-44 */
1700 phys_read
|= (pmask_t
) gndmask
<< 40;
1702 if (bitmask
!= gndmask
) {
1703 /* since clearing the outputs changed some inputs, we know
1704 * that some input signals are currently tied to some outputs.
1705 * So we'll scan them.
1707 for (bit
= 0; bit
< 8; bit
++) {
1710 if (!(scan_mask_o
& bitval
)) /* skip unused bits */
1713 w_dtr(pprt
, oldval
& ~bitval
); /* enable this output */
1714 bitmask
= PNL_PINPUT(r_str(pprt
)) & ~gndmask
;
1715 phys_read
|= (pmask_t
) bitmask
<< (5 * bit
);
1717 w_dtr(pprt
, oldval
); /* disable all outputs */
1719 /* this is easy: use old bits when they are flapping,
1720 * use new ones when stable */
1721 phys_curr
= (phys_prev
& (phys_read
^ phys_read_prev
)) |
1722 (phys_read
& ~(phys_read
^ phys_read_prev
));
1725 static inline int input_state_high(struct logical_input
*input
)
1729 * this is an invalid test. It tries to catch
1730 * transitions from single-key to multiple-key, but
1731 * doesn't take into account the contacts polarity.
1732 * The only solution to the problem is to parse keys
1733 * from the most complex to the simplest combinations,
1734 * and mark them as 'caught' once a combination
1735 * matches, then unmatch it for all other ones.
1738 /* try to catch dangerous transitions cases :
1739 * someone adds a bit, so this signal was a false
1740 * positive resulting from a transition. We should
1741 * invalidate the signal immediately and not call the
1743 * eg: 0 -(press A)-> A -(press B)-> AB : don't match A's release.
1745 if (((phys_prev
& input
->mask
) == input
->value
)
1746 && ((phys_curr
& input
->mask
) > input
->value
)) {
1747 input
->state
= INPUT_ST_LOW
; /* invalidate */
1752 if ((phys_curr
& input
->mask
) == input
->value
) {
1753 if ((input
->type
== INPUT_TYPE_STD
) &&
1754 (input
->high_timer
== 0)) {
1755 input
->high_timer
++;
1756 if (input
->u
.std
.press_fct
!= NULL
)
1757 input
->u
.std
.press_fct(input
->u
.std
.press_data
);
1758 } else if (input
->type
== INPUT_TYPE_KBD
) {
1759 /* will turn on the light */
1762 if (input
->high_timer
== 0) {
1763 char *press_str
= input
->u
.kbd
.press_str
;
1765 keypad_send_key(press_str
,
1769 if (input
->u
.kbd
.repeat_str
[0]) {
1770 char *repeat_str
= input
->u
.kbd
.repeat_str
;
1771 if (input
->high_timer
>= KEYPAD_REP_START
) {
1772 input
->high_timer
-= KEYPAD_REP_DELAY
;
1773 keypad_send_key(repeat_str
,
1774 sizeof(repeat_str
));
1776 /* we will need to come back here soon */
1780 if (input
->high_timer
< 255)
1781 input
->high_timer
++;
1785 /* else signal falling down. Let's fall through. */
1786 input
->state
= INPUT_ST_FALLING
;
1787 input
->fall_timer
= 0;
1792 static inline void input_state_falling(struct logical_input
*input
)
1795 /* FIXME !!! same comment as in input_state_high */
1796 if (((phys_prev
& input
->mask
) == input
->value
)
1797 && ((phys_curr
& input
->mask
) > input
->value
)) {
1798 input
->state
= INPUT_ST_LOW
; /* invalidate */
1803 if ((phys_curr
& input
->mask
) == input
->value
) {
1804 if (input
->type
== INPUT_TYPE_KBD
) {
1805 /* will turn on the light */
1808 if (input
->u
.kbd
.repeat_str
[0]) {
1809 char *repeat_str
= input
->u
.kbd
.repeat_str
;
1810 if (input
->high_timer
>= KEYPAD_REP_START
)
1811 input
->high_timer
-= KEYPAD_REP_DELAY
;
1812 keypad_send_key(repeat_str
,
1813 sizeof(repeat_str
));
1814 /* we will need to come back here soon */
1818 if (input
->high_timer
< 255)
1819 input
->high_timer
++;
1821 input
->state
= INPUT_ST_HIGH
;
1822 } else if (input
->fall_timer
>= input
->fall_time
) {
1823 /* call release event */
1824 if (input
->type
== INPUT_TYPE_STD
) {
1825 void (*release_fct
)(int) = input
->u
.std
.release_fct
;
1826 if (release_fct
!= NULL
)
1827 release_fct(input
->u
.std
.release_data
);
1828 } else if (input
->type
== INPUT_TYPE_KBD
) {
1829 char *release_str
= input
->u
.kbd
.release_str
;
1831 keypad_send_key(release_str
,
1832 sizeof(release_str
));
1835 input
->state
= INPUT_ST_LOW
;
1837 input
->fall_timer
++;
1842 static void panel_process_inputs(void)
1844 struct list_head
*item
;
1845 struct logical_input
*input
;
1849 "entering panel_process_inputs with pp=%016Lx & pc=%016Lx\n",
1850 phys_prev
, phys_curr
);
1855 list_for_each(item
, &logical_inputs
) {
1856 input
= list_entry(item
, struct logical_input
, list
);
1858 switch (input
->state
) {
1860 if ((phys_curr
& input
->mask
) != input
->value
)
1862 /* if all needed ones were already set previously,
1863 * this means that this logical signal has been
1864 * activated by the releasing of another combined
1865 * signal, so we don't want to match.
1866 * eg: AB -(release B)-> A -(release A)-> 0 :
1869 if ((phys_prev
& input
->mask
) == input
->value
)
1871 input
->rise_timer
= 0;
1872 input
->state
= INPUT_ST_RISING
;
1873 /* no break here, fall through */
1874 case INPUT_ST_RISING
:
1875 if ((phys_curr
& input
->mask
) != input
->value
) {
1876 input
->state
= INPUT_ST_LOW
;
1879 if (input
->rise_timer
< input
->rise_time
) {
1881 input
->rise_timer
++;
1884 input
->high_timer
= 0;
1885 input
->state
= INPUT_ST_HIGH
;
1886 /* no break here, fall through */
1888 if (input_state_high(input
))
1890 /* no break here, fall through */
1891 case INPUT_ST_FALLING
:
1892 input_state_falling(input
);
1897 static void panel_scan_timer(void)
1899 if (keypad_enabled
&& keypad_initialized
) {
1900 if (spin_trylock(&pprt_lock
)) {
1901 phys_scan_contacts();
1903 /* no need for the parport anymore */
1904 spin_unlock(&pprt_lock
);
1907 if (!inputs_stable
|| phys_curr
!= phys_prev
)
1908 panel_process_inputs();
1911 if (lcd_enabled
&& lcd_initialized
) {
1913 if (light_tempo
== 0 && ((lcd_flags
& LCD_FLAG_L
) == 0))
1915 light_tempo
= FLASH_LIGHT_TEMPO
;
1916 } else if (light_tempo
> 0) {
1918 if (light_tempo
== 0 && ((lcd_flags
& LCD_FLAG_L
) == 0))
1923 mod_timer(&scan_timer
, jiffies
+ INPUT_POLL_TIME
);
1926 static void init_scan_timer(void)
1928 if (scan_timer
.function
!= NULL
)
1929 return; /* already started */
1931 init_timer(&scan_timer
);
1932 scan_timer
.expires
= jiffies
+ INPUT_POLL_TIME
;
1933 scan_timer
.data
= 0;
1934 scan_timer
.function
= (void *)&panel_scan_timer
;
1935 add_timer(&scan_timer
);
1938 /* converts a name of the form "({BbAaPpSsEe}{01234567-})*" to a series of bits.
1939 * if <omask> or <imask> are non-null, they will be or'ed with the bits
1940 * corresponding to out and in bits respectively.
1941 * returns 1 if ok, 0 if error (in which case, nothing is written).
1943 static int input_name2mask(char *name
, pmask_t
*mask
, pmask_t
*value
,
1944 char *imask
, char *omask
)
1946 static char sigtab
[10] = "EeSsPpAaBb";
1950 om
= im
= m
= v
= 0ULL;
1952 int in
, out
, bit
, neg
;
1953 for (in
= 0; (in
< sizeof(sigtab
)) &&
1954 (sigtab
[in
] != *name
); in
++)
1956 if (in
>= sizeof(sigtab
))
1957 return 0; /* input name not found */
1958 neg
= (in
& 1); /* odd (lower) names are negated */
1963 if (isdigit(*name
)) {
1966 } else if (*name
== '-')
1969 return 0; /* unknown bit name */
1971 bit
= (out
* 5) + in
;
1987 /* tries to bind a key to the signal name <name>. The key will send the
1988 * strings <press>, <repeat>, <release> for these respective events.
1989 * Returns the pointer to the new key if ok, NULL if the key could not be bound.
1991 static struct logical_input
*panel_bind_key(char *name
, char *press
,
1992 char *repeat
, char *release
)
1994 struct logical_input
*key
;
1996 key
= kzalloc(sizeof(struct logical_input
), GFP_KERNEL
);
1998 printk(KERN_ERR
"panel: not enough memory\n");
2001 if (!input_name2mask(name
, &key
->mask
, &key
->value
, &scan_mask_i
,
2005 key
->type
= INPUT_TYPE_KBD
;
2006 key
->state
= INPUT_ST_LOW
;
2011 printk(KERN_DEBUG
"bind: <%s> : m=%016Lx v=%016Lx\n", name
, key
->mask
,
2014 strncpy(key
->u
.kbd
.press_str
, press
, sizeof(key
->u
.kbd
.press_str
));
2015 strncpy(key
->u
.kbd
.repeat_str
, repeat
, sizeof(key
->u
.kbd
.repeat_str
));
2016 strncpy(key
->u
.kbd
.release_str
, release
,
2017 sizeof(key
->u
.kbd
.release_str
));
2018 list_add(&key
->list
, &logical_inputs
);
2023 /* tries to bind a callback function to the signal name <name>. The function
2024 * <press_fct> will be called with the <press_data> arg when the signal is
2025 * activated, and so on for <release_fct>/<release_data>
2026 * Returns the pointer to the new signal if ok, NULL if the signal could not
2029 static struct logical_input
*panel_bind_callback(char *name
,
2030 void (*press_fct
) (int),
2032 void (*release_fct
) (int),
2035 struct logical_input
*callback
;
2037 callback
= kmalloc(sizeof(struct logical_input
), GFP_KERNEL
);
2039 printk(KERN_ERR
"panel: not enough memory\n");
2042 memset(callback
, 0, sizeof(struct logical_input
));
2043 if (!input_name2mask(name
, &callback
->mask
, &callback
->value
,
2044 &scan_mask_i
, &scan_mask_o
))
2047 callback
->type
= INPUT_TYPE_STD
;
2048 callback
->state
= INPUT_ST_LOW
;
2049 callback
->rise_time
= 1;
2050 callback
->fall_time
= 1;
2051 callback
->u
.std
.press_fct
= press_fct
;
2052 callback
->u
.std
.press_data
= press_data
;
2053 callback
->u
.std
.release_fct
= release_fct
;
2054 callback
->u
.std
.release_data
= release_data
;
2055 list_add(&callback
->list
, &logical_inputs
);
2060 static void keypad_init(void)
2063 init_waitqueue_head(&keypad_read_wait
);
2064 keypad_buflen
= 0; /* flushes any eventual noisy keystroke */
2066 /* Let's create all known keys */
2068 for (keynum
= 0; keypad_profile
[keynum
][0][0]; keynum
++) {
2069 panel_bind_key(keypad_profile
[keynum
][0],
2070 keypad_profile
[keynum
][1],
2071 keypad_profile
[keynum
][2],
2072 keypad_profile
[keynum
][3]);
2076 keypad_initialized
= 1;
2079 /**************************************************/
2080 /* device initialization */
2081 /**************************************************/
2083 static int panel_notify_sys(struct notifier_block
*this, unsigned long code
,
2086 if (lcd_enabled
&& lcd_initialized
) {
2090 ("\x0cReloading\nSystem...\x1b[Lc\x1b[Lb\x1b[L+");
2094 ("\x0cSystem Halted.\x1b[Lc\x1b[Lb\x1b[L+");
2097 panel_lcd_print("\x0cPower off.\x1b[Lc\x1b[Lb\x1b[L+");
2106 static struct notifier_block panel_notifier
= {
2112 static void panel_attach(struct parport
*port
)
2114 if (port
->number
!= parport
)
2119 "panel_attach(): port->number=%d parport=%d, "
2120 "already registered !\n",
2121 port
->number
, parport
);
2125 pprt
= parport_register_device(port
, "panel", NULL
, NULL
, /* pf, kf */
2127 /*PARPORT_DEV_EXCL */
2130 if (parport_claim(pprt
)) {
2132 "Panel: could not claim access to parport%d. "
2133 "Aborting.\n", parport
);
2137 /* must init LCD first, just in case an IRQ from the keypad is
2138 * generated at keypad init
2142 misc_register(&lcd_dev
);
2145 if (keypad_enabled
) {
2147 misc_register(&keypad_dev
);
2151 static void panel_detach(struct parport
*port
)
2153 if (port
->number
!= parport
)
2158 "panel_detach(): port->number=%d parport=%d, "
2159 "nothing to unregister.\n",
2160 port
->number
, parport
);
2164 if (keypad_enabled
&& keypad_initialized
) {
2165 misc_deregister(&keypad_dev
);
2166 keypad_initialized
= 0;
2169 if (lcd_enabled
&& lcd_initialized
) {
2170 misc_deregister(&lcd_dev
);
2171 lcd_initialized
= 0;
2174 parport_release(pprt
);
2175 parport_unregister_device(pprt
);
2179 static struct parport_driver panel_driver
= {
2181 .attach
= panel_attach
,
2182 .detach
= panel_detach
,
2186 int panel_init(void)
2188 /* for backwards compatibility */
2189 if (keypad_type
< 0)
2190 keypad_type
= keypad_enabled
;
2193 lcd_type
= lcd_enabled
;
2196 parport
= DEFAULT_PARPORT
;
2198 /* take care of an eventual profile */
2200 case PANEL_PROFILE_CUSTOM
:
2201 /* custom profile */
2202 if (keypad_type
< 0)
2203 keypad_type
= DEFAULT_KEYPAD
;
2205 lcd_type
= DEFAULT_LCD
;
2207 case PANEL_PROFILE_OLD
:
2208 /* 8 bits, 2*16, old keypad */
2209 if (keypad_type
< 0)
2210 keypad_type
= KEYPAD_TYPE_OLD
;
2212 lcd_type
= LCD_TYPE_OLD
;
2218 case PANEL_PROFILE_NEW
:
2219 /* serial, 2*16, new keypad */
2220 if (keypad_type
< 0)
2221 keypad_type
= KEYPAD_TYPE_NEW
;
2223 lcd_type
= LCD_TYPE_KS0074
;
2225 case PANEL_PROFILE_HANTRONIX
:
2226 /* 8 bits, 2*16 hantronix-like, no keypad */
2227 if (keypad_type
< 0)
2228 keypad_type
= KEYPAD_TYPE_NONE
;
2230 lcd_type
= LCD_TYPE_HANTRONIX
;
2232 case PANEL_PROFILE_NEXCOM
:
2233 /* generic 8 bits, 2*16, nexcom keypad, eg. Nexcom. */
2234 if (keypad_type
< 0)
2235 keypad_type
= KEYPAD_TYPE_NEXCOM
;
2237 lcd_type
= LCD_TYPE_NEXCOM
;
2239 case PANEL_PROFILE_LARGE
:
2240 /* 8 bits, 2*40, old keypad */
2241 if (keypad_type
< 0)
2242 keypad_type
= KEYPAD_TYPE_OLD
;
2244 lcd_type
= LCD_TYPE_OLD
;
2248 lcd_enabled
= (lcd_type
> 0);
2249 keypad_enabled
= (keypad_type
> 0);
2251 switch (keypad_type
) {
2252 case KEYPAD_TYPE_OLD
:
2253 keypad_profile
= old_keypad_profile
;
2255 case KEYPAD_TYPE_NEW
:
2256 keypad_profile
= new_keypad_profile
;
2258 case KEYPAD_TYPE_NEXCOM
:
2259 keypad_profile
= nexcom_keypad_profile
;
2262 keypad_profile
= NULL
;
2266 /* tells various subsystems about the fact that we are initializing */
2267 init_in_progress
= 1;
2269 if (parport_register_driver(&panel_driver
)) {
2271 "Panel: could not register with parport. Aborting.\n");
2275 if (!lcd_enabled
&& !keypad_enabled
) {
2276 /* no device enabled, let's release the parport */
2278 parport_release(pprt
);
2279 parport_unregister_device(pprt
);
2281 parport_unregister_driver(&panel_driver
);
2282 printk(KERN_ERR
"Panel driver version " PANEL_VERSION
2287 register_reboot_notifier(&panel_notifier
);
2290 printk(KERN_INFO
"Panel driver version " PANEL_VERSION
2291 " registered on parport%d (io=0x%lx).\n", parport
,
2294 printk(KERN_INFO
"Panel driver version " PANEL_VERSION
2295 " not yet registered\n");
2296 /* tells various subsystems about the fact that initialization
2298 init_in_progress
= 0;
2302 static int __init
panel_init_module(void)
2304 return panel_init();
2307 static void __exit
panel_cleanup_module(void)
2309 unregister_reboot_notifier(&panel_notifier
);
2311 if (scan_timer
.function
!= NULL
)
2312 del_timer(&scan_timer
);
2315 if (keypad_enabled
) {
2316 misc_deregister(&keypad_dev
);
2317 keypad_initialized
= 0;
2321 panel_lcd_print("\x0cLCD driver " PANEL_VERSION
2322 "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
2323 misc_deregister(&lcd_dev
);
2324 lcd_initialized
= 0;
2327 /* TODO: free all input signals */
2328 parport_release(pprt
);
2329 parport_unregister_device(pprt
);
2331 parport_unregister_driver(&panel_driver
);
2334 module_init(panel_init_module
);
2335 module_exit(panel_cleanup_module
);
2336 MODULE_AUTHOR("Willy Tarreau");
2337 MODULE_LICENSE("GPL");