summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJun Yan <juyan@nvidia.com>2013-11-25 13:59:13 -0800
committerPeter Kim <pekim@nvidia.com>2014-06-12 21:53:18 -0700
commit97fb92fdabfdf799a1da4838cbc52bdbbb840e45 (patch)
treefe83c44984a2ad214de4fba4c60f0acfec6507fa /drivers
parent14d9ab730e79a6a02f2737aaf77888d18881d322 (diff)
hid: Driver for Nvidia Shield joystick
In order to customize the flat and fuzz of the joystick, create an separate hid driver for Shield joystick. It does the same hid mapping with hid-input.c but only changes the flat and fuzz configurations. Bug 1352488 Bug 1466757 Change-Id: Ide6d37eeeffac9a7150fb257d30f348599794c4c Signed-off-by: Jun Yan <juyan@nvidia.com> Reviewed-on: http://git-master/r/335198 (cherry picked from commit e0e74a97241af85468858cdd79fd4ba994804007) Reviewed-on: http://git-master/r/401207 Signed-off-by: Kenneth Kwak <kkwak@nvidia.com> Reviewed-on: http://git-master/r/417517 Reviewed-by: Peter Kim <pekim@nvidia.com> Tested-by: Peter Kim <pekim@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/Kconfig10
-rw-r--r--drivers/hid/Makefile1
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-ids.h3
-rw-r--r--drivers/hid/hid-nvidia.c83
5 files changed, 98 insertions, 0 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 1283fa3b20a3..3c5c434d94c9 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -404,6 +404,16 @@ config HID_NTRIG
---help---
Support for N-Trig touch screen.
+config HID_NVIDIA
+ tristate "NVIDIA game controller"
+ depends on USB_HID
+ ---help---
+ Support for NVIDIA game controllers. To improve gaming experience, NVIDIA controller
+ has customized axis flat and fuzz values.
+ Supported devices:
+
+ - NVIDIA Shield Handheld game console.
+
config HID_ORTEK
tristate "Ortek PKB-1700/WKB-2000/Skycable wireless keyboard and mouse trackpad"
depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 9dca84592cc4..8d583e8f1c7b 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -85,6 +85,7 @@ obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o
obj-$(CONFIG_HID_WACOM) += hid-wacom.o
obj-$(CONFIG_HID_WALTOP) += hid-waltop.o
obj-$(CONFIG_HID_WIIMOTE) += hid-wiimote.o
+obj-$(CONFIG_HID_NVIDIA) += hid-nvidia.o
obj-$(CONFIG_USB_HID) += usbhid/
obj-$(CONFIG_USB_MOUSE) += usbhid/
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index ff73d60cfc7f..f2c78b337f31 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1518,6 +1518,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) },
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) },
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_NVIDIA, USB_DEVICE_ID_NVIDIA_LOKI) },
{ 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_PANASONIC, USB_DEVICE_ID_PANABOARD_UBT780) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 14d2239954c1..e552f6c3e191 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -596,6 +596,9 @@
#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17 0x0013
#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18 0x0014
+#define USB_VENDOR_ID_NVIDIA 0x0955
+#define USB_DEVICE_ID_NVIDIA_LOKI 0x7205
+
#define USB_VENDOR_ID_ONTRAK 0x0a07
#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064
diff --git a/drivers/hid/hid-nvidia.c b/drivers/hid/hid-nvidia.c
new file mode 100644
index 000000000000..29a4ae2a4a16
--- /dev/null
+++ b/drivers/hid/hid-nvidia.c
@@ -0,0 +1,83 @@
+/*
+ * HID driver for NVIDIA Shield Joystick
+ *
+ * Copyright (c) 2013, NVIDIA Corporation. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/device.h>
+#include <linux/input.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include "hid-ids.h"
+
+#define JOYSTICK_FUZZ 64
+#define TRIGGER_FUZZ 64
+#define JOYSTICK_FLAT 64
+#define TRIGGER_FLAT 0
+
+static int nvidia_input_mapped(struct hid_device *hdev, struct hid_input *hi,
+ struct hid_field *field, struct hid_usage *usage,
+ unsigned long **bit, int *max)
+{
+ int a = field->logical_minimum;
+ int b = field->logical_maximum;
+ int fuzz;
+ int flat;
+
+ if ((usage->type == EV_ABS) && (field->application == HID_GD_GAMEPAD
+ || field->application == HID_GD_JOYSTICK)) {
+ switch (usage->hid) {
+ case HID_GD_X:
+ case HID_GD_Y:
+ case HID_GD_RX:
+ case HID_GD_RY:
+ fuzz = JOYSTICK_FUZZ;
+ flat = JOYSTICK_FLAT;
+ break;
+ case HID_GD_Z:
+ case HID_GD_RZ:
+ fuzz = TRIGGER_FUZZ;
+ flat = TRIGGER_FLAT;
+ break;
+ default: return 0;/*Use generic mapping for HatX, HatY*/
+ }
+ set_bit(usage->type, hi->input->evbit);
+ set_bit(usage->code, *bit);
+ input_set_abs_params(hi->input, usage->code, a, b, fuzz, flat);
+ input_abs_set_res(hi->input, usage->code,
+ hidinput_calc_abs_res(field, usage->code));
+ return -1;
+ }
+
+ return 0;
+}
+
+static const struct hid_device_id nvidia_devices[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_NVIDIA, USB_DEVICE_ID_NVIDIA_LOKI) },
+ { }
+};
+MODULE_DEVICE_TABLE(hid, loki_devices);
+
+static struct hid_driver nvidia_driver = {
+ .name = "hid-nvidia",
+ .id_table = nvidia_devices,
+ .input_mapped = nvidia_input_mapped,
+};
+module_hid_driver(nvidia_driver);
+
+MODULE_AUTHOR("Jun Yan <juyan@nvidia.com>");
+MODULE_LICENSE("GPL");