2 * Front panel driver for Linux
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 */
134 #define LCD_CMD_DISPLAY_CLEAR 0x01 /* Clear entire display */
136 #define LCD_CMD_ENTRY_MODE 0x04 /* Set entry mode */
137 #define LCD_CMD_CURSOR_INC 0x02 /* Increment cursor */
139 #define LCD_CMD_DISPLAY_CTRL 0x08 /* Display control */
140 #define LCD_CMD_DISPLAY_ON 0x04 /* Set display on */
141 #define LCD_CMD_CURSOR_ON 0x02 /* Set cursor on */
142 #define LCD_CMD_BLINK_ON 0x01 /* Set blink on */
144 #define LCD_CMD_SHIFT 0x10 /* Shift cursor/display */
145 #define LCD_CMD_DISPLAY_SHIFT 0x08 /* Shift display instead of cursor */
146 #define LCD_CMD_SHIFT_RIGHT 0x04 /* Shift display/cursor to the right */
148 #define LCD_CMD_FUNCTION_SET 0x20 /* Set function */
149 #define LCD_CMD_DATA_LEN_8BITS 0x10 /* Set data length to 8 bits */
150 #define LCD_CMD_TWO_LINES 0x08 /* Set to two display lines */
151 #define LCD_CMD_FONT_5X10_DOTS 0x04 /* Set char font to 5x10 dots */
153 #define LCD_CMD_SET_CGRAM_ADDR 0x40 /* Set char generator RAM address */
155 #define LCD_CMD_SET_DDRAM_ADDR 0x80 /* Set display data RAM address */
157 #define LCD_ESCAPE_LEN 24 /* max chars for LCD escape command */
158 #define LCD_ESCAPE_CHAR 27 /* use char 27 for escape command */
162 /* macros to simplify use of the parallel port */
163 #define r_ctr(x) (parport_read_control((x)->port))
164 #define r_dtr(x) (parport_read_data((x)->port))
165 #define r_str(x) (parport_read_status((x)->port))
166 #define w_ctr(x, y) (parport_write_control((x)->port, (y)))
167 #define w_dtr(x, y) (parport_write_data((x)->port, (y)))
169 /* this defines which bits are to be used and which ones to be ignored */
170 /* logical or of the output bits involved in the scan matrix */
171 static __u8 scan_mask_o;
172 /* logical or of the input bits involved in the scan matrix */
173 static __u8 scan_mask_i;
175 typedef __u64 pmask_t;
189 struct logical_input {
190 struct list_head list;
193 enum input_type type;
194 enum input_state state;
195 __u8 rise_time, fall_time;
196 __u8 rise_timer, fall_timer, high_timer;
199 struct { /* valid when type == INPUT_TYPE_STD */
200 void (*press_fct)(int);
201 void (*release_fct)(int);
205 struct { /* valid when type == INPUT_TYPE_KBD */
206 /* strings can be non null-terminated */
207 char press_str[sizeof(void *) + sizeof(int)];
208 char repeat_str[sizeof(void *) + sizeof(int)];
209 char release_str[sizeof(void *) + sizeof(int)];
214 static LIST_HEAD(logical_inputs); /* list of all defined logical inputs */
216 /* physical contacts history
217 * Physical contacts are a 45 bits string of 9 groups of 5 bits each.
218 * The 8 lower groups correspond to output bits 0 to 7, and the 9th group
219 * corresponds to the ground.
220 * Within each group, bits are stored in the same order as read on the port :
221 * BAPSE (busy=4, ack=3, paper empty=2, select=1, error=0).
222 * So, each __u64 (or pmask_t) is represented like this :
223 * 0000000000000000000BAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSE
224 * <-----unused------><gnd><d07><d06><d05><d04><d03><d02><d01><d00>
227 /* what has just been read from the I/O ports */
228 static pmask_t phys_read;
229 /* previous phys_read */
230 static pmask_t phys_read_prev;
231 /* stabilized phys_read (phys_read|phys_read_prev) */
232 static pmask_t phys_curr;
233 /* previous phys_curr */
234 static pmask_t phys_prev;
235 /* 0 means that at least one logical signal needs be computed */
236 static char inputs_stable;
238 /* these variables are specific to the keypad */
243 static char keypad_buffer[KEYPAD_BUFFER];
244 static int keypad_buflen;
245 static int keypad_start;
246 static char keypressed;
247 static wait_queue_head_t keypad_read_wait;
249 /* lcd-specific variables */
263 /* TODO: use union here? */
273 /* contains the LCD config state */
274 unsigned long int flags;
276 /* Contains the LCD X and Y offset */
282 /* Current escape sequence and it's length or -1 if outside */
284 char buf[LCD_ESCAPE_LEN + 1];
289 /* Needed only for init */
290 static int selected_lcd_type = NOT_SET;
293 * Bit masks to convert LCD signals to parallel port outputs.
294 * _d_ are values for data port, _c_ are for control port.
295 * [0] = signal OFF, [1] = signal ON, [2] = mask
302 * one entry for each bit on the LCD
313 * each bit can be either connected to a DATA or CTRL port
319 static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES];
324 #define LCD_PROTO_PARALLEL 0
325 #define LCD_PROTO_SERIAL 1
326 #define LCD_PROTO_TI_DA8XX_LCD 2
331 #define LCD_CHARSET_NORMAL 0
332 #define LCD_CHARSET_KS0074 1
337 #define LCD_TYPE_NONE 0
338 #define LCD_TYPE_CUSTOM 1
339 #define LCD_TYPE_OLD 2
340 #define LCD_TYPE_KS0074 3
341 #define LCD_TYPE_HANTRONIX 4
342 #define LCD_TYPE_NEXCOM 5
347 #define KEYPAD_TYPE_NONE 0
348 #define KEYPAD_TYPE_OLD 1
349 #define KEYPAD_TYPE_NEW 2
350 #define KEYPAD_TYPE_NEXCOM 3
355 #define PANEL_PROFILE_CUSTOM 0
356 #define PANEL_PROFILE_OLD 1
357 #define PANEL_PROFILE_NEW 2
358 #define PANEL_PROFILE_HANTRONIX 3
359 #define PANEL_PROFILE_NEXCOM 4
360 #define PANEL_PROFILE_LARGE 5
363 * Construct custom config from the kernel's configuration
365 #define DEFAULT_PARPORT 0
366 #define DEFAULT_PROFILE PANEL_PROFILE_LARGE
367 #define DEFAULT_KEYPAD_TYPE KEYPAD_TYPE_OLD
368 #define DEFAULT_LCD_TYPE LCD_TYPE_OLD
369 #define DEFAULT_LCD_HEIGHT 2
370 #define DEFAULT_LCD_WIDTH 40
371 #define DEFAULT_LCD_BWIDTH 40
372 #define DEFAULT_LCD_HWIDTH 64
373 #define DEFAULT_LCD_CHARSET LCD_CHARSET_NORMAL
374 #define DEFAULT_LCD_PROTO LCD_PROTO_PARALLEL
376 #define DEFAULT_LCD_PIN_E PIN_AUTOLF
377 #define DEFAULT_LCD_PIN_RS PIN_SELECP
378 #define DEFAULT_LCD_PIN_RW PIN_INITP
379 #define DEFAULT_LCD_PIN_SCL PIN_STROBE
380 #define DEFAULT_LCD_PIN_SDA PIN_D0
381 #define DEFAULT_LCD_PIN_BL PIN_NOT_SET
383 #ifdef CONFIG_PANEL_PARPORT
384 #undef DEFAULT_PARPORT
385 #define DEFAULT_PARPORT CONFIG_PANEL_PARPORT
388 #ifdef CONFIG_PANEL_PROFILE
389 #undef DEFAULT_PROFILE
390 #define DEFAULT_PROFILE CONFIG_PANEL_PROFILE
393 #if DEFAULT_PROFILE == 0 /* custom */
394 #ifdef CONFIG_PANEL_KEYPAD
395 #undef DEFAULT_KEYPAD_TYPE
396 #define DEFAULT_KEYPAD_TYPE CONFIG_PANEL_KEYPAD
399 #ifdef CONFIG_PANEL_LCD
400 #undef DEFAULT_LCD_TYPE
401 #define DEFAULT_LCD_TYPE CONFIG_PANEL_LCD
404 #ifdef CONFIG_PANEL_LCD_HEIGHT
405 #undef DEFAULT_LCD_HEIGHT
406 #define DEFAULT_LCD_HEIGHT CONFIG_PANEL_LCD_HEIGHT
409 #ifdef CONFIG_PANEL_LCD_WIDTH
410 #undef DEFAULT_LCD_WIDTH
411 #define DEFAULT_LCD_WIDTH CONFIG_PANEL_LCD_WIDTH
414 #ifdef CONFIG_PANEL_LCD_BWIDTH
415 #undef DEFAULT_LCD_BWIDTH
416 #define DEFAULT_LCD_BWIDTH CONFIG_PANEL_LCD_BWIDTH
419 #ifdef CONFIG_PANEL_LCD_HWIDTH
420 #undef DEFAULT_LCD_HWIDTH
421 #define DEFAULT_LCD_HWIDTH CONFIG_PANEL_LCD_HWIDTH
424 #ifdef CONFIG_PANEL_LCD_CHARSET
425 #undef DEFAULT_LCD_CHARSET
426 #define DEFAULT_LCD_CHARSET CONFIG_PANEL_LCD_CHARSET
429 #ifdef CONFIG_PANEL_LCD_PROTO
430 #undef DEFAULT_LCD_PROTO
431 #define DEFAULT_LCD_PROTO CONFIG_PANEL_LCD_PROTO
434 #ifdef CONFIG_PANEL_LCD_PIN_E
435 #undef DEFAULT_LCD_PIN_E
436 #define DEFAULT_LCD_PIN_E CONFIG_PANEL_LCD_PIN_E
439 #ifdef CONFIG_PANEL_LCD_PIN_RS
440 #undef DEFAULT_LCD_PIN_RS
441 #define DEFAULT_LCD_PIN_RS CONFIG_PANEL_LCD_PIN_RS
444 #ifdef CONFIG_PANEL_LCD_PIN_RW
445 #undef DEFAULT_LCD_PIN_RW
446 #define DEFAULT_LCD_PIN_RW CONFIG_PANEL_LCD_PIN_RW
449 #ifdef CONFIG_PANEL_LCD_PIN_SCL
450 #undef DEFAULT_LCD_PIN_SCL
451 #define DEFAULT_LCD_PIN_SCL CONFIG_PANEL_LCD_PIN_SCL
454 #ifdef CONFIG_PANEL_LCD_PIN_SDA
455 #undef DEFAULT_LCD_PIN_SDA
456 #define DEFAULT_LCD_PIN_SDA CONFIG_PANEL_LCD_PIN_SDA
459 #ifdef CONFIG_PANEL_LCD_PIN_BL
460 #undef DEFAULT_LCD_PIN_BL
461 #define DEFAULT_LCD_PIN_BL CONFIG_PANEL_LCD_PIN_BL
464 #endif /* DEFAULT_PROFILE == 0 */
466 /* global variables */
468 /* Device single-open policy control */
469 static atomic_t lcd_available = ATOMIC_INIT(1);
470 static atomic_t keypad_available = ATOMIC_INIT(1);
472 static struct pardevice *pprt;
474 static int keypad_initialized;
476 static void (*lcd_write_cmd)(int);
477 static void (*lcd_write_data)(int);
478 static void (*lcd_clear_fast)(void);
480 static DEFINE_SPINLOCK(pprt_lock);
481 static struct timer_list scan_timer;
483 MODULE_DESCRIPTION("Generic parallel port LCD/Keypad driver");
485 static int parport = DEFAULT_PARPORT;
486 module_param(parport, int, 0000);
487 MODULE_PARM_DESC(parport, "Parallel port index (0=lpt1, 1=lpt2, ...)");
489 static int profile = DEFAULT_PROFILE;
490 module_param(profile, int, 0000);
491 MODULE_PARM_DESC(profile,
492 "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; "
493 "4=16x2 nexcom; default=40x2, old kp");
495 static int keypad_type = NOT_SET;
496 module_param(keypad_type, int, 0000);
497 MODULE_PARM_DESC(keypad_type,
498 "Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, 3=nexcom 4 keys");
500 static int lcd_type = NOT_SET;
501 module_param(lcd_type, int, 0000);
502 MODULE_PARM_DESC(lcd_type,
503 "LCD type: 0=none, 1=compiled-in, 2=old, 3=serial ks0074, 4=hantronix, 5=nexcom");
505 static int lcd_height = NOT_SET;
506 module_param(lcd_height, int, 0000);
507 MODULE_PARM_DESC(lcd_height, "Number of lines on the LCD");
509 static int lcd_width = NOT_SET;
510 module_param(lcd_width, int, 0000);
511 MODULE_PARM_DESC(lcd_width, "Number of columns on the LCD");
513 static int lcd_bwidth = NOT_SET; /* internal buffer width (usually 40) */
514 module_param(lcd_bwidth, int, 0000);
515 MODULE_PARM_DESC(lcd_bwidth, "Internal LCD line width (40)");
517 static int lcd_hwidth = NOT_SET; /* hardware buffer width (usually 64) */
518 module_param(lcd_hwidth, int, 0000);
519 MODULE_PARM_DESC(lcd_hwidth, "LCD line hardware address (64)");
521 static int lcd_charset = NOT_SET;
522 module_param(lcd_charset, int, 0000);
523 MODULE_PARM_DESC(lcd_charset, "LCD character set: 0=standard, 1=KS0074");
525 static int lcd_proto = NOT_SET;
526 module_param(lcd_proto, int, 0000);
527 MODULE_PARM_DESC(lcd_proto,
528 "LCD communication: 0=parallel (//), 1=serial, 2=TI LCD Interface");
531 * These are the parallel port pins the LCD control signals are connected to.
532 * Set this to 0 if the signal is not used. Set it to its opposite value
533 * (negative) if the signal is negated. -MAXINT is used to indicate that the
534 * pin has not been explicitly specified.
536 * WARNING! no check will be performed about collisions with keypad !
539 static int lcd_e_pin = PIN_NOT_SET;
540 module_param(lcd_e_pin, int, 0000);
541 MODULE_PARM_DESC(lcd_e_pin,
542 "# of the // port pin connected to LCD 'E' signal, with polarity (-17..17)");
544 static int lcd_rs_pin = PIN_NOT_SET;
545 module_param(lcd_rs_pin, int, 0000);
546 MODULE_PARM_DESC(lcd_rs_pin,
547 "# of the // port pin connected to LCD 'RS' signal, with polarity (-17..17)");
549 static int lcd_rw_pin = PIN_NOT_SET;
550 module_param(lcd_rw_pin, int, 0000);
551 MODULE_PARM_DESC(lcd_rw_pin,
552 "# of the // port pin connected to LCD 'RW' signal, with polarity (-17..17)");
554 static int lcd_cl_pin = PIN_NOT_SET;
555 module_param(lcd_cl_pin, int, 0000);
556 MODULE_PARM_DESC(lcd_cl_pin,
557 "# of the // port pin connected to serial LCD 'SCL' signal, with polarity (-17..17)");
559 static int lcd_da_pin = PIN_NOT_SET;
560 module_param(lcd_da_pin, int, 0000);
561 MODULE_PARM_DESC(lcd_da_pin,
562 "# of the // port pin connected to serial LCD 'SDA' signal, with polarity (-17..17)");
564 static int lcd_bl_pin = PIN_NOT_SET;
565 module_param(lcd_bl_pin, int, 0000);
566 MODULE_PARM_DESC(lcd_bl_pin,
567 "# of the // port pin connected to LCD backlight, with polarity (-17..17)");
569 /* Deprecated module parameters - consider not using them anymore */
571 static int lcd_enabled = NOT_SET;
572 module_param(lcd_enabled, int, 0000);
573 MODULE_PARM_DESC(lcd_enabled, "Deprecated option, use lcd_type instead");
575 static int keypad_enabled = NOT_SET;
576 module_param(keypad_enabled, int, 0000);
577 MODULE_PARM_DESC(keypad_enabled, "Deprecated option, use keypad_type instead");
580 static const unsigned char *lcd_char_conv;
582 /* for some LCD drivers (ks0074) we need a charset conversion table. */
583 static const unsigned char lcd_char_conv_ks0074[256] = {
584 /* 0|8 1|9 2|A 3|B 4|C 5|D 6|E 7|F */
585 /* 0x00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
586 /* 0x08 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
587 /* 0x10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
588 /* 0x18 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
589 /* 0x20 */ 0x20, 0x21, 0x22, 0x23, 0xa2, 0x25, 0x26, 0x27,
590 /* 0x28 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
591 /* 0x30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
592 /* 0x38 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
593 /* 0x40 */ 0xa0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
594 /* 0x48 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
595 /* 0x50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
596 /* 0x58 */ 0x58, 0x59, 0x5a, 0xfa, 0xfb, 0xfc, 0x1d, 0xc4,
597 /* 0x60 */ 0x96, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
598 /* 0x68 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
599 /* 0x70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
600 /* 0x78 */ 0x78, 0x79, 0x7a, 0xfd, 0xfe, 0xff, 0xce, 0x20,
601 /* 0x80 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
602 /* 0x88 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
603 /* 0x90 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
604 /* 0x98 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
605 /* 0xA0 */ 0x20, 0x40, 0xb1, 0xa1, 0x24, 0xa3, 0xfe, 0x5f,
606 /* 0xA8 */ 0x22, 0xc8, 0x61, 0x14, 0x97, 0x2d, 0xad, 0x96,
607 /* 0xB0 */ 0x80, 0x8c, 0x82, 0x83, 0x27, 0x8f, 0x86, 0xdd,
608 /* 0xB8 */ 0x2c, 0x81, 0x6f, 0x15, 0x8b, 0x8a, 0x84, 0x60,
609 /* 0xC0 */ 0xe2, 0xe2, 0xe2, 0x5b, 0x5b, 0xae, 0xbc, 0xa9,
610 /* 0xC8 */ 0xc5, 0xbf, 0xc6, 0xf1, 0xe3, 0xe3, 0xe3, 0xe3,
611 /* 0xD0 */ 0x44, 0x5d, 0xa8, 0xe4, 0xec, 0xec, 0x5c, 0x78,
612 /* 0xD8 */ 0xab, 0xa6, 0xe5, 0x5e, 0x5e, 0xe6, 0xaa, 0xbe,
613 /* 0xE0 */ 0x7f, 0xe7, 0xaf, 0x7b, 0x7b, 0xaf, 0xbd, 0xc8,
614 /* 0xE8 */ 0xa4, 0xa5, 0xc7, 0xf6, 0xa7, 0xe8, 0x69, 0x69,
615 /* 0xF0 */ 0xed, 0x7d, 0xa8, 0xe4, 0xec, 0x5c, 0x5c, 0x25,
616 /* 0xF8 */ 0xac, 0xa6, 0xea, 0xef, 0x7e, 0xeb, 0xb2, 0x79,
619 static const char old_keypad_profile[][4][9] = {
620 {"S0", "Left\n", "Left\n", ""},
621 {"S1", "Down\n", "Down\n", ""},
622 {"S2", "Up\n", "Up\n", ""},
623 {"S3", "Right\n", "Right\n", ""},
624 {"S4", "Esc\n", "Esc\n", ""},
625 {"S5", "Ret\n", "Ret\n", ""},
629 /* signals, press, repeat, release */
630 static const char new_keypad_profile[][4][9] = {
631 {"S0", "Left\n", "Left\n", ""},
632 {"S1", "Down\n", "Down\n", ""},
633 {"S2", "Up\n", "Up\n", ""},
634 {"S3", "Right\n", "Right\n", ""},
635 {"S4s5", "", "Esc\n", "Esc\n"},
636 {"s4S5", "", "Ret\n", "Ret\n"},
637 {"S4S5", "Help\n", "", ""},
638 /* add new signals above this line */
642 /* signals, press, repeat, release */
643 static const char nexcom_keypad_profile[][4][9] = {
644 {"a-p-e-", "Down\n", "Down\n", ""},
645 {"a-p-E-", "Ret\n", "Ret\n", ""},
646 {"a-P-E-", "Esc\n", "Esc\n", ""},
647 {"a-P-e-", "Up\n", "Up\n", ""},
648 /* add new signals above this line */
652 static const char (*keypad_profile)[4][9] = old_keypad_profile;
654 /* FIXME: this should be converted to a bit array containing signals states */
656 unsigned char e; /* parallel LCD E (data latch on falling edge) */
657 unsigned char rs; /* parallel LCD RS (0 = cmd, 1 = data) */
658 unsigned char rw; /* parallel LCD R/W (0 = W, 1 = R) */
659 unsigned char bl; /* parallel LCD backlight (0 = off, 1 = on) */
660 unsigned char cl; /* serial LCD clock (latch on rising edge) */
661 unsigned char da; /* serial LCD data */
664 static void init_scan_timer(void);
666 /* sets data port bits according to current signals values */
667 static int set_data_bits(void)
672 for (bit = 0; bit < LCD_BITS; bit++)
673 val &= lcd_bits[LCD_PORT_D][bit][BIT_MSK];
675 val |= lcd_bits[LCD_PORT_D][LCD_BIT_E][bits.e]
676 | lcd_bits[LCD_PORT_D][LCD_BIT_RS][bits.rs]
677 | lcd_bits[LCD_PORT_D][LCD_BIT_RW][bits.rw]
678 | lcd_bits[LCD_PORT_D][LCD_BIT_BL][bits.bl]
679 | lcd_bits[LCD_PORT_D][LCD_BIT_CL][bits.cl]
680 | lcd_bits[LCD_PORT_D][LCD_BIT_DA][bits.da];
686 /* sets ctrl port bits according to current signals values */
687 static int set_ctrl_bits(void)
692 for (bit = 0; bit < LCD_BITS; bit++)
693 val &= lcd_bits[LCD_PORT_C][bit][BIT_MSK];
695 val |= lcd_bits[LCD_PORT_C][LCD_BIT_E][bits.e]
696 | lcd_bits[LCD_PORT_C][LCD_BIT_RS][bits.rs]
697 | lcd_bits[LCD_PORT_C][LCD_BIT_RW][bits.rw]
698 | lcd_bits[LCD_PORT_C][LCD_BIT_BL][bits.bl]
699 | lcd_bits[LCD_PORT_C][LCD_BIT_CL][bits.cl]
700 | lcd_bits[LCD_PORT_C][LCD_BIT_DA][bits.da];
706 /* sets ctrl & data port bits according to current signals values */
707 static void panel_set_bits(void)
714 * Converts a parallel port pin (from -25 to 25) to data and control ports
715 * masks, and data and control port bits. The signal will be considered
716 * unconnected if it's on pin 0 or an invalid pin (<-25 or >25).
718 * Result will be used this way :
719 * out(dport, in(dport) & d_val[2] | d_val[signal_state])
720 * out(cport, in(cport) & c_val[2] | c_val[signal_state])
722 static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val)
724 int d_bit, c_bit, inv;
744 case PIN_STROBE: /* strobe, inverted */
748 case PIN_D0...PIN_D7: /* D0 - D7 = 2 - 9 */
749 d_bit = 1 << (pin - 2);
751 case PIN_AUTOLF: /* autofeed, inverted */
755 case PIN_INITP: /* init, direct */
758 case PIN_SELECP: /* select_in, inverted */
762 default: /* unknown pin, ignore */
775 /* sleeps that many milliseconds with a reschedule */
776 static void long_sleep(int ms)
781 schedule_timeout_interruptible(msecs_to_jiffies(ms));
785 * send a serial byte to the LCD panel. The caller is responsible for locking
788 static void lcd_send_serial(int byte)
793 * the data bit is set on D0, and the clock on STROBE.
794 * LCD reads D0 on STROBE's rising edge.
796 for (bit = 0; bit < 8; bit++) {
797 bits.cl = BIT_CLR; /* CLK low */
801 udelay(2); /* maintain the data during 2 us before CLK up */
802 bits.cl = BIT_SET; /* CLK high */
804 udelay(1); /* maintain the strobe during 1 us */
809 /* turn the backlight on or off */
810 static void lcd_backlight(int on)
812 if (lcd.pins.bl == PIN_NONE)
815 /* The backlight is activated by setting the AUTOFEED line to +5V */
816 spin_lock_irq(&pprt_lock);
819 spin_unlock_irq(&pprt_lock);
822 /* send a command to the LCD panel in serial mode */
823 static void lcd_write_cmd_s(int cmd)
825 spin_lock_irq(&pprt_lock);
826 lcd_send_serial(0x1F); /* R/W=W, RS=0 */
827 lcd_send_serial(cmd & 0x0F);
828 lcd_send_serial((cmd >> 4) & 0x0F);
829 udelay(40); /* the shortest command takes at least 40 us */
830 spin_unlock_irq(&pprt_lock);
833 /* send data to the LCD panel in serial mode */
834 static void lcd_write_data_s(int data)
836 spin_lock_irq(&pprt_lock);
837 lcd_send_serial(0x5F); /* R/W=W, RS=1 */
838 lcd_send_serial(data & 0x0F);
839 lcd_send_serial((data >> 4) & 0x0F);
840 udelay(40); /* the shortest data takes at least 40 us */
841 spin_unlock_irq(&pprt_lock);
844 /* send a command to the LCD panel in 8 bits parallel mode */
845 static void lcd_write_cmd_p8(int cmd)
847 spin_lock_irq(&pprt_lock);
848 /* present the data to the data port */
850 udelay(20); /* maintain the data during 20 us before the strobe */
857 udelay(40); /* maintain the strobe during 40 us */
862 udelay(120); /* the shortest command takes at least 120 us */
863 spin_unlock_irq(&pprt_lock);
866 /* send data to the LCD panel in 8 bits parallel mode */
867 static void lcd_write_data_p8(int data)
869 spin_lock_irq(&pprt_lock);
870 /* present the data to the data port */
872 udelay(20); /* maintain the data during 20 us before the strobe */
879 udelay(40); /* maintain the strobe during 40 us */
884 udelay(45); /* the shortest data takes at least 45 us */
885 spin_unlock_irq(&pprt_lock);
888 /* send a command to the TI LCD panel */
889 static void lcd_write_cmd_tilcd(int cmd)
891 spin_lock_irq(&pprt_lock);
892 /* present the data to the control port */
895 spin_unlock_irq(&pprt_lock);
898 /* send data to the TI LCD panel */
899 static void lcd_write_data_tilcd(int data)
901 spin_lock_irq(&pprt_lock);
902 /* present the data to the data port */
905 spin_unlock_irq(&pprt_lock);
908 static void lcd_gotoxy(void)
910 lcd_write_cmd(LCD_CMD_SET_DDRAM_ADDR
911 | (lcd.addr.y ? lcd.hwidth : 0)
912 /* we force the cursor to stay at the end of the
913 line if it wants to go farther */
914 | ((lcd.addr.x < lcd.bwidth) ? lcd.addr.x &
915 (lcd.hwidth - 1) : lcd.bwidth - 1));
918 static void lcd_print(char c)
920 if (lcd.addr.x < lcd.bwidth) {
921 if (lcd_char_conv != NULL)
922 c = lcd_char_conv[(unsigned char)c];
926 /* prevents the cursor from wrapping onto the next line */
927 if (lcd.addr.x == lcd.bwidth)
931 /* fills the display with spaces and resets X/Y */
932 static void lcd_clear_fast_s(void)
940 spin_lock_irq(&pprt_lock);
941 for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) {
942 lcd_send_serial(0x5F); /* R/W=W, RS=1 */
943 lcd_send_serial(' ' & 0x0F);
944 lcd_send_serial((' ' >> 4) & 0x0F);
945 udelay(40); /* the shortest data takes at least 40 us */
947 spin_unlock_irq(&pprt_lock);
954 /* fills the display with spaces and resets X/Y */
955 static void lcd_clear_fast_p8(void)
963 spin_lock_irq(&pprt_lock);
964 for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) {
965 /* present the data to the data port */
968 /* maintain the data during 20 us before the strobe */
976 /* maintain the strobe during 40 us */
982 /* the shortest data takes at least 45 us */
985 spin_unlock_irq(&pprt_lock);
992 /* fills the display with spaces and resets X/Y */
993 static void lcd_clear_fast_tilcd(void)
1001 spin_lock_irq(&pprt_lock);
1002 for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) {
1003 /* present the data to the data port */
1008 spin_unlock_irq(&pprt_lock);
1015 /* clears the display and resets X/Y */
1016 static void lcd_clear_display(void)
1018 lcd_write_cmd(LCD_CMD_DISPLAY_CLEAR);
1021 /* we must wait a few milliseconds (15) */
1025 static void lcd_init_display(void)
1027 lcd.flags = ((lcd.height > 1) ? LCD_FLAG_N : 0)
1028 | LCD_FLAG_D | LCD_FLAG_C | LCD_FLAG_B;
1030 long_sleep(20); /* wait 20 ms after power-up for the paranoid */
1032 /* 8bits, 1 line, small fonts; let's do it 3 times */
1033 lcd_write_cmd(LCD_CMD_FUNCTION_SET | LCD_CMD_DATA_LEN_8BITS);
1035 lcd_write_cmd(LCD_CMD_FUNCTION_SET | LCD_CMD_DATA_LEN_8BITS);
1037 lcd_write_cmd(LCD_CMD_FUNCTION_SET | LCD_CMD_DATA_LEN_8BITS);
1040 /* set font height and lines number */
1041 lcd_write_cmd(LCD_CMD_FUNCTION_SET | LCD_CMD_DATA_LEN_8BITS
1042 | ((lcd.flags & LCD_FLAG_F) ? LCD_CMD_FONT_5X10_DOTS : 0)
1043 | ((lcd.flags & LCD_FLAG_N) ? LCD_CMD_TWO_LINES : 0)
1047 /* display off, cursor off, blink off */
1048 lcd_write_cmd(LCD_CMD_DISPLAY_CTRL);
1051 lcd_write_cmd(LCD_CMD_DISPLAY_CTRL /* set display mode */
1052 | ((lcd.flags & LCD_FLAG_D) ? LCD_CMD_DISPLAY_ON : 0)
1053 | ((lcd.flags & LCD_FLAG_C) ? LCD_CMD_CURSOR_ON : 0)
1054 | ((lcd.flags & LCD_FLAG_B) ? LCD_CMD_BLINK_ON : 0)
1057 lcd_backlight((lcd.flags & LCD_FLAG_L) ? 1 : 0);
1061 /* entry mode set : increment, cursor shifting */
1062 lcd_write_cmd(LCD_CMD_ENTRY_MODE | LCD_CMD_CURSOR_INC);
1064 lcd_clear_display();
1068 * These are the file operation function for user access to /dev/lcd
1069 * This function can also be called from inside the kernel, by
1070 * setting file and ppos to NULL.
1074 static inline int handle_lcd_special_code(void)
1076 /* LCD special codes */
1080 char *esc = lcd.esc_seq.buf + 2;
1081 int oldflags = lcd.flags;
1083 /* check for display mode flags */
1085 case 'D': /* Display ON */
1086 lcd.flags |= LCD_FLAG_D;
1089 case 'd': /* Display OFF */
1090 lcd.flags &= ~LCD_FLAG_D;
1093 case 'C': /* Cursor ON */
1094 lcd.flags |= LCD_FLAG_C;
1097 case 'c': /* Cursor OFF */
1098 lcd.flags &= ~LCD_FLAG_C;
1101 case 'B': /* Blink ON */
1102 lcd.flags |= LCD_FLAG_B;
1105 case 'b': /* Blink OFF */
1106 lcd.flags &= ~LCD_FLAG_B;
1109 case '+': /* Back light ON */
1110 lcd.flags |= LCD_FLAG_L;
1113 case '-': /* Back light OFF */
1114 lcd.flags &= ~LCD_FLAG_L;
1118 /* flash back light using the keypad timer */
1119 if (scan_timer.function != NULL) {
1120 if (lcd.light_tempo == 0
1121 && ((lcd.flags & LCD_FLAG_L) == 0))
1123 lcd.light_tempo = FLASH_LIGHT_TEMPO;
1127 case 'f': /* Small Font */
1128 lcd.flags &= ~LCD_FLAG_F;
1131 case 'F': /* Large Font */
1132 lcd.flags |= LCD_FLAG_F;
1135 case 'n': /* One Line */
1136 lcd.flags &= ~LCD_FLAG_N;
1139 case 'N': /* Two Lines */
1140 lcd.flags |= LCD_FLAG_N;
1142 case 'l': /* Shift Cursor Left */
1143 if (lcd.addr.x > 0) {
1144 /* back one char if not at end of line */
1145 if (lcd.addr.x < lcd.bwidth)
1146 lcd_write_cmd(LCD_CMD_SHIFT);
1151 case 'r': /* shift cursor right */
1152 if (lcd.addr.x < lcd.width) {
1153 /* allow the cursor to pass the end of the line */
1154 if (lcd.addr.x < (lcd.bwidth - 1))
1155 lcd_write_cmd(LCD_CMD_SHIFT |
1156 LCD_CMD_SHIFT_RIGHT);
1161 case 'L': /* shift display left */
1162 lcd_write_cmd(LCD_CMD_SHIFT | LCD_CMD_DISPLAY_SHIFT);
1165 case 'R': /* shift display right */
1166 lcd_write_cmd(LCD_CMD_SHIFT | LCD_CMD_DISPLAY_SHIFT |
1167 LCD_CMD_SHIFT_RIGHT);
1170 case 'k': { /* kill end of line */
1173 for (x = lcd.addr.x; x < lcd.bwidth; x++)
1174 lcd_write_data(' ');
1176 /* restore cursor position */
1181 case 'I': /* reinitialize display */
1186 /* Generator : LGcxxxxx...xx; must have <c> between '0'
1187 * and '7', representing the numerical ASCII code of the
1188 * redefined character, and <xx...xx> a sequence of 16
1189 * hex digits representing 8 bytes for each character.
1190 * Most LCDs will only use 5 lower bits of the 7 first
1194 unsigned char cgbytes[8];
1195 unsigned char cgaddr;
1201 if (strchr(esc, ';') == NULL)
1206 cgaddr = *(esc++) - '0';
1215 while (*esc && cgoffset < 8) {
1217 if (*esc >= '0' && *esc <= '9') {
1218 value |= (*esc - '0') << shift;
1219 } else if (*esc >= 'A' && *esc <= 'Z') {
1220 value |= (*esc - 'A' + 10) << shift;
1221 } else if (*esc >= 'a' && *esc <= 'z') {
1222 value |= (*esc - 'a' + 10) << shift;
1229 cgbytes[cgoffset++] = value;
1236 lcd_write_cmd(LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8));
1237 for (addr = 0; addr < cgoffset; addr++)
1238 lcd_write_data(cgbytes[addr]);
1240 /* ensures that we stop writing to CGRAM */
1245 case 'x': /* gotoxy : LxXXX[yYYY]; */
1246 case 'y': /* gotoxy : LyYYY[xXXX]; */
1247 if (strchr(esc, ';') == NULL)
1253 if (kstrtoul(esc, 10, &lcd.addr.x) < 0)
1255 } else if (*esc == 'y') {
1257 if (kstrtoul(esc, 10, &lcd.addr.y) < 0)
1269 /* TODO: This indent party here got ugly, clean it! */
1270 /* Check whether one flag was changed */
1271 if (oldflags != lcd.flags) {
1272 /* check whether one of B,C,D flags were changed */
1273 if ((oldflags ^ lcd.flags) &
1274 (LCD_FLAG_B | LCD_FLAG_C | LCD_FLAG_D))
1275 /* set display mode */
1276 lcd_write_cmd(LCD_CMD_DISPLAY_CTRL
1277 | ((lcd.flags & LCD_FLAG_D)
1278 ? LCD_CMD_DISPLAY_ON : 0)
1279 | ((lcd.flags & LCD_FLAG_C)
1280 ? LCD_CMD_CURSOR_ON : 0)
1281 | ((lcd.flags & LCD_FLAG_B)
1282 ? LCD_CMD_BLINK_ON : 0));
1283 /* check whether one of F,N flags was changed */
1284 else if ((oldflags ^ lcd.flags) & (LCD_FLAG_F | LCD_FLAG_N))
1285 lcd_write_cmd(LCD_CMD_FUNCTION_SET
1286 | LCD_CMD_DATA_LEN_8BITS
1287 | ((lcd.flags & LCD_FLAG_F)
1288 ? LCD_CMD_TWO_LINES : 0)
1289 | ((lcd.flags & LCD_FLAG_N)
1290 ? LCD_CMD_FONT_5X10_DOTS
1292 /* check whether L flag was changed */
1293 else if ((oldflags ^ lcd.flags) & (LCD_FLAG_L)) {
1294 if (lcd.flags & (LCD_FLAG_L))
1296 else if (lcd.light_tempo == 0)
1297 /* switch off the light only when the tempo
1306 static void lcd_write_char(char c)
1308 /* first, we'll test if we're in escape mode */
1309 if ((c != '\n') && lcd.esc_seq.len >= 0) {
1310 /* yes, let's add this char to the buffer */
1311 lcd.esc_seq.buf[lcd.esc_seq.len++] = c;
1312 lcd.esc_seq.buf[lcd.esc_seq.len] = 0;
1314 /* aborts any previous escape sequence */
1315 lcd.esc_seq.len = -1;
1318 case LCD_ESCAPE_CHAR:
1319 /* start of an escape sequence */
1320 lcd.esc_seq.len = 0;
1321 lcd.esc_seq.buf[lcd.esc_seq.len] = 0;
1324 /* go back one char and clear it */
1325 if (lcd.addr.x > 0) {
1326 /* check if we're not at the
1328 if (lcd.addr.x < lcd.bwidth)
1330 lcd_write_cmd(LCD_CMD_SHIFT);
1333 /* replace with a space */
1334 lcd_write_data(' ');
1335 /* back one char again */
1336 lcd_write_cmd(LCD_CMD_SHIFT);
1339 /* quickly clear the display */
1343 /* flush the remainder of the current line and
1344 go to the beginning of the next line */
1345 for (; lcd.addr.x < lcd.bwidth; lcd.addr.x++)
1346 lcd_write_data(' ');
1348 lcd.addr.y = (lcd.addr.y + 1) % lcd.height;
1352 /* go to the beginning of the same line */
1357 /* print a space instead of the tab */
1361 /* simply print this char */
1367 /* now we'll see if we're in an escape mode and if the current
1368 escape sequence can be understood. */
1369 if (lcd.esc_seq.len >= 2) {
1372 if (!strcmp(lcd.esc_seq.buf, "[2J")) {
1373 /* clear the display */
1376 } else if (!strcmp(lcd.esc_seq.buf, "[H")) {
1377 /* cursor to home */
1383 /* codes starting with ^[[L */
1384 else if ((lcd.esc_seq.len >= 3) &&
1385 (lcd.esc_seq.buf[0] == '[') &&
1386 (lcd.esc_seq.buf[1] == 'L')) {
1387 processed = handle_lcd_special_code();
1390 /* LCD special escape codes */
1391 /* flush the escape sequence if it's been processed
1392 or if it is getting too long. */
1393 if (processed || (lcd.esc_seq.len >= LCD_ESCAPE_LEN))
1394 lcd.esc_seq.len = -1;
1395 } /* escape codes */
1398 static ssize_t lcd_write(struct file *file,
1399 const char __user *buf, size_t count, loff_t *ppos)
1401 const char __user *tmp = buf;
1404 for (; count-- > 0; (*ppos)++, tmp++) {
1405 if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
1406 /* let's be a little nice with other processes
1407 that need some CPU */
1410 if (get_user(c, tmp))
1419 static int lcd_open(struct inode *inode, struct file *file)
1421 if (!atomic_dec_and_test(&lcd_available))
1422 return -EBUSY; /* open only once at a time */
1424 if (file->f_mode & FMODE_READ) /* device is write-only */
1427 if (lcd.must_clear) {
1428 lcd_clear_display();
1429 lcd.must_clear = false;
1431 return nonseekable_open(inode, file);
1434 static int lcd_release(struct inode *inode, struct file *file)
1436 atomic_inc(&lcd_available);
1440 static const struct file_operations lcd_fops = {
1443 .release = lcd_release,
1444 .llseek = no_llseek,
1447 static struct miscdevice lcd_dev = {
1453 /* public function usable from the kernel for any purpose */
1454 static void panel_lcd_print(const char *s)
1456 const char *tmp = s;
1457 int count = strlen(s);
1459 if (lcd.enabled && lcd.initialized) {
1460 for (; count-- > 0; tmp++) {
1461 if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
1462 /* let's be a little nice with other processes
1463 that need some CPU */
1466 lcd_write_char(*tmp);
1471 /* initialize the LCD driver */
1472 static void lcd_init(void)
1474 switch (selected_lcd_type) {
1476 /* parallel mode, 8 bits */
1477 lcd.proto = LCD_PROTO_PARALLEL;
1478 lcd.charset = LCD_CHARSET_NORMAL;
1479 lcd.pins.e = PIN_STROBE;
1480 lcd.pins.rs = PIN_AUTOLF;
1487 case LCD_TYPE_KS0074:
1488 /* serial mode, ks0074 */
1489 lcd.proto = LCD_PROTO_SERIAL;
1490 lcd.charset = LCD_CHARSET_KS0074;
1491 lcd.pins.bl = PIN_AUTOLF;
1492 lcd.pins.cl = PIN_STROBE;
1493 lcd.pins.da = PIN_D0;
1500 case LCD_TYPE_NEXCOM:
1501 /* parallel mode, 8 bits, generic */
1502 lcd.proto = LCD_PROTO_PARALLEL;
1503 lcd.charset = LCD_CHARSET_NORMAL;
1504 lcd.pins.e = PIN_AUTOLF;
1505 lcd.pins.rs = PIN_SELECP;
1506 lcd.pins.rw = PIN_INITP;
1513 case LCD_TYPE_CUSTOM:
1514 /* customer-defined */
1515 lcd.proto = DEFAULT_LCD_PROTO;
1516 lcd.charset = DEFAULT_LCD_CHARSET;
1517 /* default geometry will be set later */
1519 case LCD_TYPE_HANTRONIX:
1520 /* parallel mode, 8 bits, hantronix-like */
1522 lcd.proto = LCD_PROTO_PARALLEL;
1523 lcd.charset = LCD_CHARSET_NORMAL;
1524 lcd.pins.e = PIN_STROBE;
1525 lcd.pins.rs = PIN_SELECP;
1534 /* Overwrite with module params set on loading */
1535 if (lcd_height != NOT_SET)
1536 lcd.height = lcd_height;
1537 if (lcd_width != NOT_SET)
1538 lcd.width = lcd_width;
1539 if (lcd_bwidth != NOT_SET)
1540 lcd.bwidth = lcd_bwidth;
1541 if (lcd_hwidth != NOT_SET)
1542 lcd.hwidth = lcd_hwidth;
1543 if (lcd_charset != NOT_SET)
1544 lcd.charset = lcd_charset;
1545 if (lcd_proto != NOT_SET)
1546 lcd.proto = lcd_proto;
1547 if (lcd_e_pin != PIN_NOT_SET)
1548 lcd.pins.e = lcd_e_pin;
1549 if (lcd_rs_pin != PIN_NOT_SET)
1550 lcd.pins.rs = lcd_rs_pin;
1551 if (lcd_rw_pin != PIN_NOT_SET)
1552 lcd.pins.rw = lcd_rw_pin;
1553 if (lcd_cl_pin != PIN_NOT_SET)
1554 lcd.pins.cl = lcd_cl_pin;
1555 if (lcd_da_pin != PIN_NOT_SET)
1556 lcd.pins.da = lcd_da_pin;
1557 if (lcd_bl_pin != PIN_NOT_SET)
1558 lcd.pins.bl = lcd_bl_pin;
1560 /* this is used to catch wrong and default values */
1562 lcd.width = DEFAULT_LCD_WIDTH;
1563 if (lcd.bwidth <= 0)
1564 lcd.bwidth = DEFAULT_LCD_BWIDTH;
1565 if (lcd.hwidth <= 0)
1566 lcd.hwidth = DEFAULT_LCD_HWIDTH;
1567 if (lcd.height <= 0)
1568 lcd.height = DEFAULT_LCD_HEIGHT;
1570 if (lcd.proto == LCD_PROTO_SERIAL) { /* SERIAL */
1571 lcd_write_cmd = lcd_write_cmd_s;
1572 lcd_write_data = lcd_write_data_s;
1573 lcd_clear_fast = lcd_clear_fast_s;
1575 if (lcd.pins.cl == PIN_NOT_SET)
1576 lcd.pins.cl = DEFAULT_LCD_PIN_SCL;
1577 if (lcd.pins.da == PIN_NOT_SET)
1578 lcd.pins.da = DEFAULT_LCD_PIN_SDA;
1580 } else if (lcd.proto == LCD_PROTO_PARALLEL) { /* PARALLEL */
1581 lcd_write_cmd = lcd_write_cmd_p8;
1582 lcd_write_data = lcd_write_data_p8;
1583 lcd_clear_fast = lcd_clear_fast_p8;
1585 if (lcd.pins.e == PIN_NOT_SET)
1586 lcd.pins.e = DEFAULT_LCD_PIN_E;
1587 if (lcd.pins.rs == PIN_NOT_SET)
1588 lcd.pins.rs = DEFAULT_LCD_PIN_RS;
1589 if (lcd.pins.rw == PIN_NOT_SET)
1590 lcd.pins.rw = DEFAULT_LCD_PIN_RW;
1592 lcd_write_cmd = lcd_write_cmd_tilcd;
1593 lcd_write_data = lcd_write_data_tilcd;
1594 lcd_clear_fast = lcd_clear_fast_tilcd;
1597 if (lcd.pins.bl == PIN_NOT_SET)
1598 lcd.pins.bl = DEFAULT_LCD_PIN_BL;
1600 if (lcd.pins.e == PIN_NOT_SET)
1601 lcd.pins.e = PIN_NONE;
1602 if (lcd.pins.rs == PIN_NOT_SET)
1603 lcd.pins.rs = PIN_NONE;
1604 if (lcd.pins.rw == PIN_NOT_SET)
1605 lcd.pins.rw = PIN_NONE;
1606 if (lcd.pins.bl == PIN_NOT_SET)
1607 lcd.pins.bl = PIN_NONE;
1608 if (lcd.pins.cl == PIN_NOT_SET)
1609 lcd.pins.cl = PIN_NONE;
1610 if (lcd.pins.da == PIN_NOT_SET)
1611 lcd.pins.da = PIN_NONE;
1613 if (lcd.charset == NOT_SET)
1614 lcd.charset = DEFAULT_LCD_CHARSET;
1616 if (lcd.charset == LCD_CHARSET_KS0074)
1617 lcd_char_conv = lcd_char_conv_ks0074;
1619 lcd_char_conv = NULL;
1621 if (lcd.pins.bl != PIN_NONE)
1624 pin_to_bits(lcd.pins.e, lcd_bits[LCD_PORT_D][LCD_BIT_E],
1625 lcd_bits[LCD_PORT_C][LCD_BIT_E]);
1626 pin_to_bits(lcd.pins.rs, lcd_bits[LCD_PORT_D][LCD_BIT_RS],
1627 lcd_bits[LCD_PORT_C][LCD_BIT_RS]);
1628 pin_to_bits(lcd.pins.rw, lcd_bits[LCD_PORT_D][LCD_BIT_RW],
1629 lcd_bits[LCD_PORT_C][LCD_BIT_RW]);
1630 pin_to_bits(lcd.pins.bl, lcd_bits[LCD_PORT_D][LCD_BIT_BL],
1631 lcd_bits[LCD_PORT_C][LCD_BIT_BL]);
1632 pin_to_bits(lcd.pins.cl, lcd_bits[LCD_PORT_D][LCD_BIT_CL],
1633 lcd_bits[LCD_PORT_C][LCD_BIT_CL]);
1634 pin_to_bits(lcd.pins.da, lcd_bits[LCD_PORT_D][LCD_BIT_DA],
1635 lcd_bits[LCD_PORT_C][LCD_BIT_DA]);
1637 /* before this line, we must NOT send anything to the display.
1638 * Since lcd_init_display() needs to write data, we have to
1639 * enable mark the LCD initialized just before. */
1640 lcd.initialized = true;
1643 /* display a short message */
1644 #ifdef CONFIG_PANEL_CHANGE_MESSAGE
1645 #ifdef CONFIG_PANEL_BOOT_MESSAGE
1646 panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*" CONFIG_PANEL_BOOT_MESSAGE);
1649 panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*Linux-" UTS_RELEASE "\nPanel-"
1654 /* clear the display on the next device opening */
1655 lcd.must_clear = true;
1660 * These are the file operation function for user access to /dev/keypad
1663 static ssize_t keypad_read(struct file *file,
1664 char __user *buf, size_t count, loff_t *ppos)
1667 char __user *tmp = buf;
1669 if (keypad_buflen == 0) {
1670 if (file->f_flags & O_NONBLOCK)
1673 if (wait_event_interruptible(keypad_read_wait,
1674 keypad_buflen != 0))
1678 for (; count-- > 0 && (keypad_buflen > 0);
1679 ++i, ++tmp, --keypad_buflen) {
1680 put_user(keypad_buffer[keypad_start], tmp);
1681 keypad_start = (keypad_start + 1) % KEYPAD_BUFFER;
1688 static int keypad_open(struct inode *inode, struct file *file)
1690 if (!atomic_dec_and_test(&keypad_available))
1691 return -EBUSY; /* open only once at a time */
1693 if (file->f_mode & FMODE_WRITE) /* device is read-only */
1696 keypad_buflen = 0; /* flush the buffer on opening */
1700 static int keypad_release(struct inode *inode, struct file *file)
1702 atomic_inc(&keypad_available);
1706 static const struct file_operations keypad_fops = {
1707 .read = keypad_read, /* read */
1708 .open = keypad_open, /* open */
1709 .release = keypad_release, /* close */
1710 .llseek = default_llseek,
1713 static struct miscdevice keypad_dev = {
1714 .minor = KEYPAD_MINOR,
1716 .fops = &keypad_fops,
1719 static void keypad_send_key(const char *string, int max_len)
1721 /* send the key to the device only if a process is attached to it. */
1722 if (!atomic_read(&keypad_available)) {
1723 while (max_len-- && keypad_buflen < KEYPAD_BUFFER && *string) {
1724 keypad_buffer[(keypad_start + keypad_buflen++) %
1725 KEYPAD_BUFFER] = *string++;
1727 wake_up_interruptible(&keypad_read_wait);
1731 /* this function scans all the bits involving at least one logical signal,
1732 * and puts the results in the bitfield "phys_read" (one bit per established
1733 * contact), and sets "phys_read_prev" to "phys_read".
1735 * Note: to debounce input signals, we will only consider as switched a signal
1736 * which is stable across 2 measures. Signals which are different between two
1737 * reads will be kept as they previously were in their logical form (phys_prev).
1738 * A signal which has just switched will have a 1 in
1739 * (phys_read ^ phys_read_prev).
1741 static void phys_scan_contacts(void)
1748 phys_prev = phys_curr;
1749 phys_read_prev = phys_read;
1750 phys_read = 0; /* flush all signals */
1752 /* keep track of old value, with all outputs disabled */
1753 oldval = r_dtr(pprt) | scan_mask_o;
1754 /* activate all keyboard outputs (active low) */
1755 w_dtr(pprt, oldval & ~scan_mask_o);
1757 /* will have a 1 for each bit set to gnd */
1758 bitmask = PNL_PINPUT(r_str(pprt)) & scan_mask_i;
1759 /* disable all matrix signals */
1760 w_dtr(pprt, oldval);
1762 /* now that all outputs are cleared, the only active input bits are
1763 * directly connected to the ground
1766 /* 1 for each grounded input */
1767 gndmask = PNL_PINPUT(r_str(pprt)) & scan_mask_i;
1769 /* grounded inputs are signals 40-44 */
1770 phys_read |= (pmask_t) gndmask << 40;
1772 if (bitmask != gndmask) {
1773 /* since clearing the outputs changed some inputs, we know
1774 * that some input signals are currently tied to some outputs.
1775 * So we'll scan them.
1777 for (bit = 0; bit < 8; bit++) {
1780 if (!(scan_mask_o & bitval)) /* skip unused bits */
1783 w_dtr(pprt, oldval & ~bitval); /* enable this output */
1784 bitmask = PNL_PINPUT(r_str(pprt)) & ~gndmask;
1785 phys_read |= (pmask_t) bitmask << (5 * bit);
1787 w_dtr(pprt, oldval); /* disable all outputs */
1789 /* this is easy: use old bits when they are flapping,
1790 * use new ones when stable */
1791 phys_curr = (phys_prev & (phys_read ^ phys_read_prev)) |
1792 (phys_read & ~(phys_read ^ phys_read_prev));
1795 static inline int input_state_high(struct logical_input *input)
1799 * this is an invalid test. It tries to catch
1800 * transitions from single-key to multiple-key, but
1801 * doesn't take into account the contacts polarity.
1802 * The only solution to the problem is to parse keys
1803 * from the most complex to the simplest combinations,
1804 * and mark them as 'caught' once a combination
1805 * matches, then unmatch it for all other ones.
1808 /* try to catch dangerous transitions cases :
1809 * someone adds a bit, so this signal was a false
1810 * positive resulting from a transition. We should
1811 * invalidate the signal immediately and not call the
1813 * eg: 0 -(press A)-> A -(press B)-> AB : don't match A's release.
1815 if (((phys_prev & input->mask) == input->value) &&
1816 ((phys_curr & input->mask) > input->value)) {
1817 input->state = INPUT_ST_LOW; /* invalidate */
1822 if ((phys_curr & input->mask) == input->value) {
1823 if ((input->type == INPUT_TYPE_STD) &&
1824 (input->high_timer == 0)) {
1825 input->high_timer++;
1826 if (input->u.std.press_fct != NULL)
1827 input->u.std.press_fct(input->u.std.press_data);
1828 } else if (input->type == INPUT_TYPE_KBD) {
1829 /* will turn on the light */
1832 if (input->high_timer == 0) {
1833 char *press_str = input->u.kbd.press_str;
1836 int s = sizeof(input->u.kbd.press_str);
1838 keypad_send_key(press_str, s);
1842 if (input->u.kbd.repeat_str[0]) {
1843 char *repeat_str = input->u.kbd.repeat_str;
1845 if (input->high_timer >= KEYPAD_REP_START) {
1846 int s = sizeof(input->u.kbd.repeat_str);
1848 input->high_timer -= KEYPAD_REP_DELAY;
1849 keypad_send_key(repeat_str, s);
1851 /* we will need to come back here soon */
1855 if (input->high_timer < 255)
1856 input->high_timer++;
1861 /* else signal falling down. Let's fall through. */
1862 input->state = INPUT_ST_FALLING;
1863 input->fall_timer = 0;
1868 static inline void input_state_falling(struct logical_input *input)
1871 /* FIXME !!! same comment as in input_state_high */
1872 if (((phys_prev & input->mask) == input->value) &&
1873 ((phys_curr & input->mask) > input->value)) {
1874 input->state = INPUT_ST_LOW; /* invalidate */
1879 if ((phys_curr & input->mask) == input->value) {
1880 if (input->type == INPUT_TYPE_KBD) {
1881 /* will turn on the light */
1884 if (input->u.kbd.repeat_str[0]) {
1885 char *repeat_str = input->u.kbd.repeat_str;
1887 if (input->high_timer >= KEYPAD_REP_START) {
1888 int s = sizeof(input->u.kbd.repeat_str);
1890 input->high_timer -= KEYPAD_REP_DELAY;
1891 keypad_send_key(repeat_str, s);
1893 /* we will need to come back here soon */
1897 if (input->high_timer < 255)
1898 input->high_timer++;
1900 input->state = INPUT_ST_HIGH;
1901 } else if (input->fall_timer >= input->fall_time) {
1902 /* call release event */
1903 if (input->type == INPUT_TYPE_STD) {
1904 void (*release_fct)(int) = input->u.std.release_fct;
1906 if (release_fct != NULL)
1907 release_fct(input->u.std.release_data);
1908 } else if (input->type == INPUT_TYPE_KBD) {
1909 char *release_str = input->u.kbd.release_str;
1911 if (release_str[0]) {
1912 int s = sizeof(input->u.kbd.release_str);
1914 keypad_send_key(release_str, s);
1918 input->state = INPUT_ST_LOW;
1920 input->fall_timer++;
1925 static void panel_process_inputs(void)
1927 struct list_head *item;
1928 struct logical_input *input;
1932 list_for_each(item, &logical_inputs) {
1933 input = list_entry(item, struct logical_input, list);
1935 switch (input->state) {
1937 if ((phys_curr & input->mask) != input->value)
1939 /* if all needed ones were already set previously,
1940 * this means that this logical signal has been
1941 * activated by the releasing of another combined
1942 * signal, so we don't want to match.
1943 * eg: AB -(release B)-> A -(release A)-> 0 :
1946 if ((phys_prev & input->mask) == input->value)
1948 input->rise_timer = 0;
1949 input->state = INPUT_ST_RISING;
1950 /* no break here, fall through */
1951 case INPUT_ST_RISING:
1952 if ((phys_curr & input->mask) != input->value) {
1953 input->state = INPUT_ST_LOW;
1956 if (input->rise_timer < input->rise_time) {
1958 input->rise_timer++;
1961 input->high_timer = 0;
1962 input->state = INPUT_ST_HIGH;
1963 /* no break here, fall through */
1965 if (input_state_high(input))
1967 /* no break here, fall through */
1968 case INPUT_ST_FALLING:
1969 input_state_falling(input);
1974 static void panel_scan_timer(void)
1976 if (keypad.enabled && keypad_initialized) {
1977 if (spin_trylock_irq(&pprt_lock)) {
1978 phys_scan_contacts();
1980 /* no need for the parport anymore */
1981 spin_unlock_irq(&pprt_lock);
1984 if (!inputs_stable || phys_curr != phys_prev)
1985 panel_process_inputs();
1988 if (lcd.enabled && lcd.initialized) {
1990 if (lcd.light_tempo == 0
1991 && ((lcd.flags & LCD_FLAG_L) == 0))
1993 lcd.light_tempo = FLASH_LIGHT_TEMPO;
1994 } else if (lcd.light_tempo > 0) {
1996 if (lcd.light_tempo == 0
1997 && ((lcd.flags & LCD_FLAG_L) == 0))
2002 mod_timer(&scan_timer, jiffies + INPUT_POLL_TIME);
2005 static void init_scan_timer(void)
2007 if (scan_timer.function != NULL)
2008 return; /* already started */
2010 setup_timer(&scan_timer, (void *)&panel_scan_timer, 0);
2011 scan_timer.expires = jiffies + INPUT_POLL_TIME;
2012 add_timer(&scan_timer);
2015 /* converts a name of the form "({BbAaPpSsEe}{01234567-})*" to a series of bits.
2016 * if <omask> or <imask> are non-null, they will be or'ed with the bits
2017 * corresponding to out and in bits respectively.
2018 * returns 1 if ok, 0 if error (in which case, nothing is written).
2020 static int input_name2mask(const char *name, pmask_t *mask, pmask_t *value,
2021 char *imask, char *omask)
2023 static char sigtab[10] = "EeSsPpAaBb";
2032 int in, out, bit, neg;
2034 for (in = 0; (in < sizeof(sigtab)) && (sigtab[in] != *name);
2038 if (in >= sizeof(sigtab))
2039 return 0; /* input name not found */
2040 neg = (in & 1); /* odd (lower) names are negated */
2045 if (isdigit(*name)) {
2048 } else if (*name == '-') {
2051 return 0; /* unknown bit name */
2054 bit = (out * 5) + in;
2070 /* tries to bind a key to the signal name <name>. The key will send the
2071 * strings <press>, <repeat>, <release> for these respective events.
2072 * Returns the pointer to the new key if ok, NULL if the key could not be bound.
2074 static struct logical_input *panel_bind_key(const char *name, const char *press,
2076 const char *release)
2078 struct logical_input *key;
2080 key = kzalloc(sizeof(*key), GFP_KERNEL);
2084 if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i,
2090 key->type = INPUT_TYPE_KBD;
2091 key->state = INPUT_ST_LOW;
2095 strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str));
2096 strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str));
2097 strncpy(key->u.kbd.release_str, release,
2098 sizeof(key->u.kbd.release_str));
2099 list_add(&key->list, &logical_inputs);
2104 /* tries to bind a callback function to the signal name <name>. The function
2105 * <press_fct> will be called with the <press_data> arg when the signal is
2106 * activated, and so on for <release_fct>/<release_data>
2107 * Returns the pointer to the new signal if ok, NULL if the signal could not
2110 static struct logical_input *panel_bind_callback(char *name,
2111 void (*press_fct)(int),
2113 void (*release_fct)(int),
2116 struct logical_input *callback;
2118 callback = kmalloc(sizeof(*callback), GFP_KERNEL);
2122 memset(callback, 0, sizeof(struct logical_input));
2123 if (!input_name2mask(name, &callback->mask, &callback->value,
2124 &scan_mask_i, &scan_mask_o))
2127 callback->type = INPUT_TYPE_STD;
2128 callback->state = INPUT_ST_LOW;
2129 callback->rise_time = 1;
2130 callback->fall_time = 1;
2131 callback->u.std.press_fct = press_fct;
2132 callback->u.std.press_data = press_data;
2133 callback->u.std.release_fct = release_fct;
2134 callback->u.std.release_data = release_data;
2135 list_add(&callback->list, &logical_inputs);
2140 static void keypad_init(void)
2144 init_waitqueue_head(&keypad_read_wait);
2145 keypad_buflen = 0; /* flushes any eventual noisy keystroke */
2147 /* Let's create all known keys */
2149 for (keynum = 0; keypad_profile[keynum][0][0]; keynum++) {
2150 panel_bind_key(keypad_profile[keynum][0],
2151 keypad_profile[keynum][1],
2152 keypad_profile[keynum][2],
2153 keypad_profile[keynum][3]);
2157 keypad_initialized = 1;
2160 /**************************************************/
2161 /* device initialization */
2162 /**************************************************/
2164 static int panel_notify_sys(struct notifier_block *this, unsigned long code,
2167 if (lcd.enabled && lcd.initialized) {
2171 ("\x0cReloading\nSystem...\x1b[Lc\x1b[Lb\x1b[L+");
2175 ("\x0cSystem Halted.\x1b[Lc\x1b[Lb\x1b[L+");
2178 panel_lcd_print("\x0cPower off.\x1b[Lc\x1b[Lb\x1b[L+");
2187 static struct notifier_block panel_notifier = {
2193 static void panel_attach(struct parport *port)
2195 struct pardev_cb panel_cb;
2197 if (port->number != parport)
2201 pr_err("%s: port->number=%d parport=%d, already registered!\n",
2202 __func__, port->number, parport);
2206 memset(&panel_cb, 0, sizeof(panel_cb));
2207 panel_cb.private = &pprt;
2208 /* panel_cb.flags = 0 should be PARPORT_DEV_EXCL? */
2210 pprt = parport_register_dev_model(port, "panel", &panel_cb, 0);
2212 pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n",
2213 __func__, port->number, parport);
2217 if (parport_claim(pprt)) {
2218 pr_err("could not claim access to parport%d. Aborting.\n",
2220 goto err_unreg_device;
2223 /* must init LCD first, just in case an IRQ from the keypad is
2224 * generated at keypad init
2228 if (misc_register(&lcd_dev))
2229 goto err_unreg_device;
2232 if (keypad.enabled) {
2234 if (misc_register(&keypad_dev))
2237 register_reboot_notifier(&panel_notifier);
2242 misc_deregister(&lcd_dev);
2244 parport_unregister_device(pprt);
2248 static void panel_detach(struct parport *port)
2250 if (port->number != parport)
2254 pr_err("%s: port->number=%d parport=%d, nothing to unregister.\n",
2255 __func__, port->number, parport);
2258 if (scan_timer.function != NULL)
2259 del_timer_sync(&scan_timer);
2262 if (keypad.enabled) {
2263 misc_deregister(&keypad_dev);
2264 keypad_initialized = 0;
2268 panel_lcd_print("\x0cLCD driver " PANEL_VERSION
2269 "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
2270 misc_deregister(&lcd_dev);
2271 lcd.initialized = false;
2274 /* TODO: free all input signals */
2275 parport_release(pprt);
2276 parport_unregister_device(pprt);
2278 unregister_reboot_notifier(&panel_notifier);
2282 static struct parport_driver panel_driver = {
2284 .match_port = panel_attach,
2285 .detach = panel_detach,
2290 static int __init panel_init_module(void)
2292 int selected_keypad_type = NOT_SET, err;
2294 /* take care of an eventual profile */
2296 case PANEL_PROFILE_CUSTOM:
2297 /* custom profile */
2298 selected_keypad_type = DEFAULT_KEYPAD_TYPE;
2299 selected_lcd_type = DEFAULT_LCD_TYPE;
2301 case PANEL_PROFILE_OLD:
2302 /* 8 bits, 2*16, old keypad */
2303 selected_keypad_type = KEYPAD_TYPE_OLD;
2304 selected_lcd_type = LCD_TYPE_OLD;
2306 /* TODO: This two are a little hacky, sort it out later */
2307 if (lcd_width == NOT_SET)
2309 if (lcd_hwidth == NOT_SET)
2312 case PANEL_PROFILE_NEW:
2313 /* serial, 2*16, new keypad */
2314 selected_keypad_type = KEYPAD_TYPE_NEW;
2315 selected_lcd_type = LCD_TYPE_KS0074;
2317 case PANEL_PROFILE_HANTRONIX:
2318 /* 8 bits, 2*16 hantronix-like, no keypad */
2319 selected_keypad_type = KEYPAD_TYPE_NONE;
2320 selected_lcd_type = LCD_TYPE_HANTRONIX;
2322 case PANEL_PROFILE_NEXCOM:
2323 /* generic 8 bits, 2*16, nexcom keypad, eg. Nexcom. */
2324 selected_keypad_type = KEYPAD_TYPE_NEXCOM;
2325 selected_lcd_type = LCD_TYPE_NEXCOM;
2327 case PANEL_PROFILE_LARGE:
2328 /* 8 bits, 2*40, old keypad */
2329 selected_keypad_type = KEYPAD_TYPE_OLD;
2330 selected_lcd_type = LCD_TYPE_OLD;
2335 * Overwrite selection with module param values (both keypad and lcd),
2336 * where the deprecated params have lower prio.
2338 if (keypad_enabled != NOT_SET)
2339 selected_keypad_type = keypad_enabled;
2340 if (keypad_type != NOT_SET)
2341 selected_keypad_type = keypad_type;
2343 keypad.enabled = (selected_keypad_type > 0);
2345 if (lcd_enabled != NOT_SET)
2346 selected_lcd_type = lcd_enabled;
2347 if (lcd_type != NOT_SET)
2348 selected_lcd_type = lcd_type;
2350 lcd.enabled = (selected_lcd_type > 0);
2354 * Init lcd struct with load-time values to preserve exact
2355 * current functionality (at least for now).
2357 lcd.height = lcd_height;
2358 lcd.width = lcd_width;
2359 lcd.bwidth = lcd_bwidth;
2360 lcd.hwidth = lcd_hwidth;
2361 lcd.charset = lcd_charset;
2362 lcd.proto = lcd_proto;
2363 lcd.pins.e = lcd_e_pin;
2364 lcd.pins.rs = lcd_rs_pin;
2365 lcd.pins.rw = lcd_rw_pin;
2366 lcd.pins.cl = lcd_cl_pin;
2367 lcd.pins.da = lcd_da_pin;
2368 lcd.pins.bl = lcd_bl_pin;
2370 /* Leave it for now, just in case */
2371 lcd.esc_seq.len = -1;
2374 switch (selected_keypad_type) {
2375 case KEYPAD_TYPE_OLD:
2376 keypad_profile = old_keypad_profile;
2378 case KEYPAD_TYPE_NEW:
2379 keypad_profile = new_keypad_profile;
2381 case KEYPAD_TYPE_NEXCOM:
2382 keypad_profile = nexcom_keypad_profile;
2385 keypad_profile = NULL;
2389 if (!lcd.enabled && !keypad.enabled) {
2390 /* no device enabled, let's exit */
2391 pr_err("driver version " PANEL_VERSION " disabled.\n");
2395 err = parport_register_driver(&panel_driver);
2397 pr_err("could not register with parport. Aborting.\n");
2402 pr_info("driver version " PANEL_VERSION
2403 " registered on parport%d (io=0x%lx).\n", parport,
2406 pr_info("driver version " PANEL_VERSION
2407 " not yet registered\n");
2411 static void __exit panel_cleanup_module(void)
2413 parport_unregister_driver(&panel_driver);
2416 module_init(panel_init_module);
2417 module_exit(panel_cleanup_module);
2418 MODULE_AUTHOR("Willy Tarreau");
2419 MODULE_LICENSE("GPL");