Skip to content

Commit cc6e0bb

Browse files
author
Jiri Kosina
committed
HID: Add support for Sony Vaio VGX-TP1E
The Sony Vaio VGX-TP1E multimedia PC has a wireless keyboard with a touchpad. The mouse pointer is wrongly declared as constant non-data variable, which make HID code to completely ignore all the "Pointer" usages. Fix the report descriptor before it enters the parser to contain touchpad pointer description that is correctly parsable (declaring data rather than constant). Reported-by: Stefan Hundhammer <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent eb99108 commit cc6e0bb

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

drivers/hid/hid-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,7 @@ static const struct hid_device_id hid_blacklist[] = {
12941294
{ HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
12951295
{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
12961296
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1297+
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
12971298
{ HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
12981299

12991300
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) },

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@
350350
#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
351351

352352
#define USB_VENDOR_ID_SONY 0x054c
353+
#define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b
353354
#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
354355

355356
#define USB_VENDOR_ID_SOUNDGRAPH 0x15c2

drivers/hid/hid-sony.c

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Copyright (c) 1999 Andreas Gal
55
* Copyright (c) 2000-2005 Vojtech Pavlik <[email protected]>
66
* Copyright (c) 2005 Michael Haboustak <[email protected]> for Concept2, Inc
7-
* Copyright (c) 2006-2007 Jiri Kosina
87
* Copyright (c) 2007 Paul Walmsley
98
* Copyright (c) 2008 Jiri Slaby
9+
* Copyright (c) 2006-2008 Jiri Kosina
1010
*/
1111

1212
/*
@@ -23,6 +23,26 @@
2323

2424
#include "hid-ids.h"
2525

26+
#define VAIO_RDESC_CONSTANT 0x0001
27+
28+
struct sony_sc {
29+
unsigned long quirks;
30+
};
31+
32+
/* Sony Vaio VGX has wrongly mouse pointer declared as constant */
33+
static void sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
34+
unsigned int rsize)
35+
{
36+
struct sony_sc *sc = hid_get_drvdata(hdev);
37+
38+
if ((sc->quirks & VAIO_RDESC_CONSTANT) &&
39+
rsize >= 56 && rdesc[54] == 0x81 && rdesc[55] == 0x07) {
40+
dev_info(&hdev->dev, "Fixing up Sony Vaio VGX report "
41+
"descriptor\n");
42+
rdesc[55] = 0x06;
43+
}
44+
}
45+
2646
/*
2747
* Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
2848
* to "operational". Without this, the ps3 controller will not report any
@@ -56,6 +76,17 @@ static int sony_set_operational(struct hid_device *hdev)
5676
static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
5777
{
5878
int ret;
79+
unsigned long quirks = id->driver_data;
80+
struct sony_sc *sc;
81+
82+
sc = kzalloc(sizeof(*sc), GFP_KERNEL);
83+
if (sc == NULL) {
84+
dev_err(&hdev->dev, "can't alloc apple descriptor\n");
85+
return -ENOMEM;
86+
}
87+
88+
sc->quirks = quirks;
89+
hid_set_drvdata(hdev, sc);
5990

6091
ret = hid_parse(hdev);
6192
if (ret) {
@@ -78,11 +109,20 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
78109
err_stop:
79110
hid_hw_stop(hdev);
80111
err_free:
112+
kfree(sc);
81113
return ret;
82114
}
83115

116+
static void sony_remove(struct hid_device *hdev)
117+
{
118+
hid_hw_stop(hdev);
119+
kfree(hid_get_drvdata(hdev));
120+
}
121+
84122
static const struct hid_device_id sony_devices[] = {
85123
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
124+
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
125+
.driver_data = VAIO_RDESC_CONSTANT },
86126
{ }
87127
};
88128
MODULE_DEVICE_TABLE(hid, sony_devices);
@@ -91,6 +131,8 @@ static struct hid_driver sony_driver = {
91131
.name = "sony",
92132
.id_table = sony_devices,
93133
.probe = sony_probe,
134+
.remove = sony_remove,
135+
.report_fixup = sony_report_fixup,
94136
};
95137

96138
static int sony_init(void)

0 commit comments

Comments
 (0)