From: Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH] HID: add support for Skycable 0x3f07 wireless presenter
References: bnc#681297
Patch-mainline: not yet, queued in subsystem tree

This device contains the very same bug in report descriptor as the
Ortek ones do (i.e. LogicalMinimum == 1, which is wrong for the key
array).

As we have more reports for the Ortek devices, we are keeping the driver
name for now. Apparently there is a chip producer which sells chip with
this buggy descriptor to multiple vendors. Thus if such reports start
to come at highger frequency, we'll either have to rename the driver
accordingly, or come up with more generic workaround.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 drivers/hid/Kconfig     |    9 +++++++--
 drivers/hid/hid-core.c  |    1 +
 drivers/hid/hid-ids.h   |    3 +++
 drivers/hid/hid-ortek.c |   15 +++++++++++----
 4 files changed, 22 insertions(+), 6 deletions(-)

--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -325,10 +325,15 @@ config HID_NTRIG
 	Support for N-Trig touch screen.
 
 config HID_ORTEK
-	tristate "Ortek PKB-1700/WKB-2000 wireless keyboard and mouse trackpad"
+	tristate "Ortek WKB-2000/Skycable wireless keyboard and mouse trackpad"
 	depends on USB_HID
 	---help---
-	Support for Ortek PKB-1700/WKB-2000 wireless keyboard + mouse trackpad.
+        There are certain devices which have LogicalMaximum wrong in the keyboard
+        usage page of their report descriptor. The most prevailing ones so far
+        are manufactured by Ortek, thus the name of the driver. Currently
+        supported devices by this driver are
+          - Ortek WKB-2000
+          - Skycable wireless presenter
 
 config HID_PANTHERLORD
 	tristate "Pantherlord/GreenAsia game controller"
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1411,6 +1411,7 @@ static const struct hid_device_id hid_ha
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -514,6 +514,9 @@
 #define USB_DEVICE_ID_SAMSUNG_IR_REMOTE	0x0001
 #define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE	0x0600
 
+#define USB_VENDOR_ID_SKYCABLE			0x1223
+#define	USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER	0x3F07
+
 #define USB_VENDOR_ID_SONY			0x054c
 #define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE	0x024b
 #define USB_DEVICE_ID_SONY_PS3_CONTROLLER	0x0268
--- a/drivers/hid/hid-ortek.c
+++ b/drivers/hid/hid-ortek.c
@@ -1,9 +1,12 @@
-/*
- *  HID driver for Ortek PKB-1700/WKB-2000 (wireless keyboard + mouse trackpad).
- *  Fixes LogicalMaximum error in USB report description, see
- *  http://bugzilla.kernel.org/show_bug.cgi?id=14787
+/*  HID driver for various devices which are apparently based on the same chipset
+ *  from certain vendor which produces chips that contain wrong LogicalMaximum
+ *  value in their HID report descriptor. Currently supported devices are:
+ *
+ *    Ortek WKB-2000
+ *    Skycable wireless presenter
  *
  *  Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com>
+ *  Copyright (c) 2011 Jiri Kosina
  */
 
 /*
@@ -25,6 +28,9 @@ static __u8 *ortek_report_fixup(struct h
 	if (*rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x01) {
 		hid_info(hdev, "Fixing up Ortek WKB-2000 report descriptor\n");
 		rdesc[55] = 0x92;
+	} else if (*rsize >= 54 && rdesc[52] == 0x25 && rdesc[53] == 0x01) {
+		hid_info(hdev, "Fixing up logical minimum in report descriptor (Skycable)\n");
+		rdesc[53] = 0x65;
 	}
 	return rdesc;
 }
@@ -32,6 +38,7 @@ static __u8 *ortek_report_fixup(struct h
 static const struct hid_device_id ortek_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
 	{ }
 };
 MODULE_DEVICE_TABLE(hid, ortek_devices);
