aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/Kconfig6
-rw-r--r--drivers/misc/mediatek/vibrator/Makefile2
-rw-r--r--drivers/misc/mediatek/vibrator/thunderquake_engine.c120
3 files changed, 128 insertions, 0 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index e7988328d..5c4498134 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -557,6 +557,12 @@ config LTR559
This driver can also be built as a module. If so, the module
will be called ltr559.
+config THUNDERQUAKE_ENGINE_GPL
+ tristate "Vibrator Intensity Controller for MTK Vibrator"
+ default y
+ help
+ Vibrator Intensity Controller for MTK Vibrator v1.0
+
source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/mediatek/vibrator/Makefile b/drivers/misc/mediatek/vibrator/Makefile
index 7443743ad..3ce20389d 100644
--- a/drivers/misc/mediatek/vibrator/Makefile
+++ b/drivers/misc/mediatek/vibrator/Makefile
@@ -2,6 +2,8 @@ include $(srctree)/drivers/misc/mediatek/Makefile.custom
obj-$(CONFIG_MTK_VIBRATOR) := vibrator_drv.o
+obj-$(CONFIG_THUNDERQUAKE_ENGINE_GPL) += thunderquake_engine.o
+
obj-y += $(subst ",,$(CONFIG_MTK_PLATFORM))/
#ccflags-y := -Idrivers/staging/android/
diff --git a/drivers/misc/mediatek/vibrator/thunderquake_engine.c b/drivers/misc/mediatek/vibrator/thunderquake_engine.c
new file mode 100644
index 000000000..5db7ce427
--- /dev/null
+++ b/drivers/misc/mediatek/vibrator/thunderquake_engine.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright © 2014, Varun Chitre "varun.chitre15" <varun.chitre15@gmail.com>
+ *
+ * Vibration Intensity Controller for MTK Vibrator
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that 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.
+ *
+ * Please preserve this licence and driver name if you implement this
+ * anywhere else.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
+#include <linux/kernel.h>
+#include <linux/kallsyms.h>
+
+#include <cust_vibrator.h>
+#include <vibrator_hal.h>
+
+#define MAX_VIBR 7
+#define MIN_VIBR 0
+
+#define ENGINE_VERSION 1
+#define ENGINE_VERSION_SUB 0
+
+extern void upmu_set_rg_vibr_vosel(kal_uint32 val);
+
+static ssize_t vibr_vtg_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+ struct vibrator_hw* hw = mt_get_cust_vibrator_hw();
+
+ return sprintf(buf, "%d\n", hw->vib_vol);
+}
+
+static ssize_t vibr_vtg_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
+{
+ unsigned int val;
+ struct vibrator_hw* hw = mt_get_cust_vibrator_hw();
+ sscanf(buf, "%u", &val);
+ if(val>=MIN_VIBR && val <=MAX_VIBR) {
+ upmu_set_rg_vibr_vosel(val);
+ hw->vib_vol=val;
+ }
+
+ return count;
+}
+
+static ssize_t thunderquake_version_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf, "version: %u.%u\n", ENGINE_VERSION, ENGINE_VERSION_SUB);
+}
+
+static struct kobj_attribute thunderquake_version_attribute =
+ __ATTR(engine_version,
+ 0444,
+ thunderquake_version_show, NULL);
+
+static struct kobj_attribute thunderquake_level_attribute =
+ __ATTR(level,
+ 0666,
+ vibr_vtg_show, vibr_vtg_store);
+
+static struct attribute *thunderquake_engine_attrs[] =
+ {
+ &thunderquake_level_attribute.attr,
+ &thunderquake_version_attribute.attr,
+ NULL,
+ };
+
+static struct attribute_group vibr_level_control_attr_group =
+ {
+ .attrs = thunderquake_engine_attrs,
+ };
+
+static struct kobject *vibr_level_control_kobj;
+
+static int vibr_level_control_init(void)
+{
+ int sysfs_result;
+ printk(KERN_DEBUG "[%s]\n",__func__);
+
+ vibr_level_control_kobj =
+ kobject_create_and_add("thunderquake_engine", kernel_kobj);
+
+ if (!vibr_level_control_kobj) {
+ pr_err("%s Interface create failed!\n",
+ __FUNCTION__);
+ return -ENOMEM;
+ }
+
+ sysfs_result = sysfs_create_group(vibr_level_control_kobj,
+ &vibr_level_control_attr_group);
+
+ if (sysfs_result) {
+ pr_info("%s sysfs create failed!\n", __FUNCTION__);
+ kobject_put(vibr_level_control_kobj);
+ }
+ return sysfs_result;
+}
+
+static void vibr_level_control_exit(void)
+{
+ if (vibr_level_control_kobj != NULL)
+ kobject_put(vibr_level_control_kobj);
+}
+
+module_init(vibr_level_control_init);
+module_exit(vibr_level_control_exit);
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Varun Chitre <varun.chitre15@gmail.com>");
+MODULE_DESCRIPTION("ThundQuake Engine - Driver to control Mediatek Vibrator Intensity"); \ No newline at end of file