summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Shyti <andi.shyti@samsung.com>2017-02-17 17:32:04 +0900
committerAndi Shyti <andi.shyti@samsung.com>2017-02-17 17:57:36 +0900
commit119844a75ed99e43cd9d0a87f7dfdf4dc438a50f (patch)
tree803ab6f7bcde98027a4facb348493324dab52836
parent8c7f0c0b101e9b9faf206c67cee29f6ec3755f8b (diff)
HID: gearvr: add support for Samsung Gear VRnext/vr-20170117
The Gear VR is a connected through USB to mobile phones and generates a hidraw device as interface to userspace. Change-Id: Ib7814fa6f86a034d5ab6fd59120efb8c2392f9bd Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
-rw-r--r--drivers/hid/Kconfig6
-rw-r--r--drivers/hid/Makefile1
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-gearvr.c73
4 files changed, 81 insertions, 0 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 1aeb80e52424..0fe823310e7a 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -310,6 +310,12 @@ config HOLTEK_FF
Say Y here if you have a Holtek On Line Grip based game controller
and want to have force feedback support for it.
+config HID_GEARVR
+ tristate "Samsung Gear VR support"
+ depends on USB_HID
+ ---help---
+ Say Y here iy you want support for the USB Samsung Gear VR
+
config HID_GT683R
tristate "MSI GT68xR LED support"
depends on LEDS_CLASS && USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 4d111f23e801..66fbf0a40e42 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o
obj-$(CONFIG_HID_ELECOM) += hid-elecom.o
obj-$(CONFIG_HID_ELO) += hid-elo.o
obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
+obj-$(CONFIG_HID_GEARVR) += hid-gearvr.o
obj-$(CONFIG_HID_GEMBIRD) += hid-gembird.o
obj-$(CONFIG_HID_GFRM) += hid-gfrm.o
obj-$(CONFIG_HID_GT683R) += hid-gt683r.o
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 538ff697a4cf..d0350a070cbb 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2044,6 +2044,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
#endif
{ 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_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_GEARVR_R320) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) },
diff --git a/drivers/hid/hid-gearvr.c b/drivers/hid/hid-gearvr.c
new file mode 100644
index 000000000000..09e6459b0c4f
--- /dev/null
+++ b/drivers/hid/hid-gearvr.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Author: Andi Shyti <andi.shyti@samsung.com>
+ *
+ * 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.
+ *
+ * Samsung Gear VR device driver
+ */
+
+#include <linux/hidraw.h>
+#include <linux/module.h>
+
+#include "hid-ids.h"
+
+static int gearvr_probe(struct hid_device *hdev, const struct hid_device_id *id)
+{
+ int err;
+
+ err = hid_parse(hdev);
+ if (err)
+ return err;
+
+ err = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
+ if (err)
+ return err;
+
+ err = hid_hw_power(hdev, PM_HINT_FULLON);
+ if (err < 0)
+ goto fail_dev_stop;
+
+ err = hid_hw_open(hdev);
+ if (err < 0)
+ goto fail_power_off;
+
+ return 0;
+
+fail_power_off:
+ hid_hw_power(hdev, PM_HINT_NORMAL);
+fail_dev_stop:
+ hid_hw_stop(hdev);
+
+ return err;
+}
+
+static void gearvr_remove(struct hid_device *hdev)
+{
+ hid_hw_close(hdev);
+ hid_hw_power(hdev, PM_HINT_NORMAL);
+ hid_hw_stop(hdev);
+}
+
+static const struct hid_device_id gearvr_devices[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS,
+ USB_DEVICE_ID_SAMSUNG_GEARVR_R320) },
+ { }
+};
+
+MODULE_DEVICE_TABLE(hid, gearvr_devices);
+
+static struct hid_driver gearvr_driver = {
+ .name = "gearvr",
+ .id_table = gearvr_devices,
+ .probe = gearvr_probe,
+ .remove = gearvr_remove,
+};
+
+module_hid_driver(gearvr_driver);
+
+MODULE_AUTHOR("Andi Shyti <andi.shyti@samsung.com>");
+MODULE_DESCRIPTION("Samsung Gear VR device driver");
+MODULE_LICENSE("GPL v2");