Skip to content

Commit 5372fc3

Browse files
committed
Revert "HID: logitech: Enable high-resolution scrolling on Logitech mice"
This reverts commit d56ca98. It turns out the current API is not that compatible with some Microsoft mice, so better start again from scratch. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Acked-by: Harry Cutts <hcutts@chromium.org> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Jiri Kosina <jkosina@suse.cz>
1 parent a69616d commit 5372fc3

File tree

1 file changed

+4
-245
lines changed

1 file changed

+4
-245
lines changed

drivers/hid/hid-logitech-hidpp.c

Lines changed: 4 additions & 245 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ MODULE_PARM_DESC(disable_tap_to_click,
6464
#define HIDPP_QUIRK_NO_HIDINPUT BIT(23)
6565
#define HIDPP_QUIRK_FORCE_OUTPUT_REPORTS BIT(24)
6666
#define HIDPP_QUIRK_UNIFYING BIT(25)
67-
#define HIDPP_QUIRK_HI_RES_SCROLL_1P0 BIT(26)
68-
#define HIDPP_QUIRK_HI_RES_SCROLL_X2120 BIT(27)
69-
#define HIDPP_QUIRK_HI_RES_SCROLL_X2121 BIT(28)
70-
71-
/* Convenience constant to check for any high-res support. */
72-
#define HIDPP_QUIRK_HI_RES_SCROLL (HIDPP_QUIRK_HI_RES_SCROLL_1P0 | \
73-
HIDPP_QUIRK_HI_RES_SCROLL_X2120 | \
74-
HIDPP_QUIRK_HI_RES_SCROLL_X2121)
7567

7668
#define HIDPP_QUIRK_DELAYED_INIT HIDPP_QUIRK_NO_HIDINPUT
7769

@@ -157,7 +149,6 @@ struct hidpp_device {
157149
unsigned long capabilities;
158150

159151
struct hidpp_battery battery;
160-
struct hid_scroll_counter vertical_wheel_counter;
161152
};
162153

163154
/* HID++ 1.0 error codes */
@@ -1166,101 +1157,6 @@ static int hidpp_battery_get_property(struct power_supply *psy,
11661157
return ret;
11671158
}
11681159

