diff options
| author | Frank Praznik <frank.praznik@oh.rr.com> | 2014-09-18 21:15:01 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2014-09-22 10:04:21 -0400 |
| commit | ce8efc3b563070c2aa2e0455b992256c98e03547 (patch) | |
| tree | f61824b3a2c457623812343ea8c6cef149c0b050 | |
| parent | 077147a3055efbaafd624aa297f4284d0996b3f2 (diff) | |
HID: sony: Set touchpad bits in the input_configured callback
Set the DualShock4 touchpad bits in the input_configured callback
so that they are registered properly for any input devices created
during hid_hw_start.
Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
| -rw-r--r-- | drivers/hid/hid-sony.c | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 96a8ec5ed296..5baa311e22fc 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
| @@ -1084,6 +1084,38 @@ static int sony_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 1084 | return 0; | 1084 | return 0; |
| 1085 | } | 1085 | } |
| 1086 | 1086 | ||
| 1087 | static int sony_register_touchpad(struct hid_input *hi, int touch_count, | ||
| 1088 | int w, int h) | ||
| 1089 | { | ||
| 1090 | struct input_dev *input_dev = hi->input; | ||
| 1091 | int ret; | ||
| 1092 | |||
| 1093 | ret = input_mt_init_slots(input_dev, touch_count, 0); | ||
| 1094 | if (ret < 0) | ||
| 1095 | return ret; | ||
| 1096 | |||
| 1097 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, w, 0, 0); | ||
| 1098 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, h, 0, 0); | ||
| 1099 | |||
| 1100 | return 0; | ||
| 1101 | } | ||
| 1102 | |||
| 1103 | static void sony_input_configured(struct hid_device *hdev, | ||
| 1104 | struct hid_input *hidinput) | ||
| 1105 | { | ||
| 1106 | struct sony_sc *sc = hid_get_drvdata(hdev); | ||
| 1107 | |||
| 1108 | /* | ||
| 1109 | * The Dualshock 4 touchpad supports 2 touches and has a | ||
| 1110 | * resolution of 1920x940. | ||
| 1111 | */ | ||
| 1112 | if (sc->quirks & DUALSHOCK4_CONTROLLER) { | ||
| 1113 | if (sony_register_touchpad(hidinput, 2, 1920, 940) != 0) | ||
| 1114 | hid_err(sc->hdev, | ||
| 1115 | "Unable to initialize multi-touch slots\n"); | ||
| 1116 | } | ||
| 1117 | } | ||
| 1118 | |||
| 1087 | /* | 1119 | /* |
| 1088 | * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller | 1120 | * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller |
| 1089 | * to "operational". Without this, the ps3 controller will not report any | 1121 | * to "operational". Without this, the ps3 controller will not report any |
| @@ -1656,26 +1688,6 @@ static void sony_battery_remove(struct sony_sc *sc) | |||
| 1656 | sc->battery.name = NULL; | 1688 | sc->battery.name = NULL; |
| 1657 | } | 1689 | } |
| 1658 | 1690 | ||
| 1659 | static int sony_register_touchpad(struct sony_sc *sc, int touch_count, | ||
| 1660 | int w, int h) | ||
| 1661 | { | ||
| 1662 | struct hid_input *hidinput = list_entry(sc->hdev->inputs.next, | ||
| 1663 | struct hid_input, list); | ||
| 1664 | struct input_dev *input_dev = hidinput->input; | ||
| 1665 | int ret; | ||
| 1666 | |||
| 1667 | ret = input_mt_init_slots(input_dev, touch_count, 0); | ||
| 1668 | if (ret < 0) { | ||
| 1669 | hid_err(sc->hdev, "Unable to initialize multi-touch slots\n"); | ||
| 1670 | return ret; | ||
| 1671 | } | ||
| 1672 | |||
| 1673 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, w, 0, 0); | ||
| 1674 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, h, 0, 0); | ||
| 1675 | |||
| 1676 | return 0; | ||
| 1677 | } | ||
| 1678 | |||
| 1679 | /* | 1691 | /* |
| 1680 | * If a controller is plugged in via USB while already connected via Bluetooth | 1692 | * If a controller is plugged in via USB while already connected via Bluetooth |
| 1681 | * it will show up as two devices. A global list of connected controllers and | 1693 | * it will show up as two devices. A global list of connected controllers and |
| @@ -1925,13 +1937,6 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1925 | goto err_stop; | 1937 | goto err_stop; |
| 1926 | } | 1938 | } |
| 1927 | } | 1939 | } |
| 1928 | /* | ||
| 1929 | * The Dualshock 4 touchpad supports 2 touches and has a | ||
| 1930 | * resolution of 1920x940. | ||
| 1931 | */ | ||
| 1932 | ret = sony_register_touchpad(sc, 2, 1920, 940); | ||
| 1933 | if (ret < 0) | ||
| 1934 | goto err_stop; | ||
| 1935 | 1940 | ||
| 1936 | sony_init_work(sc, dualshock4_state_worker); | 1941 | sony_init_work(sc, dualshock4_state_worker); |
| 1937 | } else { | 1942 | } else { |
| @@ -2039,13 +2044,14 @@ static const struct hid_device_id sony_devices[] = { | |||
| 2039 | MODULE_DEVICE_TABLE(hid, sony_devices); | 2044 | MODULE_DEVICE_TABLE(hid, sony_devices); |
| 2040 | 2045 | ||
| 2041 | static struct hid_driver sony_driver = { | 2046 | static struct hid_driver sony_driver = { |
| 2042 | .name = "sony", | 2047 | .name = "sony", |
| 2043 | .id_table = sony_devices, | 2048 | .id_table = sony_devices, |
| 2044 | .input_mapping = sony_mapping, | 2049 | .input_mapping = sony_mapping, |
| 2045 | .probe = sony_probe, | 2050 | .input_configured = sony_input_configured, |
| 2046 | .remove = sony_remove, | 2051 | .probe = sony_probe, |
| 2047 | .report_fixup = sony_report_fixup, | 2052 | .remove = sony_remove, |
| 2048 | .raw_event = sony_raw_event | 2053 | .report_fixup = sony_report_fixup, |
| 2054 | .raw_event = sony_raw_event | ||
| 2049 | }; | 2055 | }; |
| 2050 | 2056 | ||
| 2051 | static int __init sony_init(void) | 2057 | static int __init sony_init(void) |
