Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-2022102101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid

Pull HID fixes from Benjamin Tissoires:

- a 12 year old bug fix for the Apple Magic Trackpad v1 (José Expósito)

- a fix for a potential crash on removal of the Playstation controllers
(Roderick Colenbrander)

- a few new device IDs and device-specific quirks, most notably support
of the new Playstation DualSense Edge controller

* tag 'for-linus-2022102101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
HID: lenovo: Make array tp10ubkbd_led static const
HID: saitek: add madcatz variant of MMO7 mouse device ID
HID: playstation: support updated DualSense rumble mode.
HID: playstation: add initial DualSense Edge controller support
HID: playstation: stop DualSense output work on remove.
HID: magicmouse: Do not set BTN_MOUSE on double report

+83 -9
+2
drivers/hid/hid-ids.h
··· 867 867 #define USB_DEVICE_ID_MADCATZ_BEATPAD 0x4540 868 868 #define USB_DEVICE_ID_MADCATZ_RAT5 0x1705 869 869 #define USB_DEVICE_ID_MADCATZ_RAT9 0x1709 870 + #define USB_DEVICE_ID_MADCATZ_MMO7 0x1713 870 871 871 872 #define USB_VENDOR_ID_MCC 0x09db 872 873 #define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 ··· 1143 1142 #define USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 0x09cc 1144 1143 #define USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE 0x0ba0 1145 1144 #define USB_DEVICE_ID_SONY_PS5_CONTROLLER 0x0ce6 1145 + #define USB_DEVICE_ID_SONY_PS5_CONTROLLER_2 0x0df2 1146 1146 #define USB_DEVICE_ID_SONY_MOTION_CONTROLLER 0x03d5 1147 1147 #define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f 1148 1148 #define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002
+1 -1
drivers/hid/hid-lenovo.c
··· 985 985 struct device *dev = led_cdev->dev->parent; 986 986 struct hid_device *hdev = to_hid_device(dev); 987 987 struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); 988 - u8 tp10ubkbd_led[] = { TP10UBKBD_MUTE_LED, TP10UBKBD_MICMUTE_LED }; 988 + static const u8 tp10ubkbd_led[] = { TP10UBKBD_MUTE_LED, TP10UBKBD_MICMUTE_LED }; 989 989 int led_nr = 0; 990 990 int ret = 0; 991 991
+1 -1
drivers/hid/hid-magicmouse.c
··· 480 480 magicmouse_raw_event(hdev, report, data + 2, data[1]); 481 481 magicmouse_raw_event(hdev, report, data + 2 + data[1], 482 482 size - 2 - data[1]); 483 - break; 483 + return 0; 484 484 default: 485 485 return 0; 486 486 }
+76 -7
drivers/hid/hid-playstation.c
··· 46 46 uint32_t fw_version; 47 47 48 48 int (*parse_report)(struct ps_device *dev, struct hid_report *report, u8 *data, int size); 49 + void (*remove)(struct ps_device *dev); 49 50 }; 50 51 51 52 /* Calibration data for playstation motion sensors. */ ··· 108 107 #define DS_STATUS_CHARGING GENMASK(7, 4) 109 108 #define DS_STATUS_CHARGING_SHIFT 4 110 109 110 + /* Feature version from DualSense Firmware Info report. */ 111 + #define DS_FEATURE_VERSION(major, minor) ((major & 0xff) << 8 | (minor & 0xff)) 112 + 111 113 /* 112 114 * Status of a DualSense touch point contact. 113 115 * Contact IDs, with highest bit set are 'inactive' ··· 129 125 #define DS_OUTPUT_VALID_FLAG1_RELEASE_LEDS BIT(3) 130 126 #define DS_OUTPUT_VALID_FLAG1_PLAYER_INDICATOR_CONTROL_ENABLE BIT(4) 131 127 #define DS_OUTPUT_VALID_FLAG2_LIGHTBAR_SETUP_CONTROL_ENABLE BIT(1) 128 + #define DS_OUTPUT_VALID_FLAG2_COMPATIBLE_VIBRATION2 BIT(2) 132 129 #define DS_OUTPUT_POWER_SAVE_CONTROL_MIC_MUTE BIT(4) 133 130 #define DS_OUTPUT_LIGHTBAR_SETUP_LIGHT_OUT BIT(1) 134 131 ··· 147 142 struct input_dev *sensors; 148 143 struct input_dev *touchpad; 149 144 145 + /* Update version is used as a feature/capability version. */ 146 + uint16_t update_version; 147 + 150 148 /* Calibration data for accelerometer and gyroscope. */ 151 149 struct ps_calibration_data accel_calib_data[3]; 152 150 struct ps_calibration_data gyro_calib_data[3]; ··· 160 152 uint32_t sensor_timestamp_us; 161 153 162 154 /* Compatible rumble state */ 155 + bool use_vibration_v2; 163 156 bool update_rumble; 164 157 uint8_t motor_left; 165 158 uint8_t motor_right; ··· 183 174 struct led_classdev player_leds[5]; 184 175 185 176 struct work_struct output_worker; 177 + bool output_worker_initialized; 186 178 void *output_report_dmabuf; 187 179 uint8_t output_seq; /* Sequence number for output report. */ 188 180 }; ··· 309 299 {0, 0}, 310 300 }; 311 301 302 + static inline void dualsense_schedule_work(struct dualsense *ds); 312 303 static void dualsense_set_lightbar(struct dualsense *ds, uint8_t red, uint8_t green, uint8_t blue); 313 304 314 305 /* ··· 800 789 return ret; 801 790 } 802 791 792 + 803 793 static int dualsense_get_firmware_info(struct dualsense *ds) 804 794 { 805 795 uint8_t *buf; ··· 819 807 820 808 ds->base.hw_version = get_unaligned_le32(&buf[24]); 821 809 ds->base.fw_version = get_unaligned_le32(&buf[28]); 810 + 811 + /* Update version is some kind of feature version. It is distinct from 812 + * the firmware version as there can be many different variations of a 813 + * controller over time with the same physical shell, but with different 814 + * PCBs and other internal changes. The update version (internal name) is 815 + * used as a means to detect what features are available and change behavior. 816 + * Note: the version is different between DualSense and DualSense Edge. 817 + */ 818 + ds->update_version = get_unaligned_le16(&buf[44]); 822 819 823 820 err_free: 824 821 kfree(buf); ··· 899 878 ds->update_player_leds = true; 900 879 spin_unlock_irqrestore(&ds->base.lock, flags); 901 880 902 - schedule_work(&ds->output_worker); 881 + dualsense_schedule_work(ds); 903 882 904 883 return 0; 905 884 } ··· 943 922 } 944 923 } 945 924 925 + static inline void dualsense_schedule_work(struct dualsense *ds) 926 + { 927 + unsigned long flags; 928 + 929 + spin_lock_irqsave(&ds->base.lock, flags); 930 + if (ds->output_worker_initialized) 931 + schedule_work(&ds->output_worker); 932 + spin_unlock_irqrestore(&ds->base.lock, flags); 933 + } 934 + 946 935 /* 947 936 * Helper function to send DualSense output reports. Applies a CRC at the end of a report 948 937 * for Bluetooth reports. ··· 991 960 if (ds->update_rumble) { 992 961 /* Select classic rumble style haptics and enable it. */ 993 962 common->valid_flag0 |= DS_OUTPUT_VALID_FLAG0_HAPTICS_SELECT; 994 - common->valid_flag0 |= DS_OUTPUT_VALID_FLAG0_COMPATIBLE_VIBRATION; 963 + if (ds->use_vibration_v2) 964 + common->valid_flag2 |= DS_OUTPUT_VALID_FLAG2_COMPATIBLE_VIBRATION2; 965 + else 966 + common->valid_flag0 |= DS_OUTPUT_VALID_FLAG0_COMPATIBLE_VIBRATION; 995 967 common->motor_left = ds->motor_left; 996 968 common->motor_right = ds->motor_right; 997 969 ds->update_rumble = false; ··· 1116 1082 spin_unlock_irqrestore(&ps_dev->lock, flags); 1117 1083 1118 1084 /* Schedule updating of microphone state at hardware level. */ 1119 - schedule_work(&ds->output_worker); 1085 + dualsense_schedule_work(ds); 1120 1086 } 1121 1087 ds->last_btn_mic_state = btn_mic_state; 1122 1088 ··· 1231 1197 ds->motor_right = effect->u.rumble.weak_magnitude / 256; 1232 1198 spin_unlock_irqrestore(&ds->base.lock, flags); 1233 1199 1234 - schedule_work(&ds->output_worker); 1200 + dualsense_schedule_work(ds); 1235 1201 return 0; 1202 + } 1203 + 1204 + static void dualsense_remove(struct ps_device *ps_dev) 1205 + { 1206 + struct dualsense *ds = container_of(ps_dev, struct dualsense, base); 1207 + unsigned long flags; 1208 + 1209 + spin_lock_irqsave(&ds->base.lock, flags); 1210 + ds->output_worker_initialized = false; 1211 + spin_unlock_irqrestore(&ds->base.lock, flags); 1212 + 1213 + cancel_work_sync(&ds->output_worker); 1236 1214 } 1237 1215 1238 1216 static int dualsense_reset_leds(struct dualsense *ds) ··· 1283 1237 ds->lightbar_blue = blue; 1284 1238 spin_unlock_irqrestore(&ds->base.lock, flags); 1285 1239 1286 - schedule_work(&ds->output_worker); 1240 + dualsense_schedule_work(ds); 1287 1241 } 1288 1242 1289 1243 static void dualsense_set_player_leds(struct dualsense *ds) ··· 1306 1260 1307 1261 ds->update_player_leds = true; 1308 1262 ds->player_leds_state = player_ids[player_id]; 1309 - schedule_work(&ds->output_worker); 1263 + dualsense_schedule_work(ds); 1310 1264 } 1311 1265 1312 1266 static struct ps_device *dualsense_create(struct hid_device *hdev) ··· 1345 1299 ps_dev->battery_capacity = 100; /* initial value until parse_report. */ 1346 1300 ps_dev->battery_status = POWER_SUPPLY_STATUS_UNKNOWN; 1347 1301 ps_dev->parse_report = dualsense_parse_report; 1302 + ps_dev->remove = dualsense_remove; 1348 1303 INIT_WORK(&ds->output_worker, dualsense_output_worker); 1304 + ds->output_worker_initialized = true; 1349 1305 hid_set_drvdata(hdev, ds); 1350 1306 1351 1307 max_output_report_size = sizeof(struct dualsense_output_report_bt); ··· 1366 1318 if (ret) { 1367 1319 hid_err(hdev, "Failed to get firmware info from DualSense\n"); 1368 1320 return ERR_PTR(ret); 1321 + } 1322 + 1323 + /* Original DualSense firmware simulated classic controller rumble through 1324 + * its new haptics hardware. It felt different from classic rumble users 1325 + * were used to. Since then new firmwares were introduced to change behavior 1326 + * and make this new 'v2' behavior default on PlayStation and other platforms. 1327 + * The original DualSense requires a new enough firmware as bundled with PS5 1328 + * software released in 2021. DualSense edge supports it out of the box. 1329 + * Both devices also support the old mode, but it is not really used. 1330 + */ 1331 + if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER) { 1332 + /* Feature version 2.21 introduced new vibration method. */ 1333 + ds->use_vibration_v2 = ds->update_version >= DS_FEATURE_VERSION(2, 21); 1334 + } else if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) { 1335 + ds->use_vibration_v2 = true; 1369 1336 } 1370 1337 1371 1338 ret = ps_devices_list_add(ps_dev); ··· 1499 1436 goto err_stop; 1500 1437 } 1501 1438 1502 - if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER) { 1439 + if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER || 1440 + hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) { 1503 1441 dev = dualsense_create(hdev); 1504 1442 if (IS_ERR(dev)) { 1505 1443 hid_err(hdev, "Failed to create dualsense.\n"); ··· 1525 1461 ps_devices_list_remove(dev); 1526 1462 ps_device_release_player_id(dev); 1527 1463 1464 + if (dev->remove) 1465 + dev->remove(dev); 1466 + 1528 1467 hid_hw_close(hdev); 1529 1468 hid_hw_stop(hdev); 1530 1469 } ··· 1535 1468 static const struct hid_device_id ps_devices[] = { 1536 1469 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER) }, 1537 1470 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER) }, 1471 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) }, 1472 + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) }, 1538 1473 { } 1539 1474 }; 1540 1475 MODULE_DEVICE_TABLE(hid, ps_devices);
+1
drivers/hid/hid-quirks.c
··· 620 620 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_MMO7) }, 621 621 { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT5) }, 622 622 { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9) }, 623 + { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_MMO7) }, 623 624 #endif 624 625 #if IS_ENABLED(CONFIG_HID_SAMSUNG) 625 626 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
+2
drivers/hid/hid-saitek.c
··· 187 187 .driver_data = SAITEK_RELEASE_MODE_RAT7 }, 188 188 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_MMO7), 189 189 .driver_data = SAITEK_RELEASE_MODE_MMO7 }, 190 + { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_MMO7), 191 + .driver_data = SAITEK_RELEASE_MODE_MMO7 }, 190 192 { } 191 193 }; 192 194