diff options
Diffstat (limited to 'drivers/hid/hid-uclogic-params.h')
| -rw-r--r-- | drivers/hid/hid-uclogic-params.h | 203 |
1 files changed, 140 insertions, 63 deletions
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index ba48b1c7a0e5..c84ff17fb5d5 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -18,6 +18,10 @@ #include <linux/usb.h> #include <linux/hid.h> +#include <linux/list.h> + +#define UCLOGIC_MOUSE_FRAME_QUIRK BIT(0) +#define UCLOGIC_BATTERY_QUIRK BIT(1) /* Types of pen in-range reporting */ enum uclogic_params_pen_inrange { @@ -29,9 +33,33 @@ enum uclogic_params_pen_inrange { UCLOGIC_PARAMS_PEN_INRANGE_NONE, }; -/* Convert a pen in-range reporting type to a string */ -extern const char *uclogic_params_pen_inrange_to_str( - enum uclogic_params_pen_inrange inrange); +/* Types of frames */ +enum uclogic_params_frame_type { + /* Frame with buttons */ + UCLOGIC_PARAMS_FRAME_BUTTONS = 0, + /* Frame with buttons and a dial */ + UCLOGIC_PARAMS_FRAME_DIAL, + /* Frame with buttons and a mouse (shaped as a dial + touchpad) */ + UCLOGIC_PARAMS_FRAME_MOUSE, +}; + +/* + * Pen report's subreport data. + */ +struct uclogic_params_pen_subreport { + /* + * The value of the second byte of the pen report indicating this + * subreport. If zero, the subreport should be considered invalid and + * not matched. + */ + __u8 value; + + /* + * The ID to be assigned to the report, if the second byte of the pen + * report is equal to "value". Only valid if "value" is not zero. + */ + __u8 id; +}; /* * Tablet interface's pen input parameters. @@ -43,10 +71,15 @@ extern const char *uclogic_params_pen_inrange_to_str( */ struct uclogic_params_pen { /* - * Pointer to report descriptor describing the inputs. - * Allocated with kmalloc. + * True if pen usage is invalid for this interface and should be + * ignored, false otherwise. */ - __u8 *desc_ptr; + bool usage_invalid; + /* + * Pointer to report descriptor part describing the pen inputs. + * Allocated with kmalloc. NULL if the part is not specified. + */ + const __u8 *desc_ptr; /* * Size of the report descriptor. * Only valid, if "desc_ptr" is not NULL. @@ -54,6 +87,8 @@ struct uclogic_params_pen { unsigned int desc_size; /* Report ID, if reports should be tweaked, zero if not */ unsigned int id; + /* The list of subreports, only valid if "id" is not zero */ + struct uclogic_params_pen_subreport subreport_list[3]; /* Type of in-range reporting, only valid if "id" is not zero */ enum uclogic_params_pen_inrange inrange; /* @@ -62,6 +97,17 @@ 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; + /* + * True, if reports include fragmented high resolution X coords. + * This moves bytes 10-11 to the LSB of the X coordinate. + */ + bool fragmented_hires2; }; /* @@ -74,10 +120,10 @@ struct uclogic_params_pen { */ struct uclogic_params_frame { /* - * Pointer to report descriptor describing the inputs. - * Allocated with kmalloc. + * Pointer to report descriptor part describing the frame inputs. + * Allocated with kmalloc. NULL if the part is not specified. */ - __u8 *desc_ptr; + const __u8 *desc_ptr; /* * Size of the report descriptor. * Only valid, if "desc_ptr" is not NULL. @@ -88,6 +134,10 @@ struct uclogic_params_frame { */ 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 * byte boundary. Zero if not present. Only valid if "id" is not zero. @@ -96,10 +146,56 @@ struct uclogic_params_frame { /* * 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 - * if no changes to the report should be made. Only valid if "id" is - * not zero. + * if no changes to the report should be made. The ID byte will be set + * to zero whenever the byte pointed by "touch_byte" is zero, if + * the latter is valid. Only valid if "id" is not zero. */ unsigned int dev_id_byte; + /* + * Offset of the touch ring/strip 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_byte; + /* + * The value to anchor the reversed touch ring/strip reports at. + * I.e. one, if the reports should be flipped without offset. + * Zero if no reversal should be done. + * Only valid if "touch_byte" is valid and not zero. + */ + __s8 touch_flip_at; + /* + * Maximum value of the touch ring/strip report around which the value + * should be wrapped when flipping according to "touch_flip_at". + * The minimum valid value is considered to be one, with zero being + * out-of-proximity (finger lift) value. + * Only valid if "touch_flip_at" is valid and not zero. + */ + __s8 touch_max; + /* + * Offset of the bitmap dial byte, in the report. Zero if not present. + * Only valid if "id" is not zero. A bitmap dial sends reports with a + * dedicated bit per direction: 1 means clockwise rotation, 2 means + * counterclockwise, as opposed to the normal 1 and -1. + */ + unsigned int bitmap_dial_byte; + /* + * Destination offset for the second bitmap dial byte, if the tablet + * supports a second dial at all. + */ + unsigned int bitmap_second_dial_destination_byte; +}; + +/* + * List of works to be performed when a certain raw event is received. + */ +struct uclogic_raw_event_hook { + struct hid_device *hdev; + __u8 *event; + size_t size; + struct work_struct work; + struct list_head list; }; /* @@ -126,82 +222,63 @@ struct uclogic_params { * allocated with kmalloc. NULL if no common part is needed. * Only valid, if "invalid" is false. */ - __u8 *desc_ptr; + const __u8 *desc_ptr; /* * Size of the common part of the replacement report descriptor. - * Only valid, if "desc_ptr" is not NULL. + * Only valid, if "desc_ptr" is valid and not NULL. */ unsigned int desc_size; /* - * True, if pen usage in report descriptor is invalid, when present. + * Pen parameters and optional report descriptor part. * Only valid, if "invalid" is false. */ - bool pen_unused; + struct uclogic_params_pen pen; /* - * Pen parameters and optional report descriptor part. - * Only valid if "pen_unused" is valid and false. + * The list of frame control parameters and optional report descriptor + * parts. Only valid, if "invalid" is false. */ - struct uclogic_params_pen pen; + struct uclogic_params_frame frame_list[3]; /* - * Frame control parameters and optional report descriptor part. - * Only valid, if "invalid" is false. + * List of event hooks. */ - struct uclogic_params_frame frame; + struct uclogic_raw_event_hook *event_hooks; +}; + +/* Driver data */ +struct uclogic_drvdata { + /* Interface parameters */ + struct uclogic_params params; + /* Pointer to the replacement report descriptor. NULL if none. */ + const __u8 *desc_ptr; /* - * Bitmask matching frame controls "sub-report" flag in the second - * byte of the pen report, or zero if it's not expected. - * Only valid if both "pen" and "frame" are valid, and "frame.id" is - * not zero. + * Size of the replacement report descriptor. + * Only valid if desc_ptr is not NULL */ - __u8 pen_frame_flag; + unsigned int desc_size; + /* Pen input device */ + struct input_dev *pen_input; + /* In-range timer */ + struct timer_list inrange_timer; + /* Last rotary encoder state, or U8_MAX for none */ + u8 re_state; + /* Device quirks */ + unsigned long quirks; }; /* Initialize a tablet interface and discover its parameters */ extern int uclogic_params_init(struct uclogic_params *params, struct hid_device *hdev); -/* Tablet interface parameters *printf format string */ -#define UCLOGIC_PARAMS_FMT_STR \ - ".invalid = %s\n" \ - ".desc_ptr = %p\n" \ - ".desc_size = %u\n" \ - ".pen_unused = %s\n" \ - ".pen.desc_ptr = %p\n" \ - ".pen.desc_size = %u\n" \ - ".pen.id = %u\n" \ - ".pen.inrange = %s\n" \ - ".pen.fragmented_hires = %s\n" \ - ".frame.desc_ptr = %p\n" \ - ".frame.desc_size = %u\n" \ - ".frame.id = %u\n" \ - ".frame.re_lsb = %u\n" \ - ".frame.dev_id_byte = %u\n" \ - ".pen_frame_flag = 0x%02x\n" - -/* Tablet interface parameters *printf format arguments */ -#define UCLOGIC_PARAMS_FMT_ARGS(_params) \ - ((_params)->invalid ? "true" : "false"), \ - (_params)->desc_ptr, \ - (_params)->desc_size, \ - ((_params)->pen_unused ? "true" : "false"), \ - (_params)->pen.desc_ptr, \ - (_params)->pen.desc_size, \ - (_params)->pen.id, \ - uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \ - ((_params)->pen.fragmented_hires ? "true" : "false"), \ - (_params)->frame.desc_ptr, \ - (_params)->frame.desc_size, \ - (_params)->frame.id, \ - (_params)->frame.re_lsb, \ - (_params)->frame.dev_id_byte, \ - (_params)->pen_frame_flag - /* Get a replacement report descriptor for a tablet's interface. */ extern int uclogic_params_get_desc(const struct uclogic_params *params, - __u8 **pdesc, + const __u8 **pdesc, unsigned int *psize); /* Free resources used by tablet interface's parameters */ extern void uclogic_params_cleanup(struct uclogic_params *params); +/* Dump tablet interface parameters with hid_dbg() */ +extern void uclogic_params_hid_dbg(const struct hid_device *hdev, + const struct uclogic_params *params); + #endif /* _HID_UCLOGIC_PARAMS_H */ |
