Skip to contentSkip to conversation

HID: Add full MT support for Logitech Wireless Touchpad

PATCH In review Nestor Lopez Casado 3 participants 3 messages Jan 17, 2012 – Feb 2, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: Add full MT support for Logitech Wireless Touchpad

Details:

- This driver brings the full multitouch experience to the users of the Logitech Unifying Wireless Touchpad. Users of the device will be able to perform gestures with up to 4 fingers. Gesture recognition and actions performed following a given gesture are completely defined by the overlaying gesture recognition engine of the user environment. Previously, the device would only recognize a few gestures natively and send them to the OS as native HID usages.

- An additional module, hid-logitech-hidpp, allows Logitech devices supporting the Logitech HID vendor specific command protocol (HIDPP) to to send and receive commands from these devices.

---
Hi everyone,
As mentioned on the commit message, this patch brings full multitouch experience to the users of the Logitech Unifying Touchpad. The patch also provides basic service to other Logitech devices that need to interact using the HID vendor specific commands from Logitech.

The wireless touchpad already benefits from those services to enable the raw mode of the device, which allows sending up to four finger data to the input layer.

We have performed some testing succesfully, and we think that the users would be happy to enjoy more complex gestures with this touchpad under Linux.

Many thanks from the Logitech team and myself to Benjamin Tissoires who is part author of this work and has given excellent support during the development.

Cheers,
Nestor

 drivers/hid/Kconfig              |   16 ++
 drivers/hid/Makefile             |    2 +
 drivers/hid/hid-ids.h            |    2 +
 drivers/hid/hid-logitech-dj.c    |  245 +++++++++++++++++++---
 drivers/hid/hid-logitech-dj.h    |  123 -----------
 drivers/hid/hid-logitech-hidpp.c |  353 +++++++++++++++++++++++++++++++
 drivers/hid/hid-logitech-hidpp.h |  142 +++++++++++++
 drivers/hid/hid-logitech-wtp.c   |  434 ++++++++++++++++++++++++++++++++++++++
 include/linux/input.h            |    1 +
 9 files changed, 1170 insertions(+), 148 deletions(-)
 delete mode 100644 drivers/hid/hid-logitech-dj.h
 create mode 100644 drivers/hid/hid-logitech-hidpp.c
 create mode 100644 drivers/hid/hid-logitech-hidpp.h
 create mode 100644 drivers/hid/hid-logitech-wtp.c
drivers/hid/Kconfig +16 -0
index a421abd..6fd0362 100644
@@ -253,12 +253,28 @@ config HID_LOGITECH
 config HID_LOGITECH_DJ
 	tristate "Logitech Unifying receivers full support"
 	depends on HID_LOGITECH
+	select HID_LOGITECH_HIDPP
 	default m
 	---help---
 	Say Y if you want support for Logitech Unifying receivers and devices.
 	Unifying receivers are capable of pairing up to 6 Logitech compliant
 	devices to the same receiver.
 
+config HID_LOGITECH_HIDPP
+	tristate "Support for Logitech Vendor Specific HID commands"
+	---help---
+	This module allows sending vendor specific commands to Logitech
+	devices
+
+config HID_LOGITECH_WTP
+	tristate "Logitech Unifying Wireless Touchpad full multitouch support"
+	depends on HID_LOGITECH_DJ
+	select HID_LOGITECH_HIDPP
+	---help---
+	Say Y if you want full multitouch support for the Logitech Unifying Wireless
+	Touchpad. Information of up to 4 fingers is transmitted to the kernel which
+	enables complex gestures to be recognized.
+
 config LOGITECH_FF
 	bool "Logitech force feedback support"
 	depends on HID_LOGITECH
drivers/hid/Makefile +2 -0
index 8aefdc9..0c9c0ae 100644
@@ -53,6 +53,8 @@ obj-$(CONFIG_HID_KYE)		+= hid-kye.o
 obj-$(CONFIG_HID_LCPOWER)       += hid-lcpower.o
 obj-$(CONFIG_HID_LOGITECH)	+= hid-logitech.o
 obj-$(CONFIG_HID_LOGITECH_DJ)	+= hid-logitech-dj.o
+obj-$(CONFIG_HID_LOGITECH_HIDPP)	+= hid-logitech-hidpp.o
+obj-$(CONFIG_HID_LOGITECH_WTP)	+= hid-logitech-wtp.o
 obj-$(CONFIG_HID_MAGICMOUSE)    += hid-magicmouse.o
 obj-$(CONFIG_HID_MICROSOFT)	+= hid-microsoft.o
 obj-$(CONFIG_HID_MONTEREY)	+= hid-monterey.o
