Skip to content

Commit 2710111

Browse files
committed
HID: uclogic: Add frame type quirk
The report descriptor used to get information about UGEE v2 devices is incorrect in the XP-PEN Deco Pro SW. It indicates that the device frame is of type UCLOGIC_PARAMS_FRAME_BUTTONS but the device has a frame of type UCLOGIC_PARAMS_FRAME_MOUSE. Here is the original report descriptor: 0x0e 0x03 0xc8 0xb3 0x34 0x65 0x08 0x00 0xff 0x1f 0xd8 0x13 0x00 0x00 ^ This byte should be 2 Add a quirk to be able to fix the reported frame type. Tested-by: Mia Kanashi <chad@redpilled.dev> Tested-by: Andreas Grosse <andig.mail@t-online.de> Signed-off-by: José Expósito <jose.exposito89@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent f6aa2f8 commit 2710111

3 files changed

Lines changed: 29 additions & 19 deletions

File tree

hid-uclogic-core.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,6 @@
2525
#include "compat.h"
2626
#include <linux/version.h>
2727

28-
/* Driver data */
29-
struct uclogic_drvdata {
30-
/* Interface parameters */
31-
struct uclogic_params params;
32-
/* Pointer to the replacement report descriptor. NULL if none. */
33-
__u8 *desc_ptr;
34-
/*
35-
* Size of the replacement report descriptor.
36-
* Only valid if desc_ptr is not NULL
37-
*/
38-
unsigned int desc_size;
39-
/* Pen input device */
40-
struct input_dev *pen_input;
41-
/* In-range timer */
42-
struct timer_list inrange_timer;
43-
/* Last rotary encoder state, or U8_MAX for none */
44-
u8 re_state;
45-
};
46-
4728
/**
4829
* uclogic_inrange_timeout - handle pen in-range state timeout.
4930
* Emulate input events normally generated when pen goes out of range for
@@ -213,6 +194,7 @@ static int uclogic_probe(struct hid_device *hdev,
213194
}
214195
timer_setup(&drvdata->inrange_timer, uclogic_inrange_timeout, 0);
215196
drvdata->re_state = U8_MAX;
197+
drvdata->quirks = id->driver_data;
216198
hid_set_drvdata(hdev, drvdata);
217199

218200
/* Initialize the device and retrieve interface parameters */

hid-uclogic-params.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,7 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
12961296
struct hid_device *hdev)
12971297
{
12981298
int rc = 0;
1299+
struct uclogic_drvdata *drvdata;
12991300
struct usb_interface *iface;
13001301
__u8 bInterfaceNumber;
13011302
const int str_desc_len = 12;
@@ -1314,6 +1315,7 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
13141315
goto cleanup;
13151316
}
13161317

1318+
drvdata = hid_get_drvdata(hdev);
13171319
iface = to_usb_interface(hdev->dev.parent);
13181320
bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber;
13191321

@@ -1380,6 +1382,9 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
13801382
p.pen.subreport_list[0].id = UCLOGIC_RDESC_V1_FRAME_ID;
13811383

13821384
/* Initialize the frame interface */
1385+
if (drvdata->quirks & UCLOGIC_MOUSE_FRAME_QUIRK)
1386+
frame_type = UCLOGIC_PARAMS_FRAME_MOUSE;
1387+
13831388
switch (frame_type) {
13841389
case UCLOGIC_PARAMS_FRAME_DIAL:
13851390
case UCLOGIC_PARAMS_FRAME_MOUSE:

hid-uclogic-params.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <linux/usb.h>
2020
#include <linux/hid.h>
2121

22+
#define UCLOGIC_MOUSE_FRAME_QUIRK BIT(0)
23+
2224
/* Types of pen in-range reporting */
2325
enum uclogic_params_pen_inrange {
2426
/* Normal reports: zero - out of proximity, one - in proximity */
@@ -215,6 +217,27 @@ struct uclogic_params {
215217
struct uclogic_params_frame frame_list[3];
216218
};
217219

220+
/* Driver data */
221+
struct uclogic_drvdata {
222+
/* Interface parameters */
223+
struct uclogic_params params;
224+
/* Pointer to the replacement report descriptor. NULL if none. */
225+
__u8 *desc_ptr;
226+
/*
227+
* Size of the replacement report descriptor.
228+
* Only valid if desc_ptr is not NULL
229+
*/
230+
unsigned int desc_size;
231+
/* Pen input device */
232+
struct input_dev *pen_input;
233+
/* In-range timer */
234+
struct timer_list inrange_timer;
235+
/* Last rotary encoder state, or U8_MAX for none */
236+
u8 re_state;
237+
/* Device quirks */
238+
unsigned long quirks;
239+
};
240+
218241
/* Initialize a tablet interface and discover its parameters */
219242
extern int uclogic_params_init(struct uclogic_params *params,
220243
struct hid_device *hdev);

0 commit comments

Comments
 (0)