VIBRATOR: allow SYSFS control over vibrator strength

file:2c4e1545d43e1d1c0d2125bdc04248bad2fa70c8 -> file:8bbcc8ec9e8190729acb9e33c90f68646d0f9118
--- a/drivers/motor/tspdrv.c
+++ b/drivers/motor/tspdrv.c
@@ -111,6 +111,7 @@ static int max_timeout = 10000;
static int vibrator_value = -1;
static int vibrator_work;
+int8_t vibe_strength = 120;
#define TEST_MODE_TIME 10000
@@ -129,7 +130,7 @@ static int set_vibetonz(int timeout)
} else {
DbgOut((KERN_INFO "tspdrv: ENABLE\n"));
if (vibrator_drvdata.vib_model == HAPTIC_PWM) {
- strength = 120;
+ strength = vibe_strength;
/* 90% duty cycle */
ImmVibeSPI_ForceOut_SetSamples(0, 8, 1, &strength);
} else { /* HAPTIC_MOTOR */
@@ -148,6 +149,28 @@ static void _set_vibetonz_work(struct wo
return;
}
+
+static ssize_t show_vibe_strength(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", vibe_strength);
+}
+
+static ssize_t store_vibe_strength(struct device *dev, struct device_attribute *attr,const char *buf, size_t size)
+{
+ int value;
+ sscanf(buf, "%d", &value);
+ if(value < 5)
+ value = 5;
+ else if(value > 126)
+ value = 126;
+
+ vibe_strength = value;
+
+ return vibe_strength;
+}
+
+static DEVICE_ATTR(vibe_strength, 0777, show_vibe_strength, store_vibe_strength);
+
static enum hrtimer_restart vibetonz_timer_func(struct hrtimer *timer)
{
/* set_vibetonz(0); */
@@ -213,6 +236,10 @@ static void vibetonz_start(void)
if (ret)
DbgOut((KERN_ERR
"tspdrv: timed_output_dev_register is fail\n"));
+
+ ret = device_create_file(timed_output_vt.dev, &dev_attr_vibe_strength);
+ if(ret)
+ printk(KERN_ERR "[ANTHRAX] vibe_strength device file create failed\n");
}
/* File IO */