Esempio n. 1
0
static int pm8xxx_vib_set_off(struct pm8xxx_vib *vib)
{
	int rc;
	u8 val2;
	val2 = vib->reg_vib_drv;
	val2 &= ~VIB_DRV_SEL_MASK;
	VIB_INFO_LOG("%s + val: %x \n", __func__, val2);
	rc = pm8xxx_vib_write_u8(vib, val2, VIB_DRV);
	if (rc < 0){
		VIB_ERR_LOG("%s writing pmic fail, ret:%X\n", __func__, rc);
		return rc;
	}
	__dump_vib_regs(vib, "vib_set_end");
	VIB_INFO_LOG("%s - \n", __func__);
	return rc;
}
Esempio n. 2
0
static void pm8xxx_vib_enable(struct timed_output_dev *dev, int value)
{
	struct pm8xxx_vib *vib = container_of(dev, struct pm8xxx_vib,
					 timed_dev);

	VIB_INFO_LOG("%s vibrate period: %d msec\n",__func__,value);
retry:

	if (hrtimer_try_to_cancel(&vib->vib_timer) < 0) {
		cpu_relax();
		goto retry;
	}

	if (value == 0)
		pm8xxx_vib_set_off(vib);
	else {

		value = (value > vib->pdata->max_timeout_ms ?
				 vib->pdata->max_timeout_ms : value);

    /* Sense 4 haptic feedback fix */	
    if ((value == 20) || (value == 21))
      value = 40;

		pm8xxx_vib_set_on(vib);
		hrtimer_start(&vib->vib_timer,
			      ktime_set(value / 1000, (value % 1000) * 1000000),
			      HRTIMER_MODE_REL);
	}
}
static void pm8xxx_vib_enable(struct timed_output_dev *dev, int value)
{
	struct pm8xxx_vib *vib = container_of(dev, struct pm8xxx_vib,
					 timed_dev);
	if (time_th >= 0 && value > time_th && vib->pdata->camera_cb) {
		vib->pdata->camera_cb();
		vib_notified = 1;
	}

	VIB_INFO_LOG("%s vibrate period: %d msec: %s(parent:%s), tgid=%d\n",__func__,value, current->comm, current->parent->comm, current->tgid);
retry:

	if (hrtimer_try_to_cancel(&vib->vib_timer) < 0) {
		cpu_relax();
		goto retry;
	}

	if (value == 0)
		pm8xxx_vib_set_off(vib);
	else {
		value = (value > vib->pdata->max_timeout_ms ?
				 vib->pdata->max_timeout_ms : value);
		pm8xxx_vib_set_on(vib);
		hrtimer_start(&vib->vib_timer,
			      ktime_set(value / 1000, (value % 1000) * 1000000),
			      HRTIMER_MODE_REL);
	}
}
Esempio n. 4
0
static int pm8xxx_vib_set_on(struct pm8xxx_vib *vib)
{
	int rc;
	u8 val1;
	val1 = vib->reg_vib_drv;
	val1 &= ~VIB_DRV_SEL_MASK;
	val1 |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
	VIB_INFO_LOG("%s + val: %x \n", __func__, val1);
	rc = pm8xxx_vib_write_u8(vib, val1, VIB_DRV);
	if (rc < 0){
		VIB_ERR_LOG("%s writing pmic fail, ret:%X\n", __func__, rc);
		return rc;
	}
	__dump_vib_regs(vib, "vib_set_end");
	VIB_INFO_LOG("%s - \n", __func__);
	return rc;
}
static enum hrtimer_restart pm8xxx_vib_timer_func(struct hrtimer *timer)
{
	struct pm8xxx_vib *vib = container_of(timer, struct pm8xxx_vib,
							 vib_timer);
	VIB_INFO_LOG("%s \n",__func__);
	pm8xxx_vib_set_off(vib);

	return HRTIMER_NORESTART;
}
Esempio n. 6
0
static ssize_t switch_store(
                struct device *dev, struct device_attribute *attr,
                const char *buf, size_t size)
{
        int switch_status;
        switch_status = -1;
        sscanf(buf, "%d ",&switch_status);
        VIB_INFO_LOG("%s: %d\n",__func__,switch_status);
        switch_state = switch_status;
        return size;
}
static ssize_t threshold_store(
                struct device *dev, struct device_attribute *attr,
                const char *buf, size_t size)
{
        int time_buf;
        time_buf = -1;
        sscanf(buf, "%d ",&time_buf);
        VIB_INFO_LOG("%s: %d\n",__func__,time_buf);
        time_th = time_buf;
        return size;
}
Esempio n. 8
0
static ssize_t voltage_level_store(
		struct device *dev, struct device_attribute *attr,
		const char *buf, size_t size)
{
	int voltage_input;
	struct timed_output_dev *time_cdev;
	struct pm8xxx_vib *vib ;
	time_cdev = (struct timed_output_dev *) dev_get_drvdata(dev);
	vib = container_of(time_cdev, struct pm8xxx_vib, timed_dev);

	voltage_input = -1;
	sscanf(buf, "%d ",&voltage_input);
	VIB_INFO_LOG("%s voltage input: %d\n",__func__,voltage_input);
	if (voltage_input < VIB_MIN_LEVEL_mV || voltage_input > VIB_MAX_LEVEL_mV){
		VIB_ERR_LOG("%s invalid voltage level input: %d\n",__func__,voltage_input);
		return -EINVAL;
	}
	vib->level = voltage_input/100;
	return size;
}