| @@ -49,6 +49,10 @@ MODULE_PARM_DESC(disable_tap_to_click, · 48 unmodified lines |
| 49 | #define HIDPP_REPORT_LONG_LENGTH 20 | 49 | #define HIDPP_REPORT_LONG_LENGTH 20 |
| 50 | #define HIDPP_REPORT_VERY_LONG_MAX_LENGTH 64 | 50 | #define HIDPP_REPORT_VERY_LONG_MAX_LENGTH 64 |
| 51 | | 51 | |
| | 52 | #define HIDPP_REPORT_SHORT_SUPPORTED BIT(0) |
| | 53 | #define HIDPP_REPORT_LONG_SUPPORTED BIT(1) |
| | 54 | #define HIDPP_REPORT_VERY_LONG_SUPPORTED BIT(2) |
| | 55 | |
| 52 | #define HIDPP_SUB_ID_CONSUMER_VENDOR_KEYS 0x03 | 56 | #define HIDPP_SUB_ID_CONSUMER_VENDOR_KEYS 0x03 |
| 53 | #define HIDPP_SUB_ID_ROLLER 0x05 | 57 | #define HIDPP_SUB_ID_ROLLER 0x05 |
| 54 | #define HIDPP_SUB_ID_MOUSE_EXTRA_BTNS 0x06 | 58 | #define HIDPP_SUB_ID_MOUSE_EXTRA_BTNS 0x06 |
| @@ -87,6 +91,7 @@ MODULE_PARM_DESC(disable_tap_to_click, · 32 unmodified lines |
| 87 | #define HIDPP_CAPABILITY_HIDPP20_BATTERY BIT(1) | 91 | #define HIDPP_CAPABILITY_HIDPP20_BATTERY BIT(1) |
| 88 | #define HIDPP_CAPABILITY_BATTERY_MILEAGE BIT(2) | 92 | #define HIDPP_CAPABILITY_BATTERY_MILEAGE BIT(2) |
| 89 | #define HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS BIT(3) | 93 | #define HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS BIT(3) |
| | 94 | #define HIDPP_CAPABILITY_BATTERY_VOLTAGE BIT(4) |
| 90 | | 95 | |
| 91 | /* | 96 | /* |
| 92 | * There are two hidpp protocols in use, the first version hidpp10 is known | 97 | * There are two hidpp protocols in use, the first version hidpp10 is known |
| @@ -135,12 +140,15 @@ struct hidpp_report { · 42 unmodified lines |
| 135 | struct hidpp_battery { | 140 | struct hidpp_battery { |
| 136 | u8 feature_index; | 141 | u8 feature_index; |
| 137 | u8 solar_feature_index; | 142 | u8 solar_feature_index; |
| | 143 | u8 voltage_feature_index; |
| 138 | struct power_supply_desc desc; | 144 | struct power_supply_desc desc; |
| 139 | struct power_supply *ps; | 145 | struct power_supply *ps; |
| 140 | char name[64]; | 146 | char name[64]; |
| 141 | int status; | 147 | int status; |
| 142 | int capacity; | 148 | int capacity; |
| 143 | int level; | 149 | int level; |
| | 150 | int voltage; |
| | 151 | int charge_type; |
| 144 | bool online; | 152 | bool online; |
| 145 | }; | 153 | }; |
| 146 | | 154 | |
| @@ -183,9 +191,12 @@ struct hidpp_device { · 36 unmodified lines |
| 183 | | 191 | |
| 184 | unsigned long quirks; | 192 | unsigned long quirks; |
| 185 | unsigned long capabilities; | 193 | unsigned long capabilities; |
| | 194 | u8 supported_reports; |
| 186 | | 195 | |
| 187 | struct hidpp_battery battery; | 196 | struct hidpp_battery battery; |
| 188 | struct hidpp_scroll_counter vertical_wheel_counter; | 197 | struct hidpp_scroll_counter vertical_wheel_counter; |
| | 198 | |
| | 199 | u8 wireless_feature_index; |
| 189 | }; | 200 | }; |
| 190 | | 201 | |
| 191 | /* HID++ 1.0 error codes */ | 202 | /* HID++ 1.0 error codes */ |
| @@ -340,6 +351,11 @@ static int hidpp_send_rap_command_sync(struct hidpp_device *hidpp_dev, · 148 unmodified lines |
| 340 | struct hidpp_report *message; | 351 | struct hidpp_report *message; |
| 341 | int ret, max_count; | 352 | int ret, max_count; |
| 342 | | 353 | |
| | 354 | /* Send as long report if short reports are not supported. */ |
| | 355 | if (report_id == REPORT_ID_HIDPP_SHORT && |
| | 356 | !(hidpp_dev->supported_reports & HIDPP_REPORT_SHORT_SUPPORTED)) |
| | 357 | report_id = REPORT_ID_HIDPP_LONG; |
| | 358 | |
| 343 | switch (report_id) { | 359 | switch (report_id) { |
| 344 | case REPORT_ID_HIDPP_SHORT: | 360 | case REPORT_ID_HIDPP_SHORT: |
| 345 | max_count = HIDPP_REPORT_SHORT_LENGTH - 4; | 361 | max_count = HIDPP_REPORT_SHORT_LENGTH - 4; |
| @@ -393,10 +409,13 @@ static inline bool hidpp_match_error(struct hidpp_report *question, · 47 unmodified lines |
| 393 | (answer->fap.params[0] == question->fap.funcindex_clientid); | 409 | (answer->fap.params[0] == question->fap.funcindex_clientid); |
| 394 | } | 410 | } |
| 395 | | 411 | |
| 396 | static inline bool hidpp_report_is_connect_event(struct hidpp_report *report) | 412 | static inline bool hidpp_report_is_connect_event(struct hidpp_device *hidpp, |
| | 413 | struct hidpp_report *report) |
| 397 | { | 414 | { |
| 398 | return (report->report_id == REPORT_ID_HIDPP_SHORT) && | 415 | return (hidpp->wireless_feature_index && |
| 399 | (report->rap.sub_id == 0x41); | 416 | (report->fap.feature_index == hidpp->wireless_feature_index)) || |
| | 417 | ((report->report_id == REPORT_ID_HIDPP_SHORT) && |
| | 418 | (report->rap.sub_id == 0x41)); |
| 400 | } | 419 | } |
| 401 | | 420 | |
| 402 | /** | 421 | /** |
| @@ -1222,6 +1241,144 @@ static int hidpp20_battery_event(struct hidpp_device *hidpp, · 819 unmodified lines |
| 1222 | return 0; | 1241 | return 0; |
| 1223 | } | 1242 | } |
| 1224 | | 1243 | |
| | 1244 | /* -------------------------------------------------------------------------- */ |
| | 1245 | /* 0x1001: Battery voltage */ |
| | 1246 | /* -------------------------------------------------------------------------- */ |
| | 1247 | |
| | 1248 | #define HIDPP_PAGE_BATTERY_VOLTAGE 0x1001 |
| | 1249 | |
| | 1250 | #define CMD_BATTERY_VOLTAGE_GET_BATTERY_VOLTAGE 0x00 |
| | 1251 | |
| | 1252 | #define EVENT_BATTERY_VOLTAGE_STATUS_BROADCAST 0x00 |
| | 1253 | |
| | 1254 | static int hidpp20_battery_map_status_voltage(u8 data[3], int *voltage, |
| | 1255 | int *level, int *charge_type) |
| | 1256 | { |
| | 1257 | int status; |
| | 1258 | |
| | 1259 | long charge_sts = (long)data[2]; |
| | 1260 | |
| | 1261 | *level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; |
| | 1262 | switch (data[2] & 0xe0) { |
| | 1263 | case 0x00: |
| | 1264 | status = POWER_SUPPLY_STATUS_CHARGING; |
| | 1265 | break; |
| | 1266 | case 0x20: |
| | 1267 | status = POWER_SUPPLY_STATUS_FULL; |
| | 1268 | *level = POWER_SUPPLY_CAPACITY_LEVEL_FULL; |
| | 1269 | break; |
| | 1270 | case 0x40: |
| | 1271 | status = POWER_SUPPLY_STATUS_DISCHARGING; |
| | 1272 | break; |
| | 1273 | case 0xe0: |
| | 1274 | status = POWER_SUPPLY_STATUS_NOT_CHARGING; |
| | 1275 | break; |
| | 1276 | default: |
| | 1277 | status = POWER_SUPPLY_STATUS_UNKNOWN; |
| | 1278 | } |
| | 1279 | |
| | 1280 | *charge_type = POWER_SUPPLY_CHARGE_TYPE_STANDARD; |
| | 1281 | if (test_bit(3, &charge_sts)) { |
| | 1282 | *charge_type = POWER_SUPPLY_CHARGE_TYPE_FAST; |
| | 1283 | } |
| | 1284 | if (test_bit(4, &charge_sts)) { |
| | 1285 | *charge_type = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; |
| | 1286 | } |
| | 1287 | |
| | 1288 | if (test_bit(5, &charge_sts)) { |
| | 1289 | *level = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL; |
| | 1290 | } |
| | 1291 | |
| | 1292 | *voltage = get_unaligned_be16(data); |
| | 1293 | |
| | 1294 | return status; |
| | 1295 | } |
| | 1296 | |
| | 1297 | static int hidpp20_battery_get_battery_voltage(struct hidpp_device *hidpp, |
| | 1298 | u8 feature_index, |
| | 1299 | int *status, int *voltage, |
| | 1300 | int *level, int *charge_type) |
| | 1301 | { |
| | 1302 | struct hidpp_report response; |
| | 1303 | int ret; |
| | 1304 | u8 *params = (u8 *)response.fap.params; |
| | 1305 | |
| | 1306 | ret = hidpp_send_fap_command_sync(hidpp, feature_index, |
| | 1307 | CMD_BATTERY_VOLTAGE_GET_BATTERY_VOLTAGE, |
| | 1308 | NULL, 0, &response); |
| | 1309 | |
| | 1310 | if (ret > 0) { |
| | 1311 | hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", |
| | 1312 | __func__, ret); |
| | 1313 | return -EPROTO; |
| | 1314 | } |
| | 1315 | if (ret) |
| | 1316 | return ret; |
| | 1317 | |
| | 1318 | hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_VOLTAGE; |
| | 1319 | |
| | 1320 | *status = hidpp20_battery_map_status_voltage(params, voltage, |
| | 1321 | level, charge_type); |
| | 1322 | |
| | 1323 | return 0; |
| | 1324 | } |
| | 1325 | |
| | 1326 | static int hidpp20_query_battery_voltage_info(struct hidpp_device *hidpp) |
| | 1327 | { |
| | 1328 | u8 feature_type; |
| | 1329 | int ret; |
| | 1330 | int status, voltage, level, charge_type; |
| | 1331 | |
| | 1332 | if (hidpp->battery.voltage_feature_index == 0xff) { |
| | 1333 | ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_BATTERY_VOLTAGE, |
| | 1334 | &hidpp->battery.voltage_feature_index, |
| | 1335 | &feature_type); |
| | 1336 | if (ret) |
| | 1337 | return ret; |
| | 1338 | } |
| | 1339 | |
| | 1340 | ret = hidpp20_battery_get_battery_voltage(hidpp, |
| | 1341 | hidpp->battery.voltage_feature_index, |
| | 1342 | &status, &voltage, &level, &charge_type); |
| | 1343 | |
| | 1344 | if (ret) |
| | 1345 | return ret; |
| | 1346 | |
| | 1347 | hidpp->battery.status = status; |
| | 1348 | hidpp->battery.voltage = voltage; |
| | 1349 | hidpp->battery.level = level; |
| | 1350 | hidpp->battery.charge_type = charge_type; |
| | 1351 | hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; |
| | 1352 | |
| | 1353 | return 0; |
| | 1354 | } |
| | 1355 | |
| | 1356 | static int hidpp20_battery_voltage_event(struct hidpp_device *hidpp, |
| | 1357 | u8 *data, int size) |
| | 1358 | { |
| | 1359 | struct hidpp_report *report = (struct hidpp_report *)data; |
| | 1360 | int status, voltage, level, charge_type; |
| | 1361 | |
| | 1362 | if (report->fap.feature_index != hidpp->battery.voltage_feature_index || |
| | 1363 | report->fap.funcindex_clientid != EVENT_BATTERY_VOLTAGE_STATUS_BROADCAST) |
| | 1364 | return 0; |
| | 1365 | |
| | 1366 | status = hidpp20_battery_map_status_voltage(report->fap.params, &voltage, |
| | 1367 | &level, &charge_type); |
| | 1368 | |
| | 1369 | hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING; |
| | 1370 | |
| | 1371 | if (voltage != hidpp->battery.voltage || status != hidpp->battery.status) { |
| | 1372 | hidpp->battery.voltage = voltage; |
| | 1373 | hidpp->battery.status = status; |
| | 1374 | hidpp->battery.level = level; |
| | 1375 | hidpp->battery.charge_type = charge_type; |
| | 1376 | if (hidpp->battery.ps) |
| | 1377 | power_supply_changed(hidpp->battery.ps); |
| | 1378 | } |
| | 1379 | return 0; |
| | 1380 | } |
| | 1381 | |
| 1225 | static enum power_supply_property hidpp_battery_props[] = { | 1382 | static enum power_supply_property hidpp_battery_props[] = { |
| 1226 | POWER_SUPPLY_PROP_ONLINE, | 1383 | POWER_SUPPLY_PROP_ONLINE, |
| 1227 | POWER_SUPPLY_PROP_STATUS, | 1384 | POWER_SUPPLY_PROP_STATUS, |
| @@ -1231,6 +1388,7 @@ static enum power_supply_property hidpp_battery_props[] = { · 3 unmodified lines |
| 1231 | POWER_SUPPLY_PROP_SERIAL_NUMBER, | 1388 | POWER_SUPPLY_PROP_SERIAL_NUMBER, |
| 1232 | 0, /* placeholder for POWER_SUPPLY_PROP_CAPACITY, */ | 1389 | 0, /* placeholder for POWER_SUPPLY_PROP_CAPACITY, */ |
| 1233 | 0, /* placeholder for POWER_SUPPLY_PROP_CAPACITY_LEVEL, */ | 1390 | 0, /* placeholder for POWER_SUPPLY_PROP_CAPACITY_LEVEL, */ |
| | 1391 | 0, /* placeholder for POWER_SUPPLY_PROP_VOLTAGE_NOW, */ |
| 1234 | }; | 1392 | }; |
| 1235 | | 1393 | |
| 1236 | static int hidpp_battery_get_property(struct power_supply *psy, | 1394 | static int hidpp_battery_get_property(struct power_supply *psy, |
| @@ -1268,6 +1426,13 @@ static int hidpp_battery_get_property(struct power_supply *psy, · 31 unmodified lines |
| 1268 | case POWER_SUPPLY_PROP_SERIAL_NUMBER: | 1426 | case POWER_SUPPLY_PROP_SERIAL_NUMBER: |
| 1269 | val->strval = hidpp->hid_dev->uniq; | 1427 | val->strval = hidpp->hid_dev->uniq; |
| 1270 | break; | 1428 | break; |
| | 1429 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: |
| | 1430 | /* hardware reports voltage in in mV. sysfs expects uV */ |
| | 1431 | val->intval = hidpp->battery.voltage * 1000; |
| | 1432 | break; |
| | 1433 | case POWER_SUPPLY_PROP_CHARGE_TYPE: |
| | 1434 | val->intval = hidpp->battery.charge_type; |
| | 1435 | break; |
| 1271 | default: | 1436 | default: |
| 1272 | ret = -EINVAL; | 1437 | ret = -EINVAL; |
| 1273 | break; | 1438 | break; |
| @@ -1276,6 +1441,24 @@ static int hidpp_battery_get_property(struct power_supply *psy, · 2 unmodified lines |
| 1276 | return ret; | 1441 | return ret; |
| 1277 | } | 1442 | } |
| 1278 | | 1443 | |
| | 1444 | /* -------------------------------------------------------------------------- */ |
| | 1445 | /* 0x1d4b: Wireless device status */ |
| | 1446 | /* -------------------------------------------------------------------------- */ |
| | 1447 | #define HIDPP_PAGE_WIRELESS_DEVICE_STATUS 0x1d4b |
| | 1448 | |
| | 1449 | static int hidpp_set_wireless_feature_index(struct hidpp_device *hidpp) |
| | 1450 | { |
| | 1451 | u8 feature_type; |
| | 1452 | int ret; |
| | 1453 | |
| | 1454 | ret = hidpp_root_get_feature(hidpp, |
| | 1455 | HIDPP_PAGE_WIRELESS_DEVICE_STATUS, |
| | 1456 | &hidpp->wireless_feature_index, |
| | 1457 | &feature_type); |
| | 1458 | |
| | 1459 | return ret; |
| | 1460 | } |
| | 1461 | |
| 1279 | /* -------------------------------------------------------------------------- */ | 1462 | /* -------------------------------------------------------------------------- */ |
| 1280 | /* 0x2120: Hi-resolution scrolling */ | 1463 | /* 0x2120: Hi-resolution scrolling */ |
| 1281 | /* -------------------------------------------------------------------------- */ | 1464 | /* -------------------------------------------------------------------------- */ |
| @@ -3091,7 +3274,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, · 1809 unmodified lines |
| 3091 | } | 3274 | } |
| 3092 | } | 3275 | } |
| 3093 | | 3276 | |
| 3094 | if (unlikely(hidpp_report_is_connect_event(report))) { | 3277 | if (unlikely(hidpp_report_is_connect_event(hidpp, report))) { |
| 3095 | atomic_set(&hidpp->connected, | 3278 | atomic_set(&hidpp->connected, |
| 3096 | !(report->rap.params[0] & (1 << 6))); | 3279 | !(report->rap.params[0] & (1 << 6))); |
| 3097 | if (schedule_work(&hidpp->work) == 0) | 3280 | if (schedule_work(&hidpp->work) == 0) |
| @@ -3106,6 +3289,9 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, · 8 unmodified lines |
| 3106 | ret = hidpp_solar_battery_event(hidpp, data, size); | 3289 | ret = hidpp_solar_battery_event(hidpp, data, size); |
| 3107 | if (ret != 0) | 3290 | if (ret != 0) |
| 3108 | return ret; | 3291 | return ret; |
| | 3292 | ret = hidpp20_battery_voltage_event(hidpp, data, size); |
| | 3293 | if (ret != 0) |
| | 3294 | return ret; |
| 3109 | } | 3295 | } |
| 3110 | | 3296 | |
| 3111 | if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { | 3297 | if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) { |
| @@ -3227,12 +3413,16 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp) · 115 unmodified lines |
| 3227 | | 3413 | |
| 3228 | hidpp->battery.feature_index = 0xff; | 3414 | hidpp->battery.feature_index = 0xff; |
| 3229 | hidpp->battery.solar_feature_index = 0xff; | 3415 | hidpp->battery.solar_feature_index = 0xff; |
| | 3416 | hidpp->battery.voltage_feature_index = 0xff; |
| 3230 | | 3417 | |
| 3231 | if (hidpp->protocol_major >= 2) { | 3418 | if (hidpp->protocol_major >= 2) { |
| 3232 | if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) | 3419 | if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750) |
| 3233 | ret = hidpp_solar_request_battery_event(hidpp); | 3420 | ret = hidpp_solar_request_battery_event(hidpp); |
| 3234 | else | 3421 | else { |
| 3235 | ret = hidpp20_query_battery_info(hidpp); | 3422 | ret = hidpp20_query_battery_voltage_info(hidpp); |
| | 3423 | if (ret) |
| | 3424 | ret = hidpp20_query_battery_info(hidpp); |
| | 3425 | } |
| 3236 | | 3426 | |
| 3237 | if (ret) | 3427 | if (ret) |
| 3238 | return ret; | 3428 | return ret; |
| @@ -3257,7 +3447,7 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp) · 18 unmodified lines |
| 3257 | if (!battery_props) | 3447 | if (!battery_props) |
| 3258 | return -ENOMEM; | 3448 | return -ENOMEM; |
| 3259 | | 3449 | |
| 3260 | num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 2; | 3450 | num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 3; |
| 3261 | | 3451 | |
| 3262 | if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) | 3452 | if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) |
| 3263 | battery_props[num_battery_props++] = | 3453 | battery_props[num_battery_props++] = |
| @@ -3267,6 +3457,10 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp) · 3 unmodified lines |
| 3267 | battery_props[num_battery_props++] = | 3457 | battery_props[num_battery_props++] = |
| 3268 | POWER_SUPPLY_PROP_CAPACITY_LEVEL; | 3458 | POWER_SUPPLY_PROP_CAPACITY_LEVEL; |
| 3269 | | 3459 | |
| | 3460 | if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) |
| | 3461 | battery_props[num_battery_props++] = |
| | 3462 | POWER_SUPPLY_PROP_VOLTAGE_NOW; |
| | 3463 | |
| 3270 | battery = &hidpp->battery; | 3464 | battery = &hidpp->battery; |
| 3271 | | 3465 | |
| 3272 | n = atomic_inc_return(&battery_no) - 1; | 3466 | n = atomic_inc_return(&battery_no) - 1; |
| @@ -3430,7 +3624,10 @@ static void hidpp_connect_event(struct hidpp_device *hidpp) · 157 unmodified lines |
| 3430 | else | 3624 | else |
| 3431 | hidpp10_query_battery_status(hidpp); | 3625 | hidpp10_query_battery_status(hidpp); |
| 3432 | } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { | 3626 | } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) { |
| 3433 | hidpp20_query_battery_info(hidpp); | 3627 | if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE) |
| | 3628 | hidpp20_query_battery_voltage_info(hidpp); |
| | 3629 | else |
| | 3630 | hidpp20_query_battery_info(hidpp); |
| 3434 | } | 3631 | } |
| 3435 | if (hidpp->battery.ps) | 3632 | if (hidpp->battery.ps) |
| 3436 | power_supply_changed(hidpp->battery.ps); | 3633 | power_supply_changed(hidpp->battery.ps); |
| @@ -3481,10 +3678,11 @@ static int hidpp_get_report_length(struct hid_device *hdev, int id) · 44 unmodified lines |
| 3481 | return report->field[0]->report_count + 1; | 3678 | return report->field[0]->report_count + 1; |
| 3482 | } | 3679 | } |
| 3483 | | 3680 | |
| 3484 | static bool hidpp_validate_device(struct hid_device *hdev) | 3681 | static u8 hidpp_validate_device(struct hid_device *hdev) |
| 3485 | { | 3682 | { |
| 3486 | struct hidpp_device *hidpp = hid_get_drvdata(hdev); | 3683 | struct hidpp_device *hidpp = hid_get_drvdata(hdev); |
| 3487 | int id, report_length, supported_reports = 0; | 3684 | int id, report_length; |
| | 3685 | u8 supported_reports = 0; |
| 3488 | | 3686 | |
| 3489 | id = REPORT_ID_HIDPP_SHORT; | 3687 | id = REPORT_ID_HIDPP_SHORT; |
| 3490 | report_length = hidpp_get_report_length(hdev, id); | 3688 | report_length = hidpp_get_report_length(hdev, id); |
| @@ -3492,7 +3690,7 @@ static bool hidpp_validate_device(struct hid_device *hdev) · 1 unmodified line |
| 3492 | if (report_length < HIDPP_REPORT_SHORT_LENGTH) | 3690 | if (report_length < HIDPP_REPORT_SHORT_LENGTH) |
| 3493 | goto bad_device; | 3691 | goto bad_device; |
| 3494 | | 3692 | |
| 3495 | supported_reports++; | 3693 | supported_reports |= HIDPP_REPORT_SHORT_SUPPORTED; |
| 3496 | } | 3694 | } |
| 3497 | | 3695 | |
| 3498 | id = REPORT_ID_HIDPP_LONG; | 3696 | id = REPORT_ID_HIDPP_LONG; |
| @@ -3501,7 +3699,7 @@ static bool hidpp_validate_device(struct hid_device *hdev) · 2 unmodified lines |
| 3501 | if (report_length < HIDPP_REPORT_LONG_LENGTH) | 3699 | if (report_length < HIDPP_REPORT_LONG_LENGTH) |
| 3502 | goto bad_device; | 3700 | goto bad_device; |
| 3503 | | 3701 | |
| 3504 | supported_reports++; | 3702 | supported_reports |= HIDPP_REPORT_LONG_SUPPORTED; |
| 3505 | } | 3703 | } |
| 3506 | | 3704 | |
| 3507 | id = REPORT_ID_HIDPP_VERY_LONG; | 3705 | id = REPORT_ID_HIDPP_VERY_LONG; |
| @@ -3511,7 +3709,7 @@ static bool hidpp_validate_device(struct hid_device *hdev) · 3 unmodified lines |
| 3511 | report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH) | 3709 | report_length > HIDPP_REPORT_VERY_LONG_MAX_LENGTH) |
| 3512 | goto bad_device; | 3710 | goto bad_device; |
| 3513 | | 3711 | |
| 3514 | supported_reports++; | 3712 | supported_reports |= HIDPP_REPORT_VERY_LONG_SUPPORTED; |
| 3515 | hidpp->very_long_report_length = report_length; | 3713 | hidpp->very_long_report_length = report_length; |
| 3516 | } | 3714 | } |
| 3517 | | 3715 | |
| @@ -3560,7 +3758,9 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) · 42 unmodified lines |
| 3560 | /* | 3758 | /* |
| 3561 | * Make sure the device is HID++ capable, otherwise treat as generic HID | 3759 | * Make sure the device is HID++ capable, otherwise treat as generic HID |
| 3562 | */ | 3760 | */ |
| 3563 | if (!hidpp_validate_device(hdev)) { | 3761 | hidpp->supported_reports = hidpp_validate_device(hdev); |
| | 3762 | |
| | 3763 | if (!hidpp->supported_reports) { |
| 3564 | hid_set_drvdata(hdev, NULL); | 3764 | hid_set_drvdata(hdev, NULL); |
| 3565 | devm_kfree(&hdev->dev, hidpp); | 3765 | devm_kfree(&hdev->dev, hidpp); |
| 3566 | return hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 3766 | return hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
| @@ -3617,7 +3817,6 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) · 50 unmodified lines |
| 3617 | if (ret < 0) { | 3817 | if (ret < 0) { |
| 3618 | dev_err(&hdev->dev, "%s:hid_hw_open returned error:%d\n", | 3818 | dev_err(&hdev->dev, "%s:hid_hw_open returned error:%d\n", |
| 3619 | __func__, ret); | 3819 | __func__, ret); |
| 3620 | hid_hw_stop(hdev); | | |
| 3621 | goto hid_hw_open_fail; | 3820 | goto hid_hw_open_fail; |
| 3622 | } | 3821 | } |
| 3623 | | 3822 | |
| @@ -3639,6 +3838,14 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) · 15 unmodified lines |
| 3639 | hidpp_overwrite_name(hdev); | 3838 | hidpp_overwrite_name(hdev); |
| 3640 | } | 3839 | } |
| 3641 | | 3840 | |
| | 3841 | if (connected && hidpp->protocol_major >= 2) { |
| | 3842 | ret = hidpp_set_wireless_feature_index(hidpp); |
| | 3843 | if (ret == -ENOENT) |
| | 3844 | hidpp->wireless_feature_index = 0; |
| | 3845 | else if (ret) |
| | 3846 | goto hid_hw_init_fail; |
| | 3847 | } |
| | 3848 | |
| 3642 | if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { | 3849 | if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { |
| 3643 | ret = wtp_get_config(hidpp); | 3850 | ret = wtp_get_config(hidpp); |
| 3644 | if (ret) | 3851 | if (ret) |
| @@ -3752,6 +3959,8 @@ static const struct hid_device_id hidpp_devices[] = { · 107 unmodified lines |
| 3752 | { LDJ_DEVICE(0x4071), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, | 3959 | { LDJ_DEVICE(0x4071), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, |
| 3753 | { /* Mouse Logitech MX Master 2S */ | 3960 | { /* Mouse Logitech MX Master 2S */ |
| 3754 | LDJ_DEVICE(0x4069), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, | 3961 | LDJ_DEVICE(0x4069), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, |
| | 3962 | { /* Mouse Logitech MX Master 3 */ |
| | 3963 | LDJ_DEVICE(0x4082), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, |
| 3755 | { /* Mouse Logitech Performance MX */ | 3964 | { /* Mouse Logitech Performance MX */ |
| 3756 | LDJ_DEVICE(0x101a), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 }, | 3965 | LDJ_DEVICE(0x101a), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 }, |
| 3757 | { /* Keyboard logitech K400 */ | 3966 | { /* Keyboard logitech K400 */ |
| @@ -3808,6 +4017,14 @@ static const struct hid_device_id hidpp_devices[] = { · 50 unmodified lines |
| 3808 | { /* MX5500 keyboard over Bluetooth */ | 4017 | { /* MX5500 keyboard over Bluetooth */ |
| 3809 | HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb30b), | 4018 | HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb30b), |
| 3810 | .driver_data = HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS }, | 4019 | .driver_data = HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS }, |
| | 4020 | { /* MX Master mouse over Bluetooth */ |
| | 4021 | HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb012), |
| | 4022 | .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, |
| | 4023 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01e), |
| | 4024 | .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, |
| | 4025 | { /* MX Master 3 mouse over Bluetooth */ |
| | 4026 | HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb023), |
| | 4027 | .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, |
| 3811 | {} | 4028 | {} |
| 3812 | }; | 4029 | }; |
| 3813 | | 4030 | |