drivers/hid/hid-ids.h +2 -0
index b8574cd..e3b1e7f 100644
@@ -749,4 +749,6 @@
 #define USB_VENDOR_ID_PRIMAX	0x0461
 #define USB_DEVICE_ID_PRIMAX_KEYBOARD	0x4e05
 
+#define UNIFYING_DEVICE_ID_WIRELESS_TOUCHPAD	0x4011
+
 #endif
drivers/hid/hid-logitech-dj.c +220 -25

362 lines not on this page · raw message

drivers/hid/hid-logitech-dj.h deleted +0 -123

123 lines not on this page · raw message

drivers/hid/hid-logitech-hidpp.c new file +353 -0

353 lines not on this page · raw message

drivers/hid/hid-logitech-hidpp.h new file +142 -0

142 lines not on this page · raw message

drivers/hid/hid-logitech-wtp.c new file +434 -0

434 lines not on this page · raw message

include/linux/input.h +1 -0
index 3862e32..7e930e6 100644
@@ -897,6 +897,7 @@ struct input_keymap_entry {
 #define BUS_GSC			0x1A
 #define BUS_ATARI		0x1B
 #define BUS_SPI			0x1C
+#define BUS_DJ			0x1D
 
 /*
  * MT_TOOL types
Signature · 1 line
1.7.5.3
#1 lore raw

Hi Nestor,

Please find some initial comments below.

Quoted 38 lines
drivers/hid/hid-logitech-wtp.c new file +32 -0
new file mode 100644
index 0000000..d1bdef6
@@ -0,0 +1,434 @@
+/*
+ *  HID driver for Logitech Wireless Touchpad device
+ *
+ *  Copyright (c) 2011 Logitech (c)
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Should you need to contact me, the author, you can do so by e-mail send
+ * your message to Benjamin Tissoires <benjamin.tissoires at gmail com>
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/input/mt.h>
+

drivers/hid/hid-logitech-wtp.c line 42

Quoted 10 lines
drivers/hid/hid-logitech-wtp.c new file +10 -0
+MODULE_AUTHOR("Benjamin Tissoires <[email protected]>");
+MODULE_AUTHOR("Nestor Lopez Casado <[email protected]>");
+MODULE_DESCRIPTION("Logitech Wireless Touchpad");
+MODULE_LICENSE("GPL");
+
+#include "hid-ids.h"
+#include "hid-logitech-hidpp.h"
+
+#define X_SIZE 3700
+#define Y_SIZE 2480

Why are these defined, if they are also read from the device?

drivers/hid/hid-logitech-wtp.c line 47

Quoted 5 lines
drivers/hid/hid-logitech-wtp.c new file +5 -0
+#define CMD_TOUCHPAD_GET_RAW_INFO		0x01
+#define CMD_TOUCHPAD_GET_RAW_REPORT_STATE	0x11
+#define CMD_TOUCHPAD_SET_RAW_REPORT_STATE	0x21
+#define EVENT_TOUCHPAD_RAW_XY			0x30
+#define EVENT_TOUCHPAD_RAW_XY_			0x00

The last two seem unused.

Quoted 54 lines
drivers/hid/hid-logitech-wtp.c new file +54 -0
+#define WTP_RAW_XY_FEAT_INDEX			0x0F
+
+struct hidpp_touchpad_raw_info {
+	u16 x_size;
+	u16 y_size;
+	u8 z_range;
+	u8 area_range;
+	u8 timestamp_unit;
+	u8 origin;
+	u8 pen_supported;
+};
+
+struct hidpp_touchpad_raw_xy_finger {
+	u8 contact_type;
+	u8 contact_status;
+	u16 x;
+	u16 y;
+	u8 z;
+	u8 area;
+	u8 finger_id;
+};
+
+struct hidpp_touchpad_raw_xy {
+	u16 timestamp;
+	struct hidpp_touchpad_raw_xy_finger fingers[2];
+	u8 spurious_flag;
+	u8 end_of_frame;
+	u8 finger_count;
+};
+
+struct wtp_mt_slot {
+	bool touch_state;	/* is the touch valid? */
+	bool seen_in_this_frame;/* has this slot been updated */
+};
+
+struct wtp_data {
+	struct input_dev *input;
+	__u16 x_size, y_size;
+	__u8 p_range, area_range;
+	__u8 finger_count;
+	__u8 mt_feature_index;
+	__u8 button_feature_index;
+	__u8 maxcontacts;
+	struct wtp_mt_slot slots[5];
+};
+
+struct touch_hidpp_report {
+	u8 x_m;
+	u8 x_l;
+	u8 y_m;
+	u8 y_l;
+	u8 z;
+	u8 area;
+	u8 id;

drivers/hid/hid-logitech-wtp.c line 111

Quoted 10 lines
drivers/hid/hid-logitech-wtp.c new file +10 -0
+};
+
+struct dual_touch_hidpp_report {
+	u8 report_id;
+	u8 device_index;
+	u8 feature_index;
+	u8 broadcast_event;
+	u16 timestamp;
+	struct touch_hidpp_report touches[2];
+};

