xref: /openbmc/linux/drivers/hid/hid-lcpower.c (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*2874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
275b07022SChris Schlund /*
375b07022SChris Schlund  *  HID driver for LC Power Model RC1000MCE
475b07022SChris Schlund  *
575b07022SChris Schlund  *  Copyright (c) 2011 Chris Schlund
675b07022SChris Schlund  *  based on hid-topseed module
775b07022SChris Schlund  */
875b07022SChris Schlund 
975b07022SChris Schlund /*
1075b07022SChris Schlund  */
1175b07022SChris Schlund 
1275b07022SChris Schlund #include <linux/device.h>
1375b07022SChris Schlund #include <linux/hid.h>
1475b07022SChris Schlund #include <linux/module.h>
1575b07022SChris Schlund 
1675b07022SChris Schlund #include "hid-ids.h"
1775b07022SChris Schlund 
1875b07022SChris Schlund #define ts_map_key_clear(c)	hid_map_usage_clear(hi, usage, bit, max, \
1975b07022SChris Schlund 					EV_KEY, (c))
ts_input_mapping(struct hid_device * hdev,struct hid_input * hi,struct hid_field * field,struct hid_usage * usage,unsigned long ** bit,int * max)2075b07022SChris Schlund static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi,
2175b07022SChris Schlund 		struct hid_field *field, struct hid_usage *usage,
2275b07022SChris Schlund 		unsigned long **bit, int *max)
2375b07022SChris Schlund {
245f4fa6afSAxel Lin 	if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR)
2575b07022SChris Schlund 		return 0;
2675b07022SChris Schlund 
2775b07022SChris Schlund 	switch (usage->hid & HID_USAGE) {
2875b07022SChris Schlund         case 0x046: ts_map_key_clear(KEY_YELLOW);         break;
2975b07022SChris Schlund         case 0x047: ts_map_key_clear(KEY_GREEN);          break;
308ef39531SChris Schlund         case 0x049: ts_map_key_clear(KEY_BLUE);           break;
318ef39531SChris Schlund         case 0x04a: ts_map_key_clear(KEY_RED);		  break;
3275b07022SChris Schlund         case 0x00d: ts_map_key_clear(KEY_HOME);           break;
3375b07022SChris Schlund         case 0x025: ts_map_key_clear(KEY_TV);             break;
3475b07022SChris Schlund         case 0x048: ts_map_key_clear(KEY_VCR);            break;
3575b07022SChris Schlund         case 0x024: ts_map_key_clear(KEY_MENU);           break;
3675b07022SChris Schlund         default:
3775b07022SChris Schlund         return 0;
3875b07022SChris Schlund 	}
3975b07022SChris Schlund 
4075b07022SChris Schlund 	return 1;
4175b07022SChris Schlund }
4275b07022SChris Schlund 
4375b07022SChris Schlund static const struct hid_device_id ts_devices[] = {
4475b07022SChris Schlund 	{ HID_USB_DEVICE( USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000) },
4575b07022SChris Schlund 	{ }
4675b07022SChris Schlund };
4775b07022SChris Schlund MODULE_DEVICE_TABLE(hid, ts_devices);
4875b07022SChris Schlund 
4975b07022SChris Schlund static struct hid_driver ts_driver = {
5075b07022SChris Schlund 	.name = "LC RC1000MCE",
5175b07022SChris Schlund 	.id_table = ts_devices,
5275b07022SChris Schlund 	.input_mapping = ts_input_mapping,
5375b07022SChris Schlund };
54f425458eSH Hartley Sweeten module_hid_driver(ts_driver);
5575b07022SChris Schlund 
5675b07022SChris Schlund MODULE_LICENSE("GPL");
57