Thread (3 messages) 3 messages, 2 authors, 2011-06-13

Re: [PATCH] HID: Driver for Lenovo Keyboard w/ Trackpoint

From: Jiri Kosina <hidden>
Date: 2011-06-13 13:25:00

On Fri, 27 May 2011, Bernhard Seibold wrote:
This patch adds support for setting the trackpoint sensitivity
of the "Lenovo ThinkPad USB Keyboard with Trackpoint".
Hi Bernhard,

thanks a lot for the patch.
quoted hunk ↗ jump to hunk
---
 drivers/hid/Kconfig            |   10 +++
 drivers/hid/Makefile           |    1 +
 drivers/hid/hid-core.c         |    1 +
 drivers/hid/hid-ids.h          |    3 +
 drivers/hid/hid-lenovo-tpkbd.c |  166 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 181 insertions(+), 0 deletions(-)
 create mode 100644 drivers/hid/hid-lenovo-tpkbd.c
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 67d2a75..85028c4 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -224,6 +224,16 @@ config HID_LCPOWER
 	---help---
 	Support for LC-Power RC1000MCE RF remote control.
 
+config HID_LENOVO_TPKBD
+	tristate "Lenovo ThinkPad USB Keyboard with TrackPoint"
+	depends on USB_HID
+	---help---
+	Support for the Lenovo ThinkPad USB Keyboard with TrackPoint.
+
+	Say Y here if you have a Lenovo ThinkPad USB Keyboard with TrackPoint
+	and would like to change the sensitivity of the trackpoint using a
+	sysfs attribute.
+
As you are adding sysfs attribute, we'd like to have it documented as well 
Documentation/ABI somewhere.
quoted hunk ↗ jump to hunk
--- /dev/null
+++ b/drivers/hid/hid-lenovo-tpkbd.c
@@ -0,0 +1,166 @@
+/*
+ *  HID driver for Lenovo ThinkPad USB Keyboard with TrackPoint
+ *
+ *  Copyright (c) 2011 Bernhard Seibold
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/sysfs.h>
+#include <linux/device.h>
+#include <linux/usb.h>
+#include <linux/hid.h>
+#include <linux/input.h>
+#include "usbhid/usbhid.h"
+
+#include "hid-ids.h"
+
+static int lenovo_tpkbd_input_mapping(struct hid_device *hdev,
+		struct hid_input *hi, struct hid_field *field,
+		struct hid_usage *usage, unsigned long **bit, int *max)
+{
+	return 0;
+}
+
Why is this empty stub needed?
+static ssize_t pointer_sensitivity_show(struct device *dev,
+		struct device_attribute *attr,
+		char *buf)
+{
+	struct hid_device *hdev;
+	struct hid_report *report;
+	hdev = container_of(dev, struct hid_device, dev);
+
+	if (hdev == NULL)
+		return -ENODEV;
+
+	report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4];
+	usbhid_submit_report(hdev, report, USB_DIR_IN);
+	usbhid_wait_io(hdev);
usbhid_wait_io() returns -1 in case it times out.
+
+	return snprintf(buf, PAGE_SIZE, "%u\n",
+		report->field[2]->value[0]);
+}
+
+static ssize_t pointer_sensitivity_store(struct device *dev,
+		struct device_attribute *attr,
+		const char *buf,
+		size_t count)
+{
+	struct hid_device *hdev;
+	struct hid_report *report;
+	int value;
+
+	if (kstrtoint(buf, 10, &value) || value < 1 || value > 255)
+		return -EINVAL;
+
+	hdev = container_of(dev, struct hid_device, dev);
+	if (hdev == NULL)
+		return -ENODEV;
+
+	report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4];
+	usbhid_submit_report(hdev, report, USB_DIR_IN);
+	usbhid_wait_io(hdev);
The same here.

Thanks,

-- 
Jiri Kosina
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help