Seven structs seems a bit much, let's see how things unfold.

Quoted 11 lines
drivers/hid/hid-logitech-wtp.c new file +11 -0
+
+static void wtp_touch_event(struct wtp_data *fd,
+	struct hidpp_touchpad_raw_xy_finger *touch_report)
+{
+	int slot = touch_report->finger_id - 1;
+
+	fd->slots[slot].seen_in_this_frame = true;
+	fd->slots[slot].touch_state = touch_report->contact_status;
+
+	input_mt_slot(fd->input, slot);
+	input_mt_report_slot_state(fd->input, MT_TOOL_FINGER,

drivers/hid/hid-logitech-wtp.c line 132

Quoted 10 lines
drivers/hid/hid-logitech-wtp.c new file +10 -0
+					touch_report->contact_status);
+	if (touch_report->contact_status) {
+		input_event(fd->input, EV_ABS, ABS_MT_POSITION_X,
+				touch_report->x);
+		input_event(fd->input, EV_ABS, ABS_MT_POSITION_Y,
+				touch_report->y);
+		input_event(fd->input, EV_ABS, ABS_MT_PRESSURE,
+				touch_report->area);
+	}
+}

At first glance, it seems fd->slots[slot], and hence struct wtp_mt_slot, can be removed altogether. A local bitmask can keep track of the slots seen in this frame.

drivers/hid/hid-logitech-wtp.c line 138

Quoted 6 lines
drivers/hid/hid-logitech-wtp.c new file +6 -0
+
+static int wtp_touchpad_raw_xy_event(struct hidpp_device *hidpp_dev,
+				u8 *event_data)
+{
+	struct hidpp_touchpad_raw_xy *raw =
+		(struct hidpp_touchpad_raw_xy *)event_data;

Why does this function not take (struct hidpp_touchpad_raw_xy *) instead of (u8 *)?

drivers/hid/hid-logitech-wtp.c line 144

Quoted 6 lines
drivers/hid/hid-logitech-wtp.c new file +6 -0
+	struct wtp_data *fd = (struct wtp_data *)hidpp_dev->driver_data;
+
+	int finger_count = raw->finger_count;
+	bool end_of_frame = raw->end_of_frame;
+
+	int i;

The variables above were first introduced in a local struct on the stack in first ontroduced(), then sent via a pointer to a to this function, only to be put on the stack again. Sending as arguments instead might be simpler, and save us another struct.

drivers/hid/hid-logitech-wtp.c line 153

Quoted 9 lines
drivers/hid/hid-logitech-wtp.c new file +9 -0
+
+	if (!hidpp_dev->initialized)
+		return 0;
+
+	if (finger_count) {
+		wtp_touch_event(fd, &(raw->fingers[0]));
+		if ((end_of_frame && finger_count == 4) ||
+			(!end_of_frame && finger_count >= 2))
+			wtp_touch_event(fd, &(raw->fingers[1]));

One or two calls to wtp_touch_event(), with data filled in using similar logic in the calling function. Perhaps two calls with arguments instead, saving us another struct.

Quoted 5 lines
drivers/hid/hid-logitech-wtp.c new file +5 -0
+	}
+
+	if (end_of_frame || finger_count <= 2) {
+		for (i = 0; i < ARRAY_SIZE(fd->slots); i++) {
+			if (!fd->slots[i].seen_in_this_frame &&

drivers/hid/hid-logitech-wtp.c line 168

Quoted 10 lines
drivers/hid/hid-logitech-wtp.c new file +10 -0
+				fd->slots[i].touch_state) {
+				input_mt_slot(fd->input, i);
+				input_mt_report_slot_state(fd->input,
+					MT_TOOL_FINGER, 0);
+				fd->slots[i].touch_state = 0;
+			}
+
+			fd->slots[i].seen_in_this_frame = false;
+
+		}

Logic to report the non-seen fingers as up can be simplified. Please see the cyttsp driver currently in review for an example.

drivers/hid/hid-logitech-wtp.c line 177

Quoted 9 lines
drivers/hid/hid-logitech-wtp.c new file +9 -0
+		input_mt_report_pointer_emulation(fd->input, true);
+		input_report_key(fd->input, BTN_TOOL_FINGER,
+				 finger_count == 1);
+		input_report_key(fd->input, BTN_TOOL_DOUBLETAP,
+				 finger_count == 2);
+		input_report_key(fd->input, BTN_TOOL_TRIPLETAP,
+				 finger_count == 3);
+		input_report_key(fd->input, BTN_TOOL_QUADTAP,
+				 finger_count == 4);

The button reports here are already included in the call to input_mt_report_pointer_emulation().

drivers/hid/hid-logitech-wtp.c line 178

Quoted 1 line
drivers/hid/hid-logitech-wtp.c new file +1 -0
+		input_sync(fd->input);

A comment explaining that we send packets after every two touch updates would be good.

drivers/hid/hid-logitech-wtp.c line 184

Quoted 6 lines
drivers/hid/hid-logitech-wtp.c new file +6 -0
+	}
+	return 1;
+}
+
+
+static void hidpp_touchpad_touch_event(struct touch_hidpp_report *touch_report,

A const here makes it easier to see input vs output.

drivers/hid/hid-logitech-wtp.c line 196

Quoted 12 lines
drivers/hid/hid-logitech-wtp.c new file +12 -0
+	struct hidpp_touchpad_raw_xy_finger *finger)
+{
+	u8 x_m = touch_report->x_m << 2;
+	u8 y_m = touch_report->y_m << 2;
+
+	finger->contact_type = touch_report->x_m >> 6;
+	finger->x = x_m << 6 | touch_report->x_l;
+
+	finger->contact_status = touch_report->y_m >> 6;
+	finger->y = y_m << 6 | touch_report->y_l;
+
+	finger->finger_id = touch_report->id >> 4;

What is hidden in bits [3..0] of report->id?

Quoted 4 lines
drivers/hid/hid-logitech-wtp.c new file +4 -0
+	finger->z = touch_report->z;
+	finger->area = touch_report->area;
+}
+

drivers/hid/hid-logitech-wtp.c line 210

