diff options
author | José Expósito <jose.exposito89@gmail.com> | 2022-08-15 16:29:52 +0200 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2022-08-25 10:26:31 +0200 |
commit | a092986fc095b963383b948a5c74dd1d202d21b5 (patch) | |
tree | f6bf4cd76c8b54a7ac891b28c02e7da1b5b5e530 /drivers/hid/hid-uclogic-params.c | |
parent | 86402296784f656427245edd0546cac39d410b07 (diff) | |
download | linux-a092986fc095b963383b948a5c74dd1d202d21b5.tar.bz2 |
HID: uclogic: Parse the UGEE v2 frame type
The string descriptor returned by UGEE v2 devices contains a byte
indicating the device frame type.
The values discovered so far are:
- 0: Frame with buttons, present in the XP-PEN Deco L.
- 1: Frame with buttons and dial, present in the PARBLO A610 PRO.
- 2: Frame with buttons and a mouse, shaped as a dial + touchpad.
Present in the XP-PEN Deco Pro S.
Parse the frame type and add KUnit tests.
Tested-by: Jouke Witteveen <j.witteveen@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-uclogic-params.c')
-rw-r--r-- | drivers/hid/hid-uclogic-params.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 182e6f8f027a..7845dd5fb4b1 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1064,6 +1064,7 @@ cleanup: * @str_desc_size: Size of the string descriptor. * @desc_params: Output description params list. * @desc_params_size: Size of the output description params list. + * @frame_type: Output frame type. * * Returns: * Zero, if successful. A negative errno code on error. @@ -1071,7 +1072,8 @@ cleanup: static int uclogic_params_parse_ugee_v2_desc(const __u8 *str_desc, size_t str_desc_size, s32 *desc_params, - size_t desc_params_size) + size_t desc_params_size, + enum uclogic_params_frame_type *frame_type) { s32 pen_x_lm, pen_y_lm; s32 pen_x_pm, pen_y_pm; @@ -1091,6 +1093,7 @@ static int uclogic_params_parse_ugee_v2_desc(const __u8 *str_desc, pen_x_lm = get_unaligned_le16(str_desc + 2); pen_y_lm = get_unaligned_le16(str_desc + 4); frame_num_buttons = str_desc[6]; + *frame_type = str_desc[7]; pen_pressure_lm = get_unaligned_le16(str_desc + 8); resolution = get_unaligned_le16(str_desc + 10); @@ -1176,6 +1179,7 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, __u8 *str_desc = NULL; __u8 *rdesc_pen = NULL; s32 desc_params[UCLOGIC_RDESC_PH_ID_NUM]; + enum uclogic_params_frame_type frame_type; __u8 magic_arr[] = { 0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -1219,7 +1223,8 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, rc = uclogic_params_parse_ugee_v2_desc(str_desc, str_desc_len, desc_params, - ARRAY_SIZE(desc_params)); + ARRAY_SIZE(desc_params), + &frame_type); if (rc) goto cleanup; @@ -1243,8 +1248,14 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, p.pen.subreport_list[0].id = UCLOGIC_RDESC_V1_FRAME_ID; /* Initialize the frame interface */ - rc = uclogic_params_ugee_v2_init_frame_buttons(&p, desc_params, - ARRAY_SIZE(desc_params)); + switch (frame_type) { + case UCLOGIC_PARAMS_FRAME_BUTTONS: + default: + rc = uclogic_params_ugee_v2_init_frame_buttons(&p, desc_params, + ARRAY_SIZE(desc_params)); + break; + } + if (rc) goto cleanup; |