]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/hid/hid-input.c
[ARM] 4602/3: AT91: debugfs interface to view GPIO pin state
[linux-2.6-omap-h63xx.git] / drivers / hid / hid-input.c
index 36be431888fb45192fb6a3a9358c4b7dd19793a5..0b27da7d749700b4d0e2481b7c121ce9fa033aaa 100644 (file)
@@ -88,7 +88,7 @@ static const struct {
 
 /* hardware needing special handling due to colliding MSVENDOR page usages */
 #define IS_CHICONY_TACTICAL_PAD(x) (x->vendor == 0x04f2 && device->product == 0x0418)
-#define IS_MS_NEK4K(x) (x->vendor == 0x045e && x->product == 0x00db)
+#define IS_MS_KB(x) (x->vendor == 0x045e && (x->product == 0x00db || x->product == 0x00f9))
 
 #ifdef CONFIG_USB_HIDINPUT_POWERBOOK
 
@@ -297,7 +297,7 @@ static struct hid_usage *hidinput_find_key(struct hid_device *hid,
 static int hidinput_getkeycode(struct input_dev *dev, int scancode,
                                int *keycode)
 {
-       struct hid_device *hid = dev->private;
+       struct hid_device *hid = input_get_drvdata(dev);
        struct hid_usage *usage;
 
        usage = hidinput_find_key(hid, scancode, 0);
@@ -311,7 +311,7 @@ static int hidinput_getkeycode(struct input_dev *dev, int scancode,
 static int hidinput_setkeycode(struct input_dev *dev, int scancode,
                                int keycode)
 {
-       struct hid_device *hid = dev->private;
+       struct hid_device *hid = input_get_drvdata(dev);
        struct hid_usage *usage;
        int old_keycode;
 
@@ -606,6 +606,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                                case 0x0f6: map_key_clear(KEY_NEXT);            break;
                                case 0x0fa: map_key_clear(KEY_BACK);            break;
 
+                               case 0x182: map_key_clear(KEY_BOOKMARKS);       break;
                                case 0x183: map_key_clear(KEY_CONFIG);          break;
                                case 0x184: map_key_clear(KEY_WORDPROCESSOR);   break;
                                case 0x185: map_key_clear(KEY_EDITOR);          break;
@@ -622,10 +623,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                                case 0x192: map_key_clear(KEY_CALC);            break;
                                case 0x194: map_key_clear(KEY_FILE);            break;
                                case 0x196: map_key_clear(KEY_WWW);             break;
+                               case 0x19c: map_key_clear(KEY_LOGOFF);          break;
                                case 0x19e: map_key_clear(KEY_COFFEE);          break;
                                case 0x1a6: map_key_clear(KEY_HELP);            break;
                                case 0x1a7: map_key_clear(KEY_DOCUMENTS);       break;
                                case 0x1ab: map_key_clear(KEY_SPELLCHECK);      break;
+                               case 0x1b6: map_key_clear(KEY_MEDIA);           break;
+                               case 0x1b7: map_key_clear(KEY_SOUND);           break;
                                case 0x1bc: map_key_clear(KEY_MESSENGER);       break;
                                case 0x1bd: map_key_clear(KEY_INFO);            break;
                                case 0x201: map_key_clear(KEY_NEW);             break;
@@ -758,16 +762,22 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                                }
 
                        /* Microsoft Natural Ergonomic Keyboard 4000 */
-                       } else if (IS_MS_NEK4K(device)) {
+                       } else if (IS_MS_KB(device)) {
                                switch(usage->hid & HID_USAGE) {
+                                       case 0xfd06:
+                                               map_key_clear(KEY_CHAT);
+                                               break;
+                                       case 0xfd07:
+                                               map_key_clear(KEY_PHONE);
+                                               break;
                                        case 0xff05:
                                                set_bit(EV_REP, input->evbit);
-                                               map_key_clear(BTN_0);
-                                               set_bit(BTN_1, input->keybit);
-                                               set_bit(BTN_2, input->keybit);
-                                               set_bit(BTN_3, input->keybit);
-                                               set_bit(BTN_4, input->keybit);
-                                               set_bit(BTN_5, input->keybit);
+                                               map_key_clear(KEY_F13);
+                                               set_bit(KEY_F14, input->keybit);
+                                               set_bit(KEY_F15, input->keybit);
+                                               set_bit(KEY_F16, input->keybit);
+                                               set_bit(KEY_F17, input->keybit);
+                                               set_bit(KEY_F18, input->keybit);
                                        default:        goto ignore;
                                }
                        } else {
@@ -940,7 +950,7 @@ ignore:
 void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
 {
        struct input_dev *input;
-       int *quirks = &hid->quirks;
+       unsigned *quirks = &hid->quirks;
 
        if (!field->hidinput)
                return;
@@ -1029,16 +1039,16 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
                return;
        }
 
-       /* Handling MS NEK4K special buttons */
-       if (IS_MS_NEK4K(hid) && usage->hid == (HID_UP_MSVENDOR | 0xff05)) {
+       /* Handling MS keyboards special buttons */
+       if (IS_MS_KB(hid) && usage->hid == (HID_UP_MSVENDOR | 0xff05)) {
                int key = 0;
                static int last_key = 0;
                switch (value) {
-                       case 0x01: key = BTN_1; break;
-                       case 0x02: key = BTN_2; break;
-                       case 0x04: key = BTN_3; break;
-                       case 0x08: key = BTN_4; break;
-                       case 0x10: key = BTN_5; break;
+                       case 0x01: key = KEY_F14; break;
+                       case 0x02: key = KEY_F15; break;
+                       case 0x04: key = KEY_F16; break;
+                       case 0x08: key = KEY_F17; break;
+                       case 0x10: key = KEY_F18; break;
                        default: break;
                }
                if (key) {
@@ -1112,6 +1122,9 @@ int hidinput_connect(struct hid_device *hid)
        int i, j, k;
        int max_report_type = HID_OUTPUT_REPORT;
 
+       if (hid->quirks & HID_QUIRK_IGNORE_HIDINPUT)
+               return -1;
+
        INIT_LIST_HEAD(&hid->inputs);
 
        for (i = 0; i < hid->maxcollection; i++)
@@ -1139,7 +1152,7 @@ int hidinput_connect(struct hid_device *hid)
                                        kfree(hidinput);
                                        input_free_device(input_dev);
                                        err_hid("Out of memory during hid input probe");
-                                       return -1;
+                                       goto out_unwind;
                                }
 
                                input_set_drvdata(input_dev, hid);
@@ -1173,15 +1186,25 @@ int hidinput_connect(struct hid_device *hid)
                                 * UGCI) cram a lot of unrelated inputs into the
                                 * same interface. */
                                hidinput->report = report;
-                               input_register_device(hidinput->input);
+                               if (input_register_device(hidinput->input))
+                                       goto out_cleanup;
                                hidinput = NULL;
                        }
                }
 
-       if (hidinput)
-               input_register_device(hidinput->input);
+       if (hidinput && input_register_device(hidinput->input))
+               goto out_cleanup;
 
        return 0;
+
+out_cleanup:
+       input_free_device(hidinput->input);
+       kfree(hidinput);
+out_unwind:
+       /* unwind the ones we already registered */
+       hidinput_disconnect(hid);
+
+       return -1;
 }
 EXPORT_SYMBOL_GPL(hidinput_connect);