| @@ -1542,52 +1542,71 @@ static void hidinput_close(struct input_dev *dev) · 1541 unmodified lines |
| 1542 | 1542 | hid_hw_close(hid); |
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | | −static void hidinput_change_resolution_multipliers(struct hid_device *hid) |
| 1545 | +static bool __hidinput_change_resolution_multipliers(struct hid_device *hid, |
| 1546 | + struct hid_report *report, bool use_logical_max) |
| 1546 | 1547 | { |
| 1547 | | − struct hid_report_enum *rep_enum; |
| 1548 | | − struct hid_report *rep; |
| 1549 | 1548 | struct hid_usage *usage; |
| 1549 | + bool update_needed = false; |
| 1550 | 1550 | int i, j; |
| 1551 | 1551 | |
| 1552 | | − rep_enum = &hid->report_enum[HID_FEATURE_REPORT]; |
| 1553 | | − list_for_each_entry(rep, &rep_enum->report_list, list) { |
| 1554 | | − bool update_needed = false; |
| 1552 | + if (report->maxfield == 0) |
| 1553 | + return false; |
| 1555 | 1554 | |
| 1556 | | − if (rep->maxfield == 0) |
| 1557 | | − continue; |
| 1555 | + /* |
| 1556 | + * If we have more than one feature within this report we |
| 1557 | + * need to fill in the bits from the others before we can |
| 1558 | + * overwrite the ones for the Resolution Multiplier. |
| 1559 | + */ |
| 1560 | + if (report->maxfield > 1) { |
| 1561 | + hid_hw_request(hid, report, HID_REQ_GET_REPORT); |
| 1562 | + hid_hw_wait(hid); |
| 1563 | + } |
| 1558 | 1564 | |
| 1559 | | − /* |
| 1560 | | − * If we have more than one feature within this report we |
| 1561 | | − * need to fill in the bits from the others before we can |
| 1562 | | − * overwrite the ones for the Resolution Multiplier. |
| 1565 | + for (i = 0; i < report->maxfield; i++) { |
| 1566 | + __s32 value = use_logical_max ? |
| 1567 | + report->field[i]->logical_maximum : |
| 1568 | + report->field[i]->logical_minimum; |
| 1569 | + |
| 1570 | + /* There is no good reason for a Resolution |
| 1571 | + * Multiplier to have a count other than 1. |
| 1572 | + * Ignore that case. |
| 1563 | 1573 | */ |
| 1564 | | − if (rep->maxfield > 1) { |
| 1565 | | − hid_hw_request(hid, rep, HID_REQ_GET_REPORT); |
| 1566 | | − hid_hw_wait(hid); |
| 1567 | | − } |
| 1574 | + if (report->field[i]->report_count != 1) |
| 1575 | + continue; |
| 1568 | 1576 | |
| 1569 | | − for (i = 0; i < rep->maxfield; i++) { |
| 1570 | | − __s32 logical_max = rep->field[i]->logical_maximum; |
| 1577 | + for (j = 0; j < report->field[i]->maxusage; j++) { |
| 1578 | + usage = &report->field[i]->usage[j]; |
| 1571 | 1579 | |
| 1572 | | − /* There is no good reason for a Resolution |
| 1573 | | − * Multiplier to have a count other than 1. |
| 1574 | | − * Ignore that case. |
| 1575 | | − */ |
| 1576 | | − if (rep->field[i]->report_count != 1) |
| 1580 | + if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER) |
| 1577 | 1581 | continue; |
| 1578 | 1582 | |
| 1579 | | − for (j = 0; j < rep->field[i]->maxusage; j++) { |
| 1580 | | − usage = &rep->field[i]->usage[j]; |
| 1583 | + *report->field[i]->value = value; |
| 1584 | + update_needed = true; |
| 1585 | + } |
| 1586 | + } |
| 1587 | + |
| 1588 | + return update_needed; |
| 1589 | +} |
| 1581 | 1590 | |
| 1582 | | − if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER) |
| 1583 | | − continue; |
| 1591 | +static void hidinput_change_resolution_multipliers(struct hid_device *hid) |
| 1592 | +{ |
| 1593 | + struct hid_report_enum *rep_enum; |
| 1594 | + struct hid_report *rep; |
| 1595 | + int ret; |
| 1584 | 1596 | |
| 1585 | | − *rep->field[i]->value = logical_max; |
| 1586 | | − update_needed = true; |
| 1597 | + rep_enum = &hid->report_enum[HID_FEATURE_REPORT]; |
| 1598 | + list_for_each_entry(rep, &rep_enum->report_list, list) { |
| 1599 | + bool update_needed = __hidinput_change_resolution_multipliers(hid, |
| 1600 | + rep, true); |
| 1601 | + |
| 1602 | + if (update_needed) { |
| 1603 | + ret = __hid_request(hid, rep, HID_REQ_SET_REPORT); |
| 1604 | + if (ret) { |
| 1605 | + __hidinput_change_resolution_multipliers(hid, |
| 1606 | + rep, false); |
| 1607 | + return; |
| 1587 | 1608 | } |
| 1588 | 1609 | } |
| 1589 | | − if (update_needed) |
| 1590 | | − hid_hw_request(hid, rep, HID_REQ_SET_REPORT); |
| 1591 | 1610 | } |
| 1592 | 1611 | |
| 1593 | 1612 | /* refresh our structs */ |