All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 0/4] Improve support for Logitech MX Anywhere 2
@ 2017-03-25 22:49 Mauro Carvalho Chehab
  2017-03-25 22:49 ` [PATCH RFC 1/4] input: add an EV_REL event for high-res vertical wheel Mauro Carvalho Chehab
  0 siblings, 1 reply; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2017-03-25 22:49 UTC (permalink / raw)
  To: linux-input
  Cc: Mauro Carvalho Chehab, Dmitry Torokhov, Peter Hutterer,
	Benjamin Tissoires, Hans Verkuil, Jiri Kosina,
	Greg Kroah-Hartman, Stuart Yoder, Ingo Tuchscherer,
	Douglas Anderson, Martin Schwidefsky, Kamil Debski, Ping Cheng,
	Mauro Carvalho Chehab

Logitech MX Anywhere 2 and MX Master have a high res wheel, with
is currently supported only in legacy low-resolution mode.

Add the needed bits to support it.

Note: The approach taken here were to add a new EV_REL event
when the device generates output in high-resolution mode, as it
would not require any changes on userspace for low resolution.

Implementing support for high resolution mode should also be simple.

Mauro Carvalho Chehab (4):
  input: add an EV_REL event for high-res vertical wheel
  hid-logitech-hidpp: add support for high res wheel
  input: add a EV_SW event for ratchet switch
  hid-logitech-hidpp: add support for ratchet switch

 drivers/hid/hid-logitech-hidpp.c       | 216 +++++++++++++++++++++++++++++++++
 include/linux/mod_devicetable.h        |   2 +-
 include/uapi/linux/input-event-codes.h |   5 +-
 3 files changed, 221 insertions(+), 2 deletions(-)

-- 
2.9.3



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH RFC 1/4] input: add an EV_REL event for high-res vertical wheel
  2017-03-25 22:49 [PATCH RFC 0/4] Improve support for Logitech MX Anywhere 2 Mauro Carvalho Chehab
@ 2017-03-25 22:49 ` Mauro Carvalho Chehab
  2017-03-25 22:49   ` [PATCH RFC 2/4] hid-logitech-hidpp: add support for high res wheel Mauro Carvalho Chehab
  2017-03-27  1:40   ` [PATCH RFC 1/4] input: add an EV_REL event for high-res vertical wheel Peter Hutterer
  0 siblings, 2 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2017-03-25 22:49 UTC (permalink / raw)
  To: linux-input
  Cc: Mauro Carvalho Chehab, Dmitry Torokhov, Peter Hutterer,
	Benjamin Tissoires, Hans Verkuil, Mauro Carvalho Chehab,
	Douglas Anderson, Kamil Debski, Ping Cheng

As some devices can produce either low-res or high-res
vertical wheel EV_REL events, add a new event to allow
userspace to distinguish between them.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 include/uapi/linux/input-event-codes.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 3af60ee69053..23b2d377af59 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -703,6 +703,7 @@
 #define REL_DIAL		0x07
 #define REL_WHEEL		0x08
 #define REL_MISC		0x09
+#define REL_HIRES_WHEEL		0x0a
 #define REL_MAX			0x0f
 #define REL_CNT			(REL_MAX+1)
 
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH RFC 2/4] hid-logitech-hidpp: add support for high res wheel
  2017-03-25 22:49 ` [PATCH RFC 1/4] input: add an EV_REL event for high-res vertical wheel Mauro Carvalho Chehab
@ 2017-03-25 22:49   ` Mauro Carvalho Chehab
  2017-03-25 22:49     ` [PATCH RFC 3/4] input: add a EV_SW event for ratchet switch Mauro Carvalho Chehab
  2017-03-27  1:40   ` [PATCH RFC 1/4] input: add an EV_REL event for high-res vertical wheel Peter Hutterer
  1 sibling, 1 reply; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2017-03-25 22:49 UTC (permalink / raw)
  To: linux-input
  Cc: Mauro Carvalho Chehab, Dmitry Torokhov, Peter Hutterer,
	Benjamin Tissoires, Jiri Kosina

Some Logitech mouses (MX Anyware 2 and MX Master) have support
for a high-resolution wheel.

This wheel can work in backward-compatible mode, generating
wheel events via HID normal events, or it can use new
HID++ events that report not only the wheel movement, but also
the resolution.

