Commit 698b1515 authored by Willy Tarreau's avatar Willy Tarreau Committed by Greg Kroah-Hartman

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: default avatarWilly Tarreau <w@1wt.eu>
Cc: Frank Menne <frank.menne@hsm.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7005b584
/*
* 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>
......@@ -195,12 +145,12 @@
#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;
......@@ -227,16 +177,16 @@ struct logical_input {
union {
struct { /* this structure is valid when type == INPUT_TYPE_STD */
void(*press_fct)(int);
void(*release_fct)(int);
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)];
char press_str[sizeof(void *) + sizeof(int)];
char repeat_str[sizeof(void *) + sizeof(int)];
char release_str[sizeof(void *) + sizeof(int)];
} kbd;
} u;
};
......@@ -257,25 +207,25 @@ 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 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 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;
......@@ -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,66 +445,111 @@ 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] = {
......@@ -564,7 +559,7 @@ char old_keypad_profile[][4][9] = {
{"S3", "Right\n", "Right\n", ""},
{"S4", "Esc\n", "Esc\n", ""},
{"S5", "Ret\n", "Ret\n", ""},
{"","","",""}
{"", "", "", ""}
};
/* signals, press, repeat, release */
......@@ -577,17 +572,17 @@ char new_keypad_profile[][4][9] = {
{"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
{"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;
......@@ -605,7 +600,8 @@ static struct {
static void init_scan_timer(void);
/* sets data port bits according to current signals values */
static int set_data_bits(void) {
static int set_data_bits(void)
{
int val, bit;
val = r_dtr(pprt);
......@@ -624,7 +620,8 @@ static int set_data_bits(void) {
}
/* sets ctrl port bits according to current signals values */
static int set_ctrl_bits(void) {
static int set_ctrl_bits(void)
{
int val, bit;
val = r_ctr(pprt);
......@@ -643,7 +640,8 @@ static int set_ctrl_bits(void) {
}
/* sets ctrl & data port bits according to current signals values */
static void set_bits(void) {
static void set_bits(void)
{
set_data_bits();
set_ctrl_bits();
}
......@@ -657,7 +655,8 @@ 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) {
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;
......@@ -677,7 +676,7 @@ void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) {
c_bit = PNL_PSTROBE;
inv = !inv;
break;
case PIN_D0 ... PIN_D7: /* D0 - D7 = 2 - 9 */
case PIN_D0...PIN_D7: /* D0 - D7 = 2 - 9 */
d_bit = 1 << (pin - 2);
break;
case PIN_AUTOLF: /* autofeed, inverted */
......@@ -705,19 +704,20 @@ void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) {
}
/* sleeps that many milliseconds with a reschedule */
static void long_sleep(int ms) {
static void long_sleep(int ms)
{
if (in_interrupt())
mdelay(ms);
else {
current->state = TASK_INTERRUPTIBLE;
schedule_timeout((ms*HZ+999)/1000);
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) {
static void lcd_send_serial(int byte)
{
int bit;
/* the data bit is set on D0, and the clock on STROBE.
......@@ -737,7 +737,8 @@ static void lcd_send_serial(int byte) {
}
/* turn the backlight on or off */
static void lcd_backlight(int on) {
static void lcd_backlight(int on)
{
if (lcd_bl_pin == PIN_NONE)
return;
......@@ -749,7 +750,8 @@ static void lcd_backlight(int on) {
}
/* send a command to the LCD panel in serial mode */
static void lcd_write_cmd_s(int cmd) {
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);
......@@ -759,7 +761,8 @@ static void lcd_write_cmd_s(int cmd) {
}
/* send data to the LCD panel in serial mode */
static void lcd_write_data_s(int data) {
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);
......@@ -769,13 +772,16 @@ static void lcd_write_data_s(int data) {
}
/* send a command to the LCD panel in 8 bits parallel mode */
static void lcd_write_cmd_p8(int cmd) {
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;
bits.e = BIT_SET;
bits.rs = BIT_CLR;
bits.rw = BIT_CLR;
set_ctrl_bits();
udelay(40); /* maintain the strobe during 40 us */
......@@ -788,13 +794,16 @@ static void lcd_write_cmd_p8(int cmd) {
}
/* send data to the LCD panel in 8 bits parallel mode */
static void lcd_write_data_p8(int data) {
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;
bits.e = BIT_SET;
bits.rs = BIT_SET;
bits.rw = BIT_CLR;
set_ctrl_bits();
udelay(40); /* maintain the strobe during 40 us */
......@@ -806,14 +815,17 @@ static void lcd_write_data_p8(int data) {
spin_unlock(&pprt_lock);
}
static void lcd_gotoxy(void) {
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));
| ((lcd_addr_x < lcd_bwidth) ? lcd_addr_x &
(lcd_hwidth - 1) : lcd_bwidth - 1));
}
static void lcd_print(char c) {
static void lcd_print(char c)
{
if (lcd_addr_x < lcd_bwidth) {
if (lcd_char_conv != NULL)
c = lcd_char_conv[(unsigned char)c];
......@@ -821,13 +833,13 @@ static void lcd_print(char c) {
lcd_addr_x++;
}
/* prevents the cursor from wrapping onto the next line */
if (lcd_addr_x == lcd_bwidth) {
if (lcd_addr_x == lcd_bwidth)
lcd_gotoxy();
}
}
/* fills the display with spaces and resets X/Y */
static void lcd_clear_fast_s(void) {
static void lcd_clear_fast_s(void)
{
int pos;
lcd_addr_x = lcd_addr_y = 0;
lcd_gotoxy();
......@@ -846,7 +858,8 @@ static void lcd_clear_fast_s(void) {
}
/* fills the display with spaces and resets X/Y */
static void lcd_clear_fast_p8(void) {
static void lcd_clear_fast_p8(void)
{
int pos;
lcd_addr_x = lcd_addr_y = 0;
lcd_gotoxy();
......@@ -857,7 +870,9 @@ static void lcd_clear_fast_p8(void) {
w_dtr(pprt, ' ');
udelay(20); /* maintain the data during 20 us before the strobe */
bits.e = BIT_SET ; bits.rs = BIT_SET ; bits.rw = BIT_CLR;
bits.e = BIT_SET;
bits.rs = BIT_SET;
bits.rw = BIT_CLR;
set_ctrl_bits();
udelay(40); /* maintain the strobe during 40 us */
......@@ -874,14 +889,16 @@ static void lcd_clear_fast_p8(void) {
}
/* clears the display and resets X/Y */
static void lcd_clear_display(void) {
static void lcd_clear_display(void)
{
lcd_write_cmd(0x01); /* clear display */
lcd_addr_x = lcd_addr_y = 0;
/* we must wait a few milliseconds (15) */
long_sleep(15);
}
static void lcd_init_display(void) {
static void lcd_init_display(void)
{
lcd_flags = ((lcd_height > 1) ? LCD_FLAG_N : 0)
| LCD_FLAG_D | LCD_FLAG_C | LCD_FLAG_B;
......@@ -896,8 +913,8 @@ static void lcd_init_display(void) {
long_sleep(10);
lcd_write_cmd(0x30 /* set font height and lines number */
| ((lcd_flags & LCD_FLAG_F)?4:0)
| ((lcd_flags & LCD_FLAG_N)?8:0)
| ((lcd_flags & LCD_FLAG_F) ? 4 : 0)
| ((lcd_flags & LCD_FLAG_N) ? 8 : 0)
);
long_sleep(10);
......@@ -905,9 +922,9 @@ static void lcd_init_display(void) {
long_sleep(10);
lcd_write_cmd(0x08 /* set display mode */
| ((lcd_flags & LCD_FLAG_D)?4:0)
| ((lcd_flags & LCD_FLAG_C)?2:0)
| ((lcd_flags & LCD_FLAG_B)?1:0)
| ((lcd_flags & LCD_FLAG_D) ? 4 : 0)
| ((lcd_flags & LCD_FLAG_C) ? 2 : 0)
| ((lcd_flags & LCD_FLAG_B) ? 1 : 0)
);
lcd_backlight((lcd_flags & LCD_FLAG_L) ? 1 : 0);
......@@ -926,27 +943,27 @@ static void lcd_init_display(void) {
*
*/
static ssize_t lcd_write(struct file * file,
const char * buf, size_t count, loff_t *ppos ) {
static ssize_t lcd_write(struct file *file,
const char *buf, size_t count, loff_t *ppos)
{
const char *tmp = buf;
char c;
for( ; count-- > 0; (ppos ? (*ppos)++ : 0), ++tmp ) {
if (!in_interrupt() && (((count + 1) & 0x1f) == 0)) {
for (; count-- > 0; (ppos ? (*ppos)++ : 0), ++tmp) {
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
schedule(); /* let's be a little nice with other processes that need some CPU */
}
if (ppos == NULL && file == NULL)
c = *tmp; /* let's not use get_user() from the kernel ! */
else if (get_user( c, tmp ))
else if (get_user(c, tmp))
return -EFAULT;
/* first, we'll test if we're in escape mode */
if ((c != '\n') && lcd_escape_len >= 0) { /* yes, let's add this char to the buffer */
lcd_escape[lcd_escape_len++] = c;
lcd_escape[lcd_escape_len] = 0;
}
else {
} else {
lcd_escape_len = -1; /* aborts any previous escape sequence */
switch (c) {
......@@ -968,7 +985,7 @@ static ssize_t lcd_write(struct file * file,
break;
case '\n': /* flush the remainder of the current line and go to the
beginning of the next line */
for (; lcd_addr_x<lcd_bwidth; lcd_addr_x++)
for (; lcd_addr_x < lcd_bwidth; lcd_addr_x++)
lcd_write_data(' ');
lcd_addr_x = 0;
lcd_addr_y = (lcd_addr_y + 1) % lcd_height;
......@@ -981,7 +998,7 @@ static ssize_t lcd_write(struct file * file,
case '\t': /* print a space instead of the tab */
lcd_print(' ');
break;
default : /* simply print this char */
default: /* simply print this char */
lcd_print(c);
break;
}
......@@ -993,81 +1010,82 @@ static ssize_t lcd_write(struct file * file,
if (lcd_escape_len >= 2) { /* minimal length for an escape command */
int processed = 0; /* 1 means the command has been processed */
if (!strcmp(lcd_escape,"[2J")) { /* Clear the display */
if (!strcmp(lcd_escape, "[2J")) { /* Clear the display */
lcd_clear_fast(); /* clear display */
processed = 1;
}
else if (!strcmp(lcd_escape,"[H")) { /* Cursor to home */
} else if (!strcmp(lcd_escape, "[H")) { /* Cursor to home */
lcd_addr_x = lcd_addr_y = 0;
lcd_gotoxy();
processed = 1;
}
/* codes starting with ^[[L */
else if ((lcd_escape_len >= 3) &&
(lcd_escape[0]=='[') && (lcd_escape[1]=='L')) { /* LCD special codes */
(lcd_escape[0] == '[') && (lcd_escape[1] == 'L')) { /* LCD special codes */
char *esc = lcd_escape + 2;
int oldflags = lcd_flags;
/* check for display mode flags */
switch (*esc) {
case 'D' : /* Display ON */
case 'D': /* Display ON */
lcd_flags |= LCD_FLAG_D;
processed = 1;
break;
case 'd' : /* Display OFF */
case 'd': /* Display OFF */
lcd_flags &= ~LCD_FLAG_D;
processed = 1;
break;
case 'C' : /* Cursor ON */
case 'C': /* Cursor ON */
lcd_flags |= LCD_FLAG_C;
processed = 1;
break;
case 'c' : /* Cursor OFF */
case 'c': /* Cursor OFF */
lcd_flags &= ~LCD_FLAG_C;
processed = 1;
break;
case 'B' : /* Blink ON */
case 'B': /* Blink ON */
lcd_flags |= LCD_FLAG_B;
processed = 1;
break;
case 'b' : /* Blink OFF */
case 'b': /* Blink OFF */
lcd_flags &= ~LCD_FLAG_B;
processed = 1;
break;
case '+' : /* Back light ON */
case '+': /* Back light ON */
lcd_flags |= LCD_FLAG_L;
processed = 1;
break;
case '-' : /* Back light OFF */
case '-': /* Back light OFF */
lcd_flags &= ~LCD_FLAG_L;
processed = 1;
break;
case '*' : /* flash back light using the keypad timer */
case '*': /* flash back light using the keypad timer */
if (scan_timer.function != NULL) {
if (light_tempo == 0 && ((lcd_flags & LCD_FLAG_L) == 0))
if (light_tempo == 0
&& ((lcd_flags & LCD_FLAG_L)
== 0))
lcd_backlight(1);
light_tempo = FLASH_LIGHT_TEMPO;
}
processed = 1;
break;
case 'f' : /* Small Font */
case 'f': /* Small Font */
lcd_flags &= ~LCD_FLAG_F;
processed = 1;
break;
case 'F' : /* Large Font */
case 'F': /* Large Font */
lcd_flags |= LCD_FLAG_F;
processed = 1;
break;
case 'n' : /* One Line */
case 'n': /* One Line */
lcd_flags &= ~LCD_FLAG_N;
processed = 1;
break;
case 'N' : /* Two Lines */
case 'N': /* Two Lines */
lcd_flags |= LCD_FLAG_N;
break;
case 'l' : /* Shift Cursor Left */
case 'l': /* Shift Cursor Left */
if (lcd_addr_x > 0) {
if (lcd_addr_x < lcd_bwidth)
lcd_write_cmd(0x10); /* back one char if not at end of line */
......@@ -1076,7 +1094,7 @@ static ssize_t lcd_write(struct file * file,
processed = 1;
break;
case 'r' : /* shift cursor right */
case 'r': /* shift cursor right */
if (lcd_addr_x < lcd_width) {
if (lcd_addr_x < (lcd_bwidth - 1))
lcd_write_cmd(0x14); /* allow the cursor to pass the end of the line */
......@@ -1085,33 +1103,33 @@ static ssize_t lcd_write(struct file * file,
processed = 1;
break;
case 'L' : /* shift display left */
case 'L': /* shift display left */
lcd_left_shift++;
lcd_write_cmd(0x18);
processed = 1;
break;
case 'R' : /* shift display right */
case 'R': /* shift display right */
lcd_left_shift--;
lcd_write_cmd(0x1C);
processed = 1;
break;
case 'k' : { /* kill end of line */
case 'k':{ /* kill end of line */
int x;
for (x=lcd_addr_x; x<lcd_bwidth; x++)
for (x = lcd_addr_x; x < lcd_bwidth; x++)
lcd_write_data(' ');
lcd_gotoxy(); /* restore cursor position */
processed = 1;
break;
}
case 'I' : /* reinitialize display */
case 'I': /* reinitialize display */
lcd_init_display();
lcd_left_shift = 0;
processed = 1;
break;
case 'G' : /* Generator : LGcxxxxx...xx; */ {
case 'G': /* Generator : LGcxxxxx...xx; */ {
/* must have <c> between '0' and '7', representing the numerical
* ASCII code of the redefined character, and <xx...xx> a sequence
* of 16 hex digits representing 8 bytes for each character. Most
......@@ -1141,11 +1159,11 @@ static ssize_t lcd_write(struct file * file,
value = 0;
while (*esc && cgoffset < 8) {
shift ^= 4;
if (*esc >= '0' && *esc <='9')
if (*esc >= '0' && *esc <= '9')
value |= (*esc - '0') << shift;
else if (*esc >= 'A' && *esc <='Z')
else if (*esc >= 'A' && *esc <= 'Z')
value |= (*esc - 'A' + 10) << shift;
else if (*esc >= 'a' && *esc <='z')
else if (*esc >= 'a' && *esc <= 'z')
value |= (*esc - 'a' + 10) << shift;
else {
esc++;
......@@ -1161,16 +1179,15 @@ static ssize_t lcd_write(struct file * file,
}
lcd_write_cmd(0x40 | (cgaddr * 8));
for (addr = 0; addr < cgoffset; addr++) {
for (addr = 0; addr < cgoffset; addr++)
lcd_write_data(cgbytes[addr]);
}
lcd_gotoxy(); /* ensures that we stop writing to CGRAM */
processed = 1;
break;
}
case 'x' : /* gotoxy : LxXXX[yYYY]; */
case 'y' : /* gotoxy : LyYYY[xXXX]; */
case 'x': /* gotoxy : LxXXX[yYYY]; */
case 'y': /* gotoxy : LyYYY[xXXX]; */
if (strchr(esc, ';') == NULL)
break;
......@@ -1179,19 +1196,24 @@ static ssize_t lcd_write(struct file * file,
esc++;
lcd_addr_x = 0;
while (isdigit(*esc)) {
lcd_addr_x = lcd_addr_x*10 + (*esc - '0');
lcd_addr_x =
lcd_addr_x *
10 + (*esc -
'0');
esc++;
}
}
else if (*esc == 'y') {
} else if (*esc == 'y') {
esc++;
lcd_addr_y = 0;
while (isdigit(*esc)) {
lcd_addr_y = lcd_addr_y*10 + (*esc - '0');
lcd_addr_y =
lcd_addr_y *
10 + (*esc -
'0');
esc++;
}
}
else break;
} else
break;
}
lcd_gotoxy();
......@@ -1202,28 +1224,31 @@ static ssize_t lcd_write(struct file * file,
/* Check wether one flag was changed */
if (oldflags != lcd_flags) {
/* check wether one of B,C,D flags was changed */
if ((oldflags ^ lcd_flags) & (LCD_FLAG_B | LCD_FLAG_C | LCD_FLAG_D))
lcd_write_cmd(0x08 /* set display mode */
| ((lcd_flags & LCD_FLAG_D)?4:0)
| ((lcd_flags & LCD_FLAG_C)?2:0)
| ((lcd_flags & LCD_FLAG_B)?1:0)
);
if ((oldflags ^ lcd_flags) &
(LCD_FLAG_B | LCD_FLAG_C | LCD_FLAG_D))
/* set display mode */
lcd_write_cmd(0x08 |
((lcd_flags & LCD_FLAG_D) ? 4 : 0) |
((lcd_flags & LCD_FLAG_C) ? 2 : 0) |
((lcd_flags & LCD_FLAG_B) ? 1 : 0));
/* check wether one of F,N flags was changed */
else if ((oldflags ^ lcd_flags) & (LCD_FLAG_F | LCD_FLAG_N))
lcd_write_cmd(0x30
| ((lcd_flags & LCD_FLAG_F)?4:0)
| ((lcd_flags & LCD_FLAG_N)?8:0)
);
else if ((oldflags ^ lcd_flags) &
(LCD_FLAG_F | LCD_FLAG_N))
lcd_write_cmd(0x30 |
((lcd_flags & LCD_FLAG_F) ? 4 : 0) |
((lcd_flags & LCD_FLAG_N) ? 8 : 0));
/* check wether L flag was changed */
else if ((oldflags ^ lcd_flags) & (LCD_FLAG_L)) {
else if ((oldflags ^ lcd_flags) &
(LCD_FLAG_L)) {
if (lcd_flags & (LCD_FLAG_L))
lcd_backlight(1);
else if (light_tempo == 0) /* switch off the light only when the tempo lighting is gone */
lcd_backlight(0);
}
}
} /* LCD special escape codes */
}
/* LCD special escape codes */
/* flush the escape sequence if it's been processed or if it is
getting too long. */
if (processed || (lcd_escape_len >= LCD_ESCAPE_LEN))
......@@ -1231,34 +1256,35 @@ static ssize_t lcd_write(struct file * file,
} /* escape codes */
}
return( tmp - buf );
return tmp - buf;
}
static int lcd_open( struct inode *inode, struct file *file ) {
static int lcd_open(struct inode *inode, struct file *file)
{
if (lcd_open_cnt)
return( -EBUSY ); /* open only once at a time */
return -EBUSY; /* open only once at a time */
if (file->f_mode & FMODE_READ) /* device is write-only */
return ( -EPERM );
return -EPERM;
if (lcd_must_clear) {
lcd_clear_display();
lcd_must_clear = 0;
}
lcd_open_cnt++;
return( 0 );
return 0;
}
static int lcd_release( struct inode *inode, struct file *file ) {
static int lcd_release(struct inode *inode, struct file *file)
{
lcd_open_cnt--;
return( 0 );
return 0;
}
static struct file_operations lcd_fops = {
write: lcd_write,
open: lcd_open,
release: lcd_release,
.write = lcd_write,
.open = lcd_open,
.release = lcd_release,
};
static struct miscdevice lcd_dev = {
......@@ -1267,77 +1293,116 @@ static struct miscdevice lcd_dev = {
&lcd_fops
};
/* public function usable from the kernel for any purpose */
void panel_lcd_print(char *s) {
void panel_lcd_print(char *s)
{
if (lcd_enabled && lcd_initialized)
lcd_write(NULL, s, strlen(s), NULL);
}
/* initialize the LCD driver */
void lcd_init(void) {
void lcd_init(void)
{
switch (lcd_type) {
case LCD_TYPE_OLD : /* parallel mode, 8 bits */
if (lcd_proto < 0) lcd_proto = LCD_PROTO_PARALLEL;
if (lcd_charset < 0) lcd_charset = LCD_CHARSET_NORMAL;
if (lcd_e_pin == PIN_NOT_SET) lcd_e_pin = PIN_STROBE;
if (lcd_rs_pin == PIN_NOT_SET) lcd_rs_pin = PIN_AUTOLF;
if (lcd_width < 0) lcd_width = 40;
if (lcd_bwidth < 0) lcd_bwidth = 40;
if (lcd_hwidth < 0) lcd_hwidth = 64;
if (lcd_height < 0) lcd_height = 2;
break;
case LCD_TYPE_KS0074 : /* serial mode, ks0074 */
if (lcd_proto < 0) lcd_proto = LCD_PROTO_SERIAL;
if (lcd_charset < 0) lcd_charset = LCD_CHARSET_KS0074;
if (lcd_bl_pin == PIN_NOT_SET) lcd_bl_pin = PIN_AUTOLF;
if (lcd_cl_pin == PIN_NOT_SET) lcd_cl_pin = PIN_STROBE;
if (lcd_da_pin == PIN_NOT_SET) lcd_da_pin = PIN_D0;
if (lcd_width < 0) lcd_width = 16;
if (lcd_bwidth < 0) lcd_bwidth = 40;
if (lcd_hwidth < 0) lcd_hwidth = 16;
if (lcd_height < 0) lcd_height = 2;
break;
case LCD_TYPE_NEXCOM : /* parallel mode, 8 bits, generic */
if (lcd_proto < 0) lcd_proto = LCD_PROTO_PARALLEL;
if (lcd_charset < 0) lcd_charset = LCD_CHARSET_NORMAL;
if (lcd_e_pin == PIN_NOT_SET) lcd_e_pin = PIN_AUTOLF;
if (lcd_rs_pin == PIN_NOT_SET) lcd_rs_pin = PIN_SELECP;
if (lcd_rw_pin == PIN_NOT_SET) lcd_rw_pin = PIN_INITP;
if (lcd_width < 0) lcd_width = 16;
if (lcd_bwidth < 0) lcd_bwidth = 40;
if (lcd_hwidth < 0) lcd_hwidth = 64;
if (lcd_height < 0) lcd_height = 2;
break;
case LCD_TYPE_CUSTOM : /* customer-defined */
if (lcd_proto < 0) lcd_proto = DEFAULT_LCD_PROTO;
if (lcd_charset < 0) lcd_charset = DEFAULT_LCD_CHARSET;
case LCD_TYPE_OLD: /* parallel mode, 8 bits */
if (lcd_proto < 0)
lcd_proto = LCD_PROTO_PARALLEL;
if (lcd_charset < 0)
lcd_charset = LCD_CHARSET_NORMAL;
if (lcd_e_pin == PIN_NOT_SET)
lcd_e_pin = PIN_STROBE;
if (lcd_rs_pin == PIN_NOT_SET)
lcd_rs_pin = PIN_AUTOLF;
if (lcd_width < 0)
lcd_width = 40;
if (lcd_bwidth < 0)
lcd_bwidth = 40;
if (lcd_hwidth < 0)
lcd_hwidth = 64;
if (lcd_height < 0)
lcd_height = 2;
break;
case LCD_TYPE_KS0074: /* serial mode, ks0074 */
if (lcd_proto < 0)
lcd_proto = LCD_PROTO_SERIAL;
if (lcd_charset < 0)
lcd_charset = LCD_CHARSET_KS0074;
if (lcd_bl_pin == PIN_NOT_SET)
lcd_bl_pin = PIN_AUTOLF;
if (lcd_cl_pin == PIN_NOT_SET)
lcd_cl_pin = PIN_STROBE;
if (lcd_da_pin == PIN_NOT_SET)
lcd_da_pin = PIN_D0;
if (lcd_width < 0)
lcd_width = 16;
if (lcd_bwidth < 0)
lcd_bwidth = 40;
if (lcd_hwidth < 0)
lcd_hwidth = 16;
if (lcd_height < 0)
lcd_height = 2;
break;
case LCD_TYPE_NEXCOM: /* parallel mode, 8 bits, generic */
if (lcd_proto < 0)
lcd_proto = LCD_PROTO_PARALLEL;
if (lcd_charset < 0)
lcd_charset = LCD_CHARSET_NORMAL;
if (lcd_e_pin == PIN_NOT_SET)
lcd_e_pin = PIN_AUTOLF;
if (lcd_rs_pin == PIN_NOT_SET)
lcd_rs_pin = PIN_SELECP;
if (lcd_rw_pin == PIN_NOT_SET)
lcd_rw_pin = PIN_INITP;
if (lcd_width < 0)
lcd_width = 16;
if (lcd_bwidth < 0)
lcd_bwidth = 40;
if (lcd_hwidth < 0)
lcd_hwidth = 64;
if (lcd_height < 0)
lcd_height = 2;
break;
case LCD_TYPE_CUSTOM: /* customer-defined */
if (lcd_proto < 0)
lcd_proto = DEFAULT_LCD_PROTO;
if (lcd_charset < 0)
lcd_charset = DEFAULT_LCD_CHARSET;
/* default geometry will be set later */
break;
case LCD_TYPE_HANTRONIX : /* parallel mode, 8 bits, hantronix-like */
default :
if (lcd_proto < 0) lcd_proto = LCD_PROTO_PARALLEL;
if (lcd_charset < 0) lcd_charset = LCD_CHARSET_NORMAL;
if (lcd_e_pin == PIN_NOT_SET) lcd_e_pin = PIN_STROBE;
if (lcd_rs_pin == PIN_NOT_SET) lcd_rs_pin = PIN_SELECP;
case LCD_TYPE_HANTRONIX: /* parallel mode, 8 bits, hantronix-like */
default:
if (lcd_proto < 0)
lcd_proto = LCD_PROTO_PARALLEL;
if (lcd_charset < 0)
lcd_charset = LCD_CHARSET_NORMAL;
if (lcd_e_pin == PIN_NOT_SET)
lcd_e_pin = PIN_STROBE;
if (lcd_rs_pin == PIN_NOT_SET)
lcd_rs_pin = PIN_SELECP;
if (lcd_width < 0) lcd_width = 16;
if (lcd_bwidth < 0) lcd_bwidth = 40;
if (lcd_hwidth < 0) lcd_hwidth = 64;
if (lcd_height < 0) lcd_height = 2;
if (lcd_width < 0)
lcd_width = 16;
if (lcd_bwidth < 0)
lcd_bwidth = 40;
if (lcd_hwidth < 0)
lcd_hwidth = 64;
if (lcd_height < 0)
lcd_height = 2;
break;
}
/* this is used to catch wrong and default values */
if (lcd_width <= 0) lcd_width = DEFAULT_LCD_WIDTH;
if (lcd_bwidth <= 0) lcd_bwidth = DEFAULT_LCD_BWIDTH;
if (lcd_hwidth <= 0) lcd_hwidth = DEFAULT_LCD_HWIDTH;
if (lcd_height <= 0) lcd_height = DEFAULT_LCD_HEIGHT;
if (lcd_width <= 0)
lcd_width = DEFAULT_LCD_WIDTH;
if (lcd_bwidth <= 0)
lcd_bwidth = DEFAULT_LCD_BWIDTH;
if (lcd_hwidth <= 0)
lcd_hwidth = DEFAULT_LCD_HWIDTH;
if (lcd_height <= 0)
lcd_height = DEFAULT_LCD_HEIGHT;
if (lcd_proto == LCD_PROTO_SERIAL) { /* SERIAL */
lcd_write_cmd = lcd_write_cmd_s;
......@@ -1365,12 +1430,18 @@ void lcd_init(void) {
if (lcd_bl_pin == PIN_NOT_SET)
lcd_bl_pin = DEFAULT_LCD_PIN_BL;
if (lcd_e_pin == PIN_NOT_SET) lcd_e_pin = PIN_NONE;
if (lcd_rs_pin == PIN_NOT_SET) lcd_rs_pin = PIN_NONE;
if (lcd_rw_pin == PIN_NOT_SET) lcd_rw_pin = PIN_NONE;
if (lcd_bl_pin == PIN_NOT_SET) lcd_bl_pin = PIN_NONE;
if (lcd_cl_pin == PIN_NOT_SET) lcd_cl_pin = PIN_NONE;
if (lcd_da_pin == PIN_NOT_SET) lcd_da_pin = PIN_NONE;
if (lcd_e_pin == PIN_NOT_SET)
lcd_e_pin = PIN_NONE;
if (lcd_rs_pin == PIN_NOT_SET)
lcd_rs_pin = PIN_NONE;
if (lcd_rw_pin == PIN_NOT_SET)
lcd_rw_pin = PIN_NONE;
if (lcd_bl_pin == PIN_NOT_SET)
lcd_bl_pin = PIN_NONE;
if (lcd_cl_pin == PIN_NOT_SET)
lcd_cl_pin = PIN_NONE;
if (lcd_da_pin == PIN_NOT_SET)
lcd_da_pin = PIN_NONE;
if (lcd_charset < 0)
lcd_charset = DEFAULT_LCD_CHARSET;
......@@ -1383,12 +1454,18 @@ void lcd_init(void) {
if (lcd_bl_pin != PIN_NONE)
init_scan_timer();
pin_to_bits(lcd_e_pin, lcd_bits[LCD_PORT_D][LCD_BIT_E], lcd_bits[LCD_PORT_C][LCD_BIT_E]);
pin_to_bits(lcd_rs_pin, lcd_bits[LCD_PORT_D][LCD_BIT_RS], lcd_bits[LCD_PORT_C][LCD_BIT_RS]);
pin_to_bits(lcd_rw_pin, lcd_bits[LCD_PORT_D][LCD_BIT_RW], lcd_bits[LCD_PORT_C][LCD_BIT_RW]);
pin_to_bits(lcd_bl_pin, lcd_bits[LCD_PORT_D][LCD_BIT_BL], lcd_bits[LCD_PORT_C][LCD_BIT_BL]);
pin_to_bits(lcd_cl_pin, lcd_bits[LCD_PORT_D][LCD_BIT_CL], lcd_bits[LCD_PORT_C][LCD_BIT_CL]);
pin_to_bits(lcd_da_pin, lcd_bits[LCD_PORT_D][LCD_BIT_DA], lcd_bits[LCD_PORT_C][LCD_BIT_DA]);
pin_to_bits(lcd_e_pin, lcd_bits[LCD_PORT_D][LCD_BIT_E],
lcd_bits[LCD_PORT_C][LCD_BIT_E]);
pin_to_bits(lcd_rs_pin, lcd_bits[LCD_PORT_D][LCD_BIT_RS],
lcd_bits[LCD_PORT_C][LCD_BIT_RS]);
pin_to_bits(lcd_rw_pin, lcd_bits[LCD_PORT_D][LCD_BIT_RW],
lcd_bits[LCD_PORT_C][LCD_BIT_RW]);
pin_to_bits(lcd_bl_pin, lcd_bits[LCD_PORT_D][LCD_BIT_BL],
lcd_bits[LCD_PORT_C][LCD_BIT_BL]);
pin_to_bits(lcd_cl_pin, lcd_bits[LCD_PORT_D][LCD_BIT_CL],
lcd_bits[LCD_PORT_C][LCD_BIT_CL]);
pin_to_bits(lcd_da_pin, lcd_bits[LCD_PORT_D][LCD_BIT_DA],
lcd_bits[LCD_PORT_C][LCD_BIT_DA]);
/* before this line, we must NOT send anything to the display.
* Since lcd_init_display() needs to write data, we have to
......@@ -1403,20 +1480,21 @@ void lcd_init(void) {
panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*" CONFIG_PANEL_BOOT_MESSAGE);
#endif
#else
panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*Linux-" UTS_RELEASE "\nPanel-" PANEL_VERSION);
panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*Linux-" UTS_RELEASE "\nPanel-"
PANEL_VERSION);
#endif
lcd_addr_x = lcd_addr_y = 0;
lcd_must_clear = 1; /* clear the display on the next device opening */
lcd_gotoxy();
}
/*
* These are the file operation function for user access to /dev/keypad
*/
static ssize_t keypad_read(struct file * file,
char * buf, size_t count, loff_t *ppos ) {
static ssize_t keypad_read(struct file *file,
char *buf, size_t count, loff_t *ppos)
{
unsigned i = *ppos;
char *tmp = buf;
......@@ -1425,47 +1503,44 @@ static ssize_t keypad_read(struct file * file,
if (file->f_flags & O_NONBLOCK)
return -EAGAIN;
//printk(KERN_ERR "keypad_read():1 len=%d", keypad_buflen);
interruptible_sleep_on(&keypad_read_wait);
//printk(KERN_ERR "keypad_read():2 len=%d", keypad_buflen);
if (signal_pending(current))
return -EINTR;
}
//printk(KERN_ERR "keypad_read():3 len=%d", keypad_buflen);
for( ; count-- > 0 && (keypad_buflen > 0); ++i, ++tmp, --keypad_buflen ) {
put_user( keypad_buffer[keypad_start], tmp );
for (; count-- > 0 && (keypad_buflen > 0); ++i, ++tmp, --keypad_buflen) {
put_user(keypad_buffer[keypad_start], tmp);
keypad_start = (keypad_start + 1) % KEYPAD_BUFFER;
}
*ppos = i;
//printk(KERN_ERR "keypad_read():4 len=%d", keypad_buflen);
return( tmp - buf );
return tmp - buf;
}
static int keypad_open( struct inode *inode, struct file *file ) {
static int keypad_open(struct inode *inode, struct file *file)
{
if (keypad_open_cnt)
return( -EBUSY ); /* open only once at a time */
return -EBUSY; /* open only once at a time */
if (file->f_mode & FMODE_WRITE) /* device is read-only */
return ( -EPERM );
return -EPERM;
keypad_buflen = 0; /* flush the buffer on opening */
keypad_open_cnt++;
return( 0 );
return 0;
}
static int keypad_release( struct inode *inode, struct file *file ) {
static int keypad_release(struct inode *inode, struct file *file)
{
keypad_open_cnt--;
return( 0 );
return 0;
}
static struct file_operations keypad_fops = {
read: keypad_read, /* read */
open: keypad_open, /* open */
release: keypad_release, /* close */
.read = keypad_read, /* read */
.open = keypad_open, /* open */
.release = keypad_release, /* close */
};
static struct miscdevice keypad_dev = {
......@@ -1474,25 +1549,21 @@ static struct miscdevice keypad_dev = {
&keypad_fops
};
static void keypad_send_key(char *string, int max_len) {
//printk(KERN_ERR "keypad_send_key(%c,%d):1\n", *string,max_len);
static void keypad_send_key(char *string, int max_len)
{
if (init_in_progress)
return;
//printk(KERN_ERR "keypad_send_key(%c,%d):2\n", *string,max_len);
/* send the key to the device only if a process is attached to it. */
if (keypad_open_cnt > 0) {
//printk(KERN_ERR "keypad_send_key(%c,%d):3\n", *string,max_len);
while (max_len-- && keypad_buflen < KEYPAD_BUFFER && *string) {
keypad_buffer[(keypad_start + keypad_buflen++) % KEYPAD_BUFFER] = *string++;
keypad_buffer[(keypad_start + keypad_buflen++) %
KEYPAD_BUFFER] = *string++;
}
//printk(KERN_ERR "keypad_send_key(%d):4\n", *string,max_len);
wake_up_interruptible(&keypad_read_wait);
}
//printk(KERN_ERR "keypad_send_key(%d):5\n", *string,max_len);
}
/* this function scans all the bits involving at least one logical signal, and puts the
* results in the bitfield "phys_read" (one bit per established contact), and sets
* "phys_read_prev" to "phys_read".
......@@ -1502,7 +1573,8 @@ static void keypad_send_key(char *string, int max_len) {
* as they previously were in their logical form (phys_prev). A signal which has just
* switched will have a 1 in (phys_read ^ phys_read_prev).
*/
static void phys_scan_contacts(void) {
static void phys_scan_contacts(void)
{
int bit, bitval;
char oldval;
char bitmask;
......@@ -1522,13 +1594,13 @@ static void phys_scan_contacts(void) {
*/
gndmask = PNL_PINPUT(r_str(pprt)) & scan_mask_i; /* 1 for each grounded input */
phys_read |= (pmask_t)gndmask << 40; /* grounded inputs are signals 40-44 */
phys_read |= (pmask_t) gndmask << 40; /* grounded inputs are signals 40-44 */
if (bitmask != gndmask) {
/* since clearing the outputs changed some inputs, we know that some
* input signals are currently tied to some outputs. So we'll scan them.
*/
for (bit = 0; bit < 8; bit ++) {
for (bit = 0; bit < 8; bit++) {
bitval = 1 << bit;
if (!(scan_mask_o & bitval)) /* skip unused bits */
......@@ -1536,20 +1608,25 @@ static void phys_scan_contacts(void) {
w_dtr(pprt, oldval & ~bitval); /* enable this output */
bitmask = PNL_PINPUT(r_str(pprt)) & ~gndmask;
phys_read |= (pmask_t) bitmask << (5*bit);
phys_read |= (pmask_t) bitmask << (5 * bit);
}
w_dtr(pprt, oldval); /* disable all outputs */
}
/* this is easy: use old bits when they are flapping, use new ones when stable */
phys_curr = (phys_prev & (phys_read ^ phys_read_prev)) | (phys_read & ~(phys_read ^ phys_read_prev));
phys_curr =
(phys_prev & (phys_read ^ phys_read_prev)) | (phys_read &
~(phys_read ^
phys_read_prev));
}
static void panel_process_inputs(void) {
static void panel_process_inputs(void)
{
struct list_head *item;
struct logical_input *input;
#if 0
printk(KERN_DEBUG "entering panel_process_inputs with pp=%016Lx & pc=%016Lx\n",
printk(KERN_DEBUG
"entering panel_process_inputs with pp=%016Lx & pc=%016Lx\n",
phys_prev, phys_curr);
#endif
......@@ -1606,38 +1683,51 @@ static void panel_process_inputs(void) {
input->state = INPUT_ST_LOW; /* invalidate */
break;
}
//else
#endif
if ((phys_curr & input->mask) == input->value) {
if ((input->type == INPUT_TYPE_STD) && (input->high_timer == 0)) {
if ((input->type == INPUT_TYPE_STD)
&& (input->high_timer == 0)) {
input->high_timer++;
if (input->u.std.press_fct != NULL)
input->u.std.press_fct(input->u.std.press_data);
}
else if (input->type == INPUT_TYPE_KBD) {
input->u.std.press_fct(input->u.
std.
press_data);
} else if (input->type == INPUT_TYPE_KBD) {
keypressed = 1; /* will turn on the light */
if (input->high_timer == 0) {
if (input->u.kbd.press_str[0])
keypad_send_key(input->u.kbd.press_str, sizeof(input->u.kbd.press_str));
keypad_send_key(input->
u.kbd.
press_str,
sizeof
(input->
u.kbd.
press_str));
}
if (input->u.kbd.repeat_str[0]) {
if (input->high_timer >= KEYPAD_REP_START) {
input->high_timer -= KEYPAD_REP_DELAY;
keypad_send_key(input->u.kbd.repeat_str, sizeof(input->u.kbd.repeat_str));
if (input->high_timer >=
KEYPAD_REP_START) {
input->high_timer -=
KEYPAD_REP_DELAY;
keypad_send_key(input->
u.kbd.
repeat_str,
sizeof
(input->
u.kbd.
repeat_str));
}
inputs_stable = 0; /* we will need to come back here soon */
}
if (input->high_timer < 255) {
if (input->high_timer < 255)
input->high_timer++;
}
}
break;
}
else {
} else {
/* else signal falling down. Let's fall through. */
input->state = INPUT_ST_FALLING;
input->fall_timer = 0;
......@@ -1651,7 +1741,6 @@ static void panel_process_inputs(void) {
input->state = INPUT_ST_LOW; /* invalidate */
break;
}
//else
#endif
if ((phys_curr & input->mask) == input->value) {
......@@ -1661,32 +1750,31 @@ static void panel_process_inputs(void) {
if (input->u.kbd.repeat_str[0]) {
if (input->high_timer >= KEYPAD_REP_START)
input->high_timer -= KEYPAD_REP_DELAY;
keypad_send_key(input->u.kbd.repeat_str, sizeof(input->u.kbd.repeat_str));
keypad_send_key(input->u.kbd.repeat_str,
sizeof(input->u.kbd.repeat_str));
inputs_stable = 0; /* we will need to come back here soon */
}
if (input->high_timer < 255) {
if (input->high_timer < 255)
input->high_timer++;
}
}
input->state = INPUT_ST_HIGH;
break;
}
else if (input->fall_timer >= input->fall_time) {
} else if (input->fall_timer >= input->fall_time) {
/* call release event */
if (input->type == INPUT_TYPE_STD) {
if (input->u.std.release_fct != NULL)
input->u.std.release_fct(input->u.std.release_data);
}
else if (input->type == INPUT_TYPE_KBD) {
} else if (input->type == INPUT_TYPE_KBD) {
if (input->u.kbd.release_str[0])
keypad_send_key(input->u.kbd.release_str, sizeof(input->u.kbd.release_str));
keypad_send_key(input->u.kbd.release_str,
sizeof(input->u.kbd.release_str));
}
input->state = INPUT_ST_LOW;
break;
}
else {
} else {
input->fall_timer++;
inputs_stable = 0;
break;
......@@ -1695,7 +1783,8 @@ static void panel_process_inputs(void) {
}
}
static void panel_scan_timer(void) {
static void panel_scan_timer(void)
{
if ((keypad_enabled && keypad_initialized)
|| (smartcard_enabled && smartcard_enabled)) {
......@@ -1704,18 +1793,16 @@ static void panel_scan_timer(void) {
spin_unlock(&pprt_lock); /* no need for the parport anymore */
}
if (!inputs_stable || phys_curr != phys_prev) {
if (!inputs_stable || phys_curr != phys_prev)
panel_process_inputs();
}
}
if (lcd_enabled && lcd_initialized) {
if (keypressed) {
if (light_tempo == 0 && ((lcd_flags & LCD_FLAG_L) == 0))
lcd_backlight(1);
light_tempo = FLASH_LIGHT_TEMPO;
}
else if (light_tempo > 0) {
} else if (light_tempo > 0) {
light_tempo--;
if (light_tempo == 0 && ((lcd_flags & LCD_FLAG_L) == 0))
lcd_backlight(0);
......@@ -1726,7 +1813,8 @@ static void panel_scan_timer(void) {
}
/* send a high / low clock impulse of <duration> microseconds high and low */
static void smartcard_send_clock(int duration) {
static void smartcard_send_clock(int duration)
{
int old;
w_dtr(pprt, (old = r_dtr(pprt)) | PNL_SC_CLK);
......@@ -1735,7 +1823,8 @@ static void smartcard_send_clock(int duration) {
udelay(duration);
}
static void smartcard_insert(int dummy) {
static void smartcard_insert(int dummy)
{
int ofs;
spin_lock(&pprt_lock);
......@@ -1771,7 +1860,8 @@ static void smartcard_insert(int dummy) {
keypad_send_key("CardIn\n", 7);
}
static void smartcard_remove(int dummy) {
static void smartcard_remove(int dummy)
{
printk(KERN_INFO "Panel: smart card removed : %02x%02x%02x%02x%1x\n",
smartcard_data[2], smartcard_data[3], smartcard_data[4],
smartcard_data[5], smartcard_data[6] >> 4);
......@@ -1783,46 +1873,52 @@ static void smartcard_remove(int dummy) {
* These are the file operation function for user access to /dev/smartcard
*/
static ssize_t smartcard_read(struct file * file,
char * buf, size_t count, loff_t *ppos ) {
static ssize_t smartcard_read(struct file *file,
char *buf, size_t count, loff_t *ppos)
{
unsigned i = *ppos;
char *tmp = buf;
for( ; count-- > 0 && (smartcard_ptr < 9); ++i, ++tmp, ++smartcard_ptr ) {
for (; count-- > 0 && (smartcard_ptr < 9); ++i, ++tmp, ++smartcard_ptr) {
if (smartcard_ptr & 1)
put_user( '0' + (smartcard_data[2 + (smartcard_ptr >> 1)] & 0xF), tmp );
put_user('0' +
(smartcard_data[2 + (smartcard_ptr >> 1)] &
0xF), tmp);
else
put_user( '0' + (smartcard_data[2 + (smartcard_ptr >> 1)] >> 4), tmp );
put_user('0' +
(smartcard_data[2 + (smartcard_ptr >> 1)] >>
4), tmp);
}
*ppos = i;
return( tmp - buf );
return tmp - buf;
}
static int smartcard_open( struct inode *inode, struct file *file ) {
static int smartcard_open(struct inode *inode, struct file *file)
{
if (smartcard_open_cnt)
return( -EBUSY ); /* open only once at a time */
return -EBUSY; /* open only once at a time */
if (file->f_mode & FMODE_WRITE) /* device is read-only */
return ( -EPERM );
return -EPERM;
smartcard_ptr = 0; /* flush the buffer on opening */
smartcard_open_cnt++;
return( 0 );
return 0;
}
static int smartcard_release( struct inode *inode, struct file *file ) {
static int smartcard_release(struct inode *inode, struct file *file)
{
smartcard_open_cnt--;
return( 0 );
return 0;
}
static struct file_operations smartcard_fops = {
read: smartcard_read, /* read */
open: smartcard_open, /* open */
release: smartcard_release, /* close */
.read = smartcard_read, /* read */
.open = smartcard_open, /* open */
.release = smartcard_release, /* close */
};
static struct miscdevice smartcard_dev = {
......@@ -1831,7 +1927,8 @@ static struct miscdevice smartcard_dev = {
&smartcard_fops
};
static void init_scan_timer(void) {
static void init_scan_timer(void)
{
if (scan_timer.function != NULL)
return; /* already started */
......@@ -1847,15 +1944,18 @@ static void init_scan_timer(void) {
* to out and in bits respectively.
* returns 1 if ok, 0 if error (in which case, nothing is written).
*/
static int input_name2mask(char *name, pmask_t *mask, pmask_t *value, char *imask, char *omask) {
static char sigtab[10]="EeSsPpAaBb";
static int input_name2mask(char *name, pmask_t *mask, pmask_t *value,
char *imask, char *omask)
{
static char sigtab[10] = "EeSsPpAaBb";
char im, om;
pmask_t m, v;
om = im = m = v = 0ULL;
while (*name) {
int in, out, bit, neg;
for (in = 0; (in < sizeof(sigtab)) && (sigtab[in] != *name); in++);
for (in = 0; (in < sizeof(sigtab)) && (sigtab[in] != *name); in++)
;
if (in >= sizeof(sigtab))
return 0; /* input name not found */
neg = (in & 1); /* odd (lower) names are negated */
......@@ -1866,8 +1966,7 @@ static int input_name2mask(char *name, pmask_t *mask, pmask_t *value, char *imas
if (isdigit(*name)) {
out = *name - '0';
om |= (1 << out);
}
else if (*name == '-')
} else if (*name == '-')
out = 8;
else
return 0; /* unknown bit name */
......@@ -1892,28 +1991,34 @@ static int input_name2mask(char *name, pmask_t *mask, pmask_t *value, char *imas
* strings <press>, <repeat>, <release> for these respective events.
* Returns the pointer to the new key if ok, NULL if the key could not be bound.
*/
static struct logical_input *panel_bind_key(char *name, char *press, char *repeat, char *release) {
static struct logical_input *panel_bind_key(char *name, char *press,
char *repeat, char *release)
{
struct logical_input *key;
key = (struct logical_input*)kmalloc(sizeof(struct logical_input), GFP_KERNEL);
key = kmalloc(sizeof(struct logical_input), GFP_KERNEL);
if (!key) {
printk(KERN_ERR "panel: not enough memory\n");
return NULL;
}
memset(key, 0, sizeof(struct logical_input));
if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i, &scan_mask_o))
if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i,
&scan_mask_o))
return NULL;
key->type = INPUT_TYPE_KBD;
key->state = INPUT_ST_LOW;
key->rise_time = 1;
key->fall_time = 1;
#if 0
printk(KERN_DEBUG "bind: <%s> : m=%016Lx v=%016Lx\n", name, key->mask, key->value);
printk(KERN_DEBUG "bind: <%s> : m=%016Lx v=%016Lx\n", name, key->mask,
key->value);
#endif
strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str));
strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str));
strncpy(key->u.kbd.release_str, release, sizeof(key->u.kbd.release_str));
strncpy(key->u.kbd.release_str, release,
sizeof(key->u.kbd.release_str));
list_add(&key->list, &logical_inputs);
return key;
}
......@@ -1924,18 +2029,23 @@ static struct logical_input *panel_bind_key(char *name, char *press, char *repea
* Returns the pointer to the new signal if ok, NULL if the signal could not be bound.
*/
static struct logical_input *panel_bind_callback(char *name,
void (*press_fct)(int), int press_data,
void (*release_fct)(int), int release_data) {
void (*press_fct) (int),
int press_data,
void (*release_fct) (int),
int release_data)
{
struct logical_input *callback;
callback = (struct logical_input*)kmalloc(sizeof(struct logical_input), GFP_KERNEL);
callback = kmalloc(sizeof(struct logical_input), GFP_KERNEL);
if (!callback) {
printk(KERN_ERR "panel: not enough memory\n");
return NULL;
}
memset(callback, 0, sizeof(struct logical_input));
if (!input_name2mask(name, &callback->mask, &callback->value, &scan_mask_i, &scan_mask_o))
if (!input_name2mask(name, &callback->mask, &callback->value,
&scan_mask_i, &scan_mask_o))
return NULL;
callback->type = INPUT_TYPE_STD;
callback->state = INPUT_ST_LOW;
callback->rise_time = 1;
......@@ -1948,7 +2058,8 @@ static struct logical_input *panel_bind_callback(char *name,
return callback;
}
static void keypad_init(void) {
static void keypad_init(void)
{
int keynum;
init_waitqueue_head(&keypad_read_wait);
keypad_buflen = 0; /* flushes any eventual noisy keystroke */
......@@ -1966,16 +2077,16 @@ static void keypad_init(void) {
keypad_initialized = 1;
}
static void smartcard_init(void) {
static void smartcard_init(void)
{
init_waitqueue_head(&smartcard_read_wait);
panel_bind_callback(SMARTCARD_LOGICAL_DETECTOR, &smartcard_insert, 0, &smartcard_remove, 0);
panel_bind_callback(SMARTCARD_LOGICAL_DETECTOR, &smartcard_insert, 0,
&smartcard_remove, 0);
init_scan_timer();
smartcard_enabled = 1;
}
/**************************************************/
/* device initialization */
/**************************************************/
......@@ -2015,45 +2126,36 @@ __initfunc(void panel_setup(char *str, int *ints))
if (!strncmp(str, "parport:", 8)) {
str += 8;
where = &parport;
}
else if (!strncmp(str, "disabled", 8)) {
} else if (!strncmp(str, "disabled", 8)) {
return 0;
}
else if (!strncmp(str, "lcd_height:", 11)) {
} else if (!strncmp(str, "lcd_height:", 11)) {
str += 11;
where = &lcd_height;
}
else if (!strncmp(str, "lcd_width:", 10)) {
} else if (!strncmp(str, "lcd_width:", 10)) {
str += 10;
where = &lcd_width;
}
else if (!strncmp(str, "lcd_bwidth:", 11)) {
} else if (!strncmp(str, "lcd_bwidth:", 11)) {
str += 11;
where = &lcd_bwidth;
}
else if (!strncmp(str, "lcd_hwidth:", 11)) {
} else if (!strncmp(str, "lcd_hwidth:", 11)) {
str += 11;
where = &lcd_hwidth;
}
else if (!strncmp(str, "lcd_enabled:", 12)) {
} else if (!strncmp(str, "lcd_enabled:", 12)) {
str += 12;
where = &lcd_enabled;
}
else if (!strncmp(str, "keypad_enabled:", 15)) {
} else if (!strncmp(str, "keypad_enabled:", 15)) {
str += 15;
where = &keypad_enabled;
}
else if (!strncmp(str, "smartcard_enabled:", 18)) {
} else if (!strncmp(str, "smartcard_enabled:", 18)) {
str += 18;
where = &smartcard_enabled;
}
else if (!strncmp(str, "profile:", 8)) {
} else if (!strncmp(str, "profile:", 8)) {
str += 8;
where = &profile;
}
else if (!helpdisplayed) {
} else if (!helpdisplayed) {
helpdisplayed = 1;
printk(KERN_ERR "Panel version " PANEL_VERSION ": invalid argument. Known arguments are :\n"
printk(KERN_ERR "Panel version " PANEL_VERSION
": invalid argument. Known arguments are :\n"
" parport:, lcd_{height,width,bwidth,enabled}:, keypad_enabled:\n");
}
......@@ -2061,7 +2163,7 @@ __initfunc(void panel_setup(char *str, int *ints))
if (where != NULL) {
dummy = 0;
while (isdigit(*str)) {
dummy = (dummy*10) + (*str - '0');
dummy = (dummy * 10) + (*str - '0');
str++;
}
*where = dummy;
......@@ -2077,21 +2179,25 @@ __initfunc(void panel_setup(char *str, int *ints))
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
__setup("panel=", panel_setup );
__setup("panel=", panel_setup);
#else
__setup("panel", panel_setup );
__setup("panel", panel_setup);
#endif
#endif /* !MODULE */
static int panel_notify_sys(struct notifier_block *this, unsigned long code, void *unused) {
static int panel_notify_sys(struct notifier_block *this, unsigned long code,
void *unused)
{
if (lcd_enabled && lcd_initialized) {
switch(code) {
switch (code) {
case SYS_DOWN:
panel_lcd_print("\x0cReloading\nSystem...\x1b[Lc\x1b[Lb\x1b[L+");
panel_lcd_print
("\x0cReloading\nSystem...\x1b[Lc\x1b[Lb\x1b[L+");
break;
case SYS_HALT:
panel_lcd_print("\x0cSystem Halted.\x1b[Lc\x1b[Lb\x1b[L+");
panel_lcd_print
("\x0cSystem Halted.\x1b[Lc\x1b[Lb\x1b[L+");
break;
case SYS_POWER_OFF:
panel_lcd_print("\x0cPower off.\x1b[Lc\x1b[Lb\x1b[L+");
......@@ -2109,74 +2215,67 @@ static struct notifier_block panel_notifier = {
0
};
static void panel_attach (struct parport *port)
static void panel_attach(struct parport *port)
{
if (port->number != parport)
return;
if (pprt) {
printk(KERN_ERR "panel_attach(): port->number=%d parport=%d, already registered !\n", port->number, parport);
printk(KERN_ERR
"panel_attach(): port->number=%d parport=%d, already registered !\n",
port->number, parport);
return;
}
pprt = parport_register_device(port, "panel",
NULL, NULL, /* pf, kf */
pprt = parport_register_device(port, "panel", NULL, NULL, /* pf, kf */
NULL,
/*PARPORT_DEV_EXCL*/
0,
(void *)&pprt);
/*PARPORT_DEV_EXCL */
0, (void *)&pprt);
if (parport_claim(pprt)) {
printk(KERN_ERR "Panel: could not claim access to parport%d. Aborting.\n", parport);
//parport_unregister_device(pprt);
//parport_unregister_driver(&panel_driver);
//return -EIO;
printk(KERN_ERR
"Panel: could not claim access to parport%d. Aborting.\n",
parport);
return;
}
/* turns IRQ off */
// port->ops->disable_irq(port);
/* must init LCD first, just in case an IRQ from the keypad is generated at keypad init */
if (lcd_enabled) {
lcd_init();
misc_register( &lcd_dev );
misc_register(&lcd_dev);
}
if (keypad_enabled) {
keypad_init();
misc_register( &keypad_dev );
misc_register(&keypad_dev);
}
if (smartcard_enabled) {
smartcard_init();
misc_register( &smartcard_dev );
misc_register(&smartcard_dev);
}
}
static void panel_detach (struct parport *port)
static void panel_detach(struct parport *port)
{
if (port->number != parport)
return;
if (!pprt) {
printk(KERN_ERR "panel_detach(): port->number=%d parport=%d, nothing to unregister.\n",
printk(KERN_ERR
"panel_detach(): port->number=%d parport=%d, nothing to unregister.\n",
port->number, parport);
return;
}
if (smartcard_enabled && smartcard_initialized) {
misc_deregister( &smartcard_dev );
}
if (smartcard_enabled && smartcard_initialized)
misc_deregister(&smartcard_dev);
if (keypad_enabled && keypad_initialized) {
misc_deregister( &keypad_dev );
}
if (keypad_enabled && keypad_initialized)
misc_deregister(&keypad_dev);
if (lcd_enabled && lcd_initialized) {
misc_deregister( &lcd_dev );
}
if (lcd_enabled && lcd_initialized)
misc_deregister(&lcd_dev);
parport_release(pprt);
parport_unregister_device(pprt);
......@@ -2190,7 +2289,8 @@ static struct parport_driver panel_driver = {
};
/* init function */
int panel_init (void) {
int panel_init(void)
{
/* for backwards compatibility */
if (keypad_type < 0)
keypad_type = keypad_enabled;
......@@ -2204,36 +2304,56 @@ int panel_init (void) {
/* take care of an eventual profile */
switch (profile) {
case PANEL_PROFILE_CUSTOM: /* custom profile */
if (keypad_type < 0) keypad_type = DEFAULT_KEYPAD;
if (smartcard_enabled < 0) smartcard_enabled = DEFAULT_SMARTCARD;
if (lcd_type < 0) lcd_type = DEFAULT_LCD;
if (keypad_type < 0)
keypad_type = DEFAULT_KEYPAD;
if (smartcard_enabled < 0)
smartcard_enabled = DEFAULT_SMARTCARD;
if (lcd_type < 0)
lcd_type = DEFAULT_LCD;
break;
case PANEL_PROFILE_OLD: /* 8 bits, 2*16, old keypad */
if (keypad_type < 0) keypad_type = KEYPAD_TYPE_OLD;
if (smartcard_enabled < 0) smartcard_enabled = 0;
if (lcd_type < 0) lcd_type = LCD_TYPE_OLD;
if (lcd_width < 0) lcd_width = 16;
if (lcd_hwidth < 0) lcd_hwidth = 16;
if (keypad_type < 0)
keypad_type = KEYPAD_TYPE_OLD;
if (smartcard_enabled < 0)
smartcard_enabled = 0;
if (lcd_type < 0)
lcd_type = LCD_TYPE_OLD;
if (lcd_width < 0)
lcd_width = 16;
if (lcd_hwidth < 0)
lcd_hwidth = 16;
break;
case PANEL_PROFILE_NEW: /* serial, 2*16, new keypad */
if (keypad_type < 0) keypad_type = KEYPAD_TYPE_NEW;
if (smartcard_enabled < 0) smartcard_enabled = 1;
if (lcd_type < 0) lcd_type = LCD_TYPE_KS0074;
if (keypad_type < 0)
keypad_type = KEYPAD_TYPE_NEW;
if (smartcard_enabled < 0)
smartcard_enabled = 1;
if (lcd_type < 0)
lcd_type = LCD_TYPE_KS0074;
break;
case PANEL_PROFILE_HANTRONIX: /* 8 bits, 2*16 hantronix-like, no keypad */
if (keypad_type < 0) keypad_type = KEYPAD_TYPE_NONE;
if (smartcard_enabled < 0) smartcard_enabled = 0;
if (lcd_type < 0) lcd_type = LCD_TYPE_HANTRONIX;
if (keypad_type < 0)
keypad_type = KEYPAD_TYPE_NONE;
if (smartcard_enabled < 0)
smartcard_enabled = 0;
if (lcd_type < 0)
lcd_type = LCD_TYPE_HANTRONIX;
break;
case PANEL_PROFILE_NEXCOM: /* generic 8 bits, 2*16, nexcom keypad, eg. Nexcom. */
if (keypad_type < 0) keypad_type = KEYPAD_TYPE_NEXCOM;
if (smartcard_enabled < 0) smartcard_enabled = 0;
if (lcd_type < 0) lcd_type = LCD_TYPE_NEXCOM;
if (keypad_type < 0)
keypad_type = KEYPAD_TYPE_NEXCOM;
if (smartcard_enabled < 0)
smartcard_enabled = 0;
if (lcd_type < 0)
lcd_type = LCD_TYPE_NEXCOM;
break;
case PANEL_PROFILE_LARGE: /* 8 bits, 2*40, old keypad */
if (keypad_type < 0) keypad_type = KEYPAD_TYPE_OLD;
if (smartcard_enabled < 0) smartcard_enabled = 0;
if (lcd_type < 0) lcd_type = LCD_TYPE_OLD;
if (keypad_type < 0)
keypad_type = KEYPAD_TYPE_OLD;
if (smartcard_enabled < 0)
smartcard_enabled = 0;
if (lcd_type < 0)
lcd_type = LCD_TYPE_OLD;
break;
}
......@@ -2259,64 +2379,59 @@ int panel_init (void) {
init_in_progress = 1;
if (parport_register_driver(&panel_driver)) {
printk(KERN_ERR "Panel: could not register with parport. Aborting.\n");
printk(KERN_ERR
"Panel: could not register with parport. Aborting.\n");
return -EIO;
}
// The parport can be asynchronously registered later.
//if (pprt == NULL) {
// printk(KERN_ERR "Panel: could not register parport%d. Aborting.\n", parport);
// parport_unregister_driver(&panel_driver);
// return -ENODEV; /* port not found */
//}
if (!lcd_enabled && !keypad_enabled && !smartcard_enabled) { /* no device enabled, let's release the parport */
if (pprt) {
parport_release(pprt);
parport_unregister_device(pprt);
}
parport_unregister_driver(&panel_driver);
printk(KERN_ERR "Panel driver version " PANEL_VERSION " disabled.\n");
printk(KERN_ERR "Panel driver version " PANEL_VERSION
" disabled.\n");
return -ENODEV;
}
register_reboot_notifier(&panel_notifier);
if (pprt)
printk(KERN_INFO "Panel driver version " PANEL_VERSION " registered on parport%d (io=0x%lx).\n",
parport, pprt->port->base);
printk(KERN_INFO "Panel driver version " PANEL_VERSION
" registered on parport%d (io=0x%lx).\n", parport,
pprt->port->base);
else
printk(KERN_INFO "Panel driver version " PANEL_VERSION " not yet registered\n");
printk(KERN_INFO "Panel driver version " PANEL_VERSION
" not yet registered\n");
/* tells various subsystems about the fact that initialization is finished */
init_in_progress = 0;
return 0;
}
#if defined(MODULE) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
INIT_FUNC (void) {
INIT_FUNC(void)
{
return panel_init();
}
CLEANUP_FUNC (void) {
CLEANUP_FUNC(void)
{
unregister_reboot_notifier(&panel_notifier);
if (scan_timer.function != NULL) {
if (scan_timer.function != NULL)
del_timer(&scan_timer);
}
if (keypad_enabled) {
misc_deregister( &keypad_dev );
}
if (keypad_enabled)
misc_deregister(&keypad_dev);
if (smartcard_enabled) {
misc_deregister( &smartcard_dev );
}
if (smartcard_enabled)
misc_deregister(&smartcard_dev);
if (lcd_enabled) {
panel_lcd_print("\x0cLCD driver " PANEL_VERSION "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
misc_deregister( &lcd_dev );
panel_lcd_print("\x0cLCD driver " PANEL_VERSION
"\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
misc_deregister(&lcd_dev);
}
/* TODO: free all input signals */
......@@ -2340,4 +2455,3 @@ MODULE_LICENSE("GPL");
* tab-width: 8
* End:
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment