HID: uclogic: Refactor UGEEv2 probe magic data
authorJosé Expósito <jose.exposito89@gmail.com>
Mon, 26 Dec 2022 12:54:51 +0000 (13:54 +0100)
committerJiri Kosina <jkosina@suse.cz>
Wed, 18 Jan 2023 08:44:57 +0000 (09:44 +0100)
A fututure patch will need to use the array of magic data that the
UGEEv2 devices expect on probe and the endpoint number. Move them to a
common place.

Refactor, no functional changes.

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>
drivers/hid/hid-uclogic-params.c
drivers/hid/hid-uclogic-rdesc.c
drivers/hid/hid-uclogic-rdesc.h

index 37cf4a93eafad35f23f2d1df4785cb3c2d87e8f2..b6a515973942c6e3f2864e082dac6df15ae73641 100644 (file)
@@ -1021,8 +1021,8 @@ cleanup:
  * Returns:
  *     Zero, if successful. A negative errno code on error.
  */
-static int uclogic_probe_interface(struct hid_device *hdev, u8 *magic_arr,
-                                  int magic_size, int endpoint)
+static int uclogic_probe_interface(struct hid_device *hdev, const u8 *magic_arr,
+                                  size_t magic_size, int endpoint)
 {
        struct usb_device *udev;
        unsigned int pipe = 0;
@@ -1311,9 +1311,6 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
        __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
-       };
        /* The resulting parameters (noop) */
        struct uclogic_params p = {0, };
 
@@ -1344,7 +1341,9 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
         * The specific data was discovered by sniffing the Windows driver
         * traffic.
         */
-       rc = uclogic_probe_interface(hdev, magic_arr, sizeof(magic_arr), 0x03);
+       rc = uclogic_probe_interface(hdev, uclogic_ugee_v2_probe_arr,
+                                    uclogic_ugee_v2_probe_size,
+                                    uclogic_ugee_v2_probe_endpoint);
        if (rc) {
                uclogic_params_init_invalid(&p);
                goto output;
index fb40775f5f5b38416b8e6705f1df62f92056de68..b6dfdf6356a60c8de02c7c2ad4222d327619ec50 100644 (file)
@@ -859,6 +859,12 @@ const __u8 uclogic_rdesc_v2_frame_dial_arr[] = {
 const size_t uclogic_rdesc_v2_frame_dial_size =
                        sizeof(uclogic_rdesc_v2_frame_dial_arr);
 
+const __u8 uclogic_ugee_v2_probe_arr[] = {
+       0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+const size_t uclogic_ugee_v2_probe_size = sizeof(uclogic_ugee_v2_probe_arr);
+const int uclogic_ugee_v2_probe_endpoint = 0x03;
+
 /* Fixed report descriptor template for UGEE v2 pen reports */
 const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[] = {
        0x05, 0x0d,         /*  Usage Page (Digitizers),                */
index a1f78c07293ff041600210ce7a3b76c68d695b6e..906d068f50a95e54a9ae592d384f77ff9544ec7e 100644 (file)
@@ -164,6 +164,11 @@ extern const size_t uclogic_rdesc_v2_frame_dial_size;
 /* Report ID for tweaked UGEE v2 battery reports */
 #define UCLOGIC_RDESC_UGEE_V2_BATTERY_ID 0xba
 
+/* Magic data expected by UGEEv2 devices on probe */
+extern const __u8 uclogic_ugee_v2_probe_arr[];
+extern const size_t uclogic_ugee_v2_probe_size;
+extern const int uclogic_ugee_v2_probe_endpoint;
+
 /* Fixed report descriptor template for UGEE v2 pen reports */
 extern const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[];
 extern const size_t uclogic_rdesc_ugee_v2_pen_template_size;