Add support for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/hid/hid-logitech-hidpp.c | 197 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 197 insertions(+)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 2e2515a4c070..ee3f544bda4f 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -62,6 +62,7 @@ MODULE_PARM_DESC(disable_tap_to_click,
 #define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS	BIT(22)
 #define HIDPP_QUIRK_NO_HIDINPUT			BIT(23)
 #define HIDPP_QUIRK_FORCE_OUTPUT_REPORTS	BIT(24)
+#define HIDPP_QUIRK_HIRES_SCROLL		BIT(25)
 
 #define HIDPP_QUIRK_DELAYED_INIT		(HIDPP_QUIRK_NO_HIDINPUT | \
 						 HIDPP_QUIRK_CONNECT_EVENTS)
@@ -1361,6 +1362,67 @@ static int hidpp_ff_deinit(struct hid_device *hid)
 	return 0;
 }
 
+/* -------------------------------------------------------------------------- */
+/* 0x2121: High Resolution Wheel                                              */
+/* -------------------------------------------------------------------------- */
+
+#define HIDPP_HIGH_RES_WHEEL		0x2121
+
+#define CMD_MOUSE_SET_WHEEL_MODE	0x20
+#define CMD_MOUSE_GET_WHEEL_RATCHET	0x30
+
+struct high_res_wheel_data {
+	u8 feature_index;
+	struct input_dev *input;
+	bool ratchet;
+};
+
+/**
+ * hidpp_mouse_set_wheel_mode - Sets high resolution wheel mode
+ *
+ * @invert:	if true, inverts wheel movement
+ * @high_res:	if true, wheel is in high-resolution mode. Otherwise, low res
+ * @hidpp:	if true, report wheel events via HID++ notification. If false,
+ *		use standard HID events
+ */
+static int hidpp_mouse_set_wheel_mode(struct hidpp_device *hidpp,
+				      bool invert,
+				      bool high_res,
+				      bool hidpp_mode)
+{
+	struct high_res_wheel_data *hrd = hidpp->private_data;
+	u8 feature_type;
+	struct hidpp_report response;
+	int ret;
+	u8 params[16] = { 0 };
+
+	if (!hrd->feature_index) {
+		ret = hidpp_root_get_feature(hidpp,
+					    HIDPP_HIGH_RES_WHEEL,
+					    &hrd->feature_index,
+					    &feature_type);
+		if (ret)
+			/* means that the device is not powered up */
+			return ret;
+	}
+
+	params[0] = invert     ? 0x4 : 0  |
+		    high_res   ? 0x2 : 0  |
+		    hidpp_mode ? 0x1 : 0;
+
+	ret = hidpp_send_fap_command_sync(hidpp, hrd->feature_index,
+					  CMD_MOUSE_SET_WHEEL_MODE,
+					  params, 16, &response);
+	if (ret > 0) {
+		hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
+			__func__, ret);
+		return -EPROTO;
+	}
+	if (ret)
+		return ret;
+
+	return 0;
+}
 
 /* ************************************************************************** */
 /*                                                                            */
@@ -1816,6 +1878,119 @@ static int m560_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 }
 
 /* ------------------------------------------------------------------------- */
+/* Logitech mouse devices with high resolution wheel                         */
+/* ------------------------------------------------------------------------- */
+
+static int high_res_raw_event(struct hid_device *hdev, u8 *data, int size)
+{
+	struct hidpp_device *hidpp = hid_get_drvdata(hdev);
+	struct high_res_wheel_data *hrd = hidpp->private_data;
+
+	/* Don't handle special raw events before setting feature_index */
+	if (!hrd || !hrd->feature_index)
+		return 0;
+
+	if (data[0] != REPORT_ID_HIDPP_LONG ||
+	    data[2] != hrd->feature_index)
+		return 1;
+
+	if (size < 8) {
+		hid_err(hdev, "error in report: size = %d: %*ph\n", size,
+			size, data);
+		return 0;
+	}
+
+	/*
+	 * high res wheel mouse events
+	 *
+	 * Wheel movement events are like:
+	 *
+	 * 11 03 0b 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
+	 *
+	 * data[0] = 0x11
+	 * data[1] = device-id
+	 * data[2] = feature index (0b)
+	 * data[3] = event type: 0x00 - wheel movement
+	 * data[4] = bitmask:
+	 *		bits 0-3: number of sampling periods combined
+	 *		bit 4:
+	 *			0 = low resolution
+	 *			1 = high resolution
+	 * data[5] - deltaV MSB
+	 * data[6] = deltaV LSB
+	 * Remaining payload is reserved
+	 *
+	 * Ratchet events are like:
+	 * 11 03 0b 10 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+	 *
+	 * data[0] = 0x11
+	 * data[1] = device-id
+	 * data[2] = feature index
+	 * data[3] = event type: 0x10 - ratchet state
+	 * data[4] = bit 0:
+	 *		1 = ratchet
+	 *		0 = free wheel
+	 * Remaining payload is reserved
+	 */
+
+	if (data[3] == 0) {
+		s16 delta = data[6] | data[5] << 8;
+		bool res = data[4] & 0x10;
+
+		/*
+		 * Report high-resolution events as REL_HWHEEL and
+		 * low-resolution events as REL_WHEEL.
+		 */
+		if (res)
+			input_report_rel(hrd->input, REL_HIRES_WHEEL, delta);
+		else
+			input_report_rel(hrd->input, REL_WHEEL, delta);
+	}
+
+	/* FIXME: also report ratchet events to userspace */
+
+	return 1;
+}
+
+static void high_res_populate_input(struct hidpp_device *hidpp,
+		struct input_dev *input_dev, bool origin_is_hid_core)
+{
+	struct high_res_wheel_data *hrd = hidpp->private_data;
+
+	hrd->input = input_dev;
+
+	__set_bit(REL_WHEEL, hrd->input->relbit);
+	__set_bit(REL_HIRES_WHEEL, hrd->input->relbit);
+}
+
+
+static int high_res_allocate(struct hid_device *hdev)
+{
+	struct hidpp_device *hidpp = hid_get_drvdata(hdev);
+	struct high_res_wheel_data *hrd;
+
+	hrd = devm_kzalloc(&hdev->dev, sizeof(struct high_res_wheel_data),
+			GFP_KERNEL);
+	if (!hrd)
+		return -ENOMEM;
+
+	hidpp->private_data = hrd;
+
+	return 0;
+};
+
+static int high_res_connect(struct hid_device *hdev, bool connected)
+{
+	struct hidpp_device *hidpp = hid_get_drvdata(hdev);
+
+	if (!connected)
+		return 0;
+
+	/* Enable HID++ wheel event output mode */
+	return hidpp_mouse_set_wheel_mode(hidpp, false, false, true);
+}
+
+/* ------------------------------------------------------------------------- */
 /* Logitech K400 devices                                                     */
 /* ------------------------------------------------------------------------- */
 
@@ -1955,6 +2130,9 @@ static void hidpp_populate_input(struct hidpp_device *hidpp,
 		wtp_populate_input(hidpp, input, origin_is_hid_core);
 	else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560)
 		m560_populate_input(hidpp, input, origin_is_hid_core);
+	else if (hidpp->quirks & HIDPP_QUIRK_HIRES_SCROLL)
+		high_res_populate_input(hidpp, input, origin_is_hid_core);
+
 }
 
 static int hidpp_input_configured(struct hid_device *hdev,
@@ -2054,6 +2232,8 @@ static int hidpp_raw_event(struct hid_device *hdev, struct hid_report *report,
 		return wtp_raw_event(hdev, data, size);
 	else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560)
 		return m560_raw_event(hdev, data, size);
+	else if (hidpp->quirks & HIDPP_QUIRK_HIRES_SCROLL)
+		return high_res_raw_event(hdev, data, size);
 
 	return 0;
 }
@@ -2141,6 +2321,10 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
 		ret = k400_connect(hdev, connected);
 		if (ret)
 			return;
+	} else if (hidpp->quirks & HIDPP_QUIRK_HIRES_SCROLL) {
+		ret = high_res_connect(hdev, connected);
+		if (ret)
+			return;
 	}
 
 	if (!connected || hidpp->delayed_input)
@@ -2215,6 +2399,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP;
 		hidpp->quirks &= ~HIDPP_QUIRK_CONNECT_EVENTS;
 		hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT;
