]>
Commit | Line | Data |
---|---|---|
351f683b | 1 | // SPDX-License-Identifier: GPL-2.0+ |
7005b584 | 2 | /* |
698b1515 WT |
3 | * Front panel driver for Linux |
4 | * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu> | |
39f8ea46 | 5 | * Copyright (C) 2016-2017 Glider bvba |
7005b584 | 6 | * |
698b1515 WT |
7 | * This code drives an LCD module (/dev/lcd), and a keypad (/dev/keypad) |
8 | * connected to a parallel printer port. | |
7005b584 | 9 | * |
698b1515 WT |
10 | * The LCD module may either be an HD44780-like 8-bit parallel LCD, or a 1-bit |
11 | * serial module compatible with Samsung's KS0074. The pins may be connected in | |
12 | * any combination, everything is programmable. | |
7005b584 | 13 | * |
698b1515 WT |
14 | * The keypad consists in a matrix of push buttons connecting input pins to |
15 | * data output pins or to the ground. The combinations have to be hard-coded | |
16 | * in the driver, though several profiles exist and adding new ones is easy. | |
7005b584 | 17 | * |
698b1515 WT |
18 | * Several profiles are provided for commonly found LCD+keypad modules on the |
19 | * market, such as those found in Nexcom's appliances. | |
7005b584 WT |
20 | * |
21 | * FIXME: | |
22 | * - the initialization/deinitialization process is very dirty and should | |
23 | * be rewritten. It may even be buggy. | |
24 | * | |
25 | * TODO: | |
26 | * - document 24 keys keyboard (3 rows of 8 cols, 32 diodes + 2 inputs) | |
27 | * - make the LCD a part of a virtual screen of Vx*Vy | |
28 | * - make the inputs list smp-safe | |
29 | * - change the keyboard to a double mapping : signals -> key_id -> values | |
30 | * so that applications can change values without knowing signals | |
31 | * | |
32 | */ | |
33 | ||
493aa896 TY |
34 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
35 | ||
7005b584 WT |
36 | #include <linux/module.h> |
37 | ||
38 | #include <linux/types.h> | |
39 | #include <linux/errno.h> | |
40 | #include <linux/signal.h> | |
41 | #include <linux/sched.h> | |
42 | #include <linux/spinlock.h> | |
7005b584 WT |
43 | #include <linux/interrupt.h> |
44 | #include <linux/miscdevice.h> | |
698b1515 | 45 | #include <linux/slab.h> |
7005b584 WT |
46 | #include <linux/ioport.h> |
47 | #include <linux/fcntl.h> | |
48 | #include <linux/init.h> | |
49 | #include <linux/delay.h> | |
d85170ed | 50 | #include <linux/kernel.h> |
7005b584 WT |
51 | #include <linux/ctype.h> |
52 | #include <linux/parport.h> | |
7005b584 | 53 | #include <linux/list.h> |
7005b584 | 54 | |
698b1515 | 55 | #include <linux/io.h> |
48f658bb | 56 | #include <linux/uaccess.h> |
7005b584 | 57 | |
39f8ea46 GU |
58 | #include <misc/charlcd.h> |
59 | ||
7005b584 | 60 | #define KEYPAD_MINOR 185 |
7005b584 | 61 | |
7005b584 WT |
62 | #define LCD_MAXBYTES 256 /* max burst write */ |
63 | ||
7005b584 | 64 | #define KEYPAD_BUFFER 64 |
7005b584 | 65 | |
429ccf05 | 66 | /* poll the keyboard this every second */ |
2b3c9eb2 | 67 | #define INPUT_POLL_TIME (HZ / 50) |
429ccf05 HH |
68 | /* a key starts to repeat after this times INPUT_POLL_TIME */ |
69 | #define KEYPAD_REP_START (10) | |
70 | /* a key repeats this times INPUT_POLL_TIME */ | |
71 | #define KEYPAD_REP_DELAY (2) | |
72 | ||
7005b584 WT |
73 | /* converts an r_str() input to an active high, bits string : 000BAOSE */ |
74 | #define PNL_PINPUT(a) ((((unsigned char)(a)) ^ 0x7F) >> 3) | |
75 | ||
698b1515 WT |
76 | #define PNL_PBUSY 0x80 /* inverted input, active low */ |
77 | #define PNL_PACK 0x40 /* direct input, active low */ | |
78 | #define PNL_POUTPA 0x20 /* direct input, active high */ | |
79 | #define PNL_PSELECD 0x10 /* direct input, active high */ | |
80 | #define PNL_PERRORP 0x08 /* direct input, active low */ | |
7005b584 | 81 | |
698b1515 | 82 | #define PNL_PBIDIR 0x20 /* bi-directional ports */ |
429ccf05 HH |
83 | /* high to read data in or-ed with data out */ |
84 | #define PNL_PINTEN 0x10 | |
698b1515 WT |
85 | #define PNL_PSELECP 0x08 /* inverted output, active low */ |
86 | #define PNL_PINITP 0x04 /* direct output, active low */ | |
87 | #define PNL_PAUTOLF 0x02 /* inverted output, active low */ | |
88 | #define PNL_PSTROBE 0x01 /* inverted output */ | |
7005b584 WT |
89 | |
90 | #define PNL_PD0 0x01 | |
91 | #define PNL_PD1 0x02 | |
92 | #define PNL_PD2 0x04 | |
93 | #define PNL_PD3 0x08 | |
94 | #define PNL_PD4 0x10 | |
95 | #define PNL_PD5 0x20 | |
96 | #define PNL_PD6 0x40 | |
97 | #define PNL_PD7 0x80 | |
98 | ||
99 | #define PIN_NONE 0 | |
100 | #define PIN_STROBE 1 | |
101 | #define PIN_D0 2 | |
102 | #define PIN_D1 3 | |
103 | #define PIN_D2 4 | |
104 | #define PIN_D3 5 | |
105 | #define PIN_D4 6 | |
106 | #define PIN_D5 7 | |
107 | #define PIN_D6 8 | |
108 | #define PIN_D7 9 | |
109 | #define PIN_AUTOLF 14 | |
110 | #define PIN_INITP 16 | |
111 | #define PIN_SELECP 17 | |
112 | #define PIN_NOT_SET 127 | |
113 | ||
36277d4a MG |
114 | #define NOT_SET -1 |
115 | ||
7005b584 WT |
116 | /* macros to simplify use of the parallel port */ |
117 | #define r_ctr(x) (parport_read_control((x)->port)) | |
118 | #define r_dtr(x) (parport_read_data((x)->port)) | |
119 | #define r_str(x) (parport_read_status((x)->port)) | |
6ebb56d9 TY |
120 | #define w_ctr(x, y) (parport_write_control((x)->port, (y))) |
121 | #define w_dtr(x, y) (parport_write_data((x)->port, (y))) | |
7005b584 WT |
122 | |
123 | /* this defines which bits are to be used and which ones to be ignored */ | |
429ccf05 HH |
124 | /* logical or of the output bits involved in the scan matrix */ |
125 | static __u8 scan_mask_o; | |
126 | /* logical or of the input bits involved in the scan matrix */ | |
127 | static __u8 scan_mask_i; | |
7005b584 | 128 | |
7005b584 | 129 | enum input_type { |
698b1515 WT |
130 | INPUT_TYPE_STD, |
131 | INPUT_TYPE_KBD, | |
7005b584 WT |
132 | }; |
133 | ||
134 | enum input_state { | |
698b1515 WT |
135 | INPUT_ST_LOW, |
136 | INPUT_ST_RISING, | |
137 | INPUT_ST_HIGH, | |
138 | INPUT_ST_FALLING, | |
7005b584 WT |
139 | }; |
140 | ||
141 | struct logical_input { | |
698b1515 | 142 | struct list_head list; |
35fe0872 KS |
143 | __u64 mask; |
144 | __u64 value; | |
698b1515 WT |
145 | enum input_type type; |
146 | enum input_state state; | |
147 | __u8 rise_time, fall_time; | |
148 | __u8 rise_timer, fall_timer, high_timer; | |
149 | ||
150 | union { | |
429ccf05 | 151 | struct { /* valid when type == INPUT_TYPE_STD */ |
68d386bf MA |
152 | void (*press_fct)(int); |
153 | void (*release_fct)(int); | |
698b1515 WT |
154 | int press_data; |
155 | int release_data; | |
156 | } std; | |
429ccf05 HH |
157 | struct { /* valid when type == INPUT_TYPE_KBD */ |
158 | /* strings can be non null-terminated */ | |
698b1515 WT |
159 | char press_str[sizeof(void *) + sizeof(int)]; |
160 | char repeat_str[sizeof(void *) + sizeof(int)]; | |
161 | char release_str[sizeof(void *) + sizeof(int)]; | |
162 | } kbd; | |
163 | } u; | |
7005b584 WT |
164 | }; |
165 | ||
36d2041a | 166 | static LIST_HEAD(logical_inputs); /* list of all defined logical inputs */ |
7005b584 WT |
167 | |
168 | /* physical contacts history | |
169 | * Physical contacts are a 45 bits string of 9 groups of 5 bits each. | |
170 | * The 8 lower groups correspond to output bits 0 to 7, and the 9th group | |
171 | * corresponds to the ground. | |
172 | * Within each group, bits are stored in the same order as read on the port : | |
173 | * BAPSE (busy=4, ack=3, paper empty=2, select=1, error=0). | |
35fe0872 | 174 | * So, each __u64 is represented like this : |
7005b584 WT |
175 | * 0000000000000000000BAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSEBAPSE |
176 | * <-----unused------><gnd><d07><d06><d05><d04><d03><d02><d01><d00> | |
177 | */ | |
429ccf05 HH |
178 | |
179 | /* what has just been read from the I/O ports */ | |
35fe0872 | 180 | static __u64 phys_read; |
429ccf05 | 181 | /* previous phys_read */ |
35fe0872 | 182 | static __u64 phys_read_prev; |
429ccf05 | 183 | /* stabilized phys_read (phys_read|phys_read_prev) */ |
35fe0872 | 184 | static __u64 phys_curr; |
429ccf05 | 185 | /* previous phys_curr */ |
35fe0872 | 186 | static __u64 phys_prev; |
429ccf05 HH |
187 | /* 0 means that at least one logical signal needs be computed */ |
188 | static char inputs_stable; | |
7005b584 | 189 | |
7005b584 | 190 | /* these variables are specific to the keypad */ |
a8b2580b MG |
191 | static struct { |
192 | bool enabled; | |
193 | } keypad; | |
194 | ||
7005b584 | 195 | static char keypad_buffer[KEYPAD_BUFFER]; |
698b1515 WT |
196 | static int keypad_buflen; |
197 | static int keypad_start; | |
198 | static char keypressed; | |
7005b584 | 199 | static wait_queue_head_t keypad_read_wait; |
7005b584 WT |
200 | |
201 | /* lcd-specific variables */ | |
a8b2580b MG |
202 | static struct { |
203 | bool enabled; | |
6d8b588c | 204 | bool initialized; |
6d8b588c | 205 | |
8037e2a3 MG |
206 | int charset; |
207 | int proto; | |
fda4ae18 | 208 | |
8037e2a3 MG |
209 | /* TODO: use union here? */ |
210 | struct { | |
211 | int e; | |
212 | int rs; | |
213 | int rw; | |
214 | int cl; | |
215 | int da; | |
216 | int bl; | |
217 | } pins; | |
6d8b588c | 218 | |
39f8ea46 | 219 | struct charlcd *charlcd; |
a8b2580b | 220 | } lcd; |
429ccf05 | 221 | |
87b8e0c8 MG |
222 | /* Needed only for init */ |
223 | static int selected_lcd_type = NOT_SET; | |
224 | ||
7005b584 WT |
225 | /* |
226 | * Bit masks to convert LCD signals to parallel port outputs. | |
227 | * _d_ are values for data port, _c_ are for control port. | |
228 | * [0] = signal OFF, [1] = signal ON, [2] = mask | |
229 | */ | |
698b1515 WT |
230 | #define BIT_CLR 0 |
231 | #define BIT_SET 1 | |
232 | #define BIT_MSK 2 | |
7005b584 WT |
233 | #define BIT_STATES 3 |
234 | /* | |
235 | * one entry for each bit on the LCD | |
236 | */ | |
237 | #define LCD_BIT_E 0 | |
238 | #define LCD_BIT_RS 1 | |
239 | #define LCD_BIT_RW 2 | |
240 | #define LCD_BIT_BL 3 | |
241 | #define LCD_BIT_CL 4 | |
242 | #define LCD_BIT_DA 5 | |
243 | #define LCD_BITS 6 | |
244 | ||
245 | /* | |
246 | * each bit can be either connected to a DATA or CTRL port | |
247 | */ | |
248 | #define LCD_PORT_C 0 | |
249 | #define LCD_PORT_D 1 | |
250 | #define LCD_PORTS 2 | |
251 | ||
252 | static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; | |
253 | ||
254 | /* | |
255 | * LCD protocols | |
256 | */ | |
257 | #define LCD_PROTO_PARALLEL 0 | |
258 | #define LCD_PROTO_SERIAL 1 | |
77943d31 | 259 | #define LCD_PROTO_TI_DA8XX_LCD 2 |
7005b584 WT |
260 | |
261 | /* | |
262 | * LCD character sets | |
263 | */ | |
264 | #define LCD_CHARSET_NORMAL 0 | |
265 | #define LCD_CHARSET_KS0074 1 | |
266 | ||
267 | /* | |
268 | * LCD types | |
269 | */ | |
270 | #define LCD_TYPE_NONE 0 | |
2c20d92d SM |
271 | #define LCD_TYPE_CUSTOM 1 |
272 | #define LCD_TYPE_OLD 2 | |
273 | #define LCD_TYPE_KS0074 3 | |
274 | #define LCD_TYPE_HANTRONIX 4 | |
275 | #define LCD_TYPE_NEXCOM 5 | |
7005b584 WT |
276 | |
277 | /* | |
278 | * keypad types | |
279 | */ | |
280 | #define KEYPAD_TYPE_NONE 0 | |
281 | #define KEYPAD_TYPE_OLD 1 | |
282 | #define KEYPAD_TYPE_NEW 2 | |
283 | #define KEYPAD_TYPE_NEXCOM 3 | |
284 | ||
285 | /* | |
286 | * panel profiles | |
287 | */ | |
288 | #define PANEL_PROFILE_CUSTOM 0 | |
289 | #define PANEL_PROFILE_OLD 1 | |
290 | #define PANEL_PROFILE_NEW 2 | |
291 | #define PANEL_PROFILE_HANTRONIX 3 | |
292 | #define PANEL_PROFILE_NEXCOM 4 | |
293 | #define PANEL_PROFILE_LARGE 5 | |
294 | ||
295 | /* | |
296 | * Construct custom config from the kernel's configuration | |
297 | */ | |
7005b584 | 298 | #define DEFAULT_PARPORT 0 |
fe4d7e2c | 299 | #define DEFAULT_PROFILE PANEL_PROFILE_LARGE |
98fac3d3 MG |
300 | #define DEFAULT_KEYPAD_TYPE KEYPAD_TYPE_OLD |
301 | #define DEFAULT_LCD_TYPE LCD_TYPE_OLD | |
fe4d7e2c | 302 | #define DEFAULT_LCD_HEIGHT 2 |
7005b584 WT |
303 | #define DEFAULT_LCD_WIDTH 40 |
304 | #define DEFAULT_LCD_BWIDTH 40 | |
305 | #define DEFAULT_LCD_HWIDTH 64 | |
fe4d7e2c | 306 | #define DEFAULT_LCD_CHARSET LCD_CHARSET_NORMAL |
7005b584 WT |
307 | #define DEFAULT_LCD_PROTO LCD_PROTO_PARALLEL |
308 | ||
309 | #define DEFAULT_LCD_PIN_E PIN_AUTOLF | |
310 | #define DEFAULT_LCD_PIN_RS PIN_SELECP | |
311 | #define DEFAULT_LCD_PIN_RW PIN_INITP | |
312 | #define DEFAULT_LCD_PIN_SCL PIN_STROBE | |
313 | #define DEFAULT_LCD_PIN_SDA PIN_D0 | |
314 | #define DEFAULT_LCD_PIN_BL PIN_NOT_SET | |
7005b584 | 315 | |
7005b584 WT |
316 | #ifdef CONFIG_PANEL_PARPORT |
317 | #undef DEFAULT_PARPORT | |
318 | #define DEFAULT_PARPORT CONFIG_PANEL_PARPORT | |
319 | #endif | |
320 | ||
1e13e8aa MG |
321 | #ifdef CONFIG_PANEL_PROFILE |
322 | #undef DEFAULT_PROFILE | |
323 | #define DEFAULT_PROFILE CONFIG_PANEL_PROFILE | |
324 | #endif | |
325 | ||
698b1515 | 326 | #if DEFAULT_PROFILE == 0 /* custom */ |
7005b584 | 327 | #ifdef CONFIG_PANEL_KEYPAD |
98fac3d3 MG |
328 | #undef DEFAULT_KEYPAD_TYPE |
329 | #define DEFAULT_KEYPAD_TYPE CONFIG_PANEL_KEYPAD | |
7005b584 WT |
330 | #endif |
331 | ||
7005b584 | 332 | #ifdef CONFIG_PANEL_LCD |
98fac3d3 MG |
333 | #undef DEFAULT_LCD_TYPE |
334 | #define DEFAULT_LCD_TYPE CONFIG_PANEL_LCD | |
7005b584 WT |
335 | #endif |
336 | ||
1e13e8aa MG |
337 | #ifdef CONFIG_PANEL_LCD_HEIGHT |
338 | #undef DEFAULT_LCD_HEIGHT | |
339 | #define DEFAULT_LCD_HEIGHT CONFIG_PANEL_LCD_HEIGHT | |
340 | #endif | |
341 | ||
7005b584 WT |
342 | #ifdef CONFIG_PANEL_LCD_WIDTH |
343 | #undef DEFAULT_LCD_WIDTH | |
344 | #define DEFAULT_LCD_WIDTH CONFIG_PANEL_LCD_WIDTH | |
345 | #endif | |
346 | ||
347 | #ifdef CONFIG_PANEL_LCD_BWIDTH | |
348 | #undef DEFAULT_LCD_BWIDTH | |
349 | #define DEFAULT_LCD_BWIDTH CONFIG_PANEL_LCD_BWIDTH | |
350 | #endif | |
351 | ||
352 | #ifdef CONFIG_PANEL_LCD_HWIDTH | |
353 | #undef DEFAULT_LCD_HWIDTH | |
354 | #define DEFAULT_LCD_HWIDTH CONFIG_PANEL_LCD_HWIDTH | |
355 | #endif | |
356 | ||
1e13e8aa MG |
357 | #ifdef CONFIG_PANEL_LCD_CHARSET |
358 | #undef DEFAULT_LCD_CHARSET | |
359 | #define DEFAULT_LCD_CHARSET CONFIG_PANEL_LCD_CHARSET | |
7005b584 WT |
360 | #endif |
361 | ||
362 | #ifdef CONFIG_PANEL_LCD_PROTO | |
363 | #undef DEFAULT_LCD_PROTO | |
364 | #define DEFAULT_LCD_PROTO CONFIG_PANEL_LCD_PROTO | |
365 | #endif | |
366 | ||
367 | #ifdef CONFIG_PANEL_LCD_PIN_E | |
368 | #undef DEFAULT_LCD_PIN_E | |
369 | #define DEFAULT_LCD_PIN_E CONFIG_PANEL_LCD_PIN_E | |
370 | #endif | |
371 | ||
372 | #ifdef CONFIG_PANEL_LCD_PIN_RS | |
373 | #undef DEFAULT_LCD_PIN_RS | |
374 | #define DEFAULT_LCD_PIN_RS CONFIG_PANEL_LCD_PIN_RS | |
375 | #endif | |
376 | ||
377 | #ifdef CONFIG_PANEL_LCD_PIN_RW | |
378 | #undef DEFAULT_LCD_PIN_RW | |
379 | #define DEFAULT_LCD_PIN_RW CONFIG_PANEL_LCD_PIN_RW | |
380 | #endif | |
381 | ||
382 | #ifdef CONFIG_PANEL_LCD_PIN_SCL | |
383 | #undef DEFAULT_LCD_PIN_SCL | |
384 | #define DEFAULT_LCD_PIN_SCL CONFIG_PANEL_LCD_PIN_SCL | |
385 | #endif | |
386 | ||
387 | #ifdef CONFIG_PANEL_LCD_PIN_SDA | |
388 | #undef DEFAULT_LCD_PIN_SDA | |
389 | #define DEFAULT_LCD_PIN_SDA CONFIG_PANEL_LCD_PIN_SDA | |
390 | #endif | |
391 | ||
392 | #ifdef CONFIG_PANEL_LCD_PIN_BL | |
393 | #undef DEFAULT_LCD_PIN_BL | |
394 | #define DEFAULT_LCD_PIN_BL CONFIG_PANEL_LCD_PIN_BL | |
395 | #endif | |
396 | ||
7005b584 WT |
397 | #endif /* DEFAULT_PROFILE == 0 */ |
398 | ||
399 | /* global variables */ | |
f4757af8 MG |
400 | |
401 | /* Device single-open policy control */ | |
f4757af8 MG |
402 | static atomic_t keypad_available = ATOMIC_INIT(1); |
403 | ||
698b1515 | 404 | static struct pardevice *pprt; |
7005b584 | 405 | |
f6d1fcfe | 406 | static int keypad_initialized; |
7005b584 | 407 | |
698b1515 | 408 | static DEFINE_SPINLOCK(pprt_lock); |
7005b584 WT |
409 | static struct timer_list scan_timer; |
410 | ||
63023177 | 411 | MODULE_DESCRIPTION("Generic parallel port LCD/Keypad driver"); |
f6d1fcfe | 412 | |
59a66a24 | 413 | static int parport = DEFAULT_PARPORT; |
698b1515 WT |
414 | module_param(parport, int, 0000); |
415 | MODULE_PARM_DESC(parport, "Parallel port index (0=lpt1, 1=lpt2, ...)"); | |
f6d1fcfe | 416 | |
98e0e762 MG |
417 | static int profile = DEFAULT_PROFILE; |
418 | module_param(profile, int, 0000); | |
419 | MODULE_PARM_DESC(profile, | |
420 | "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; " | |
421 | "4=16x2 nexcom; default=40x2, old kp"); | |
422 | ||
36277d4a | 423 | static int keypad_type = NOT_SET; |
98e0e762 MG |
424 | module_param(keypad_type, int, 0000); |
425 | MODULE_PARM_DESC(keypad_type, | |
426 | "Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, 3=nexcom 4 keys"); | |
427 | ||
36277d4a | 428 | static int lcd_type = NOT_SET; |
98e0e762 MG |
429 | module_param(lcd_type, int, 0000); |
430 | MODULE_PARM_DESC(lcd_type, | |
2c20d92d | 431 | "LCD type: 0=none, 1=compiled-in, 2=old, 3=serial ks0074, 4=hantronix, 5=nexcom"); |
98e0e762 | 432 | |
36277d4a | 433 | static int lcd_height = NOT_SET; |
698b1515 WT |
434 | module_param(lcd_height, int, 0000); |
435 | MODULE_PARM_DESC(lcd_height, "Number of lines on the LCD"); | |
f6d1fcfe | 436 | |
36277d4a | 437 | static int lcd_width = NOT_SET; |
698b1515 WT |
438 | module_param(lcd_width, int, 0000); |
439 | MODULE_PARM_DESC(lcd_width, "Number of columns on the LCD"); | |
f6d1fcfe | 440 | |
36277d4a | 441 | static int lcd_bwidth = NOT_SET; /* internal buffer width (usually 40) */ |
698b1515 WT |
442 | module_param(lcd_bwidth, int, 0000); |
443 | MODULE_PARM_DESC(lcd_bwidth, "Internal LCD line width (40)"); | |
f6d1fcfe | 444 | |
36277d4a | 445 | static int lcd_hwidth = NOT_SET; /* hardware buffer width (usually 64) */ |
698b1515 WT |
446 | module_param(lcd_hwidth, int, 0000); |
447 | MODULE_PARM_DESC(lcd_hwidth, "LCD line hardware address (64)"); | |
f6d1fcfe | 448 | |
36277d4a | 449 | static int lcd_charset = NOT_SET; |
98e0e762 MG |
450 | module_param(lcd_charset, int, 0000); |
451 | MODULE_PARM_DESC(lcd_charset, "LCD character set: 0=standard, 1=KS0074"); | |
f6d1fcfe | 452 | |
36277d4a | 453 | static int lcd_proto = NOT_SET; |
698b1515 | 454 | module_param(lcd_proto, int, 0000); |
429ccf05 | 455 | MODULE_PARM_DESC(lcd_proto, |
fdf4a494 | 456 | "LCD communication: 0=parallel (//), 1=serial, 2=TI LCD Interface"); |
f6d1fcfe | 457 | |
f6d1fcfe WT |
458 | /* |
459 | * These are the parallel port pins the LCD control signals are connected to. | |
460 | * Set this to 0 if the signal is not used. Set it to its opposite value | |
461 | * (negative) if the signal is negated. -MAXINT is used to indicate that the | |
462 | * pin has not been explicitly specified. | |
463 | * | |
63023177 | 464 | * WARNING! no check will be performed about collisions with keypad ! |
f6d1fcfe WT |
465 | */ |
466 | ||
467 | static int lcd_e_pin = PIN_NOT_SET; | |
698b1515 WT |
468 | module_param(lcd_e_pin, int, 0000); |
469 | MODULE_PARM_DESC(lcd_e_pin, | |
fe5d2e01 | 470 | "# of the // port pin connected to LCD 'E' signal, with polarity (-17..17)"); |
f6d1fcfe WT |
471 | |
472 | static int lcd_rs_pin = PIN_NOT_SET; | |
698b1515 WT |
473 | module_param(lcd_rs_pin, int, 0000); |
474 | MODULE_PARM_DESC(lcd_rs_pin, | |
fe5d2e01 | 475 | "# of the // port pin connected to LCD 'RS' signal, with polarity (-17..17)"); |
f6d1fcfe WT |
476 | |
477 | static int lcd_rw_pin = PIN_NOT_SET; | |
698b1515 WT |
478 | module_param(lcd_rw_pin, int, 0000); |
479 | MODULE_PARM_DESC(lcd_rw_pin, | |
fe5d2e01 | 480 | "# of the // port pin connected to LCD 'RW' signal, with polarity (-17..17)"); |
f6d1fcfe | 481 | |
98e0e762 MG |
482 | static int lcd_cl_pin = PIN_NOT_SET; |
483 | module_param(lcd_cl_pin, int, 0000); | |
484 | MODULE_PARM_DESC(lcd_cl_pin, | |
485 | "# of the // port pin connected to serial LCD 'SCL' signal, with polarity (-17..17)"); | |
f6d1fcfe WT |
486 | |
487 | static int lcd_da_pin = PIN_NOT_SET; | |
698b1515 WT |
488 | module_param(lcd_da_pin, int, 0000); |
489 | MODULE_PARM_DESC(lcd_da_pin, | |
fe5d2e01 | 490 | "# of the // port pin connected to serial LCD 'SDA' signal, with polarity (-17..17)"); |
f6d1fcfe | 491 | |
98e0e762 MG |
492 | static int lcd_bl_pin = PIN_NOT_SET; |
493 | module_param(lcd_bl_pin, int, 0000); | |
494 | MODULE_PARM_DESC(lcd_bl_pin, | |
495 | "# of the // port pin connected to LCD backlight, with polarity (-17..17)"); | |
496 | ||
497 | /* Deprecated module parameters - consider not using them anymore */ | |
498 | ||
36277d4a | 499 | static int lcd_enabled = NOT_SET; |
98e0e762 MG |
500 | module_param(lcd_enabled, int, 0000); |
501 | MODULE_PARM_DESC(lcd_enabled, "Deprecated option, use lcd_type instead"); | |
502 | ||
36277d4a | 503 | static int keypad_enabled = NOT_SET; |
98e0e762 MG |
504 | module_param(keypad_enabled, int, 0000); |
505 | MODULE_PARM_DESC(keypad_enabled, "Deprecated option, use keypad_type instead"); | |
506 | ||
7005b584 | 507 | /* for some LCD drivers (ks0074) we need a charset conversion table. */ |
36d2041a | 508 | static const unsigned char lcd_char_conv_ks0074[256] = { |
698b1515 WT |
509 | /* 0|8 1|9 2|A 3|B 4|C 5|D 6|E 7|F */ |
510 | /* 0x00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | |
511 | /* 0x08 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | |
512 | /* 0x10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, | |
513 | /* 0x18 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, | |
514 | /* 0x20 */ 0x20, 0x21, 0x22, 0x23, 0xa2, 0x25, 0x26, 0x27, | |
515 | /* 0x28 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, | |
516 | /* 0x30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, | |
517 | /* 0x38 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, | |
518 | /* 0x40 */ 0xa0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, | |
519 | /* 0x48 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, | |
520 | /* 0x50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, | |
521 | /* 0x58 */ 0x58, 0x59, 0x5a, 0xfa, 0xfb, 0xfc, 0x1d, 0xc4, | |
522 | /* 0x60 */ 0x96, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, | |
523 | /* 0x68 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, | |
524 | /* 0x70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, | |
525 | /* 0x78 */ 0x78, 0x79, 0x7a, 0xfd, 0xfe, 0xff, 0xce, 0x20, | |
526 | /* 0x80 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, | |
527 | /* 0x88 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, | |
528 | /* 0x90 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, | |
529 | /* 0x98 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, | |
530 | /* 0xA0 */ 0x20, 0x40, 0xb1, 0xa1, 0x24, 0xa3, 0xfe, 0x5f, | |
531 | /* 0xA8 */ 0x22, 0xc8, 0x61, 0x14, 0x97, 0x2d, 0xad, 0x96, | |
532 | /* 0xB0 */ 0x80, 0x8c, 0x82, 0x83, 0x27, 0x8f, 0x86, 0xdd, | |
533 | /* 0xB8 */ 0x2c, 0x81, 0x6f, 0x15, 0x8b, 0x8a, 0x84, 0x60, | |
534 | /* 0xC0 */ 0xe2, 0xe2, 0xe2, 0x5b, 0x5b, 0xae, 0xbc, 0xa9, | |
535 | /* 0xC8 */ 0xc5, 0xbf, 0xc6, 0xf1, 0xe3, 0xe3, 0xe3, 0xe3, | |
536 | /* 0xD0 */ 0x44, 0x5d, 0xa8, 0xe4, 0xec, 0xec, 0x5c, 0x78, | |
537 | /* 0xD8 */ 0xab, 0xa6, 0xe5, 0x5e, 0x5e, 0xe6, 0xaa, 0xbe, | |
538 | /* 0xE0 */ 0x7f, 0xe7, 0xaf, 0x7b, 0x7b, 0xaf, 0xbd, 0xc8, | |
539 | /* 0xE8 */ 0xa4, 0xa5, 0xc7, 0xf6, 0xa7, 0xe8, 0x69, 0x69, | |
540 | /* 0xF0 */ 0xed, 0x7d, 0xa8, 0xe4, 0xec, 0x5c, 0x5c, 0x25, | |
541 | /* 0xF8 */ 0xac, 0xa6, 0xea, 0xef, 0x7e, 0xeb, 0xb2, 0x79, | |
7005b584 WT |
542 | }; |
543 | ||
36d2041a | 544 | static const char old_keypad_profile[][4][9] = { |
698b1515 WT |
545 | {"S0", "Left\n", "Left\n", ""}, |
546 | {"S1", "Down\n", "Down\n", ""}, | |
547 | {"S2", "Up\n", "Up\n", ""}, | |
548 | {"S3", "Right\n", "Right\n", ""}, | |
549 | {"S4", "Esc\n", "Esc\n", ""}, | |
550 | {"S5", "Ret\n", "Ret\n", ""}, | |
551 | {"", "", "", ""} | |
7005b584 WT |
552 | }; |
553 | ||
554 | /* signals, press, repeat, release */ | |
36d2041a | 555 | static const char new_keypad_profile[][4][9] = { |
698b1515 WT |
556 | {"S0", "Left\n", "Left\n", ""}, |
557 | {"S1", "Down\n", "Down\n", ""}, | |
558 | {"S2", "Up\n", "Up\n", ""}, | |
559 | {"S3", "Right\n", "Right\n", ""}, | |
560 | {"S4s5", "", "Esc\n", "Esc\n"}, | |
561 | {"s4S5", "", "Ret\n", "Ret\n"}, | |
562 | {"S4S5", "Help\n", "", ""}, | |
563 | /* add new signals above this line */ | |
564 | {"", "", "", ""} | |
7005b584 WT |
565 | }; |
566 | ||
567 | /* signals, press, repeat, release */ | |
36d2041a | 568 | static const char nexcom_keypad_profile[][4][9] = { |
698b1515 WT |
569 | {"a-p-e-", "Down\n", "Down\n", ""}, |
570 | {"a-p-E-", "Ret\n", "Ret\n", ""}, | |
571 | {"a-P-E-", "Esc\n", "Esc\n", ""}, | |
572 | {"a-P-e-", "Up\n", "Up\n", ""}, | |
573 | /* add new signals above this line */ | |
574 | {"", "", "", ""} | |
7005b584 WT |
575 | }; |
576 | ||
36d2041a | 577 | static const char (*keypad_profile)[4][9] = old_keypad_profile; |
7005b584 | 578 | |
bea7433b DC |
579 | static DECLARE_BITMAP(bits, LCD_BITS); |
580 | ||
581 | static void lcd_get_bits(unsigned int port, int *val) | |
582 | { | |
583 | unsigned int bit, state; | |
584 | ||
585 | for (bit = 0; bit < LCD_BITS; bit++) { | |
586 | state = test_bit(bit, bits) ? BIT_SET : BIT_CLR; | |
587 | *val &= lcd_bits[port][bit][BIT_MSK]; | |
588 | *val |= lcd_bits[port][bit][state]; | |
589 | } | |
590 | } | |
7005b584 | 591 | |
7005b584 | 592 | /* sets data port bits according to current signals values */ |
698b1515 WT |
593 | static int set_data_bits(void) |
594 | { | |
bea7433b | 595 | int val; |
698b1515 WT |
596 | |
597 | val = r_dtr(pprt); | |
bea7433b | 598 | lcd_get_bits(LCD_PORT_D, &val); |
698b1515 WT |
599 | w_dtr(pprt, val); |
600 | return val; | |
7005b584 WT |
601 | } |
602 | ||
603 | /* sets ctrl port bits according to current signals values */ | |
698b1515 WT |
604 | static int set_ctrl_bits(void) |
605 | { | |
bea7433b | 606 | int val; |
698b1515 WT |
607 | |
608 | val = r_ctr(pprt); | |
bea7433b | 609 | lcd_get_bits(LCD_PORT_C, &val); |
698b1515 WT |
610 | w_ctr(pprt, val); |
611 | return val; | |
7005b584 WT |
612 | } |
613 | ||
614 | /* sets ctrl & data port bits according to current signals values */ | |
6136ac86 | 615 | static void panel_set_bits(void) |
698b1515 WT |
616 | { |
617 | set_data_bits(); | |
618 | set_ctrl_bits(); | |
7005b584 WT |
619 | } |
620 | ||
621 | /* | |
622 | * Converts a parallel port pin (from -25 to 25) to data and control ports | |
623 | * masks, and data and control port bits. The signal will be considered | |
624 | * unconnected if it's on pin 0 or an invalid pin (<-25 or >25). | |
625 | * | |
626 | * Result will be used this way : | |
627 | * out(dport, in(dport) & d_val[2] | d_val[signal_state]) | |
628 | * out(cport, in(cport) & c_val[2] | c_val[signal_state]) | |
629 | */ | |
36d2041a | 630 | static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) |
698b1515 WT |
631 | { |
632 | int d_bit, c_bit, inv; | |
633 | ||
2d53426b DB |
634 | d_val[0] = 0; |
635 | c_val[0] = 0; | |
636 | d_val[1] = 0; | |
637 | c_val[1] = 0; | |
638 | d_val[2] = 0xFF; | |
639 | c_val[2] = 0xFF; | |
698b1515 WT |
640 | |
641 | if (pin == 0) | |
642 | return; | |
643 | ||
644 | inv = (pin < 0); | |
645 | if (inv) | |
646 | pin = -pin; | |
647 | ||
2d53426b DB |
648 | d_bit = 0; |
649 | c_bit = 0; | |
698b1515 WT |
650 | |
651 | switch (pin) { | |
652 | case PIN_STROBE: /* strobe, inverted */ | |
653 | c_bit = PNL_PSTROBE; | |
654 | inv = !inv; | |
655 | break; | |
656 | case PIN_D0...PIN_D7: /* D0 - D7 = 2 - 9 */ | |
657 | d_bit = 1 << (pin - 2); | |
658 | break; | |
659 | case PIN_AUTOLF: /* autofeed, inverted */ | |
660 | c_bit = PNL_PAUTOLF; | |
661 | inv = !inv; | |
662 | break; | |
429ccf05 | 663 | case PIN_INITP: /* init, direct */ |
698b1515 WT |
664 | c_bit = PNL_PINITP; |
665 | break; | |
666 | case PIN_SELECP: /* select_in, inverted */ | |
667 | c_bit = PNL_PSELECP; | |
668 | inv = !inv; | |
669 | break; | |
670 | default: /* unknown pin, ignore */ | |
671 | break; | |
672 | } | |
673 | ||
674 | if (c_bit) { | |
675 | c_val[2] &= ~c_bit; | |
676 | c_val[!inv] = c_bit; | |
677 | } else if (d_bit) { | |
678 | d_val[2] &= ~d_bit; | |
679 | d_val[!inv] = d_bit; | |
680 | } | |
7005b584 WT |
681 | } |
682 | ||
881bf281 AW |
683 | /* |
684 | * send a serial byte to the LCD panel. The caller is responsible for locking | |
685 | * if needed. | |
686 | */ | |
698b1515 WT |
687 | static void lcd_send_serial(int byte) |
688 | { | |
689 | int bit; | |
690 | ||
881bf281 AW |
691 | /* |
692 | * the data bit is set on D0, and the clock on STROBE. | |
693 | * LCD reads D0 on STROBE's rising edge. | |
694 | */ | |
698b1515 | 695 | for (bit = 0; bit < 8; bit++) { |
bea7433b | 696 | clear_bit(LCD_BIT_CL, bits); /* CLK low */ |
6136ac86 | 697 | panel_set_bits(); |
bea7433b DC |
698 | if (byte & 1) { |
699 | set_bit(LCD_BIT_DA, bits); | |
700 | } else { | |
701 | clear_bit(LCD_BIT_DA, bits); | |
702 | } | |
703 | ||
6136ac86 | 704 | panel_set_bits(); |
429ccf05 | 705 | udelay(2); /* maintain the data during 2 us before CLK up */ |
bea7433b | 706 | set_bit(LCD_BIT_CL, bits); /* CLK high */ |
6136ac86 | 707 | panel_set_bits(); |
429ccf05 | 708 | udelay(1); /* maintain the strobe during 1 us */ |
698b1515 WT |
709 | byte >>= 1; |
710 | } | |
7005b584 WT |
711 | } |
712 | ||
713 | /* turn the backlight on or off */ | |
39f8ea46 | 714 | static void lcd_backlight(struct charlcd *charlcd, int on) |
698b1515 | 715 | { |
39f8ea46 GU |
716 | if (lcd.pins.bl == PIN_NONE) |
717 | return; | |
718 | ||
6975e183 | 719 | /* The backlight is activated by setting the AUTOFEED line to +5V */ |
d4d2dbca | 720 | spin_lock_irq(&pprt_lock); |
bea7433b DC |
721 | if (on) |
722 | set_bit(LCD_BIT_BL, bits); | |
723 | else | |
724 | clear_bit(LCD_BIT_BL, bits); | |
6136ac86 | 725 | panel_set_bits(); |
d4d2dbca | 726 | spin_unlock_irq(&pprt_lock); |
7005b584 WT |
727 | } |
728 | ||
729 | /* send a command to the LCD panel in serial mode */ | |
39f8ea46 | 730 | static void lcd_write_cmd_s(struct charlcd *charlcd, int cmd) |
698b1515 | 731 | { |
d4d2dbca | 732 | spin_lock_irq(&pprt_lock); |
698b1515 WT |
733 | lcd_send_serial(0x1F); /* R/W=W, RS=0 */ |
734 | lcd_send_serial(cmd & 0x0F); | |
735 | lcd_send_serial((cmd >> 4) & 0x0F); | |
b64a1cbe | 736 | udelay(40); /* the shortest command takes at least 40 us */ |
d4d2dbca | 737 | spin_unlock_irq(&pprt_lock); |
7005b584 WT |
738 | } |
739 | ||
740 | /* send data to the LCD panel in serial mode */ | |
39f8ea46 | 741 | static void lcd_write_data_s(struct charlcd *charlcd, int data) |
698b1515 | 742 | { |
d4d2dbca | 743 | spin_lock_irq(&pprt_lock); |
698b1515 WT |
744 | lcd_send_serial(0x5F); /* R/W=W, RS=1 */ |
745 | lcd_send_serial(data & 0x0F); | |
746 | lcd_send_serial((data >> 4) & 0x0F); | |
b64a1cbe | 747 | udelay(40); /* the shortest data takes at least 40 us */ |
d4d2dbca | 748 | spin_unlock_irq(&pprt_lock); |
7005b584 WT |
749 | } |
750 | ||
751 | /* send a command to the LCD panel in 8 bits parallel mode */ | |
39f8ea46 | 752 | static void lcd_write_cmd_p8(struct charlcd *charlcd, int cmd) |
698b1515 | 753 | { |
d4d2dbca | 754 | spin_lock_irq(&pprt_lock); |
698b1515 WT |
755 | /* present the data to the data port */ |
756 | w_dtr(pprt, cmd); | |
b64a1cbe | 757 | udelay(20); /* maintain the data during 20 us before the strobe */ |
7005b584 | 758 | |
bea7433b DC |
759 | set_bit(LCD_BIT_E, bits); |
760 | clear_bit(LCD_BIT_RS, bits); | |
761 | clear_bit(LCD_BIT_RW, bits); | |
698b1515 | 762 | set_ctrl_bits(); |
7005b584 | 763 | |
b64a1cbe | 764 | udelay(40); /* maintain the strobe during 40 us */ |
7005b584 | 765 | |
bea7433b | 766 | clear_bit(LCD_BIT_E, bits); |
698b1515 | 767 | set_ctrl_bits(); |
7005b584 | 768 | |
b64a1cbe | 769 | udelay(120); /* the shortest command takes at least 120 us */ |
d4d2dbca | 770 | spin_unlock_irq(&pprt_lock); |
7005b584 WT |
771 | } |
772 | ||
773 | /* send data to the LCD panel in 8 bits parallel mode */ | |
39f8ea46 | 774 | static void lcd_write_data_p8(struct charlcd *charlcd, int data) |
698b1515 | 775 | { |
d4d2dbca | 776 | spin_lock_irq(&pprt_lock); |
698b1515 WT |
777 | /* present the data to the data port */ |
778 | w_dtr(pprt, data); | |
b64a1cbe | 779 | udelay(20); /* maintain the data during 20 us before the strobe */ |
7005b584 | 780 | |
bea7433b DC |
781 | set_bit(LCD_BIT_E, bits); |
782 | set_bit(LCD_BIT_RS, bits); | |
783 | clear_bit(LCD_BIT_RW, bits); | |
698b1515 | 784 | set_ctrl_bits(); |
7005b584 | 785 | |
b64a1cbe | 786 | udelay(40); /* maintain the strobe during 40 us */ |
7005b584 | 787 | |
bea7433b | 788 | clear_bit(LCD_BIT_E, bits); |
698b1515 | 789 | set_ctrl_bits(); |
7005b584 | 790 | |
b64a1cbe | 791 | udelay(45); /* the shortest data takes at least 45 us */ |
d4d2dbca | 792 | spin_unlock_irq(&pprt_lock); |
7005b584 WT |
793 | } |
794 | ||
77943d31 | 795 | /* send a command to the TI LCD panel */ |
39f8ea46 | 796 | static void lcd_write_cmd_tilcd(struct charlcd *charlcd, int cmd) |
77943d31 | 797 | { |
d4d2dbca | 798 | spin_lock_irq(&pprt_lock); |
77943d31 SR |
799 | /* present the data to the control port */ |
800 | w_ctr(pprt, cmd); | |
b64a1cbe | 801 | udelay(60); |
d4d2dbca | 802 | spin_unlock_irq(&pprt_lock); |
77943d31 SR |
803 | } |
804 | ||
805 | /* send data to the TI LCD panel */ | |
39f8ea46 | 806 | static void lcd_write_data_tilcd(struct charlcd *charlcd, int data) |
77943d31 | 807 | { |
d4d2dbca | 808 | spin_lock_irq(&pprt_lock); |
77943d31 SR |
809 | /* present the data to the data port */ |
810 | w_dtr(pprt, data); | |
b64a1cbe | 811 | udelay(60); |
d4d2dbca | 812 | spin_unlock_irq(&pprt_lock); |
77943d31 SR |
813 | } |
814 | ||
7005b584 | 815 | /* fills the display with spaces and resets X/Y */ |
39f8ea46 | 816 | static void lcd_clear_fast_s(struct charlcd *charlcd) |
698b1515 WT |
817 | { |
818 | int pos; | |
c3ed0afc | 819 | |
d4d2dbca | 820 | spin_lock_irq(&pprt_lock); |
39f8ea46 | 821 | for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { |
698b1515 WT |
822 | lcd_send_serial(0x5F); /* R/W=W, RS=1 */ |
823 | lcd_send_serial(' ' & 0x0F); | |
824 | lcd_send_serial((' ' >> 4) & 0x0F); | |
df44f150 | 825 | /* the shortest data takes at least 40 us */ |
4cff7adb | 826 | udelay(40); |
698b1515 | 827 | } |
d4d2dbca | 828 | spin_unlock_irq(&pprt_lock); |
7005b584 WT |
829 | } |
830 | ||
831 | /* fills the display with spaces and resets X/Y */ | |
39f8ea46 | 832 | static void lcd_clear_fast_p8(struct charlcd *charlcd) |
698b1515 WT |
833 | { |
834 | int pos; | |
c3ed0afc | 835 | |
d4d2dbca | 836 | spin_lock_irq(&pprt_lock); |
39f8ea46 | 837 | for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { |
698b1515 WT |
838 | /* present the data to the data port */ |
839 | w_dtr(pprt, ' '); | |
429ccf05 HH |
840 | |
841 | /* maintain the data during 20 us before the strobe */ | |
b64a1cbe | 842 | udelay(20); |
7005b584 | 843 | |
bea7433b DC |
844 | set_bit(LCD_BIT_E, bits); |
845 | set_bit(LCD_BIT_RS, bits); | |
846 | clear_bit(LCD_BIT_RW, bits); | |
698b1515 | 847 | set_ctrl_bits(); |
7005b584 | 848 | |
429ccf05 | 849 | /* maintain the strobe during 40 us */ |
b64a1cbe | 850 | udelay(40); |
7005b584 | 851 | |
bea7433b | 852 | clear_bit(LCD_BIT_E, bits); |
698b1515 | 853 | set_ctrl_bits(); |
7005b584 | 854 | |
429ccf05 | 855 | /* the shortest data takes at least 45 us */ |
b64a1cbe | 856 | udelay(45); |
698b1515 | 857 | } |
d4d2dbca | 858 | spin_unlock_irq(&pprt_lock); |
7005b584 WT |
859 | } |
860 | ||
77943d31 | 861 | /* fills the display with spaces and resets X/Y */ |
39f8ea46 | 862 | static void lcd_clear_fast_tilcd(struct charlcd *charlcd) |
77943d31 SR |
863 | { |
864 | int pos; | |
c3ed0afc | 865 | |
d4d2dbca | 866 | spin_lock_irq(&pprt_lock); |
39f8ea46 | 867 | for (pos = 0; pos < charlcd->height * charlcd->hwidth; pos++) { |
77943d31 SR |
868 | /* present the data to the data port */ |
869 | w_dtr(pprt, ' '); | |
b64a1cbe | 870 | udelay(60); |
77943d31 SR |
871 | } |
872 | ||
d4d2dbca | 873 | spin_unlock_irq(&pprt_lock); |
7005b584 WT |
874 | } |
875 | ||
7b948f13 | 876 | static const struct charlcd_ops charlcd_serial_ops = { |
39f8ea46 GU |
877 | .write_cmd = lcd_write_cmd_s, |
878 | .write_data = lcd_write_data_s, | |
879 | .clear_fast = lcd_clear_fast_s, | |
880 | .backlight = lcd_backlight, | |
881 | }; | |
7005b584 | 882 | |
7b948f13 | 883 | static const struct charlcd_ops charlcd_parallel_ops = { |
39f8ea46 GU |
884 | .write_cmd = lcd_write_cmd_p8, |
885 | .write_data = lcd_write_data_p8, | |
886 | .clear_fast = lcd_clear_fast_p8, | |
887 | .backlight = lcd_backlight, | |
888 | }; | |
7005b584 | 889 | |
7b948f13 | 890 | static const struct charlcd_ops charlcd_tilcd_ops = { |
39f8ea46 GU |
891 | .write_cmd = lcd_write_cmd_tilcd, |
892 | .write_data = lcd_write_data_tilcd, | |
893 | .clear_fast = lcd_clear_fast_tilcd, | |
894 | .backlight = lcd_backlight, | |
895 | }; | |
7005b584 | 896 | |
39f8ea46 GU |
897 | /* initialize the LCD driver */ |
898 | static void lcd_init(void) | |
429ccf05 | 899 | { |
39f8ea46 | 900 | struct charlcd *charlcd; |
429ccf05 | 901 | |
39f8ea46 GU |
902 | charlcd = charlcd_alloc(0); |
903 | if (!charlcd) | |
904 | return; | |
70a8c3eb | 905 | |
8c17893c | 906 | /* |
39f8ea46 GU |
907 | * Init lcd struct with load-time values to preserve exact |
908 | * current functionality (at least for now). | |
8c17893c | 909 | */ |
39f8ea46 GU |
910 | charlcd->height = lcd_height; |
911 | charlcd->width = lcd_width; | |
912 | charlcd->bwidth = lcd_bwidth; | |
913 | charlcd->hwidth = lcd_hwidth; | |
70a8c3eb | 914 | |
87b8e0c8 | 915 | switch (selected_lcd_type) { |
429ccf05 HH |
916 | case LCD_TYPE_OLD: |
917 | /* parallel mode, 8 bits */ | |
8037e2a3 MG |
918 | lcd.proto = LCD_PROTO_PARALLEL; |
919 | lcd.charset = LCD_CHARSET_NORMAL; | |
920 | lcd.pins.e = PIN_STROBE; | |
921 | lcd.pins.rs = PIN_AUTOLF; | |
922 | ||
39f8ea46 GU |
923 | charlcd->width = 40; |
924 | charlcd->bwidth = 40; | |
925 | charlcd->hwidth = 64; | |
926 | charlcd->height = 2; | |
7005b584 | 927 | break; |
429ccf05 HH |
928 | case LCD_TYPE_KS0074: |
929 | /* serial mode, ks0074 */ | |
8037e2a3 MG |
930 | lcd.proto = LCD_PROTO_SERIAL; |
931 | lcd.charset = LCD_CHARSET_KS0074; | |
932 | lcd.pins.bl = PIN_AUTOLF; | |
933 | lcd.pins.cl = PIN_STROBE; | |
934 | lcd.pins.da = PIN_D0; | |
935 | ||
39f8ea46 GU |
936 | charlcd->width = 16; |
937 | charlcd->bwidth = 40; | |
938 | charlcd->hwidth = 16; | |
939 | charlcd->height = 2; | |
7005b584 | 940 | break; |
429ccf05 HH |
941 | case LCD_TYPE_NEXCOM: |
942 | /* parallel mode, 8 bits, generic */ | |
8037e2a3 MG |
943 | lcd.proto = LCD_PROTO_PARALLEL; |
944 | lcd.charset = LCD_CHARSET_NORMAL; | |
945 | lcd.pins.e = PIN_AUTOLF; | |
946 | lcd.pins.rs = PIN_SELECP; | |
947 | lcd.pins.rw = PIN_INITP; | |
948 | ||
39f8ea46 GU |
949 | charlcd->width = 16; |
950 | charlcd->bwidth = 40; | |
951 | charlcd->hwidth = 64; | |
952 | charlcd->height = 2; | |
7005b584 | 953 | break; |
429ccf05 HH |
954 | case LCD_TYPE_CUSTOM: |
955 | /* customer-defined */ | |
8037e2a3 MG |
956 | lcd.proto = DEFAULT_LCD_PROTO; |
957 | lcd.charset = DEFAULT_LCD_CHARSET; | |
7005b584 WT |
958 | /* default geometry will be set later */ |
959 | break; | |
429ccf05 HH |
960 | case LCD_TYPE_HANTRONIX: |
961 | /* parallel mode, 8 bits, hantronix-like */ | |
698b1515 | 962 | default: |
8037e2a3 MG |
963 | lcd.proto = LCD_PROTO_PARALLEL; |
964 | lcd.charset = LCD_CHARSET_NORMAL; | |
965 | lcd.pins.e = PIN_STROBE; | |
966 | lcd.pins.rs = PIN_SELECP; | |
967 | ||
39f8ea46 GU |
968 | charlcd->width = 16; |
969 | charlcd->bwidth = 40; | |
970 | charlcd->hwidth = 64; | |
971 | charlcd->height = 2; | |
7005b584 | 972 | break; |
698b1515 | 973 | } |
7005b584 | 974 | |
8037e2a3 | 975 | /* Overwrite with module params set on loading */ |
1a4b2e3e | 976 | if (lcd_height != NOT_SET) |
39f8ea46 | 977 | charlcd->height = lcd_height; |
1a4b2e3e | 978 | if (lcd_width != NOT_SET) |
39f8ea46 | 979 | charlcd->width = lcd_width; |
1a4b2e3e | 980 | if (lcd_bwidth != NOT_SET) |
39f8ea46 | 981 | charlcd->bwidth = lcd_bwidth; |
1a4b2e3e | 982 | if (lcd_hwidth != NOT_SET) |
39f8ea46 | 983 | charlcd->hwidth = lcd_hwidth; |
1a4b2e3e | 984 | if (lcd_charset != NOT_SET) |
8037e2a3 | 985 | lcd.charset = lcd_charset; |
1a4b2e3e | 986 | if (lcd_proto != NOT_SET) |
8037e2a3 MG |
987 | lcd.proto = lcd_proto; |
988 | if (lcd_e_pin != PIN_NOT_SET) | |
989 | lcd.pins.e = lcd_e_pin; | |
990 | if (lcd_rs_pin != PIN_NOT_SET) | |
991 | lcd.pins.rs = lcd_rs_pin; | |
992 | if (lcd_rw_pin != PIN_NOT_SET) | |
993 | lcd.pins.rw = lcd_rw_pin; | |
994 | if (lcd_cl_pin != PIN_NOT_SET) | |
995 | lcd.pins.cl = lcd_cl_pin; | |
996 | if (lcd_da_pin != PIN_NOT_SET) | |
997 | lcd.pins.da = lcd_da_pin; | |
998 | if (lcd_bl_pin != PIN_NOT_SET) | |
999 | lcd.pins.bl = lcd_bl_pin; | |
1000 | ||
698b1515 | 1001 | /* this is used to catch wrong and default values */ |
39f8ea46 GU |
1002 | if (charlcd->width <= 0) |
1003 | charlcd->width = DEFAULT_LCD_WIDTH; | |
1004 | if (charlcd->bwidth <= 0) | |
1005 | charlcd->bwidth = DEFAULT_LCD_BWIDTH; | |
1006 | if (charlcd->hwidth <= 0) | |
1007 | charlcd->hwidth = DEFAULT_LCD_HWIDTH; | |
1008 | if (charlcd->height <= 0) | |
1009 | charlcd->height = DEFAULT_LCD_HEIGHT; | |
8037e2a3 MG |
1010 | |
1011 | if (lcd.proto == LCD_PROTO_SERIAL) { /* SERIAL */ | |
39f8ea46 | 1012 | charlcd->ops = &charlcd_serial_ops; |
698b1515 | 1013 | |
8037e2a3 MG |
1014 | if (lcd.pins.cl == PIN_NOT_SET) |
1015 | lcd.pins.cl = DEFAULT_LCD_PIN_SCL; | |
1016 | if (lcd.pins.da == PIN_NOT_SET) | |
1017 | lcd.pins.da = DEFAULT_LCD_PIN_SDA; | |
698b1515 | 1018 | |
8037e2a3 | 1019 | } else if (lcd.proto == LCD_PROTO_PARALLEL) { /* PARALLEL */ |
39f8ea46 | 1020 | charlcd->ops = &charlcd_parallel_ops; |
698b1515 | 1021 | |
8037e2a3 MG |
1022 | if (lcd.pins.e == PIN_NOT_SET) |
1023 | lcd.pins.e = DEFAULT_LCD_PIN_E; | |
1024 | if (lcd.pins.rs == PIN_NOT_SET) | |
1025 | lcd.pins.rs = DEFAULT_LCD_PIN_RS; | |
1026 | if (lcd.pins.rw == PIN_NOT_SET) | |
1027 | lcd.pins.rw = DEFAULT_LCD_PIN_RW; | |
77943d31 | 1028 | } else { |
39f8ea46 | 1029 | charlcd->ops = &charlcd_tilcd_ops; |
698b1515 | 1030 | } |
7005b584 | 1031 | |
8037e2a3 MG |
1032 | if (lcd.pins.bl == PIN_NOT_SET) |
1033 | lcd.pins.bl = DEFAULT_LCD_PIN_BL; | |
1034 | ||
1035 | if (lcd.pins.e == PIN_NOT_SET) | |
1036 | lcd.pins.e = PIN_NONE; | |
1037 | if (lcd.pins.rs == PIN_NOT_SET) | |
1038 | lcd.pins.rs = PIN_NONE; | |
1039 | if (lcd.pins.rw == PIN_NOT_SET) | |
1040 | lcd.pins.rw = PIN_NONE; | |
1041 | if (lcd.pins.bl == PIN_NOT_SET) | |
1042 | lcd.pins.bl = PIN_NONE; | |
1043 | if (lcd.pins.cl == PIN_NOT_SET) | |
1044 | lcd.pins.cl = PIN_NONE; | |
1045 | if (lcd.pins.da == PIN_NOT_SET) | |
1046 | lcd.pins.da = PIN_NONE; | |
1047 | ||
1048 | if (lcd.charset == NOT_SET) | |
1049 | lcd.charset = DEFAULT_LCD_CHARSET; | |
1050 | ||
1051 | if (lcd.charset == LCD_CHARSET_KS0074) | |
39f8ea46 | 1052 | charlcd->char_conv = lcd_char_conv_ks0074; |
698b1515 | 1053 | else |
39f8ea46 | 1054 | charlcd->char_conv = NULL; |
698b1515 | 1055 | |
8037e2a3 | 1056 | pin_to_bits(lcd.pins.e, lcd_bits[LCD_PORT_D][LCD_BIT_E], |
698b1515 | 1057 | lcd_bits[LCD_PORT_C][LCD_BIT_E]); |
8037e2a3 | 1058 | pin_to_bits(lcd.pins.rs, lcd_bits[LCD_PORT_D][LCD_BIT_RS], |
698b1515 | 1059 | lcd_bits[LCD_PORT_C][LCD_BIT_RS]); |
8037e2a3 | 1060 | pin_to_bits(lcd.pins.rw, lcd_bits[LCD_PORT_D][LCD_BIT_RW], |
698b1515 | 1061 | lcd_bits[LCD_PORT_C][LCD_BIT_RW]); |
8037e2a3 | 1062 | pin_to_bits(lcd.pins.bl, lcd_bits[LCD_PORT_D][LCD_BIT_BL], |
698b1515 | 1063 | lcd_bits[LCD_PORT_C][LCD_BIT_BL]); |
8037e2a3 | 1064 | pin_to_bits(lcd.pins.cl, lcd_bits[LCD_PORT_D][LCD_BIT_CL], |
698b1515 | 1065 | lcd_bits[LCD_PORT_C][LCD_BIT_CL]); |
8037e2a3 | 1066 | pin_to_bits(lcd.pins.da, lcd_bits[LCD_PORT_D][LCD_BIT_DA], |
698b1515 WT |
1067 | lcd_bits[LCD_PORT_C][LCD_BIT_DA]); |
1068 | ||
39f8ea46 | 1069 | lcd.charlcd = charlcd; |
6d8b588c | 1070 | lcd.initialized = true; |
7005b584 WT |
1071 | } |
1072 | ||
7005b584 WT |
1073 | /* |
1074 | * These are the file operation function for user access to /dev/keypad | |
1075 | */ | |
1076 | ||
698b1515 | 1077 | static ssize_t keypad_read(struct file *file, |
cce75f41 | 1078 | char __user *buf, size_t count, loff_t *ppos) |
698b1515 | 1079 | { |
698b1515 | 1080 | unsigned i = *ppos; |
cce75f41 | 1081 | char __user *tmp = buf; |
7005b584 | 1082 | |
698b1515 WT |
1083 | if (keypad_buflen == 0) { |
1084 | if (file->f_flags & O_NONBLOCK) | |
1085 | return -EAGAIN; | |
7005b584 | 1086 | |
310df69c AB |
1087 | if (wait_event_interruptible(keypad_read_wait, |
1088 | keypad_buflen != 0)) | |
698b1515 WT |
1089 | return -EINTR; |
1090 | } | |
7005b584 | 1091 | |
429ccf05 HH |
1092 | for (; count-- > 0 && (keypad_buflen > 0); |
1093 | ++i, ++tmp, --keypad_buflen) { | |
698b1515 WT |
1094 | put_user(keypad_buffer[keypad_start], tmp); |
1095 | keypad_start = (keypad_start + 1) % KEYPAD_BUFFER; | |
1096 | } | |
1097 | *ppos = i; | |
7005b584 | 1098 | |
698b1515 | 1099 | return tmp - buf; |
7005b584 WT |
1100 | } |
1101 | ||
698b1515 WT |
1102 | static int keypad_open(struct inode *inode, struct file *file) |
1103 | { | |
93dc1774 WT |
1104 | int ret; |
1105 | ||
1106 | ret = -EBUSY; | |
f4757af8 | 1107 | if (!atomic_dec_and_test(&keypad_available)) |
93dc1774 | 1108 | goto fail; /* open only once at a time */ |
7005b584 | 1109 | |
93dc1774 | 1110 | ret = -EPERM; |
698b1515 | 1111 | if (file->f_mode & FMODE_WRITE) /* device is read-only */ |
93dc1774 | 1112 | goto fail; |
7005b584 | 1113 | |
698b1515 | 1114 | keypad_buflen = 0; /* flush the buffer on opening */ |
698b1515 | 1115 | return 0; |
93dc1774 WT |
1116 | fail: |
1117 | atomic_inc(&keypad_available); | |
1118 | return ret; | |
7005b584 WT |
1119 | } |
1120 | ||
698b1515 WT |
1121 | static int keypad_release(struct inode *inode, struct file *file) |
1122 | { | |
f4757af8 | 1123 | atomic_inc(&keypad_available); |
698b1515 | 1124 | return 0; |
7005b584 WT |
1125 | } |
1126 | ||
429ccf05 | 1127 | static const struct file_operations keypad_fops = { |
698b1515 WT |
1128 | .read = keypad_read, /* read */ |
1129 | .open = keypad_open, /* open */ | |
1130 | .release = keypad_release, /* close */ | |
6038f373 | 1131 | .llseek = default_llseek, |
7005b584 WT |
1132 | }; |
1133 | ||
1134 | static struct miscdevice keypad_dev = { | |
6c3773de MG |
1135 | .minor = KEYPAD_MINOR, |
1136 | .name = "keypad", | |
1137 | .fops = &keypad_fops, | |
7005b584 WT |
1138 | }; |
1139 | ||
36d2041a | 1140 | static void keypad_send_key(const char *string, int max_len) |
698b1515 | 1141 | { |
698b1515 | 1142 | /* send the key to the device only if a process is attached to it. */ |
f4757af8 | 1143 | if (!atomic_read(&keypad_available)) { |
698b1515 WT |
1144 | while (max_len-- && keypad_buflen < KEYPAD_BUFFER && *string) { |
1145 | keypad_buffer[(keypad_start + keypad_buflen++) % | |
1146 | KEYPAD_BUFFER] = *string++; | |
1147 | } | |
1148 | wake_up_interruptible(&keypad_read_wait); | |
7005b584 | 1149 | } |
7005b584 WT |
1150 | } |
1151 | ||
429ccf05 HH |
1152 | /* this function scans all the bits involving at least one logical signal, |
1153 | * and puts the results in the bitfield "phys_read" (one bit per established | |
1154 | * contact), and sets "phys_read_prev" to "phys_read". | |
7005b584 | 1155 | * |
429ccf05 HH |
1156 | * Note: to debounce input signals, we will only consider as switched a signal |
1157 | * which is stable across 2 measures. Signals which are different between two | |
1158 | * reads will be kept as they previously were in their logical form (phys_prev). | |
1159 | * A signal which has just switched will have a 1 in | |
1160 | * (phys_read ^ phys_read_prev). | |
7005b584 | 1161 | */ |
698b1515 WT |
1162 | static void phys_scan_contacts(void) |
1163 | { | |
1164 | int bit, bitval; | |
1165 | char oldval; | |
1166 | char bitmask; | |
1167 | char gndmask; | |
1168 | ||
1169 | phys_prev = phys_curr; | |
1170 | phys_read_prev = phys_read; | |
1171 | phys_read = 0; /* flush all signals */ | |
1172 | ||
429ccf05 HH |
1173 | /* keep track of old value, with all outputs disabled */ |
1174 | oldval = r_dtr(pprt) | scan_mask_o; | |
1175 | /* activate all keyboard outputs (active low) */ | |
1176 | w_dtr(pprt, oldval & ~scan_mask_o); | |
1177 | ||
1178 | /* will have a 1 for each bit set to gnd */ | |
1179 | bitmask = PNL_PINPUT(r_str(pprt)) & scan_mask_i; | |
1180 | /* disable all matrix signals */ | |
1181 | w_dtr(pprt, oldval); | |
698b1515 WT |
1182 | |
1183 | /* now that all outputs are cleared, the only active input bits are | |
1184 | * directly connected to the ground | |
7005b584 | 1185 | */ |
698b1515 | 1186 | |
429ccf05 HH |
1187 | /* 1 for each grounded input */ |
1188 | gndmask = PNL_PINPUT(r_str(pprt)) & scan_mask_i; | |
1189 | ||
1190 | /* grounded inputs are signals 40-44 */ | |
35fe0872 | 1191 | phys_read |= (__u64)gndmask << 40; |
7005b584 | 1192 | |
698b1515 | 1193 | if (bitmask != gndmask) { |
8c17893c NB |
1194 | /* |
1195 | * since clearing the outputs changed some inputs, we know | |
429ccf05 HH |
1196 | * that some input signals are currently tied to some outputs. |
1197 | * So we'll scan them. | |
698b1515 WT |
1198 | */ |
1199 | for (bit = 0; bit < 8; bit++) { | |
79f2af62 | 1200 | bitval = BIT(bit); |
7005b584 | 1201 | |
698b1515 WT |
1202 | if (!(scan_mask_o & bitval)) /* skip unused bits */ |
1203 | continue; | |
1204 | ||
1205 | w_dtr(pprt, oldval & ~bitval); /* enable this output */ | |
1206 | bitmask = PNL_PINPUT(r_str(pprt)) & ~gndmask; | |
35fe0872 | 1207 | phys_read |= (__u64)bitmask << (5 * bit); |
698b1515 WT |
1208 | } |
1209 | w_dtr(pprt, oldval); /* disable all outputs */ | |
7005b584 | 1210 | } |
8c17893c NB |
1211 | /* |
1212 | * this is easy: use old bits when they are flapping, | |
1213 | * use new ones when stable | |
1214 | */ | |
429ccf05 HH |
1215 | phys_curr = (phys_prev & (phys_read ^ phys_read_prev)) | |
1216 | (phys_read & ~(phys_read ^ phys_read_prev)); | |
1217 | } | |
1218 | ||
1219 | static inline int input_state_high(struct logical_input *input) | |
1220 | { | |
1221 | #if 0 | |
1222 | /* FIXME: | |
1223 | * this is an invalid test. It tries to catch | |
1224 | * transitions from single-key to multiple-key, but | |
1225 | * doesn't take into account the contacts polarity. | |
1226 | * The only solution to the problem is to parse keys | |
1227 | * from the most complex to the simplest combinations, | |
1228 | * and mark them as 'caught' once a combination | |
1229 | * matches, then unmatch it for all other ones. | |
1230 | */ | |
1231 | ||
1232 | /* try to catch dangerous transitions cases : | |
1233 | * someone adds a bit, so this signal was a false | |
1234 | * positive resulting from a transition. We should | |
1235 | * invalidate the signal immediately and not call the | |
1236 | * release function. | |
1237 | * eg: 0 -(press A)-> A -(press B)-> AB : don't match A's release. | |
1238 | */ | |
fdf4a494 DB |
1239 | if (((phys_prev & input->mask) == input->value) && |
1240 | ((phys_curr & input->mask) > input->value)) { | |
429ccf05 HH |
1241 | input->state = INPUT_ST_LOW; /* invalidate */ |
1242 | return 1; | |
1243 | } | |
1244 | #endif | |
1245 | ||
1246 | if ((phys_curr & input->mask) == input->value) { | |
1247 | if ((input->type == INPUT_TYPE_STD) && | |
1248 | (input->high_timer == 0)) { | |
1249 | input->high_timer++; | |
b565b3fb | 1250 | if (input->u.std.press_fct) |
429ccf05 HH |
1251 | input->u.std.press_fct(input->u.std.press_data); |
1252 | } else if (input->type == INPUT_TYPE_KBD) { | |
1253 | /* will turn on the light */ | |
1254 | keypressed = 1; | |
1255 | ||
1256 | if (input->high_timer == 0) { | |
1257 | char *press_str = input->u.kbd.press_str; | |
c3ed0afc | 1258 | |
e6626de5 JC |
1259 | if (press_str[0]) { |
1260 | int s = sizeof(input->u.kbd.press_str); | |
c3ed0afc | 1261 | |
e6626de5 JC |
1262 | keypad_send_key(press_str, s); |
1263 | } | |
429ccf05 HH |
1264 | } |
1265 | ||
1266 | if (input->u.kbd.repeat_str[0]) { | |
1267 | char *repeat_str = input->u.kbd.repeat_str; | |
c3ed0afc | 1268 | |
429ccf05 | 1269 | if (input->high_timer >= KEYPAD_REP_START) { |
e6626de5 | 1270 | int s = sizeof(input->u.kbd.repeat_str); |
c3ed0afc | 1271 | |
429ccf05 | 1272 | input->high_timer -= KEYPAD_REP_DELAY; |
e6626de5 | 1273 | keypad_send_key(repeat_str, s); |
429ccf05 HH |
1274 | } |
1275 | /* we will need to come back here soon */ | |
1276 | inputs_stable = 0; | |
1277 | } | |
1278 | ||
1279 | if (input->high_timer < 255) | |
1280 | input->high_timer++; | |
1281 | } | |
1282 | return 1; | |
429ccf05 | 1283 | } |
083b3638 VH |
1284 | |
1285 | /* else signal falling down. Let's fall through. */ | |
1286 | input->state = INPUT_ST_FALLING; | |
1287 | input->fall_timer = 0; | |
1288 | ||
429ccf05 HH |
1289 | return 0; |
1290 | } | |
1291 | ||
1292 | static inline void input_state_falling(struct logical_input *input) | |
1293 | { | |
1294 | #if 0 | |
1295 | /* FIXME !!! same comment as in input_state_high */ | |
fdf4a494 DB |
1296 | if (((phys_prev & input->mask) == input->value) && |
1297 | ((phys_curr & input->mask) > input->value)) { | |
429ccf05 HH |
1298 | input->state = INPUT_ST_LOW; /* invalidate */ |
1299 | return; | |
1300 | } | |
1301 | #endif | |
1302 | ||
1303 | if ((phys_curr & input->mask) == input->value) { | |
1304 | if (input->type == INPUT_TYPE_KBD) { | |
1305 | /* will turn on the light */ | |
1306 | keypressed = 1; | |
1307 | ||
1308 | if (input->u.kbd.repeat_str[0]) { | |
1309 | char *repeat_str = input->u.kbd.repeat_str; | |
c3ed0afc | 1310 | |
e6626de5 JC |
1311 | if (input->high_timer >= KEYPAD_REP_START) { |
1312 | int s = sizeof(input->u.kbd.repeat_str); | |
c3ed0afc | 1313 | |
429ccf05 | 1314 | input->high_timer -= KEYPAD_REP_DELAY; |
e6626de5 JC |
1315 | keypad_send_key(repeat_str, s); |
1316 | } | |
429ccf05 HH |
1317 | /* we will need to come back here soon */ |
1318 | inputs_stable = 0; | |
1319 | } | |
1320 | ||
1321 | if (input->high_timer < 255) | |
1322 | input->high_timer++; | |
1323 | } | |
1324 | input->state = INPUT_ST_HIGH; | |
1325 | } else if (input->fall_timer >= input->fall_time) { | |
1326 | /* call release event */ | |
1327 | if (input->type == INPUT_TYPE_STD) { | |
1328 | void (*release_fct)(int) = input->u.std.release_fct; | |
c3ed0afc | 1329 | |
b565b3fb | 1330 | if (release_fct) |
429ccf05 HH |
1331 | release_fct(input->u.std.release_data); |
1332 | } else if (input->type == INPUT_TYPE_KBD) { | |
1333 | char *release_str = input->u.kbd.release_str; | |
c3ed0afc | 1334 | |
e6626de5 JC |
1335 | if (release_str[0]) { |
1336 | int s = sizeof(input->u.kbd.release_str); | |
c3ed0afc | 1337 | |
e6626de5 JC |
1338 | keypad_send_key(release_str, s); |
1339 | } | |
429ccf05 HH |
1340 | } |
1341 | ||
1342 | input->state = INPUT_ST_LOW; | |
1343 | } else { | |
1344 | input->fall_timer++; | |
1345 | inputs_stable = 0; | |
1346 | } | |
7005b584 WT |
1347 | } |
1348 | ||
698b1515 WT |
1349 | static void panel_process_inputs(void) |
1350 | { | |
698b1515 | 1351 | struct logical_input *input; |
7005b584 | 1352 | |
698b1515 WT |
1353 | keypressed = 0; |
1354 | inputs_stable = 1; | |
4654bdb6 | 1355 | list_for_each_entry(input, &logical_inputs, list) { |
698b1515 WT |
1356 | switch (input->state) { |
1357 | case INPUT_ST_LOW: | |
1358 | if ((phys_curr & input->mask) != input->value) | |
1359 | break; | |
429ccf05 HH |
1360 | /* if all needed ones were already set previously, |
1361 | * this means that this logical signal has been | |
1362 | * activated by the releasing of another combined | |
1363 | * signal, so we don't want to match. | |
1364 | * eg: AB -(release B)-> A -(release A)-> 0 : | |
1365 | * don't match A. | |
698b1515 WT |
1366 | */ |
1367 | if ((phys_prev & input->mask) == input->value) | |
1368 | break; | |
1369 | input->rise_timer = 0; | |
1370 | input->state = INPUT_ST_RISING; | |
5617c599 | 1371 | /* fall through */ |
698b1515 WT |
1372 | case INPUT_ST_RISING: |
1373 | if ((phys_curr & input->mask) != input->value) { | |
1374 | input->state = INPUT_ST_LOW; | |
1375 | break; | |
1376 | } | |
1377 | if (input->rise_timer < input->rise_time) { | |
1378 | inputs_stable = 0; | |
1379 | input->rise_timer++; | |
1380 | break; | |
1381 | } | |
1382 | input->high_timer = 0; | |
1383 | input->state = INPUT_ST_HIGH; | |
5617c599 | 1384 | /* fall through */ |
698b1515 | 1385 | case INPUT_ST_HIGH: |
429ccf05 | 1386 | if (input_state_high(input)) |
698b1515 | 1387 | break; |
5617c599 | 1388 | /* fall through */ |
698b1515 | 1389 | case INPUT_ST_FALLING: |
429ccf05 | 1390 | input_state_falling(input); |
698b1515 WT |
1391 | } |
1392 | } | |
1393 | } | |
7005b584 | 1394 | |
607a6301 | 1395 | static void panel_scan_timer(struct timer_list *unused) |
698b1515 | 1396 | { |
a8b2580b | 1397 | if (keypad.enabled && keypad_initialized) { |
d4d2dbca | 1398 | if (spin_trylock_irq(&pprt_lock)) { |
698b1515 | 1399 | phys_scan_contacts(); |
429ccf05 HH |
1400 | |
1401 | /* no need for the parport anymore */ | |
d4d2dbca | 1402 | spin_unlock_irq(&pprt_lock); |
7005b584 WT |
1403 | } |
1404 | ||
698b1515 WT |
1405 | if (!inputs_stable || phys_curr != phys_prev) |
1406 | panel_process_inputs(); | |
7005b584 | 1407 | } |
7005b584 | 1408 | |
fda4ae18 | 1409 | if (keypressed && lcd.enabled && lcd.initialized) |
39f8ea46 | 1410 | charlcd_poke(lcd.charlcd); |
698b1515 WT |
1411 | |
1412 | mod_timer(&scan_timer, jiffies + INPUT_POLL_TIME); | |
7005b584 WT |
1413 | } |
1414 | ||
698b1515 WT |
1415 | static void init_scan_timer(void) |
1416 | { | |
b565b3fb | 1417 | if (scan_timer.function) |
698b1515 WT |
1418 | return; /* already started */ |
1419 | ||
607a6301 | 1420 | timer_setup(&scan_timer, panel_scan_timer, 0); |
698b1515 | 1421 | scan_timer.expires = jiffies + INPUT_POLL_TIME; |
698b1515 | 1422 | add_timer(&scan_timer); |
7005b584 WT |
1423 | } |
1424 | ||
1425 | /* converts a name of the form "({BbAaPpSsEe}{01234567-})*" to a series of bits. | |
429ccf05 HH |
1426 | * if <omask> or <imask> are non-null, they will be or'ed with the bits |
1427 | * corresponding to out and in bits respectively. | |
7005b584 WT |
1428 | * returns 1 if ok, 0 if error (in which case, nothing is written). |
1429 | */ | |
35fe0872 | 1430 | static u8 input_name2mask(const char *name, __u64 *mask, __u64 *value, |
d938e1eb | 1431 | u8 *imask, u8 *omask) |
698b1515 | 1432 | { |
8aa7307b | 1433 | const char sigtab[] = "EeSsPpAaBb"; |
d938e1eb | 1434 | u8 im, om; |
35fe0872 | 1435 | __u64 m, v; |
698b1515 | 1436 | |
d12f27e8 KS |
1437 | om = 0; |
1438 | im = 0; | |
2d53426b DB |
1439 | m = 0ULL; |
1440 | v = 0ULL; | |
698b1515 WT |
1441 | while (*name) { |
1442 | int in, out, bit, neg; | |
8aa7307b | 1443 | const char *idx; |
c3ed0afc | 1444 | |
8aa7307b KS |
1445 | idx = strchr(sigtab, *name); |
1446 | if (!idx) | |
698b1515 | 1447 | return 0; /* input name not found */ |
8aa7307b KS |
1448 | |
1449 | in = idx - sigtab; | |
698b1515 WT |
1450 | neg = (in & 1); /* odd (lower) names are negated */ |
1451 | in >>= 1; | |
79f2af62 | 1452 | im |= BIT(in); |
698b1515 WT |
1453 | |
1454 | name++; | |
52ebf93f | 1455 | if (*name >= '0' && *name <= '7') { |
698b1515 | 1456 | out = *name - '0'; |
79f2af62 | 1457 | om |= BIT(out); |
3ac76904 | 1458 | } else if (*name == '-') { |
698b1515 | 1459 | out = 8; |
3ac76904 | 1460 | } else { |
698b1515 | 1461 | return 0; /* unknown bit name */ |
3ac76904 | 1462 | } |
698b1515 WT |
1463 | |
1464 | bit = (out * 5) + in; | |
1465 | ||
1466 | m |= 1ULL << bit; | |
1467 | if (!neg) | |
1468 | v |= 1ULL << bit; | |
1469 | name++; | |
7005b584 | 1470 | } |
698b1515 WT |
1471 | *mask = m; |
1472 | *value = v; | |
1473 | if (imask) | |
1474 | *imask |= im; | |
1475 | if (omask) | |
1476 | *omask |= om; | |
1477 | return 1; | |
7005b584 WT |
1478 | } |
1479 | ||
1480 | /* tries to bind a key to the signal name <name>. The key will send the | |
1481 | * strings <press>, <repeat>, <release> for these respective events. | |
1482 | * Returns the pointer to the new key if ok, NULL if the key could not be bound. | |
1483 | */ | |
36d2041a PH |
1484 | static struct logical_input *panel_bind_key(const char *name, const char *press, |
1485 | const char *repeat, | |
1486 | const char *release) | |
698b1515 WT |
1487 | { |
1488 | struct logical_input *key; | |
1489 | ||
fdf4a494 | 1490 | key = kzalloc(sizeof(*key), GFP_KERNEL); |
eb073a9b | 1491 | if (!key) |
698b1515 | 1492 | return NULL; |
eb073a9b | 1493 | |
698b1515 | 1494 | if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i, |
cb46f472 KV |
1495 | &scan_mask_o)) { |
1496 | kfree(key); | |
698b1515 | 1497 | return NULL; |
cb46f472 | 1498 | } |
698b1515 WT |
1499 | |
1500 | key->type = INPUT_TYPE_KBD; | |
1501 | key->state = INPUT_ST_LOW; | |
1502 | key->rise_time = 1; | |
1503 | key->fall_time = 1; | |
7005b584 | 1504 | |
698b1515 WT |
1505 | strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str)); |
1506 | strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str)); | |
1507 | strncpy(key->u.kbd.release_str, release, | |
1508 | sizeof(key->u.kbd.release_str)); | |
1509 | list_add(&key->list, &logical_inputs); | |
1510 | return key; | |
7005b584 WT |
1511 | } |
1512 | ||
63023177 | 1513 | #if 0 |
7005b584 WT |
1514 | /* tries to bind a callback function to the signal name <name>. The function |
1515 | * <press_fct> will be called with the <press_data> arg when the signal is | |
1516 | * activated, and so on for <release_fct>/<release_data> | |
429ccf05 HH |
1517 | * Returns the pointer to the new signal if ok, NULL if the signal could not |
1518 | * be bound. | |
7005b584 WT |
1519 | */ |
1520 | static struct logical_input *panel_bind_callback(char *name, | |
68d386bf | 1521 | void (*press_fct)(int), |
698b1515 | 1522 | int press_data, |
68d386bf | 1523 | void (*release_fct)(int), |
698b1515 WT |
1524 | int release_data) |
1525 | { | |
1526 | struct logical_input *callback; | |
1527 | ||
fdf4a494 | 1528 | callback = kmalloc(sizeof(*callback), GFP_KERNEL); |
eb073a9b | 1529 | if (!callback) |
698b1515 | 1530 | return NULL; |
eb073a9b | 1531 | |
698b1515 WT |
1532 | memset(callback, 0, sizeof(struct logical_input)); |
1533 | if (!input_name2mask(name, &callback->mask, &callback->value, | |
1534 | &scan_mask_i, &scan_mask_o)) | |
1535 | return NULL; | |
1536 | ||
1537 | callback->type = INPUT_TYPE_STD; | |
1538 | callback->state = INPUT_ST_LOW; | |
1539 | callback->rise_time = 1; | |
1540 | callback->fall_time = 1; | |
1541 | callback->u.std.press_fct = press_fct; | |
1542 | callback->u.std.press_data = press_data; | |
1543 | callback->u.std.release_fct = release_fct; | |
1544 | callback->u.std.release_data = release_data; | |
1545 | list_add(&callback->list, &logical_inputs); | |
1546 | return callback; | |
7005b584 | 1547 | } |
63023177 | 1548 | #endif |
7005b584 | 1549 | |
698b1515 WT |
1550 | static void keypad_init(void) |
1551 | { | |
1552 | int keynum; | |
c3ed0afc | 1553 | |
698b1515 WT |
1554 | init_waitqueue_head(&keypad_read_wait); |
1555 | keypad_buflen = 0; /* flushes any eventual noisy keystroke */ | |
7005b584 | 1556 | |
698b1515 | 1557 | /* Let's create all known keys */ |
7005b584 | 1558 | |
698b1515 WT |
1559 | for (keynum = 0; keypad_profile[keynum][0][0]; keynum++) { |
1560 | panel_bind_key(keypad_profile[keynum][0], | |
1561 | keypad_profile[keynum][1], | |
1562 | keypad_profile[keynum][2], | |
1563 | keypad_profile[keynum][3]); | |
1564 | } | |
7005b584 | 1565 | |
698b1515 WT |
1566 | init_scan_timer(); |
1567 | keypad_initialized = 1; | |
7005b584 WT |
1568 | } |
1569 | ||
7005b584 WT |
1570 | /**************************************************/ |
1571 | /* device initialization */ | |
1572 | /**************************************************/ | |
1573 | ||
698b1515 | 1574 | static void panel_attach(struct parport *port) |
7005b584 | 1575 | { |
9be83c0a SM |
1576 | struct pardev_cb panel_cb; |
1577 | ||
698b1515 WT |
1578 | if (port->number != parport) |
1579 | return; | |
1580 | ||
1581 | if (pprt) { | |
eb073a9b TY |
1582 | pr_err("%s: port->number=%d parport=%d, already registered!\n", |
1583 | __func__, port->number, parport); | |
698b1515 WT |
1584 | return; |
1585 | } | |
1586 | ||
9be83c0a SM |
1587 | memset(&panel_cb, 0, sizeof(panel_cb)); |
1588 | panel_cb.private = &pprt; | |
1589 | /* panel_cb.flags = 0 should be PARPORT_DEV_EXCL? */ | |
1590 | ||
1591 | pprt = parport_register_dev_model(port, "panel", &panel_cb, 0); | |
b565b3fb | 1592 | if (!pprt) { |
eb073a9b TY |
1593 | pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n", |
1594 | __func__, port->number, parport); | |
10f3f5b7 KV |
1595 | return; |
1596 | } | |
698b1515 WT |
1597 | |
1598 | if (parport_claim(pprt)) { | |
eb073a9b TY |
1599 | pr_err("could not claim access to parport%d. Aborting.\n", |
1600 | parport); | |
10f3f5b7 | 1601 | goto err_unreg_device; |
698b1515 WT |
1602 | } |
1603 | ||
429ccf05 HH |
1604 | /* must init LCD first, just in case an IRQ from the keypad is |
1605 | * generated at keypad init | |
1606 | */ | |
a8b2580b | 1607 | if (lcd.enabled) { |
698b1515 | 1608 | lcd_init(); |
39f8ea46 | 1609 | if (!lcd.charlcd || charlcd_register(lcd.charlcd)) |
10f3f5b7 | 1610 | goto err_unreg_device; |
698b1515 WT |
1611 | } |
1612 | ||
a8b2580b | 1613 | if (keypad.enabled) { |
698b1515 | 1614 | keypad_init(); |
10f3f5b7 KV |
1615 | if (misc_register(&keypad_dev)) |
1616 | goto err_lcd_unreg; | |
698b1515 | 1617 | } |
10f3f5b7 KV |
1618 | return; |
1619 | ||
1620 | err_lcd_unreg: | |
a8b2580b | 1621 | if (lcd.enabled) |
39f8ea46 | 1622 | charlcd_unregister(lcd.charlcd); |
10f3f5b7 | 1623 | err_unreg_device: |
39f8ea46 GU |
1624 | kfree(lcd.charlcd); |
1625 | lcd.charlcd = NULL; | |
10f3f5b7 KV |
1626 | parport_unregister_device(pprt); |
1627 | pprt = NULL; | |
7005b584 WT |
1628 | } |
1629 | ||
698b1515 | 1630 | static void panel_detach(struct parport *port) |
7005b584 | 1631 | { |
698b1515 WT |
1632 | if (port->number != parport) |
1633 | return; | |
1634 | ||
1635 | if (!pprt) { | |
eb073a9b TY |
1636 | pr_err("%s: port->number=%d parport=%d, nothing to unregister.\n", |
1637 | __func__, port->number, parport); | |
698b1515 WT |
1638 | return; |
1639 | } | |
b565b3fb | 1640 | if (scan_timer.function) |
7d98c63e | 1641 | del_timer_sync(&scan_timer); |
698b1515 | 1642 | |
3f77b439 GU |
1643 | if (keypad.enabled) { |
1644 | misc_deregister(&keypad_dev); | |
1645 | keypad_initialized = 0; | |
1646 | } | |
698b1515 | 1647 | |
3f77b439 | 1648 | if (lcd.enabled) { |
39f8ea46 | 1649 | charlcd_unregister(lcd.charlcd); |
3f77b439 | 1650 | lcd.initialized = false; |
39f8ea46 GU |
1651 | kfree(lcd.charlcd); |
1652 | lcd.charlcd = NULL; | |
0b0595bf | 1653 | } |
3f77b439 GU |
1654 | |
1655 | /* TODO: free all input signals */ | |
1656 | parport_release(pprt); | |
1657 | parport_unregister_device(pprt); | |
1658 | pprt = NULL; | |
7005b584 WT |
1659 | } |
1660 | ||
1661 | static struct parport_driver panel_driver = { | |
698b1515 | 1662 | .name = "panel", |
9be83c0a | 1663 | .match_port = panel_attach, |
698b1515 | 1664 | .detach = panel_detach, |
9be83c0a | 1665 | .devmodel = true, |
7005b584 WT |
1666 | }; |
1667 | ||
1668 | /* init function */ | |
d9114767 | 1669 | static int __init panel_init_module(void) |
698b1515 | 1670 | { |
e134201b | 1671 | int selected_keypad_type = NOT_SET, err; |
698b1515 | 1672 | |
698b1515 WT |
1673 | /* take care of an eventual profile */ |
1674 | switch (profile) { | |
429ccf05 HH |
1675 | case PANEL_PROFILE_CUSTOM: |
1676 | /* custom profile */ | |
87b8e0c8 MG |
1677 | selected_keypad_type = DEFAULT_KEYPAD_TYPE; |
1678 | selected_lcd_type = DEFAULT_LCD_TYPE; | |
698b1515 | 1679 | break; |
429ccf05 HH |
1680 | case PANEL_PROFILE_OLD: |
1681 | /* 8 bits, 2*16, old keypad */ | |
87b8e0c8 MG |
1682 | selected_keypad_type = KEYPAD_TYPE_OLD; |
1683 | selected_lcd_type = LCD_TYPE_OLD; | |
1684 | ||
1685 | /* TODO: This two are a little hacky, sort it out later */ | |
2d35bcf6 | 1686 | if (lcd_width == NOT_SET) |
698b1515 | 1687 | lcd_width = 16; |
2d35bcf6 | 1688 | if (lcd_hwidth == NOT_SET) |
698b1515 WT |
1689 | lcd_hwidth = 16; |
1690 | break; | |
429ccf05 HH |
1691 | case PANEL_PROFILE_NEW: |
1692 | /* serial, 2*16, new keypad */ | |
87b8e0c8 MG |
1693 | selected_keypad_type = KEYPAD_TYPE_NEW; |
1694 | selected_lcd_type = LCD_TYPE_KS0074; | |
698b1515 | 1695 | break; |
429ccf05 HH |
1696 | case PANEL_PROFILE_HANTRONIX: |
1697 | /* 8 bits, 2*16 hantronix-like, no keypad */ | |
87b8e0c8 MG |
1698 | selected_keypad_type = KEYPAD_TYPE_NONE; |
1699 | selected_lcd_type = LCD_TYPE_HANTRONIX; | |
698b1515 | 1700 | break; |
429ccf05 HH |
1701 | case PANEL_PROFILE_NEXCOM: |
1702 | /* generic 8 bits, 2*16, nexcom keypad, eg. Nexcom. */ | |
87b8e0c8 MG |
1703 | selected_keypad_type = KEYPAD_TYPE_NEXCOM; |
1704 | selected_lcd_type = LCD_TYPE_NEXCOM; | |
698b1515 | 1705 | break; |
429ccf05 HH |
1706 | case PANEL_PROFILE_LARGE: |
1707 | /* 8 bits, 2*40, old keypad */ | |
87b8e0c8 MG |
1708 | selected_keypad_type = KEYPAD_TYPE_OLD; |
1709 | selected_lcd_type = LCD_TYPE_OLD; | |
698b1515 WT |
1710 | break; |
1711 | } | |
1712 | ||
87b8e0c8 MG |
1713 | /* |
1714 | * Overwrite selection with module param values (both keypad and lcd), | |
1715 | * where the deprecated params have lower prio. | |
1716 | */ | |
1a4b2e3e | 1717 | if (keypad_enabled != NOT_SET) |
87b8e0c8 | 1718 | selected_keypad_type = keypad_enabled; |
1a4b2e3e | 1719 | if (keypad_type != NOT_SET) |
87b8e0c8 MG |
1720 | selected_keypad_type = keypad_type; |
1721 | ||
1722 | keypad.enabled = (selected_keypad_type > 0); | |
1723 | ||
1a4b2e3e | 1724 | if (lcd_enabled != NOT_SET) |
87b8e0c8 | 1725 | selected_lcd_type = lcd_enabled; |
1a4b2e3e | 1726 | if (lcd_type != NOT_SET) |
87b8e0c8 MG |
1727 | selected_lcd_type = lcd_type; |
1728 | ||
1729 | lcd.enabled = (selected_lcd_type > 0); | |
698b1515 | 1730 | |
733345ec SM |
1731 | if (lcd.enabled) { |
1732 | /* | |
1733 | * Init lcd struct with load-time values to preserve exact | |
1734 | * current functionality (at least for now). | |
1735 | */ | |
733345ec SM |
1736 | lcd.charset = lcd_charset; |
1737 | lcd.proto = lcd_proto; | |
1738 | lcd.pins.e = lcd_e_pin; | |
1739 | lcd.pins.rs = lcd_rs_pin; | |
1740 | lcd.pins.rw = lcd_rw_pin; | |
1741 | lcd.pins.cl = lcd_cl_pin; | |
1742 | lcd.pins.da = lcd_da_pin; | |
1743 | lcd.pins.bl = lcd_bl_pin; | |
733345ec SM |
1744 | } |
1745 | ||
87b8e0c8 | 1746 | switch (selected_keypad_type) { |
698b1515 WT |
1747 | case KEYPAD_TYPE_OLD: |
1748 | keypad_profile = old_keypad_profile; | |
1749 | break; | |
1750 | case KEYPAD_TYPE_NEW: | |
1751 | keypad_profile = new_keypad_profile; | |
1752 | break; | |
1753 | case KEYPAD_TYPE_NEXCOM: | |
1754 | keypad_profile = nexcom_keypad_profile; | |
1755 | break; | |
1756 | default: | |
1757 | keypad_profile = NULL; | |
1758 | break; | |
1759 | } | |
1760 | ||
a8b2580b | 1761 | if (!lcd.enabled && !keypad.enabled) { |
f43de77c | 1762 | /* no device enabled, let's exit */ |
30f468b2 | 1763 | pr_err("panel driver disabled.\n"); |
698b1515 | 1764 | return -ENODEV; |
7005b584 | 1765 | } |
7005b584 | 1766 | |
e134201b SM |
1767 | err = parport_register_driver(&panel_driver); |
1768 | if (err) { | |
f43de77c | 1769 | pr_err("could not register with parport. Aborting.\n"); |
e134201b | 1770 | return err; |
f43de77c SM |
1771 | } |
1772 | ||
698b1515 | 1773 | if (pprt) |
30f468b2 GU |
1774 | pr_info("panel driver registered on parport%d (io=0x%lx).\n", |
1775 | parport, pprt->port->base); | |
698b1515 | 1776 | else |
30f468b2 | 1777 | pr_info("panel driver not yet registered\n"); |
698b1515 WT |
1778 | return 0; |
1779 | } | |
7005b584 | 1780 | |
f6d1fcfe | 1781 | static void __exit panel_cleanup_module(void) |
698b1515 | 1782 | { |
698b1515 | 1783 | parport_unregister_driver(&panel_driver); |
7005b584 | 1784 | } |
7005b584 | 1785 | |
7005b584 WT |
1786 | module_init(panel_init_module); |
1787 | module_exit(panel_cleanup_module); | |
1788 | MODULE_AUTHOR("Willy Tarreau"); | |
1789 | MODULE_LICENSE("GPL"); | |
7005b584 WT |
1790 | |
1791 | /* | |
1792 | * Local variables: | |
1793 | * c-indent-level: 4 | |
1794 | * tab-width: 8 | |
1795 | * End: | |
1796 | */ |