Exemple #1
0
/**
 * pm8xxx_work_handler - worker to set vibration level
 * @work: pointer to work_struct
 */
static void pm8xxx_work_handler(struct work_struct *work)
{
	struct pm8xxx_vib *vib = container_of(work, struct pm8xxx_vib, work);
	int rc;
	unsigned int val;

	rc = regmap_read(vib->regmap, VIB_DRV, &val);
	if (rc < 0)
		return;

	/*
	 * pmic vibrator supports voltage ranges from 1.2 to 3.1V, so
	 * scale the level to fit into these ranges.
	 */
	if (vib->speed) {
		vib->active = true;
		vib->level = ((VIB_MAX_LEVELS * vib->speed) / MAX_FF_SPEED) +
						VIB_MIN_LEVEL_mV;
		vib->level /= 100;
	} else {
		vib->active = false;
		vib->level = VIB_MIN_LEVEL_mV / 100;
	}

	pm8xxx_vib_set(vib, vib->active);
}
Exemple #2
0
static void pm8xxx_vib_update(struct work_struct *work)
{
	struct pm8xxx_vib *vib = container_of(work, struct pm8xxx_vib,
					 work);

	pm8xxx_vib_set(vib, vib->state);
}
Exemple #3
0
static void pm8xxx_vibrator_off(struct work_struct *work)
{
    struct pm8xxx_vib *vib = vib_dev;

    VIB_DEBUG_LOG(KERN_INFO, "called.\n");
    pm8xxx_vib_set(vib, 0, 0);
}
Exemple #4
0
/**
 * pm8xxx_vib_close - callback of input close callback
 * @dev: input device pointer
 *
 * Turns off the vibrator.
 */
static void pm8xxx_vib_close(struct input_dev *dev)
{
	struct pm8xxx_vib *vib = input_get_drvdata(dev);

	cancel_work_sync(&vib->work);
	if (vib->active)
		pm8xxx_vib_set(vib, false);
}
Exemple #5
0
static int pm8xxx_vib_suspend(struct device *dev)
{
	struct pm8xxx_vib *vib = dev_get_drvdata(dev);

	/* Turn off the vibrator */
	pm8xxx_vib_set(vib, false);

	return 0;
}
static void pm8xxx_vib_update(struct work_struct *work)
{
	struct pm8xxx_vib *vib = container_of(work, struct pm8xxx_vib,
					 work);

	VIBRATOR_PRINTK(1, "%s ++\n", __func__);
	pm8xxx_vib_set(vib, vib->state);
	VIBRATOR_PRINTK(1, "%s --\n", __func__);
}
static int pm8xxx_vib_suspend(struct device *dev)
{
	struct pm8xxx_vib *vib = dev_get_drvdata(dev);

	
	pm8xxx_vib_set(vib, false);

	return 0;
}
Exemple #8
0
static void pm8xxx_vibrator_on(struct work_struct *work)
{
    struct vib_on_work_struct *work_data = container_of
                                 (work, struct vib_on_work_struct, work_vib_on);
    struct pm8xxx_vib *vib = vib_dev;

    VIB_DEBUG_LOG(KERN_INFO, "called.\n");
    pm8xxx_vib_set(vib, 1, work_data->vib_time);
}
Exemple #9
0
static int pm8xxx_vib_suspend(struct device *dev)
{
	struct pm8xxx_vib *vib = dev_get_drvdata(dev);

	hrtimer_cancel(&vib->vib_timer);
	cancel_work_sync(&vib->work);
	/* turn-off vibrator */
	pm8xxx_vib_set(vib, 0);

	return 0;
}
Exemple #10
0
static int pm8xxx_vib_suspend(struct device *dev)
{
    struct pm8xxx_vib *vib = dev_get_drvdata(dev);
    int count = 0;

    VIB_DEBUG_LOG(KERN_INFO, "called.\n");
    hrtimer_cancel(&vib->vib_timer);
    for (count = 0; count < VIB_WORK_NUM; count++) {
        VIB_DEBUG_LOG(KERN_INFO, "count=%d.\n", count);
        cancel_work_sync(&(vib->vib_on_work_data[count].work_vib_on));
        cancel_work_sync(&vib->work_vib_off[count]);
        vib->vib_on_work_data[count].vib_time = 0;
    }
    /* turn-off vibrator */
    pm8xxx_vib_set(vib, 0, 0);

    VIB_DEBUG_LOG(KERN_INFO, "end.\n");
    return 0;
}
static void pm8xxx_work_handler(struct work_struct *work)
{
	struct pm8xxx_vib *vib = container_of(work, struct pm8xxx_vib, work);
	int rc;
	u8 val;

	rc = pm8xxx_vib_read_u8(vib, &val, VIB_DRV);
	if (rc < 0)
		return;

	if (vib->speed) {
		vib->active = true;
		vib->level = ((VIB_MAX_LEVELS * vib->speed) / MAX_FF_SPEED) +
						VIB_MIN_LEVEL_mV;
		vib->level /= 100;
	} else {
		vib->active = false;
		vib->level = VIB_MIN_LEVEL_mV / 100;
	}

	pm8xxx_vib_set(vib, vib->active);
}
static int dbg_vibrator_onoff_set(void *data, u64 value)
{
	struct pm8xxx_vib *vib = (struct pm8xxx_vib *)data;

	if (value == 0) {
		mutex_lock(&vib->lock);
		vib->state = 0;
		mutex_unlock(&vib->lock);
	} else if (value == 1) {
		mutex_lock(&vib->lock);
		vib->state = 1;
		mutex_unlock(&vib->lock);
	} else {
			VIBRATOR_PRINTK(1, "%s: Error command(%lld)\n",
				__func__, value);
	}
			
	VIBRATOR_PRINTK(1, "%s: turn %s vibrator\n",
		__func__, vib->state ? "on":"off");
			
	pm8xxx_vib_set(vib, vib->state);
	
	return 0;
}