提交 d9c57a70 编写于 作者: B Benjamin Tissoires 提交者: Jiri Kosina

HID: multitouch: export a quirk for the button handling of touchpads

Instead of using the class name, we better have a specific quirk for it
so other classes can make use of it.
Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: NPeter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 183b6366
...@@ -74,6 +74,7 @@ MODULE_LICENSE("GPL"); ...@@ -74,6 +74,7 @@ MODULE_LICENSE("GPL");
#define MT_QUIRK_TOUCH_SIZE_SCALING BIT(15) #define MT_QUIRK_TOUCH_SIZE_SCALING BIT(15)
#define MT_QUIRK_STICKY_FINGERS BIT(16) #define MT_QUIRK_STICKY_FINGERS BIT(16)
#define MT_QUIRK_ASUS_CUSTOM_UP BIT(17) #define MT_QUIRK_ASUS_CUSTOM_UP BIT(17)
#define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18)
#define MT_INPUTMODE_TOUCHSCREEN 0x02 #define MT_INPUTMODE_TOUCHSCREEN 0x02
#define MT_INPUTMODE_TOUCHPAD 0x03 #define MT_INPUTMODE_TOUCHPAD 0x03
...@@ -241,7 +242,8 @@ static struct mt_class mt_classes[] = { ...@@ -241,7 +242,8 @@ static struct mt_class mt_classes[] = {
MT_QUIRK_IGNORE_DUPLICATES | MT_QUIRK_IGNORE_DUPLICATES |
MT_QUIRK_HOVERING | MT_QUIRK_HOVERING |
MT_QUIRK_CONTACT_CNT_ACCURATE | MT_QUIRK_CONTACT_CNT_ACCURATE |
MT_QUIRK_STICKY_FINGERS }, MT_QUIRK_STICKY_FINGERS |
MT_QUIRK_WIN8_PTP_BUTTONS },
{ .name = MT_CLS_EXPORT_ALL_INPUTS, { .name = MT_CLS_EXPORT_ALL_INPUTS,
.quirks = MT_QUIRK_ALWAYS_VALID | .quirks = MT_QUIRK_ALWAYS_VALID |
MT_QUIRK_CONTACT_CNT_ACCURATE, MT_QUIRK_CONTACT_CNT_ACCURATE,
...@@ -250,7 +252,8 @@ static struct mt_class mt_classes[] = { ...@@ -250,7 +252,8 @@ static struct mt_class mt_classes[] = {
.quirks = MT_QUIRK_ALWAYS_VALID | .quirks = MT_QUIRK_ALWAYS_VALID |
MT_QUIRK_IGNORE_DUPLICATES | MT_QUIRK_IGNORE_DUPLICATES |
MT_QUIRK_HOVERING | MT_QUIRK_HOVERING |
MT_QUIRK_CONTACT_CNT_ACCURATE, MT_QUIRK_CONTACT_CNT_ACCURATE |
MT_QUIRK_WIN8_PTP_BUTTONS,
.export_all_inputs = true }, .export_all_inputs = true },
/* /*
...@@ -659,8 +662,7 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, ...@@ -659,8 +662,7 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
* MS PTP spec says that external buttons left and right have * MS PTP spec says that external buttons left and right have
* usages 2 and 3. * usages 2 and 3.
*/ */
if ((cls->name == MT_CLS_WIN_8 || if ((cls->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) &&
cls->name == MT_CLS_WIN_8_DUAL) &&
field->application == HID_DG_TOUCHPAD && field->application == HID_DG_TOUCHPAD &&
(usage->hid & HID_USAGE) > 1) (usage->hid & HID_USAGE) > 1)
code--; code--;
...@@ -772,9 +774,7 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) ...@@ -772,9 +774,7 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
*/ */
static void mt_sync_frame(struct mt_device *td, struct input_dev *input) static void mt_sync_frame(struct mt_device *td, struct input_dev *input)
{ {
__s32 cls = td->mtclass.name; if (td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS)
if (cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL)
input_event(input, EV_KEY, BTN_LEFT, td->left_button_state); input_event(input, EV_KEY, BTN_LEFT, td->left_button_state);
input_mt_sync_frame(input); input_mt_sync_frame(input);
...@@ -826,7 +826,6 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, ...@@ -826,7 +826,6 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field,
bool first_packet) bool first_packet)
{ {
struct mt_device *td = hid_get_drvdata(hid); struct mt_device *td = hid_get_drvdata(hid);
__s32 cls = td->mtclass.name;
__s32 quirks = td->mtclass.quirks; __s32 quirks = td->mtclass.quirks;
struct input_dev *input = field->hidinput->input; struct input_dev *input = field->hidinput->input;
...@@ -904,7 +903,7 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, ...@@ -904,7 +903,7 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field,
* non finger/touch events in the first_packet of * non finger/touch events in the first_packet of
* a (possible) multi-packet frame. * a (possible) multi-packet frame.
*/ */
if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) && if ((quirks & MT_QUIRK_WIN8_PTP_BUTTONS) &&
!first_packet) !first_packet)
return; return;
...@@ -915,7 +914,7 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, ...@@ -915,7 +914,7 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field,
* BTN_LEFT if either is pressed, so we or all values * BTN_LEFT if either is pressed, so we or all values
* together and report the result in mt_sync_frame(). * together and report the result in mt_sync_frame().
*/ */
if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) && if ((quirks & MT_QUIRK_WIN8_PTP_BUTTONS) &&
usage->type == EV_KEY && usage->code == BTN_LEFT) { usage->type == EV_KEY && usage->code == BTN_LEFT) {
td->left_button_state |= value; td->left_button_state |= value;
return; return;
...@@ -939,7 +938,6 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, ...@@ -939,7 +938,6 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field,
static void mt_touch_report(struct hid_device *hid, struct hid_report *report) static void mt_touch_report(struct hid_device *hid, struct hid_report *report)
{ {
struct mt_device *td = hid_get_drvdata(hid); struct mt_device *td = hid_get_drvdata(hid);
__s32 cls = td->mtclass.name;
struct hid_field *field; struct hid_field *field;
bool first_packet; bool first_packet;
unsigned count; unsigned count;
...@@ -968,7 +966,7 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report) ...@@ -968,7 +966,7 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report)
* of a possible multi-packet frame be checking that the * of a possible multi-packet frame be checking that the
* timestamp has changed. * timestamp has changed.
*/ */
if ((cls == MT_CLS_WIN_8 || cls == MT_CLS_WIN_8_DUAL) && if ((td->mtclass.quirks & MT_QUIRK_WIN8_PTP_BUTTONS) &&
td->num_received == 0 && td->prev_scantime != scantime) td->num_received == 0 && td->prev_scantime != scantime)
td->num_expected = value; td->num_expected = value;
/* A non 0 contact count always indicates a first packet */ /* A non 0 contact count always indicates a first packet */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册