]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: uclogic: Support custom device suffix for frames
authorNikolai Kondrashov <spbnick@gmail.com>
Thu, 3 Mar 2022 07:47:32 +0000 (08:47 +0100)
committerJiri Kosina <jkosina@suse.cz>
Mon, 11 Apr 2022 14:51:52 +0000 (16:51 +0200)
Support assigning custom device name suffixes to frame input devices
instead of just "Pad". This allows distinguishing multiple frame input
devices, e.g. for Huion HS610.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-uclogic-core.c
drivers/hid/hid-uclogic-params.h

index b448616dacb9d4140e74ecafb5ef5fadbcc8f3cc..96f3fb8c492c320c0c52b51c8848aaf477999601 100644 (file)
@@ -110,6 +110,8 @@ static int uclogic_input_configured(struct hid_device *hdev,
        for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) {
                frame = &params->frame_list[i];
                if (hi->report->id == frame->id) {
+                       /* Assign custom suffix, if any */
+                       suffix = frame->suffix;
                        /*
                         * Disable EV_MSC reports for touch ring interfaces to
                         * make the Wacom driver pickup touch ring extents
@@ -119,27 +121,29 @@ static int uclogic_input_configured(struct hid_device *hdev,
                }
        }
 
-       field = hi->report->field[0];
-
-       switch (field->application) {
-       case HID_GD_KEYBOARD:
-               suffix = "Keyboard";
-               break;
-       case HID_GD_MOUSE:
-               suffix = "Mouse";
-               break;
-       case HID_GD_KEYPAD:
-               suffix = "Pad";
-               break;
-       case HID_DG_PEN:
-               suffix = "Pen";
-               break;
-       case HID_CP_CONSUMER_CONTROL:
-               suffix = "Consumer Control";
-               break;
-       case HID_GD_SYSTEM_CONTROL:
-               suffix = "System Control";
-               break;
+       if (!suffix) {
+               field = hi->report->field[0];
+
+               switch (field->application) {
+               case HID_GD_KEYBOARD:
+                       suffix = "Keyboard";
+                       break;
+               case HID_GD_MOUSE:
+                       suffix = "Mouse";
+                       break;
+               case HID_GD_KEYPAD:
+                       suffix = "Pad";
+                       break;
+               case HID_DG_PEN:
+                       suffix = "Pen";
+                       break;
+               case HID_CP_CONSUMER_CONTROL:
+                       suffix = "Consumer Control";
+                       break;
+               case HID_GD_SYSTEM_CONTROL:
+                       suffix = "System Control";
+                       break;
+               }
        }
 
        if (suffix) {
index fe13bc36983b48ea3172fd58322dd445a896198d..8042820e78b135915fd8099ba374fff3d471f900 100644 (file)
@@ -114,6 +114,10 @@ struct uclogic_params_frame {
         * Report ID, if reports should be tweaked, zero if not.
         */
        unsigned int id;
+       /*
+        * The suffix to add to the input device name, if not NULL.
+        */
+       const char *suffix;
        /*
         * Number of the least-significant bit of the 2-bit state of a rotary
         * encoder, in the report. Cannot point to a 2-bit field crossing a
@@ -212,6 +216,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
                ".frame_list[0].desc_ptr = %p\n"                \
                ".frame_list[0].desc_size = %u\n"               \
                ".frame_list[0].id = %u\n"                      \
+               ".frame_list[0].suffix = %s\n"                  \
                ".frame_list[0].re_lsb = %u\n"                  \
                ".frame_list[0].dev_id_byte = %u\n"             \
                ".frame_list[0].touch_ring_byte = %u\n"         \
@@ -234,6 +239,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
                (_params)->frame_list[0].desc_ptr,                          \
                (_params)->frame_list[0].desc_size,                         \
                (_params)->frame_list[0].id,                                \
+               (_params)->frame_list[0].suffix,                            \
                (_params)->frame_list[0].re_lsb,                            \
                (_params)->frame_list[0].dev_id_byte,                       \
                (_params)->frame_list[0].touch_ring_byte,                   \