1169-
/* -------------------------------------------------------------------------- */
1170-
/* 0x2120: Hi-resolution scrolling */
1171-
/* -------------------------------------------------------------------------- */
1172-
1173-
#define HIDPP_PAGE_HI_RESOLUTION_SCROLLING 0x2120
1174-
1175-
#define CMD_HI_RESOLUTION_SCROLLING_SET_HIGHRES_SCROLLING_MODE 0x10
1176-
1177-
static int hidpp_hrs_set_highres_scrolling_mode(struct hidpp_device *hidpp,
1178-
bool enabled, u8 *multiplier)
1179-
{
1180-
u8 feature_index;
1181-
u8 feature_type;
1182-
int ret;
1183-
u8 params[1];
1184-
struct hidpp_report response;
1185-
1186-
ret = hidpp_root_get_feature(hidpp,
1187-
HIDPP_PAGE_HI_RESOLUTION_SCROLLING,
1188-
&feature_index,
1189-
&feature_type);
1190-
if (ret)
1191-
return ret;
1192-
1193-
params[0] = enabled ? BIT(0) : 0;
1194-
ret = hidpp_send_fap_command_sync(hidpp, feature_index,
1195-
CMD_HI_RESOLUTION_SCROLLING_SET_HIGHRES_SCROLLING_MODE,
1196-
params, sizeof(params), &response);
1197-
if (ret)
1198-
return ret;
1199-
*multiplier = response.fap.params[1];
1200-
return 0;
1201-
}
1202-
1203-
/* -------------------------------------------------------------------------- */
1204-
/* 0x2121: HiRes Wheel */
1205-
/* -------------------------------------------------------------------------- */
1206-
1207-
#define HIDPP_PAGE_HIRES_WHEEL 0x2121
1208-
1209-
#define CMD_HIRES_WHEEL_GET_WHEEL_CAPABILITY 0x00
1210-
#define CMD_HIRES_WHEEL_SET_WHEEL_MODE 0x20
1211-
1212-
static int hidpp_hrw_get_wheel_capability(struct hidpp_device *hidpp,
1213-
u8 *multiplier)
1214-
{
1215-
u8 feature_index;
1216-
u8 feature_type;
1217-
int ret;
1218-
struct hidpp_report response;
1219-
1220-
ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL,
1221-
&feature_index, &feature_type);
1222-
if (ret)
1223-
goto return_default;
1224-
1225-
ret = hidpp_send_fap_command_sync(hidpp, feature_index,
1226-
CMD_HIRES_WHEEL_GET_WHEEL_CAPABILITY,
1227-
NULL, 0, &response);
1228-
if (ret)
1229-
goto return_default;
1230-
1231-
*multiplier = response.fap.params[0];
1232-
return 0;
1233-
return_default:
1234-
*multiplier = 8;
1235-
hid_warn(hidpp->hid_dev,
1236-
"Couldn't get wheel multiplier (error %d), assuming %d.\n",
1237-
ret, *multiplier);
1238-
return ret;
1239-
}
1240-
1241-
static int hidpp_hrw_set_wheel_mode(struct hidpp_device *hidpp, bool invert,
1242-
bool high_resolution, bool use_hidpp)
1243-
{
1244-
u8 feature_index;
1245-
u8 feature_type;
1246-
int ret;
1247-
u8 params[1];
1248-
struct hidpp_report response;
1249-
1250-
ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL,
1251-
&feature_index, &feature_type);
1252-
if (ret)
1253-
return ret;
1254-
1255-
params[0] = (invert ? BIT(2) : 0) |
1256-
(high_resolution ? BIT(1) : 0) |
1257-
(use_hidpp ? BIT(0) : 0);
1258-
1259-
return hidpp_send_fap_command_sync(hidpp, feature_index,
1260-
CMD_HIRES_WHEEL_SET_WHEEL_MODE,
1261-
params, sizeof(params), &response);
1262-
}
1263-
12641160
/* -------------------------------------------------------------------------- */
12651161
/* 0x4301: Solar Keyboard */
12661162
/* -------------------------------------------------------------------------- */
@@ -2524,8 +2420,7 @@ static int m560_raw_event(struct hid_device *hdev, u8 *data, int size)
25242420
input_report_rel(mydata->input, REL_Y, v);
25252421

25262422
v = hid_snto32(data[6], 8);
2527-
hid_scroll_counter_handle_scroll(
2528-
&hidpp->vertical_wheel_counter, v);
2423+
input_report_rel(mydata->input, REL_WHEEL, v);
25292424

25302425
input_sync(mydata->input);
25312426
}
@@ -2653,73 +2548,6 @@ static int g920_get_config(struct hidpp_device *hidpp)
26532548
return 0;
26542549
}
26552550

2656-
/* -------------------------------------------------------------------------- */
2657-
/* High-resolution scroll wheels */
2658-
/* -------------------------------------------------------------------------- */
2659-
2660-
/**
2661-
* struct hi_res_scroll_info - Stores info on a device's high-res scroll wheel.
2662-
* @product_id: the HID product ID of the device being described.
2663-
* @microns_per_hi_res_unit: the distance moved by the user's finger for each
2664-
* high-resolution unit reported by the device, in
2665-
* 256ths of a millimetre.
2666-
*/
2667-
struct hi_res_scroll_info {
2668-
__u32 product_id;
2669-
int microns_per_hi_res_unit;
2670-
};
2671-
2672-
static struct hi_res_scroll_info hi_res_scroll_devices[] = {
2673-
{ /* Anywhere MX */
2674-
.product_id = 0x1017, .microns_per_hi_res_unit = 445 },
2675-
{ /* Performance MX */
2676-
.product_id = 0x101a, .microns_per_hi_res_unit = 406 },
2677-
{ /* M560 */
2678-
.product_id = 0x402d, .microns_per_hi_res_unit = 435 },
2679-
{ /* MX Master 2S */
2680-
.product_id = 0x4069, .microns_per_hi_res_unit = 406 },
2681-
};
2682-
2683-
static int hi_res_scroll_look_up_microns(__u32 product_id)
2684-
{
2685-
int i;
2686-
int num_devices = sizeof(hi_res_scroll_devices)
2687-
/ sizeof(hi_res_scroll_devices[0]);
2688-
for (i = 0; i < num_devices; i++) {
2689-
if (hi_res_scroll_devices[i].product_id == product_id)
2690-
return hi_res_scroll_devices[i].microns_per_hi_res_unit;
2691-
}
2692-
/* We don't have a value for this device, so use a sensible default. */
2693-
return 406;
2694-
}
2695-
2696-
static int hi_res_scroll_enable(struct hidpp_device *hidpp)
2697-
{
2698-
int ret;
2699-
u8 multiplier;
2700-
2701-
if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2121) {
2702-
ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false);
2703-
hidpp_hrw_get_wheel_capability(hidpp, &multiplier);
2704-
} else if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2120) {
2705-
ret = hidpp_hrs_set_highres_scrolling_mode(hidpp, true,
2706-
&multiplier);
2707-
} else /* if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_1P0) */ {
2708-
ret = hidpp10_enable_scrolling_acceleration(hidpp);
2709-
multiplier = 8;
2710-
}
2711-
if (ret)
2712-
return ret;
2713-
2714-
hidpp->vertical_wheel_counter.resolution_multiplier = multiplier;
2715-
hidpp->vertical_wheel_counter.microns_per_hi_res_unit =
2716-
hi_res_scroll_look_up_microns(hidpp->hid_dev->product);
2717-
hid_info(hidpp->hid_dev, "multiplier = %d, microns = %d\n",
2718-
multiplier,
2719-
hidpp->vertical_wheel_counter.microns_per_hi_res_unit);
2720-
return 0;
2721-
}
2722-
27232551
/* -------------------------------------------------------------------------- */
27242552
/* Generic HID++ devices */
27252553
/* -------------------------------------------------------------------------- */
@@ -2765,11 +2593,6 @@ static void hidpp_populate_input(struct hidpp_device *hidpp,
27652593
wtp_populate_input(hidpp, input, origin_is_hid_core);
27662594
else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560)
27672595
m560_populate_input(hidpp, input, origin_is_hid_core);
2768-
2769-
if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) {
2770-
input_set_capability(input, EV_REL, REL_WHEEL_HI_RES);
2771-
hidpp->vertical_wheel_counter.dev = input;
2772-
}
27732596
}
27742597

27752598
static int hidpp_input_configured(struct hid_device *hdev,
@@ -2888,27 +2711,6 @@ static int hidpp_raw_event(struct hid_device *hdev, struct hid_report *report,
28882711
return 0;
28892712
}
28902713

2891-
static int hidpp_event(struct hid_device *hdev, struct hid_field *field,
2892-
struct hid_usage *usage, __s32 value)
2893-
{
2894-
/* This function will only be called for scroll events, due to the
2895-
* restriction imposed in hidpp_usages.
2896-
*/
2897-
struct hidpp_device *hidpp = hid_get_drvdata(hdev);
2898-
struct hid_scroll_counter *counter = &hidpp->vertical_wheel_counter;
2899-
/* A scroll event may occur before the multiplier has been retrieved or
2900-
* the input device set, or high-res scroll enabling may fail. In such
2901-
* cases we must return early (falling back to default behaviour) to
2902-
* avoid a crash in hid_scroll_counter_handle_scroll.
2903-
*/
2904-
if (!(hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) || value == 0
2905-
|| counter->dev == NULL || counter->resolution_multiplier == 0)
2906-
return 0;
2907-
2908-
hid_scroll_counter_handle_scroll(counter, value);
2909-
return 1;
2910-
}
2911-
29122714
static int hidpp_initialize_battery(struct hidpp_device *hidpp)
29132715
{
29142716
static atomic_t battery_no = ATOMIC_INIT(0);
@@ -3120,9 +2922,6 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
31202922
if (hidpp->battery.ps)
31212923
power_supply_changed(hidpp->battery.ps);
31222924

3123-
if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL)
3124-
hi_res_scroll_enable(hidpp);
3125-
31262925
if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input)
31272926
/* if the input nodes are already created, we can stop now */
31282927
return;
@@ -3308,10 +3107,6 @@ static void hidpp_remove(struct hid_device *hdev)
33083107
mutex_destroy(&hidpp->send_mutex);
33093108
}
33103109

3311-
#define LDJ_DEVICE(product) \
3312-
HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, \
3313-
USB_VENDOR_ID_LOGITECH, (product))
3314-
33153110
static const struct hid_device_id hidpp_devices[] = {
33163111
{ /* wireless touchpad */
33173112
HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
@@ -3326,39 +3121,10 @@ static const struct hid_device_id hidpp_devices[] = {
33263121
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH,
33273122
USB_DEVICE_ID_LOGITECH_T651),
33283123
.driver_data = HIDPP_QUIRK_CLASS_WTP },
3329-
{ /* Mouse Logitech Anywhere MX */
3330-
LDJ_DEVICE(0x1017), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 },
3331-
{ /* Mouse Logitech Cube */
3332-
LDJ_DEVICE(0x4010), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2120 },
3333-
{ /* Mouse Logitech M335 */
3334-
LDJ_DEVICE(0x4050), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3335-
{ /* Mouse Logitech M515 */
3336-
LDJ_DEVICE(0x4007), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2120 },
33373124
{ /* Mouse logitech M560 */
3338-
LDJ_DEVICE(0x402d),
3339-
.driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_CLASS_M560
3340-
| HIDPP_QUIRK_HI_RES_SCROLL_X2120 },
3341-
{ /* Mouse Logitech M705 (firmware RQM17) */
3342-
LDJ_DEVICE(0x101b), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 },
3343-
{ /* Mouse Logitech M705 (firmware RQM67) */
3344-
LDJ_DEVICE(0x406d), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3345-
{ /* Mouse Logitech M720 */
3346-
LDJ_DEVICE(0x405e), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3347-
{ /* Mouse Logitech MX Anywhere 2 */
3348-
LDJ_DEVICE(0x404a), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3349-
{ LDJ_DEVICE(0xb013), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3350-
{ LDJ_DEVICE(0xb018), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3351-
{ LDJ_DEVICE(0xb01f), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3352-
{ /* Mouse Logitech MX Anywhere 2S */
3353-
LDJ_DEVICE(0x406a), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3354-
{ /* Mouse Logitech MX Master */
3355-
LDJ_DEVICE(0x4041), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3356-
{ LDJ_DEVICE(0x4060), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3357-
{ LDJ_DEVICE(0x4071), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3358-
{ /* Mouse Logitech MX Master 2S */
3359-
LDJ_DEVICE(0x4069), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
3360-
{ /* Mouse Logitech Performance MX */
3361-
LDJ_DEVICE(0x101a), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 },
3125+
HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
3126+
USB_VENDOR_ID_LOGITECH, 0x402d),
3127+
.driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_CLASS_M560 },
33623128
{ /* Keyboard logitech K400 */
33633129
HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
33643130
USB_VENDOR_ID_LOGITECH, 0x4024),
@@ -3378,19 +3144,12 @@ static const struct hid_device_id hidpp_devices[] = {
33783144

33793145
MODULE_DEVICE_TABLE(hid, hidpp_devices);
33803146

3381-
static const struct hid_usage_id hidpp_usages[] = {
3382-
{ HID_GD_WHEEL, EV_REL, REL_WHEEL },
3383-
{ HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
3384-
};
3385-
33863147
static struct hid_driver hidpp_driver = {
33873148
.name = "logitech-hidpp-device",
33883149
.id_table = hidpp_devices,
33893150
.probe = hidpp_probe,
33903151
.remove = hidpp_remove,
33913152
.raw_event = hidpp_raw_event,
3392-
.usage_table = hidpp_usages,
3393-
.event = hidpp_event,
33943153
.input_configured = hidpp_input_configured,
33953154
.input_mapping = hidpp_input_mapping,
33963155
.input_mapped = hidpp_input_mapped,

0 commit comments

Comments
 (0)