Skip to content

Commit bda3c85

Browse files
author
Jiri Kosina
committed
Merge branch 'for-5.18/sigma-micro' into for-linus
- driver for SiGma Micro keyboards (Desmond Lim)
2 parents 1fe30b4 + 9767340 commit bda3c85

File tree

4 files changed

+142
-0
lines changed

4 files changed

+142
-0
lines changed

drivers/hid/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,16 @@ config HID_SEMITEK
993993
- Woo-dy
994994
- X-Bows Nature/Knight
995995

996+
config HID_SIGMAMICRO
997+
tristate "SiGma Micro-based keyboards"
998+
depends on USB_HID
999+
help
1000+
Support for keyboards that use the SiGma Micro (a.k.a SigmaChip) IC.
1001+
1002+
Supported devices:
1003+
- Landslides KR-700
1004+
- Rapoo V500
1005+
9961006
config HID_SONY
9971007
tristate "Sony PS2/3/4 accessories"
9981008
depends on USB_HID

drivers/hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ obj-$(CONFIG_HID_RMI) += hid-rmi.o
110110
obj-$(CONFIG_HID_SAITEK) += hid-saitek.o
111111
obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
112112
obj-$(CONFIG_HID_SEMITEK) += hid-semitek.o
113+
obj-$(CONFIG_HID_SIGMAMICRO) += hid-sigmamicro.o
113114
obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o
114115
obj-$(CONFIG_HID_SONY) += hid-sony.o
115116
obj-$(CONFIG_HID_SPEEDLINK) += hid-speedlink.o

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@
11031103

11041104
#define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f
11051105
#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002
1106+
#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD2 0x0059
11061107

11071108
#define USB_VENDOR_ID_SIGMATEL 0x066F
11081109
#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780