+		hidpp->quirks &= ~HIDPP_QUIRK_HIRES_SCROLL;
 	}
 
 	if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) {
@@ -2229,6 +2414,10 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		ret = k400_allocate(hdev);
 		if (ret)
 			goto allocate_fail;
+	} else if (hidpp->quirks & HIDPP_QUIRK_HIRES_SCROLL) {
+		ret = high_res_allocate(hdev);
+		if (ret)
+			goto allocate_fail;
 	}
 
 	INIT_WORK(&hidpp->work, delayed_work_cb);
@@ -2354,6 +2543,14 @@ static const struct hid_device_id hidpp_devices[] = {
 	  HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
 		USB_VENDOR_ID_LOGITECH, 0x402d),
 	  .driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_CLASS_M560 },
+	{ /* Logitech MX Master with high resolution scroll */
+	  HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
+		USB_VENDOR_ID_LOGITECH, 0x4041),
+	  .driver_data = HIDPP_QUIRK_CONNECT_EVENTS | HIDPP_QUIRK_HIRES_SCROLL },
+	{ /* Logitech MX Anywhere 2r with high resolution scroll */
+	  HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
+		USB_VENDOR_ID_LOGITECH, 0x404a),
+	  .driver_data = HIDPP_QUIRK_CONNECT_EVENTS | HIDPP_QUIRK_HIRES_SCROLL },
 	{ /* Keyboard logitech K400 */
 	  HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
 		USB_VENDOR_ID_LOGITECH, 0x4024),
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH RFC 3/4] input: add a EV_SW event for ratchet switch
  2017-03-25 22:49   ` [PATCH RFC 2/4] hid-logitech-hidpp: add support for high res wheel Mauro Carvalho Chehab
@ 2017-03-25 22:49     ` Mauro Carvalho Chehab
  2017-03-25 22:49       ` [PATCH RFC 4/4] hid-logitech-hidpp: add support " Mauro Carvalho Chehab
  2017-03-27  1:53       ` [PATCH RFC 3/4] input: add a EV_SW event " Peter Hutterer
  0 siblings, 2 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2017-03-25 22:49 UTC (permalink / raw)
  To: linux-input
  Cc: Mauro Carvalho Chehab, Dmitry Torokhov, Peter Hutterer,
	Benjamin Tissoires, Greg Kroah-Hartman, Martin Schwidefsky,
	Mauro Carvalho Chehab, Ingo Tuchscherer, Stuart Yoder,
	Hans Verkuil, Douglas Anderson, Ping Cheng, Kamil Debski

Some mouses have a switch on their wheel, allowing to switch
between ratchet or free wheel mode. Add support for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 include/linux/mod_devicetable.h        | 2 +-
 include/uapi/linux/input-event-codes.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 8a57f0b1242d..73534c591b40 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -292,7 +292,7 @@ struct pcmcia_device_id {
 #define INPUT_DEVICE_ID_LED_MAX		0x0f
 #define INPUT_DEVICE_ID_SND_MAX		0x07
 #define INPUT_DEVICE_ID_FF_MAX		0x7f
-#define INPUT_DEVICE_ID_SW_MAX		0x0f
+#define INPUT_DEVICE_ID_SW_MAX		0x1f
 
 #define INPUT_DEVICE_ID_MATCH_BUS	1
 #define INPUT_DEVICE_ID_MATCH_VENDOR	2
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 23b2d377af59..a3eafd0527f1 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -782,7 +782,9 @@
 #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
 #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
 #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
-#define SW_MAX			0x0f
+#define SW_RATCHET		0x10  /* set = ratchet mode,
+					 unset: free wheel */
+#define SW_MAX			0x1f
 #define SW_CNT			(SW_MAX+1)
 
 /*
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH RFC 4/4] hid-logitech-hidpp: add support for ratchet switch
  2017-03-25 22:49     ` [PATCH RFC 3/4] input: add a EV_SW event for ratchet switch Mauro Carvalho Chehab
@ 2017-03-25 22:49       ` Mauro Carvalho Chehab
  2017-03-27  1:53       ` [PATCH RFC 3/4] input: add a EV_SW event " Peter Hutterer
  1 sibling, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2017-03-25 22:49 UTC (permalink / raw)
  To: linux-input
  Cc: Mauro Carvalho Chehab, Dmitry Torokhov, Peter Hutterer,
	Benjamin Tissoires, Jiri Kosina

Logitech Anywhere MX2 and MX master produce events for
the wheel ratchet/free wheel button. Add support for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/hid/hid-logitech-hidpp.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index ee3f544bda4f..72f80869633f 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -1406,6 +1406,19 @@ static int hidpp_mouse_set_wheel_mode(struct hidpp_device *hidpp,
 			return ret;
 	}
 
+	ret = hidpp_send_fap_command_sync(hidpp, hrd->feature_index,
+					  CMD_MOUSE_GET_WHEEL_RATCHET,
+					  params, 16, &response);
+	if (ret > 0) {
+		hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
+			__func__, ret);
+		return -EPROTO;
+	}
+	if (ret)
+		return ret;
+
+	hrd->ratchet = response.fap.params[0] & 0x01;
+
 	params[0] = invert     ? 0x4 : 0  |
 		    high_res   ? 0x2 : 0  |
 		    hidpp_mode ? 0x1 : 0;
@@ -1945,10 +1958,11 @@ static int high_res_raw_event(struct hid_device *hdev, u8 *data, int size)
 			input_report_rel(hrd->input, REL_HIRES_WHEEL, delta);
 		else
 			input_report_rel(hrd->input, REL_WHEEL, delta);
+	} else if (data[3] == 0x10) {
+		hrd->ratchet = data[4] & 0x01;
+		input_report_switch(hrd->input, SW_RATCHET, hrd->ratchet);
 	}
 
-	/* FIXME: also report ratchet events to userspace */
-
 	return 1;
 }
 
