Commit d170e8e0 authored by Nikolai Kondrashov's avatar Nikolai Kondrashov Committed by Jiri Kosina

HID: uclogic: Add support for touch ring reports

Add support for touch ring to UC-Logic driver. The touch ring reports
can be flipped around a specific point to match the orientation and
direction reported by the Wacom drivers. The proximity will also be
reported similar to the Wacom drivers.
Signed-off-by: default avatarNikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: default avatarJosé Expósito <jose.exposito89@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 5e206459
...@@ -90,6 +90,8 @@ static int uclogic_input_configured(struct hid_device *hdev, ...@@ -90,6 +90,8 @@ static int uclogic_input_configured(struct hid_device *hdev,
const char *suffix = NULL; const char *suffix = NULL;
struct hid_field *field; struct hid_field *field;
size_t len; size_t len;
size_t i;
const struct uclogic_params_frame *frame;
/* no report associated (HID_QUIRK_MULTI_INPUT not set) */ /* no report associated (HID_QUIRK_MULTI_INPUT not set) */
if (!hi->report) if (!hi->report)
...@@ -104,6 +106,19 @@ static int uclogic_input_configured(struct hid_device *hdev, ...@@ -104,6 +106,19 @@ static int uclogic_input_configured(struct hid_device *hdev,
drvdata->pen_input = hi->input; drvdata->pen_input = hi->input;
} }
/* If it's one of the frame devices */
for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) {
frame = &params->frame_list[i];
if (hi->report->id == frame->id) {
/*
* Disable EV_MSC reports for touch ring interfaces to
* make the Wacom driver pickup touch ring extents
*/
if (frame->touch_ring_byte > 0)
__clear_bit(EV_MSC, hi->input->evbit);
}
}
field = hi->report->field[0]; field = hi->report->field[0];
switch (field->application) { switch (field->application) {
...@@ -313,8 +328,16 @@ static int uclogic_raw_event_frame( ...@@ -313,8 +328,16 @@ static int uclogic_raw_event_frame(
/* If need to, and can, set pad device ID for Wacom drivers */ /* If need to, and can, set pad device ID for Wacom drivers */
if (frame->dev_id_byte > 0 && frame->dev_id_byte < size) { if (frame->dev_id_byte > 0 && frame->dev_id_byte < size) {
/* If we also have a touch ring and the finger left it */
if (frame->touch_ring_byte > 0 &&
frame->touch_ring_byte < size &&
data[frame->touch_ring_byte] == 0) {
data[frame->dev_id_byte] = 0;
} else {
data[frame->dev_id_byte] = 0xf; data[frame->dev_id_byte] = 0xf;
} }
}
/* If need to, and can, read rotary encoder state change */ /* If need to, and can, read rotary encoder state change */
if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) { if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) {
unsigned int byte = frame->re_lsb / 8; unsigned int byte = frame->re_lsb / 8;
...@@ -341,6 +364,20 @@ static int uclogic_raw_event_frame( ...@@ -341,6 +364,20 @@ static int uclogic_raw_event_frame(
drvdata->re_state = state; drvdata->re_state = state;
} }
/* If need to, and can, transform the touch ring reports */
if (frame->touch_ring_byte > 0 && frame->touch_ring_byte < size &&
frame->touch_ring_flip_at != 0) {
__s8 value = data[frame->touch_ring_byte];
if (value != 0) {
value = frame->touch_ring_flip_at - value;
if (value < 0)
value = frame->touch_ring_max + value;
data[frame->touch_ring_byte] = value;
}
}
return 0; return 0;
} }
......
...@@ -123,10 +123,32 @@ struct uclogic_params_frame { ...@@ -123,10 +123,32 @@ struct uclogic_params_frame {
/* /*
* Offset of the Wacom-style device ID byte in the report, to be set * Offset of the Wacom-style device ID byte in the report, to be set
* to pad device ID (0xf), for compatibility with Wacom drivers. Zero * to pad device ID (0xf), for compatibility with Wacom drivers. Zero
* if no changes to the report should be made. Only valid if "id" is * if no changes to the report should be made. The ID byte will be set
* not zero. * to zero whenever the byte pointed by "touch_ring_byte" is zero, if
* the latter is valid. Only valid if "id" is not zero.
*/ */
unsigned int dev_id_byte; unsigned int dev_id_byte;
/*
* Offset of the touch ring state byte, in the report.
* Zero if not present. If dev_id_byte is also valid and non-zero,
* then the device ID byte will be cleared when the byte pointed to by
* this offset is zero. Only valid if "id" is not zero.
*/
unsigned int touch_ring_byte;
/*
* Maximum value of the touch ring report.
* The minimum valid value is considered to be one,
* with zero being out-of-proximity (finger lift) value.
*/
__s8 touch_ring_max;
/*
* The value to anchor the reversed reports at.
* I.e. one, if the reports should be flipped without offset.
* Zero if no reversal should be done.
*/
__s8 touch_ring_flip_at;
}; };
/* /*
...@@ -191,7 +213,10 @@ extern int uclogic_params_init(struct uclogic_params *params, ...@@ -191,7 +213,10 @@ extern int uclogic_params_init(struct uclogic_params *params,
".frame_list[0].desc_size = %u\n" \ ".frame_list[0].desc_size = %u\n" \
".frame_list[0].id = %u\n" \ ".frame_list[0].id = %u\n" \
".frame_list[0].re_lsb = %u\n" \ ".frame_list[0].re_lsb = %u\n" \
".frame_list[0].dev_id_byte = %u\n" ".frame_list[0].dev_id_byte = %u\n" \
".frame_list[0].touch_ring_byte = %u\n" \
".frame_list[0].touch_ring_max = %hhd\n" \
".frame_list[0].touch_ring_flip_at = %hhd\n"
/* Tablet interface parameters *printf format arguments */ /* Tablet interface parameters *printf format arguments */
#define UCLOGIC_PARAMS_FMT_ARGS(_params) \ #define UCLOGIC_PARAMS_FMT_ARGS(_params) \
...@@ -210,7 +235,10 @@ extern int uclogic_params_init(struct uclogic_params *params, ...@@ -210,7 +235,10 @@ extern int uclogic_params_init(struct uclogic_params *params,
(_params)->frame_list[0].desc_size, \ (_params)->frame_list[0].desc_size, \
(_params)->frame_list[0].id, \ (_params)->frame_list[0].id, \
(_params)->frame_list[0].re_lsb, \ (_params)->frame_list[0].re_lsb, \
(_params)->frame_list[0].dev_id_byte (_params)->frame_list[0].dev_id_byte, \
(_params)->frame_list[0].touch_ring_byte, \
(_params)->frame_list[0].touch_ring_max, \
(_params)->frame_list[0].touch_ring_flip_at
/* Get a replacement report descriptor for a tablet's interface. */ /* Get a replacement report descriptor for a tablet's interface. */
extern int uclogic_params_get_desc(const struct uclogic_params *params, extern int uclogic_params_get_desc(const struct uclogic_params *params,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment