Skip to content

Commit e1c9b9f

Browse files
author
Jiri Kosina
committed
Merge branches 'for-4.5/upstream-fixes', 'for-4.6/cmedia', 'for-4.6/i2c-hid', 'for-4.6/logitech', 'for-4.6/multitouch', 'for-4.6/penmount', 'for-4.6/sony', 'for-4.6/thingm', 'for-4.6/upstream' and 'for-4.6/wacom' into for-linus
10 parents c14022b + ad8ddc5 + 3b65428 + af2e628 + d3e69b9 + 5f66872 + 1adf904 + 1d1b564 + f9a82c2 + f620516 commit e1c9b9f

16 files changed

+1326
-603
lines changed

drivers/hid/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ config HID_PRODIKEYS
196196
multimedia keyboard, but will lack support for the musical keyboard
197197
and some additional multimedia keys.
198198

199+
config HID_CMEDIA
200+
tristate "CMedia CM6533 HID audio jack controls"
201+
depends on HID
202+
---help---
203+
Support for CMedia CM6533 HID audio jack controls.
204+
199205
config HID_CP2112
200206
tristate "Silicon Labs CP2112 HID USB-to-SMBus Bridge support"
201207
depends on USB_HID && I2C && GPIOLIB

drivers/hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ obj-$(CONFIG_HID_BELKIN) += hid-belkin.o
2929
obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o
3030
obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
3131
obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
32+
obj-$(CONFIG_HID_CMEDIA) += hid-cmedia.o
3233
obj-$(CONFIG_HID_CORSAIR) += hid-corsair.o
3334
obj-$(CONFIG_HID_CP2112) += hid-cp2112.o
3435
obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o

drivers/hid/hid-cmedia.c

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/*
2+
* HID driver for CMedia CM6533 audio jack controls
3+
*
4+
* Copyright (C) 2015 Ben Chen <[email protected]>
5+
*
6+
* This software is licensed under the terms of the GNU General Public
7+
* License version 2, as published by the Free Software Foundation, and
8+
* may be copied, distributed, and modified under those terms.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*/
15+
16+
#include <linux/device.h>
17+
#include <linux/hid.h>
18+
#include <linux/module.h>
19+
#include "hid-ids.h"
20+
21+
MODULE_AUTHOR("Ben Chen");
22+
MODULE_DESCRIPTION("CM6533 HID jack controls");
23+
MODULE_LICENSE("GPL");
24+
25+
#define CM6533_JD_TYPE_COUNT 1
26+
#define CM6533_JD_RAWEV_LEN 16
27+
#define CM6533_JD_SFX_OFFSET 8
28+
29+
/*
30+
*
31+
*CM6533 audio jack HID raw events:
32+
*
33+
*Plug in:
34+
*01000600 002083xx 080008c0 10000000
35+
*about 3 seconds later...
36+
*01000a00 002083xx 08000380 10000000
37+
*01000600 002083xx 08000380 10000000
38+
*
39+
*Plug out:
40+
*01000400 002083xx 080008c0 x0000000
41+
*/
42+
43+
static const u8 ji_sfx[] = { 0x08, 0x00, 0x08, 0xc0 };
44+
static const u8 ji_in[] = { 0x01, 0x00, 0x06, 0x00 };
45+
static const u8 ji_out[] = { 0x01, 0x00, 0x04, 0x00 };
46+
47+
static int jack_switch_types[CM6533_JD_TYPE_COUNT] = {
48+
SW_HEADPHONE_INSERT,
49+
};
50+
51+
struct cmhid {
52+
struct input_dev *input_dev;
53+
struct hid_device *hid;
54+
unsigned short switch_map[CM6533_JD_TYPE_COUNT];
55+
};
56+
57+
static void hp_ev(struct hid_device *hid, struct cmhid *cm, int value)
58+
{
59+
input_report_switch(cm->input_dev, SW_HEADPHONE_INSERT, value);
60+
input_sync(cm->input_dev);
61+
}
62+
63+
static int cmhid_raw_event(struct hid_device *hid, struct hid_report *report,
64+
u8 *data, int len)
65+
{
66+
struct cmhid *cm = hid_get_drvdata(hid);
67+
68+
if (len != CM6533_JD_RAWEV_LEN)
69+
goto out;
70+
if (memcmp(data+CM6533_JD_SFX_OFFSET, ji_sfx, sizeof(ji_sfx)))
71+
goto out;
72+
73+
if (!memcmp(data, ji_out, sizeof(ji_out))) {
74+
hp_ev(hid, cm, 0);
75+
goto out;
76+
}
77+
if (!memcmp(data, ji_in, sizeof(ji_in))) {
78+
hp_ev(hid, cm, 1);
79+
goto out;
80+
}
81+
82+
out:
83+
return 0;
84+
}
85+
86+
static int cmhid_input_configured(struct hid_device *hid,
87+
struct hid_input *hidinput)
88+
{
89+
struct input_dev *input_dev = hidinput->input;
90+
struct cmhid *cm = hid_get_drvdata(hid);
91+
int i;
92+
93+
cm->input_dev = input_dev;
94+
memcpy(cm->switch_map, jack_switch_types, sizeof(cm->switch_map));
95+
input_dev->evbit[0] = BIT(EV_SW);
96+
for (i = 0; i < CM6533_JD_TYPE_COUNT; i++)
97+
input_set_capability(cm->input_dev,
98+
EV_SW, jack_switch_types[i]);
99+
return 0;
100+
}
101+
102+
static int cmhid_input_mapping(struct hid_device *hid,
103+
struct hid_input *hi, struct hid_field *field,
104+
struct hid_usage *usage, unsigned long **bit, int *max)
105+
{
106+
return -1;
107+
}
108+
109+
static int cmhid_probe(struct hid_device *hid, const struct hid_device_id *id)
110+
{
111+
int ret;
112+
struct cmhid *cm;
113+
114+
cm = kzalloc(sizeof(struct cmhid), GFP_KERNEL);
115+
if (!cm) {
116+
ret = -ENOMEM;
117+
goto allocfail;
118+
}
119+
120+
cm->hid = hid;
121+
122+
hid->quirks |= HID_QUIRK_HIDINPUT_FORCE;
123+
hid_set_drvdata(hid, cm);
124+
125+
ret = hid_parse(hid);
126+
if (ret) {
127+
hid_err(hid, "parse failed\n");
128+
goto fail;
129+
}
130+
131+
ret = hid_hw_start(hid, HID_CONNECT_DEFAULT | HID_CONNECT_HIDDEV_FORCE);
132+
if (ret) {
133+
hid_err(hid, "hw start failed\n");
134+
goto fail;
135+
}
136+
137+
return 0;
138+
fail:
139+
kfree(cm);
140+
allocfail:
141+
return ret;
142+
}
143+
144+
static void cmhid_remove(struct hid_device *hid)
145+
{
146+
struct cmhid *cm = hid_get_drvdata(hid);
147+
148+
hid_hw_stop(hid);
149+
kfree(cm);
150+
}
151+
152+
static const struct hid_device_id cmhid_devices[] = {
153+
{ HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM6533) },
154+
{ }
155+
};
156+
MODULE_DEVICE_TABLE(hid, cmhid_devices);
157+
158+
static struct hid_driver cmhid_driver = {
159+
.name = "cm6533_jd",
160+
.id_table = cmhid_devices,
161+
.raw_event = cmhid_raw_event,
162+
.input_configured = cmhid_input_configured,
163+
.probe = cmhid_probe,
164+
.remove = cmhid_remove,
165+
.input_mapping = cmhid_input_mapping,
166+
};
167+
module_hid_driver(cmhid_driver);
168+

