Skip to content

Commit

Permalink
Add intensity (voltage) control to the vibrator driver
Browse files Browse the repository at this point in the history
This sucks but idc I want to try out CM's hardware tunables
  • Loading branch information
Daz Jones committed Sep 5, 2013
1 parent 36cc942 commit 3baf45f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/arm/configs/cyanogenmod_u8815_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ CONFIG_HUAWEI_SETTING_TIMER_FOR_VIBRATOR_OFF=y
CONFIG_HUAWEI_FEATURE_OEMINFO=y
CONFIG_HUAWEI_POWER_DOWN_CHARGE=y
# CONFIG_HUAWEI_RPC_CRASH_DEBUG is not set
CONFIG_HUAWEI_VIBRATOR_INTENSITY_SYSFS=y
CONFIG_HUAWEI_BT_BCM43XX=y
# CONFIG_HUAWEI_BT_WCN2243 is not set
CONFIG_FRAMEBUF_SELF_ADAPT_HACK=y
Expand Down
7 changes: 7 additions & 0 deletions arch/arm/mach-msm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2323,6 +2323,13 @@ config HUAWEI_RPC_CRASH_DEBUG
help
Select Y if use rpc related logs.

config HUAWEI_VIBRATOR_INTENSITY_SYSFS
bool "Huawei vibrator intensity sysfs"
depends on HUAWEI_SETTING_TIMER_FOR_VIBRATOR_OFF
default n
help
Select Y to enable a sysfs for controlling the vibrator intensity (voltage).

config HUAWEI_BT_BCM43XX
bool "Huawei BCM43XX Bluetooth"
default n
Expand Down
40 changes: 40 additions & 0 deletions arch/arm/mach-msm/msm_vibrator.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ static struct hrtimer vibe_timer;
#ifdef CONFIG_HUAWEI_SETTING_TIMER_FOR_VIBRATOR_OFF
static int time_value = 0;
#endif
#ifdef CONFIG_HUAWEI_VIBRATOR_INTENSITY_SYSFS
static int volt_value = 3000;
#endif

static void set_pmic_vibrator(int on)
{
Expand Down Expand Up @@ -86,7 +89,11 @@ static void set_pmic_vibrator(int on)
#ifndef CONFIG_HUAWEI_SETTING_TIMER_FOR_VIBRATOR_OFF
req.data = cpu_to_be32(PMIC_VIBRATOR_LEVEL);
#else
#ifdef CONFIG_HUAWEI_VIBRATOR_INTENSITY_SYSFS
req.vib_volt = cpu_to_be32(volt_value);
#else
req.vib_volt = cpu_to_be32(PMIC_VIBRATOR_LEVEL);
#endif
req.vib_time = cpu_to_be32(time_value);
#endif
}
Expand Down Expand Up @@ -177,6 +184,27 @@ static int vibrator_get_time(struct timed_output_dev *dev)
return 0;
}

#ifdef CONFIG_HUAWEI_VIBRATOR_INTENSITY_SYSFS
static ssize_t intensity_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", volt_value);
}

static ssize_t intensity_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
int value;

if (sscanf(buf, "%d", &value) != 1)
return -EINVAL;

volt_value = value;

return size;
}

static DEVICE_ATTR(intensity, 0666, intensity_show, intensity_store);
#endif

static enum hrtimer_restart vibrator_timer_func(struct hrtimer *timer)
{
timed_vibrator_off(NULL);
Expand All @@ -191,13 +219,25 @@ static struct timed_output_dev pmic_vibrator = {

void __init msm_init_pmic_vibrator(void)
{
#ifdef CONFIG_HUAWEI_VIBRATOR_INTENSITY_SYSFS
int err;
#endif

INIT_WORK(&work_vibrator_on, pmic_vibrator_on);
INIT_WORK(&work_vibrator_off, pmic_vibrator_off);

hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
vibe_timer.function = vibrator_timer_func;

timed_output_dev_register(&pmic_vibrator);

#ifdef CONFIG_HUAWEI_VIBRATOR_INTENSITY_SYSFS
err = device_create_file(pmic_vibrator.dev, &dev_attr_intensity);
if (err < 0)
{
pr_err("%s: failed to create sysfs\n", __func__);
}
#endif
}

MODULE_DESCRIPTION("timed output pmic vibrator device");
Expand Down

0 comments on commit 3baf45f

Please sign in to comment.