linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: kye: Add support for MousePen M508X
@ 2022-11-19 17:46 David Yang
  2022-11-19 19:17 ` [PATCH v2] " David Yang
  0 siblings, 1 reply; 5+ messages in thread
From: David Yang @ 2022-11-19 17:46 UTC (permalink / raw)
  To: mmyangfl; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

Genius MousePen M508X digitizer tablet sends incorrect report descriptor by
default. This patch replaces it with a corrected one.

Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 drivers/hid/hid-ids.h |   1 +
 drivers/hid/hid-kye.c | 152 +++++++++++++++++++++++++++++++++++++++---
 2 files changed, 144 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index dad953f66..45f49b9be 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -716,6 +716,7 @@
 #define USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2	0x501a
 #define USB_DEVICE_ID_KYE_EASYPEN_M610X	0x5013
 #define USB_DEVICE_ID_KYE_PENSKETCH_M912	0x5015
+#define USB_DEVICE_ID_KYE_MOUSEPEN_M508X	0x5017
 #define USB_DEVICE_ID_KYE_EASYPEN_M406XE	0x5019
 
 #define USB_VENDOR_ID_LABTEC		0x1020
diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c
index da903138e..ef36599af 100644
--- a/drivers/hid/hid-kye.c
+++ b/drivers/hid/hid-kye.c
@@ -480,6 +480,131 @@ static __u8 pensketch_m912_rdesc_fixed[] = {
 	0xC0                          /*  End Collection                  */
 };
 
+/* Original MousePen M508X report descriptor size */
+#define MOUSEPEN_M508X_RDESC_ORIG_SIZE	482
+
+/* Fixed MousePen M508X report descriptor */
+static __u8 mousepen_m508x_rdesc_fixed[] = {
+	0x06, 0x00, 0xFF,             /*  Usage Page (FF00h),             */
+	0x09, 0x01,                   /*  Usage (01h),                    */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x05,                   /*    Report ID (5),                */
+	0x09, 0x01,                   /*    Usage (01h),                  */
+	0x15, 0x81,                   /*    Logical Minimum (-127),       */
+	0x25, 0x7F,                   /*    Logical Maximum (127),        */
+	0x75, 0x08,                   /*    Report Size (8),              */
+	0x95, 0x07,                   /*    Report Count (7),             */
+	0xB1, 0x02,                   /*    Feature (Variable),           */
+	0xC0,                         /*  End Collection,                 */
+	0x05, 0x0D,                   /*  Usage Page (Digitizer),         */
+	0x09, 0x01,                   /*  Usage (Digitizer),              */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x10,                   /*    Report ID (16),               */
+	0x09, 0x20,                   /*    Usage (Stylus),               */
+	0xA1, 0x00,                   /*    Collection (Physical),        */
+	0x09, 0x42,                   /*      Usage (Tip Switch),         */
+	0x09, 0x44,                   /*      Usage (Barrel Switch),      */
+	0x09, 0x46,                   /*      Usage (Tablet Pick),        */
+	0x14,                         /*      Logical Minimum (0),        */
+	0x25, 0x01,                   /*      Logical Maximum (1),        */
+	0x75, 0x01,                   /*      Report Size (1),            */
+	0x95, 0x03,                   /*      Report Count (3),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x95, 0x04,                   /*      Report Count (4),           */
+	0x81, 0x01,                   /*      Input (Constant),           */
+	0x09, 0x32,                   /*      Usage (In Range),           */
+	0x95, 0x01,                   /*      Report Count (1),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x05, 0x01,                   /*      Usage Page (Desktop),       */
+	0x09, 0x30,                   /*      Usage (X),                  */
+	0x27, 0x00, 0xA0, 0x00, 0x00, /*      Logical Maximum (40960),    */
+	0x34,                         /*      Physical Minimum (0),       */
+	0x45, 0x16,                   /*      Physical Maximum (22),      */
+	0x65, 0x11,                   /*      Unit (Centimeter),          */
+	0x75, 0x10,                   /*      Report Size (16),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x09, 0x31,                   /*      Usage (Y),                  */
+	0x26, 0x00, 0x64,             /*      Logical Maximum (25600),    */
+	0x46, 0x8F, 0x00,             /*      Physical Maximum (143),     */
+	0x55, 0xFF,                   /*      Unit Exponent (-1),         */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x05, 0x0D,                   /*      Usage Page (Digitizer),     */
+	0x09, 0x30,                   /*      Usage (Tip Pressure),       */
+	0x26, 0xFF, 0x07,             /*      Logical Maximum (2047),     */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0xC0,                         /*    End Collection,               */
+	0xC0,                         /*  End Collection,                 */
+	0x05, 0x0D,                   /*  Usage Page (Digitizer),         */
+	0x09, 0x21,                   /*  Usage (Puck),                   */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x11,                   /*    Report ID (17),               */
+	0x09, 0x21,                   /*    Usage (Puck),                 */
+	0xA0,                         /*    Collection (Physical),        */
+	0x05, 0x09,                   /*      Usage Page (Button),        */
+	0x19, 0x01,                   /*      Usage Minimum (01h),        */
+	0x29, 0x03,                   /*      Usage Maximum (03h),        */
+	0x14,                         /*      Logical Minimum (0),        */
+	0x25, 0x01,                   /*      Logical Maximum (1),        */
+	0x75, 0x01,                   /*      Report Size (1),            */
+	0x95, 0x03,                   /*      Report Count (3),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x95, 0x04,                   /*      Report Count (4),           */
+	0x81, 0x01,                   /*      Input (Constant),           */
+	0x05, 0x0D,                   /*      Usage Page (Digitizer),     */
+	0x09, 0x32,                   /*      Usage (In Range),           */
+	0x95, 0x01,                   /*      Report Count (1),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x05, 0x01,                   /*      Usage Page (Desktop),       */
+	0x09, 0x30,                   /*      Usage (X),                  */
+	0x27, 0x00, 0xA0, 0x00, 0x00, /*      Logical Maximum (40960),    */
+	0x34,                         /*      Physical Minimum (0),       */
+	0x45, 0x16,                   /*      Physical Maximum (22),      */
+	0x65, 0x11,                   /*      Unit (Centimeter),          */
+	0x75, 0x10,                   /*      Report Size (16),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x09, 0x31,                   /*      Usage (Y),                  */
+	0x26, 0x00, 0x64,             /*      Logical Maximum (25600),    */
+	0x46, 0x8F, 0x00,             /*      Physical Maximum (143),     */
+	0x55, 0xFF,                   /*      Unit Exponent (-1),         */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x09, 0x38,                   /*      Usage (Wheel),              */
+	0x15, 0xFF,                   /*      Logical Minimum (-1),       */
+	0x25, 0x01,                   /*      Logical Maximum (1),        */
+	0x44,                         /*      Physical Maximum (0),       */
+	0x75, 0x08,                   /*      Report Size (8),            */
+	0x95, 0x01,                   /*      Report Count (1),           */
+	0x81, 0x06,                   /*      Input (Variable, Relative), */
+	0x81, 0x01,                   /*      Input (Constant),           */
+	0xC0,                         /*    End Collection,               */
+	0xC0,                         /*  End Collection,                 */
+	0x05, 0x0C,                   /*  Usage Page (Consumer),          */
+	0x09, 0x01,                   /*  Usage (Consumer Control),       */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x12,                   /*    Report ID (18),               */
+	0x0A, 0x01, 0x02,             /*    Usage (AC New),               */
+	0x0B, 0x76, 0x00, 0x0D, 0x00, /*    Usage (Digitizer Brush),      */
+	0x0A, 0x6A, 0x02,             /*    Usage (AC Delete),            */
+	0x0A, 0x1A, 0x02,             /*    Usage (AC Undo),              */
+	0x14,                         /*    Logical Minimum (0),          */
+	0x25, 0x01,                   /*    Logical Maximum (1),          */
+	0x75, 0x01,                   /*    Report Size (1),              */
+	0x95, 0x04,                   /*    Report Count (4),             */
+	0x81, 0x02,                   /*    Input (Variable),             */
+	0x81, 0x01,                   /*    Input (Constant),             */
+	0x15, 0xFF,                   /*    Logical Minimum (-1),         */
+	0x75, 0x08,                   /*    Report Size (8),              */
+	0x95, 0x02,                   /*    Report Count (2),             */
+	0x81, 0x01,                   /*    Input (Constant),             */
+	0x0A, 0x35, 0x02,             /*    Usage (AC Scroll),            */
+	0x0A, 0x2F, 0x02,             /*    Usage (AC Zoom),              */
+	0x0A, 0x38, 0x02,             /*    Usage (AC Pan),               */
+	0x95, 0x03,                   /*    Report Count (3),             */
+	0x81, 0x06,                   /*    Input (Variable, Relative),   */
+	0x95, 0x01,                   /*    Report Count (1),             */
+	0x81, 0x01,                   /*    Input (Constant),             */
+	0xC0                          /*  End Collection                  */
+};
+
 /* Original EasyPen M406XE report descriptor size */
 #define EASYPEN_M406XE_RDESC_ORIG_SIZE	476
 
@@ -626,18 +751,24 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 			*rsize = sizeof(easypen_m610x_rdesc_fixed);
 		}
 		break;
-	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
-		if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
-			rdesc = easypen_m406xe_rdesc_fixed;
-			*rsize = sizeof(easypen_m406xe_rdesc_fixed);
-		}
-		break;
 	case USB_DEVICE_ID_KYE_PENSKETCH_M912:
 		if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) {
 			rdesc = pensketch_m912_rdesc_fixed;
 			*rsize = sizeof(pensketch_m912_rdesc_fixed);
 		}
 		break;
+	case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
+		if (*rsize == MOUSEPEN_M508X_RDESC_ORIG_SIZE) {
+			rdesc = mousepen_m508x_rdesc_fixed;
+			*rsize = sizeof(mousepen_m508x_rdesc_fixed);
+		}
+		break;
+	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
+		if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
+			rdesc = easypen_m406xe_rdesc_fixed;
+			*rsize = sizeof(easypen_m406xe_rdesc_fixed);
+		}
+		break;
 	case USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE:
 		rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
 					"Genius Gila Gaming Mouse");
@@ -721,8 +852,9 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
 	case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
 	case USB_DEVICE_ID_KYE_EASYPEN_M610X:
-	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
 	case USB_DEVICE_ID_KYE_PENSKETCH_M912:
+	case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
+	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
 		ret = kye_tablet_enable(hdev);
 		if (ret) {
 			hid_err(hdev, "tablet enabling failed\n");
@@ -756,6 +888,10 @@ static const struct hid_device_id kye_devices[] = {
 				USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
 				USB_DEVICE_ID_KYE_EASYPEN_M610X) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
+				USB_DEVICE_ID_KYE_PENSKETCH_M912) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
+				USB_DEVICE_ID_KYE_MOUSEPEN_M508X) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
 				USB_DEVICE_ID_KYE_EASYPEN_M406XE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
@@ -764,8 +900,6 @@ static const struct hid_device_id kye_devices[] = {
 				USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
 				USB_DEVICE_ID_GENIUS_MANTICORE) },
-	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
-				USB_DEVICE_ID_KYE_PENSKETCH_M912) },
 	{ }
 };
 MODULE_DEVICE_TABLE(hid, kye_devices);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2] HID: kye: Add support for MousePen M508X
  2022-11-19 17:46 [PATCH] HID: kye: Add support for MousePen M508X David Yang
@ 2022-11-19 19:17 ` David Yang
  2022-11-19 20:50   ` [PATCH v3] " David Yang
  0 siblings, 1 reply; 5+ messages in thread
From: David Yang @ 2022-11-19 19:17 UTC (permalink / raw)
  To: mmyangfl; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

Genius MousePen M508X digitizer tablet sends incorrect report descriptor by
default. This patch replaces it with a corrected one.

Signed-off-by: David Yang <mmyangfl@gmail.com>
---
v2: add missing hid-quirks.c entry
 drivers/hid/hid-ids.h    |   1 +
 drivers/hid/hid-kye.c    | 152 ++++++++++++++++++++++++++++++++++++---
 drivers/hid/hid-quirks.c |   1 +
 3 files changed, 145 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index dad953f66..45f49b9be 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -716,6 +716,7 @@
 #define USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2	0x501a
 #define USB_DEVICE_ID_KYE_EASYPEN_M610X	0x5013
 #define USB_DEVICE_ID_KYE_PENSKETCH_M912	0x5015
+#define USB_DEVICE_ID_KYE_MOUSEPEN_M508X	0x5017
 #define USB_DEVICE_ID_KYE_EASYPEN_M406XE	0x5019
 
 #define USB_VENDOR_ID_LABTEC		0x1020
diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c
index da903138e..97e209c1f 100644
--- a/drivers/hid/hid-kye.c
+++ b/drivers/hid/hid-kye.c
@@ -480,6 +480,131 @@ static __u8 pensketch_m912_rdesc_fixed[] = {
 	0xC0                          /*  End Collection                  */
 };
 
+/* Original MousePen M508X report descriptor size */
+#define MOUSEPEN_M508X_RDESC_ORIG_SIZE	482
+
+/* Fixed MousePen M508X report descriptor */
+static __u8 mousepen_m508x_rdesc_fixed[] = {
+	0x06, 0x00, 0xFF,             /*  Usage Page (FF00h),             */
+	0x09, 0x01,                   /*  Usage (01h),                    */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x05,                   /*    Report ID (5),                */
+	0x09, 0x01,                   /*    Usage (01h),                  */
+	0x15, 0x81,                   /*    Logical Minimum (-127),       */
+	0x25, 0x7F,                   /*    Logical Maximum (127),        */
+	0x75, 0x08,                   /*    Report Size (8),              */
+	0x95, 0x07,                   /*    Report Count (7),             */
+	0xB1, 0x02,                   /*    Feature (Variable),           */
+	0xC0,                         /*  End Collection,                 */
+	0x05, 0x0D,                   /*  Usage Page (Digitizer),         */
+	0x09, 0x01,                   /*  Usage (Digitizer),              */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x10,                   /*    Report ID (16),               */
+	0x09, 0x20,                   /*    Usage (Stylus),               */
+	0xA1, 0x00,                   /*    Collection (Physical),        */
+	0x09, 0x42,                   /*      Usage (Tip Switch),         */
+	0x09, 0x44,                   /*      Usage (Barrel Switch),      */
+	0x09, 0x46,                   /*      Usage (Tablet Pick),        */
+	0x14,                         /*      Logical Minimum (0),        */
+	0x25, 0x01,                   /*      Logical Maximum (1),        */
+	0x75, 0x01,                   /*      Report Size (1),            */
+	0x95, 0x03,                   /*      Report Count (3),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x95, 0x04,                   /*      Report Count (4),           */
+	0x81, 0x01,                   /*      Input (Constant),           */
+	0x09, 0x32,                   /*      Usage (In Range),           */
+	0x95, 0x01,                   /*      Report Count (1),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x05, 0x01,                   /*      Usage Page (Desktop),       */
+	0x09, 0x30,                   /*      Usage (X),                  */
+	0x27, 0x00, 0xA0, 0x00, 0x00, /*      Logical Maximum (40960),    */
+	0x34,                         /*      Physical Minimum (0),       */
+	0x45, 0x16,                   /*      Physical Maximum (22),      */
+	0x65, 0x11,                   /*      Unit (Centimeter),          */
+	0x75, 0x10,                   /*      Report Size (16),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x09, 0x31,                   /*      Usage (Y),                  */
+	0x26, 0x00, 0x64,             /*      Logical Maximum (25600),    */
+	0x46, 0x8F, 0x00,             /*      Physical Maximum (143),     */
+	0x55, 0xFF,                   /*      Unit Exponent (-1),         */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x05, 0x0D,                   /*      Usage Page (Digitizer),     */
+	0x09, 0x30,                   /*      Usage (Tip Pressure),       */
+	0x26, 0xFF, 0x07,             /*      Logical Maximum (2047),     */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0xC0,                         /*    End Collection,               */
+	0xC0,                         /*  End Collection,                 */
+	0x05, 0x0D,                   /*  Usage Page (Digitizer),         */
+	0x09, 0x21,                   /*  Usage (Puck),                   */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x11,                   /*    Report ID (17),               */
+	0x09, 0x21,                   /*    Usage (Puck),                 */
+	0xA0,                         /*    Collection (Physical),        */
+	0x05, 0x09,                   /*      Usage Page (Button),        */
+	0x19, 0x01,                   /*      Usage Minimum (01h),        */
+	0x29, 0x03,                   /*      Usage Maximum (03h),        */
+	0x14,                         /*      Logical Minimum (0),        */
+	0x25, 0x01,                   /*      Logical Maximum (1),        */
+	0x75, 0x01,                   /*      Report Size (1),            */
+	0x95, 0x03,                   /*      Report Count (3),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x95, 0x04,                   /*      Report Count (4),           */
+	0x81, 0x01,                   /*      Input (Constant),           */
+	0x05, 0x0D,                   /*      Usage Page (Digitizer),     */
+	0x09, 0x32,                   /*      Usage (In Range),           */
+	0x95, 0x01,                   /*      Report Count (1),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x05, 0x01,                   /*      Usage Page (Desktop),       */
+	0x09, 0x30,                   /*      Usage (X),                  */
+	0x27, 0x00, 0xA0, 0x00, 0x00, /*      Logical Maximum (40960),    */
+	0x34,                         /*      Physical Minimum (0),       */
+	0x45, 0x16,                   /*      Physical Maximum (22),      */
+	0x65, 0x11,                   /*      Unit (Centimeter),          */
+	0x75, 0x10,                   /*      Report Size (16),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x09, 0x31,                   /*      Usage (Y),                  */
+	0x26, 0x00, 0x64,             /*      Logical Maximum (25600),    */
+	0x46, 0x8F, 0x00,             /*      Physical Maximum (143),     */
+	0x55, 0xFF,                   /*      Unit Exponent (-1),         */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x09, 0x38,                   /*      Usage (Wheel),              */
+	0x15, 0xFF,                   /*      Logical Minimum (-1),       */
+	0x25, 0x01,                   /*      Logical Maximum (1),        */
+	0x44,                         /*      Physical Maximum (0),       */
+	0x75, 0x08,                   /*      Report Size (8),            */
+	0x95, 0x01,                   /*      Report Count (1),           */
+	0x81, 0x06,                   /*      Input (Variable, Relative), */
+	0x81, 0x01,                   /*      Input (Constant),           */
+	0xC0,                         /*    End Collection,               */
+	0xC0,                         /*  End Collection,                 */
+	0x05, 0x0C,                   /*  Usage Page (Consumer),          */
+	0x09, 0x01,                   /*  Usage (Consumer Control),       */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x12,                   /*    Report ID (18),               */
+	0x0A, 0x01, 0x02,             /*    Usage (AC New),               */
+	0x09, 0x40,                   /*    Usage (Menu),                 */
+	0x0A, 0x6A, 0x02,             /*    Usage (AC Delete),            */
+	0x0A, 0x1A, 0x02,             /*    Usage (AC Undo),              */
+	0x14,                         /*    Logical Minimum (0),          */
+	0x25, 0x01,                   /*    Logical Maximum (1),          */
+	0x75, 0x01,                   /*    Report Size (1),              */
+	0x95, 0x04,                   /*    Report Count (4),             */
+	0x81, 0x02,                   /*    Input (Variable),             */
+	0x81, 0x01,                   /*    Input (Constant),             */
+	0x15, 0xFF,                   /*    Logical Minimum (-1),         */
+	0x75, 0x08,                   /*    Report Size (8),              */
+	0x95, 0x02,                   /*    Report Count (2),             */
+	0x81, 0x01,                   /*    Input (Constant),             */
+	0x0A, 0x35, 0x02,             /*    Usage (AC Scroll),            */
+	0x0A, 0x2F, 0x02,             /*    Usage (AC Zoom),              */
+	0x0A, 0x38, 0x02,             /*    Usage (AC Pan),               */
+	0x95, 0x03,                   /*    Report Count (3),             */
+	0x81, 0x06,                   /*    Input (Variable, Relative),   */
+	0x95, 0x01,                   /*    Report Count (1),             */
+	0x81, 0x01,                   /*    Input (Constant),             */
+	0xC0                          /*  End Collection                  */
+};
+
 /* Original EasyPen M406XE report descriptor size */
 #define EASYPEN_M406XE_RDESC_ORIG_SIZE	476
 
@@ -626,18 +751,24 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 			*rsize = sizeof(easypen_m610x_rdesc_fixed);
 		}
 		break;
-	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
-		if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
-			rdesc = easypen_m406xe_rdesc_fixed;
-			*rsize = sizeof(easypen_m406xe_rdesc_fixed);
-		}
-		break;
 	case USB_DEVICE_ID_KYE_PENSKETCH_M912:
 		if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) {
 			rdesc = pensketch_m912_rdesc_fixed;
 			*rsize = sizeof(pensketch_m912_rdesc_fixed);
 		}
 		break;
+	case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
+		if (*rsize == MOUSEPEN_M508X_RDESC_ORIG_SIZE) {
+			rdesc = mousepen_m508x_rdesc_fixed;
+			*rsize = sizeof(mousepen_m508x_rdesc_fixed);
+		}
+		break;
+	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
+		if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
+			rdesc = easypen_m406xe_rdesc_fixed;
+			*rsize = sizeof(easypen_m406xe_rdesc_fixed);
+		}
+		break;
 	case USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE:
 		rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
 					"Genius Gila Gaming Mouse");
@@ -721,8 +852,9 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
 	case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
 	case USB_DEVICE_ID_KYE_EASYPEN_M610X:
-	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
 	case USB_DEVICE_ID_KYE_PENSKETCH_M912:
+	case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
+	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
 		ret = kye_tablet_enable(hdev);
 		if (ret) {
 			hid_err(hdev, "tablet enabling failed\n");
@@ -756,6 +888,10 @@ static const struct hid_device_id kye_devices[] = {
 				USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
 				USB_DEVICE_ID_KYE_EASYPEN_M610X) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
+				USB_DEVICE_ID_KYE_PENSKETCH_M912) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
+				USB_DEVICE_ID_KYE_MOUSEPEN_M508X) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
 				USB_DEVICE_ID_KYE_EASYPEN_M406XE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
@@ -764,8 +900,6 @@ static const struct hid_device_id kye_devices[] = {
 				USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
 				USB_DEVICE_ID_GENIUS_MANTICORE) },
-	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
-				USB_DEVICE_ID_KYE_PENSKETCH_M912) },
 	{ }
 };
 MODULE_DEVICE_TABLE(hid, kye_devices);
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 50e1c717f..c70bbdc1a 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -108,6 +108,7 @@ static const struct hid_device_id hid_quirks[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X), HID_QUIRK_MULTI_INPUT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2), HID_QUIRK_MULTI_INPUT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_M912), HID_QUIRK_MULTI_INPUT },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_M508X), HID_QUIRK_MULTI_INPUT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M406XE), HID_QUIRK_MULTI_INPUT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2), HID_QUIRK_ALWAYS_POLL },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_OPTICAL_USB_MOUSE_600E), HID_QUIRK_ALWAYS_POLL },
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3] HID: kye: Add support for MousePen M508X
  2022-11-19 19:17 ` [PATCH v2] " David Yang
