1fcfacfd3SJiri Slaby /* 2fcfacfd3SJiri Slaby * HID driver for some chicony "special" devices 3fcfacfd3SJiri Slaby * 4fcfacfd3SJiri Slaby * Copyright (c) 1999 Andreas Gal 5fcfacfd3SJiri Slaby * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> 6fcfacfd3SJiri Slaby * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc 7fcfacfd3SJiri Slaby * Copyright (c) 2006-2007 Jiri Kosina 8fcfacfd3SJiri Slaby * Copyright (c) 2007 Paul Walmsley 9fcfacfd3SJiri Slaby * Copyright (c) 2008 Jiri Slaby 10fcfacfd3SJiri Slaby */ 11fcfacfd3SJiri Slaby 12fcfacfd3SJiri Slaby /* 13fcfacfd3SJiri Slaby * This program is free software; you can redistribute it and/or modify it 14fcfacfd3SJiri Slaby * under the terms of the GNU General Public License as published by the Free 15fcfacfd3SJiri Slaby * Software Foundation; either version 2 of the License, or (at your option) 16fcfacfd3SJiri Slaby * any later version. 17fcfacfd3SJiri Slaby */ 18fcfacfd3SJiri Slaby 19fcfacfd3SJiri Slaby #include <linux/device.h> 20fcfacfd3SJiri Slaby #include <linux/input.h> 21fcfacfd3SJiri Slaby #include <linux/hid.h> 22fcfacfd3SJiri Slaby #include <linux/module.h> 23fcfacfd3SJiri Slaby 24fcfacfd3SJiri Slaby #include "hid-ids.h" 25fcfacfd3SJiri Slaby 26fcfacfd3SJiri Slaby #define ch_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ 27fcfacfd3SJiri Slaby EV_KEY, (c)) 28fcfacfd3SJiri Slaby static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi, 29fcfacfd3SJiri Slaby struct hid_field *field, struct hid_usage *usage, 30fcfacfd3SJiri Slaby unsigned long **bit, int *max) 31fcfacfd3SJiri Slaby { 32fcfacfd3SJiri Slaby if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR) 33fcfacfd3SJiri Slaby return 0; 34fcfacfd3SJiri Slaby 35fcfacfd3SJiri Slaby set_bit(EV_REP, hi->input->evbit); 36fcfacfd3SJiri Slaby switch (usage->hid & HID_USAGE) { 37fcfacfd3SJiri Slaby case 0xff01: ch_map_key_clear(BTN_1); break; 38fcfacfd3SJiri Slaby case 0xff02: ch_map_key_clear(BTN_2); break; 39fcfacfd3SJiri Slaby case 0xff03: ch_map_key_clear(BTN_3); break; 40fcfacfd3SJiri Slaby case 0xff04: ch_map_key_clear(BTN_4); break; 41fcfacfd3SJiri Slaby case 0xff05: ch_map_key_clear(BTN_5); break; 42fcfacfd3SJiri Slaby case 0xff06: ch_map_key_clear(BTN_6); break; 43fcfacfd3SJiri Slaby case 0xff07: ch_map_key_clear(BTN_7); break; 44fcfacfd3SJiri Slaby case 0xff08: ch_map_key_clear(BTN_8); break; 45fcfacfd3SJiri Slaby case 0xff09: ch_map_key_clear(BTN_9); break; 46fcfacfd3SJiri Slaby case 0xff0a: ch_map_key_clear(BTN_A); break; 47fcfacfd3SJiri Slaby case 0xff0b: ch_map_key_clear(BTN_B); break; 483596bb92SKeng-Yu Lin case 0x00f1: ch_map_key_clear(KEY_WLAN); break; 493596bb92SKeng-Yu Lin case 0x00f2: ch_map_key_clear(KEY_BRIGHTNESSDOWN); break; 503596bb92SKeng-Yu Lin case 0x00f3: ch_map_key_clear(KEY_BRIGHTNESSUP); break; 513596bb92SKeng-Yu Lin case 0x00f4: ch_map_key_clear(KEY_DISPLAY_OFF); break; 52*6c30d5a5SKeng-Yu Lin case 0x00f7: ch_map_key_clear(KEY_CAMERA); break; 53*6c30d5a5SKeng-Yu Lin case 0x00f8: ch_map_key_clear(KEY_PROG1); break; 54fcfacfd3SJiri Slaby default: 55fcfacfd3SJiri Slaby return 0; 56fcfacfd3SJiri Slaby } 57fcfacfd3SJiri Slaby return 1; 58fcfacfd3SJiri Slaby } 59fcfacfd3SJiri Slaby 60fcfacfd3SJiri Slaby static const struct hid_device_id ch_devices[] = { 61fcfacfd3SJiri Slaby { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, 623596bb92SKeng-Yu Lin { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) }, 63fcfacfd3SJiri Slaby { } 64fcfacfd3SJiri Slaby }; 65fcfacfd3SJiri Slaby MODULE_DEVICE_TABLE(hid, ch_devices); 66fcfacfd3SJiri Slaby 67fcfacfd3SJiri Slaby static struct hid_driver ch_driver = { 68fcfacfd3SJiri Slaby .name = "chicony", 69fcfacfd3SJiri Slaby .id_table = ch_devices, 70fcfacfd3SJiri Slaby .input_mapping = ch_input_mapping, 71fcfacfd3SJiri Slaby }; 72fcfacfd3SJiri Slaby 73a24f423bSPeter Huewe static int __init ch_init(void) 74fcfacfd3SJiri Slaby { 75fcfacfd3SJiri Slaby return hid_register_driver(&ch_driver); 76fcfacfd3SJiri Slaby } 77fcfacfd3SJiri Slaby 78a24f423bSPeter Huewe static void __exit ch_exit(void) 79fcfacfd3SJiri Slaby { 80fcfacfd3SJiri Slaby hid_unregister_driver(&ch_driver); 81fcfacfd3SJiri Slaby } 82fcfacfd3SJiri Slaby 83fcfacfd3SJiri Slaby module_init(ch_init); 84fcfacfd3SJiri Slaby module_exit(ch_exit); 85fcfacfd3SJiri Slaby MODULE_LICENSE("GPL"); 86