void max77888_vibtonz_en(bool en) { if (g_hap_data == NULL) { printk(KERN_ERR "[VIB] the motor is not ready!!!"); return ; } if (en) { if (g_hap_data->running) return; max77888_haptic_i2c(g_hap_data, true); g_hap_data->running = true; } else { if (!g_hap_data->running) return; max77888_haptic_i2c(g_hap_data, false); g_hap_data->running = false; } }
void vibtonz_en(bool en) { int ret; if (g_hap_data == NULL) { printk(KERN_ERR "[VIB] the motor is not ready!!!"); return ; } if (en) { if (g_hap_data->running) return; max77888_haptic_i2c(g_hap_data, true); pwm_config(g_hap_data->pwm, prev_duty, g_hap_data->pdata->period); pwm_enable(g_hap_data->pwm); if (g_hap_data->pdata->motor_en) g_hap_data->pdata->motor_en(true); else ret = regulator_enable(g_hap_data->regulator); g_hap_data->running = true; } else { if (!g_hap_data->running) return; if (g_hap_data->pdata->motor_en) g_hap_data->pdata->motor_en(false); else regulator_disable(g_hap_data->regulator); pwm_disable(g_hap_data->pwm); max77888_haptic_i2c(g_hap_data, false); g_hap_data->running = false; } }
static void haptic_work(struct work_struct *work) { struct max77888_haptic_data *hap_data = container_of(work, struct max77888_haptic_data, work); int ret; pr_debug("[VIB] %s\n", __func__); if (hap_data->timeout > 0) { if (hap_data->running) return; max77888_haptic_i2c(hap_data, true); pwm_config(hap_data->pwm, hap_data->pdata->duty, hap_data->pdata->period); pwm_enable(hap_data->pwm); if (hap_data->pdata->motor_en) hap_data->pdata->motor_en(true); else ret = regulator_enable(hap_data->regulator); hap_data->running = true; } else { if (!hap_data->running) return; if (hap_data->pdata->motor_en) hap_data->pdata->motor_en(false); else regulator_disable(hap_data->regulator); pwm_disable(hap_data->pwm); max77888_haptic_i2c(hap_data, false); hap_data->running = false; } return; }