@ 2022-11-19 20:50   ` David Yang
  2022-11-22  9:29     ` Jiri Kosina
  0 siblings, 1 reply; 5+ messages in thread
From: David Yang @ 2022-11-19 20:50 UTC (permalink / raw)
  To: mmyangfl; +Cc: Jiri Kosina, Benjamin Tissoires, linux-input, linux-kernel

Genius MousePen M508X digitizer tablet sends incorrect report descriptor by
default. This patch replaces it with a corrected one.

Signed-off-by: David Yang <mmyangfl@gmail.com>
---
v2: add missing hid-quirks.c entry
v3: minor fix of descriptor
 drivers/hid/hid-ids.h    |   1 +
 drivers/hid/hid-kye.c    | 152 ++++++++++++++++++++++++++++++++++++---
 drivers/hid/hid-quirks.c |   1 +
 3 files changed, 145 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index dad953f66..45f49b9be 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -716,6 +716,7 @@
 #define USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2	0x501a
 #define USB_DEVICE_ID_KYE_EASYPEN_M610X	0x5013
 #define USB_DEVICE_ID_KYE_PENSKETCH_M912	0x5015
+#define USB_DEVICE_ID_KYE_MOUSEPEN_M508X	0x5017
 #define USB_DEVICE_ID_KYE_EASYPEN_M406XE	0x5019
 
 #define USB_VENDOR_ID_LABTEC		0x1020
diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c
index da903138e..805d30c39 100644
--- a/drivers/hid/hid-kye.c
+++ b/drivers/hid/hid-kye.c
@@ -480,6 +480,131 @@ static __u8 pensketch_m912_rdesc_fixed[] = {
 	0xC0                          /*  End Collection                  */
 };
 
+/* Original MousePen M508X report descriptor size */
+#define MOUSEPEN_M508X_RDESC_ORIG_SIZE	482
+
+/* Fixed MousePen M508X report descriptor */
+static __u8 mousepen_m508x_rdesc_fixed[] = {
+	0x06, 0x00, 0xFF,             /*  Usage Page (FF00h),             */
+	0x09, 0x01,                   /*  Usage (01h),                    */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x05,                   /*    Report ID (5),                */
+	0x09, 0x01,                   /*    Usage (01h),                  */
+	0x15, 0x81,                   /*    Logical Minimum (-127),       */
+	0x25, 0x7F,                   /*    Logical Maximum (127),        */
+	0x75, 0x08,                   /*    Report Size (8),              */
+	0x95, 0x07,                   /*    Report Count (7),             */
+	0xB1, 0x02,                   /*    Feature (Variable),           */
+	0xC0,                         /*  End Collection,                 */
+	0x05, 0x0D,                   /*  Usage Page (Digitizer),         */
+	0x09, 0x01,                   /*  Usage (Digitizer),              */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x10,                   /*    Report ID (16),               */
+	0x09, 0x20,                   /*    Usage (Stylus),               */
+	0xA1, 0x00,                   /*    Collection (Physical),        */
+	0x09, 0x42,                   /*      Usage (Tip Switch),         */
+	0x09, 0x44,                   /*      Usage (Barrel Switch),      */
+	0x09, 0x46,                   /*      Usage (Tablet Pick),        */
+	0x14,                         /*      Logical Minimum (0),        */
+	0x25, 0x01,                   /*      Logical Maximum (1),        */
+	0x75, 0x01,                   /*      Report Size (1),            */
+	0x95, 0x03,                   /*      Report Count (3),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x95, 0x04,                   /*      Report Count (4),           */
+	0x81, 0x01,                   /*      Input (Constant),           */
+	0x09, 0x32,                   /*      Usage (In Range),           */
+	0x95, 0x01,                   /*      Report Count (1),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x75, 0x10,                   /*      Report Size (16),           */
+	0xA4,                         /*      Push,                       */
+	0x05, 0x01,                   /*      Usage Page (Desktop),       */
+	0x09, 0x30,                   /*      Usage (X),                  */
+	0x27, 0x00, 0xA0, 0x00, 0x00, /*      Logical Maximum (40960),    */
+	0x34,                         /*      Physical Minimum (0),       */
+	0x45, 0x16,                   /*      Physical Maximum (22),      */
+	0x65, 0x11,                   /*      Unit (Centimeter),          */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x09, 0x31,                   /*      Usage (Y),                  */
+	0x26, 0x00, 0x64,             /*      Logical Maximum (25600),    */
+	0x46, 0x8F, 0x00,             /*      Physical Maximum (143),     */
+	0x55, 0xFF,                   /*      Unit Exponent (-1),         */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0xB4,                         /*      Pop,                        */
+	0x09, 0x30,                   /*      Usage (Tip Pressure),       */
+	0x26, 0xFF, 0x07,             /*      Logical Maximum (2047),     */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0xC0,                         /*    End Collection,               */
+	0xC0,                         /*  End Collection,                 */
+	0x05, 0x0D,                   /*  Usage Page (Digitizer),         */
+	0x09, 0x21,                   /*  Usage (Puck),                   */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x11,                   /*    Report ID (17),               */
+	0x09, 0x21,                   /*    Usage (Puck),                 */
+	0xA0,                         /*    Collection (Physical),        */
+	0x05, 0x09,                   /*      Usage Page (Button),        */
+	0x19, 0x01,                   /*      Usage Minimum (01h),        */
+	0x29, 0x03,                   /*      Usage Maximum (03h),        */
+	0x14,                         /*      Logical Minimum (0),        */
+	0x25, 0x01,                   /*      Logical Maximum (1),        */
+	0x75, 0x01,                   /*      Report Size (1),            */
+	0x95, 0x03,                   /*      Report Count (3),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x95, 0x04,                   /*      Report Count (4),           */
+	0x81, 0x01,                   /*      Input (Constant),           */
+	0x05, 0x0D,                   /*      Usage Page (Digitizer),     */
+	0x09, 0x32,                   /*      Usage (In Range),           */
+	0x95, 0x01,                   /*      Report Count (1),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x05, 0x01,                   /*      Usage Page (Desktop),       */
+	0xA4,                         /*      Push,                       */
+	0x09, 0x30,                   /*      Usage (X),                  */
+	0x27, 0x00, 0xA0, 0x00, 0x00, /*      Logical Maximum (40960),    */
+	0x34,                         /*      Physical Minimum (0),       */
+	0x45, 0x16,                   /*      Physical Maximum (22),      */
+	0x65, 0x11,                   /*      Unit (Centimeter),          */
+	0x75, 0x10,                   /*      Report Size (16),           */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0x09, 0x31,                   /*      Usage (Y),                  */
+	0x26, 0x00, 0x64,             /*      Logical Maximum (25600),    */
+	0x46, 0x8F, 0x00,             /*      Physical Maximum (143),     */
+	0x55, 0xFF,                   /*      Unit Exponent (-1),         */
+	0x81, 0x02,                   /*      Input (Variable),           */
+	0xB4,                         /*      Pop,                        */
+	0x09, 0x38,                   /*      Usage (Wheel),              */
+	0x15, 0xFF,                   /*      Logical Minimum (-1),       */
+	0x75, 0x08,                   /*      Report Size (8),            */
+	0x81, 0x06,                   /*      Input (Variable, Relative), */
+	0x81, 0x01,                   /*      Input (Constant),           */
+	0xC0,                         /*    End Collection,               */
+	0xC0,                         /*  End Collection,                 */
+	0x05, 0x0C,                   /*  Usage Page (Consumer),          */
+	0x09, 0x01,                   /*  Usage (Consumer Control),       */
+	0xA1, 0x01,                   /*  Collection (Application),       */
+	0x85, 0x12,                   /*    Report ID (18),               */
+	0x0A, 0x01, 0x02,             /*    Usage (AC New),               */
+	0x09, 0x40,                   /*    Usage (Menu),                 */
+	0x0A, 0x6A, 0x02,             /*    Usage (AC Delete),            */
+	0x0A, 0x1A, 0x02,             /*    Usage (AC Undo),              */
+	0x14,                         /*    Logical Minimum (0),          */
+	0x25, 0x01,                   /*    Logical Maximum (1),          */
+	0x75, 0x01,                   /*    Report Size (1),              */
+	0x95, 0x04,                   /*    Report Count (4),             */
+	0x81, 0x02,                   /*    Input (Variable),             */
+	0x81, 0x01,                   /*    Input (Constant),             */
+	0x15, 0xFF,                   /*    Logical Minimum (-1),         */
+	0x75, 0x08,                   /*    Report Size (8),              */
+	0x95, 0x02,                   /*    Report Count (2),             */
+	0x81, 0x01,                   /*    Input (Constant),             */
+	0x0A, 0x35, 0x02,             /*    Usage (AC Scroll),            */
+	0x0A, 0x2F, 0x02,             /*    Usage (AC Zoom),              */
+	0x0A, 0x38, 0x02,             /*    Usage (AC Pan),               */
+	0x95, 0x03,                   /*    Report Count (3),             */
+	0x81, 0x06,                   /*    Input (Variable, Relative),   */
+	0x95, 0x01,                   /*    Report Count (1),             */
+	0x81, 0x01,                   /*    Input (Constant),             */
+	0xC0                          /*  End Collection                  */
+};
+
 /* Original EasyPen M406XE report descriptor size */
 #define EASYPEN_M406XE_RDESC_ORIG_SIZE	476
 
@@ -626,18 +751,24 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 			*rsize = sizeof(easypen_m610x_rdesc_fixed);
 		}
 		break;
-	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
-		if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
-			rdesc = easypen_m406xe_rdesc_fixed;
-			*rsize = sizeof(easypen_m406xe_rdesc_fixed);
-		}
-		break;
 	case USB_DEVICE_ID_KYE_PENSKETCH_M912:
 		if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) {
 			rdesc = pensketch_m912_rdesc_fixed;
 			*rsize = sizeof(pensketch_m912_rdesc_fixed);
 		}
 		break;
+	case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
+		if (*rsize == MOUSEPEN_M508X_RDESC_ORIG_SIZE) {
+			rdesc = mousepen_m508x_rdesc_fixed;
+			*rsize = sizeof(mousepen_m508x_rdesc_fixed);
+		}
+		break;
+	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
+		if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
+			rdesc = easypen_m406xe_rdesc_fixed;
+			*rsize = sizeof(easypen_m406xe_rdesc_fixed);
+		}
+		break;
 	case USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE:
 		rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
 					"Genius Gila Gaming Mouse");
@@ -721,8 +852,9 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
 	case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
 	case USB_DEVICE_ID_KYE_EASYPEN_M610X:
-	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
 	case USB_DEVICE_ID_KYE_PENSKETCH_M912:
+	case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
+	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
 		ret = kye_tablet_enable(hdev);
 		if (ret) {
 			hid_err(hdev, "tablet enabling failed\n");
@@ -756,6 +888,10 @@ static const struct hid_device_id kye_devices[] = {
 				USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
 				USB_DEVICE_ID_KYE_EASYPEN_M610X) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
+				USB_DEVICE_ID_KYE_PENSKETCH_M912) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
+				USB_DEVICE_ID_KYE_MOUSEPEN_M508X) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
 				USB_DEVICE_ID_KYE_EASYPEN_M406XE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
@@ -764,8 +900,6 @@ static const struct hid_device_id kye_devices[] = {
 				USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
 				USB_DEVICE_ID_GENIUS_MANTICORE) },
-	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
-				USB_DEVICE_ID_KYE_PENSKETCH_M912) },
 	{ }
 };
 MODULE_DEVICE_TABLE(hid, kye_devices);
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 50e1c717f..c70bbdc1a 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -108,6 +108,7 @@ static const struct hid_device_id hid_quirks[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X), HID_QUIRK_MULTI_INPUT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2), HID_QUIRK_MULTI_INPUT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_M912), HID_QUIRK_MULTI_INPUT },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_M508X), HID_QUIRK_MULTI_INPUT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M406XE), HID_QUIRK_MULTI_INPUT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2), HID_QUIRK_ALWAYS_POLL },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_OPTICAL_USB_MOUSE_600E), HID_QUIRK_ALWAYS_POLL },
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] HID: kye: Add support for MousePen M508X
  2022-11-19 20:50   ` [PATCH v3] " David Yang
@ 2022-11-22  9:29     ` Jiri Kosina
  2022-11-22 11:55       ` Yangfl
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Kosina @ 2022-11-22  9:29 UTC (permalink / raw)
  To: David Yang; +Cc: Benjamin Tissoires, linux-input, linux-kernel

On Sun, 20 Nov 2022, David Yang wrote:

> Genius MousePen M508X digitizer tablet sends incorrect report descriptor by
> default. This patch replaces it with a corrected one.
> 
> Signed-off-by: David Yang <mmyangfl@gmail.com>

Thanks for the fix. A few comments below.

> @@ -626,18 +751,24 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
>  			*rsize = sizeof(easypen_m610x_rdesc_fixed);
>  		}
>  		break;
> -	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
> -		if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
> -			rdesc = easypen_m406xe_rdesc_fixed;
> -			*rsize = sizeof(easypen_m406xe_rdesc_fixed);
> -		}
> -		break;
>  	case USB_DEVICE_ID_KYE_PENSKETCH_M912:
>  		if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) {
>  			rdesc = pensketch_m912_rdesc_fixed;
>  			*rsize = sizeof(pensketch_m912_rdesc_fixed);
>  		}
>  		break;
> +	case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
> +		if (*rsize == MOUSEPEN_M508X_RDESC_ORIG_SIZE) {
> +			rdesc = mousepen_m508x_rdesc_fixed;
> +			*rsize = sizeof(mousepen_m508x_rdesc_fixed);
> +		}
> +		break;
> +	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
> +		if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
> +			rdesc = easypen_m406xe_rdesc_fixed;
> +			*rsize = sizeof(easypen_m406xe_rdesc_fixed);
> +		}
> +		break;

What is the reason for moving USB_DEVICE_ID_KYE_EASYPEN_M406XE around?

>  	case USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE:
>  		rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
>  					"Genius Gila Gaming Mouse");
> @@ -721,8 +852,9 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  	case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
>  	case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
>  	case USB_DEVICE_ID_KYE_EASYPEN_M610X:
> -	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
>  	case USB_DEVICE_ID_KYE_PENSKETCH_M912:
> +	case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
> +	case USB_DEVICE_ID_KYE_EASYPEN_M406XE:

Same here.

>  		ret = kye_tablet_enable(hdev);
>  		if (ret) {
>  			hid_err(hdev, "tablet enabling failed\n");
> @@ -756,6 +888,10 @@ static const struct hid_device_id kye_devices[] = {
>  				USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
>  	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
>  				USB_DEVICE_ID_KYE_EASYPEN_M610X) },
> +	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> +				USB_DEVICE_ID_KYE_PENSKETCH_M912) },
> +	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> +				USB_DEVICE_ID_KYE_MOUSEPEN_M508X) },
>  	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
>  				USB_DEVICE_ID_KYE_EASYPEN_M406XE) },
>  	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> @@ -764,8 +900,6 @@ static const struct hid_device_id kye_devices[] = {
>  				USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
>  	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
>  				USB_DEVICE_ID_GENIUS_MANTICORE) },
> -	{ HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> -				USB_DEVICE_ID_KYE_PENSKETCH_M912) },

This looks unrelated and incorrect, why are you dropping 
USB_DEVICE_ID_KYE_PENSKETCH_M912 from the device table?

Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] HID: kye: Add support for MousePen M508X
  2022-11-22  9:29     ` Jiri Kosina