@@ -1961,6 +1975,11 @@ static void high_res_populate_input(struct hidpp_device *hidpp,
 
 	__set_bit(REL_WHEEL, hrd->input->relbit);
 	__set_bit(REL_HIRES_WHEEL, hrd->input->relbit);
+	__set_bit(EV_SW, hrd->input->evbit);
+	__set_bit(SW_RATCHET, hrd->input->swbit);
+
+	/* Report current state of the ratchet switch */
+	input_report_switch(hrd->input, SW_RATCHET, hrd->ratchet);
 }
 
 
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH RFC 1/4] input: add an EV_REL event for high-res vertical wheel
  2017-03-25 22:49 ` [PATCH RFC 1/4] input: add an EV_REL event for high-res vertical wheel Mauro Carvalho Chehab
  2017-03-25 22:49   ` [PATCH RFC 2/4] hid-logitech-hidpp: add support for high res wheel Mauro Carvalho Chehab
@ 2017-03-27  1:40   ` Peter Hutterer
  1 sibling, 0 replies; 10+ messages in thread
From: Peter Hutterer @ 2017-03-27  1:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-input, Dmitry Torokhov, Benjamin Tissoires, Hans Verkuil,
	Mauro Carvalho Chehab, Douglas Anderson, Kamil Debski,
	Ping Cheng

On Sat, Mar 25, 2017 at 07:49:39PM -0300, Mauro Carvalho Chehab wrote:
> As some devices can produce either low-res or high-res
> vertical wheel EV_REL events, add a new event to allow
> userspace to distinguish between them.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

Just replied to the other email, but this one is a nak until we have the
Documentation/input/event-codes.txt patch with it explaining how this code
should be used, what these codes represent, what the interaction is with
other codes (e.g. can a device send wheel and hires wheel at the same time?)
etc. There are a lot of questions left to be answered.

Cheers,
   Peter

> ---
>  include/uapi/linux/input-event-codes.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 3af60ee69053..23b2d377af59 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -703,6 +703,7 @@
>  #define REL_DIAL		0x07
>  #define REL_WHEEL		0x08
>  #define REL_MISC		0x09
> +#define REL_HIRES_WHEEL		0x0a
>  #define REL_MAX			0x0f
>  #define REL_CNT			(REL_MAX+1)
>  
> -- 
> 2.9.3
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH RFC 3/4] input: add a EV_SW event for ratchet switch
  2017-03-25 22:49     ` [PATCH RFC 3/4] input: add a EV_SW event for ratchet switch Mauro Carvalho Chehab
  2017-03-25 22:49       ` [PATCH RFC 4/4] hid-logitech-hidpp: add support " Mauro Carvalho Chehab
@ 2017-03-27  1:53       ` Peter Hutterer
  2017-03-27 12:27         ` Mauro Carvalho Chehab
  1 sibling, 1 reply; 10+ messages in thread
From: Peter Hutterer @ 2017-03-27  1:53 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-input, Dmitry Torokhov, Benjamin Tissoires,
	Greg Kroah-Hartman, Martin Schwidefsky, Mauro Carvalho Chehab,
	Ingo Tuchscherer, Stuart Yoder, Hans Verkuil, Douglas Anderson,
	Ping Cheng, Kamil Debski

On Sat, Mar 25, 2017 at 07:49:41PM -0300, Mauro Carvalho Chehab wrote:
> Some mouses have a switch on their wheel, allowing to switch
> between ratchet or free wheel mode. Add support for it.

I understand the want to support it because it's there but what do you
expect this to be used for?

tbh, I wouldn't know what to do with this information, short of displaying
some OSD to inform the user. Which is rather superfluous since the physical
change will feel obvious anyway.

A Documentation/input/event-codes.txt hunk would be welcomed here too
btw.

Cheers,
   Peter

> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  include/linux/mod_devicetable.h        | 2 +-
>  include/uapi/linux/input-event-codes.h | 4 +++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 8a57f0b1242d..73534c591b40 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -292,7 +292,7 @@ struct pcmcia_device_id {
>  #define INPUT_DEVICE_ID_LED_MAX		0x0f
>  #define INPUT_DEVICE_ID_SND_MAX		0x07
>  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> +#define INPUT_DEVICE_ID_SW_MAX		0x1f
>  
>  #define INPUT_DEVICE_ID_MATCH_BUS	1
>  #define INPUT_DEVICE_ID_MATCH_VENDOR	2
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 23b2d377af59..a3eafd0527f1 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -782,7 +782,9 @@
>  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
>  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
>  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> -#define SW_MAX			0x0f
> +#define SW_RATCHET		0x10  /* set = ratchet mode,
> +					 unset: free wheel */
> +#define SW_MAX			0x1f
>  #define SW_CNT			(SW_MAX+1)
>  
>  /*
> -- 
> 2.9.3
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH RFC 3/4] input: add a EV_SW event for ratchet switch
  2017-03-27  1:53       ` [PATCH RFC 3/4] input: add a EV_SW event " Peter Hutterer
@ 2017-03-27 12:27         ` Mauro Carvalho Chehab
  2017-03-28  0:25           ` Peter Hutterer
  0 siblings, 1 reply; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2017-03-27 12:27 UTC (permalink / raw)
  To: Peter Hutterer
  Cc: linux-input, Dmitry Torokhov, Benjamin Tissoires,
	Greg Kroah-Hartman, Martin Schwidefsky, Mauro Carvalho Chehab,
	Ingo Tuchscherer, Stuart Yoder, Hans Verkuil, Douglas Anderson,
	Ping Cheng, Kamil Debski

Em Mon, 27 Mar 2017 11:53:57 +1000
Peter Hutterer <peter.hutterer@who-t.net> escreveu:

> On Sat, Mar 25, 2017 at 07:49:41PM -0300, Mauro Carvalho Chehab wrote:
> > Some mouses have a switch on their wheel, allowing to switch
> > between ratchet or free wheel mode. Add support for it.  
> 
> I understand the want to support it because it's there but what do you
> expect this to be used for?
> 
> tbh, I wouldn't know what to do with this information, short of displaying
> some OSD to inform the user. Which is rather superfluous since the physical
> change will feel obvious anyway.

For this particular device, the main reason is because it is there :-)
As adding support for it is trivial, I don't see any reason why not
adding it.

Yet, applications could use it, in order to switch between a "discrete" 
mode, where one wheel position corresponds to one line of scroll, and
movements below a threshold would be ignored.


> 
> A Documentation/input/event-codes.txt hunk would be welcomed here too
> btw.

