All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/5] add support for high res wheel found on some Logitech devices
@ 2017-04-11 13:29 Mauro Carvalho Chehab
  2017-04-11 13:29 ` [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events Mauro Carvalho Chehab
  0 siblings, 1 reply; 12+ messages in thread
From: Mauro Carvalho Chehab @ 2017-04-11 13:29 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Benjamin Tissoires, Jiri Kosina
  Cc: Mauro Carvalho Chehab

Some Logitech mouses (MX Anyware 2, MX Master) have a wheel with two
resolutions. It initializes in low resolution mode, but can be changed to high
resolution. It also supports free wheel mode, where there's no tactile
feedback at the wheel, nor it offers resistence to movements. Such mode is
enabled/disabled by clicking at the wheel (on this wheel, the middle button
is a separate button).

Add support for it.

Tested on with MX Anywhere 2 device.

PS.:
       Patches 2 and 3 will have trivial conflicts with -next version of the
       input tree, due to the documentation patches that got merged there.

v4:
 - rebased on the top of HID tree, branch 'for-next'
 - added a patch reserving some REL_MISC_n events
 - fixed CMD_MOUSE_SET_WHEEL_MODE params logic;
 - don't send 16 bytes on FAP command sync - send just what's needed;
 - HIDPP_QUIRK_CONNECT_EVENTS is now applied by default.

v3: addressed Peter's comments for EV_SW SW_RATCHET documentation

Mauro Carvalho Chehab (5):
  input: event-codes: reserve some space for REL_MISC events
  input: add an EV_REL event for high-res vertical wheel
  input: add a EV_SW event for ratchet switch
  hid-logitech-hidpp: add support for high res wheel
  hid-logitech-hidpp: add support for ratchet switch

 Documentation/input/event-codes.txt    |  29 ++++-
 drivers/hid/hid-logitech-hidpp.c       | 216 +++++++++++++++++++++++++++++++++
 include/linux/mod_devicetable.h        |   4 +-
 include/uapi/linux/input-event-codes.h |  13 +-
 4 files changed, 255 insertions(+), 7 deletions(-)

-- 
2.9.3



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

* [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events
  2017-04-11 13:29 [PATCH v4 0/5] add support for high res wheel found on some Logitech devices Mauro Carvalho Chehab
@ 2017-04-11 13:29 ` Mauro Carvalho Chehab
  2017-04-11 13:29   ` [PATCH v4 2/5] input: add an EV_REL event for high-res vertical wheel Mauro Carvalho Chehab
  2017-04-15 17:55   ` [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events Dmitry Torokhov
  0 siblings, 2 replies; 12+ messages in thread
From: Mauro Carvalho Chehab @ 2017-04-11 13:29 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Benjamin Tissoires, Jiri Kosina
  Cc: Mauro Carvalho Chehab, Stuart Yoder, Ingo Tuchscherer,
	David S. Miller, Greg Kroah-Hartman, Florian Fainelli,
	Ping Cheng, Hans Verkuil, Kamil Debski, Douglas Anderson

The HID input layer has a tendency to map usages to REL_MISC
+1, +2, +3, etc... When it doesn't know how to map an
usage, the core layer maps it to the next one.

So, reserve some space for such events.

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

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 8850fcaf50db..a3e8c572a046 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -286,7 +286,7 @@ struct pcmcia_device_id {
 #define INPUT_DEVICE_ID_EV_MAX		0x1f
 #define INPUT_DEVICE_ID_KEY_MIN_INTERESTING	0x71
 #define INPUT_DEVICE_ID_KEY_MAX		0x2ff
-#define INPUT_DEVICE_ID_REL_MAX		0x0f
+#define INPUT_DEVICE_ID_REL_MAX		0x1f
 #define INPUT_DEVICE_ID_ABS_MAX		0x3f
 #define INPUT_DEVICE_ID_MSC_MAX		0x07
 #define INPUT_DEVICE_ID_LED_MAX		0x0f
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index f5a8d96e1e09..444956ba832c 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -704,7 +704,13 @@
 #define REL_DIAL		0x07
 #define REL_WHEEL		0x08
 #define REL_MISC		0x09
-#define REL_MAX			0x0f
+#define REL_MISC_1		0x0a
+#define REL_MISC_2		0x0b
+#define REL_MISC_3		0x0c
+#define REL_MISC_4		0x0d
+#define REL_MISC_5		0x0e
+#define REL_MISC_6		0x0f
+#define REL_MAX			0x1f
 #define REL_CNT			(REL_MAX+1)
 
 /*
-- 
2.9.3


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

* [PATCH v4 2/5] input: add an EV_REL event for high-res vertical wheel
  2017-04-11 13:29 ` [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events Mauro Carvalho Chehab
@ 2017-04-11 13:29   ` Mauro Carvalho Chehab
  2017-04-11 13:29     ` [PATCH v4 3/5] input: add a EV_SW event for ratchet switch Mauro Carvalho Chehab
  2017-04-15 17:55   ` [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events Dmitry Torokhov
  1 sibling, 1 reply; 12+ messages in thread
From: Mauro Carvalho Chehab @ 2017-04-11 13:29 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Benjamin Tissoires, Jiri Kosina
  Cc: Mauro Carvalho Chehab, Jonathan Corbet, Roderick Colenbrander,
	Ping Cheng, Hans Verkuil, Kamil Debski, Douglas Anderson,
	linux-doc

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>
---
 Documentation/input/event-codes.txt    | 17 ++++++++++++++---
 include/uapi/linux/input-event-codes.h |  1 +
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/Documentation/input/event-codes.txt b/Documentation/input/event-codes.txt
index 575415f4cef0..50352ab5f6d4 100644
--- a/Documentation/input/event-codes.txt
+++ b/Documentation/input/event-codes.txt
@@ -156,9 +156,20 @@ instead of EV_REL codes.
 
 A few EV_REL codes have special meanings:
 
-* REL_WHEEL, REL_HWHEEL:
-  - These codes are used for vertical and horizontal scroll wheels,
-    respectively.
+* REL_WHEEL:
+
+  - These codes are used for vertical scroll wheels.
+
+  - REL_WHEEL is for normal wheel operational mode, e. g. low-resolution
+    (line-based) scroll.
+
+  - REL_HIRES_WHEEL should be used when the wheel has two resolutions and it
+    is in high-resolution mode, e. g. the same angular movement that would
+    produce a single REL_WHEEL will produce multiple REL_HIRES_WHEEL events.
+
+* REL_HWHEEL:
+
+  - This code is used for horizontal scroll wheels.
 
 EV_ABS:
 ----------
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 444956ba832c..da48d4079511 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -710,6 +710,7 @@
 #define REL_MISC_4		0x0d
 #define REL_MISC_5		0x0e
 #define REL_MISC_6		0x0f
+#define REL_HIRES_WHEEL		0x10
 #define REL_MAX			0x1f
 #define REL_CNT			(REL_MAX+1)
 
-- 
2.9.3


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

* [PATCH v4 3/5] input: add a EV_SW event for ratchet switch
  2017-04-11 13:29   ` [PATCH v4 2/5] input: add an EV_REL event for high-res vertical wheel Mauro Carvalho Chehab
@ 2017-04-11 13:29     ` Mauro Carvalho Chehab
  2017-04-11 13:29       ` [PATCH v4 4/5] hid-logitech-hidpp: add support for high res wheel Mauro Carvalho Chehab
                         ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Mauro Carvalho Chehab @ 2017-04-11 13:29 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Benjamin Tissoires, Jiri Kosina
  Cc: Mauro Carvalho Chehab, Jonathan Corbet, Roderick Colenbrander,
	Stuart Yoder, David S. Miller, Ingo Tuchscherer,
	Florian Fainelli, Ping Cheng, Hans Verkuil, Kamil Debski,
	Douglas Anderson, linux-doc

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

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

diff --git a/Documentation/input/event-codes.txt b/Documentation/input/event-codes.txt
index 50352ab5f6d4..5dbd45db9bf6 100644
--- a/Documentation/input/event-codes.txt
+++ b/Documentation/input/event-codes.txt
@@ -206,6 +206,18 @@ Upon resume, if the switch state is the same as before suspend, then the input
 subsystem will filter out the duplicate switch state reports. The driver does
 not need to keep the state of the switch at any time.
 
+A few EV_SW codes have special meanings:
+
+* SW_RATCHET:
+
+  - Some mice have a special switch for their wheel that allows to change
+    between free wheel mode and ratchet mode. When the switch is ratchet
+    mode (ON state), the wheel will offer some resistance for movements. It
+    may also provide a tactile feedback when scrolled.
+
+    Note that some mice have a ratchet switch that does not generate a
+    software event.
+
 EV_MSC:
 ----------
 EV_MSC events are used for input and output events that do not fall under other
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index a3e8c572a046..79dd7dbf5442 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 da48d4079511..da83e231e93d 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -789,7 +789,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] 12+ messages in thread

* [PATCH v4 4/5] hid-logitech-hidpp: add support for high res wheel
  2017-04-11 13:29     ` [PATCH v4 3/5] input: add a EV_SW event for ratchet switch Mauro Carvalho Chehab
@ 2017-04-11 13:29       ` Mauro Carvalho Chehab
  2017-04-11 13:29         ` [PATCH v4 5/5] hid-logitech-hidpp: add support for ratchet switch Mauro Carvalho Chehab
  2017-04-14 12:54       ` [PATCH v4 3/5] input: add a EV_SW event " Benjamin Tissoires
  2017-04-15 18:04       ` Dmitry Torokhov
  2 siblings, 1 reply; 12+ messages in thread
From: Mauro Carvalho Chehab @ 2017-04-11 13:29 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Benjamin Tissoires, Jiri Kosina
  Cc: Mauro Carvalho Chehab, 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 41b39464ded8..20ced3f519ae 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -64,6 +64,7 @@ MODULE_PARM_DESC(disable_tap_to_click,
 #define HIDPP_QUIRK_NO_HIDINPUT			BIT(23)
 #define HIDPP_QUIRK_FORCE_OUTPUT_REPORTS	BIT(24)
 #define HIDPP_QUIRK_UNIFYING			BIT(25)
+#define HIDPP_QUIRK_HIRES_SCROLL		BIT(26)
 
 #define HIDPP_QUIRK_DELAYED_INIT		HIDPP_QUIRK_NO_HIDINPUT
 
@@ -1986,6 +1987,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[1];
+
+	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     ? BIT(2) : 0)  |
+		    (high_res   ? BIT(1) : 0)  |
+		    (hidpp_mode ? BIT(0) : 0);
+
+	ret = hidpp_send_fap_command_sync(hidpp, hrd->feature_index,
+					  CMD_MOUSE_SET_WHEEL_MODE,
+					  params, sizeof(params), &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;
+}
 
 /* ************************************************************************** */
 /*                                                                            */
@@ -2435,6 +2497,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                                                     */
 /* ------------------------------------------------------------------------- */
 
@@ -2571,6 +2746,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,
@@ -2685,6 +2863,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;
 }
@@ -2852,6 +3032,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;
 	}
 
 	/* the device is already connected, we can ask for its name and
@@ -2951,6 +3135,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	if (disable_raw_mode) {
 		hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP;
 		hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT;
+		hidpp->quirks &= ~HIDPP_QUIRK_HIRES_SCROLL;
 	}
 
 	if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) {
@@ -2965,6 +3150,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);
@@ -3100,6 +3289,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_HIRES_SCROLL },
+	{ /* Logitech MX Anywhere 2 with high resolution scroll */
+	  HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
+		USB_VENDOR_ID_LOGITECH, 0x404a),
+	  .driver_data = 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] 12+ messages in thread