@ 2022-11-22 11:55       ` Yangfl
  0 siblings, 0 replies; 5+ messages in thread
From: Yangfl @ 2022-11-22 11:55 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, linux-kernel

Jiri Kosina <jikos@kernel.org> 于2022年11月22日周二 17:29写道:
>
> On Sun, 20 Nov 2022, David Yang wrote:
>
> > Genius MousePen M508X digitizer tablet sends incorrect report descriptor by
> > default. This patch replaces it with a corrected one.
> >
> > Signed-off-by: David Yang <mmyangfl@gmail.com>
>
> Thanks for the fix. A few comments below.
>
> > @@ -626,18 +751,24 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
> >                       *rsize = sizeof(easypen_m610x_rdesc_fixed);
> >               }
> >               break;
> > -     case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
> > -             if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
> > -                     rdesc = easypen_m406xe_rdesc_fixed;
> > -                     *rsize = sizeof(easypen_m406xe_rdesc_fixed);
> > -             }
> > -             break;
> >       case USB_DEVICE_ID_KYE_PENSKETCH_M912:
> >               if (*rsize == PENSKETCH_M912_RDESC_ORIG_SIZE) {
> >                       rdesc = pensketch_m912_rdesc_fixed;
> >                       *rsize = sizeof(pensketch_m912_rdesc_fixed);
> >               }
> >               break;
> > +     case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
> > +             if (*rsize == MOUSEPEN_M508X_RDESC_ORIG_SIZE) {
> > +                     rdesc = mousepen_m508x_rdesc_fixed;
> > +                     *rsize = sizeof(mousepen_m508x_rdesc_fixed);
> > +             }
> > +             break;
> > +     case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
> > +             if (*rsize == EASYPEN_M406XE_RDESC_ORIG_SIZE) {
> > +                     rdesc = easypen_m406xe_rdesc_fixed;
> > +                     *rsize = sizeof(easypen_m406xe_rdesc_fixed);
> > +             }
> > +             break;
>
> What is the reason for moving USB_DEVICE_ID_KYE_EASYPEN_M406XE around?
>

Reorder to match the sequence of device ids in hid-ids.h. Same below.

> >       case USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE:
> >               rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
> >                                       "Genius Gila Gaming Mouse");
> > @@ -721,8 +852,9 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id)
> >       case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
> >       case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2:
> >       case USB_DEVICE_ID_KYE_EASYPEN_M610X:
> > -     case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
> >       case USB_DEVICE_ID_KYE_PENSKETCH_M912:
> > +     case USB_DEVICE_ID_KYE_MOUSEPEN_M508X:
> > +     case USB_DEVICE_ID_KYE_EASYPEN_M406XE:
>
> Same here.
>
> >               ret = kye_tablet_enable(hdev);
> >               if (ret) {
> >                       hid_err(hdev, "tablet enabling failed\n");
> > @@ -756,6 +888,10 @@ static const struct hid_device_id kye_devices[] = {
> >                               USB_DEVICE_ID_KYE_MOUSEPEN_I608X_V2) },
> >       { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> >                               USB_DEVICE_ID_KYE_EASYPEN_M610X) },
> > +     { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> > +                             USB_DEVICE_ID_KYE_PENSKETCH_M912) },
> > +     { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> > +                             USB_DEVICE_ID_KYE_MOUSEPEN_M508X) },
> >       { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> >                               USB_DEVICE_ID_KYE_EASYPEN_M406XE) },
> >       { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> > @@ -764,8 +900,6 @@ static const struct hid_device_id kye_devices[] = {
> >                               USB_DEVICE_ID_GENIUS_GX_IMPERATOR) },
> >       { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> >                               USB_DEVICE_ID_GENIUS_MANTICORE) },
> > -     { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
> > -                             USB_DEVICE_ID_KYE_PENSKETCH_M912) },
>
> This looks unrelated and incorrect, why are you dropping
> USB_DEVICE_ID_KYE_PENSKETCH_M912 from the device table?
>

USB_DEVICE_ID_KYE_PENSKETCH_M912 is moved upward, see -756,6 +888,10.

> Thanks,
>
> --
> Jiri Kosina
> SUSE Labs
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-22 11:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-19 17:46 [PATCH] HID: kye: Add support for MousePen M508X David Yang
2022-11-19 19:17 ` [PATCH v2] " David Yang
2022-11-19 20:50   ` [PATCH v3] " David Yang
2022-11-22  9:29     ` Jiri Kosina
2022-11-22 11:55       ` Yangfl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).