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