diff options
author | Jiri Kosina <jkosina@suse.cz> | 2013-04-30 04:19:21 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-04-30 04:19:21 -0400 |
commit | ad1b890e06af049fb48d7ccb799d0e96c071c893 (patch) | |
tree | d52f8e173cfaaf9e71fe4bb46259b3a3bb513088 /drivers/hid | |
parent | 047dff63f913c21c5228b94118e7996ab998cdc4 (diff) | |
parent | 2d44e3d26891e9530e29395f5a86b751c2f69ee8 (diff) |
Merge branches 'for-3.10/wiimote' and 'for-3.9/upstream-fixes' into for-linus
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-core.c | 1 | ||||
-rw-r--r-- | drivers/hid/hid-ids.h | 1 | ||||
-rw-r--r-- | drivers/hid/hid-wiimote-core.c | 43 |
3 files changed, 40 insertions, 5 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 98dd6ab9aa27..6961bbeab3ed 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1730,6 +1730,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1730 | 1730 | ||
1731 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, | 1731 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, |
1732 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, | 1732 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, |
1733 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE2) }, | ||
1733 | { } | 1734 | { } |
1734 | }; | 1735 | }; |
1735 | 1736 | ||
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 61bea32b6ab5..38535c9243d5 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -617,6 +617,7 @@ | |||
617 | 617 | ||
618 | #define USB_VENDOR_ID_NINTENDO 0x057e | 618 | #define USB_VENDOR_ID_NINTENDO 0x057e |
619 | #define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306 | 619 | #define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306 |
620 | #define USB_DEVICE_ID_NINTENDO_WIIMOTE2 0x0330 | ||
620 | 621 | ||
621 | #define USB_VENDOR_ID_NOVATEK 0x0603 | 622 | #define USB_VENDOR_ID_NOVATEK 0x0603 |
622 | #define USB_DEVICE_ID_NOVATEK_PCT 0x0600 | 623 | #define USB_DEVICE_ID_NOVATEK_PCT 0x0600 |
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c index 0fb8ab93db68..e5ee1f20bbd9 100644 --- a/drivers/hid/hid-wiimote-core.c +++ b/drivers/hid/hid-wiimote-core.c | |||
@@ -789,12 +789,20 @@ static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir, | |||
789 | input_report_abs(wdata->ir, yid, y); | 789 | input_report_abs(wdata->ir, yid, y); |
790 | } | 790 | } |
791 | 791 | ||
792 | static void handler_status(struct wiimote_data *wdata, const __u8 *payload) | 792 | /* reduced status report with "BB BB" key data only */ |
793 | static void handler_status_K(struct wiimote_data *wdata, | ||
794 | const __u8 *payload) | ||
793 | { | 795 | { |
794 | handler_keys(wdata, payload); | 796 | handler_keys(wdata, payload); |
795 | 797 | ||
796 | /* on status reports the drm is reset so we need to resend the drm */ | 798 | /* on status reports the drm is reset so we need to resend the drm */ |
797 | wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); | 799 | wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL); |
800 | } | ||
801 | |||
802 | /* extended status report with "BB BB LF 00 00 VV" data */ | ||
803 | static void handler_status(struct wiimote_data *wdata, const __u8 *payload) | ||
804 | { | ||
805 | handler_status_K(wdata, payload); | ||
798 | 806 | ||
799 | wiiext_event(wdata, payload[2] & 0x02); | 807 | wiiext_event(wdata, payload[2] & 0x02); |
800 | 808 | ||
@@ -804,6 +812,12 @@ static void handler_status(struct wiimote_data *wdata, const __u8 *payload) | |||
804 | } | 812 | } |
805 | } | 813 | } |
806 | 814 | ||
815 | /* reduced generic report with "BB BB" key data only */ | ||
816 | static void handler_generic_K(struct wiimote_data *wdata, const __u8 *payload) | ||
817 | { | ||
818 | handler_keys(wdata, payload); | ||
819 | } | ||
820 | |||
807 | static void handler_data(struct wiimote_data *wdata, const __u8 *payload) | 821 | static void handler_data(struct wiimote_data *wdata, const __u8 *payload) |
808 | { | 822 | { |
809 | __u16 offset = payload[3] << 8 | payload[4]; | 823 | __u16 offset = payload[3] << 8 | payload[4]; |
@@ -947,16 +961,26 @@ struct wiiproto_handler { | |||
947 | 961 | ||
948 | static struct wiiproto_handler handlers[] = { | 962 | static struct wiiproto_handler handlers[] = { |
949 | { .id = WIIPROTO_REQ_STATUS, .size = 6, .func = handler_status }, | 963 | { .id = WIIPROTO_REQ_STATUS, .size = 6, .func = handler_status }, |
964 | { .id = WIIPROTO_REQ_STATUS, .size = 2, .func = handler_status_K }, | ||
950 | { .id = WIIPROTO_REQ_DATA, .size = 21, .func = handler_data }, | 965 | { .id = WIIPROTO_REQ_DATA, .size = 21, .func = handler_data }, |
966 | { .id = WIIPROTO_REQ_DATA, .size = 2, .func = handler_generic_K }, | ||
951 | { .id = WIIPROTO_REQ_RETURN, .size = 4, .func = handler_return }, | 967 | { .id = WIIPROTO_REQ_RETURN, .size = 4, .func = handler_return }, |
968 | { .id = WIIPROTO_REQ_RETURN, .size = 2, .func = handler_generic_K }, | ||
952 | { .id = WIIPROTO_REQ_DRM_K, .size = 2, .func = handler_keys }, | 969 | { .id = WIIPROTO_REQ_DRM_K, .size = 2, .func = handler_keys }, |
953 | { .id = WIIPROTO_REQ_DRM_KA, .size = 5, .func = handler_drm_KA }, | 970 | { .id = WIIPROTO_REQ_DRM_KA, .size = 5, .func = handler_drm_KA }, |
971 | { .id = WIIPROTO_REQ_DRM_KA, .size = 2, .func = handler_generic_K }, | ||
954 | { .id = WIIPROTO_REQ_DRM_KE, .size = 10, .func = handler_drm_KE }, | 972 | { .id = WIIPROTO_REQ_DRM_KE, .size = 10, .func = handler_drm_KE }, |
973 | { .id = WIIPROTO_REQ_DRM_KE, .size = 2, .func = handler_generic_K }, | ||
955 | { .id = WIIPROTO_REQ_DRM_KAI, .size = 17, .func = handler_drm_KAI }, | 974 | { .id = WIIPROTO_REQ_DRM_KAI, .size = 17, .func = handler_drm_KAI }, |
975 | { .id = WIIPROTO_REQ_DRM_KAI, .size = 2, .func = handler_generic_K }, | ||
956 | { .id = WIIPROTO_REQ_DRM_KEE, .size = 21, .func = handler_drm_KEE }, | 976 | { .id = WIIPROTO_REQ_DRM_KEE, .size = 21, .func = handler_drm_KEE }, |
977 | { .id = WIIPROTO_REQ_DRM_KEE, .size = 2, .func = handler_generic_K }, | ||
957 | { .id = WIIPROTO_REQ_DRM_KAE, .size = 21, .func = handler_drm_KAE }, | 978 | { .id = WIIPROTO_REQ_DRM_KAE, .size = 21, .func = handler_drm_KAE }, |
979 | { .id = WIIPROTO_REQ_DRM_KAE, .size = 2, .func = handler_generic_K }, | ||
958 | { .id = WIIPROTO_REQ_DRM_KIE, .size = 21, .func = handler_drm_KIE }, | 980 | { .id = WIIPROTO_REQ_DRM_KIE, .size = 21, .func = handler_drm_KIE }, |
981 | { .id = WIIPROTO_REQ_DRM_KIE, .size = 2, .func = handler_generic_K }, | ||
959 | { .id = WIIPROTO_REQ_DRM_KAIE, .size = 21, .func = handler_drm_KAIE }, | 982 | { .id = WIIPROTO_REQ_DRM_KAIE, .size = 21, .func = handler_drm_KAIE }, |
983 | { .id = WIIPROTO_REQ_DRM_KAIE, .size = 2, .func = handler_generic_K }, | ||
960 | { .id = WIIPROTO_REQ_DRM_E, .size = 21, .func = handler_drm_E }, | 984 | { .id = WIIPROTO_REQ_DRM_E, .size = 21, .func = handler_drm_E }, |
961 | { .id = WIIPROTO_REQ_DRM_SKAI1, .size = 21, .func = handler_drm_SKAI1 }, | 985 | { .id = WIIPROTO_REQ_DRM_SKAI1, .size = 21, .func = handler_drm_SKAI1 }, |
962 | { .id = WIIPROTO_REQ_DRM_SKAI2, .size = 21, .func = handler_drm_SKAI2 }, | 986 | { .id = WIIPROTO_REQ_DRM_SKAI2, .size = 21, .func = handler_drm_SKAI2 }, |
@@ -970,7 +994,6 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report, | |||
970 | struct wiiproto_handler *h; | 994 | struct wiiproto_handler *h; |
971 | int i; | 995 | int i; |
972 | unsigned long flags; | 996 | unsigned long flags; |
973 | bool handled = false; | ||
974 | 997 | ||
975 | if (size < 1) | 998 | if (size < 1) |
976 | return -EINVAL; | 999 | return -EINVAL; |
@@ -981,11 +1004,11 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report, | |||
981 | h = &handlers[i]; | 1004 | h = &handlers[i]; |
982 | if (h->id == raw_data[0] && h->size < size) { | 1005 | if (h->id == raw_data[0] && h->size < size) { |
983 | h->func(wdata, &raw_data[1]); | 1006 | h->func(wdata, &raw_data[1]); |
984 | handled = true; | 1007 | break; |
985 | } | 1008 | } |
986 | } | 1009 | } |
987 | 1010 | ||
988 | if (!handled) | 1011 | if (!handlers[i].id) |
989 | hid_warn(hdev, "Unhandled report %hhu size %d\n", raw_data[0], | 1012 | hid_warn(hdev, "Unhandled report %hhu size %d\n", raw_data[0], |
990 | size); | 1013 | size); |
991 | 1014 | ||
@@ -1160,6 +1183,7 @@ static void wiimote_destroy(struct wiimote_data *wdata) | |||
1160 | wiimote_leds_destroy(wdata); | 1183 | wiimote_leds_destroy(wdata); |
1161 | 1184 | ||
1162 | power_supply_unregister(&wdata->battery); | 1185 | power_supply_unregister(&wdata->battery); |
1186 | kfree(wdata->battery.name); | ||
1163 | input_unregister_device(wdata->accel); | 1187 | input_unregister_device(wdata->accel); |
1164 | input_unregister_device(wdata->ir); | 1188 | input_unregister_device(wdata->ir); |
1165 | input_unregister_device(wdata->input); | 1189 | input_unregister_device(wdata->input); |
@@ -1216,9 +1240,14 @@ static int wiimote_hid_probe(struct hid_device *hdev, | |||
1216 | wdata->battery.properties = wiimote_battery_props; | 1240 | wdata->battery.properties = wiimote_battery_props; |
1217 | wdata->battery.num_properties = ARRAY_SIZE(wiimote_battery_props); | 1241 | wdata->battery.num_properties = ARRAY_SIZE(wiimote_battery_props); |
1218 | wdata->battery.get_property = wiimote_battery_get_property; | 1242 | wdata->battery.get_property = wiimote_battery_get_property; |
1219 | wdata->battery.name = "wiimote_battery"; | ||
1220 | wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; | 1243 | wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; |
1221 | wdata->battery.use_for_apm = 0; | 1244 | wdata->battery.use_for_apm = 0; |
1245 | wdata->battery.name = kasprintf(GFP_KERNEL, "wiimote_battery_%s", | ||
1246 | wdata->hdev->uniq); | ||
1247 | if (!wdata->battery.name) { | ||
1248 | ret = -ENOMEM; | ||
1249 | goto err_battery_name; | ||
1250 | } | ||
1222 | 1251 | ||
1223 | ret = power_supply_register(&wdata->hdev->dev, &wdata->battery); | 1252 | ret = power_supply_register(&wdata->hdev->dev, &wdata->battery); |
1224 | if (ret) { | 1253 | if (ret) { |
@@ -1254,6 +1283,8 @@ err_free: | |||
1254 | return ret; | 1283 | return ret; |
1255 | 1284 | ||
1256 | err_battery: | 1285 | err_battery: |
1286 | kfree(wdata->battery.name); | ||
1287 | err_battery_name: | ||
1257 | input_unregister_device(wdata->input); | 1288 | input_unregister_device(wdata->input); |
1258 | wdata->input = NULL; | 1289 | wdata->input = NULL; |
1259 | err_input: | 1290 | err_input: |
@@ -1283,6 +1314,8 @@ static void wiimote_hid_remove(struct hid_device *hdev) | |||
1283 | static const struct hid_device_id wiimote_hid_devices[] = { | 1314 | static const struct hid_device_id wiimote_hid_devices[] = { |
1284 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, | 1315 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, |
1285 | USB_DEVICE_ID_NINTENDO_WIIMOTE) }, | 1316 | USB_DEVICE_ID_NINTENDO_WIIMOTE) }, |
1317 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, | ||
1318 | USB_DEVICE_ID_NINTENDO_WIIMOTE2) }, | ||
1286 | { } | 1319 | { } |
1287 | }; | 1320 | }; |
1288 | MODULE_DEVICE_TABLE(hid, wiimote_hid_devices); | 1321 | MODULE_DEVICE_TABLE(hid, wiimote_hid_devices); |