Quoted 10 lines
drivers/hid/hid-logitech-wtp.c new file +10 -0
+static int hidpp_touchpad_raw_xy_event(struct hidpp_device *hidpp_device,
+		struct hidpp_report *hidpp_report)
+{
+	struct dual_touch_hidpp_report *dual_touch_report;
+	struct hidpp_touchpad_raw_xy raw_xy;
+
+	dual_touch_report = (struct dual_touch_hidpp_report *)hidpp_report;
+	raw_xy.end_of_frame = dual_touch_report->touches[0].id & 0x01;
+	raw_xy.spurious_flag = (dual_touch_report->touches[0].id >> 1) & 0x01;
+	raw_xy.finger_count = dual_touch_report->touches[1].id & 0x0f;

It seems the dual_touch_report data could be named better. End of frame and finger_count are both extracted from the touch id, from different "fingers" at that.

drivers/hid/hid-logitech-wtp.c line 221

Quoted 11 lines
drivers/hid/hid-logitech-wtp.c new file +11 -0
+
+	if (raw_xy.finger_count) {
+		hidpp_touchpad_touch_event(&dual_touch_report->touches[0],
+				&raw_xy.fingers[0]);
+		if ((raw_xy.end_of_frame && raw_xy.finger_count == 4) ||
+			(!raw_xy.end_of_frame && raw_xy.finger_count >= 2))
+			hidpp_touchpad_touch_event(
+					&dual_touch_report->touches[1],
+					&raw_xy.fingers[1]);
+	}
+	return wtp_touchpad_raw_xy_event(hidpp_device, (u8 *)&raw_xy);

This could probably be simplified to two calls to wtp_touch_event() directly.

Quoted 9 lines
drivers/hid/hid-logitech-wtp.c new file +9 -0
+}
+
+static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp_dev,
+	struct hidpp_touchpad_raw_info *raw_info)
+{
+	struct hidpp_report response;
+	int ret;
+	u8 *params = (u8 *)response.fap.params;
+

drivers/hid/hid-logitech-wtp.c line 240

Quoted 10 lines
drivers/hid/hid-logitech-wtp.c new file +10 -0
+	ret = hidpp_send_fap_command_sync(hidpp_dev, WTP_RAW_XY_FEAT_INDEX,
+			CMD_TOUCHPAD_GET_RAW_INFO, NULL, 0, &response);
+
+	if (ret)
+		return -ret;
+
+	*raw_info = *(struct hidpp_touchpad_raw_info *)params;
+
+	raw_info->x_size = params[0] << 8 | params[1];
+	raw_info->y_size = params[2] << 8 | params[3];

So we get the coordinate sizes here.

Quoted 46 lines
drivers/hid/hid-logitech-wtp.c new file +46 -0
+
+	return ret;
+}
+
+static int hidpp_touchpad_set_raw_report_state(struct hidpp_device *hidpp_dev,
+				bool send_raw_reports,
+				bool force_vs_area,
+				bool sensor_enhanced_settings)
+{
+	struct hidpp_report response;
+	int ret;
+	u8 params = send_raw_reports | force_vs_area << 1 |
+				sensor_enhanced_settings << 2;
+
+	ret = hidpp_send_fap_command_sync(hidpp_dev, WTP_RAW_XY_FEAT_INDEX,
+		CMD_TOUCHPAD_SET_RAW_REPORT_STATE, &params, 1, &response);
+
+	if (ret)
+		return -ret;
+
+	return ret;
+}
+
+static int wtp_input_mapping(struct hid_device *hdev, struct hid_input *hi,
+		struct hid_field *field, struct hid_usage *usage,
+		unsigned long **bit, int *max)
+{
+	struct hidpp_device *hidpp_dev = hid_get_drvdata(hdev);
+	struct wtp_data *fd = (struct wtp_data *)hidpp_dev->driver_data;
+	struct input_dev *input = hi->input;
+
+	dbg_hid("%s:\n", __func__);
+
+	if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON)
+		return -1;
+
+	fd->input = hi->input;
+
+	__set_bit(BTN_TOUCH, input->keybit);
+	__set_bit(BTN_TOOL_FINGER, input->keybit);
+	__set_bit(BTN_TOOL_DOUBLETAP, input->keybit);
+	__set_bit(BTN_TOOL_TRIPLETAP, input->keybit);
+	__set_bit(BTN_TOOL_QUADTAP, input->keybit);
+
+	__set_bit(EV_ABS, input->evbit);
+

drivers/hid/hid-logitech-wtp.c line 296

Quoted 10 lines
drivers/hid/hid-logitech-wtp.c new file +10 -0
+	input_mt_init_slots(input, fd->maxcontacts);
+
+	input_set_capability(input, EV_KEY, BTN_TOUCH);
+
+	input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
+	input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0);
+	input_set_abs_params(input, ABS_MT_POSITION_X, 0, X_SIZE, 0, 0);
+	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, Y_SIZE, 0, 0);
+	input_set_abs_params(input, ABS_X, 0, X_SIZE, 0, 0);
+	input_set_abs_params(input, ABS_Y, 0, Y_SIZE, 0, 0);

And we use static coordinate sizes here.

