diff options
| -rw-r--r-- | drivers/hid/wacom_wac.c | 76 | ||||
| -rw-r--r-- | drivers/hid/wacom_wac.h | 1 |
2 files changed, 52 insertions, 25 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 7a748a71d149..b1a9a3ca6d56 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c | |||
| @@ -1591,18 +1591,13 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, | |||
| 1591 | } | 1591 | } |
| 1592 | } | 1592 | } |
| 1593 | 1593 | ||
| 1594 | static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field, | 1594 | static void wacom_wac_pad_battery_event(struct hid_device *hdev, struct hid_field *field, |
| 1595 | struct hid_usage *usage, __s32 value) | 1595 | struct hid_usage *usage, __s32 value) |
| 1596 | { | 1596 | { |
| 1597 | struct wacom *wacom = hid_get_drvdata(hdev); | 1597 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1598 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | 1598 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1599 | struct input_dev *input = wacom_wac->pad_input; | ||
| 1600 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); | 1599 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
| 1601 | 1600 | ||
| 1602 | if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) { | ||
| 1603 | wacom_wac->hid_data.inrange_state |= value; | ||
| 1604 | } | ||
| 1605 | |||
| 1606 | switch (equivalent_usage) { | 1601 | switch (equivalent_usage) { |
| 1607 | case WACOM_HID_WD_BATTERY_LEVEL: | 1602 | case WACOM_HID_WD_BATTERY_LEVEL: |
| 1608 | wacom_wac->hid_data.battery_capacity = value; | 1603 | wacom_wac->hid_data.battery_capacity = value; |
| @@ -1614,11 +1609,28 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field | |||
| 1614 | wacom_wac->hid_data.ps_connected = value; | 1609 | wacom_wac->hid_data.ps_connected = value; |
| 1615 | wacom_wac->hid_data.bat_connected = 1; | 1610 | wacom_wac->hid_data.bat_connected = 1; |
| 1616 | break; | 1611 | break; |
| 1612 | } | ||
| 1613 | } | ||
| 1617 | 1614 | ||
| 1615 | static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field, | ||
| 1616 | struct hid_usage *usage, __s32 value) | ||
| 1617 | { | ||
| 1618 | struct wacom *wacom = hid_get_drvdata(hdev); | ||
| 1619 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | ||
| 1620 | struct input_dev *input = wacom_wac->pad_input; | ||
| 1621 | struct wacom_features *features = &wacom_wac->features; | ||
| 1622 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); | ||
| 1623 | |||
| 1624 | if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) { | ||
| 1625 | wacom_wac->hid_data.inrange_state |= value; | ||
| 1626 | } | ||
| 1627 | |||
| 1628 | switch (equivalent_usage) { | ||
| 1618 | case WACOM_HID_WD_TOUCHRINGSTATUS: | 1629 | case WACOM_HID_WD_TOUCHRINGSTATUS: |
| 1619 | break; | 1630 | break; |
| 1620 | 1631 | ||
| 1621 | default: | 1632 | default: |
| 1633 | features->input_event_flag = true; | ||
| 1622 | input_event(input, usage->type, usage->code, value); | 1634 | input_event(input, usage->type, usage->code, value); |
| 1623 | break; | 1635 | break; |
| 1624 | } | 1636 | } |
| @@ -1633,21 +1645,12 @@ static void wacom_wac_pad_pre_report(struct hid_device *hdev, | |||
| 1633 | wacom_wac->hid_data.inrange_state = 0; | 1645 | wacom_wac->hid_data.inrange_state = 0; |
| 1634 | } | 1646 | } |
| 1635 | 1647 | ||
| 1636 | static void wacom_wac_pad_report(struct hid_device *hdev, | 1648 | static void wacom_wac_pad_battery_report(struct hid_device *hdev, |
| 1637 | struct hid_report *report) | 1649 | struct hid_report *report) |
| 1638 | { | 1650 | { |
| 1639 | struct wacom *wacom = hid_get_drvdata(hdev); | 1651 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1640 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | 1652 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1641 | struct wacom_features *features = &wacom_wac->features; | 1653 | struct wacom_features *features = &wacom_wac->features; |
| 1642 | struct input_dev *input = wacom_wac->pad_input; | ||
| 1643 | bool active = wacom_wac->hid_data.inrange_state != 0; | ||
| 1644 | |||
| 1645 | /* | ||
| 1646 | * don't report prox for events like accelerometer | ||
| 1647 | * or battery status | ||
| 1648 | */ | ||
| 1649 | if (wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) | ||
| 1650 | input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0); | ||
| 1651 | 1654 | ||
| 1652 | if (features->quirks & WACOM_QUIRK_BATTERY) { | 1655 | if (features->quirks & WACOM_QUIRK_BATTERY) { |
| 1653 | int capacity = wacom_wac->hid_data.battery_capacity; | 1656 | int capacity = wacom_wac->hid_data.battery_capacity; |
| @@ -1658,8 +1661,27 @@ static void wacom_wac_pad_report(struct hid_device *hdev, | |||
| 1658 | wacom_notify_battery(wacom_wac, capacity, charging, | 1661 | wacom_notify_battery(wacom_wac, capacity, charging, |
| 1659 | connected, powered); | 1662 | connected, powered); |
| 1660 | } | 1663 | } |
| 1664 | } | ||
| 1661 | 1665 | ||
| 1662 | input_sync(input); | 1666 | static void wacom_wac_pad_report(struct hid_device *hdev, |
| 1667 | struct hid_report *report) | ||
| 1668 | { | ||
| 1669 | struct wacom *wacom = hid_get_drvdata(hdev); | ||
| 1670 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | ||
| 1671 | struct wacom_features *features = &wacom_wac->features; | ||
| 1672 | struct input_dev *input = wacom_wac->pad_input; | ||
| 1673 | bool active = wacom_wac->hid_data.inrange_state != 0; | ||
| 1674 | |||
| 1675 | /* report prox for expresskey events */ | ||
| 1676 | if (wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) { | ||
| 1677 | features->input_event_flag = true; | ||
| 1678 | input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0); | ||
| 1679 | } | ||
| 1680 | |||
| 1681 | if (features->input_event_flag) { | ||
| 1682 | features->input_event_flag = false; | ||
| 1683 | input_sync(input); | ||
| 1684 | } | ||
| 1663 | } | 1685 | } |
| 1664 | 1686 | ||
| 1665 | static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, | 1687 | static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, |
| @@ -2118,9 +2140,11 @@ void wacom_wac_event(struct hid_device *hdev, struct hid_field *field, | |||
| 2118 | if (wacom->wacom_wac.features.type != HID_GENERIC) | 2140 | if (wacom->wacom_wac.features.type != HID_GENERIC) |
| 2119 | return; | 2141 | return; |
| 2120 | 2142 | ||
| 2121 | if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) | 2143 | if (WACOM_PAD_FIELD(field)) { |
| 2122 | wacom_wac_pad_event(hdev, field, usage, value); | 2144 | wacom_wac_pad_battery_event(hdev, field, usage, value); |
| 2123 | else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) | 2145 | if (wacom->wacom_wac.pad_input) |
| 2146 | wacom_wac_pad_event(hdev, field, usage, value); | ||
| 2147 | } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) | ||
| 2124 | wacom_wac_pen_event(hdev, field, usage, value); | 2148 | wacom_wac_pen_event(hdev, field, usage, value); |
| 2125 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) | 2149 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
| 2126 | wacom_wac_finger_event(hdev, field, usage, value); | 2150 | wacom_wac_finger_event(hdev, field, usage, value); |
| @@ -2163,12 +2187,14 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report) | |||
| 2163 | 2187 | ||
| 2164 | wacom_report_events(hdev, report); | 2188 | wacom_report_events(hdev, report); |
| 2165 | 2189 | ||
| 2166 | if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) | 2190 | if (WACOM_PAD_FIELD(field)) { |
| 2167 | return wacom_wac_pad_report(hdev, report); | 2191 | wacom_wac_pad_battery_report(hdev, report); |
| 2168 | else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) | 2192 | if (wacom->wacom_wac.pad_input) |
| 2169 | return wacom_wac_pen_report(hdev, report); | 2193 | wacom_wac_pad_report(hdev, report); |
| 2194 | } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) | ||
| 2195 | wacom_wac_pen_report(hdev, report); | ||
| 2170 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) | 2196 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
| 2171 | return wacom_wac_finger_report(hdev, report); | 2197 | wacom_wac_finger_report(hdev, report); |
| 2172 | } | 2198 | } |
| 2173 | 2199 | ||
| 2174 | static int wacom_bpt_touch(struct wacom_wac *wacom) | 2200 | static int wacom_bpt_touch(struct wacom_wac *wacom) |
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index a54a3017a23f..fb0e50acb10d 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h | |||
| @@ -232,6 +232,7 @@ struct wacom_features { | |||
| 232 | int pktlen; | 232 | int pktlen; |
| 233 | bool check_for_hid_type; | 233 | bool check_for_hid_type; |
| 234 | int hid_type; | 234 | int hid_type; |
| 235 | bool input_event_flag; | ||
| 235 | }; | 236 | }; |
| 236 | 237 | ||
| 237 | struct wacom_shared { | 238 | struct wacom_shared { |
