* [PATCH 1/7] HID: uclogic: Support Huion tilt reporting
2022-02-10 19:04 [PATCH 0/7] DIGImend patches, part one José Expósito
@ 2022-02-10 19:04 ` José Expósito
2022-02-10 19:04 ` [PATCH 2/7] HID: uclogic: Rename Huion HS64 PID to Huion Tablet 2 José Expósito
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: José Expósito @ 2022-02-10 19:04 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
José Expósito
From: Nikolai Kondrashov <spbnick@gmail.com>
Add support for Huion v2 protocol tilt reporting. Describe reports as
angles in degrees, which is not exactly true, but there doesn't seem to
be a straightforward, consistent conversion possible, and what's
reported would have to be enough.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-core.c | 3 +++
drivers/hid/hid-uclogic-params.c | 1 +
drivers/hid/hid-uclogic-params.h | 8 ++++++++
drivers/hid/hid-uclogic-rdesc.c | 12 +++++++++++-
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index d8ab0139e5cd..823704bc02ef 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -304,6 +304,9 @@ static int uclogic_raw_event(struct hid_device *hdev,
mod_timer(&drvdata->inrange_timer,
jiffies + msecs_to_jiffies(100));
}
+ /* If we report tilt and Y direction is flipped */
+ if (size >= 12 && params->pen.tilt_y_flipped)
+ data[11] = -data[11];
}
/* Tweak frame control reports, if necessary */
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 3e70f969fb84..30e0f69ed5af 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -369,6 +369,7 @@ static int uclogic_params_pen_init_v2(struct uclogic_params_pen *pen,
pen->id = UCLOGIC_RDESC_PEN_V2_ID;
pen->inrange = UCLOGIC_PARAMS_PEN_INRANGE_NONE;
pen->fragmented_hires = true;
+ pen->tilt_y_flipped = true;
found = true;
finish:
*pfound = found;
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index ba48b1c7a0e5..e8381bb77bd0 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -62,6 +62,12 @@ struct uclogic_params_pen {
* Only valid if "id" is not zero.
*/
bool fragmented_hires;
+ /*
+ * True if the pen reports tilt in bytes at offset 10 (X) and 11 (Y),
+ * and the Y tilt direction is flipped.
+ * Only valid if "id" is not zero.
+ */
+ bool tilt_y_flipped;
};
/*
@@ -171,6 +177,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
".pen.id = %u\n" \
".pen.inrange = %s\n" \
".pen.fragmented_hires = %s\n" \
+ ".pen.tilt_y_flipped = %s\n" \
".frame.desc_ptr = %p\n" \
".frame.desc_size = %u\n" \
".frame.id = %u\n" \
@@ -189,6 +196,7 @@ extern int uclogic_params_init(struct uclogic_params *params,
(_params)->pen.id, \
uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \
((_params)->pen.fragmented_hires ? "true" : "false"), \
+ ((_params)->pen.tilt_y_flipped ? "true" : "false"), \
(_params)->frame.desc_ptr, \
(_params)->frame.desc_size, \
(_params)->frame.id, \
diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c
index 6dd6dcd09c8b..2607cbdf8ff2 100644
--- a/drivers/hid/hid-uclogic-rdesc.c
+++ b/drivers/hid/hid-uclogic-rdesc.c
@@ -633,7 +633,17 @@ const __u8 uclogic_rdesc_pen_v2_template_arr[] = {
0x27, UCLOGIC_RDESC_PEN_PH(PRESSURE_LM),
/* Logical Maximum (PLACEHOLDER), */
0x81, 0x02, /* Input (Variable), */
- 0x81, 0x03, /* Input (Constant, Variable), */
+ 0x54, /* Unit Exponent (0), */
+ 0x65, 0x14, /* Unit (Degrees), */
+ 0x35, 0xC4, /* Physical Minimum (-60), */
+ 0x45, 0x3C, /* Physical Maximum (60), */
+ 0x15, 0xC4, /* Logical Minimum (-60), */
+ 0x25, 0x3C, /* Logical Maximum (60), */
+ 0x75, 0x08, /* Report Size (8), */
+ 0x95, 0x02, /* Report Count (2), */
+ 0x09, 0x3D, /* Usage (X Tilt), */
+ 0x09, 0x3E, /* Usage (Y Tilt), */
+ 0x81, 0x02, /* Input (Variable), */
0xC0, /* End Collection, */
0xC0 /* End Collection */
};
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 2/7] HID: uclogic: Rename Huion HS64 PID to Huion Tablet 2
2022-02-10 19:04 [PATCH 0/7] DIGImend patches, part one José Expósito
2022-02-10 19:04 ` [PATCH 1/7] HID: uclogic: Support Huion tilt reporting José Expósito
@ 2022-02-10 19:04 ` José Expósito
2022-02-10 19:04 ` [PATCH 3/7] HID: uclogic: Support Huion 13th frame button José Expósito
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: José Expósito @ 2022-02-10 19:04 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
José Expósito
From: Nikolai Kondrashov <spbnick@gmail.com>
Since the 006d Huion PID is used by multiple tablets (at least HS64 and
HS610), rename its constant to a more general
"USB_DEVICE_ID_HUION_TABLET2".
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-ids.h | 2 +-
drivers/hid/hid-uclogic-core.c | 2 +-
drivers/hid/hid-uclogic-params.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 85975031389b..10780a076693 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -606,7 +606,7 @@
#define USB_VENDOR_ID_HUION 0x256c
#define USB_DEVICE_ID_HUION_TABLET 0x006e
-#define USB_DEVICE_ID_HUION_HS64 0x006d
+#define USB_DEVICE_ID_HUION_TABLET2 0x006d
#define USB_VENDOR_ID_IBM 0x04b3
#define USB_DEVICE_ID_IBM_SCROLLPOINT_III 0x3100
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 823704bc02ef..850c660ec2ab 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -376,7 +376,7 @@ static const struct hid_device_id uclogic_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_HUION,
USB_DEVICE_ID_HUION_TABLET) },
{ HID_USB_DEVICE(USB_VENDOR_ID_HUION,
- USB_DEVICE_ID_HUION_HS64) },
+ USB_DEVICE_ID_HUION_TABLET2) },
{ HID_USB_DEVICE(USB_VENDOR_ID_TRUST,
USB_DEVICE_ID_TRUST_PANORA_TABLET) },
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC,
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 30e0f69ed5af..98910d8dae92 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -993,7 +993,7 @@ int uclogic_params_init(struct uclogic_params *params,
case VID_PID(USB_VENDOR_ID_HUION,
USB_DEVICE_ID_HUION_TABLET):
case VID_PID(USB_VENDOR_ID_HUION,
- USB_DEVICE_ID_HUION_HS64):
+ USB_DEVICE_ID_HUION_TABLET2):
case VID_PID(USB_VENDOR_ID_UCLOGIC,
USB_DEVICE_ID_HUION_TABLET):
case VID_PID(USB_VENDOR_ID_UCLOGIC,
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 3/7] HID: uclogic: Support Huion 13th frame button
2022-02-10 19:04 [PATCH 0/7] DIGImend patches, part one José Expósito
2022-02-10 19:04 ` [PATCH 1/7] HID: uclogic: Support Huion tilt reporting José Expósito
2022-02-10 19:04 ` [PATCH 2/7] HID: uclogic: Rename Huion HS64 PID to Huion Tablet 2 José Expósito
@ 2022-02-10 19:04 ` José Expósito
2022-02-10 19:04 ` [PATCH 4/7] HID: uclogic: Split pen and frame raw event handling José Expósito
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: José Expósito @ 2022-02-10 19:04 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
José Expósito
From: Nikolai Kondrashov <spbnick@gmail.com>
Support reporting 13th frame button for Huion tablets. This supports
reporting the button in the center of the dial for Huion HS610.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-rdesc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c
index 2607cbdf8ff2..ec16355d200b 100644
--- a/drivers/hid/hid-uclogic-rdesc.c
+++ b/drivers/hid/hid-uclogic-rdesc.c
@@ -689,8 +689,8 @@ const size_t uclogic_rdesc_pen_v2_template_size =
0xA0, /* Collection (Physical), */ \
0x05, 0x09, /* Usage Page (Button), */ \
0x19, 0x01, /* Usage Minimum (01h), */ \
- 0x29, 0x02, /* Usage Maximum (02h), */ \
- 0x95, 0x02, /* Report Count (2), */ \
+ 0x29, 0x03, /* Usage Maximum (03h), */ \
+ 0x95, 0x03, /* Report Count (3), */ \
0x81, 0x02, /* Input (Variable), */ \
0x95, _padding, /* Report Count (_padding), */ \
0x81, 0x01, /* Input (Constant), */ \
@@ -699,14 +699,14 @@ const size_t uclogic_rdesc_pen_v2_template_size =
/* Fixed report descriptor for (tweaked) v1 buttonpad reports */
const __u8 uclogic_rdesc_buttonpad_v1_arr[] = {
- UCLOGIC_RDESC_BUTTONPAD_BYTES(20)
+ UCLOGIC_RDESC_BUTTONPAD_BYTES(19)
};
const size_t uclogic_rdesc_buttonpad_v1_size =
sizeof(uclogic_rdesc_buttonpad_v1_arr);
/* Fixed report descriptor for (tweaked) v2 buttonpad reports */
const __u8 uclogic_rdesc_buttonpad_v2_arr[] = {
- UCLOGIC_RDESC_BUTTONPAD_BYTES(52)
+ UCLOGIC_RDESC_BUTTONPAD_BYTES(51)
};
const size_t uclogic_rdesc_buttonpad_v2_size =
sizeof(uclogic_rdesc_buttonpad_v2_arr);
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 4/7] HID: uclogic: Split pen and frame raw event handling
2022-02-10 19:04 [PATCH 0/7] DIGImend patches, part one José Expósito
` (2 preceding siblings ...)
2022-02-10 19:04 ` [PATCH 3/7] HID: uclogic: Support Huion 13th frame button José Expósito
@ 2022-02-10 19:04 ` José Expósito
2022-02-10 19:04 ` [PATCH 5/7] HID: uclogic: Access pen/frame params directly in raw_event handling José Expósito
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: José Expósito @ 2022-02-10 19:04 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
José Expósito
From: Nikolai Kondrashov <spbnick@gmail.com>
In order to avoid ending up with a big uclogic_raw_event function,
split it in two smaller functions: uclogic_raw_event_pen for the pen
events and uclogic_raw_event_frame for the pad events.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-core.c | 195 ++++++++++++++++++++-------------
1 file changed, 120 insertions(+), 75 deletions(-)
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 850c660ec2ab..9187fd835a46 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -246,6 +246,123 @@ static int uclogic_resume(struct hid_device *hdev)
}
#endif
+/**
+ * uclogic_raw_event_pen - handle raw pen events (pen HID reports).
+ *
+ * @drvdata: Driver data.
+ * @data: Report data buffer, can be modified.
+ * @size: Report data size, bytes.
+ *
+ * Returns:
+ * Negative value on error (stops event delivery), zero for success.
+ */
+static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
+ u8 *data, int size)
+{
+ struct uclogic_params *params = &drvdata->params;
+
+ WARN_ON(drvdata == NULL);
+ WARN_ON(data == NULL && size != 0);
+
+ /* If in-range reports are inverted */
+ if (params->pen.inrange ==
+ UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) {
+ /* Invert the in-range bit */
+ data[1] ^= 0x40;
+ }
+ /*
+ * If report contains fragmented high-resolution pen
+ * coordinates
+ */
+ if (size >= 10 && params->pen.fragmented_hires) {
+ u8 pressure_low_byte;
+ u8 pressure_high_byte;
+
+ /* Lift pressure bytes */
+ pressure_low_byte = data[6];
+ pressure_high_byte = data[7];
+ /*
+ * Move Y coord to make space for high-order X
+ * coord byte
+ */
+ data[6] = data[5];
+ data[5] = data[4];
+ /* Move high-order X coord byte */
+ data[4] = data[8];
+ /* Move high-order Y coord byte */
+ data[7] = data[9];
+ /* Place pressure bytes */
+ data[8] = pressure_low_byte;
+ data[9] = pressure_high_byte;
+ }
+ /* If we need to emulate in-range detection */
+ if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
+ /* Set in-range bit */
+ data[1] |= 0x40;
+ /* (Re-)start in-range timeout */
+ mod_timer(&drvdata->inrange_timer,
+ jiffies + msecs_to_jiffies(100));
+ }
+ /* If we report tilt and Y direction is flipped */
+ if (size >= 12 && params->pen.tilt_y_flipped)
+ data[11] = -data[11];
+
+ return 0;
+}
+
+/**
+ * uclogic_raw_event_frame - handle raw frame events (frame HID reports).
+ *
+ * @drvdata: Driver data.
+ * @data: Report data buffer, can be modified.
+ * @size: Report data size, bytes.
+ *
+ * Returns:
+ * Negative value on error (stops event delivery), zero for success.
+ */
+static int uclogic_raw_event_frame(struct uclogic_drvdata *drvdata,
+ u8 *data, int size)
+{
+ struct uclogic_params *params = &drvdata->params;
+
+ WARN_ON(drvdata == NULL);
+ WARN_ON(data == NULL && size != 0);
+
+ /* If need to, and can, set pad device ID for Wacom drivers */
+ if (params->frame.dev_id_byte > 0 &&
+ params->frame.dev_id_byte < size) {
+ data[params->frame.dev_id_byte] = 0xf;
+ }
+ /* If need to, and can, read rotary encoder state change */
+ if (params->frame.re_lsb > 0 &&
+ params->frame.re_lsb / 8 < size) {
+ unsigned int byte = params->frame.re_lsb / 8;
+ unsigned int bit = params->frame.re_lsb % 8;
+
+ u8 change;
+ u8 prev_state = drvdata->re_state;
+ /* Read Gray-coded state */
+ u8 state = (data[byte] >> bit) & 0x3;
+ /* Encode state change into 2-bit signed integer */
+ if ((prev_state == 1 && state == 0) ||
+ (prev_state == 2 && state == 3)) {
+ change = 1;
+ } else if ((prev_state == 2 && state == 0) ||
+ (prev_state == 1 && state == 3)) {
+ change = 3;
+ } else {
+ change = 0;
+ }
+ /* Write change */
+ data[byte] = (data[byte] & ~((u8)3 << bit)) |
+ (change << bit);
+ /* Remember state */
+ drvdata->re_state = state;
+ }
+
+ return 0;
+}
+
static int uclogic_raw_event(struct hid_device *hdev,
struct hid_report *report,
u8 *data, int size)
@@ -265,85 +382,13 @@ static int uclogic_raw_event(struct hid_device *hdev,
data[0] = params->frame.id;
return 0;
}
- /* If in-range reports are inverted */
- if (params->pen.inrange ==
- UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) {
- /* Invert the in-range bit */
- data[1] ^= 0x40;
- }
- /*
- * If report contains fragmented high-resolution pen
- * coordinates
- */
- if (size >= 10 && params->pen.fragmented_hires) {
- u8 pressure_low_byte;
- u8 pressure_high_byte;
-
- /* Lift pressure bytes */
- pressure_low_byte = data[6];
- pressure_high_byte = data[7];
- /*
- * Move Y coord to make space for high-order X
- * coord byte
- */
- data[6] = data[5];
- data[5] = data[4];
- /* Move high-order X coord byte */
- data[4] = data[8];
- /* Move high-order Y coord byte */
- data[7] = data[9];
- /* Place pressure bytes */
- data[8] = pressure_low_byte;
- data[9] = pressure_high_byte;
- }
- /* If we need to emulate in-range detection */
- if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
- /* Set in-range bit */
- data[1] |= 0x40;
- /* (Re-)start in-range timeout */
- mod_timer(&drvdata->inrange_timer,
- jiffies + msecs_to_jiffies(100));
- }
- /* If we report tilt and Y direction is flipped */
- if (size >= 12 && params->pen.tilt_y_flipped)
- data[11] = -data[11];
+ return uclogic_raw_event_pen(drvdata, data, size);
}
/* Tweak frame control reports, if necessary */
if ((report->type == HID_INPUT_REPORT) &&
- (report->id == params->frame.id)) {
- /* If need to, and can, set pad device ID for Wacom drivers */
- if (params->frame.dev_id_byte > 0 &&
- params->frame.dev_id_byte < size) {
- data[params->frame.dev_id_byte] = 0xf;
- }
- /* If need to, and can, read rotary encoder state change */
- if (params->frame.re_lsb > 0 &&
- params->frame.re_lsb / 8 < size) {
- unsigned int byte = params->frame.re_lsb / 8;
- unsigned int bit = params->frame.re_lsb % 8;
-
- u8 change;
- u8 prev_state = drvdata->re_state;
- /* Read Gray-coded state */
- u8 state = (data[byte] >> bit) & 0x3;
- /* Encode state change into 2-bit signed integer */
- if ((prev_state == 1 && state == 0) ||
- (prev_state == 2 && state == 3)) {
- change = 1;
- } else if ((prev_state == 2 && state == 0) ||
- (prev_state == 1 && state == 3)) {
- change = 3;
- } else {
- change = 0;
- }
- /* Write change */
- data[byte] = (data[byte] & ~((u8)3 << bit)) |
- (change << bit);
- /* Remember state */
- drvdata->re_state = state;
- }
- }
+ (report->id == params->frame.id))
+ return uclogic_raw_event_frame(drvdata, data, size);
return 0;
}
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 5/7] HID: uclogic: Access pen/frame params directly in raw_event handling
2022-02-10 19:04 [PATCH 0/7] DIGImend patches, part one José Expósito
` (3 preceding siblings ...)
2022-02-10 19:04 ` [PATCH 4/7] HID: uclogic: Split pen and frame raw event handling José Expósito
@ 2022-02-10 19:04 ` José Expósito
2022-02-10 19:04 ` [PATCH 6/7] HID: uclogic: Skip non-input raw events earlier José Expósito
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: José Expósito @ 2022-02-10 19:04 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
José Expósito
From: Nikolai Kondrashov <spbnick@gmail.com>
Simplify the raw event handling code by accessing the
uclogic_params_pen/uclogic_params_frame structs directly.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-core.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 9187fd835a46..56b76d9b46af 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -259,13 +259,13 @@ static int uclogic_resume(struct hid_device *hdev)
static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
u8 *data, int size)
{
- struct uclogic_params *params = &drvdata->params;
+ struct uclogic_params_pen *pen = &drvdata->params.pen;
WARN_ON(drvdata == NULL);
WARN_ON(data == NULL && size != 0);
/* If in-range reports are inverted */
- if (params->pen.inrange ==
+ if (pen->inrange ==
UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) {
/* Invert the in-range bit */
data[1] ^= 0x40;
@@ -274,7 +274,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
* If report contains fragmented high-resolution pen
* coordinates
*/
- if (size >= 10 && params->pen.fragmented_hires) {
+ if (size >= 10 && pen->fragmented_hires) {
u8 pressure_low_byte;
u8 pressure_high_byte;
@@ -296,7 +296,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
data[9] = pressure_high_byte;
}
/* If we need to emulate in-range detection */
- if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
+ if (pen->inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
/* Set in-range bit */
data[1] |= 0x40;
/* (Re-)start in-range timeout */
@@ -304,7 +304,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
jiffies + msecs_to_jiffies(100));
}
/* If we report tilt and Y direction is flipped */
- if (size >= 12 && params->pen.tilt_y_flipped)
+ if (size >= 12 && pen->tilt_y_flipped)
data[11] = -data[11];
return 0;
@@ -323,21 +323,19 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
static int uclogic_raw_event_frame(struct uclogic_drvdata *drvdata,
u8 *data, int size)
{
- struct uclogic_params *params = &drvdata->params;
+ struct uclogic_params_frame *frame = &drvdata->params.frame;
WARN_ON(drvdata == NULL);
WARN_ON(data == NULL && size != 0);
/* If need to, and can, set pad device ID for Wacom drivers */
- if (params->frame.dev_id_byte > 0 &&
- params->frame.dev_id_byte < size) {
- data[params->frame.dev_id_byte] = 0xf;
+ if (frame->dev_id_byte > 0 && frame->dev_id_byte < size) {
+ data[frame->dev_id_byte] = 0xf;
}
/* If need to, and can, read rotary encoder state change */
- if (params->frame.re_lsb > 0 &&
- params->frame.re_lsb / 8 < size) {
- unsigned int byte = params->frame.re_lsb / 8;
- unsigned int bit = params->frame.re_lsb % 8;
+ if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) {
+ unsigned int byte = frame->re_lsb / 8;
+ unsigned int bit = frame->re_lsb % 8;
u8 change;
u8 prev_state = drvdata->re_state;
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 6/7] HID: uclogic: Skip non-input raw events earlier
2022-02-10 19:04 [PATCH 0/7] DIGImend patches, part one José Expósito
` (4 preceding siblings ...)
2022-02-10 19:04 ` [PATCH 5/7] HID: uclogic: Access pen/frame params directly in raw_event handling José Expósito
@ 2022-02-10 19:04 ` José Expósito
2022-02-10 19:04 ` [PATCH 7/7] HID: uclogic: Handle virtual frame reports José Expósito
2022-02-16 15:43 ` [PATCH 0/7] DIGImend patches, part one Jiri Kosina
7 siblings, 0 replies; 9+ messages in thread
From: José Expósito @ 2022-02-10 19:04 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
José Expósito
From: Nikolai Kondrashov <spbnick@gmail.com>
Early return when a non-input raw event is received to simplify the
logic present in uclogic_raw_event.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-core.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 56b76d9b46af..8aac3f7a9cda 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -368,9 +368,12 @@ static int uclogic_raw_event(struct hid_device *hdev,
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
struct uclogic_params *params = &drvdata->params;
+ /* Do not handle anything but input reports */
+ if (report->type != HID_INPUT_REPORT)
+ return 0;
+
/* Tweak pen reports, if necessary */
if (!params->pen_unused &&
- (report->type == HID_INPUT_REPORT) &&
(report->id == params->pen.id) &&
(size >= 2)) {
/* If it's the "virtual" frame controls report */
@@ -384,8 +387,7 @@ static int uclogic_raw_event(struct hid_device *hdev,
}
/* Tweak frame control reports, if necessary */
- if ((report->type == HID_INPUT_REPORT) &&
- (report->id == params->frame.id))
+ if (report->id == params->frame.id)
return uclogic_raw_event_frame(drvdata, data, size);
return 0;
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 7/7] HID: uclogic: Handle virtual frame reports
2022-02-10 19:04 [PATCH 0/7] DIGImend patches, part one José Expósito
` (5 preceding siblings ...)
2022-02-10 19:04 ` [PATCH 6/7] HID: uclogic: Skip non-input raw events earlier José Expósito
@ 2022-02-10 19:04 ` José Expósito
2022-02-16 15:43 ` [PATCH 0/7] DIGImend patches, part one Jiri Kosina
7 siblings, 0 replies; 9+ messages in thread
From: José Expósito @ 2022-02-10 19:04 UTC (permalink / raw)
To: jikos
Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel,
José Expósito
From: Nikolai Kondrashov <spbnick@gmail.com>
Explicitly change report ID to virtual ID and handle virtual frame
reports as real for consistency.
Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-core.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 8aac3f7a9cda..73d79d149869 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -365,6 +365,7 @@ static int uclogic_raw_event(struct hid_device *hdev,
struct hid_report *report,
u8 *data, int size)
{
+ unsigned int report_id = report->id;
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
struct uclogic_params *params = &drvdata->params;
@@ -374,20 +375,20 @@ static int uclogic_raw_event(struct hid_device *hdev,
/* Tweak pen reports, if necessary */
if (!params->pen_unused &&
- (report->id == params->pen.id) &&
+ (report_id == params->pen.id) &&
(size >= 2)) {
/* If it's the "virtual" frame controls report */
if (params->frame.id != 0 &&
data[1] & params->pen_frame_flag) {
/* Change to virtual frame controls report ID */
- data[0] = params->frame.id;
- return 0;
+ report_id = data[0] = params->frame.id;
+ } else {
+ return uclogic_raw_event_pen(drvdata, data, size);
}
- return uclogic_raw_event_pen(drvdata, data, size);
}
/* Tweak frame control reports, if necessary */
- if (report->id == params->frame.id)
+ if (report_id == params->frame.id)
return uclogic_raw_event_frame(drvdata, data, size);
return 0;
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 0/7] DIGImend patches, part one
2022-02-10 19:04 [PATCH 0/7] DIGImend patches, part one José Expósito
` (6 preceding siblings ...)
2022-02-10 19:04 ` [PATCH 7/7] HID: uclogic: Handle virtual frame reports José Expósito
@ 2022-02-16 15:43 ` Jiri Kosina
7 siblings, 0 replies; 9+ messages in thread
From: Jiri Kosina @ 2022-02-16 15:43 UTC (permalink / raw)
To: José Expósito
Cc: benjamin.tissoires, spbnick, linux-input, linux-kernel
On Thu, 10 Feb 2022, José Expósito wrote:
> I'm working on the UC Logic driver to add support for my tablet.
> After some work, I noticed that I needed some patches from the
> DIGImend project [1].
>
> Instead of cherry picking what I needed, I decided to go the hard
> way and upstream every change present in DIGImend but missing in
> the kernel with the intention of making development easier in the
> future for everyone and providing better hardware support.
>
> In a private conversation with DIGImend's maintainer, Nikolai
> Kondrashov, I asked him for permission to upstream his changes and
> he said it was fine :) All credit goes to him, I only fixed his
> patches so they apply, fixed minor checkpatch errors, squashed
> related changes and reviewed and tested them when my hardware
> allowed me to.
>
> This is the first series of patches from DIGImend. There are 37
> patches in total [2], but I can imagine nobody wants to review such
> a long series, so I'll be sending small groups of related patches...
Thanks a lot for consideration :)
> Unless someone feels brave and tells me to send all of them ;)
Definitely not me :)
The patches look good to me, and I see Nikolai is CCed, so I've now queued
them in hid.git#for-5.18/uclogic
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 9+ messages in thread