drivers/hid/hid-sigmamicro.c

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* HID driver for SiGma Micro-based keyboards
4+
*
5+
* Copyright (c) 2016 Kinglong Mee
6+
* Copyright (c) 2021 Desmond Lim
7+
*/
8+
9+
#include <linux/device.h>
10+
#include <linux/hid.h>
11+
#include <linux/module.h>
12+
13+
#include "hid-ids.h"
14+
15+
static const __u8 sm_0059_rdesc[] = {
16+
0x05, 0x0c, /* Usage Page (Consumer Devices) 0 */
17+
0x09, 0x01, /* Usage (Consumer Control) 2 */
18+
0xa1, 0x01, /* Collection (Application) 4 */
19+
0x85, 0x01, /* Report ID (1) 6 */
20+
0x19, 0x00, /* Usage Minimum (0) 8 */
21+
0x2a, 0x3c, 0x02, /* Usage Maximum (572) 10 */
22+
0x15, 0x00, /* Logical Minimum (0) 13 */
23+
0x26, 0x3c, 0x02, /* Logical Maximum (572) 15 */
24+
0x95, 0x01, /* Report Count (1) 18 */
25+
0x75, 0x10, /* Report Size (16) 20 */
26+
0x81, 0x00, /* Input (Data,Arr,Abs) 22 */
27+
0xc0, /* End Collection 24 */
28+
0x05, 0x01, /* Usage Page (Generic Desktop) 25 */
29+
0x09, 0x80, /* Usage (System Control) 27 */
30+
0xa1, 0x01, /* Collection (Application) 29 */
31+
0x85, 0x02, /* Report ID (2) 31 */
32+
0x19, 0x81, /* Usage Minimum (129) 33 */
33+
0x29, 0x83, /* Usage Maximum (131) 35 */
34+
0x25, 0x01, /* Logical Maximum (1) 37 */
35+
0x75, 0x01, /* Report Size (1) 39 */
36+
0x95, 0x03, /* Report Count (3) 41 */
37+
0x81, 0x02, /* Input (Data,Var,Abs) 43 */
38+
0x95, 0x05, /* Report Count (5) 45 */
39+
0x81, 0x01, /* Input (Cnst,Arr,Abs) 47 */
40+
0xc0, /* End Collection 49 */
41+
0x06, 0x00, 0xff, /* Usage Page (Vendor Defined Page 1) 50 */
42+
0x09, 0x01, /* Usage (Vendor Usage 1) 53 */
43+
0xa1, 0x01, /* Collection (Application) 55 */
44+
0x85, 0x03, /* Report ID (3) 57 */
45+
0x1a, 0xf1, 0x00, /* Usage Minimum (241) 59 */
46+
0x2a, 0xf8, 0x00, /* Usage Maximum (248) 62 */
47+
0x15, 0x00, /* Logical Minimum (0) 65 */
48+
0x25, 0x01, /* Logical Maximum (1) 67 */
49+
0x75, 0x01, /* Report Size (1) 69 */
50+
0x95, 0x08, /* Report Count (8) 71 */
51+
0x81, 0x02, /* Input (Data,Var,Abs) 73 */
52+
0xc0, /* End Collection 75 */
53+
0x05, 0x01, /* Usage Page (Generic Desktop) 76 */
54+
0x09, 0x06, /* Usage (Keyboard) 78 */
55+
0xa1, 0x01, /* Collection (Application) 80 */
56+
0x85, 0x04, /* Report ID (4) 82 */
57+
0x05, 0x07, /* Usage Page (Keyboard) 84 */
58+
0x19, 0xe0, /* Usage Minimum (224) 86 */
59+
0x29, 0xe7, /* Usage Maximum (231) 88 */
60+
0x15, 0x00, /* Logical Minimum (0) 90 */
61+
0x25, 0x01, /* Logical Maximum (1) 92 */
62+
0x75, 0x01, /* Report Size (1) 94 */
63+
0x95, 0x08, /* Report Count (8) 96 */
64+
0x81, 0x00, /* Input (Data,Arr,Abs) 98 */
65+
0x95, 0x30, /* Report Count (48) 100 */
66+
0x75, 0x01, /* Report Size (1) 102 */
67+
0x15, 0x00, /* Logical Minimum (0) 104 */
68+
0x25, 0x01, /* Logical Maximum (1) 106 */
69+
0x05, 0x07, /* Usage Page (Keyboard) 108 */
70+
0x19, 0x00, /* Usage Minimum (0) 110 */
71+
0x29, 0x2f, /* Usage Maximum (47) 112 */
72+
0x81, 0x02, /* Input (Data,Var,Abs) 114 */
73+
0xc0, /* End Collection 116 */
74+
0x05, 0x01, /* Usage Page (Generic Desktop) 117 */
75+
0x09, 0x06, /* Usage (Keyboard) 119 */
76+
0xa1, 0x01, /* Collection (Application) 121 */
77+
0x85, 0x05, /* Report ID (5) 123 */
78+
0x95, 0x38, /* Report Count (56) 125 */
79+
0x75, 0x01, /* Report Size (1) 127 */
80+
0x15, 0x00, /* Logical Minimum (0) 129 */
81+
0x25, 0x01, /* Logical Maximum (1) 131 */
82+
0x05, 0x07, /* Usage Page (Keyboard) 133 */
83+
0x19, 0x30, /* Usage Minimum (48) 135 */
84+
0x29, 0x67, /* Usage Maximum (103) 137 */
85+
0x81, 0x02, /* Input (Data,Var,Abs) 139 */
86+
0xc0, /* End Collection 141 */
87+
0x05, 0x01, /* Usage Page (Generic Desktop) 142 */
88+
0x09, 0x06, /* Usage (Keyboard) 144 */
89+
0xa1, 0x01, /* Collection (Application) 146 */
90+
0x85, 0x06, /* Report ID (6) 148 */
91+
0x95, 0x38, /* Report Count (56) 150 */
92+
0x75, 0x01, /* Report Size (1) 152 */
93+
0x15, 0x00, /* Logical Minimum (0) 154 */
94+
0x25, 0x01, /* Logical Maximum (1) 156 */
95+
0x05, 0x07, /* Usage Page (Keyboard) 158 */
96+
0x19, 0x68, /* Usage Minimum (104) 160 */
97+
0x29, 0x9f, /* Usage Maximum (159) 162 */
98+
0x81, 0x02, /* Input (Data,Var,Abs) 164 */
99+
0xc0, /* End Collection 166 */
100+
};
101+
102+
static __u8 *sm_report_fixup(struct hid_device *hdev, __u8 *rdesc,
103+
unsigned int *rsize)
104+
{
105+
if (*rsize == sizeof(sm_0059_rdesc) &&
106+
!memcmp(sm_0059_rdesc, rdesc, *rsize)) {
107+
hid_info(hdev, "Fixing up SiGma Micro report descriptor\n");
108+
rdesc[99] = 0x02;
109+
}
110+
return rdesc;
111+
}
112+
113+
static const struct hid_device_id sm_devices[] = {
114+
{ HID_USB_DEVICE(USB_VENDOR_ID_SIGMA_MICRO,
115+
USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD2) },
116+
{ }
117+
};
118+
MODULE_DEVICE_TABLE(hid, sm_devices);
119+
120+
static struct hid_driver sm_driver = {
121+
.name = "sigmamicro",
122+
.id_table = sm_devices,
123+
.report_fixup = sm_report_fixup,
124+
};
125+
module_hid_driver(sm_driver);
126+
127+
MODULE_AUTHOR("Kinglong Mee <[email protected]>");
128+
MODULE_AUTHOR("Desmond Lim <[email protected]>");
129+
MODULE_DESCRIPTION("SiGma Micro HID driver");
130+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)