diff options
author | Willy Tarreau <w@1wt.eu> | 2008-11-22 11:29:33 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-06 13:52:30 -0800 |
commit | 698b1515f03914386ad9cc033d62447e5d43f880 (patch) | |
tree | 8ae9ea7dadb81c8a24c70d5889703fd4dc85ed91 /drivers/staging | |
parent | 7005b58458e4beecaf5efacb872c456bc7d3541a (diff) |
Staging: panel: major checkpatch cleanup
All of the 401 errors, and 108 of the 235 warnings reported by checkpatch
were cleared. The only remanining warnings left concern lines larger than
80 characters. This cleanup will be performed last.
Signed-off-by: Willy Tarreau <w@1wt.eu>
Cc: Frank Menne <frank.menne@hsm.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/panel/panel.c | 3316 |
1 files changed, 1715 insertions, 1601 deletions
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index e021f5c4e07..dcbad349e58 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -1,75 +1,25 @@ /* - * Front panel driver for Linux - 20000810 - Willy Tarreau - willy@meta-x.org. - * It includes and LCD display (/dev/lcd), a 4-key keypad (/dev/keypad), and a - * smart card reader (/dev/smartcard). + * Front panel driver for Linux + * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu> * - * Updates for this driver may be found here : + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. * - * http://w.ods.org/linux/kernel/lcdpanel/ + * This code drives an LCD module (/dev/lcd), and a keypad (/dev/keypad) + * connected to a parallel printer port. * - * the driver skeleton has been stolen from nvram.c which was clearly written. + * The LCD module may either be an HD44780-like 8-bit parallel LCD, or a 1-bit + * serial module compatible with Samsung's KS0074. The pins may be connected in + * any combination, everything is programmable. * - * Changes: - * 2000/08/10 - * - keypad now scrolls LCD when not opened - * - released 0.5.1 - * 2000/08/10 - * - bug fixes - * - released 0.5.2 - * 2000/08/10 - * - Reposition LCD when opening /dev/keypad (WIP) - * - Released 0.5.3 - * 2001/02/04 - * - Start of port to kernel 2.4.1 - * 2001/03/11 - * - implementation of a 24-key keyboard scanner with less electronics - * around, thus allowing to release the IRQ line. - * 2001/03/25 - * - the driver now compiles and works with both 2.4.2 and 2.2.18 kernels - * 2001/04/22 - * - implementation of KS0074-based serial LCD (load with lcd_enabled=2 and lcd_hwidth=16) - * 2001/04/29 - * - added back-light support, released 0.7.1 - * 2001/05/01 - * - added charset conversion table for ks0074, released 0.7.2 - * 2001/05/08 - * - start of rewriting towards v0.8 - * 2001/10/21 - * - replaced linux/malloc.h with linux/slab.h to be 2.4 compliant - * - definition of the multi-layer input system with its naming scheme - * - profile support for simplified configuration - * 2001/10/28 - * - smartcard now works for telecards. /dev/smartcard returns the card serial number - * 2001/11/10 - * - fix too short sleep for lcd_clear - * 2004/05/09 - * - add support for hantronix LCD modules (RS on SELECTIN instead of AUTOLF) - * (load with lcd_enabled=3 or profile=3) - * 2004/06/04 - * - changed all parallel LCD functions to be more generic. Now any - * connection of control signal is allowed with lcd_*_pin. - * 2004/07/23 - * - cleaned up some code - * - added support for keypads with inverted inputs - * - added support for Nexcom's LCD/Keypad on profile 4 - * - added character generator for chars 0-7 : "\e[LG{0-7}{8*2 hexdigits};" - * 2004/07/29 : 0.9.0 - * - deprecated lcd_enabled and keypad_enabled in profit of *_type - * - changed configuration so that the user can choose everything at - * kernel compilation time - * 2004/07/31 : 0.9.2 - * - fixed a stupid copy-paste bug affecting only the serial LCD - * - moved display geometries to lcd_init() to avoid problems with custom profiles. - * 2004/08/06 : 0.9.3 - * - added a system notifier callback to print the system state on the LCD - * during reboots or halts. + * The keypad consists in a matrix of push buttons connecting input pins to + * data output pins or to the ground. The combinations have to be hard-coded + * in the driver, though several profiles exist and adding new ones is easy. * - * 2005/05/20 : 0.9.4 - * - first working port on kernel 2.6 - * - * 2006/12/18 : 0.9.5 - * - fixed a long standing bug in 2.6 causing panics during reboot/kexec - * if the LCD was enabled but not initialized due to lack of parport. + * Several profiles are provided for commonly found LCD+keypad modules on the + * market, such as those found in Nexcom's appliances. * * FIXME: * - the initialization/deinitialization process is very dirty and should @@ -94,7 +44,7 @@ #include <linux/smp_lock.h> #include <linux/interrupt.h> #include <linux/miscdevice.h> -#include <linux/slab.h> // previously <linux/malloc.h> +#include <linux/slab.h> #include <linux/ioport.h> #include <linux/fcntl.h> #include <linux/init.h> @@ -107,7 +57,7 @@ #include <linux/reboot.h> #include <linux/utsrelease.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/uaccess.h> #include <asm/system.h> @@ -133,18 +83,18 @@ /* converts an r_str() input to an active high, bits string : 000BAOSE */ #define PNL_PINPUT(a) ((((unsigned char)(a)) ^ 0x7F) >> 3) -#define PNL_PBUSY 0x80 /* inverted input, active low */ -#define PNL_PACK 0x40 /* direct input, active low */ -#define PNL_POUTPA 0x20 /* direct input, active high */ -#define PNL_PSELECD 0x10 /* direct input, active high */ -#define PNL_PERRORP 0x08 /* direct input, active low */ +#define PNL_PBUSY 0x80 /* inverted input, active low */ +#define PNL_PACK 0x40 /* direct input, active low */ +#define PNL_POUTPA 0x20 /* direct input, active high */ +#define PNL_PSELECD 0x10 /* direct input, active high */ +#define PNL_PERRORP 0x08 /* direct input, active low */ -#define PNL_PBIDIR 0x20 /* bi-directional ports */ -#define PNL_PINTEN 0x10 /* high to read data in or-ed with data out */ -#define PNL_PSELECP 0x08 /* inverted output, active low */ -#define PNL_PINITP 0x04 /* direct output, active low */ -#define PNL_PAUTOLF 0x02 /* inverted output, active low */ -#define PNL_PSTROBE 0x01 /* inverted output */ +#define PNL_PBIDIR 0x20 /* bi-directional ports */ +#define PNL_PINTEN 0x10 /* high to read data in or-ed with data out */ +#define PNL_PSELECP 0x08 /* inverted output, active low */ +#define PNL_PINITP 0x04 /* direct output, active low */ +#define PNL_PAUTOLF 0x02 /* inverted output, active low */ +#define PNL_PSTROBE 0x01 /* inverted output */ #define PNL_PD0 0x01 #define PNL_PD1 0x02 @@ -171,7 +121,7 @@ #define PIN_NOT_SET 127 /* some smartcard-specific signals */ -#define PNL_SC_IO PNL_PD1 /* Warning! inverted output, 0=highZ */ +#define PNL_SC_IO PNL_PD1 /* Warning! inverted output, 0=highZ */ #define PNL_SC_RST PNL_PD2 #define PNL_SC_CLK PNL_PD3 #define PNL_SC_RW PNL_PD4 @@ -195,53 +145,53 @@ #define r_ctr(x) (parport_read_control((x)->port)) #define r_dtr(x) (parport_read_data((x)->port)) #define r_str(x) (parport_read_status((x)->port)) -#define w_ctr(x,y) do { parport_write_control((x)->port, (y)); } while (0) -#define w_dtr(x,y) do { parport_write_data((x)->port, (y)); } while (0) +#define w_ctr(x, y) do { parport_write_control((x)->port, (y)); } while (0) +#define w_dtr(x, y) do { parport_write_data((x)->port, (y)); } while (0) /* this defines which bits are to be used and which ones to be ignored */ -static __u8 scan_mask_o = 0; /* logical or of the output bits involved in the scan matrix */ -static __u8 scan_mask_i = 0; /* logical or of the input bits involved in the scan matrix */ +static __u8 scan_mask_o; /* logical or of the output bits involved in the scan matrix */ +static __u8 scan_mask_i; /* logical or of the input bits involved in the scan matrix */ -typedef __u64 pmask_t; +typedef __u64 pmask_t; enum input_type { - INPUT_TYPE_STD, - INPUT_TYPE_KBD, + INPUT_TYPE_STD, + INPUT_TYPE_KBD, }; enum input_state { - INPUT_ST_LOW, - INPUT_ST_RISING, - INPUT_ST_HIGH, - INPUT_ST_FALLING, + INPUT_ST_LOW, + INPUT_ST_RISING, + INPUT_ST_HIGH, + INPUT_ST_FALLING, }; struct logical_input { - struct list_head list; - pmask_t mask; - pmask_t value; - enum input_type type; - enum input_state state; - __u8 rise_time, fall_time; - __u8 rise_timer, fall_timer, high_timer; - - union { - struct { /* this structure is valid when type == INPUT_TYPE_STD */ - void(*press_fct)(int); - void(*release_fct)(int); - int press_data; - int release_data; - } std; - struct { /* this structure is valid when type == INPUT_TYPE_KBD */ - /* strings can be full-length (ie. non null-terminated) */ - char press_str[sizeof(void *) + sizeof (int)]; - char repeat_str[sizeof(void *) + sizeof (int)]; - char release_str[sizeof(void *) + sizeof (int)]; - } kbd; - } u; + struct list_head list; + pmask_t mask; + pmask_t value; + enum input_type type; + enum input_state state; + __u8 rise_time, fall_time; + __u8 rise_timer, fall_timer, high_timer; + + union { + struct { /* this structure is valid when type == INPUT_TYPE_STD */ + void (*press_fct) (int); + void (*release_fct) (int); + int press_data; + int release_data; + } std; + struct { /* this structure is valid when type == INPUT_TYPE_KBD */ + /* strings can be full-length (ie. non null-terminated) */ + char press_str[sizeof(void *) + sizeof(int)]; + char repeat_str[sizeof(void *) + sizeof(int)]; + char release_str[sizeof(void *) + sizeof(int)]; + } kbd; + } u; }; -LIST_HEAD(logical_inputs); /* list of all defined logical inputs */ +LIST_HEAD(logical_inputs); /* list of all defined logical inputs */ /* physical contacts history * Physical contacts are a 45 bits string of 9 groups of 5 bits each. @@ -254,34 +204,34 @@ LIST_HEAD(logical_inputs); /* list of all defined logical inputs */ * <-----unused------><gnd><d07><d06><d05><d04><d03><d02><d01><d00> */ static pmask_t phys_read; /* what has just been read from the I/O ports */ -static pmask_t phys_read_prev; /* previous phys_read */ -static pmask_t phys_curr; /* stabilized phys_read (phys_read|phys_read_prev) */ -static pmask_t phys_prev; /* previous phys_curr */ -static char inputs_stable = 0; /* 0 means that at least one logical signal needs be computed */ +static pmask_t phys_read_prev; /* previous phys_read */ +static pmask_t phys_curr; /* stabilized phys_read (phys_read|phys_read_prev) */ +static pmask_t phys_prev; /* previous phys_curr */ +static char inputs_stable; /* 0 means that at least one logical signal needs be computed */ /* these variables are specific to the smartcard */ static __u8 smartcard_data[SMARTCARD_BYTES]; -static int smartcard_ptr = 0; /* pointer to half bytes in smartcard_data */ +static int smartcard_ptr; /* pointer to half bytes in smartcard_data */ /* these variables are specific to the keypad */ static char keypad_buffer[KEYPAD_BUFFER]; -static int keypad_buflen = 0; -static int keypad_start = 0; -static char keypressed = 0; +static int keypad_buflen; +static int keypad_start; +static char keypressed; static wait_queue_head_t keypad_read_wait; static wait_queue_head_t smartcard_read_wait; /* lcd-specific variables */ -static unsigned long int lcd_flags = 0; /* contains the LCD config state */ -static unsigned long int lcd_addr_x = 0; /* contains the LCD X offset */ -static unsigned long int lcd_addr_y = 0; /* contains the LCD Y offset */ -static char lcd_escape[LCD_ESCAPE_LEN+1]; /* current escape sequence, 0 terminated */ -static int lcd_escape_len = -1; /* not in escape state. >=0 = escape cmd len */ +static unsigned long int lcd_flags; /* contains the LCD config state */ +static unsigned long int lcd_addr_x; /* contains the LCD X offset */ +static unsigned long int lcd_addr_y; /* contains the LCD Y offset */ +static char lcd_escape[LCD_ESCAPE_LEN + 1]; /* current escape sequence, 0 terminated */ +static int lcd_escape_len = -1; /* not in escape state. >=0 = escape cmd len */ static int lcd_height = -1; -static int lcd_width = -1; -static int lcd_hwidth = -1; /* hardware buffer width (usually 64) */ -static int lcd_bwidth = -1; /* internal buffer width (usually 40) */ +static int lcd_width = -1; +static int lcd_hwidth = -1; /* hardware buffer width (usually 64) */ +static int lcd_bwidth = -1; /* internal buffer width (usually 40) */ /* * These are the parallel port pins the LCD control signals are connected to. @@ -291,7 +241,7 @@ static int lcd_bwidth = -1; /* internal buffer width (usually 40) */ * * WARNING! no check will be performed about collisions with keypad/smartcard ! */ -static int lcd_e_pin = PIN_NOT_SET; +static int lcd_e_pin = PIN_NOT_SET; static int lcd_rs_pin = PIN_NOT_SET; static int lcd_rw_pin = PIN_NOT_SET; static int lcd_bl_pin = PIN_NOT_SET; @@ -303,9 +253,9 @@ static int lcd_da_pin = PIN_NOT_SET; * _d_ are values for data port, _c_ are for control port. * [0] = signal OFF, [1] = signal ON, [2] = mask */ -#define BIT_CLR 0 -#define BIT_SET 1 -#define BIT_MSK 2 +#define BIT_CLR 0 +#define BIT_SET 1 +#define BIT_MSK 2 #define BIT_STATES 3 /* * one entry for each bit on the LCD @@ -399,7 +349,7 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; #define DEFAULT_PARPORT CONFIG_PANEL_PARPORT #endif -#if DEFAULT_PROFILE==0 /* custom */ +#if DEFAULT_PROFILE == 0 /* custom */ #ifdef CONFIG_PANEL_KEYPAD #undef DEFAULT_KEYPAD #define DEFAULT_KEYPAD CONFIG_PANEL_KEYPAD @@ -478,12 +428,12 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES]; #endif /* DEFAULT_PROFILE == 0 */ /* global variables */ -static int smartcard_open_cnt = 0; /* #times opened */ -static int keypad_open_cnt = 0; /* #times opened */ -static int lcd_open_cnt = 0; /* #times opened */ +static int smartcard_open_cnt; /* #times opened */ +static int keypad_open_cnt; /* #times opened */ +static int lcd_open_cnt; /* #times opened */ static int profile = DEFAULT_PROFILE; -static struct pardevice *pprt = NULL; +static struct pardevice *pprt; static int parport = -1; static int lcd_enabled = -1; static int lcd_type = -1; @@ -495,157 +445,205 @@ static int smartcard_enabled = -1; static int lcd_initialized, keypad_initialized, smartcard_initialized; -static int light_tempo = 0; +static int light_tempo; -static char lcd_must_clear = 0; -static char lcd_left_shift = 0; -static char init_in_progress = 0; +static char lcd_must_clear; +static char lcd_left_shift; +static char init_in_progress; -static void(*lcd_write_cmd)(int) = NULL; -static void(*lcd_write_data)(int) = NULL; -static void(*lcd_clear_fast)(void) = NULL; +static void (*lcd_write_cmd) (int); +static void (*lcd_write_data) (int); +static void (*lcd_clear_fast) (void); -static spinlock_t pprt_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(pprt_lock); static struct timer_list scan_timer; #ifdef MODULE MODULE_DESCRIPTION("Generic parallel port LCD/Keypad/Smartcard driver"); -module_param(parport, int, 0000);MODULE_PARM_DESC(parport, "Parallel port index (0=lpt1, 1=lpt2, ...)"); -module_param(lcd_height, int, 0000);MODULE_PARM_DESC(lcd_height, "Number of lines on the LCD"); -module_param(lcd_width, int, 0000);MODULE_PARM_DESC(lcd_width, "Number of columns on the LCD"); -module_param(lcd_bwidth, int, 0000);MODULE_PARM_DESC(lcd_bwidth, "Internal LCD line width (40)"); -module_param(lcd_hwidth, int, 0000);MODULE_PARM_DESC(lcd_hwidth, "LCD line hardware address (64)"); -module_param(lcd_enabled, int, 0000);MODULE_PARM_DESC(lcd_enabled, "Deprecated option, use lcd_type instead"); -module_param(keypad_enabled, int, 0000);MODULE_PARM_DESC(keypad_enabled, "Deprecated option, use keypad_type instead"); -module_param(lcd_type, int, 0000);MODULE_PARM_DESC(lcd_type, "LCD type: 0=none, 1=old //, 2=serial ks0074, 3=hantronix //, 4=nexcom //, 5=compiled-in"); -module_param(lcd_proto, int, 0000);MODULE_PARM_DESC(lcd_proto, "LCD communication: 0=parallel (//), 1=serial"); -module_param(lcd_charset, int, 0000);MODULE_PARM_DESC(lcd_charset, "LCD character set: 0=standard, 1=KS0074"); -module_param(keypad_type, int, 0000);MODULE_PARM_DESC(keypad_type, "Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, 3=nexcom 4 keys"); -module_param(smartcard_enabled, int, 0000);MODULE_PARM_DESC(smartcard_enabled, "Smartcard reader: 0=disabled (default), 1=enabled"); -module_param(profile, int, 0000); MODULE_PARM_DESC(profile, "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; 4=16x2 nexcom; default=40x2, old kp"); - -module_param(lcd_e_pin, int, 0000); MODULE_PARM_DESC(lcd_e_pin, "# of the // port pin connected to LCD 'E' signal, with polarity (-17..17)"); -module_param(lcd_rs_pin, int, 0000);MODULE_PARM_DESC(lcd_rs_pin, "# of the // port pin connected to LCD 'RS' signal, with polarity (-17..17)"); -module_param(lcd_rw_pin, int, 0000);MODULE_PARM_DESC(lcd_rw_pin, "# of the // port pin connected to LCD 'RW' signal, with polarity (-17..17)"); -module_param(lcd_bl_pin, int, 0000);MODULE_PARM_DESC(lcd_bl_pin, "# of the // port pin connected to LCD backlight, with polarity (-17..17)"); -module_param(lcd_da_pin, int, 0000);MODULE_PARM_DESC(lcd_da_pin, "# of the // port pin connected to serial LCD 'SDA' signal, with polarity (-17..17)"); -module_param(lcd_cl_pin, int, 0000);MODULE_PARM_DESC(lcd_cl_pin, "# of the // port pin connected to serial LCD 'SCL' signal, with polarity (-17..17)"); +module_param(parport, int, 0000); +MODULE_PARM_DESC(parport, "Parallel port index (0=lpt1, 1=lpt2, ...)"); +module_param(lcd_height, int, 0000); +MODULE_PARM_DESC(lcd_height, "Number of lines on the LCD"); +module_param(lcd_width, int, 0000); +MODULE_PARM_DESC(lcd_width, "Number of columns on the LCD"); +module_param(lcd_bwidth, int, 0000); +MODULE_PARM_DESC(lcd_bwidth, "Internal LCD line width (40)"); +module_param(lcd_hwidth, int, 0000); +MODULE_PARM_DESC(lcd_hwidth, "LCD line hardware address (64)"); +module_param(lcd_enabled, int, 0000); +MODULE_PARM_DESC(lcd_enabled, "Deprecated option, use lcd_type instead"); +module_param(keypad_enabled, int, 0000); +MODULE_PARM_DESC(keypad_enabled, "Deprecated option, use keypad_type instead"); +module_param(lcd_type, int, 0000); +MODULE_PARM_DESC(lcd_type, + "LCD type: 0=none, 1=old //, 2=serial ks0074, 3=hantronix //, 4=nexcom //, 5=compiled-in"); +module_param(lcd_proto, int, 0000); +MODULE_PARM_DESC(lcd_proto, "LCD communication: 0=parallel (//), 1=serial"); +module_param(lcd_charset, int, 0000); +MODULE_PARM_DESC(lcd_charset, "LCD character set: 0=standard, 1=KS0074"); +module_param(keypad_type, int, 0000); +MODULE_PARM_DESC(keypad_type, + "Keypad type: 0=none, 1=old 6 keys, 2=new 6+1 keys, 3=nexcom 4 keys"); +module_param(smartcard_enabled, int, 0000); +MODULE_PARM_DESC(smartcard_enabled, + "Smartcard reader: 0=disabled (default), 1=enabled"); +module_param(profile, int, 0000); +MODULE_PARM_DESC(profile, + "1=16x2 old kp; 2=serial 16x2, new kp; 3=16x2 hantronix; 4=16x2 nexcom; default=40x2, old kp"); + +module_param(lcd_e_pin, int, 0000); +MODULE_PARM_DESC(lcd_e_pin, + "# of the // port pin connected to LCD 'E' signal, with polarity (-17..17)"); +module_param(lcd_rs_pin, int, 0000); +MODULE_PARM_DESC(lcd_rs_pin, + "# of the // port pin connected to LCD 'RS' signal, with polarity (-17..17)"); +module_param(lcd_rw_pin, int, 0000); +MODULE_PARM_DESC(lcd_rw_pin, + "# of the // port pin connected to LCD 'RW' signal, with polarity (-17..17)"); +module_param(lcd_bl_pin, int, 0000); +MODULE_PARM_DESC(lcd_bl_pin, + "# of the // port pin connected to LCD backlight, with polarity (-17..17)"); +module_param(lcd_da_pin, int, 0000); +MODULE_PARM_DESC(lcd_da_pin, + "# of the // port pin connected to serial LCD 'SDA' signal, with polarity (-17..17)"); +module_param(lcd_cl_pin, int, 0000); +MODULE_PARM_DESC(lcd_cl_pin, + "# of the // port pin connected to serial LCD 'SCL' signal, with polarity (-17..17)"); #endif -static unsigned char *lcd_char_conv = NULL; +static unsigned char *lcd_char_conv; /* for some LCD drivers (ks0074) we need a charset conversion table. */ static unsigned char lcd_char_conv_ks0074[256] = { - /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ - /* 0x00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - /* 0x10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - /* 0x20 */ 0x20, 0x21, 0x22, 0x23, 0xa2, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - /* 0x30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - /* 0x40 */ 0xa0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - /* 0x50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xfa, 0xfb, 0xfc, 0x1d, 0xc4, - /* 0x60 */ 0x96, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - /* 0x70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0xfd, 0xfe, 0xff, 0xce, 0x20, - /* 0x80 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - /* 0x90 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - /* 0xA0 */ 0x20, 0x40, 0xb1, 0xa1, 0x24, 0xa3, 0xfe, 0x5f, 0x22, 0xc8, 0x61, 0x14, 0x97, 0x2d, 0xad, 0x96, - /* 0xB0 */ 0x80, 0x8c, 0x82, 0x83, 0x27, 0x8f, 0x86, 0xdd, 0x2c, 0x81, 0x6f, 0x15, 0x8b, 0x8a, 0x84, 0x60, - /* 0xC0 */ 0xe2, 0xe2, 0xe2, 0x5b, 0x5b, 0xae, 0xbc, 0xa9, 0xc5, 0xbf, 0xc6, 0xf1, 0xe3, 0xe3, 0xe3, 0xe3, - /* 0xD0 */ 0x44, 0x5d, 0xa8, 0xe4, 0xec, 0xec, 0x5c, 0x78, 0xab, 0xa6, 0xe5, 0x5e, 0x5e, 0xe6, 0xaa, 0xbe, - /* 0xE0 */ 0x7f, 0xe7, 0xaf, 0x7b, 0x7b, 0xaf, 0xbd, 0xc8, 0xa4, 0xa5, 0xc7, 0xf6, 0xa7, 0xe8, 0x69, 0x69, - /* 0xF0 */ 0xed, 0x7d, 0xa8, 0xe4, 0xec, 0x5c, 0x5c, 0x25, 0xac, 0xa6, 0xea, 0xef, 0x7e, 0xeb, 0xb2, 0x79, + /* 0|8 1|9 2|A 3|B 4|C 5|D 6|E 7|F */ + /* 0x00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + /* 0x08 */ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + /* 0x10 */ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + /* 0x18 */ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + /* 0x20 */ 0x20, 0x21, 0x22, 0x23, 0xa2, 0x25, 0x26, 0x27, + /* 0x28 */ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + /* 0x30 */ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + /* 0x38 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + /* 0x40 */ 0xa0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + /* 0x48 */ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + /* 0x50 */ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + /* 0x58 */ 0x58, 0x59, 0x5a, 0xfa, 0xfb, 0xfc, 0x1d, 0xc4, + /* 0x60 */ 0x96, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + /* 0x68 */ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + /* 0x70 */ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + /* 0x78 */ 0x78, 0x79, 0x7a, 0xfd, 0xfe, 0xff, 0xce, 0x20, + /* 0x80 */ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + /* 0x88 */ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + /* 0x90 */ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + /* 0x98 */ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + /* 0xA0 */ 0x20, 0x40, 0xb1, 0xa1, 0x24, 0xa3, 0xfe, 0x5f, + /* 0xA8 */ 0x22, 0xc8, 0x61, 0x14, 0x97, 0x2d, 0xad, 0x96, + /* 0xB0 */ 0x80, 0x8c, 0x82, 0x83, 0x27, 0x8f, 0x86, 0xdd, + /* 0xB8 */ 0x2c, 0x81, 0x6f, 0x15, 0x8b, 0x8a, 0x84, 0x60, + /* 0xC0 */ 0xe2, 0xe2, 0xe2, 0x5b, 0x5b, 0xae, 0xbc, 0xa9, + /* 0xC8 */ 0xc5, 0xbf, 0xc6, 0xf1, 0xe3, 0xe3, 0xe3, 0xe3, + /* 0xD0 */ 0x44, 0x5d, 0xa8, 0xe4, 0xec, 0xec, 0x5c, 0x78, + /* 0xD8 */ 0xab, 0xa6, 0xe5, 0x5e, 0x5e, 0xe6, 0xaa, 0xbe, + /* 0xE0 */ 0x7f, 0xe7, 0xaf, 0x7b, 0x7b, 0xaf, 0xbd, 0xc8, + /* 0xE8 */ 0xa4, 0xa5, 0xc7, 0xf6, 0xa7, 0xe8, 0x69, 0x69, + /* 0xF0 */ 0xed, 0x7d, 0xa8, 0xe4, 0xec, 0x5c, 0x5c, 0x25, + /* 0xF8 */ 0xac, 0xa6, 0xea, 0xef, 0x7e, 0xeb, 0xb2, 0x79, }; char old_keypad_profile[][4][9] = { - {"S0", "Left\n", "Left\n", ""}, - {"S1", "Down\n", "Down\n", ""}, - {"S2", "Up\n", "Up\n", ""}, - {"S3", "Right\n", "Right\n", ""}, - {"S4", "Esc\n", "Esc\n", ""}, - {"S5", "Ret\n", "Ret\n", ""}, - {"","","",""} + {"S0", "Left\n", "Left\n", ""}, + {"S1", "Down\n", "Down\n", ""}, + {"S2", "Up\n", "Up\n", ""}, + {"S3", "Right\n", "Right\n", ""}, + {"S4", "Esc\n", "Esc\n", ""}, + {"S5", "Ret\n", "Ret\n", ""}, + {"", "", "", ""} }; /* signals, press, repeat, release */ char new_keypad_profile[][4][9] = { - {"S0", "Left\n", "Left\n", ""}, - {"S1", "Down\n", "Down\n", ""}, - {"S2", "Up\n", "Up\n", ""}, - {"S3", "Right\n", "Right\n", ""}, - {"S4s5", "", "Esc\n", "Esc\n"}, - {"s4S5", "", "Ret\n", "Ret\n"}, - {"S4S5", "Help\n", "", ""}, - /* add new signals above this line */ - {"","","",""} + {"S0", "Left\n", "Left\n", ""}, + {"S1", "Down\n", "Down\n", ""}, + {"S2", "Up\n", "Up\n", ""}, + {"S3", "Right\n", "Right\n", ""}, + {"S4s5", "", "Esc\n", "Esc\n"}, + {"s4S5", "", "Ret\n", "Ret\n"}, + {"S4S5", "Help\n", "", ""}, + /* add new signals above this line */ + {"", "", "", ""} }; /* signals, press, repeat, release */ char nexcom_keypad_profile[][4][9] = { - {"a-p-e-", "Down\n", "Down\n", ""}, // Down - {"a-p-E-", "Ret\n", "Ret\n", ""}, // Enter - {"a-P-E-", "Esc\n", "Esc\n", ""}, // Esc - {"a-P-e-", "Up\n", "Up\n", ""}, // Up - /* add new signals above this line */ - {"","","",""} + {"a-p-e-", "Down\n", "Down\n", ""}, + {"a-p-E-", "Ret\n", "Ret\n", ""}, + {"a-P-E-", "Esc\n", "Esc\n", ""}, + {"a-P-e-", "Up\n", "Up\n", ""}, + /* add new signals above this line */ + {"", "", "", ""} }; static char (*keypad_profile)[4][9] = old_keypad_profile; /* FIXME: this should be converted to a bit array containing signals states */ static struct { - unsigned char e; /* parallel LCD E (data latch on falling edge) */ - unsigned char rs; /* parallel LCD RS (0 = cmd, 1 = data) */ - unsigned char rw; /* parallel LCD R/W (0 = W, 1 = R) */ - unsigned char bl; /* parallel LCD backlight (0 = off, 1 = on) */ - unsigned char cl; /* serial LCD clock (latch on rising edge) */ - unsigned char da; /* serial LCD data */ + unsigned char e; /* parallel LCD E (data latch on falling edge) */ + unsigned char rs; /* parallel LCD RS (0 = cmd, 1 = data) */ + unsigned char rw; /* parallel LCD R/W (0 = W, 1 = R) */ + unsigned char bl; /* parallel LCD backlight (0 = off, 1 = on) */ + unsigned char cl; /* serial LCD clock (latch on rising edge) */ + unsigned char da; /* serial LCD data */ } bits; static void init_scan_timer(void); /* sets data port bits according to current signals values */ -static int set_data_bits(void) { - int val, bit; - - val = r_dtr(pprt); - for (bit = 0; bit < LCD_BITS; bit++) - val &= lcd_bits[LCD_PORT_D][bit][BIT_MSK]; - - val |= lcd_bits[LCD_PORT_D][LCD_BIT_E][bits.e] - | lcd_bits[LCD_PORT_D][LCD_BIT_RS][bits.rs] - | lcd_bits[LCD_PORT_D][LCD_BIT_RW][bits.rw] - | lcd_bits[LCD_PORT_D][LCD_BIT_BL][bits.bl] - | lcd_bits[LCD_PORT_D][LCD_BIT_CL][bits.cl] - | lcd_bits[LCD_PORT_D][LCD_BIT_DA][bits.da]; - - w_dtr(pprt, val); - return val; +static int set_data_bits(void) +{ + int val, bit; + + val = r_dtr(pprt); + for (bit = 0; bit < LCD_BITS; bit++) + val &= lcd_bits[LCD_PORT_D][bit][BIT_MSK]; + + val |= lcd_bits[LCD_PORT_D][LCD_BIT_E][bits.e] + | lcd_bits[LCD_PORT_D][LCD_BIT_RS][bits.rs] + | lcd_bits[LCD_PORT_D][LCD_BIT_RW][bits.rw] + | lcd_bits[LCD_PORT_D][LCD_BIT_BL][bits.bl] + | lcd_bits[LCD_PORT_D][LCD_BIT_CL][bits.cl] + | lcd_bits[LCD_PORT_D][LCD_BIT_DA][bits.da]; + + w_dtr(pprt, val); + return val; } /* sets ctrl port bits according to current signals values */ -static int set_ctrl_bits(void) { - int val, bit; - - val = r_ctr(pprt); - for (bit = 0; bit < LCD_BITS; bit++) - val &= lcd_bits[LCD_PORT_C][bit][BIT_MSK]; - - val |= lcd_bits[LCD_PORT_C][LCD_BIT_E][bits.e] - | lcd_bits[LCD_PORT_C][LCD_BIT_RS][bits.rs] - | lcd_bits[LCD_PORT_C][LCD_BIT_RW][bits.rw] - | lcd_bits[LCD_PORT_C][LCD_BIT_BL][bits.bl] - | lcd_bits[LCD_PORT_C][LCD_BIT_CL][bits.cl] - | lcd_bits[LCD_PORT_C][LCD_BIT_DA][bits.da]; - - w_ctr(pprt, val); - return val; +static int set_ctrl_bits(void) +{ + int val, bit; + + val = r_ctr(pprt); + for (bit = 0; bit < LCD_BITS; bit++) + val &= lcd_bits[LCD_PORT_C][bit][BIT_MSK]; + + val |= lcd_bits[LCD_PORT_C][LCD_BIT_E][bits.e] + | lcd_bits[LCD_PORT_C][LCD_BIT_RS][bits.rs] + | lcd_bits[LCD_PORT_C][LCD_BIT_RW][bits.rw] + | lcd_bits[LCD_PORT_C][LCD_BIT_BL][bits.bl] + | lcd_bits[LCD_PORT_C][LCD_BIT_CL][bits.cl] + | lcd_bits[LCD_PORT_C][LCD_BIT_DA][bits.da]; + + w_ctr(pprt, val); + return val; } /* sets ctrl & data port bits according to current signals values */ -static void set_bits(void) { - set_data_bits(); - set_ctrl_bits(); +static void set_bits(void) +{ + set_data_bits(); + set_ctrl_bits(); } /* @@ -657,266 +655,285 @@ static void set_bits(void) { * out(dport, in(dport) & d_val[2] | d_val[signal_state]) * out(cport, in(cport) & c_val[2] | c_val[signal_state]) */ -void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) { - int d_bit, c_bit, inv; - - d_val[0] = c_val[0] = d_val[1] = c_val[1] = 0; - d_val[2] = c_val[2] = 0xFF; - - if (pin == 0) - return; - - inv = (pin < 0); - if (inv) - pin = -pin; - - d_bit = c_bit = 0; - - switch (pin) { - case PIN_STROBE: /* strobe, inverted */ - c_bit = PNL_PSTROBE; - inv = !inv; - break; - case PIN_D0 ... PIN_D7: /* D0 - D7 = 2 - 9 */ - d_bit = 1 << (pin - 2); - break; - case PIN_AUTOLF: /* autofeed, inverted */ - c_bit = PNL_PAUTOLF; - inv = !inv; - break; - case PIN_INITP: /* init, direct */ - c_bit = PNL_PINITP; - break; - case PIN_SELECP: /* select_in, inverted */ - c_bit = PNL_PSELECP; - inv = !inv; - break; - default: /* unknown pin, ignore */ - break; - } - - if (c_bit) { - c_val[2] &= ~c_bit; - c_val[!inv] = c_bit; - } else if (d_bit) { - d_val[2] &= ~d_bit; - d_val[!inv] = d_bit; - } +void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) +{ + int d_bit, c_bit, inv; + + d_val[0] = c_val[0] = d_val[1] = c_val[1] = 0; + d_val[2] = c_val[2] = 0xFF; + + if (pin == 0) + return; + + inv = (pin < 0); + if (inv) + pin = -pin; + + d_bit = c_bit = 0; + + switch (pin) { + case PIN_STROBE: /* strobe, inverted */ + c_bit = PNL_PSTROBE; + inv = !inv; + break; + case PIN_D0...PIN_D7: /* D0 - D7 = 2 - 9 */ + d_bit = 1 << (pin - 2); + break; + case PIN_AUTOLF: /* autofeed, inverted */ + c_bit = PNL_PAUTOLF; + inv = !inv; + break; + case PIN_INITP: /* init, direct */ + c_bit = PNL_PINITP; + break; + case PIN_SELECP: /* select_in, inverted */ + c_bit = PNL_PSELECP; + inv = !inv; + break; + default: /* unknown pin, ignore */ + break; + } + + if (c_bit) { + c_val[2] &= ~c_bit; + c_val[!inv] = c_bit; + } else if (d_bit) { + d_val[2] &= ~d_bit; + d_val[!inv] = d_bit; + } } /* sleeps that many milliseconds with a reschedule */ -static void long_sleep(int ms) { - - if (in_interrupt()) - mdelay(ms); - else { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout((ms*HZ+999)/1000); - } -} +static void long_sleep(int ms) +{ + if (in_interrupt()) + mdelay(ms); + else { + current->state = TASK_INTERRUPTIBLE; + schedule_timeout((ms * HZ + 999) / 1000); + } +} /* send a serial byte to the LCD panel. The caller is responsible for locking if needed. */ -static void lcd_send_serial(int byte) { - int bit; - - /* the data bit is set on D0, and the clock on STROBE. - * LCD reads D0 on STROBE's rising edge. - */ - for (bit = 0; bit < 8; bit++) { - bits.cl = BIT_CLR; /* CLK low */ - set_bits(); - bits.da = byte & 1; - set_bits(); - udelay(2); /* maintain the data during 2 us before CLK up */ - bits.cl = BIT_SET; /* CLK high */ - set_bits(); - udelay(1); /* maintain the strobe during 1 us */ - byte >>= 1; - } +static void lcd_send_serial(int byte) +{ + int bit; + + /* the data bit is set on D0, and the clock on STROBE. + * LCD reads D0 on STROBE's rising edge. + */ + for (bit = 0; bit < 8; bit++) { + bits.cl = BIT_CLR; /* CLK low */ + set_bits(); + bits.da = byte & 1; + set_bits(); + udelay(2); /* maintain the data during 2 us before CLK up */ + bits.cl = BIT_SET; /* CLK high */ + set_bits(); + udelay(1); /* maintain the strobe during 1 us */ + byte >>= 1; + } } /* turn the backlight on or off */ -static void lcd_backlight(int on) { - if (lcd_bl_pin == PIN_NONE) - return; - - /* The backlight is activated by seting the AUTOFEED line to +5V */ - spin_lock(&pprt_lock); - bits.bl = on; - set_bits(); - spin_unlock(&pprt_lock); +static void lcd_backlight(int on) +{ + if (lcd_bl_pin == PIN_NONE) + return; + + /* The backlight is activated by seting the AUTOFEED line to +5V */ + spin_lock(&pprt_lock); + bits.bl = on; + set_bits(); + spin_unlock(&pprt_lock); } /* send a command to the LCD panel in serial mode */ -static void lcd_write_cmd_s(int cmd) { - spin_lock(&pprt_lock); - lcd_send_serial(0x1F); /* R/W=W, RS=0 */ - lcd_send_serial(cmd & 0x0F); - lcd_send_serial((cmd >> 4) & 0x0F); - udelay(40); /* the shortest command takes at least 40 us */ - spin_unlock(&pprt_lock); +static void lcd_write_cmd_s(int cmd) +{ + spin_lock(&pprt_lock); + lcd_send_serial(0x1F); /* R/W=W, RS=0 */ + lcd_send_serial(cmd & 0x0F); + lcd_send_serial((cmd >> 4) & 0x0F); + udelay(40); /* the shortest command takes at least 40 us */ + spin_unlock(&pprt_lock); } /* send data to the LCD panel in serial mode */ -static void lcd_write_data_s(int data) { - spin_lock(&pprt_lock); - lcd_send_serial(0x5F); /* R/W=W, RS=1 */ - lcd_send_serial(data & 0x0F); - lcd_send_serial((data >> 4) & 0x0F); - udelay(40); /* the shortest data takes at least 40 us */ - spin_unlock(&pprt_lock); +static void lcd_write_data_s(int data) +{ + spin_lock(&pprt_lock); + lcd_send_serial(0x5F); /* R/W=W, RS=1 */ + lcd_send_serial(data & 0x0F); + lcd_send_serial((data >> 4) & 0x0F); + udelay(40); /* the shortest data takes at least 40 us */ + spin_unlock(&pprt_lock); } /* send a command to the LCD panel in 8 bits parallel mode */ -static void lcd_write_cmd_p8(int cmd) { - spin_lock(&pprt_lock); - /* present the data to the data port */ - w_dtr(pprt, cmd); - udelay(20); /* maintain the data during 20 us before the strobe */ +static void lcd_write_cmd_p8(int cmd) +{ + spin_lock(&pprt_lock); + /* present the data to the data port */ + w_dtr(pprt, cmd); + udelay(20); /* maintain the data during 20 us before the strobe */ - bits.e = BIT_SET ; bits.rs = BIT_CLR ; bits.rw = BIT_CLR; - set_ctrl_bits(); + bits.e = BIT_SET; + bits.rs = BIT_CLR; + bits.rw = BIT_CLR; + set_ctrl_bits(); - udelay(40); /* maintain the strobe during 40 us */ + udelay(40); /* maintain the strobe during 40 us */ - bits.e = BIT_CLR; - set_ctrl_bits(); + bits.e = BIT_CLR; + set_ctrl_bits(); - udelay(120); /* the shortest command takes at least 120 us */ - spin_unlock(&pprt_lock); + udelay(120); /* the shortest command takes at least 120 us */ + spin_unlock(&pprt_lock); } /* send data to the LCD panel in 8 bits parallel mode */ -static void lcd_write_data_p8(int data) { - spin_lock(&pprt_lock); - /* present the data to the data port */ - w_dtr(pprt, data); - udelay(20); /* maintain the data during 20 us before the strobe */ +static void lcd_write_data_p8(int data) +{ + spin_lock(&pprt_lock); + /* present the data to the data port */ + w_dtr(pprt, data); + udelay(20); /* maintain the data during 20 us before the strobe */ - bits.e = BIT_SET ; bits.rs = BIT_SET ; bits.rw = BIT_CLR; - set_ctrl_bits(); + bits.e = BIT_SET; + bits.rs = BIT_SET; + bits.rw = BIT_CLR; + set_ctrl_bits(); - udelay(40); /* maintain the strobe during 40 us */ + udelay(40); /* maintain the strobe during 40 us */ - bits.e = BIT_CLR; - set_ctrl_bits(); + bits.e = BIT_CLR; + set_ctrl_bits(); - udelay(45); /* the shortest data takes at least 45 us */ - spin_unlock(&pprt_lock); + udelay(45); /* the shortest data takes at least 45 us */ + spin_unlock(&pprt_lock); } -static void lcd_gotoxy(void) { - lcd_write_cmd(0x80 /* set DDRAM address */ - | (lcd_addr_y ? lcd_hwidth : 0) - /* we force the cursor to stay at the end of the line if it wants to go farther */ - | ((lcd_addr_x < lcd_bwidth) ? lcd_addr_x & (lcd_hwidth-1) : lcd_bwidth - 1)); +static void lcd_gotoxy(void) +{ + lcd_write_cmd(0x80 /* set DDRAM address */ + | (lcd_addr_y ? lcd_hwidth : 0) + /* we force the cursor to stay at the end of the line if it wants to go farther */ + | ((lcd_addr_x < lcd_bwidth) ? lcd_addr_x & + (lcd_hwidth - 1) : lcd_bwidth - 1)); } -static void lcd_print(char c) { - if (lcd_addr_x < lcd_bwidth) { - if (lcd_char_conv != NULL) - c = lcd_char_conv[(unsigned char)c]; - lcd_write_data(c); - lcd_addr_x++; - } - /* prevents the cursor from wrapping onto the next line */ - if (lcd_addr_x == lcd_bwidth) { - lcd_gotoxy(); - }< |