2 * Input driver to ExplorerPS/2 device driver module.
4 * Copyright (c) 1999-2002 Vojtech Pavlik
5 * Copyright (c) 2004 Dmitry Torokhov
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
12 #define MOUSEDEV_MINOR_BASE 32
13 #define MOUSEDEV_MINORS 32
14 #define MOUSEDEV_MIX 31
16 #include <linux/slab.h>
17 #include <linux/poll.h>
18 #include <linux/module.h>
19 #include <linux/moduleparam.h>
20 #include <linux/init.h>
21 #include <linux/input.h>
22 #include <linux/smp_lock.h>
23 #include <linux/random.h>
24 #include <linux/major.h>
25 #include <linux/device.h>
26 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
27 #include <linux/miscdevice.h>
30 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
31 MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
32 MODULE_LICENSE("GPL");
34 #ifndef CONFIG_INPUT_MOUSEDEV_SCREEN_X
35 #define CONFIG_INPUT_MOUSEDEV_SCREEN_X 1024
37 #ifndef CONFIG_INPUT_MOUSEDEV_SCREEN_Y
38 #define CONFIG_INPUT_MOUSEDEV_SCREEN_Y 768
41 static int xres
= CONFIG_INPUT_MOUSEDEV_SCREEN_X
;
42 module_param(xres
, uint
, 0644);
43 MODULE_PARM_DESC(xres
, "Horizontal screen resolution");
45 static int yres
= CONFIG_INPUT_MOUSEDEV_SCREEN_Y
;
46 module_param(yres
, uint
, 0644);
47 MODULE_PARM_DESC(yres
, "Vertical screen resolution");
49 static unsigned tap_time
= 200;
50 module_param(tap_time
, uint
, 0644);
51 MODULE_PARM_DESC(tap_time
, "Tap time for touchpads in absolute mode (msecs)");
53 struct mousedev_hw_data
{
57 unsigned long buttons
;
65 wait_queue_head_t wait
;
66 struct list_head client_list
;
67 struct input_handle handle
;
69 struct mousedev_hw_data packet
;
70 unsigned int pkt_count
;
71 int old_x
[4], old_y
[4];
82 struct mousedev_motion
{
84 unsigned long buttons
;
87 #define PACKET_QUEUE_LEN 16
88 struct mousedev_client
{
89 struct fasync_struct
*fasync
;
90 struct mousedev
*mousedev
;
91 struct list_head node
;
93 struct mousedev_motion packets
[PACKET_QUEUE_LEN
];
94 unsigned int head
, tail
;
95 spinlock_t packet_lock
;
99 unsigned char ready
, buffer
, bufsiz
;
100 unsigned char imexseq
, impsseq
;
101 enum mousedev_emul mode
;
102 unsigned long last_buttons
;
105 #define MOUSEDEV_SEQ_LEN 6
107 static unsigned char mousedev_imps_seq
[] = { 0xf3, 200, 0xf3, 100, 0xf3, 80 };
108 static unsigned char mousedev_imex_seq
[] = { 0xf3, 200, 0xf3, 200, 0xf3, 80 };
110 static struct input_handler mousedev_handler
;
112 static struct mousedev
*mousedev_table
[MOUSEDEV_MINORS
];
113 static struct mousedev mousedev_mix
;
115 #define fx(i) (mousedev->old_x[(mousedev->pkt_count - (i)) & 03])
116 #define fy(i) (mousedev->old_y[(mousedev->pkt_count - (i)) & 03])
118 static void mousedev_touchpad_event(struct input_dev
*dev
, struct mousedev
*mousedev
, unsigned int code
, int value
)
121 enum { FRACTION_DENOM
= 128 };
123 if (mousedev
->touch
) {
124 size
= dev
->absmax
[ABS_X
] - dev
->absmin
[ABS_X
];
131 if (mousedev
->pkt_count
>= 2) {
132 tmp
= ((value
- fx(2)) * (256 * FRACTION_DENOM
)) / size
;
133 tmp
+= mousedev
->frac_dx
;
134 mousedev
->packet
.dx
= tmp
/ FRACTION_DENOM
;
135 mousedev
->frac_dx
= tmp
- mousedev
->packet
.dx
* FRACTION_DENOM
;
141 if (mousedev
->pkt_count
>= 2) {
142 tmp
= -((value
- fy(2)) * (256 * FRACTION_DENOM
)) / size
;
143 tmp
+= mousedev
->frac_dy
;
144 mousedev
->packet
.dy
= tmp
/ FRACTION_DENOM
;
145 mousedev
->frac_dy
= tmp
- mousedev
->packet
.dy
* FRACTION_DENOM
;
152 static void mousedev_abs_event(struct input_dev
*dev
, struct mousedev
*mousedev
, unsigned int code
, int value
)
158 size
= dev
->absmax
[ABS_X
] - dev
->absmin
[ABS_X
];
161 if (value
> dev
->absmax
[ABS_X
])
162 value
= dev
->absmax
[ABS_X
];
163 if (value
< dev
->absmin
[ABS_X
])
164 value
= dev
->absmin
[ABS_X
];
165 mousedev
->packet
.x
= ((value
- dev
->absmin
[ABS_X
]) * xres
) / size
;
166 mousedev
->packet
.abs_event
= 1;
170 size
= dev
->absmax
[ABS_Y
] - dev
->absmin
[ABS_Y
];
173 if (value
> dev
->absmax
[ABS_Y
])
174 value
= dev
->absmax
[ABS_Y
];
175 if (value
< dev
->absmin
[ABS_Y
])
176 value
= dev
->absmin
[ABS_Y
];
177 mousedev
->packet
.y
= yres
- ((value
- dev
->absmin
[ABS_Y
]) * yres
) / size
;
178 mousedev
->packet
.abs_event
= 1;
183 static void mousedev_rel_event(struct mousedev
*mousedev
, unsigned int code
, int value
)
186 case REL_X
: mousedev
->packet
.dx
+= value
; break;
187 case REL_Y
: mousedev
->packet
.dy
-= value
; break;
188 case REL_WHEEL
: mousedev
->packet
.dz
-= value
; break;
192 static void mousedev_key_event(struct mousedev
*mousedev
, unsigned int code
, int value
)
199 case BTN_LEFT
: index
= 0; break;
202 case BTN_RIGHT
: index
= 1; break;
206 case BTN_MIDDLE
: index
= 2; break;
209 case BTN_SIDE
: index
= 3; break;
211 case BTN_EXTRA
: index
= 4; break;
216 set_bit(index
, &mousedev
->packet
.buttons
);
217 set_bit(index
, &mousedev_mix
.packet
.buttons
);
219 clear_bit(index
, &mousedev
->packet
.buttons
);
220 clear_bit(index
, &mousedev_mix
.packet
.buttons
);
224 static void mousedev_notify_readers(struct mousedev
*mousedev
, struct mousedev_hw_data
*packet
)
226 struct mousedev_client
*client
;
227 struct mousedev_motion
*p
;
229 int wake_readers
= 0;
231 list_for_each_entry(client
, &mousedev
->client_list
, node
) {
232 spin_lock_irqsave(&client
->packet_lock
, flags
);
234 p
= &client
->packets
[client
->head
];
235 if (client
->ready
&& p
->buttons
!= mousedev
->packet
.buttons
) {
236 unsigned int new_head
= (client
->head
+ 1) % PACKET_QUEUE_LEN
;
237 if (new_head
!= client
->tail
) {
238 p
= &client
->packets
[client
->head
= new_head
];
239 memset(p
, 0, sizeof(struct mousedev_motion
));
243 if (packet
->abs_event
) {
244 p
->dx
+= packet
->x
- client
->pos_x
;
245 p
->dy
+= packet
->y
- client
->pos_y
;
246 client
->pos_x
= packet
->x
;
247 client
->pos_y
= packet
->y
;
250 client
->pos_x
+= packet
->dx
;
251 client
->pos_x
= client
->pos_x
< 0 ? 0 : (client
->pos_x
>= xres
? xres
: client
->pos_x
);
252 client
->pos_y
+= packet
->dy
;
253 client
->pos_y
= client
->pos_y
< 0 ? 0 : (client
->pos_y
>= yres
? yres
: client
->pos_y
);
258 p
->buttons
= mousedev
->packet
.buttons
;
260 if (p
->dx
|| p
->dy
|| p
->dz
|| p
->buttons
!= client
->last_buttons
)
263 spin_unlock_irqrestore(&client
->packet_lock
, flags
);
266 kill_fasync(&client
->fasync
, SIGIO
, POLL_IN
);
272 wake_up_interruptible(&mousedev
->wait
);
275 static void mousedev_touchpad_touch(struct mousedev
*mousedev
, int value
)
278 if (mousedev
->touch
&&
279 time_before(jiffies
, mousedev
->touch
+ msecs_to_jiffies(tap_time
))) {
281 * Toggle left button to emulate tap.
282 * We rely on the fact that mousedev_mix always has 0
283 * motion packet so we won't mess current position.
285 set_bit(0, &mousedev
->packet
.buttons
);
286 set_bit(0, &mousedev_mix
.packet
.buttons
);
287 mousedev_notify_readers(mousedev
, &mousedev_mix
.packet
);
288 mousedev_notify_readers(&mousedev_mix
, &mousedev_mix
.packet
);
289 clear_bit(0, &mousedev
->packet
.buttons
);
290 clear_bit(0, &mousedev_mix
.packet
.buttons
);
292 mousedev
->touch
= mousedev
->pkt_count
= 0;
293 mousedev
->frac_dx
= 0;
294 mousedev
->frac_dy
= 0;
296 } else if (!mousedev
->touch
)
297 mousedev
->touch
= jiffies
;
300 static void mousedev_event(struct input_handle
*handle
, unsigned int type
, unsigned int code
, int value
)
302 struct mousedev
*mousedev
= handle
->private;
306 /* Ignore joysticks */
307 if (test_bit(BTN_TRIGGER
, handle
->dev
->keybit
))
310 if (test_bit(BTN_TOOL_FINGER
, handle
->dev
->keybit
))
311 mousedev_touchpad_event(handle
->dev
, mousedev
, code
, value
);
313 mousedev_abs_event(handle
->dev
, mousedev
, code
, value
);
318 mousedev_rel_event(mousedev
, code
, value
);
323 if (code
== BTN_TOUCH
&& test_bit(BTN_TOOL_FINGER
, handle
->dev
->keybit
))
324 mousedev_touchpad_touch(mousedev
, value
);
326 mousedev_key_event(mousedev
, code
, value
);
331 if (code
== SYN_REPORT
) {
332 if (mousedev
->touch
) {
333 mousedev
->pkt_count
++;
334 /* Input system eats duplicate events, but we need all of them
335 * to do correct averaging so apply present one forward
341 mousedev_notify_readers(mousedev
, &mousedev
->packet
);
342 mousedev_notify_readers(&mousedev_mix
, &mousedev
->packet
);
344 mousedev
->packet
.dx
= mousedev
->packet
.dy
= mousedev
->packet
.dz
= 0;
345 mousedev
->packet
.abs_event
= 0;
351 static int mousedev_fasync(int fd
, struct file
*file
, int on
)
354 struct mousedev_client
*client
= file
->private_data
;
356 retval
= fasync_helper(fd
, file
, on
, &client
->fasync
);
358 return retval
< 0 ? retval
: 0;
361 static void mousedev_free(struct mousedev
*mousedev
)
363 mousedev_table
[mousedev
->minor
] = NULL
;
367 static void mixdev_release(void)
369 struct input_handle
*handle
;
371 list_for_each_entry(handle
, &mousedev_handler
.h_list
, h_node
) {
372 struct mousedev
*mousedev
= handle
->private;
374 if (!mousedev
->open
) {
376 input_close_device(&mousedev
->handle
);
378 mousedev_free(mousedev
);
383 static int mousedev_release(struct inode
*inode
, struct file
*file
)
385 struct mousedev_client
*client
= file
->private_data
;
386 struct mousedev
*mousedev
= client
->mousedev
;
388 mousedev_fasync(-1, file
, 0);
390 list_del(&client
->node
);
393 if (!--mousedev
->open
) {
394 if (mousedev
->minor
== MOUSEDEV_MIX
)
396 else if (!mousedev_mix
.open
) {
398 input_close_device(&mousedev
->handle
);
400 mousedev_free(mousedev
);
407 static int mousedev_open(struct inode
*inode
, struct file
*file
)
409 struct mousedev_client
*client
;
410 struct input_handle
*handle
;
411 struct mousedev
*mousedev
;
414 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
415 if (imajor(inode
) == MISC_MAJOR
)
419 i
= iminor(inode
) - MOUSEDEV_MINOR_BASE
;
421 if (i
>= MOUSEDEV_MINORS
)
424 mousedev
= mousedev_table
[i
];
428 client
= kzalloc(sizeof(struct mousedev_client
), GFP_KERNEL
);
432 spin_lock_init(&client
->packet_lock
);
433 client
->pos_x
= xres
/ 2;
434 client
->pos_y
= yres
/ 2;
435 client
->mousedev
= mousedev
;
436 list_add_tail(&client
->node
, &mousedev
->client_list
);
438 if (!mousedev
->open
++) {
439 if (mousedev
->minor
== MOUSEDEV_MIX
) {
440 list_for_each_entry(handle
, &mousedev_handler
.h_list
, h_node
) {
441 struct mousedev
*md
= handle
->private;
442 if (!md
->open
&& md
->exist
)
443 input_open_device(handle
);
446 if (!mousedev_mix
.open
&& mousedev
->exist
)
447 input_open_device(&mousedev
->handle
);
450 file
->private_data
= client
;
454 static inline int mousedev_limit_delta(int delta
, int limit
)
456 return delta
> limit
? limit
: (delta
< -limit
? -limit
: delta
);
459 static void mousedev_packet(struct mousedev_client
*client
, signed char *ps2_data
)
461 struct mousedev_motion
*p
;
464 spin_lock_irqsave(&client
->packet_lock
, flags
);
465 p
= &client
->packets
[client
->tail
];
467 ps2_data
[0] = 0x08 | ((p
->dx
< 0) << 4) | ((p
->dy
< 0) << 5) | (p
->buttons
& 0x07);
468 ps2_data
[1] = mousedev_limit_delta(p
->dx
, 127);
469 ps2_data
[2] = mousedev_limit_delta(p
->dy
, 127);
470 p
->dx
-= ps2_data
[1];
471 p
->dy
-= ps2_data
[2];
473 switch (client
->mode
) {
474 case MOUSEDEV_EMUL_EXPS
:
475 ps2_data
[3] = mousedev_limit_delta(p
->dz
, 7);
476 p
->dz
-= ps2_data
[3];
477 ps2_data
[3] = (ps2_data
[3] & 0x0f) | ((p
->buttons
& 0x18) << 1);
481 case MOUSEDEV_EMUL_IMPS
:
482 ps2_data
[0] |= ((p
->buttons
& 0x10) >> 3) | ((p
->buttons
& 0x08) >> 1);
483 ps2_data
[3] = mousedev_limit_delta(p
->dz
, 127);
484 p
->dz
-= ps2_data
[3];
488 case MOUSEDEV_EMUL_PS2
:
490 ps2_data
[0] |= ((p
->buttons
& 0x10) >> 3) | ((p
->buttons
& 0x08) >> 1);
496 if (!p
->dx
&& !p
->dy
&& !p
->dz
) {
497 if (client
->tail
== client
->head
) {
499 client
->last_buttons
= p
->buttons
;
501 client
->tail
= (client
->tail
+ 1) % PACKET_QUEUE_LEN
;
504 spin_unlock_irqrestore(&client
->packet_lock
, flags
);
508 static ssize_t
mousedev_write(struct file
*file
, const char __user
*buffer
, size_t count
, loff_t
*ppos
)
510 struct mousedev_client
*client
= file
->private_data
;
514 for (i
= 0; i
< count
; i
++) {
516 if (get_user(c
, buffer
+ i
))
519 if (c
== mousedev_imex_seq
[client
->imexseq
]) {
520 if (++client
->imexseq
== MOUSEDEV_SEQ_LEN
) {
522 client
->mode
= MOUSEDEV_EMUL_EXPS
;
527 if (c
== mousedev_imps_seq
[client
->impsseq
]) {
528 if (++client
->impsseq
== MOUSEDEV_SEQ_LEN
) {
530 client
->mode
= MOUSEDEV_EMUL_IMPS
;
535 client
->ps2
[0] = 0xfa;
539 case 0xeb: /* Poll */
540 mousedev_packet(client
, &client
->ps2
[1]);
541 client
->bufsiz
++; /* account for leading ACK */
544 case 0xf2: /* Get ID */
545 switch (client
->mode
) {
546 case MOUSEDEV_EMUL_PS2
: client
->ps2
[1] = 0; break;
547 case MOUSEDEV_EMUL_IMPS
: client
->ps2
[1] = 3; break;
548 case MOUSEDEV_EMUL_EXPS
: client
->ps2
[1] = 4; break;
553 case 0xe9: /* Get info */
554 client
->ps2
[1] = 0x60; client
->ps2
[2] = 3; client
->ps2
[3] = 200;
558 case 0xff: /* Reset */
559 client
->impsseq
= client
->imexseq
= 0;
560 client
->mode
= MOUSEDEV_EMUL_PS2
;
561 client
->ps2
[1] = 0xaa; client
->ps2
[2] = 0x00;
570 client
->buffer
= client
->bufsiz
;
573 kill_fasync(&client
->fasync
, SIGIO
, POLL_IN
);
575 wake_up_interruptible(&client
->mousedev
->wait
);
580 static ssize_t
mousedev_read(struct file
*file
, char __user
*buffer
, size_t count
, loff_t
*ppos
)
582 struct mousedev_client
*client
= file
->private_data
;
585 if (!client
->ready
&& !client
->buffer
&& (file
->f_flags
& O_NONBLOCK
))
588 retval
= wait_event_interruptible(client
->mousedev
->wait
,
589 !client
->mousedev
->exist
|| client
->ready
|| client
->buffer
);
594 if (!client
->mousedev
->exist
)
597 if (!client
->buffer
&& client
->ready
) {
598 mousedev_packet(client
, client
->ps2
);
599 client
->buffer
= client
->bufsiz
;
602 if (count
> client
->buffer
)
603 count
= client
->buffer
;
605 client
->buffer
-= count
;
607 if (copy_to_user(buffer
, client
->ps2
+ client
->bufsiz
- client
->buffer
- count
, count
))
613 /* No kernel lock - fine */
614 static unsigned int mousedev_poll(struct file
*file
, poll_table
*wait
)
616 struct mousedev_client
*client
= file
->private_data
;
617 struct mousedev
*mousedev
= client
->mousedev
;
619 poll_wait(file
, &mousedev
->wait
, wait
);
620 return ((client
->ready
|| client
->buffer
) ? (POLLIN
| POLLRDNORM
) : 0) |
621 (mousedev
->exist
? 0 : (POLLHUP
| POLLERR
));
624 static const struct file_operations mousedev_fops
= {
625 .owner
= THIS_MODULE
,
626 .read
= mousedev_read
,
627 .write
= mousedev_write
,
628 .poll
= mousedev_poll
,
629 .open
= mousedev_open
,
630 .release
= mousedev_release
,
631 .fasync
= mousedev_fasync
,
634 static int mousedev_connect(struct input_handler
*handler
, struct input_dev
*dev
,
635 const struct input_device_id
*id
)
637 struct mousedev
*mousedev
;
638 struct class_device
*cdev
;
643 for (minor
= 0; minor
< MOUSEDEV_MINORS
&& mousedev_table
[minor
]; minor
++);
644 if (minor
== MOUSEDEV_MINORS
) {
645 printk(KERN_ERR
"mousedev: no more free mousedev devices\n");
649 mousedev
= kzalloc(sizeof(struct mousedev
), GFP_KERNEL
);
653 INIT_LIST_HEAD(&mousedev
->client_list
);
654 INIT_LIST_HEAD(&mousedev
->mixdev_node
);
655 init_waitqueue_head(&mousedev
->wait
);
657 mousedev
->minor
= minor
;
659 mousedev
->handle
.dev
= dev
;
660 mousedev
->handle
.name
= mousedev
->name
;
661 mousedev
->handle
.handler
= handler
;
662 mousedev
->handle
.private = mousedev
;
663 sprintf(mousedev
->name
, "mouse%d", minor
);
665 mousedev_table
[minor
] = mousedev
;
667 devt
= MKDEV(INPUT_MAJOR
, MOUSEDEV_MINOR_BASE
+ minor
),
669 cdev
= class_device_create(&input_class
, &dev
->cdev
, devt
,
670 dev
->cdev
.dev
, mousedev
->name
);
672 error
= PTR_ERR(cdev
);
673 goto err_free_mousedev
;
676 /* temporary symlink to keep userspace happy */
677 error
= sysfs_create_link(&input_class
.subsys
.kset
.kobj
,
678 &cdev
->kobj
, mousedev
->name
);
680 goto err_cdev_destroy
;
682 error
= input_register_handle(&mousedev
->handle
);
684 goto err_remove_link
;
686 if (mousedev_mix
.open
) {
687 error
= input_open_device(&mousedev
->handle
);
689 goto err_unregister_handle
;
694 err_unregister_handle
:
695 input_unregister_handle(&mousedev
->handle
);
697 sysfs_remove_link(&input_class
.subsys
.kset
.kobj
, mousedev
->name
);
699 class_device_destroy(&input_class
, devt
);
701 mousedev_table
[minor
] = NULL
;
706 static void mousedev_disconnect(struct input_handle
*handle
)
708 struct mousedev
*mousedev
= handle
->private;
709 struct mousedev_client
*client
;
711 input_unregister_handle(handle
);
713 sysfs_remove_link(&input_class
.subsys
.kset
.kobj
, mousedev
->name
);
714 class_device_destroy(&input_class
,
715 MKDEV(INPUT_MAJOR
, MOUSEDEV_MINOR_BASE
+ mousedev
->minor
));
718 if (mousedev
->open
) {
719 input_close_device(handle
);
720 wake_up_interruptible(&mousedev
->wait
);
721 list_for_each_entry(client
, &mousedev
->client_list
, node
)
722 kill_fasync(&client
->fasync
, SIGIO
, POLL_HUP
);
724 if (mousedev_mix
.open
)
725 input_close_device(handle
);
726 mousedev_free(mousedev
);
730 static const struct input_device_id mousedev_ids
[] = {
732 .flags
= INPUT_DEVICE_ID_MATCH_EVBIT
| INPUT_DEVICE_ID_MATCH_KEYBIT
| INPUT_DEVICE_ID_MATCH_RELBIT
,
733 .evbit
= { BIT(EV_KEY
) | BIT(EV_REL
) },
734 .keybit
= { [LONG(BTN_LEFT
)] = BIT(BTN_LEFT
) },
735 .relbit
= { BIT(REL_X
) | BIT(REL_Y
) },
736 }, /* A mouse like device, at least one button, two relative axes */
738 .flags
= INPUT_DEVICE_ID_MATCH_EVBIT
| INPUT_DEVICE_ID_MATCH_RELBIT
,
739 .evbit
= { BIT(EV_KEY
) | BIT(EV_REL
) },
740 .relbit
= { BIT(REL_WHEEL
) },
741 }, /* A separate scrollwheel */
743 .flags
= INPUT_DEVICE_ID_MATCH_EVBIT
| INPUT_DEVICE_ID_MATCH_KEYBIT
| INPUT_DEVICE_ID_MATCH_ABSBIT
,
744 .evbit
= { BIT(EV_KEY
) | BIT(EV_ABS
) },
745 .keybit
= { [LONG(BTN_TOUCH
)] = BIT(BTN_TOUCH
) },
746 .absbit
= { BIT(ABS_X
) | BIT(ABS_Y
) },
747 }, /* A tablet like device, at least touch detection, two absolute axes */
749 .flags
= INPUT_DEVICE_ID_MATCH_EVBIT
| INPUT_DEVICE_ID_MATCH_KEYBIT
| INPUT_DEVICE_ID_MATCH_ABSBIT
,
750 .evbit
= { BIT(EV_KEY
) | BIT(EV_ABS
) },
751 .keybit
= { [LONG(BTN_TOOL_FINGER
)] = BIT(BTN_TOOL_FINGER
) },
752 .absbit
= { BIT(ABS_X
) | BIT(ABS_Y
) | BIT(ABS_PRESSURE
) | BIT(ABS_TOOL_WIDTH
) },
755 { }, /* Terminating entry */
758 MODULE_DEVICE_TABLE(input
, mousedev_ids
);
760 static struct input_handler mousedev_handler
= {
761 .event
= mousedev_event
,
762 .connect
= mousedev_connect
,
763 .disconnect
= mousedev_disconnect
,
764 .fops
= &mousedev_fops
,
765 .minor
= MOUSEDEV_MINOR_BASE
,
767 .id_table
= mousedev_ids
,
770 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
771 static struct miscdevice psaux_mouse
= {
772 PSMOUSE_MINOR
, "psaux", &mousedev_fops
774 static int psaux_registered
;
777 static int __init
mousedev_init(void)
779 struct class_device
*cdev
;
782 error
= input_register_handler(&mousedev_handler
);
786 memset(&mousedev_mix
, 0, sizeof(struct mousedev
));
787 INIT_LIST_HEAD(&mousedev_mix
.client_list
);
788 init_waitqueue_head(&mousedev_mix
.wait
);
789 mousedev_table
[MOUSEDEV_MIX
] = &mousedev_mix
;
790 mousedev_mix
.exist
= 1;
791 mousedev_mix
.minor
= MOUSEDEV_MIX
;
793 cdev
= class_device_create(&input_class
, NULL
,
794 MKDEV(INPUT_MAJOR
, MOUSEDEV_MINOR_BASE
+ MOUSEDEV_MIX
), NULL
, "mice");
796 input_unregister_handler(&mousedev_handler
);
797 return PTR_ERR(cdev
);
800 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
801 error
= misc_register(&psaux_mouse
);
803 printk(KERN_WARNING
"mice: could not register psaux device, "
804 "error: %d\n", error
);
806 psaux_registered
= 1;
809 printk(KERN_INFO
"mice: PS/2 mouse device common for all mice\n");
814 static void __exit
mousedev_exit(void)
816 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
817 if (psaux_registered
)
818 misc_deregister(&psaux_mouse
);
820 class_device_destroy(&input_class
,
821 MKDEV(INPUT_MAJOR
, MOUSEDEV_MINOR_BASE
+ MOUSEDEV_MIX
));
822 input_unregister_handler(&mousedev_handler
);
825 module_init(mousedev_init
);
826 module_exit(mousedev_exit
);