2005-04-17 06:20:36 +08:00
|
|
|
#ifndef _PSMOUSE_H
|
|
|
|
#define _PSMOUSE_H
|
|
|
|
|
|
|
|
#define PSMOUSE_CMD_SETSCALE11 0x00e6
|
|
|
|
#define PSMOUSE_CMD_SETSCALE21 0x00e7
|
|
|
|
#define PSMOUSE_CMD_SETRES 0x10e8
|
|
|
|
#define PSMOUSE_CMD_GETINFO 0x03e9
|
|
|
|
#define PSMOUSE_CMD_SETSTREAM 0x00ea
|
|
|
|
#define PSMOUSE_CMD_SETPOLL 0x00f0
|
2006-01-14 13:27:37 +08:00
|
|
|
#define PSMOUSE_CMD_POLL 0x00eb /* caller sets number of bytes to receive */
|
2005-04-17 06:20:36 +08:00
|
|
|
#define PSMOUSE_CMD_GETID 0x02f2
|
|
|
|
#define PSMOUSE_CMD_SETRATE 0x10f3
|
|
|
|
#define PSMOUSE_CMD_ENABLE 0x00f4
|
|
|
|
#define PSMOUSE_CMD_DISABLE 0x00f5
|
|
|
|
#define PSMOUSE_CMD_RESET_DIS 0x00f6
|
|
|
|
#define PSMOUSE_CMD_RESET_BAT 0x02ff
|
|
|
|
|
|
|
|
#define PSMOUSE_RET_BAT 0xaa
|
|
|
|
#define PSMOUSE_RET_ID 0x00
|
|
|
|
#define PSMOUSE_RET_ACK 0xfa
|
|
|
|
#define PSMOUSE_RET_NAK 0xfe
|
|
|
|
|
|
|
|
enum psmouse_state {
|
|
|
|
PSMOUSE_IGNORE,
|
|
|
|
PSMOUSE_INITIALIZING,
|
2006-01-14 13:27:37 +08:00
|
|
|
PSMOUSE_RESYNCING,
|
2005-04-17 06:20:36 +08:00
|
|
|
PSMOUSE_CMD_MODE,
|
|
|
|
PSMOUSE_ACTIVATED,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* psmouse protocol handler return codes */
|
|
|
|
typedef enum {
|
|
|
|
PSMOUSE_BAD_DATA,
|
|
|
|
PSMOUSE_GOOD_DATA,
|
|
|
|
PSMOUSE_FULL_PACKET
|
|
|
|
} psmouse_ret_t;
|
|
|
|
|
|
|
|
struct psmouse {
|
|
|
|
void *private;
|
2005-09-15 15:01:44 +08:00
|
|
|
struct input_dev *dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct ps2dev ps2dev;
|
2008-09-17 00:30:33 +08:00
|
|
|
struct delayed_work resync_work;
|
2005-04-17 06:20:36 +08:00
|
|
|
char *vendor;
|
|
|
|
char *name;
|
|
|
|
unsigned char packet[8];
|
2006-01-14 13:27:37 +08:00
|
|
|
unsigned char badbyte;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned char pktcnt;
|
|
|
|
unsigned char pktsize;
|
|
|
|
unsigned char type;
|
2010-04-19 15:42:16 +08:00
|
|
|
bool ignore_parity;
|
2009-09-10 10:13:20 +08:00
|
|
|
bool acks_disable_command;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int model;
|
|
|
|
unsigned long last;
|
2009-09-10 10:13:20 +08:00
|
|
|
unsigned long out_of_sync_cnt;
|
2006-01-14 13:27:37 +08:00
|
|
|
unsigned long num_resyncs;
|
2005-04-17 06:20:36 +08:00
|
|
|
enum psmouse_state state;
|
|
|
|
char devname[64];
|
|
|
|
char phys[32];
|
|
|
|
|
|
|
|
unsigned int rate;
|
|
|
|
unsigned int resolution;
|
|
|
|
unsigned int resetafter;
|
2006-01-14 13:27:37 +08:00
|
|
|
unsigned int resync_time;
|
2009-09-10 10:13:20 +08:00
|
|
|
bool smartscroll; /* Logitech only */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse);
|
2005-04-17 06:20:36 +08:00
|
|
|
void (*set_rate)(struct psmouse *psmouse, unsigned int rate);
|
|
|
|
void (*set_resolution)(struct psmouse *psmouse, unsigned int resolution);
|
|
|
|
|
|
|
|
int (*reconnect)(struct psmouse *psmouse);
|
|
|
|
void (*disconnect)(struct psmouse *psmouse);
|
2007-02-18 14:40:24 +08:00
|
|
|
void (*cleanup)(struct psmouse *psmouse);
|
2006-01-14 13:27:37 +08:00
|
|
|
int (*poll)(struct psmouse *psmouse);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
void (*pt_activate)(struct psmouse *psmouse);
|
|
|
|
void (*pt_deactivate)(struct psmouse *psmouse);
|
|
|
|
};
|
|
|
|
|
|
|
|
enum psmouse_type {
|
|
|
|
PSMOUSE_NONE,
|
|
|
|
PSMOUSE_PS2,
|
|
|
|
PSMOUSE_PS2PP,
|
|
|
|
PSMOUSE_THINKPS,
|
|
|
|
PSMOUSE_GENPS,
|
|
|
|
PSMOUSE_IMPS,
|
|
|
|
PSMOUSE_IMEX,
|
|
|
|
PSMOUSE_SYNAPTICS,
|
|
|
|
PSMOUSE_ALPS,
|
2005-05-29 15:30:22 +08:00
|
|
|
PSMOUSE_LIFEBOOK,
|
2005-08-08 14:26:18 +08:00
|
|
|
PSMOUSE_TRACKPOINT,
|
2007-02-18 14:49:10 +08:00
|
|
|
PSMOUSE_TOUCHKIT_PS2,
|
2007-05-10 13:47:18 +08:00
|
|
|
PSMOUSE_CORTRON,
|
2008-09-17 00:30:34 +08:00
|
|
|
PSMOUSE_HGPK,
|
2008-10-17 10:10:19 +08:00
|
|
|
PSMOUSE_ELANTECH,
|
2009-05-11 09:15:39 +08:00
|
|
|
PSMOUSE_FSP,
|
2005-06-01 15:40:01 +08:00
|
|
|
PSMOUSE_AUTO /* This one should always be last */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2008-09-17 00:30:33 +08:00
|
|
|
void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
|
|
|
|
unsigned long delay);
|
2005-04-17 06:20:36 +08:00
|
|
|
int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
|
|
|
|
int psmouse_reset(struct psmouse *psmouse);
|
2008-09-17 00:30:33 +08:00
|
|
|
void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state);
|
2005-04-17 06:20:36 +08:00
|
|
|
void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
|
|
|
|
|
2005-09-04 14:40:20 +08:00
|
|
|
struct psmouse_attribute {
|
|
|
|
struct device_attribute dattr;
|
|
|
|
void *data;
|
|
|
|
ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf);
|
|
|
|
ssize_t (*set)(struct psmouse *psmouse, void *data,
|
|
|
|
const char *buf, size_t count);
|
2009-09-10 10:13:20 +08:00
|
|
|
bool protect;
|
2005-09-04 14:40:20 +08:00
|
|
|
};
|
|
|
|
#define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
|
|
|
|
|
|
|
|
ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf);
|
|
|
|
ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count);
|
|
|
|
|
2009-08-19 02:45:02 +08:00
|
|
|
#define __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect) \
|
2005-09-04 14:40:20 +08:00
|
|
|
static struct psmouse_attribute psmouse_attr_##_name = { \
|
|
|
|
.dattr = { \
|
|
|
|
.attr = { \
|
|
|
|
.name = __stringify(_name), \
|
|
|
|
.mode = _mode, \
|
|
|
|
}, \
|
|
|
|
.show = psmouse_attr_show_helper, \
|
|
|
|
.store = psmouse_attr_set_helper, \
|
|
|
|
}, \
|
|
|
|
.data = _data, \
|
|
|
|
.show = _show, \
|
|
|
|
.set = _set, \
|
2008-09-17 00:30:34 +08:00
|
|
|
.protect = _protect, \
|
2005-09-04 14:40:20 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-08-19 02:45:02 +08:00
|
|
|
#define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect) \
|
|
|
|
static ssize_t _show(struct psmouse *, void *, char *); \
|
|
|
|
static ssize_t _set(struct psmouse *, void *, const char *, size_t); \
|
|
|
|
__PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect)
|
|
|
|
|
|
|
|
#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \
|
2009-09-10 10:13:20 +08:00
|
|
|
__PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, true)
|
2009-08-19 02:45:02 +08:00
|
|
|
|
|
|
|
#define PSMOUSE_DEFINE_RO_ATTR(_name, _mode, _data, _show) \
|
|
|
|
static ssize_t _show(struct psmouse *, void *, char *); \
|
2009-09-10 10:13:20 +08:00
|
|
|
__PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, NULL, true)
|
2009-08-19 02:45:02 +08:00
|
|
|
|
|
|
|
#define PSMOUSE_DEFINE_WO_ATTR(_name, _mode, _data, _set) \
|
|
|
|
static ssize_t _set(struct psmouse *, void *, const char *, size_t); \
|
2009-09-10 10:13:20 +08:00
|
|
|
__PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, NULL, _set, true)
|
2008-09-17 00:30:34 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _PSMOUSE_H */
|