Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  HID driver for TiVo Slide Bluetooth remote
0004  *
0005  *  Copyright (c) 2011 Jarod Wilson <jarod@redhat.com>
0006  *  based on the hid-topseed driver, which is in turn, based on hid-cherry...
0007  */
0008 
0009 /*
0010  */
0011 
0012 #include <linux/device.h>
0013 #include <linux/hid.h>
0014 #include <linux/module.h>
0015 
0016 #include "hid-ids.h"
0017 
0018 #define HID_UP_TIVOVENDOR   0xffff0000
0019 #define tivo_map_key_clear(c)   hid_map_usage_clear(hi, usage, bit, max, \
0020                     EV_KEY, (c))
0021 
0022 static int tivo_input_mapping(struct hid_device *hdev, struct hid_input *hi,
0023         struct hid_field *field, struct hid_usage *usage,
0024         unsigned long **bit, int *max)
0025 {
0026     switch (usage->hid & HID_USAGE_PAGE) {
0027     case HID_UP_TIVOVENDOR:
0028         switch (usage->hid & HID_USAGE) {
0029         /* TiVo button */
0030         case 0x3d: tivo_map_key_clear(KEY_MEDIA);   break;
0031         /* Live TV */
0032         case 0x3e: tivo_map_key_clear(KEY_TV);      break;
0033         /* Red thumbs down */
0034         case 0x41: tivo_map_key_clear(KEY_KPMINUS); break;
0035         /* Green thumbs up */
0036         case 0x42: tivo_map_key_clear(KEY_KPPLUS);  break;
0037         default:
0038             return 0;
0039         }
0040         break;
0041     case HID_UP_CONSUMER:
0042         switch (usage->hid & HID_USAGE) {
0043         /* Enter/Last (default mapping: KEY_LAST) */
0044         case 0x083: tivo_map_key_clear(KEY_ENTER);  break;
0045         /* Info (default mapping: KEY_PROPS) */
0046         case 0x209: tivo_map_key_clear(KEY_INFO);   break;
0047         default:
0048             return 0;
0049         }
0050         break;
0051     default:
0052         return 0;
0053     }
0054 
0055     /* This means we found a matching mapping here, else, look in the
0056      * standard hid mappings in hid-input.c */
0057     return 1;
0058 }
0059 
0060 static const struct hid_device_id tivo_devices[] = {
0061     /* TiVo Slide Bluetooth remote, pairs with a Broadcom dongle */
0062     { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) },
0063     { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) },
0064     { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_PRO) },
0065     { }
0066 };
0067 MODULE_DEVICE_TABLE(hid, tivo_devices);
0068 
0069 static struct hid_driver tivo_driver = {
0070     .name = "tivo_slide",
0071     .id_table = tivo_devices,
0072     .input_mapping = tivo_input_mapping,
0073 };
0074 module_hid_driver(tivo_driver);
0075 
0076 MODULE_LICENSE("GPL");
0077 MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");