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/config.h>
23 #include <linux/smp_lock.h>
24 #include <linux/random.h>
25 #include <linux/major.h>
26 #include <linux/device.h>
27 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
28 #include <linux/miscdevice.h>
31 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
32 MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
33 MODULE_LICENSE("GPL");
35 #ifndef CONFIG_INPUT_MOUSEDEV_SCREEN_X
36 #define CONFIG_INPUT_MOUSEDEV_SCREEN_X 1024
38 #ifndef CONFIG_INPUT_MOUSEDEV_SCREEN_Y
39 #define CONFIG_INPUT_MOUSEDEV_SCREEN_Y 768
42 static int xres
= CONFIG_INPUT_MOUSEDEV_SCREEN_X
;
43 module_param(xres
, uint
, 0);
44 MODULE_PARM_DESC(xres
, "Horizontal screen resolution");
46 static int yres
= CONFIG_INPUT_MOUSEDEV_SCREEN_Y
;
47 module_param(yres
, uint
, 0);
48 MODULE_PARM_DESC(yres
, "Vertical screen resolution");
50 static unsigned tap_time
= 200;
51 module_param(tap_time
, uint
, 0);
52 MODULE_PARM_DESC(tap_time
, "Tap time for touchpads in absolute mode (msecs)");
54 struct mousedev_hw_data
{
58 unsigned long buttons
;
66 wait_queue_head_t wait
;
67 struct list_head list
;
68 struct input_handle handle
;
70 struct mousedev_hw_data packet
;
71 unsigned int pkt_count
;
72 int old_x
[4], old_y
[4];
83 struct mousedev_motion
{
85 unsigned long buttons
;
88 #define PACKET_QUEUE_LEN 16
89 struct mousedev_list
{
90 struct fasync_struct
*fasync
;
91 struct mousedev
*mousedev
;
92 struct list_head node
;
94 struct mousedev_motion packets
[PACKET_QUEUE_LEN
];
95 unsigned int head
, tail
;
96 spinlock_t packet_lock
;
100 unsigned char ready
, buffer
, bufsiz
;
101 unsigned char imexseq
, impsseq
;
102 enum mousedev_emul mode
;
103 unsigned long last_buttons
;
106 #define MOUSEDEV_SEQ_LEN 6
108 static unsigned char mousedev_imps_seq
[] = { 0xf3, 200, 0xf3, 100, 0xf3, 80 };
109 static unsigned char mousedev_imex_seq
[] = { 0xf3, 200, 0xf3, 200, 0xf3, 80 };
111 static struct input_handler mousedev_handler
;
113 static struct mousedev
*mousedev_table
[MOUSEDEV_MINORS
];
114 static struct mousedev mousedev_mix
;
116 #define fx(i) (mousedev->old_x[(mousedev->pkt_count - (i)) & 03])
117 #define fy(i) (mousedev->old_y[(mousedev->pkt_count - (i)) & 03])
119 static void mousedev_touchpad_event(struct input_dev
*dev
, struct mousedev
*mousedev
, unsigned int code
, int value
)
122 enum { FRACTION_DENOM
= 128 };
124 if (mousedev
->touch
) {
125 size
= dev
->absmax
[ABS_X
] - dev
->absmin
[ABS_X
];
126 if (size
== 0) size
= 256 * 2;
130 if (mousedev
->pkt_count
>= 2) {
131 tmp
= ((value
- fx(2)) * (256 * FRACTION_DENOM
)) / size
;
132 tmp
+= mousedev
->frac_dx
;
133 mousedev
->packet
.dx
= tmp
/ FRACTION_DENOM
;
134 mousedev
->frac_dx
= tmp
- mousedev
->packet
.dx
* FRACTION_DENOM
;
140 if (mousedev
->pkt_count
>= 2) {
141 tmp
= -((value
- fy(2)) * (256 * FRACTION_DENOM
)) / size
;
142 tmp
+= mousedev
->frac_dy
;
143 mousedev
->packet
.dy
= tmp
/ FRACTION_DENOM
;
144 mousedev
->frac_dy
= tmp
- mousedev
->packet
.dy
* FRACTION_DENOM
;
151 static void mousedev_abs_event(struct input_dev
*dev
, struct mousedev
*mousedev
, unsigned int code
, int value
)
157 size
= dev
->absmax
[ABS_X
] - dev
->absmin
[ABS_X
];
158 if (size
== 0) size
= xres
;
159 if (value
> dev
->absmax
[ABS_X
]) value
= dev
->absmax
[ABS_X
];
160 if (value
< dev
->absmin
[ABS_X
]) value
= dev
->absmin
[ABS_X
];
161 mousedev
->packet
.x
= ((value
- dev
->absmin
[ABS_X
]) * xres
) / size
;
162 mousedev
->packet
.abs_event
= 1;
166 size
= dev
->absmax
[ABS_Y
] - dev
->absmin
[ABS_Y
];
167 if (size
== 0) size
= yres
;
168 if (value
> dev
->absmax
[ABS_Y
]) value
= dev
->absmax
[ABS_Y
];
169 if (value
< dev
->absmin
[ABS_Y
]) value
= dev
->absmin
[ABS_Y
];
170 mousedev
->packet
.y
= yres
- ((value
- dev
->absmin
[ABS_Y
]) * yres
) / size
;
171 mousedev
->packet
.abs_event
= 1;
176 static void mousedev_rel_event(struct mousedev
*mousedev
, unsigned int code
, int value
)
179 case REL_X
: mousedev
->packet
.dx
+= value
; break;
180 case REL_Y
: mousedev
->packet
.dy
-= value
; break;
181 case REL_WHEEL
: mousedev
->packet
.dz
-= value
; break;
185 static void mousedev_key_event(struct mousedev
*mousedev
, unsigned int code
, int value
)
193 case BTN_LEFT
: index
= 0; break;
196 case BTN_RIGHT
: index
= 1; break;
199 case BTN_MIDDLE
: index
= 2; break;
202 case BTN_SIDE
: index
= 3; break;
204 case BTN_EXTRA
: index
= 4; break;
209 set_bit(index
, &mousedev
->packet
.buttons
);
210 set_bit(index
, &mousedev_mix
.packet
.buttons
);
212 clear_bit(index
, &mousedev
->packet
.buttons
);
213 clear_bit(index
, &mousedev_mix
.packet
.buttons
);
217 static void mousedev_notify_readers(struct mousedev
*mousedev
, struct mousedev_hw_data
*packet
)
219 struct mousedev_list
*list
;
220 struct mousedev_motion
*p
;
222 int wake_readers
= 0;
224 list_for_each_entry(list
, &mousedev
->list
, node
) {
225 spin_lock_irqsave(&list
->packet_lock
, flags
);
227 p
= &list
->packets
[list
->head
];
228 if (list
->ready
&& p
->buttons
!= mousedev
->packet
.buttons
) {
229 unsigned int new_head
= (list
->head
+ 1) % PACKET_QUEUE_LEN
;
230 if (new_head
!= list
->tail
) {
231 p
= &list
->packets
[list
->head
= new_head
];
232 memset(p
, 0, sizeof(struct mousedev_motion
));
236 if (packet
->abs_event
) {
237 p
->dx
+= packet
->x
- list
->pos_x
;
238 p
->dy
+= packet
->y
- list
->pos_y
;
239 list
->pos_x
= packet
->x
;
240 list
->pos_y
= packet
->y
;
243 list
->pos_x
+= packet
->dx
;
244 list
->pos_x
= list
->pos_x
< 0 ? 0 : (list
->pos_x
>= xres
? xres
: list
->pos_x
);
245 list
->pos_y
+= packet
->dy
;
246 list
->pos_y
= list
->pos_y
< 0 ? 0 : (list
->pos_y
>= yres
? yres
: list
->pos_y
);
251 p
->buttons
= mousedev
->packet
.buttons
;
253 if (p
->dx
|| p
->dy
|| p
->dz
|| p
->buttons
!= list
->last_buttons
)
256 spin_unlock_irqrestore(&list
->packet_lock
, flags
);
259 kill_fasync(&list
->fasync
, SIGIO
, POLL_IN
);
265 wake_up_interruptible(&mousedev
->wait
);
268 static void mousedev_touchpad_touch(struct mousedev
*mousedev
, int value
)
271 if (mousedev
->touch
&&
272 time_before(jiffies
, mousedev
->touch
+ msecs_to_jiffies(tap_time
))) {
274 * Toggle left button to emulate tap.
275 * We rely on the fact that mousedev_mix always has 0
276 * motion packet so we won't mess current position.
278 set_bit(0, &mousedev
->packet
.buttons
);
279 set_bit(0, &mousedev_mix
.packet
.buttons
);
280 mousedev_notify_readers(mousedev
, &mousedev_mix
.packet
);
281 mousedev_notify_readers(&mousedev_mix
, &mousedev_mix
.packet
);
282 clear_bit(0, &mousedev
->packet
.buttons
);
283 clear_bit(0, &mousedev_mix
.packet
.buttons
);
285 mousedev
->touch
= mousedev
->pkt_count
= 0;
286 mousedev
->frac_dx
= 0;
287 mousedev
->frac_dy
= 0;
290 if (!mousedev
->touch
)
291 mousedev
->touch
= jiffies
;
294 static void mousedev_event(struct input_handle
*handle
, unsigned int type
, unsigned int code
, int value
)
296 struct mousedev
*mousedev
= handle
->private;
300 /* Ignore joysticks */
301 if (test_bit(BTN_TRIGGER
, handle
->dev
->keybit
))
304 if (test_bit(BTN_TOOL_FINGER
, handle
->dev
->keybit
))
305 mousedev_touchpad_event(handle
->dev
, mousedev
, code
, value
);
307 mousedev_abs_event(handle
->dev
, mousedev
, code
, value
);
312 mousedev_rel_event(mousedev
, code
, value
);
317 if (code
== BTN_TOUCH
&& test_bit(BTN_TOOL_FINGER
, handle
->dev
->keybit
))
318 mousedev_touchpad_touch(mousedev
, value
);
320 mousedev_key_event(mousedev
, code
, value
);
325 if (code
== SYN_REPORT
) {
326 if (mousedev
->touch
) {
327 mousedev
->pkt_count
++;
328 /* Input system eats duplicate events, but we need all of them
329 * to do correct averaging so apply present one forward
335 mousedev_notify_readers(mousedev
, &mousedev
->packet
);
336 mousedev_notify_readers(&mousedev_mix
, &mousedev
->packet
);
338 mousedev
->packet
.dx
= mousedev
->packet
.dy
= mousedev
->packet
.dz
= 0;
339 mousedev
->packet
.abs_event
= 0;
345 static int mousedev_fasync(int fd
, struct file
*file
, int on
)
348 struct mousedev_list
*list
= file
->private_data
;
349 retval
= fasync_helper(fd
, file
, on
, &list
->fasync
);
350 return retval
< 0 ? retval
: 0;
353 static void mousedev_free(struct mousedev
*mousedev
)
355 mousedev_table
[mousedev
->minor
] = NULL
;
359 static int mixdev_release(void)
361 struct input_handle
*handle
;
363 list_for_each_entry(handle
, &mousedev_handler
.h_list
, h_node
) {
364 struct mousedev
*mousedev
= handle
->private;
366 if (!mousedev
->open
) {
368 input_close_device(&mousedev
->handle
);
370 mousedev_free(mousedev
);
377 static int mousedev_release(struct inode
* inode
, struct file
* file
)
379 struct mousedev_list
*list
= file
->private_data
;
381 mousedev_fasync(-1, file
, 0);
383 list_del(&list
->node
);
385 if (!--list
->mousedev
->open
) {
386 if (list
->mousedev
->minor
== MOUSEDEV_MIX
)
387 return mixdev_release();
389 if (!mousedev_mix
.open
) {
390 if (list
->mousedev
->exist
)
391 input_close_device(&list
->mousedev
->handle
);
393 mousedev_free(list
->mousedev
);
401 static int mousedev_open(struct inode
* inode
, struct file
* file
)
403 struct mousedev_list
*list
;
404 struct input_handle
*handle
;
405 struct mousedev
*mousedev
;
408 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
409 if (imajor(inode
) == MISC_MAJOR
)
413 i
= iminor(inode
) - MOUSEDEV_MINOR_BASE
;
415 if (i
>= MOUSEDEV_MINORS
|| !mousedev_table
[i
])
418 if (!(list
= kmalloc(sizeof(struct mousedev_list
), GFP_KERNEL
)))
420 memset(list
, 0, sizeof(struct mousedev_list
));
422 spin_lock_init(&list
->packet_lock
);
423 list
->pos_x
= xres
/ 2;
424 list
->pos_y
= yres
/ 2;
425 list
->mousedev
= mousedev_table
[i
];
426 list_add_tail(&list
->node
, &mousedev_table
[i
]->list
);
427 file
->private_data
= list
;
429 if (!list
->mousedev
->open
++) {
430 if (list
->mousedev
->minor
== MOUSEDEV_MIX
) {
431 list_for_each_entry(handle
, &mousedev_handler
.h_list
, h_node
) {
432 mousedev
= handle
->private;
433 if (!mousedev
->open
&& mousedev
->exist
)
434 input_open_device(handle
);
437 if (!mousedev_mix
.open
&& list
->mousedev
->exist
)
438 input_open_device(&list
->mousedev
->handle
);
444 static inline int mousedev_limit_delta(int delta
, int limit
)
446 return delta
> limit
? limit
: (delta
< -limit
? -limit
: delta
);
449 static void mousedev_packet(struct mousedev_list
*list
, signed char *ps2_data
)
451 struct mousedev_motion
*p
;
454 spin_lock_irqsave(&list
->packet_lock
, flags
);
455 p
= &list
->packets
[list
->tail
];
457 ps2_data
[0] = 0x08 | ((p
->dx
< 0) << 4) | ((p
->dy
< 0) << 5) | (p
->buttons
& 0x07);
458 ps2_data
[1] = mousedev_limit_delta(p
->dx
, 127);
459 ps2_data
[2] = mousedev_limit_delta(p
->dy
, 127);
460 p
->dx
-= ps2_data
[1];
461 p
->dy
-= ps2_data
[2];
463 switch (list
->mode
) {
464 case MOUSEDEV_EMUL_EXPS
:
465 ps2_data
[3] = mousedev_limit_delta(p
->dz
, 7);
466 p
->dz
-= ps2_data
[3];
467 ps2_data
[3] = (ps2_data
[3] & 0x0f) | ((p
->buttons
& 0x18) << 1);
471 case MOUSEDEV_EMUL_IMPS
:
472 ps2_data
[0] |= ((p
->buttons
& 0x10) >> 3) | ((p
->buttons
& 0x08) >> 1);
473 ps2_data
[3] = mousedev_limit_delta(p
->dz
, 127);
474 p
->dz
-= ps2_data
[3];
478 case MOUSEDEV_EMUL_PS2
:
480 ps2_data
[0] |= ((p
->buttons
& 0x10) >> 3) | ((p
->buttons
& 0x08) >> 1);
486 if (!p
->dx
&& !p
->dy
&& !p
->dz
) {
487 if (list
->tail
== list
->head
) {
489 list
->last_buttons
= p
->buttons
;
491 list
->tail
= (list
->tail
+ 1) % PACKET_QUEUE_LEN
;
494 spin_unlock_irqrestore(&list
->packet_lock
, flags
);
498 static ssize_t
mousedev_write(struct file
* file
, const char __user
* buffer
, size_t count
, loff_t
*ppos
)
500 struct mousedev_list
*list
= file
->private_data
;
504 for (i
= 0; i
< count
; i
++) {
506 if (get_user(c
, buffer
+ i
))
509 if (c
== mousedev_imex_seq
[list
->imexseq
]) {
510 if (++list
->imexseq
== MOUSEDEV_SEQ_LEN
) {
512 list
->mode
= MOUSEDEV_EMUL_EXPS
;
514 } else list
->imexseq
= 0;
516 if (c
== mousedev_imps_seq
[list
->impsseq
]) {
517 if (++list
->impsseq
== MOUSEDEV_SEQ_LEN
) {
519 list
->mode
= MOUSEDEV_EMUL_IMPS
;
521 } else list
->impsseq
= 0;
527 case 0xeb: /* Poll */
528 mousedev_packet(list
, &list
->ps2
[1]);
529 list
->bufsiz
++; /* account for leading ACK */
532 case 0xf2: /* Get ID */
533 switch (list
->mode
) {
534 case MOUSEDEV_EMUL_PS2
: list
->ps2
[1] = 0; break;
535 case MOUSEDEV_EMUL_IMPS
: list
->ps2
[1] = 3; break;
536 case MOUSEDEV_EMUL_EXPS
: list
->ps2
[1] = 4; break;
541 case 0xe9: /* Get info */
542 list
->ps2
[1] = 0x60; list
->ps2
[2] = 3; list
->ps2
[3] = 200;
546 case 0xff: /* Reset */
547 list
->impsseq
= list
->imexseq
= 0;
548 list
->mode
= MOUSEDEV_EMUL_PS2
;
549 list
->ps2
[1] = 0xaa; list
->ps2
[2] = 0x00;
558 list
->buffer
= list
->bufsiz
;
561 kill_fasync(&list
->fasync
, SIGIO
, POLL_IN
);
563 wake_up_interruptible(&list
->mousedev
->wait
);
568 static ssize_t
mousedev_read(struct file
* file
, char __user
* buffer
, size_t count
, loff_t
*ppos
)
570 struct mousedev_list
*list
= file
->private_data
;
573 if (!list
->ready
&& !list
->buffer
&& (file
->f_flags
& O_NONBLOCK
))
576 retval
= wait_event_interruptible(list
->mousedev
->wait
,
577 !list
->mousedev
->exist
|| list
->ready
|| list
->buffer
);
582 if (!list
->mousedev
->exist
)
585 if (!list
->buffer
&& list
->ready
) {
586 mousedev_packet(list
, list
->ps2
);
587 list
->buffer
= list
->bufsiz
;
590 if (count
> list
->buffer
)
591 count
= list
->buffer
;
593 list
->buffer
-= count
;
595 if (copy_to_user(buffer
, list
->ps2
+ list
->bufsiz
- list
->buffer
- count
, count
))
601 /* No kernel lock - fine */
602 static unsigned int mousedev_poll(struct file
*file
, poll_table
*wait
)
604 struct mousedev_list
*list
= file
->private_data
;
605 poll_wait(file
, &list
->mousedev
->wait
, wait
);
606 return ((list
->ready
|| list
->buffer
) ? (POLLIN
| POLLRDNORM
) : 0) |
607 (list
->mousedev
->exist
? 0 : (POLLHUP
| POLLERR
));
610 static struct file_operations mousedev_fops
= {
611 .owner
= THIS_MODULE
,
612 .read
= mousedev_read
,
613 .write
= mousedev_write
,
614 .poll
= mousedev_poll
,
615 .open
= mousedev_open
,
616 .release
= mousedev_release
,
617 .fasync
= mousedev_fasync
,
620 static struct input_handle
*mousedev_connect(struct input_handler
*handler
, struct input_dev
*dev
, struct input_device_id
*id
)
622 struct mousedev
*mousedev
;
623 struct class_device
*cdev
;
626 for (minor
= 0; minor
< MOUSEDEV_MINORS
&& mousedev_table
[minor
]; minor
++);
627 if (minor
== MOUSEDEV_MINORS
) {
628 printk(KERN_ERR
"mousedev: no more free mousedev devices\n");
632 if (!(mousedev
= kmalloc(sizeof(struct mousedev
), GFP_KERNEL
)))
634 memset(mousedev
, 0, sizeof(struct mousedev
));
636 INIT_LIST_HEAD(&mousedev
->list
);
637 init_waitqueue_head(&mousedev
->wait
);
639 mousedev
->minor
= minor
;
641 mousedev
->handle
.dev
= dev
;
642 mousedev
->handle
.name
= mousedev
->name
;
643 mousedev
->handle
.handler
= handler
;
644 mousedev
->handle
.private = mousedev
;
645 sprintf(mousedev
->name
, "mouse%d", minor
);
647 if (mousedev_mix
.open
)
648 input_open_device(&mousedev
->handle
);
650 mousedev_table
[minor
] = mousedev
;
652 cdev
= class_device_create(&input_class
, &dev
->cdev
,
653 MKDEV(INPUT_MAJOR
, MOUSEDEV_MINOR_BASE
+ minor
),
654 dev
->cdev
.dev
, mousedev
->name
);
656 /* temporary symlink to keep userspace happy */
657 sysfs_create_link(&input_class
.subsys
.kset
.kobj
, &cdev
->kobj
,
660 return &mousedev
->handle
;
663 static void mousedev_disconnect(struct input_handle
*handle
)
665 struct mousedev
*mousedev
= handle
->private;
666 struct mousedev_list
*list
;
668 sysfs_remove_link(&input_class
.subsys
.kset
.kobj
, mousedev
->name
);
669 class_device_destroy(&input_class
,
670 MKDEV(INPUT_MAJOR
, MOUSEDEV_MINOR_BASE
+ mousedev
->minor
));
673 if (mousedev
->open
) {
674 input_close_device(handle
);
675 wake_up_interruptible(&mousedev
->wait
);
676 list_for_each_entry(list
, &mousedev
->list
, node
)
677 kill_fasync(&list
->fasync
, SIGIO
, POLL_HUP
);
679 if (mousedev_mix
.open
)
680 input_close_device(handle
);
681 mousedev_free(mousedev
);
685 static struct input_device_id mousedev_ids
[] = {
687 .flags
= INPUT_DEVICE_ID_MATCH_EVBIT
| INPUT_DEVICE_ID_MATCH_KEYBIT
| INPUT_DEVICE_ID_MATCH_RELBIT
,
688 .evbit
= { BIT(EV_KEY
) | BIT(EV_REL
) },
689 .keybit
= { [LONG(BTN_LEFT
)] = BIT(BTN_LEFT
) },
690 .relbit
= { BIT(REL_X
) | BIT(REL_Y
) },
691 }, /* A mouse like device, at least one button, two relative axes */
693 .flags
= INPUT_DEVICE_ID_MATCH_EVBIT
| INPUT_DEVICE_ID_MATCH_RELBIT
,
694 .evbit
= { BIT(EV_KEY
) | BIT(EV_REL
) },
695 .relbit
= { BIT(REL_WHEEL
) },
696 }, /* A separate scrollwheel */
698 .flags
= INPUT_DEVICE_ID_MATCH_EVBIT
| INPUT_DEVICE_ID_MATCH_KEYBIT
| INPUT_DEVICE_ID_MATCH_ABSBIT
,
699 .evbit
= { BIT(EV_KEY
) | BIT(EV_ABS
) },
700 .keybit
= { [LONG(BTN_TOUCH
)] = BIT(BTN_TOUCH
) },
701 .absbit
= { BIT(ABS_X
) | BIT(ABS_Y
) },
702 }, /* A tablet like device, at least touch detection, two absolute axes */
704 .flags
= INPUT_DEVICE_ID_MATCH_EVBIT
| INPUT_DEVICE_ID_MATCH_KEYBIT
| INPUT_DEVICE_ID_MATCH_ABSBIT
,
705 .evbit
= { BIT(EV_KEY
) | BIT(EV_ABS
) },
706 .keybit
= { [LONG(BTN_TOOL_FINGER
)] = BIT(BTN_TOOL_FINGER
) },
707 .absbit
= { BIT(ABS_X
) | BIT(ABS_Y
) | BIT(ABS_PRESSURE
) | BIT(ABS_TOOL_WIDTH
) },
710 { }, /* Terminating entry */
713 MODULE_DEVICE_TABLE(input
, mousedev_ids
);
715 static struct input_handler mousedev_handler
= {
716 .event
= mousedev_event
,
717 .connect
= mousedev_connect
,
718 .disconnect
= mousedev_disconnect
,
719 .fops
= &mousedev_fops
,
720 .minor
= MOUSEDEV_MINOR_BASE
,
722 .id_table
= mousedev_ids
,
725 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
726 static struct miscdevice psaux_mouse
= {
727 PSMOUSE_MINOR
, "psaux", &mousedev_fops
729 static int psaux_registered
;
732 static int __init
mousedev_init(void)
734 input_register_handler(&mousedev_handler
);
736 memset(&mousedev_mix
, 0, sizeof(struct mousedev
));
737 INIT_LIST_HEAD(&mousedev_mix
.list
);
738 init_waitqueue_head(&mousedev_mix
.wait
);
739 mousedev_table
[MOUSEDEV_MIX
] = &mousedev_mix
;
740 mousedev_mix
.exist
= 1;
741 mousedev_mix
.minor
= MOUSEDEV_MIX
;
743 class_device_create(&input_class
, NULL
,
744 MKDEV(INPUT_MAJOR
, MOUSEDEV_MINOR_BASE
+ MOUSEDEV_MIX
), NULL
, "mice");
746 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
747 if (!(psaux_registered
= !misc_register(&psaux_mouse
)))
748 printk(KERN_WARNING
"mice: could not misc_register the device\n");
751 printk(KERN_INFO
"mice: PS/2 mouse device common for all mice\n");
756 static void __exit
mousedev_exit(void)
758 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
759 if (psaux_registered
)
760 misc_deregister(&psaux_mouse
);
762 class_device_destroy(&input_class
,
763 MKDEV(INPUT_MAJOR
, MOUSEDEV_MINOR_BASE
+ MOUSEDEV_MIX
));
764 input_unregister_handler(&mousedev_handler
);
767 module_init(mousedev_init
);
768 module_exit(mousedev_exit
);