Quoted 29 lines
drivers/hid/hid-logitech-wtp.c new file +29 -0
+
+	return 0;
+}
+
+static void wtp_connect_change(struct hidpp_device *hidpp_dev, bool connected)
+{
+	dbg_hid("%s: connected:%d\n", __func__, connected);
+	if ((connected) && (hidpp_dev->initialized))
+		hidpp_touchpad_set_raw_report_state(hidpp_dev, true, true, true);
+}
+
+static int wtp_device_init(struct hidpp_device *hidpp_dev)
+{
+	int ret;
+	struct hidpp_touchpad_raw_info raw_info = {};
+	struct wtp_data *fd = (struct wtp_data *)hidpp_dev->driver_data;
+
+	dbg_hid("%s\n", __func__);
+
+	ret = hidpp_touchpad_set_raw_report_state(hidpp_dev, true, true, true);
+
+	if (ret) {
+		hid_err(hidpp_dev->hid_dev, "unable to set to raw report mode. "
+			"The device may not be in range.\n");
+		return ret;
+	}
+
+	ret = hidpp_touchpad_get_raw_info(hidpp_dev, &raw_info);
+

drivers/hid/hid-logitech-wtp.c line 335

Quoted 10 lines
drivers/hid/hid-logitech-wtp.c new file +10 -0
+	if (!ret) {
+		if ((X_SIZE != raw_info.x_size) || (Y_SIZE != raw_info.y_size))
+			hid_err(hidpp_dev->hid_dev,
+				"error getting size. Should have %dx%d, "
+				"but device reported %dx%d, ignoring\n",
+				X_SIZE, Y_SIZE,
+				raw_info.x_size, raw_info.y_size);
+
+		fd->x_size = raw_info.x_size;
+		fd->y_size = raw_info.y_size;

And we bail out if the device coordinates are not the same as the ones compiled in here. Seems to me we should initialize the input device based on the device coordinates instead?

Quoted 113 lines
drivers/hid/hid-logitech-wtp.c new file +99 -0
+	}
+
+	return ret;
+}
+
+static int wtp_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+	struct wtp_data *fd;
+	struct hidpp_device *hidpp_device;
+	int ret;
+
+	dbg_hid("%s\n", __func__);
+
+	hidpp_device = kzalloc(sizeof(struct hidpp_device), GFP_KERNEL);
+	if (!hidpp_device) {
+		hid_err(hdev, "cannot allocate hidpp_device\n");
+		return -ENOMEM;
+	}
+
+	fd = kzalloc(sizeof(struct wtp_data), GFP_KERNEL);
+	if (!fd) {
+		hid_err(hdev, "cannot allocate wtp Touch data\n");
+		kfree(hidpp_device);
+		return -ENOMEM;
+	}
+
+	fd->mt_feature_index = 0x0f;
+	fd->button_feature_index = 0x02;
+	fd->maxcontacts = 5;
+
+	hidpp_device->driver_data = (void *)fd;
+	hid_set_drvdata(hdev, hidpp_device);
+
+	hidpp_device->device_init = wtp_device_init;
+	hidpp_device->connect_change = wtp_connect_change;
+	hidpp_device->raw_event = hidpp_touchpad_raw_xy_event;
+
+	ret = hid_parse(hdev);
+	if (ret)
+		goto parse_failed;
+
+	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+	if (ret)
+		goto failed;
+
+	ret = hidpp_init(hidpp_device, hdev);
+	if (ret)
+		goto failed;
+
+	return 0;
+
+failed:
+	hid_hw_stop(hdev);
+parse_failed:
+	kfree(hidpp_device->driver_data);
+	kfree(hidpp_device);
+	hid_set_drvdata(hdev, NULL);
+	return -ENODEV;
+}
+
+static void wtp_remove(struct hid_device *hdev)
+{
+	struct hidpp_device *hidpp_dev = hid_get_drvdata(hdev);
+	struct wtp_data *fd = hidpp_dev->driver_data;
+	dbg_hid("%s\n", __func__);
+	hid_hw_stop(hdev);
+	hidpp_remove(hidpp_dev);
+	kfree(fd);
+	kfree(hidpp_dev);
+	hid_set_drvdata(hdev, NULL);
+}
+
+static const struct hid_device_id wtp_devices[] = {
+	{HID_DEVICE(BUS_DJ, USB_VENDOR_ID_LOGITECH, UNIFYING_DEVICE_ID_WIRELESS_TOUCHPAD) },
+	{ }
+};
+MODULE_DEVICE_TABLE(hid, wtp_devices);
+
+static struct hid_driver wtp_driver = {
+	.name = "wtp-touch",
+	.id_table = wtp_devices,
+	.probe = wtp_probe,
+	.remove = wtp_remove,
+	.input_mapping = wtp_input_mapping,
+	.raw_event = hidpp_raw_event,
+};
+
+static int __init wtp_init(void)
+{
+	return hid_register_driver(&wtp_driver);
+}
+
+static void __exit wtp_exit(void)
+{
+	hid_unregister_driver(&wtp_driver);
+}
+
+module_init(wtp_init);
+module_exit(wtp_exit);
include/linux/input.h +1 -0
index 3862e32..7e930e6 100644
@@ -897,6 +897,7 @@ struct input_keymap_entry {
 #define BUS_GSC			0x1A
 #define BUS_ATARI		0x1B
 #define BUS_SPI			0x1C
+#define BUS_DJ			0x1D
 
 /*
  * MT_TOOL types
Signature · 1 line
1.7.5.3

Thanks,
Henrik

#2 lore raw
Quoted 3 lines · Henrik Rydberg

Hi Nestor,

Please find some initial comments below.

Henrik,

thanks a lot for the review in my absence.

Nestor, I believe you are going to send an updated driver, right?

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs