summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorJun Yan <juyan@nvidia.com>2013-11-25 13:59:13 -0800
committerRaymond Poudrier <rapoudrier@nvidia.com>2013-12-04 23:43:00 -0800
commite0e74a97241af85468858cdd79fd4ba994804007 (patch)
tree0b1bbac2ae5dc23979f6a3f1a4b715f33e2e7013 /drivers/hid
parent5690c61e563ead14ae000466f293eb5173e12dbc (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 Change-Id: Ide6d37eeeffac9a7150fb257d30f348599794c4c Signed-off-by: Jun Yan <juyan@nvidia.com> Reviewed-on: http://git-master/r/335198 Reviewed-by: Anshul Jain (SW) <anshulj@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Raymond Poudrier <rapoudrier@nvidia.com>
Diffstat (limited to 'drivers/hid')
-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 fb52f3f6de80..0f0f885f471a 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -454,6 +454,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 HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 2065694f57ab..4d1cce738bcc 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -117,6 +117,7 @@ obj-$(CONFIG_HID_WACOM) += hid-wacom.o
obj-$(CONFIG_HID_WALTOP) += hid-waltop.o
obj-$(CONFIG_HID_WIIMOTE) += hid-wiimote.o
obj-$(CONFIG_HID_SENSOR_HUB) += hid-sensor-hub.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 e04bf0ef93a9..e89a54cbfbb0 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1745,6 +1745,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_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 114fd1661834..be4eb9cb7de9 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -648,6 +648,9 @@
#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18 0x0014
#define USB_DEVICE_ID_NTRIG_DUOSENSE 0x1500
+#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");