Sure. Will do on a next patch series, once we agree about the high
resolution wheel movements API.
> 
> Cheers,
>    Peter
> 
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > ---
> >  include/linux/mod_devicetable.h        | 2 +-
> >  include/uapi/linux/input-event-codes.h | 4 +++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> > index 8a57f0b1242d..73534c591b40 100644
> > --- a/include/linux/mod_devicetable.h
> > +++ b/include/linux/mod_devicetable.h
> > @@ -292,7 +292,7 @@ struct pcmcia_device_id {
> >  #define INPUT_DEVICE_ID_LED_MAX		0x0f
> >  #define INPUT_DEVICE_ID_SND_MAX		0x07
> >  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> > -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> > +#define INPUT_DEVICE_ID_SW_MAX		0x1f
> >  
> >  #define INPUT_DEVICE_ID_MATCH_BUS	1
> >  #define INPUT_DEVICE_ID_MATCH_VENDOR	2
> > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > index 23b2d377af59..a3eafd0527f1 100644
> > --- a/include/uapi/linux/input-event-codes.h
> > +++ b/include/uapi/linux/input-event-codes.h
> > @@ -782,7 +782,9 @@
> >  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
> >  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
> >  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> > -#define SW_MAX			0x0f
> > +#define SW_RATCHET		0x10  /* set = ratchet mode,
> > +					 unset: free wheel */
> > +#define SW_MAX			0x1f
> >  #define SW_CNT			(SW_MAX+1)
> >  
> >  /*
> > -- 
> > 2.9.3
> > 
> >   



Thanks,
Mauro

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH RFC 3/4] input: add a EV_SW event for ratchet switch
  2017-03-27 12:27         ` Mauro Carvalho Chehab
@ 2017-03-28  0:25           ` Peter Hutterer
  2017-03-28  9:36             ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Hutterer @ 2017-03-28  0:25 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-input, Dmitry Torokhov, Benjamin Tissoires,
	Greg Kroah-Hartman, Martin Schwidefsky, Mauro Carvalho Chehab,
	Ingo Tuchscherer, Stuart Yoder, Hans Verkuil, Douglas Anderson,
	Ping Cheng, Kamil Debski

On Mon, Mar 27, 2017 at 09:27:31AM -0300, Mauro Carvalho Chehab wrote:
> Em Mon, 27 Mar 2017 11:53:57 +1000
> Peter Hutterer <peter.hutterer@who-t.net> escreveu:
> 
> > On Sat, Mar 25, 2017 at 07:49:41PM -0300, Mauro Carvalho Chehab wrote:
> > > Some mouses have a switch on their wheel, allowing to switch
> > > between ratchet or free wheel mode. Add support for it.  
> > 
> > I understand the want to support it because it's there but what do you
> > expect this to be used for?
> > 
> > tbh, I wouldn't know what to do with this information, short of displaying
> > some OSD to inform the user. Which is rather superfluous since the physical
> > change will feel obvious anyway.
> 
> For this particular device, the main reason is because it is there :-)
> As adding support for it is trivial, I don't see any reason why not
> adding it.
> 
> Yet, applications could use it, in order to switch between a "discrete" 
> mode, where one wheel position corresponds to one line of scroll, and
> movements below a threshold would be ignored.

fwiw, that would more likely be the  result of receiving a different event
code (hires-wheel), more so than a ratchet switch - at least on this device.

the mice I have here don't change the behaviour of the wheel, so the
granularity is the same before and after. But they also don't send events
for the state, so there's that :)

Cheers,
   Peter
> 
> 
> > 
> > A Documentation/input/event-codes.txt hunk would be welcomed here too
> > btw.
> 
> Sure. Will do on a next patch series, once we agree about the high
> resolution wheel movements API.
> > 
> > Cheers,
> >    Peter
> > 
> > > 
> > > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > > ---
> > >  include/linux/mod_devicetable.h        | 2 +-
> > >  include/uapi/linux/input-event-codes.h | 4 +++-
> > >  2 files changed, 4 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> > > index 8a57f0b1242d..73534c591b40 100644
> > > --- a/include/linux/mod_devicetable.h
> > > +++ b/include/linux/mod_devicetable.h
> > > @@ -292,7 +292,7 @@ struct pcmcia_device_id {
> > >  #define INPUT_DEVICE_ID_LED_MAX		0x0f
> > >  #define INPUT_DEVICE_ID_SND_MAX		0x07
> > >  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> > > -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> > > +#define INPUT_DEVICE_ID_SW_MAX		0x1f
> > >  
> > >  #define INPUT_DEVICE_ID_MATCH_BUS	1
> > >  #define INPUT_DEVICE_ID_MATCH_VENDOR	2
> > > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > > index 23b2d377af59..a3eafd0527f1 100644
> > > --- a/include/uapi/linux/input-event-codes.h
> > > +++ b/include/uapi/linux/input-event-codes.h
> > > @@ -782,7 +782,9 @@
> > >  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
> > >  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
> > >  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> > > -#define SW_MAX			0x0f
> > > +#define SW_RATCHET		0x10  /* set = ratchet mode,
> > > +					 unset: free wheel */
> > > +#define SW_MAX			0x1f
> > >  #define SW_CNT			(SW_MAX+1)
> > >  
> > >  /*
> > > -- 
> > > 2.9.3
> > > 
> > >   
> 
> 
> 
> Thanks,
> Mauro

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH RFC 3/4] input: add a EV_SW event for ratchet switch
  2017-03-28  0:25           ` Peter Hutterer
@ 2017-03-28  9:36             ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2017-03-28  9:36 UTC (permalink / raw)
  To: Peter Hutterer
  Cc: linux-input, Dmitry Torokhov, Benjamin Tissoires,
	Greg Kroah-Hartman, Martin Schwidefsky, Mauro Carvalho Chehab,
	Ingo Tuchscherer, Stuart Yoder, Hans Verkuil, Douglas Anderson,
	Ping Cheng, Kamil Debski

Em Tue, 28 Mar 2017 10:25:17 +1000
Peter Hutterer <peter.hutterer@who-t.net> escreveu:

> On Mon, Mar 27, 2017 at 09:27:31AM -0300, Mauro Carvalho Chehab wrote:
> > Em Mon, 27 Mar 2017 11:53:57 +1000
> > Peter Hutterer <peter.hutterer@who-t.net> escreveu:
> >   
> > > On Sat, Mar 25, 2017 at 07:49:41PM -0300, Mauro Carvalho Chehab wrote:  
> > > > Some mouses have a switch on their wheel, allowing to switch
> > > > between ratchet or free wheel mode. Add support for it.    
> > > 
> > > I understand the want to support it because it's there but what do you
> > > expect this to be used for?
> > > 
> > > tbh, I wouldn't know what to do with this information, short of displaying
> > > some OSD to inform the user. Which is rather superfluous since the physical
> > > change will feel obvious anyway.  
> > 
> > For this particular device, the main reason is because it is there :-)
> > As adding support for it is trivial, I don't see any reason why not
> > adding it.
> > 
> > Yet, applications could use it, in order to switch between a "discrete" 
> > mode, where one wheel position corresponds to one line of scroll, and
> > movements below a threshold would be ignored.  
> 
> fwiw, that would more likely be the  result of receiving a different event
> code (hires-wheel), more so than a ratchet switch - at least on this device.

Yeah, that would be another alternative.

> the mice I have here don't change the behaviour of the wheel, so the
> granularity is the same before and after. But they also don't send events
> for the state, so there's that :)

Another alternative would be that applications could be listening to
EV_SW SW_RATCHET event. When the switch changes to free wheel, it could
be enabling high-resolution mode.

Thanks,
Mauro

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-03-28  9:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-25 22:49 [PATCH RFC 0/4] Improve support for Logitech MX Anywhere 2 Mauro Carvalho Chehab
2017-03-25 22:49 ` [PATCH RFC 1/4] input: add an EV_REL event for high-res vertical wheel Mauro Carvalho Chehab
2017-03-25 22:49   ` [PATCH RFC 2/4] hid-logitech-hidpp: add support for high res wheel Mauro Carvalho Chehab
2017-03-25 22:49     ` [PATCH RFC 3/4] input: add a EV_SW event for ratchet switch Mauro Carvalho Chehab
2017-03-25 22:49       ` [PATCH RFC 4/4] hid-logitech-hidpp: add support " Mauro Carvalho Chehab
2017-03-27  1:53       ` [PATCH RFC 3/4] input: add a EV_SW event " Peter Hutterer
2017-03-27 12:27         ` Mauro Carvalho Chehab
2017-03-28  0:25           ` Peter Hutterer
2017-03-28  9:36             ` Mauro Carvalho Chehab
2017-03-27  1:40   ` [PATCH RFC 1/4] input: add an EV_REL event for high-res vertical wheel Peter Hutterer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.