2 * Microsoft busmouse driver based on Logitech driver (see busmouse.c)
4 * Microsoft BusMouse support by Teemu Rantanen (tvr@cs.hut.fi) (02AUG92)
6 * Microsoft Bus Mouse support modified by Derrick Cole (cole@concert.net)
9 * Microsoft Bus Mouse support folded into 0.97pl4 code
10 * by Peter Cervasio (pete%q106fm.uucp@wupost.wustl.edu) (08SEP92)
11 * Changes: Logitech and Microsoft support in the same kernel.
12 * Defined new constants in busmouse.h for MS mice.
13 * Added int mse_busmouse_type to distinguish busmouse types
14 * Added a couple of new functions to handle differences in using
15 * MS vs. Logitech (where the int variable wasn't appropriate).
17 * Modified by Peter Cervasio (address above) (26SEP92)
18 * Changes: Included code to (properly?) detect when a Microsoft mouse is
19 * really attached to the machine. Don't know what this does to
20 * Logitech bus mice, but all it does is read ports.
22 * Modified by Christoph Niemann (niemann@rubdv15.etdv.ruhr-uni-bochum.de)
23 * Changes: Better interrupt-handler (like in busmouse.c).
24 * Some changes to reduce code-size.
25 * Changed detection code to use inb_p() instead of doing empty
28 * Modularised 8-Sep-95 Philip Blundell <pjb27@cam.ac.uk>
30 * Converted to use new generic busmouse code. 5 Apr 1998
31 * Russell King <rmk@arm.uk.linux.org>
36 #include <linux/module.h>
38 #include <linux/kernel.h>
39 #include <linux/ioport.h>
40 #include <linux/sched.h>
41 #include <linux/logibusmouse.h>
42 #include <linux/signal.h>
43 #include <linux/errno.h>
44 #include <linux/miscdevice.h>
45 #include <linux/random.h>
46 #include <linux/poll.h>
47 #include <linux/init.h>
50 #include <asm/uaccess.h>
51 #include <asm/system.h>
57 static int mouse_irq
= MOUSE_IRQ
;
60 MODULE_PARM(mouse_irq
, "i");
63 void __init
msmouse_setup(char *str
, int *ints
)
69 static void ms_mouse_interrupt(int irq
, void *dev_id
, struct pt_regs
* regs
)
72 unsigned char buttons
;
74 outb(MS_MSE_COMMAND_MODE
, MS_MSE_CONTROL_PORT
);
75 outb((inb(MS_MSE_DATA_PORT
) | 0x20), MS_MSE_DATA_PORT
);
77 outb(MS_MSE_READ_X
, MS_MSE_CONTROL_PORT
);
78 dx
= inb(MS_MSE_DATA_PORT
);
80 outb(MS_MSE_READ_Y
, MS_MSE_CONTROL_PORT
);
81 dy
= inb(MS_MSE_DATA_PORT
);
83 outb(MS_MSE_READ_BUTTONS
, MS_MSE_CONTROL_PORT
);
84 buttons
= ~(inb(MS_MSE_DATA_PORT
)) & 0x07;
86 outb(MS_MSE_COMMAND_MODE
, MS_MSE_CONTROL_PORT
);
87 outb((inb(MS_MSE_DATA_PORT
) & 0xdf), MS_MSE_DATA_PORT
);
89 /* why did the original have:
90 * if (dx != 0 || dy != 0 || buttons != mouse.buttons ||
91 * ((~buttons) & 0x07))
92 * ^^^^^^^^^^^^^^^^^^^ this?
94 busmouse_add_movementbuttons(msedev
, dx
, -dy
, buttons
);
97 static int release_mouse(struct inode
* inode
, struct file
* file
)
100 free_irq(mouse_irq
, NULL
);
105 static int open_mouse(struct inode
* inode
, struct file
* file
)
107 if (request_irq(mouse_irq
, ms_mouse_interrupt
, 0, "MS Busmouse", NULL
))
110 outb(MS_MSE_START
, MS_MSE_CONTROL_PORT
);
116 static struct busmouse msbusmouse
= {
117 MICROSOFT_BUSMOUSE
, "msbusmouse", open_mouse
, release_mouse
, 0
120 int __init
ms_bus_mouse_init(void)
125 if (check_region(MS_MSE_CONTROL_PORT
, 0x04))
128 if (inb_p(MS_MSE_SIGNATURE_PORT
) == 0xde) {
130 mse_byte
= inb_p(MS_MSE_SIGNATURE_PORT
);
132 for (i
= 0; i
< 4; i
++) {
133 if (inb_p(MS_MSE_SIGNATURE_PORT
) == 0xde) {
134 if (inb_p(MS_MSE_SIGNATURE_PORT
) == mse_byte
)
145 request_region(MS_MSE_CONTROL_PORT
, 0x04, "MS Busmouse");
146 msedev
= register_busmouse(&msbusmouse
);
148 printk(KERN_WARNING
"Unable to register msbusmouse driver.\n");
150 printk(KERN_INFO
"Microsoft BusMouse detected and installed.\n");
151 return msedev
< 0 ? msedev
: 0;
154 void ms_bus_mouse_exit(void)
156 unregister_busmouse(msedev
);
157 release_region(MS_MSE_CONTROL_PORT
, 0x04);
160 module_init(ms_bus_mouse_init
)
161 module_exit(ms_bus_mouse_exit
)