* [PATCH v4 5/5] hid-logitech-hidpp: add support for ratchet switch
  2017-04-11 13:29       ` [PATCH v4 4/5] hid-logitech-hidpp: add support for high res wheel Mauro Carvalho Chehab
@ 2017-04-11 13:29         ` Mauro Carvalho Chehab
  2017-04-14 12:56           ` Benjamin Tissoires
  0 siblings, 1 reply; 12+ messages in thread
From: Mauro Carvalho Chehab @ 2017-04-11 13:29 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Benjamin Tissoires, Jiri Kosina
  Cc: Mauro Carvalho Chehab, 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 20ced3f519ae..fa5a28cc77ca 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -2031,6 +2031,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, 0, &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     ? BIT(2) : 0)  |
 		    (high_res   ? BIT(1) : 0)  |
 		    (hidpp_mode ? BIT(0) : 0);
@@ -2564,10 +2577,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;
 }
 
@@ -2580,6 +2594,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] 12+ messages in thread

* Re: [PATCH v4 3/5] input: add a EV_SW event for ratchet switch
  2017-04-11 13:29     ` [PATCH v4 3/5] input: add a EV_SW event for ratchet switch Mauro Carvalho Chehab
  2017-04-11 13:29       ` [PATCH v4 4/5] hid-logitech-hidpp: add support for high res wheel Mauro Carvalho Chehab
@ 2017-04-14 12:54       ` Benjamin Tissoires
  2017-04-15 18:04       ` Dmitry Torokhov
  2 siblings, 0 replies; 12+ messages in thread
From: Benjamin Tissoires @ 2017-04-14 12:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-input, Dmitry Torokhov, Jiri Kosina, Jonathan Corbet,
	Roderick Colenbrander, Stuart Yoder, David S. Miller,
	Ingo Tuchscherer, Florian Fainelli, Ping Cheng, Hans Verkuil,
	Kamil Debski, Douglas Anderson, linux-doc

On Apr 11 2017 or thereabouts, Mauro Carvalho Chehab wrote:
> Some mice have a switch on their wheel, allowing to switch
> between ratchet and free wheel mode. Add support for it.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---

Patches 1 to 3 are:
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin

>  Documentation/input/event-codes.txt    | 12 ++++++++++++
>  include/linux/mod_devicetable.h        |  2 +-
>  include/uapi/linux/input-event-codes.h |  4 +++-
>  3 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/input/event-codes.txt b/Documentation/input/event-codes.txt
> index 50352ab5f6d4..5dbd45db9bf6 100644
> --- a/Documentation/input/event-codes.txt
> +++ b/Documentation/input/event-codes.txt
> @@ -206,6 +206,18 @@ Upon resume, if the switch state is the same as before suspend, then the input
>  subsystem will filter out the duplicate switch state reports. The driver does
>  not need to keep the state of the switch at any time.
>  
> +A few EV_SW codes have special meanings:
> +
> +* SW_RATCHET:
> +
> +  - Some mice have a special switch for their wheel that allows to change
> +    between free wheel mode and ratchet mode. When the switch is ratchet
> +    mode (ON state), the wheel will offer some resistance for movements. It
> +    may also provide a tactile feedback when scrolled.
> +
> +    Note that some mice have a ratchet switch that does not generate a
> +    software event.
> +
>  EV_MSC:
>  ----------
>  EV_MSC events are used for input and output events that do not fall under other
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index a3e8c572a046..79dd7dbf5442 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 da48d4079511..da83e231e93d 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -789,7 +789,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] 12+ messages in thread

* Re: [PATCH v4 5/5] hid-logitech-hidpp: add support for ratchet switch
  2017-04-11 13:29         ` [PATCH v4 5/5] hid-logitech-hidpp: add support for ratchet switch Mauro Carvalho Chehab
