Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Jarod Wilson | 44ea35c | 2011-10-14 16:57:42 -0400 | [diff] [blame] | 2 | /* |
| 3 | * HID driver for TiVo Slide Bluetooth remote |
| 4 | * |
| 5 | * Copyright (c) 2011 Jarod Wilson <jarod@redhat.com> |
| 6 | * based on the hid-topseed driver, which is in turn, based on hid-cherry... |
| 7 | */ |
| 8 | |
| 9 | /* |
Jarod Wilson | 44ea35c | 2011-10-14 16:57:42 -0400 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <linux/device.h> |
| 13 | #include <linux/hid.h> |
| 14 | #include <linux/module.h> |
| 15 | |
| 16 | #include "hid-ids.h" |
| 17 | |
| 18 | #define HID_UP_TIVOVENDOR 0xffff0000 |
| 19 | #define tivo_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ |
| 20 | EV_KEY, (c)) |
| 21 | |
| 22 | static int tivo_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 23 | struct hid_field *field, struct hid_usage *usage, |
| 24 | unsigned long **bit, int *max) |
| 25 | { |
| 26 | switch (usage->hid & HID_USAGE_PAGE) { |
| 27 | case HID_UP_TIVOVENDOR: |
| 28 | switch (usage->hid & HID_USAGE) { |
| 29 | /* TiVo button */ |
| 30 | case 0x3d: tivo_map_key_clear(KEY_MEDIA); break; |
| 31 | /* Live TV */ |
| 32 | case 0x3e: tivo_map_key_clear(KEY_TV); break; |
| 33 | /* Red thumbs down */ |
| 34 | case 0x41: tivo_map_key_clear(KEY_KPMINUS); break; |
| 35 | /* Green thumbs up */ |
| 36 | case 0x42: tivo_map_key_clear(KEY_KPPLUS); break; |
| 37 | default: |
| 38 | return 0; |
| 39 | } |
| 40 | break; |
| 41 | case HID_UP_CONSUMER: |
| 42 | switch (usage->hid & HID_USAGE) { |
| 43 | /* Enter/Last (default mapping: KEY_LAST) */ |
| 44 | case 0x083: tivo_map_key_clear(KEY_ENTER); break; |
| 45 | /* Info (default mapping: KEY_PROPS) */ |
| 46 | case 0x209: tivo_map_key_clear(KEY_INFO); break; |
| 47 | default: |
| 48 | return 0; |
| 49 | } |
| 50 | break; |
| 51 | default: |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | /* This means we found a matching mapping here, else, look in the |
| 56 | * standard hid mappings in hid-input.c */ |
| 57 | return 1; |
| 58 | } |
| 59 | |
| 60 | static const struct hid_device_id tivo_devices[] = { |
| 61 | /* TiVo Slide Bluetooth remote, pairs with a Broadcom dongle */ |
Jiri Kosina | 2cee571 | 2012-03-30 15:26:57 +0200 | [diff] [blame] | 62 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) }, |
Jarod Wilson | 44ea35c | 2011-10-14 16:57:42 -0400 | [diff] [blame] | 63 | { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) }, |
Forest Wilkinson | 9b02864 | 2015-03-12 23:58:16 -0700 | [diff] [blame] | 64 | { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_PRO) }, |
Jarod Wilson | 44ea35c | 2011-10-14 16:57:42 -0400 | [diff] [blame] | 65 | { } |
| 66 | }; |
| 67 | MODULE_DEVICE_TABLE(hid, tivo_devices); |
| 68 | |
| 69 | static struct hid_driver tivo_driver = { |
| 70 | .name = "tivo_slide", |
| 71 | .id_table = tivo_devices, |
| 72 | .input_mapping = tivo_input_mapping, |
| 73 | }; |
H Hartley Sweeten | f425458 | 2012-12-17 15:28:26 -0700 | [diff] [blame] | 74 | module_hid_driver(tivo_driver); |
Jarod Wilson | 44ea35c | 2011-10-14 16:57:42 -0400 | [diff] [blame] | 75 | |
Jarod Wilson | 44ea35c | 2011-10-14 16:57:42 -0400 | [diff] [blame] | 76 | MODULE_LICENSE("GPL"); |
| 77 | MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>"); |