JD Cole | 1a3f83f | 2014-10-31 17:34:42 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Plantronics USB HID Driver |
| 3 | * |
| 4 | * Copyright (c) 2014 JD Cole <jd.cole@plantronics.com> |
| 5 | * Copyright (c) 2014 Terry Junge <terry.junge@plantronics.com> |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the Free |
| 11 | * Software Foundation; either version 2 of the License, or (at your option) |
| 12 | * any later version. |
| 13 | */ |
| 14 | |
| 15 | #include "hid-ids.h" |
| 16 | |
| 17 | #include <linux/hid.h> |
| 18 | #include <linux/module.h> |
| 19 | |
| 20 | static int plantronics_input_mapping(struct hid_device *hdev, |
| 21 | struct hid_input *hi, |
| 22 | struct hid_field *field, |
| 23 | struct hid_usage *usage, |
| 24 | unsigned long **bit, int *max) |
| 25 | { |
| 26 | if (field->application == HID_CP_CONSUMERCONTROL |
| 27 | && (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) { |
| 28 | hid_dbg(hdev, "usage: %08x (appl: %08x) - defaulted\n", |
| 29 | usage->hid, field->application); |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | hid_dbg(hdev, "usage: %08x (appl: %08x) - ignored\n", |
| 34 | usage->hid, field->application); |
| 35 | |
| 36 | return -1; |
| 37 | } |
| 38 | |
| 39 | static int plantronics_probe(struct hid_device *hdev, |
| 40 | const struct hid_device_id *id) |
| 41 | { |
| 42 | int ret; |
| 43 | |
| 44 | ret = hid_parse(hdev); |
| 45 | if (ret) { |
| 46 | hid_err(hdev, "parse failed\n"); |
| 47 | goto err; |
| 48 | } |
| 49 | |
| 50 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
| 51 | if (ret) { |
| 52 | hid_err(hdev, "hw start failed\n"); |
| 53 | goto err; |
| 54 | } |
| 55 | |
| 56 | return 0; |
| 57 | err: |
| 58 | return ret; |
| 59 | } |
| 60 | |
| 61 | static const struct hid_device_id plantronics_devices[] = { |
| 62 | { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) }, |
| 63 | { } |
| 64 | }; |
| 65 | MODULE_DEVICE_TABLE(hid, plantronics_devices); |
| 66 | |
| 67 | static struct hid_driver plantronics_driver = { |
| 68 | .name = "plantronics", |
| 69 | .id_table = plantronics_devices, |
| 70 | .input_mapping = plantronics_input_mapping, |
| 71 | .probe = plantronics_probe, |
| 72 | }; |
| 73 | module_hid_driver(plantronics_driver); |
| 74 | |
| 75 | MODULE_AUTHOR("JD Cole <jd.cole@plantronics.com>"); |
| 76 | MODULE_AUTHOR("Terry Junge <terry.junge@plantronics.com>"); |
| 77 | MODULE_DESCRIPTION("Plantronics USB HID Driver"); |
| 78 | MODULE_LICENSE("GPL"); |