drivers/hid/hid-core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
19651965
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) },
19661966
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) },
19671967
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) },
1968+
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_KEYBOARD) },
19681969
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
19691970
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
19701971
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K_JP) },
@@ -2049,6 +2050,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
20492050
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
20502051
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
20512052
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE) },
2053+
{ HID_USB_DEVICE(USB_VENDOR_ID_SINO_LITE, USB_DEVICE_ID_SINO_LITE_CONTROLLER) },
20522054
{ HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) },
20532055
{ HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
20542056
{ HID_USB_DEVICE(USB_VENDOR_ID_THINGM, USB_DEVICE_ID_BLINK1) },
@@ -2097,6 +2099,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
20972099
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) },
20982100
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE2) },
20992101
{ HID_USB_DEVICE(USB_VENDOR_ID_RAZER, USB_DEVICE_ID_RAZER_BLADE_14) },
2102+
{ HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM6533) },
21002103
{ }
21012104
};
21022105

drivers/hid/hid-dr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static inline int drff_init(struct hid_device *hid)
151151
* descriptor. In any case, it's a wonder it works on Windows.
152152
*
153153
* Usage Page (Desktop), ; Generic desktop controls (01h)
154-
* Usage (Joystik), ; Joystik (04h, application collection)
154+
* Usage (Joystick), ; Joystick (04h, application collection)
155155
* Collection (Application),
156156
* Collection (Logical),
157157
* Report Size (8),
@@ -207,7 +207,7 @@ static inline int drff_init(struct hid_device *hid)
207207
/* Fixed report descriptor for PID 0x011 joystick */
208208
static __u8 pid0011_rdesc_fixed[] = {
209209
0x05, 0x01, /* Usage Page (Desktop), */
210-
0x09, 0x04, /* Usage (Joystik), */
210+
0x09, 0x04, /* Usage (Joystick), */
211211
0xA1, 0x01, /* Collection (Application), */
212212
0xA1, 0x02, /* Collection (Logical), */
213213
0x14, /* Logical Minimum (0), */

drivers/hid/hid-ids.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249

250250
#define USB_VENDOR_ID_CMEDIA 0x0d8c
251251
#define USB_DEVICE_ID_CM109 0x000e
252+
#define USB_DEVICE_ID_CM6533 0x0022
252253

253254
#define USB_VENDOR_ID_CODEMERCS 0x07c0
254255
#define USB_DEVICE_ID_CODEMERCS_IOW_FIRST 0x1500
@@ -683,6 +684,7 @@
683684
#define USB_DEVICE_ID_MS_NE7K 0x071d
684685
#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K 0x0730
685686
#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c
687+
#define USB_DEVICE_ID_MS_COMFORT_KEYBOARD 0x00e3
686688
#define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799
687689
#define USB_DEVICE_ID_MS_TOUCH_COVER_2 0x07a7
688690
#define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9
@@ -877,6 +879,9 @@
877879
#define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002
878880
#define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000
879881

882+
#define USB_VENDOR_ID_SINO_LITE 0x1345
883+
#define USB_DEVICE_ID_SINO_LITE_CONTROLLER 0x3008
884+
880885
#define USB_VENDOR_ID_SOUNDGRAPH 0x15c2
881886
#define USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST 0x0034
882887
#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST 0x0046
@@ -1052,7 +1057,7 @@
10521057
#define USB_DEVICE_ID_RI_KA_WEBMAIL 0x1320 /* Webmail Notifier */
10531058

10541059
#define USB_VENDOR_ID_MULTIPLE_1781 0x1781
1055-
#define USB_DEVICE_ID_RAPHNET_4NES4SNES_OLD 0x0a8d
1060+
#define USB_DEVICE_ID_RAPHNET_4NES4SNES_OLD 0x0a9d
10561061

10571062
#define USB_VENDOR_ID_DRACAL_RAPHNET 0x289b
10581063
#define USB_DEVICE_ID_RAPHNET_2NES2SNES 0x0002

drivers/hid/hid-lg.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
*/
6262
static __u8 df_rdesc_fixed[] = {
6363
0x05, 0x01, /* Usage Page (Desktop), */
64-
0x09, 0x04, /* Usage (Joystik), */
64+
0x09, 0x04, /* Usage (Joystick), */
6565
0xA1, 0x01, /* Collection (Application), */
6666
0xA1, 0x02, /* Collection (Logical), */
6767
0x95, 0x01, /* Report Count (1), */
@@ -127,7 +127,7 @@ static __u8 df_rdesc_fixed[] = {
127127

128128
static __u8 dfp_rdesc_fixed[] = {
129129
0x05, 0x01, /* Usage Page (Desktop), */
130-
0x09, 0x04, /* Usage (Joystik), */
130+
0x09, 0x04, /* Usage (Joystick), */
131131
0xA1, 0x01, /* Collection (Application), */
132132
0xA1, 0x02, /* Collection (Logical), */
133133
0x95, 0x01, /* Report Count (1), */
@@ -175,7 +175,7 @@ static __u8 dfp_rdesc_fixed[] = {
175175

176176
static __u8 fv_rdesc_fixed[] = {
177177
0x05, 0x01, /* Usage Page (Desktop), */
178-
0x09, 0x04, /* Usage (Joystik), */
178+
0x09, 0x04, /* Usage (Joystick), */
179179
0xA1, 0x01, /* Collection (Application), */
180180
0xA1, 0x02, /* Collection (Logical), */
181181
0x95, 0x01, /* Report Count (1), */
@@ -242,7 +242,7 @@ static __u8 fv_rdesc_fixed[] = {
242242

243243
static __u8 momo_rdesc_fixed[] = {
244244
0x05, 0x01, /* Usage Page (Desktop), */
245-
0x09, 0x04, /* Usage (Joystik), */
245+
0x09, 0x04, /* Usage (Joystick), */
246246
0xA1, 0x01, /* Collection (Application), */
247247
0xA1, 0x02, /* Collection (Logical), */
248248
0x95, 0x01, /* Report Count (1), */
@@ -288,7 +288,7 @@ static __u8 momo_rdesc_fixed[] = {
288288

289289
static __u8 momo2_rdesc_fixed[] = {
290290
0x05, 0x01, /* Usage Page (Desktop), */
291-
0x09, 0x04, /* Usage (Joystik), */
291+
0x09, 0x04, /* Usage (Joystick), */
292292
0xA1, 0x01, /* Collection (Application), */
293293
0xA1, 0x02, /* Collection (Logical), */
294294
0x95, 0x01, /* Report Count (1), */

0 commit comments

Comments
 (0)