aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc/keyspan_remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/misc/keyspan_remote.c')
-rw-r--r--drivers/input/misc/keyspan_remote.c119
1 files changed, 67 insertions, 52 deletions
diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c
index fd74347047dd..952938a8e991 100644
--- a/drivers/input/misc/keyspan_remote.c
+++ b/drivers/input/misc/keyspan_remote.c
@@ -16,7 +16,6 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/moduleparam.h>
20#include <linux/usb/input.h> 19#include <linux/usb/input.h>
21 20
22#define DRIVER_VERSION "v0.1" 21#define DRIVER_VERSION "v0.1"
@@ -46,53 +45,12 @@ MODULE_PARM_DESC(debug, "Enable extra debug messages and information");
46 45
47#define RECV_SIZE 8 /* The UIA-11 type have a 8 byte limit. */ 46#define RECV_SIZE 8 /* The UIA-11 type have a 8 byte limit. */
48 47
49/* table of devices that work with this driver */
50static struct usb_device_id keyspan_table[] = {
51 { USB_DEVICE(USB_KEYSPAN_VENDOR_ID, USB_KEYSPAN_PRODUCT_UIA11) },
52 { } /* Terminating entry */
53};
54
55/* Structure to store all the real stuff that a remote sends to us. */
56struct keyspan_message {
57 u16 system;
58 u8 button;
59 u8 toggle;
60};
61
62/* Structure used for all the bit testing magic needed to be done. */
63struct bit_tester {
64 u32 tester;
65 int len;
66 int pos;
67 int bits_left;
68 u8 buffer[32];
69};
70
71/* Structure to hold all of our driver specific stuff */
72struct usb_keyspan {
73 char name[128];
74 char phys[64];
75 struct usb_device* udev;
76 struct input_dev *input;
77 struct usb_interface* interface;
78 struct usb_endpoint_descriptor* in_endpoint;
79 struct urb* irq_urb;
80 int open;
81 dma_addr_t in_dma;
82 unsigned char* in_buffer;
83
84 /* variables used to parse messages from remote. */
85 struct bit_tester data;
86 int stage;
87 int toggle;
88};
89
90/* 48/*
91 * Table that maps the 31 possible keycodes to input keys. 49 * Table that maps the 31 possible keycodes to input keys.
92 * Currently there are 15 and 17 button models so RESERVED codes 50 * Currently there are 15 and 17 button models so RESERVED codes
93 * are blank areas in the mapping. 51 * are blank areas in the mapping.
94 */ 52 */
95static const int keyspan_key_table[] = { 53static const unsigned short keyspan_key_table[] = {
96 KEY_RESERVED, /* 0 is just a place holder. */ 54 KEY_RESERVED, /* 0 is just a place holder. */
97 KEY_RESERVED, 55 KEY_RESERVED,
98 KEY_STOP, 56 KEY_STOP,
@@ -127,6 +85,48 @@ static const int keyspan_key_table[] = {
127 KEY_MENU 85 KEY_MENU
128}; 86};
129 87
88/* table of devices that work with this driver */
89static struct usb_device_id keyspan_table[] = {
90 { USB_DEVICE(USB_KEYSPAN_VENDOR_ID, USB_KEYSPAN_PRODUCT_UIA11) },
91 { } /* Terminating entry */
92};
93
94/* Structure to store all the real stuff that a remote sends to us. */
95struct keyspan_message {
96 u16 system;
97 u8 button;
98 u8 toggle;
99};
100
101/* Structure used for all the bit testing magic needed to be done. */
102struct bit_tester {
103 u32 tester;
104 int len;
105 int pos;
106 int bits_left;
107 u8 buffer[32];
108};
109
110/* Structure to hold all of our driver specific stuff */
111struct usb_keyspan {
112 char name[128];
113 char phys[64];
114 unsigned short keymap[ARRAY_SIZE(keyspan_key_table)];
115 struct usb_device *udev;
116 struct input_dev *input;
117 struct usb_interface *interface;
118 struct usb_endpoint_descriptor *in_endpoint;
119 struct urb* irq_urb;
120 int open;
121 dma_addr_t in_dma;
122 unsigned char *in_buffer;
123
124 /* variables used to parse messages from remote. */
125 struct bit_tester data;
126 int stage;
127 int toggle;
128};
129
130static struct usb_driver keyspan_driver; 130static struct usb_driver keyspan_driver;
131 131
132/* 132/*
@@ -173,6 +173,15 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed)
173 return 0; 173 return 0;
174} 174}
175 175
176static void keyspan_report_button(struct usb_keyspan *remote, int button, int press)
177{
178 struct input_dev *input = remote->input;
179
180 input_event(input, EV_MSC, MSC_SCAN, button);
181 input_report_key(input, remote->keymap[button], press);
182 input_sync(input);
183}
184
176/* 185/*
177 * Routine that handles all the logic needed to parse out the message from the remote. 186 * Routine that handles all the logic needed to parse out the message from the remote.
178 */ 187 */
@@ -311,9 +320,8 @@ static void keyspan_check_data(struct usb_keyspan *remote)
311 __FUNCTION__, message.system, message.button, message.toggle); 320 __FUNCTION__, message.system, message.button, message.toggle);
312 321
313 if (message.toggle != remote->toggle) { 322 if (message.toggle != remote->toggle) {
314 input_report_key(remote->input, keyspan_key_table[message.button], 1); 323 keyspan_report_button(remote, message.button, 1);
315 input_report_key(remote->input, keyspan_key_table[message.button], 0); 324 keyspan_report_button(remote, message.button, 0);
316 input_sync(remote->input);
317 remote->toggle = message.toggle; 325 remote->toggle = message.toggle;
318 } 326 }
319 327
@@ -491,16 +499,21 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
491 499
492 usb_make_path(udev, remote->phys, sizeof(remote->phys)); 500 usb_make_path(udev, remote->phys, sizeof(remote->phys));
493 strlcat(remote->phys, "/input0", sizeof(remote->phys)); 501 strlcat(remote->phys, "/input0", sizeof(remote->phys));
502 memcpy(remote->keymap, keyspan_key_table, sizeof(remote->keymap));
494 503
495 input_dev->name = remote->name; 504 input_dev->name = remote->name;
496 input_dev->phys = remote->phys; 505 input_dev->phys = remote->phys;
497 usb_to_input_id(udev, &input_dev->id); 506 usb_to_input_id(udev, &input_dev->id);
498 input_dev->dev.parent = &interface->dev; 507 input_dev->dev.parent = &interface->dev;
508 input_dev->keycode = remote->keymap;
509 input_dev->keycodesize = sizeof(unsigned short);
510 input_dev->keycodemax = ARRAY_SIZE(remote->keymap);
499 511
500 input_dev->evbit[0] = BIT_MASK(EV_KEY); /* We will only report KEY events. */ 512 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
513 __set_bit(EV_KEY, input_dev->evbit);
501 for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++) 514 for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++)
502 if (keyspan_key_table[i] != KEY_RESERVED) 515 __set_bit(keyspan_key_table[i], input_dev->keybit);
503 set_bit(keyspan_key_table[i], input_dev->keybit); 516 __clear_bit(KEY_RESERVED, input_dev->keybit);
504 517
505 input_set_drvdata(input_dev, remote); 518 input_set_drvdata(input_dev, remote);
506 519
@@ -508,12 +521,14 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
508 input_dev->close = keyspan_close; 521 input_dev->close = keyspan_close;
509 522
510 /* 523 /*
511 * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() 524 * Initialize the URB to access the device.
525 * The urb gets sent to the device in keyspan_open()
512 */ 526 */
513 usb_fill_int_urb(remote->irq_urb, 527 usb_fill_int_urb(remote->irq_urb,
514 remote->udev, usb_rcvintpipe(remote->udev, remote->in_endpoint->bEndpointAddress), 528 remote->udev,
529 usb_rcvintpipe(remote->udev, endpoint->bEndpointAddress),
515 remote->in_buffer, RECV_SIZE, keyspan_irq_recv, remote, 530 remote->in_buffer, RECV_SIZE, keyspan_irq_recv, remote,
516 remote->in_endpoint->bInterval); 531 endpoint->bInterval);
517 remote->irq_urb->transfer_dma = remote->in_dma; 532 remote->irq_urb->transfer_dma = remote->in_dma;
518 remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 533 remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
519 534