diff options
author | Max Asbock <masbock@us.ibm.com> | 2005-06-21 20:16:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-21 22:07:35 -0400 |
commit | 278d72ae8803ffcd16070c95fe1d53f4466dc741 (patch) | |
tree | 6cee233065ff15a42dfa86b7b159c4b06bb01b3f /drivers | |
parent | b8acb808468a88a188d7c5aba3681c583a5785f9 (diff) |
[PATCH] ibmasm driver: redesign handling of remote control events
This patch rewrites the handling of remote control events. Rather than making
them available from a special file in the ibmasmfs, now the events from the
RSA card get translated into kernel input events and injected into the input
subsystem. The driver now will generate two /dev/input/eventX nodes -- one
for the keyboard and one for the mouse. The mouse node generates absolute
events more like a touch pad than a mouse.
Signed-off-by: Vernon Mauery <vernux@us.ibm.com>
Signed-off-by: Max Asbock <masbock@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/ibmasm/ibmasm.h | 65 | ||||
-rw-r--r-- | drivers/misc/ibmasm/ibmasmfs.c | 89 | ||||
-rw-r--r-- | drivers/misc/ibmasm/lowlevel.c | 18 | ||||
-rw-r--r-- | drivers/misc/ibmasm/module.c | 69 | ||||
-rw-r--r-- | drivers/misc/ibmasm/remote.c | 304 | ||||
-rw-r--r-- | drivers/misc/ibmasm/remote.h | 173 |
6 files changed, 449 insertions, 269 deletions
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h index 35c4def5af18..653a7d096a8b 100644 --- a/drivers/misc/ibmasm/ibmasm.h +++ b/drivers/misc/ibmasm/ibmasm.h | |||
@@ -34,16 +34,31 @@ | |||
34 | #include <linux/version.h> | 34 | #include <linux/version.h> |
35 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
36 | #include <linux/device.h> | 36 | #include <linux/device.h> |
37 | #include <linux/input.h> | ||
37 | 38 | ||
38 | /* Driver identification */ | 39 | /* Driver identification */ |
39 | #define DRIVER_NAME "ibmasm" | 40 | #define DRIVER_NAME "ibmasm" |
40 | #define DRIVER_VERSION "0.4" | 41 | #define DRIVER_VERSION "1.0" |
41 | #define DRIVER_AUTHOR "Max Asbock" | 42 | #define DRIVER_AUTHOR "Max Asbock <masbock@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>" |
42 | #define DRIVER_DESC "IBM ASM Service Processor Driver" | 43 | #define DRIVER_DESC "IBM ASM Service Processor Driver" |
43 | 44 | ||
44 | #define err(msg) printk(KERN_ERR "%s: " msg "\n", DRIVER_NAME) | 45 | #define err(msg) printk(KERN_ERR "%s: " msg "\n", DRIVER_NAME) |
45 | #define info(msg) printk(KERN_INFO "%s: " msg "\n", DRIVER_NAME) | 46 | #define info(msg) printk(KERN_INFO "%s: " msg "\n", DRIVER_NAME) |
46 | 47 | ||
48 | extern int ibmasm_debug; | ||
49 | #define dbg(STR, ARGS...) \ | ||
50 | do { \ | ||
51 | if (ibmasm_debug) \ | ||
52 | printk(KERN_DEBUG STR , ##ARGS); \ | ||
53 | } while (0) | ||
54 | |||
55 | static inline char *get_timestamp(char *buf) | ||
56 | { | ||
57 | struct timeval now; | ||
58 | do_gettimeofday(&now); | ||
59 | sprintf(buf, "%lu.%lu", now.tv_sec, now.tv_usec); | ||
60 | return buf; | ||
61 | } | ||
47 | 62 | ||
48 | #define IBMASM_CMD_PENDING 0 | 63 | #define IBMASM_CMD_PENDING 0 |
49 | #define IBMASM_CMD_COMPLETE 1 | 64 | #define IBMASM_CMD_COMPLETE 1 |
@@ -121,41 +136,11 @@ struct reverse_heartbeat { | |||
121 | unsigned int stopped; | 136 | unsigned int stopped; |
122 | }; | 137 | }; |
123 | 138 | ||
124 | 139 | struct ibmasm_remote { | |
125 | /* remote console events */ | 140 | struct input_dev keybd_dev; |
126 | struct mouse_event { | 141 | struct input_dev mouse_dev; |
127 | long x; | ||
128 | long y; | ||
129 | unsigned char buttons; | ||
130 | unsigned char transitions; | ||
131 | }; | 142 | }; |
132 | 143 | ||
133 | struct keyboard_event { | ||
134 | unsigned long key_code; | ||
135 | unsigned char key_down; | ||
136 | }; | ||
137 | |||
138 | struct remote_event { | ||
139 | unsigned long type; | ||
140 | union { | ||
141 | struct mouse_event mouse; | ||
142 | struct keyboard_event keyboard; | ||
143 | } data; | ||
144 | }; | ||
145 | |||
146 | #define DRIVER_REMOTE_QUEUE_SIZE 240 | ||
147 | |||
148 | struct remote_queue { | ||
149 | struct remote_event *start; | ||
150 | struct remote_event *end; | ||
151 | struct remote_event *reader; | ||
152 | struct remote_event *writer; | ||
153 | unsigned int size; | ||
154 | int open; | ||
155 | wait_queue_head_t wait; | ||
156 | }; | ||
157 | |||
158 | |||
159 | struct service_processor { | 144 | struct service_processor { |
160 | struct list_head node; | 145 | struct list_head node; |
161 | spinlock_t lock; | 146 | spinlock_t lock; |
@@ -168,7 +153,7 @@ struct service_processor { | |||
168 | char dirname[IBMASM_NAME_SIZE]; | 153 | char dirname[IBMASM_NAME_SIZE]; |
169 | char devname[IBMASM_NAME_SIZE]; | 154 | char devname[IBMASM_NAME_SIZE]; |
170 | unsigned int number; | 155 | unsigned int number; |
171 | struct remote_queue remote_queue; | 156 | struct ibmasm_remote *remote; |
172 | int serial_line; | 157 | int serial_line; |
173 | struct device *dev; | 158 | struct device *dev; |
174 | }; | 159 | }; |
@@ -210,11 +195,9 @@ extern int ibmasm_send_i2o_message(struct service_processor *sp); | |||
210 | extern irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id, struct pt_regs *regs); | 195 | extern irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id, struct pt_regs *regs); |
211 | 196 | ||
212 | /* remote console */ | 197 | /* remote console */ |
213 | extern void ibmasm_handle_mouse_interrupt(struct service_processor *sp); | 198 | extern void ibmasm_handle_mouse_interrupt(struct service_processor *sp, struct pt_regs *regs); |
214 | extern int ibmasm_init_remote_queue(struct service_processor *sp); | 199 | extern int ibmasm_init_remote_input_dev(struct service_processor *sp); |
215 | extern void ibmasm_free_remote_queue(struct service_processor *sp); | 200 | extern void ibmasm_free_remote_input_dev(struct service_processor *sp); |
216 | extern void ibmasm_advance_reader(struct remote_queue *q, unsigned int n); | ||
217 | extern size_t ibmasm_events_available(struct remote_queue *q); | ||
218 | 201 | ||
219 | /* file system */ | 202 | /* file system */ |
220 | extern int ibmasmfs_register(void); | 203 | extern int ibmasmfs_register(void); |
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c index c87ef7d82b70..ca839162e4f7 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c | |||
@@ -37,9 +37,7 @@ | |||
37 | * | |-- event | 37 | * | |-- event |
38 | * | |-- reverse_heartbeat | 38 | * | |-- reverse_heartbeat |
39 | * | `-- remote_video | 39 | * | `-- remote_video |
40 | * | |-- connected | ||
41 | * | |-- depth | 40 | * | |-- depth |
42 | * | |-- events | ||
43 | * | |-- height | 41 | * | |-- height |
44 | * | `-- width | 42 | * | `-- width |
45 | * . | 43 | * . |
@@ -50,9 +48,7 @@ | |||
50 | * |-- event | 48 | * |-- event |
51 | * |-- reverse_heartbeat | 49 | * |-- reverse_heartbeat |
52 | * `-- remote_video | 50 | * `-- remote_video |
53 | * |-- connected | ||
54 | * |-- depth | 51 | * |-- depth |
55 | * |-- events | ||
56 | * |-- height | 52 | * |-- height |
57 | * `-- width | 53 | * `-- width |
58 | * | 54 | * |
@@ -75,14 +71,6 @@ | |||
75 | * remote_video/width: control remote display settings | 71 | * remote_video/width: control remote display settings |
76 | * write: set value | 72 | * write: set value |
77 | * read: read value | 73 | * read: read value |
78 | * | ||
79 | * remote_video/connected | ||
80 | * read: return "1" if web browser VNC java applet is connected, | ||
81 | * "0" otherwise | ||
82 | * | ||
83 | * remote_video/events | ||
84 | * read: sleep until a remote mouse or keyboard event occurs, then return | ||
85 | * then event. | ||
86 | */ | 74 | */ |
87 | 75 | ||
88 | #include <linux/fs.h> | 76 | #include <linux/fs.h> |
@@ -593,75 +581,6 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user * | |||
593 | return count; | 581 | return count; |
594 | } | 582 | } |
595 | 583 | ||
596 | static int remote_event_file_open(struct inode *inode, struct file *file) | ||
597 | { | ||
598 | struct service_processor *sp; | ||
599 | unsigned long flags; | ||
600 | struct remote_queue *q; | ||
601 | |||
602 | file->private_data = inode->u.generic_ip; | ||
603 | sp = file->private_data; | ||
604 | q = &sp->remote_queue; | ||
605 | |||
606 | /* allow only one event reader */ | ||
607 | spin_lock_irqsave(&sp->lock, flags); | ||
608 | if (q->open) { | ||
609 | spin_unlock_irqrestore(&sp->lock, flags); | ||
610 | return -EBUSY; | ||
611 | } | ||
612 | q->open = 1; | ||
613 | spin_unlock_irqrestore(&sp->lock, flags); | ||
614 | |||
615 | enable_mouse_interrupts(sp); | ||
616 | |||
617 | return 0; | ||
618 | } | ||
619 | |||
620 | static int remote_event_file_close(struct inode *inode, struct file *file) | ||
621 | { | ||
622 | struct service_processor *sp = file->private_data; | ||
623 | |||
624 | disable_mouse_interrupts(sp); | ||
625 | wake_up_interruptible(&sp->remote_queue.wait); | ||
626 | sp->remote_queue.open = 0; | ||
627 | |||
628 | return 0; | ||
629 | } | ||
630 | |||
631 | static ssize_t remote_event_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset) | ||
632 | { | ||
633 | struct service_processor *sp = file->private_data; | ||
634 | struct remote_queue *q = &sp->remote_queue; | ||
635 | size_t data_size; | ||
636 | struct remote_event *reader = q->reader; | ||
637 | size_t num_events; | ||
638 | |||
639 | if (*offset < 0) | ||
640 | return -EINVAL; | ||
641 | if (count == 0 || count > 1024) | ||
642 | return 0; | ||
643 | if (*offset != 0) | ||
644 | return 0; | ||
645 | |||
646 | if (wait_event_interruptible(q->wait, q->reader != q->writer)) | ||
647 | return -ERESTARTSYS; | ||
648 | |||
649 | /* only get multiples of struct remote_event */ | ||
650 | num_events = min((count/sizeof(struct remote_event)), ibmasm_events_available(q)); | ||
651 | if (!num_events) | ||
652 | return 0; | ||
653 | |||
654 | data_size = num_events * sizeof(struct remote_event); | ||
655 | |||
656 | if (copy_to_user(buf, reader, data_size)) | ||
657 | return -EFAULT; | ||
658 | |||
659 | ibmasm_advance_reader(q, num_events); | ||
660 | |||
661 | return data_size; | ||
662 | } | ||
663 | |||
664 | |||
665 | static struct file_operations command_fops = { | 584 | static struct file_operations command_fops = { |
666 | .open = command_file_open, | 585 | .open = command_file_open, |
667 | .release = command_file_close, | 586 | .release = command_file_close, |
@@ -690,12 +609,6 @@ static struct file_operations remote_settings_fops = { | |||
690 | .write = remote_settings_file_write, | 609 | .write = remote_settings_file_write, |
691 | }; | 610 | }; |
692 | 611 | ||
693 | static struct file_operations remote_event_fops = { | ||
694 | .open = remote_event_file_open, | ||
695 | .release = remote_event_file_close, | ||
696 | .read = remote_event_file_read, | ||
697 | }; | ||
698 | |||
699 | 612 | ||
700 | static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root) | 613 | static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root) |
701 | { | 614 | { |
@@ -721,7 +634,5 @@ static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root) | |||
721 | ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR); | 634 | ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR); |
722 | ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR); | 635 | ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR); |
723 | ibmasmfs_create_file(sb, remote_dir, "depth", &remote_settings_fops, (void *)display_depth(sp), S_IRUSR|S_IWUSR); | 636 | ibmasmfs_create_file(sb, remote_dir, "depth", &remote_settings_fops, (void *)display_depth(sp), S_IRUSR|S_IWUSR); |
724 | ibmasmfs_create_file(sb, remote_dir, "connected", &remote_settings_fops, (void *)vnc_status(sp), S_IRUSR); | ||
725 | ibmasmfs_create_file(sb, remote_dir, "events", &remote_event_fops, (void *)sp, S_IRUSR); | ||
726 | } | 637 | } |
727 | } | 638 | } |
diff --git a/drivers/misc/ibmasm/lowlevel.c b/drivers/misc/ibmasm/lowlevel.c index 5156de2759d8..47949a2c7e94 100644 --- a/drivers/misc/ibmasm/lowlevel.c +++ b/drivers/misc/ibmasm/lowlevel.c | |||
@@ -46,8 +46,8 @@ int ibmasm_send_i2o_message(struct service_processor *sp) | |||
46 | 46 | ||
47 | message = get_i2o_message(sp->base_address, mfa); | 47 | message = get_i2o_message(sp->base_address, mfa); |
48 | 48 | ||
49 | memcpy(&message->header, &header, sizeof(struct i2o_header)); | 49 | memcpy_toio(&message->header, &header, sizeof(struct i2o_header)); |
50 | memcpy(&message->data, command->buffer, command_size); | 50 | memcpy_toio(&message->data, command->buffer, command_size); |
51 | 51 | ||
52 | set_mfa_inbound(sp->base_address, mfa); | 52 | set_mfa_inbound(sp->base_address, mfa); |
53 | 53 | ||
@@ -59,23 +59,27 @@ irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id, struct pt_regs *reg | |||
59 | u32 mfa; | 59 | u32 mfa; |
60 | struct service_processor *sp = (struct service_processor *)dev_id; | 60 | struct service_processor *sp = (struct service_processor *)dev_id; |
61 | void __iomem *base_address = sp->base_address; | 61 | void __iomem *base_address = sp->base_address; |
62 | char tsbuf[32]; | ||
62 | 63 | ||
63 | if (!sp_interrupt_pending(base_address)) | 64 | if (!sp_interrupt_pending(base_address)) |
64 | return IRQ_NONE; | 65 | return IRQ_NONE; |
65 | 66 | ||
67 | dbg("respond to interrupt at %s\n", get_timestamp(tsbuf)); | ||
68 | |||
66 | if (mouse_interrupt_pending(sp)) { | 69 | if (mouse_interrupt_pending(sp)) { |
67 | ibmasm_handle_mouse_interrupt(sp); | 70 | ibmasm_handle_mouse_interrupt(sp, regs); |
68 | mfa = get_mfa_outbound(base_address); | ||
69 | clear_mouse_interrupt(sp); | 71 | clear_mouse_interrupt(sp); |
70 | set_mfa_outbound(base_address, mfa); | ||
71 | return IRQ_HANDLED; | ||
72 | } | 72 | } |
73 | 73 | ||
74 | mfa = get_mfa_outbound(base_address); | 74 | mfa = get_mfa_outbound(base_address); |
75 | if (valid_mfa(mfa)) { | 75 | if (valid_mfa(mfa)) { |
76 | struct i2o_message *msg = get_i2o_message(base_address, mfa); | 76 | struct i2o_message *msg = get_i2o_message(base_address, mfa); |
77 | ibmasm_receive_message(sp, &msg->data, incoming_data_size(msg)); | 77 | ibmasm_receive_message(sp, &msg->data, incoming_data_size(msg)); |
78 | } | 78 | } else |
79 | dbg("didn't get a valid MFA\n"); | ||
80 | |||
79 | set_mfa_outbound(base_address, mfa); | 81 | set_mfa_outbound(base_address, mfa); |
82 | dbg("finished interrupt at %s\n", get_timestamp(tsbuf)); | ||
83 | |||
80 | return IRQ_HANDLED; | 84 | return IRQ_HANDLED; |
81 | } | 85 | } |
diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c index 777432ae764a..1fdf03fd2da7 100644 --- a/drivers/misc/ibmasm/module.c +++ b/drivers/misc/ibmasm/module.c | |||
@@ -56,17 +56,26 @@ | |||
56 | #include "lowlevel.h" | 56 | #include "lowlevel.h" |
57 | #include "remote.h" | 57 | #include "remote.h" |
58 | 58 | ||
59 | int ibmasm_debug = 0; | ||
60 | module_param(ibmasm_debug, int , S_IRUGO | S_IWUSR); | ||
61 | MODULE_PARM_DESC(ibmasm_debug, " Set debug mode on or off"); | ||
62 | |||
59 | 63 | ||
60 | static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 64 | static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
61 | { | 65 | { |
62 | int err, result = -ENOMEM; | 66 | int result; |
63 | struct service_processor *sp; | 67 | struct service_processor *sp; |
64 | 68 | ||
65 | if ((err = pci_enable_device(pdev))) { | 69 | if ((result = pci_enable_device(pdev))) { |
66 | printk(KERN_ERR "%s: can't enable PCI device at %s\n", | 70 | dev_err(&pdev->dev, "Failed to enable PCI device\n"); |
67 | DRIVER_NAME, pci_name(pdev)); | 71 | return result; |
68 | return err; | ||
69 | } | 72 | } |
73 | if ((result = pci_request_regions(pdev, DRIVER_NAME))) { | ||
74 | dev_err(&pdev->dev, "Failed to allocate PCI resources\n"); | ||
75 | goto error_resources; | ||
76 | } | ||
77 | /* vnc client won't work without bus-mastering */ | ||
78 | pci_set_master(pdev); | ||
70 | 79 | ||
71 | sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL); | 80 | sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL); |
72 | if (sp == NULL) { | 81 | if (sp == NULL) { |
@@ -76,6 +85,9 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi | |||
76 | } | 85 | } |
77 | memset(sp, 0, sizeof(struct service_processor)); | 86 | memset(sp, 0, sizeof(struct service_processor)); |
78 | 87 | ||
88 | sp->lock = SPIN_LOCK_UNLOCKED; | ||
89 | INIT_LIST_HEAD(&sp->command_queue); | ||
90 | |||
79 | pci_set_drvdata(pdev, (void *)sp); | 91 | pci_set_drvdata(pdev, (void *)sp); |
80 | sp->dev = &pdev->dev; | 92 | sp->dev = &pdev->dev; |
81 | sp->number = pdev->bus->number; | 93 | sp->number = pdev->bus->number; |
@@ -101,15 +113,6 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi | |||
101 | goto error_ioremap; | 113 | goto error_ioremap; |
102 | } | 114 | } |
103 | 115 | ||
104 | result = ibmasm_init_remote_queue(sp); | ||
105 | if (result) { | ||
106 | dev_err(sp->dev, "Failed to initialize remote queue\n"); | ||
107 | goto error_remote_queue; | ||
108 | } | ||
109 | |||
110 | spin_lock_init(&sp->lock); | ||
111 | INIT_LIST_HEAD(&sp->command_queue); | ||
112 | |||
113 | result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp); | 116 | result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp); |
114 | if (result) { | 117 | if (result) { |
115 | dev_err(sp->dev, "Failed to register interrupt handler\n"); | 118 | dev_err(sp->dev, "Failed to register interrupt handler\n"); |
@@ -117,7 +120,12 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi | |||
117 | } | 120 | } |
118 | 121 | ||
119 | enable_sp_interrupts(sp->base_address); | 122 | enable_sp_interrupts(sp->base_address); |
120 | disable_mouse_interrupts(sp); | 123 | |
124 | result = ibmasm_init_remote_input_dev(sp); | ||
125 | if (result) { | ||
126 | dev_err(sp->dev, "Failed to initialize remote queue\n"); | ||
127 | goto error_send_message; | ||
128 | } | ||
121 | 129 | ||
122 | result = ibmasm_send_driver_vpd(sp); | 130 | result = ibmasm_send_driver_vpd(sp); |
123 | if (result) { | 131 | if (result) { |
@@ -133,30 +141,25 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi | |||
133 | 141 | ||
134 | ibmasm_register_uart(sp); | 142 | ibmasm_register_uart(sp); |
135 | 143 | ||
136 | dev_printk(KERN_DEBUG, &pdev->dev, "WARNING: This software may not be supported or function\n"); | ||
137 | dev_printk(KERN_DEBUG, &pdev->dev, "correctly on your IBM server. Please consult the IBM\n"); | ||
138 | dev_printk(KERN_DEBUG, &pdev->dev, "ServerProven website\n"); | ||
139 | dev_printk(KERN_DEBUG, &pdev->dev, "http://www.pc.ibm.com/ww/eserver/xseries/serverproven\n"); | ||
140 | dev_printk(KERN_DEBUG, &pdev->dev, "for information on the specific driver level and support\n"); | ||
141 | dev_printk(KERN_DEBUG, &pdev->dev, "statement for your IBM server.\n"); | ||
142 | |||
143 | return 0; | 144 | return 0; |
144 | 145 | ||
145 | error_send_message: | 146 | error_send_message: |
146 | disable_sp_interrupts(sp->base_address); | 147 | disable_sp_interrupts(sp->base_address); |
148 | ibmasm_free_remote_input_dev(sp); | ||
147 | free_irq(sp->irq, (void *)sp); | 149 | free_irq(sp->irq, (void *)sp); |
148 | error_request_irq: | 150 | error_request_irq: |
149 | ibmasm_free_remote_queue(sp); | ||
150 | error_remote_queue: | ||
151 | iounmap(sp->base_address); | 151 | iounmap(sp->base_address); |
152 | error_ioremap: | 152 | error_ioremap: |
153 | ibmasm_heartbeat_exit(sp); | 153 | ibmasm_heartbeat_exit(sp); |
154 | error_heartbeat: | 154 | error_heartbeat: |
155 | ibmasm_event_buffer_exit(sp); | 155 | ibmasm_event_buffer_exit(sp); |
156 | error_eventbuffer: | 156 | error_eventbuffer: |
157 | pci_set_drvdata(pdev, NULL); | ||
157 | kfree(sp); | 158 | kfree(sp); |
158 | error_kmalloc: | 159 | error_kmalloc: |
159 | pci_disable_device(pdev); | 160 | pci_release_regions(pdev); |
161 | error_resources: | ||
162 | pci_disable_device(pdev); | ||
160 | 163 | ||
161 | return result; | 164 | return result; |
162 | } | 165 | } |
@@ -165,16 +168,24 @@ static void __devexit ibmasm_remove_one(struct pci_dev *pdev) | |||
165 | { | 168 | { |
166 | struct service_processor *sp = (struct service_processor *)pci_get_drvdata(pdev); | 169 | struct service_processor *sp = (struct service_processor *)pci_get_drvdata(pdev); |
167 | 170 | ||
171 | dbg("Unregistering UART\n"); | ||
168 | ibmasm_unregister_uart(sp); | 172 | ibmasm_unregister_uart(sp); |
169 | ibmasm_send_os_state(sp, SYSTEM_STATE_OS_DOWN); | 173 | dbg("Sending OS down message\n"); |
174 | if (ibmasm_send_os_state(sp, SYSTEM_STATE_OS_DOWN)) | ||
175 | err("failed to get repsonse to 'Send OS State' command\n"); | ||
176 | dbg("Disabling heartbeats\n"); | ||
177 | ibmasm_heartbeat_exit(sp); | ||
178 | dbg("Disabling interrupts\n"); | ||
170 | disable_sp_interrupts(sp->base_address); | 179 | disable_sp_interrupts(sp->base_address); |
171 | disable_mouse_interrupts(sp); | 180 | dbg("Freeing SP irq\n"); |
172 | free_irq(sp->irq, (void *)sp); | 181 | free_irq(sp->irq, (void *)sp); |
173 | ibmasm_heartbeat_exit(sp); | 182 | dbg("Cleaning up\n"); |
174 | ibmasm_free_remote_queue(sp); | 183 | ibmasm_free_remote_input_dev(sp); |
175 | iounmap(sp->base_address); | 184 | iounmap(sp->base_address); |
176 | ibmasm_event_buffer_exit(sp); | 185 | ibmasm_event_buffer_exit(sp); |
186 | pci_set_drvdata(pdev, NULL); | ||
177 | kfree(sp); | 187 | kfree(sp); |
188 | pci_release_regions(pdev); | ||
178 | pci_disable_device(pdev); | 189 | pci_disable_device(pdev); |
179 | } | 190 | } |
180 | 191 | ||
diff --git a/drivers/misc/ibmasm/remote.c b/drivers/misc/ibmasm/remote.c index 520c3f10c271..d3c48d23ee51 100644 --- a/drivers/misc/ibmasm/remote.c +++ b/drivers/misc/ibmasm/remote.c | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | /* | 1 | /* |
3 | * IBM ASM Service Processor Device Driver | 2 | * IBM ASM Service Processor Device Driver |
4 | * | 3 | * |
@@ -18,135 +17,256 @@ | |||
18 | * | 17 | * |
19 | * Copyright (C) IBM Corporation, 2004 | 18 | * Copyright (C) IBM Corporation, 2004 |
20 | * | 19 | * |
21 | * Author: Max Asböck <amax@us.ibm.com> | 20 | * Authors: Max Asböck <amax@us.ibm.com> |
21 | * Vernon Mauery <vernux@us.ibm.com> | ||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | /* Remote mouse and keyboard event handling functions */ | 25 | /* Remote mouse and keyboard event handling functions */ |
26 | 26 | ||
27 | #include <linux/pci.h> | ||
27 | #include "ibmasm.h" | 28 | #include "ibmasm.h" |
28 | #include "remote.h" | 29 | #include "remote.h" |
29 | 30 | ||
30 | int ibmasm_init_remote_queue(struct service_processor *sp) | 31 | static int xmax = 1600; |
31 | { | 32 | static int ymax = 1200; |
32 | struct remote_queue *q = &sp->remote_queue; | ||
33 | |||
34 | disable_mouse_interrupts(sp); | ||
35 | 33 | ||
36 | q->open = 0; | ||
37 | q->size = 0; | ||
38 | 34 | ||
39 | q->start = kmalloc(DRIVER_REMOTE_QUEUE_SIZE * sizeof(struct remote_event), GFP_KERNEL); | 35 | static unsigned short xlate_high[XLATE_SIZE] = { |
40 | if (q->start == 0) | 36 | [KEY_SYM_ENTER & 0xff] = KEY_ENTER, |
41 | return -ENOMEM; | 37 | [KEY_SYM_KPSLASH & 0xff] = KEY_KPSLASH, |
38 | [KEY_SYM_KPSTAR & 0xff] = KEY_KPASTERISK, | ||
39 | [KEY_SYM_KPMINUS & 0xff] = KEY_KPMINUS, | ||
40 | [KEY_SYM_KPDOT & 0xff] = KEY_KPDOT, | ||
41 | [KEY_SYM_KPPLUS & 0xff] = KEY_KPPLUS, | ||
42 | [KEY_SYM_KP0 & 0xff] = KEY_KP0, | ||
43 | [KEY_SYM_KP1 & 0xff] = KEY_KP1, | ||
44 | [KEY_SYM_KP2 & 0xff] = KEY_KP2, [KEY_SYM_KPDOWN & 0xff] = KEY_KP2, | ||
45 | [KEY_SYM_KP3 & 0xff] = KEY_KP3, | ||
46 | [KEY_SYM_KP4 & 0xff] = KEY_KP4, [KEY_SYM_KPLEFT & 0xff] = KEY_KP4, | ||
47 | [KEY_SYM_KP5 & 0xff] = KEY_KP5, | ||
48 | [KEY_SYM_KP6 & 0xff] = KEY_KP6, [KEY_SYM_KPRIGHT & 0xff] = KEY_KP6, | ||
49 | [KEY_SYM_KP7 & 0xff] = KEY_KP7, | ||
50 | [KEY_SYM_KP8 & 0xff] = KEY_KP8, [KEY_SYM_KPUP & 0xff] = KEY_KP8, | ||
51 | [KEY_SYM_KP9 & 0xff] = KEY_KP9, | ||
52 | [KEY_SYM_BK_SPC & 0xff] = KEY_BACKSPACE, | ||
53 | [KEY_SYM_TAB & 0xff] = KEY_TAB, | ||
54 | [KEY_SYM_CTRL & 0xff] = KEY_LEFTCTRL, | ||
55 | [KEY_SYM_ALT & 0xff] = KEY_LEFTALT, | ||
56 | [KEY_SYM_INSERT & 0xff] = KEY_INSERT, | ||
57 | [KEY_SYM_DELETE & 0xff] = KEY_DELETE, | ||
58 | [KEY_SYM_SHIFT & 0xff] = KEY_LEFTSHIFT, | ||
59 | [KEY_SYM_UARROW & 0xff] = KEY_UP, | ||
60 | [KEY_SYM_DARROW & 0xff] = KEY_DOWN, | ||
61 | [KEY_SYM_LARROW & 0xff] = KEY_LEFT, | ||
62 | [KEY_SYM_RARROW & 0xff] = KEY_RIGHT, | ||
63 | [KEY_SYM_ESCAPE & 0xff] = KEY_ESC, | ||
64 | [KEY_SYM_PAGEUP & 0xff] = KEY_PAGEUP, | ||
65 | [KEY_SYM_PAGEDOWN & 0xff] = KEY_PAGEDOWN, | ||
66 | [KEY_SYM_HOME & 0xff] = KEY_HOME, | ||
67 | [KEY_SYM_END & 0xff] = KEY_END, | ||
68 | [KEY_SYM_F1 & 0xff] = KEY_F1, | ||
69 | [KEY_SYM_F2 & 0xff] = KEY_F2, | ||
70 | [KEY_SYM_F3 & 0xff] = KEY_F3, | ||
71 | [KEY_SYM_F4 & 0xff] = KEY_F4, | ||
72 | [KEY_SYM_F5 & 0xff] = KEY_F5, | ||
73 | [KEY_SYM_F6 & 0xff] = KEY_F6, | ||
74 | [KEY_SYM_F7 & 0xff] = KEY_F7, | ||
75 | [KEY_SYM_F8 & 0xff] = KEY_F8, | ||
76 | [KEY_SYM_F9 & 0xff] = KEY_F9, | ||
77 | [KEY_SYM_F10 & 0xff] = KEY_F10, | ||
78 | [KEY_SYM_F11 & 0xff] = KEY_F11, | ||
79 | [KEY_SYM_F12 & 0xff] = KEY_F12, | ||
80 | [KEY_SYM_CAP_LOCK & 0xff] = KEY_CAPSLOCK, | ||
81 | [KEY_SYM_NUM_LOCK & 0xff] = KEY_NUMLOCK, | ||
82 | [KEY_SYM_SCR_LOCK & 0xff] = KEY_SCROLLLOCK, | ||
83 | }; | ||
84 | static unsigned short xlate[XLATE_SIZE] = { | ||
85 | [NO_KEYCODE] = KEY_RESERVED, | ||
86 | [KEY_SYM_SPACE] = KEY_SPACE, | ||
87 | [KEY_SYM_TILDE] = KEY_GRAVE, [KEY_SYM_BKTIC] = KEY_GRAVE, | ||
88 | [KEY_SYM_ONE] = KEY_1, [KEY_SYM_BANG] = KEY_1, | ||
89 | [KEY_SYM_TWO] = KEY_2, [KEY_SYM_AT] = KEY_2, | ||
90 | [KEY_SYM_THREE] = KEY_3, [KEY_SYM_POUND] = KEY_3, | ||
91 | [KEY_SYM_FOUR] = KEY_4, [KEY_SYM_DOLLAR] = KEY_4, | ||
92 | [KEY_SYM_FIVE] = KEY_5, [KEY_SYM_PERCENT] = KEY_5, | ||
93 | [KEY_SYM_SIX] = KEY_6, [KEY_SYM_CARAT] = KEY_6, | ||
94 | [KEY_SYM_SEVEN] = KEY_7, [KEY_SYM_AMPER] = KEY_7, | ||
95 | [KEY_SYM_EIGHT] = KEY_8, [KEY_SYM_STAR] = KEY_8, | ||
96 | [KEY_SYM_NINE] = KEY_9, [KEY_SYM_LPAREN] = KEY_9, | ||
97 | [KEY_SYM_ZERO] = KEY_0, [KEY_SYM_RPAREN] = KEY_0, | ||
98 | [KEY_SYM_MINUS] = KEY_MINUS, [KEY_SYM_USCORE] = KEY_MINUS, | ||
99 | [KEY_SYM_EQUAL] = KEY_EQUAL, [KEY_SYM_PLUS] = KEY_EQUAL, | ||
100 | [KEY_SYM_LBRKT] = KEY_LEFTBRACE, [KEY_SYM_LCURLY] = KEY_LEFTBRACE, | ||
101 | [KEY_SYM_RBRKT] = KEY_RIGHTBRACE, [KEY_SYM_RCURLY] = KEY_RIGHTBRACE, | ||
102 | [KEY_SYM_SLASH] = KEY_BACKSLASH, [KEY_SYM_PIPE] = KEY_BACKSLASH, | ||
103 | [KEY_SYM_TIC] = KEY_APOSTROPHE, [KEY_SYM_QUOTE] = KEY_APOSTROPHE, | ||
104 | [KEY_SYM_SEMIC] = KEY_SEMICOLON, [KEY_SYM_COLON] = KEY_SEMICOLON, | ||
105 | [KEY_SYM_COMMA] = KEY_COMMA, [KEY_SYM_LT] = KEY_COMMA, | ||
106 | [KEY_SYM_PERIOD] = KEY_DOT, [KEY_SYM_GT] = KEY_DOT, | ||
107 | [KEY_SYM_BSLASH] = KEY_SLASH, [KEY_SYM_QMARK] = KEY_SLASH, | ||
108 | [KEY_SYM_A] = KEY_A, [KEY_SYM_a] = KEY_A, | ||
109 | [KEY_SYM_B] = KEY_B, [KEY_SYM_b] = KEY_B, | ||
110 | [KEY_SYM_C] = KEY_C, [KEY_SYM_c] = KEY_C, | ||
111 | [KEY_SYM_D] = KEY_D, [KEY_SYM_d] = KEY_D, | ||
112 | [KEY_SYM_E] = KEY_E, [KEY_SYM_e] = KEY_E, | ||
113 | [KEY_SYM_F] = KEY_F, [KEY_SYM_f] = KEY_F, | ||
114 | [KEY_SYM_G] = KEY_G, [KEY_SYM_g] = KEY_G, | ||
115 | [KEY_SYM_H] = KEY_H, [KEY_SYM_h] = KEY_H, | ||
116 | [KEY_SYM_I] = KEY_I, [KEY_SYM_i] = KEY_I, | ||
117 | [KEY_SYM_J] = KEY_J, [KEY_SYM_j] = KEY_J, | ||
118 | [KEY_SYM_K] = KEY_K, [KEY_SYM_k] = KEY_K, | ||
119 | [KEY_SYM_L] = KEY_L, [KEY_SYM_l] = KEY_L, | ||
120 | [KEY_SYM_M] = KEY_M, [KEY_SYM_m] = KEY_M, | ||
121 | [KEY_SYM_N] = KEY_N, [KEY_SYM_n] = KEY_N, | ||
122 | [KEY_SYM_O] = KEY_O, [KEY_SYM_o] = KEY_O, | ||
123 | [KEY_SYM_P] = KEY_P, [KEY_SYM_p] = KEY_P, | ||
124 | [KEY_SYM_Q] = KEY_Q, [KEY_SYM_q] = KEY_Q, | ||
125 | [KEY_SYM_R] = KEY_R, [KEY_SYM_r] = KEY_R, | ||
126 | [KEY_SYM_S] = KEY_S, [KEY_SYM_s] = KEY_S, | ||
127 | [KEY_SYM_T] = KEY_T, [KEY_SYM_t] = KEY_T, | ||
128 | [KEY_SYM_U] = KEY_U, [KEY_SYM_u] = KEY_U, | ||
129 | [KEY_SYM_V] = KEY_V, [KEY_SYM_v] = KEY_V, | ||
130 | [KEY_SYM_W] = KEY_W, [KEY_SYM_w] = KEY_W, | ||
131 | [KEY_SYM_X] = KEY_X, [KEY_SYM_x] = KEY_X, | ||
132 | [KEY_SYM_Y] = KEY_Y, [KEY_SYM_y] = KEY_Y, | ||
133 | [KEY_SYM_Z] = KEY_Z, [KEY_SYM_z] = KEY_Z, | ||
134 | }; | ||
42 | 135 | ||
43 | q->end = q->start + DRIVER_REMOTE_QUEUE_SIZE; | 136 | static char remote_mouse_name[] = "ibmasm RSA I remote mouse"; |
44 | q->reader = q->start; | 137 | static char remote_keybd_name[] = "ibmasm RSA I remote keyboard"; |
45 | q->writer = q->start; | ||
46 | q->size = DRIVER_REMOTE_QUEUE_SIZE; | ||
47 | init_waitqueue_head(&q->wait); | ||
48 | 138 | ||
49 | return 0; | 139 | static void print_input(struct remote_input *input) |
50 | } | ||
51 | |||
52 | void ibmasm_free_remote_queue(struct service_processor *sp) | ||
53 | { | 140 | { |
54 | kfree(sp->remote_queue.start); | 141 | if (input->type == INPUT_TYPE_MOUSE) { |
142 | unsigned char buttons = input->mouse_buttons; | ||
143 | dbg("remote mouse movement: (x,y)=(%d,%d)%s%s%s%s\n", | ||
144 | input->data.mouse.x, input->data.mouse.y, | ||
145 | (buttons)?" -- buttons:":"", | ||
146 | (buttons & REMOTE_BUTTON_LEFT)?"left ":"", | ||
147 | (buttons & REMOTE_BUTTON_MIDDLE)?"middle ":"", | ||
148 | (buttons & REMOTE_BUTTON_RIGHT)?"right":"" | ||
149 | ); | ||
150 | } else { | ||
151 | dbg("remote keypress (code, flag, down):" | ||
152 | "%d (0x%x) [0x%x] [0x%x]\n", | ||
153 | input->data.keyboard.key_code, | ||
154 | input->data.keyboard.key_code, | ||
155 | input->data.keyboard.key_flag, | ||
156 | input->data.keyboard.key_down | ||
157 | ); | ||
158 | } | ||
55 | } | 159 | } |
56 | 160 | ||
57 | void ibmasm_advance_reader(struct remote_queue *q, unsigned int n) | 161 | static void send_mouse_event(struct input_dev *dev, struct pt_regs *regs, |
162 | struct remote_input *input) | ||
58 | { | 163 | { |
59 | q->reader += n; | 164 | unsigned char buttons = input->mouse_buttons; |
60 | if (q->reader >= q->end) | ||
61 | q->reader -= q->size; | ||
62 | } | ||
63 | 165 | ||
64 | size_t ibmasm_events_available(struct remote_queue *q) | 166 | input_regs(dev, regs); |
65 | { | 167 | input_report_abs(dev, ABS_X, input->data.mouse.x); |
66 | ssize_t diff = q->writer - q->reader; | 168 | input_report_abs(dev, ABS_Y, input->data.mouse.y); |
67 | 169 | input_report_key(dev, BTN_LEFT, buttons & REMOTE_BUTTON_LEFT); | |
68 | return (diff >= 0) ? diff : q->end - q->reader; | 170 | input_report_key(dev, BTN_MIDDLE, buttons & REMOTE_BUTTON_MIDDLE); |
171 | input_report_key(dev, BTN_RIGHT, buttons & REMOTE_BUTTON_RIGHT); | ||
172 | input_sync(dev); | ||
69 | } | 173 | } |
70 | |||
71 | 174 | ||
72 | static int space_free(struct remote_queue *q) | 175 | static void send_keyboard_event(struct input_dev *dev, struct pt_regs *regs, |
176 | struct remote_input *input) | ||
73 | { | 177 | { |
74 | if (q->reader == q->writer) | 178 | unsigned int key; |
75 | return q->size - 1; | 179 | unsigned short code = input->data.keyboard.key_code; |
76 | 180 | ||
77 | return ( (q->reader + q->size - q->writer) % q->size ) - 1; | 181 | if (code & 0xff00) |
182 | key = xlate_high[code & 0xff]; | ||
183 | else | ||
184 | key = xlate[code]; | ||
185 | input_regs(dev, regs); | ||
186 | input_report_key(dev, key, (input->data.keyboard.key_down) ? 1 : 0); | ||
187 | input_sync(dev); | ||
78 | } | 188 | } |
79 | 189 | ||
80 | static void set_mouse_event(struct remote_input *input, struct mouse_event *mouse) | 190 | void ibmasm_handle_mouse_interrupt(struct service_processor *sp, |
191 | struct pt_regs *regs) | ||
81 | { | 192 | { |
82 | static char last_buttons = 0; | 193 | unsigned long reader; |
194 | unsigned long writer; | ||
195 | struct remote_input input; | ||
83 | 196 | ||
84 | mouse->x = input->data.mouse.x; | 197 | reader = get_queue_reader(sp); |
85 | mouse->y = input->data.mouse.y; | 198 | writer = get_queue_writer(sp); |
86 | 199 | ||
87 | if (input->mouse_buttons == REMOTE_MOUSE_DOUBLE_CLICK) { | 200 | while (reader != writer) { |
88 | mouse->buttons = REMOTE_MOUSE_DOUBLE_CLICK; | 201 | memcpy_fromio(&input, get_queue_entry(sp, reader), |
89 | last_buttons = 0; | 202 | sizeof(struct remote_input)); |
90 | return; | ||
91 | } | ||
92 | mouse->transitions = last_buttons ^ input->mouse_buttons; | ||
93 | mouse->buttons = input->mouse_buttons; | ||
94 | 203 | ||
95 | last_buttons = input->mouse_buttons; | 204 | print_input(&input); |
96 | } | 205 | if (input.type == INPUT_TYPE_MOUSE) { |
206 | send_mouse_event(&sp->remote->mouse_dev, regs, &input); | ||
207 | } else if (input.type == INPUT_TYPE_KEYBOARD) { | ||
208 | send_keyboard_event(&sp->remote->keybd_dev, regs, &input); | ||
209 | } else | ||
210 | break; | ||
97 | 211 | ||
98 | static void set_keyboard_event(struct remote_input *input, struct keyboard_event *keyboard) | 212 | reader = advance_queue_reader(sp, reader); |
99 | { | 213 | writer = get_queue_writer(sp); |
100 | keyboard->key_code = input->data.keyboard.key_code; | 214 | } |
101 | keyboard->key_down = input->data.keyboard.key_down; | ||
102 | } | 215 | } |
103 | 216 | ||
104 | static int add_to_driver_queue(struct remote_queue *q, struct remote_input *input) | 217 | int ibmasm_init_remote_input_dev(struct service_processor *sp) |
105 | { | 218 | { |
106 | struct remote_event *event = q->writer; | 219 | /* set up the mouse input device */ |
220 | struct ibmasm_remote *remote; | ||
221 | struct pci_dev *pdev = to_pci_dev(sp->dev); | ||
222 | int i; | ||
107 | 223 | ||
108 | if (space_free(q) < 1) { | 224 | sp->remote = remote = kmalloc(sizeof(*remote), GFP_KERNEL); |
109 | return 1; | 225 | if (!remote) |
110 | } | 226 | return -ENOMEM; |
111 | 227 | ||
112 | switch(input->type) { | 228 | memset(remote, 0, sizeof(*remote)); |
113 | case (INPUT_TYPE_MOUSE): | ||
114 | event->type = INPUT_TYPE_MOUSE; | ||
115 | set_mouse_event(input, &event->data.mouse); | ||
116 | break; | ||
117 | case (INPUT_TYPE_KEYBOARD): | ||
118 | event->type = INPUT_TYPE_KEYBOARD; | ||
119 | set_keyboard_event(input, &event->data.keyboard); | ||
120 | break; | ||
121 | default: | ||
122 | return 0; | ||
123 | } | ||
124 | event->type = input->type; | ||
125 | 229 | ||
126 | q->writer++; | 230 | remote->mouse_dev.private = remote; |
127 | if (q->writer == q->end) | 231 | init_input_dev(&remote->mouse_dev); |
128 | q->writer = q->start; | 232 | remote->mouse_dev.id.vendor = pdev->vendor; |
233 | remote->mouse_dev.id.product = pdev->device; | ||
234 | remote->mouse_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
235 | remote->mouse_dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | | ||
236 | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); | ||
237 | set_bit(BTN_TOUCH, remote->mouse_dev.keybit); | ||
238 | remote->mouse_dev.name = remote_mouse_name; | ||
239 | input_set_abs_params(&remote->mouse_dev, ABS_X, 0, xmax, 0, 0); | ||
240 | input_set_abs_params(&remote->mouse_dev, ABS_Y, 0, ymax, 0, 0); | ||
129 | 241 | ||
130 | return 0; | 242 | remote->keybd_dev.private = remote; |
131 | } | 243 | init_input_dev(&remote->keybd_dev); |
132 | 244 | remote->keybd_dev.id.vendor = pdev->vendor; | |
245 | remote->keybd_dev.id.product = pdev->device; | ||
246 | remote->keybd_dev.evbit[0] = BIT(EV_KEY); | ||
247 | remote->keybd_dev.name = remote_keybd_name; | ||
133 | 248 | ||
134 | void ibmasm_handle_mouse_interrupt(struct service_processor *sp) | 249 | for (i=0; i<XLATE_SIZE; i++) { |
135 | { | 250 | if (xlate_high[i]) |
136 | unsigned long reader; | 251 | set_bit(xlate_high[i], remote->keybd_dev.keybit); |
137 | unsigned long writer; | 252 | if (xlate[i]) |
138 | struct remote_input input; | 253 | set_bit(xlate[i], remote->keybd_dev.keybit); |
254 | } | ||
139 | 255 | ||
140 | reader = get_queue_reader(sp); | 256 | input_register_device(&remote->mouse_dev); |
141 | writer = get_queue_writer(sp); | 257 | input_register_device(&remote->keybd_dev); |
258 | enable_mouse_interrupts(sp); | ||
142 | 259 | ||
143 | while (reader != writer) { | 260 | printk(KERN_INFO "ibmasm remote responding to events on RSA card %d\n", sp->number); |
144 | memcpy(&input, (void *)get_queue_entry(sp, reader), sizeof(struct remote_input)); | ||
145 | 261 | ||
146 | if (add_to_driver_queue(&sp->remote_queue, &input)) | 262 | return 0; |
147 | break; | 263 | } |
148 | 264 | ||
149 | reader = advance_queue_reader(sp, reader); | 265 | void ibmasm_free_remote_input_dev(struct service_processor *sp) |
150 | } | 266 | { |
151 | wake_up_interruptible(&sp->remote_queue.wait); | 267 | disable_mouse_interrupts(sp); |
268 | input_unregister_device(&sp->remote->keybd_dev); | ||
269 | input_unregister_device(&sp->remote->mouse_dev); | ||
270 | kfree(sp->remote); | ||
152 | } | 271 | } |
272 | |||
diff --git a/drivers/misc/ibmasm/remote.h b/drivers/misc/ibmasm/remote.h index a8eb19f02d3f..b7076a8442d2 100644 --- a/drivers/misc/ibmasm/remote.h +++ b/drivers/misc/ibmasm/remote.h | |||
@@ -51,11 +51,13 @@ | |||
51 | 51 | ||
52 | 52 | ||
53 | /* mouse button states received from SP */ | 53 | /* mouse button states received from SP */ |
54 | #define REMOTE_MOUSE_DOUBLE_CLICK 0xF0 | 54 | #define REMOTE_DOUBLE_CLICK 0xF0 |
55 | #define REMOTE_MOUSE_BUTTON_LEFT 0x01 | 55 | #define REMOTE_BUTTON_LEFT 0x01 |
56 | #define REMOTE_MOUSE_BUTTON_MIDDLE 0x02 | 56 | #define REMOTE_BUTTON_MIDDLE 0x02 |
57 | #define REMOTE_MOUSE_BUTTON_RIGHT 0x04 | 57 | #define REMOTE_BUTTON_RIGHT 0x04 |
58 | 58 | ||
59 | /* size of keysym/keycode translation matricies */ | ||
60 | #define XLATE_SIZE 256 | ||
59 | 61 | ||
60 | struct mouse_input { | 62 | struct mouse_input { |
61 | unsigned short y; | 63 | unsigned short y; |
@@ -83,11 +85,13 @@ struct remote_input { | |||
83 | unsigned char pad3; | 85 | unsigned char pad3; |
84 | }; | 86 | }; |
85 | 87 | ||
86 | #define mouse_addr(sp) sp->base_address + CONDOR_MOUSE_DATA | 88 | #define mouse_addr(sp) (sp->base_address + CONDOR_MOUSE_DATA) |
87 | #define display_width(sp) mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESX | 89 | #define display_width(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESX) |
88 | #define display_height(sp) mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESY | 90 | #define display_height(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESY) |
89 | #define display_depth(sp) mouse_addr(sp) + CONDOR_INPUT_DISPLAY_BITS | 91 | #define display_depth(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_BITS) |
90 | #define vnc_status(sp) mouse_addr(sp) + CONDOR_OUTPUT_VNC_STATUS | 92 | #define desktop_info(sp) (mouse_addr(sp) + CONDOR_INPUT_DESKTOP_INFO) |
93 | #define vnc_status(sp) (mouse_addr(sp) + CONDOR_OUTPUT_VNC_STATUS) | ||
94 | #define isr_control(sp) (mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL) | ||
91 | 95 | ||
92 | #define mouse_interrupt_pending(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS) | 96 | #define mouse_interrupt_pending(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS) |
93 | #define clear_mouse_interrupt(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS) | 97 | #define clear_mouse_interrupt(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS) |
@@ -101,10 +105,10 @@ struct remote_input { | |||
101 | #define get_queue_reader(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_READER) | 105 | #define get_queue_reader(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_READER) |
102 | #define set_queue_reader(sp, reader) writel(reader, mouse_addr(sp) + CONDOR_MOUSE_Q_READER) | 106 | #define set_queue_reader(sp, reader) writel(reader, mouse_addr(sp) + CONDOR_MOUSE_Q_READER) |
103 | 107 | ||
104 | #define queue_begin mouse_addr(sp) + CONDOR_MOUSE_Q_BEGIN | 108 | #define queue_begin (mouse_addr(sp) + CONDOR_MOUSE_Q_BEGIN) |
105 | 109 | ||
106 | #define get_queue_entry(sp, read_index) \ | 110 | #define get_queue_entry(sp, read_index) \ |
107 | queue_begin + read_index * sizeof(struct remote_input) | 111 | ((void*)(queue_begin + read_index * sizeof(struct remote_input))) |
108 | 112 | ||
109 | static inline int advance_queue_reader(struct service_processor *sp, unsigned long reader) | 113 | static inline int advance_queue_reader(struct service_processor *sp, unsigned long reader) |
110 | { | 114 | { |
@@ -116,4 +120,151 @@ static inline int advance_queue_reader(struct service_processor *sp, unsigned lo | |||
116 | return reader; | 120 | return reader; |
117 | } | 121 | } |
118 | 122 | ||
123 | #define NO_KEYCODE 0 | ||
124 | #define KEY_SYM_BK_SPC 0xFF08 | ||
125 | #define KEY_SYM_TAB 0xFF09 | ||
126 | #define KEY_SYM_ENTER 0xFF0D | ||
127 | #define KEY_SYM_SCR_LOCK 0xFF14 | ||
128 | #define KEY_SYM_ESCAPE 0xFF1B | ||
129 | #define KEY_SYM_HOME 0xFF50 | ||
130 | #define KEY_SYM_LARROW 0xFF51 | ||
131 | #define KEY_SYM_UARROW 0xFF52 | ||
132 | #define KEY_SYM_RARROW 0xFF53 | ||
133 | #define KEY_SYM_DARROW 0xFF54 | ||
134 | #define KEY_SYM_PAGEUP 0xFF55 | ||
135 | #define KEY_SYM_PAGEDOWN 0xFF56 | ||
136 | #define KEY_SYM_END 0xFF57 | ||
137 | #define KEY_SYM_INSERT 0xFF63 | ||
138 | #define KEY_SYM_NUM_LOCK 0xFF7F | ||
139 | #define KEY_SYM_KPSTAR 0xFFAA | ||
140 | #define KEY_SYM_KPPLUS 0xFFAB | ||
141 | #define KEY_SYM_KPMINUS 0xFFAD | ||
142 | #define KEY_SYM_KPDOT 0xFFAE | ||
143 | #define KEY_SYM_KPSLASH 0xFFAF | ||
144 | #define KEY_SYM_KPRIGHT 0xFF96 | ||
145 | #define KEY_SYM_KPUP 0xFF97 | ||
146 | #define KEY_SYM_KPLEFT 0xFF98 | ||
147 | #define KEY_SYM_KPDOWN 0xFF99 | ||
148 | #define KEY_SYM_KP0 0xFFB0 | ||
149 | #define KEY_SYM_KP1 0xFFB1 | ||
150 | #define KEY_SYM_KP2 0xFFB2 | ||
151 | #define KEY_SYM_KP3 0xFFB3 | ||
152 | #define KEY_SYM_KP4 0xFFB4 | ||
153 | #define KEY_SYM_KP5 0xFFB5 | ||
154 | #define KEY_SYM_KP6 0xFFB6 | ||
155 | #define KEY_SYM_KP7 0xFFB7 | ||
156 | #define KEY_SYM_KP8 0xFFB8 | ||
157 | #define KEY_SYM_KP9 0xFFB9 | ||
158 | #define KEY_SYM_F1 0xFFBE // 1B 5B 5B 41 | ||
159 | #define KEY_SYM_F2 0xFFBF // 1B 5B 5B 42 | ||
160 | #define KEY_SYM_F3 0xFFC0 // 1B 5B 5B 43 | ||
161 | #define KEY_SYM_F4 0xFFC1 // 1B 5B 5B 44 | ||
162 | #define KEY_SYM_F5 0xFFC2 // 1B 5B 5B 45 | ||
163 | #define KEY_SYM_F6 0xFFC3 // 1B 5B 31 37 7E | ||
164 | #define KEY_SYM_F7 0xFFC4 // 1B 5B 31 38 7E | ||
165 | #define KEY_SYM_F8 0xFFC5 // 1B 5B 31 39 7E | ||
166 | #define KEY_SYM_F9 0xFFC6 // 1B 5B 32 30 7E | ||
167 | #define KEY_SYM_F10 0xFFC7 // 1B 5B 32 31 7E | ||
168 | #define KEY_SYM_F11 0xFFC8 // 1B 5B 32 33 7E | ||
169 | #define KEY_SYM_F12 0xFFC9 // 1B 5B 32 34 7E | ||
170 | #define KEY_SYM_SHIFT 0xFFE1 | ||
171 | #define KEY_SYM_CTRL 0xFFE3 | ||
172 | #define KEY_SYM_ALT 0xFFE9 | ||
173 | #define KEY_SYM_CAP_LOCK 0xFFE5 | ||
174 | #define KEY_SYM_DELETE 0xFFFF | ||
175 | #define KEY_SYM_TILDE 0x60 | ||
176 | #define KEY_SYM_BKTIC 0x7E | ||
177 | #define KEY_SYM_ONE 0x31 | ||
178 | #define KEY_SYM_BANG 0x21 | ||
179 | #define KEY_SYM_TWO 0x32 | ||
180 | #define KEY_SYM_AT 0x40 | ||
181 | #define KEY_SYM_THREE 0x33 | ||
182 | #define KEY_SYM_POUND 0x23 | ||
183 | #define KEY_SYM_FOUR 0x34 | ||
184 | #define KEY_SYM_DOLLAR 0x24 | ||
185 | #define KEY_SYM_FIVE 0x35 | ||
186 | #define KEY_SYM_PERCENT 0x25 | ||
187 | #define KEY_SYM_SIX 0x36 | ||
188 | #define KEY_SYM_CARAT 0x5E | ||
189 | #define KEY_SYM_SEVEN 0x37 | ||
190 | #define KEY_SYM_AMPER 0x26 | ||
191 | #define KEY_SYM_EIGHT 0x38 | ||
192 | #define KEY_SYM_STAR 0x2A | ||
193 | #define KEY_SYM_NINE 0x39 | ||
194 | #define KEY_SYM_LPAREN 0x28 | ||
195 | #define KEY_SYM_ZERO 0x30 | ||
196 | #define KEY_SYM_RPAREN 0x29 | ||
197 | #define KEY_SYM_MINUS 0x2D | ||
198 | #define KEY_SYM_USCORE 0x5F | ||
199 | #define KEY_SYM_EQUAL 0x2B | ||
200 | #define KEY_SYM_PLUS 0x3D | ||
201 | #define KEY_SYM_LBRKT 0x5B | ||
202 | #define KEY_SYM_LCURLY 0x7B | ||
203 | #define KEY_SYM_RBRKT 0x5D | ||
204 | #define KEY_SYM_RCURLY 0x7D | ||
205 | #define KEY_SYM_SLASH 0x5C | ||
206 | #define KEY_SYM_PIPE 0x7C | ||
207 | #define KEY_SYM_TIC 0x27 | ||
208 | #define KEY_SYM_QUOTE 0x22 | ||
209 | #define KEY_SYM_SEMIC 0x3B | ||
210 | #define KEY_SYM_COLON 0x3A | ||
211 | #define KEY_SYM_COMMA 0x2C | ||
212 | #define KEY_SYM_LT 0x3C | ||
213 | #define KEY_SYM_PERIOD 0x2E | ||
214 | #define KEY_SYM_GT 0x3E | ||
215 | #define KEY_SYM_BSLASH 0x2F | ||
216 | #define KEY_SYM_QMARK 0x3F | ||
217 | #define KEY_SYM_A 0x41 | ||
218 | #define KEY_SYM_B 0x42 | ||
219 | #define KEY_SYM_C 0x43 | ||
220 | #define KEY_SYM_D 0x44 | ||
221 | #define KEY_SYM_E 0x45 | ||
222 | #define KEY_SYM_F 0x46 | ||
223 | #define KEY_SYM_G 0x47 | ||
224 | #define KEY_SYM_H 0x48 | ||
225 | #define KEY_SYM_I 0x49 | ||
226 | #define KEY_SYM_J 0x4A | ||
227 | #define KEY_SYM_K 0x4B | ||
228 | #define KEY_SYM_L 0x4C | ||
229 | #define KEY_SYM_M 0x4D | ||
230 | #define KEY_SYM_N 0x4E | ||
231 | #define KEY_SYM_O 0x4F | ||
232 | #define KEY_SYM_P 0x50 | ||
233 | #define KEY_SYM_Q 0x51 | ||
234 | #define KEY_SYM_R 0x52 | ||
235 | #define KEY_SYM_S 0x53 | ||
236 | #define KEY_SYM_T 0x54 | ||
237 | #define KEY_SYM_U 0x55 | ||
238 | #define KEY_SYM_V 0x56 | ||
239 | #define KEY_SYM_W 0x57 | ||
240 | #define KEY_SYM_X 0x58 | ||
241 | #define KEY_SYM_Y 0x59 | ||
242 | #define KEY_SYM_Z 0x5A | ||
243 | #define KEY_SYM_a 0x61 | ||
244 | #define KEY_SYM_b 0x62 | ||
245 | #define KEY_SYM_c 0x63 | ||
246 | #define KEY_SYM_d 0x64 | ||
247 | #define KEY_SYM_e 0x65 | ||
248 | #define KEY_SYM_f 0x66 | ||
249 | #define KEY_SYM_g 0x67 | ||
250 | #define KEY_SYM_h 0x68 | ||
251 | #define KEY_SYM_i 0x69 | ||
252 | #define KEY_SYM_j 0x6A | ||
253 | #define KEY_SYM_k 0x6B | ||
254 | #define KEY_SYM_l 0x6C | ||
255 | #define KEY_SYM_m 0x6D | ||
256 | #define KEY_SYM_n 0x6E | ||
257 | #define KEY_SYM_o 0x6F | ||
258 | #define KEY_SYM_p 0x70 | ||
259 | #define KEY_SYM_q 0x71 | ||
260 | #define KEY_SYM_r 0x72 | ||
261 | #define KEY_SYM_s 0x73 | ||
262 | #define KEY_SYM_t 0x74 | ||
263 | #define KEY_SYM_u 0x75 | ||
264 | #define KEY_SYM_v 0x76 | ||
265 | #define KEY_SYM_w 0x77 | ||
266 | #define KEY_SYM_x 0x78 | ||
267 | #define KEY_SYM_y 0x79 | ||
268 | #define KEY_SYM_z 0x7A | ||
269 | #define KEY_SYM_SPACE 0x20 | ||
119 | #endif /* _IBMASM_REMOTE_H_ */ | 270 | #endif /* _IBMASM_REMOTE_H_ */ |