Skip to content

Commit 118dfde

Browse files
spbnickJiri Kosina
authored andcommitted
HID: uclogic: Differentiate touch ring and touch strip
Improve support for touch strips. Signed-off-by: Nikolai Kondrashov <[email protected]> Signed-off-by: José Expósito <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent fbc08b4 commit 118dfde

File tree

3 files changed

+112
-24
lines changed

3 files changed

+112
-24
lines changed

drivers/hid/hid-uclogic-params.c

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,14 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
808808
static const char transition_ver[] = "HUION_T153_160607";
809809
char *ver_ptr = NULL;
810810
const size_t ver_len = sizeof(transition_ver) + 1;
811+
__u8 *params_ptr = NULL;
812+
size_t params_len = 0;
813+
/* Parameters string descriptor of a model with touch ring (HS610) */
814+
const __u8 touch_ring_model_params_buf[] = {
815+
0x13, 0x03, 0x70, 0xC6, 0x00, 0x06, 0x7C, 0x00,
816+
0xFF, 0x1F, 0xD8, 0x13, 0x03, 0x0D, 0x10, 0x01,
817+
0x04, 0x3C, 0x3E
818+
};
811819

812820
/* Check arguments */
813821
if (params == NULL || hdev == NULL) {
@@ -852,7 +860,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
852860
} else {
853861
/* Try to probe v2 pen parameters */
854862
rc = uclogic_params_pen_init_v2(&p.pen, &found,
855-
NULL, NULL, hdev);
863+
&params_ptr, &params_len,
864+
hdev);
856865
if (rc != 0) {
857866
hid_err(hdev,
858867
"failed probing pen v2 parameters: %d\n", rc);
@@ -872,24 +881,58 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
872881
goto cleanup;
873882
}
874883