@ 2017-04-14 12:56           ` Benjamin Tissoires
  0 siblings, 0 replies; 12+ messages in thread
From: Benjamin Tissoires @ 2017-04-14 12:56 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-input, Dmitry Torokhov, Jiri Kosina, Jiri Kosina

On Apr 11 2017 or thereabouts, Mauro Carvalho Chehab wrote:
> 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>
> ---

On a MX Master, patches 4-5 are:
Reviewed-and-tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin

>  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 20ced3f519ae..fa5a28cc77ca 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -2031,6 +2031,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, 0, &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     ? BIT(2) : 0)  |
>  		    (high_res   ? BIT(1) : 0)  |
>  		    (hidpp_mode ? BIT(0) : 0);
> @@ -2564,10 +2577,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;
>  }
>  
> @@ -2580,6 +2594,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	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events
  2017-04-11 13:29 ` [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events Mauro Carvalho Chehab
  2017-04-11 13:29   ` [PATCH v4 2/5] input: add an EV_REL event for high-res vertical wheel Mauro Carvalho Chehab
@ 2017-04-15 17:55   ` Dmitry Torokhov
  2017-06-21 12:05     ` Benjamin Tissoires
  1 sibling, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2017-04-15 17:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Stuart Yoder,
	Ingo Tuchscherer, David S. Miller, Greg Kroah-Hartman,
	Florian Fainelli, Ping Cheng, Hans Verkuil, Kamil Debski,
	Douglas Anderson

On Tue, Apr 11, 2017 at 10:29:38AM -0300, Mauro Carvalho Chehab wrote:
> The HID input layer has a tendency to map usages to REL_MISC
> +1, +2, +3, etc... When it doesn't know how to map an
> usage, the core layer maps it to the next one.

We should wean HID off this habit. We should not be adding placeholder
events without defined meaning.

> 
> So, reserve some space for such events.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  include/linux/mod_devicetable.h        | 2 +-
>  include/uapi/linux/input-event-codes.h | 8 +++++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 8850fcaf50db..a3e8c572a046 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -286,7 +286,7 @@ struct pcmcia_device_id {
>  #define INPUT_DEVICE_ID_EV_MAX		0x1f
>  #define INPUT_DEVICE_ID_KEY_MIN_INTERESTING	0x71
>  #define INPUT_DEVICE_ID_KEY_MAX		0x2ff
> -#define INPUT_DEVICE_ID_REL_MAX		0x0f
> +#define INPUT_DEVICE_ID_REL_MAX		0x1f
>  #define INPUT_DEVICE_ID_ABS_MAX		0x3f
>  #define INPUT_DEVICE_ID_MSC_MAX		0x07
>  #define INPUT_DEVICE_ID_LED_MAX		0x0f
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index f5a8d96e1e09..444956ba832c 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -704,7 +704,13 @@
>  #define REL_DIAL		0x07
>  #define REL_WHEEL		0x08
>  #define REL_MISC		0x09
> -#define REL_MAX			0x0f
> +#define REL_MISC_1		0x0a
> +#define REL_MISC_2		0x0b
> +#define REL_MISC_3		0x0c
> +#define REL_MISC_4		0x0d
> +#define REL_MISC_5		0x0e
> +#define REL_MISC_6		0x0f
> +#define REL_MAX			0x1f
>  #define REL_CNT			(REL_MAX+1)
>  
>  /*
> -- 
> 2.9.3
> 

-- 
Dmitry

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

* Re: [PATCH v4 3/5] input: add a EV_SW event for ratchet switch
  2017-04-11 13:29     ` [PATCH v4 3/5] input: add a EV_SW event for ratchet switch Mauro Carvalho Chehab
  2017-04-11 13:29       ` [PATCH v4 4/5] hid-logitech-hidpp: add support for high res wheel Mauro Carvalho Chehab
  2017-04-14 12:54       ` [PATCH v4 3/5] input: add a EV_SW event " Benjamin Tissoires
@ 2017-04-15 18:04       ` Dmitry Torokhov
  2017-04-15 22:50         ` Mauro Carvalho Chehab
  2 siblings, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2017-04-15 18:04 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Jonathan Corbet,
	Roderick Colenbrander, Stuart Yoder, David S. Miller,
	Ingo Tuchscherer, Florian Fainelli, Ping Cheng, Hans Verkuil,
	Kamil Debski, Douglas Anderson, linux-doc

Hi Mauro,

On Tue, Apr 11, 2017 at 10:29:40AM -0300, Mauro Carvalho Chehab wrote:
> Some mice have a switch on their wheel, allowing to switch
> between ratchet and free wheel mode. Add support for it.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> ---
>  Documentation/input/event-codes.txt    | 12 ++++++++++++
>  include/linux/mod_devicetable.h        |  2 +-
>  include/uapi/linux/input-event-codes.h |  4 +++-
>  3 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/input/event-codes.txt b/Documentation/input/event-codes.txt
> index 50352ab5f6d4..5dbd45db9bf6 100644
> --- a/Documentation/input/event-codes.txt
> +++ b/Documentation/input/event-codes.txt
> @@ -206,6 +206,18 @@ Upon resume, if the switch state is the same as before suspend, then the input
>  subsystem will filter out the duplicate switch state reports. The driver does
>  not need to keep the state of the switch at any time.
>  
> +A few EV_SW codes have special meanings:
> +
> +* SW_RATCHET:
> +
> +  - Some mice have a special switch for their wheel that allows to change
> +    between free wheel mode and ratchet mode. When the switch is ratchet
> +    mode (ON state), the wheel will offer some resistance for movements. It
> +    may also provide a tactile feedback when scrolled.
> +
> +    Note that some mice have a ratchet switch that does not generate a
> +    software event.

So it is still not clear to me why we need the 2 discrete events. Either
we key off the behavior off the new REL event, or from switch, but not
both.

Also, it is unclear to me if allocating a new event for "hires" wheel is
optimal. This still does not solve the question about resolution (how
high is "hires" and what to do if Logitech will come out with
ultra-high-resolution wheel next year, or if we need to express
resolution for other relative events).

Thanks.

> +
>  EV_MSC:
>  ----------
>  EV_MSC events are used for input and output events that do not fall under other
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index a3e8c572a046..79dd7dbf5442 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 da48d4079511..da83e231e93d 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -789,7 +789,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
> 

-- 
Dmitry

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

* Re: [PATCH v4 3/5] input: add a EV_SW event for ratchet switch
  2017-04-15 18:04       ` Dmitry Torokhov
@ 2017-04-15 22:50         ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 12+ messages in thread
From: Mauro Carvalho Chehab @ 2017-04-15 22:50 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, Benjamin Tissoires, Jiri Kosina, Jonathan Corbet,
	Roderick Colenbrander, Stuart Yoder, David S. Miller,
	Ingo Tuchscherer, Florian Fainelli, Ping Cheng, Hans Verkuil,
	Kamil Debski, Douglas Anderson, linux-doc

Em Sat, 15 Apr 2017 11:04:36 -0700
Dmitry Torokhov <dmitry.torokhov@gmail.com> escreveu:

> Hi Mauro,
> 
> On Tue, Apr 11, 2017 at 10:29:40AM -0300, Mauro Carvalho Chehab wrote:
> > Some mice have a switch on their wheel, allowing to switch
> > between ratchet and free wheel mode. Add support for it.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > ---
> >  Documentation/input/event-codes.txt    | 12 ++++++++++++
> >  include/linux/mod_devicetable.h        |  2 +-
> >  include/uapi/linux/input-event-codes.h |  4 +++-
> >  3 files changed, 16 insertions(+), 2 deletions(-)
> > 
> > diff --git a/Documentation/input/event-codes.txt b/Documentation/input/event-codes.txt
> > index 50352ab5f6d4..5dbd45db9bf6 100644
> > --- a/Documentation/input/event-codes.txt
> > +++ b/Documentation/input/event-codes.txt
> > @@ -206,6 +206,18 @@ Upon resume, if the switch state is the same as before suspend, then the input
> >  subsystem will filter out the duplicate switch state reports. The driver does
> >  not need to keep the state of the switch at any time.
> >  
> > +A few EV_SW codes have special meanings:
> > +
> > +* SW_RATCHET:
> > +
> > +  - Some mice have a special switch for their wheel that allows to change
> > +    between free wheel mode and ratchet mode. When the switch is ratchet
> > +    mode (ON state), the wheel will offer some resistance for movements. It
> > +    may also provide a tactile feedback when scrolled.
> > +
> > +    Note that some mice have a ratchet switch that does not generate a
> > +    software event.  
> 
> So it is still not clear to me why we need the 2 discrete events. Either
> we key off the behavior off the new REL event, or from switch, but not
> both.

The two events are independent. Clicking at the Wheel button just
sets it to free wheel or back to ratchet mode. It doesn't switch
the resolution.

The high resolution events are sent only when userspace sets
the mouse to high resolution mode.

I wrote patch series for Solaar with allows switching between
low resolution and high resolution modes and controls if the
wheel movement is normal or inverted:

	https://github.com/pwr/Solaar/pull/351

It uses the hidraw interface to switch between the two modes.

> Also, it is unclear to me if allocating a new event for "hires" wheel is
> optimal. This still does not solve the question about resolution (how
> high is "hires" and what to do if Logitech will come out with
> ultra-high-resolution wheel next year, or if we need to express
> resolution for other relative events).

How "high" is the resolution can be queried on those devices.
Not sure how to report it to userspace, though. Ok, one application
could query it via hidraw interface (my Solaar patches do that
when solaar is called with the "show" parameter).

Perhaps an ioctl? Or do you have a better idea?

> 
> Thanks.
> 
> > +
> >  EV_MSC:
> >  ----------
> >  EV_MSC events are used for input and output events that do not fall under other
> > diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> > index a3e8c572a046..79dd7dbf5442 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 da48d4079511..da83e231e93d 100644
> > --- a/include/uapi/linux/input-event-codes.h
> > +++ b/include/uapi/linux/input-event-codes.h
> > @@ -789,7 +789,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] 12+ messages in thread

* Re: [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events
  2017-04-15 17:55   ` [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events Dmitry Torokhov
@ 2017-06-21 12:05     ` Benjamin Tissoires
  0 siblings, 0 replies; 12+ messages in thread
From: Benjamin Tissoires @ 2017-06-21 12:05 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mauro Carvalho Chehab, linux-input, Jiri Kosina, Stuart Yoder,
	Ingo Tuchscherer, David S. Miller, Greg Kroah-Hartman,
	Florian Fainelli, Ping Cheng, Hans Verkuil, Kamil Debski,
	Douglas Anderson

On Apr 15 2017 or thereabouts, Dmitry Torokhov wrote:
> On Tue, Apr 11, 2017 at 10:29:38AM -0300, Mauro Carvalho Chehab wrote:
> > The HID input layer has a tendency to map usages to REL_MISC
> > +1, +2, +3, etc... When it doesn't know how to map an
> > usage, the core layer maps it to the next one.
> 
> We should wean HID off this habit. We should not be adding placeholder
> events without defined meaning.

See https://patchwork.kernel.org/patch/9795625/ for such patch.

Feedbacks welcome :)

Cheers,
Benjamin

> 
> > 
> > So, reserve some space for such events.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > ---
> >  include/linux/mod_devicetable.h        | 2 +-
> >  include/uapi/linux/input-event-codes.h | 8 +++++++-
> >  2 files changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> > index 8850fcaf50db..a3e8c572a046 100644
> > --- a/include/linux/mod_devicetable.h
> > +++ b/include/linux/mod_devicetable.h
> > @@ -286,7 +286,7 @@ struct pcmcia_device_id {
> >  #define INPUT_DEVICE_ID_EV_MAX		0x1f
> >  #define INPUT_DEVICE_ID_KEY_MIN_INTERESTING	0x71
> >  #define INPUT_DEVICE_ID_KEY_MAX		0x2ff
> > -#define INPUT_DEVICE_ID_REL_MAX		0x0f
> > +#define INPUT_DEVICE_ID_REL_MAX		0x1f
> >  #define INPUT_DEVICE_ID_ABS_MAX		0x3f
> >  #define INPUT_DEVICE_ID_MSC_MAX		0x07
> >  #define INPUT_DEVICE_ID_LED_MAX		0x0f
> > diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> > index f5a8d96e1e09..444956ba832c 100644
> > --- a/include/uapi/linux/input-event-codes.h
> > +++ b/include/uapi/linux/input-event-codes.h
> > @@ -704,7 +704,13 @@
> >  #define REL_DIAL		0x07
> >  #define REL_WHEEL		0x08
> >  #define REL_MISC		0x09
> > -#define REL_MAX			0x0f
> > +#define REL_MISC_1		0x0a
> > +#define REL_MISC_2		0x0b
> > +#define REL_MISC_3		0x0c
> > +#define REL_MISC_4		0x0d
> > +#define REL_MISC_5		0x0e
> > +#define REL_MISC_6		0x0f
> > +#define REL_MAX			0x1f
> >  #define REL_CNT			(REL_MAX+1)
> >  
> >  /*
> > -- 
> > 2.9.3
> > 
> 
> -- 
> Dmitry

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

end of thread, other threads:[~2017-06-21 12:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 13:29 [PATCH v4 0/5] add support for high res wheel found on some Logitech devices Mauro Carvalho Chehab
2017-04-11 13:29 ` [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events Mauro Carvalho Chehab
2017-04-11 13:29   ` [PATCH v4 2/5] input: add an EV_REL event for high-res vertical wheel Mauro Carvalho Chehab
2017-04-11 13:29     ` [PATCH v4 3/5] input: add a EV_SW event for ratchet switch Mauro Carvalho Chehab
2017-04-11 13:29       ` [PATCH v4 4/5] hid-logitech-hidpp: add support for high res wheel Mauro Carvalho Chehab
2017-04-11 13:29         ` [PATCH v4 5/5] hid-logitech-hidpp: add support for ratchet switch Mauro Carvalho Chehab
2017-04-14 12:56           ` Benjamin Tissoires
2017-04-14 12:54       ` [PATCH v4 3/5] input: add a EV_SW event " Benjamin Tissoires
2017-04-15 18:04       ` Dmitry Torokhov
2017-04-15 22:50         ` Mauro Carvalho Chehab
2017-04-15 17:55   ` [PATCH v4 1/5] input: event-codes: reserve some space for REL_MISC events Dmitry Torokhov
2017-06-21 12:05     ` Benjamin Tissoires

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.