875-
/* Create v2 frame touch ring parameters */
876-
rc = uclogic_params_frame_init_with_desc(
884+
/* Link from pen sub-report */
885+
p.pen.subreport_list[0].value = 0xe0;
886+
p.pen.subreport_list[0].id =
887+
UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID;
888+
889+
/* If this is the model with touch ring */
890+
if (params_ptr != NULL &&
891+
params_len == sizeof(touch_ring_model_params_buf) &&
892+
memcmp(params_ptr, touch_ring_model_params_buf,
893+
params_len) == 0) {
894+
/* Create touch ring parameters */
895+
rc = uclogic_params_frame_init_with_desc(
877896
&p.frame_list[1],
878897
uclogic_rdesc_v2_frame_touch_ring_arr,
879898
uclogic_rdesc_v2_frame_touch_ring_size,
880899
UCLOGIC_RDESC_V2_FRAME_TOUCH_ID);
881-
if (rc != 0) {
882-
hid_err(hdev,
883-
"failed creating v2 frame touch ring parameters: %d\n",
884-
rc);
885-
goto cleanup;
900+
if (rc != 0) {
901+
hid_err(hdev,
902+
"failed creating v2 frame touch ring parameters: %d\n",
903+
rc);
904+
goto cleanup;
905+
}
906+
p.frame_list[1].suffix = "Touch Ring";
907+
p.frame_list[1].dev_id_byte =
908+
UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE;
909+
p.frame_list[1].touch_byte = 5;
910+
p.frame_list[1].touch_max = 12;
911+
p.frame_list[1].touch_flip_at = 7;
912+
} else {
913+
/* Create touch strip parameters */
914+
rc = uclogic_params_frame_init_with_desc(
915+
&p.frame_list[1],
916+
uclogic_rdesc_v2_frame_touch_strip_arr,
917+
uclogic_rdesc_v2_frame_touch_strip_size,
918+
UCLOGIC_RDESC_V2_FRAME_TOUCH_ID);
919+
if (rc != 0) {
920+
hid_err(hdev,
921+
"failed creating v2 frame touch strip parameters: %d\n",
922+
rc);
923+
goto cleanup;
924+
}
925+
p.frame_list[1].suffix = "Touch Strip";
926+
p.frame_list[1].dev_id_byte =
927+
UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE;
928+
p.frame_list[1].touch_byte = 5;
929+
p.frame_list[1].touch_max = 8;
886930
}
887-
p.frame_list[1].suffix = "Touch Ring";
888-
p.frame_list[1].dev_id_byte =
889-
UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE;
890-
p.frame_list[1].touch_byte = 5;
891-
p.frame_list[1].touch_max = 12;
892-
p.frame_list[1].touch_flip_at = 7;
931+
932+
/* Link from pen sub-report */
933+
p.pen.subreport_list[1].value = 0xf0;
934+
p.pen.subreport_list[1].id =
935+
UCLOGIC_RDESC_V2_FRAME_TOUCH_ID;
893936

894937
/* Create v2 frame dial parameters */
895938
rc = uclogic_params_frame_init_with_desc(
@@ -908,19 +951,11 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
908951
UCLOGIC_RDESC_V2_FRAME_DIAL_DEV_ID_BYTE;
909952
p.frame_list[2].bitmap_dial_byte = 5;
910953

911-
/*
912-
* Link button and touch ring subreports from pen
913-
* reports
914-
*/
915-
p.pen.subreport_list[0].value = 0xe0;
916-
p.pen.subreport_list[0].id =
917-
UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID;
918-
p.pen.subreport_list[1].value = 0xf0;
919-
p.pen.subreport_list[1].id =
920-
UCLOGIC_RDESC_V2_FRAME_TOUCH_ID;
954+
/* Link from pen sub-report */
921955
p.pen.subreport_list[2].value = 0xf1;
922956
p.pen.subreport_list[2].id =
923957
UCLOGIC_RDESC_V2_FRAME_DIAL_ID;
958+
924959
goto output;
925960
}
926961
hid_dbg(hdev, "pen v2 parameters not found\n");
@@ -961,6 +996,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
961996
memset(&p, 0, sizeof(p));
962997
rc = 0;
963998
cleanup:
999+
kfree(params_ptr);
9641000
kfree(ver_ptr);
9651001
uclogic_params_cleanup(&p);
9661002
return rc;

drivers/hid/hid-uclogic-rdesc.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,54 @@ const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[] = {
761761
const size_t uclogic_rdesc_v2_frame_touch_ring_size =
762762
sizeof(uclogic_rdesc_v2_frame_touch_ring_arr);
763763

764+
/* Fixed report descriptor for (tweaked) v2 frame touch strip reports */
765+
const __u8 uclogic_rdesc_v2_frame_touch_strip_arr[] = {
766+
0x05, 0x01, /* Usage Page (Desktop), */
767+
0x09, 0x07, /* Usage (Keypad), */
768+
0xA1, 0x01, /* Collection (Application), */
769+
0x85, UCLOGIC_RDESC_V2_FRAME_TOUCH_ID,
770+
/* Report ID (TOUCH_ID), */
771+
0x14, /* Logical Minimum (0), */
772+
0x05, 0x0D, /* Usage Page (Digitizer), */
773+
0x09, 0x39, /* Usage (Tablet Function Keys), */
774+
0xA0, /* Collection (Physical), */
775+
0x25, 0x01, /* Logical Maximum (1), */
776+
0x75, 0x01, /* Report Size (1), */
777+
0x05, 0x09, /* Usage Page (Button), */
778+
0x09, 0x01, /* Usage (01h), */
779+
0x95, 0x01, /* Report Count (1), */
780+
0x81, 0x02, /* Input (Variable), */
781+
0x95, 0x07, /* Report Count (7), */
782+
0x81, 0x01, /* Input (Constant), */
783+
0x75, 0x08, /* Report Size (8), */
784+
0x95, 0x02, /* Report Count (2), */
785+
0x81, 0x01, /* Input (Constant), */
786+
0x05, 0x0D, /* Usage Page (Digitizer), */
787+
0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */
788+
0x26, 0xFF, 0x00, /* Logical Maximum (255), */
789+
0x95, 0x01, /* Report Count (1), */
790+
0x81, 0x02, /* Input (Variable), */
791+
0x05, 0x01, /* Usage Page (Desktop), */
792+
0x09, 0x38, /* Usage (Wheel), */
793+
0x95, 0x01, /* Report Count (1), */
794+
0x15, 0x00, /* Logical Minimum (0), */
795+
0x25, 0x07, /* Logical Maximum (7), */
796+
0x81, 0x02, /* Input (Variable), */
797+
0x09, 0x30, /* Usage (X), */
798+
0x09, 0x31, /* Usage (Y), */
799+
0x14, /* Logical Minimum (0), */
800+
0x25, 0x01, /* Logical Maximum (1), */
801+
0x75, 0x01, /* Report Size (1), */
802+
0x95, 0x02, /* Report Count (2), */
803+
0x81, 0x02, /* Input (Variable), */
804+
0x95, 0x2E, /* Report Count (46), */
805+
0x81, 0x01, /* Input (Constant), */
806+
0xC0, /* End Collection, */
807+
0xC0 /* End Collection */
808+
};
809+
const size_t uclogic_rdesc_v2_frame_touch_strip_size =
810+
sizeof(uclogic_rdesc_v2_frame_touch_strip_arr);
811+
764812
/* Fixed report descriptor for (tweaked) v2 frame dial reports */
765813
const __u8 uclogic_rdesc_v2_frame_dial_arr[] = {
766814
0x05, 0x01, /* Usage Page (Desktop), */

drivers/hid/hid-uclogic-rdesc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ extern const size_t uclogic_rdesc_v2_frame_buttons_size;
138138
extern const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[];
139139
extern const size_t uclogic_rdesc_v2_frame_touch_ring_size;
140140

141+
/* Fixed report descriptor for (tweaked) v2 frame touch strip reports */
142+
extern const __u8 uclogic_rdesc_v2_frame_touch_strip_arr[];
143+
extern const size_t uclogic_rdesc_v2_frame_touch_strip_size;
144+
141145
/* Device ID byte offset in v2 frame touch ring/strip reports */
142146
#define UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE 0x4
143147

0 commit comments

Comments
 (0)