static int set_vibetonz(int timeout) { #ifndef CONFIG_MACH_Q1_REV02 struct regulator *regulator; #endif if (!timeout) { vibe_control_max8997(Immvib_pwm, 0); if (regulator_hapticmotor_enabled == 1) { #ifdef CONFIG_MACH_Q1_REV02 gpio_direction_output(GPIO_MOTOR_EN, 0); #else regulator = regulator_get(NULL, "vmotor"); if (IS_ERR(regulator)) { DbgOut((KERN_ERR "Failed to get vmoter regulator.\n")); return 0; } regulator_force_disable(regulator); regulator_put(regulator); regulator_hapticmotor_enabled = 0; #endif DbgOut((KERN_INFO "tspdrv: DISABLE\n")); wake_unlock(&vib_wake_lock); } } else { wake_lock(&vib_wake_lock); _pwm_config(Immvib_pwm, VIBRATOR_DUTY, VIBRATOR_PERIOD); vibe_control_max8997(Immvib_pwm, 1); #ifdef CONFIG_MACH_Q1_REV02 gpio_direction_output(GPIO_MOTOR_EN, 1); #else regulator = regulator_get(NULL, "vmotor"); if (IS_ERR(regulator)) { DbgOut((KERN_ERR "Failed to get vmoter regulator.\n")); return 0; } regulator_enable(regulator); regulator_put(regulator); #endif regulator_hapticmotor_enabled = 1; DbgOut((KERN_INFO "tspdrv: ENABLE\n")); } vibrator_value = timeout; printk(KERN_DEBUG "tspdrv: %s (%d)\n", __func__, regulator_hapticmotor_enabled); return 0; }
static int set_vibetonz(int timeout) { struct regulator *regulator; if (!timeout) { vibe_control_max8997(Immvib_pwm, 0); if (regulator_hapticmotor_enabled == 1) { regulator = regulator_get(NULL, "vmotor"); if (IS_ERR(regulator)) { DbgOut((KERN_ERR "Failed to get vmoter regulator.\n")); return 0; } regulator_force_disable(regulator); regulator_put(regulator); regulator_hapticmotor_enabled = 0; DbgOut((KERN_INFO "tspdrv: DISABLE\n")); wake_unlock(&vib_wake_lock); } } else { wake_lock(&vib_wake_lock); #if defined(CONFIG_BUILD_TARGET_CM7) _pwm_config(Immvib_pwm, vibrator_duty_levels[vibrator_level], VIBRATOR_PERIOD); #else _pwm_config(Immvib_pwm, VIBRATOR_DUTY, VIBRATOR_PERIOD); #endif vibe_control_max8997(Immvib_pwm, 1); regulator = regulator_get(NULL, "vmotor"); if (IS_ERR(regulator)) { DbgOut((KERN_ERR "Failed to get vmoter regulator.\n")); return 0; } regulator_enable(regulator); regulator_put(regulator); regulator_hapticmotor_enabled = 1; DbgOut((KERN_INFO "tspdrv: ENABLE\n")); } vibrator_value = timeout; printk(KERN_DEBUG "tspdrv: %s (%d)\n", __func__, regulator_hapticmotor_enabled); return 0; }
/* ** Called to disable amp (disable output force) */ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex) { #if 0 if (g_bAmpEnabled) { DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_AmpDisable.\n")); g_bAmpEnabled = false; /* Disable amp */ /* Disable PWM CLK */ } #endif if (g_bAmpEnabled) { struct regulator *regulator; g_bAmpEnabled = false; _pwm_config(Immvib_pwm, freq_count/2, freq_count); if (regulator_hapticmotor_enabled == 1) { regulator = regulator_get(NULL, "vmotor"); if (IS_ERR(regulator)) { DbgOut((KERN_ERR"Failed to get vmoter regulator.\n")); return 0; } regulator_disable(regulator); regulator_put(regulator); regulator_hapticmotor_enabled = 0; } vibe_control_max8997(Immvib_pwm, 0); } return VIBE_S_SUCCESS; }
/* ** Called to enable amp (enable output force) */ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpEnable(VibeUInt8 nActuatorIndex) { #if 0 if (!g_bAmpEnabled) { DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_AmpEnable.\n")); g_bAmpEnabled = true; /* Generate PWM CLK with proper frequency(ex. 22400Hz) and 50% duty cycle.*/ /* Enable amp */ } #endif if (!g_bAmpEnabled) { struct regulator *regulator; g_bAmpEnabled = true; _pwm_config(Immvib_pwm, freq_count/2, freq_count); vibe_control_max8997(Immvib_pwm, 1); regulator = regulator_get(NULL, "vmotor"); if (IS_ERR(regulator)) { DbgOut((KERN_ERR"Failed to get vmoter regulator.\n")); return 0; } regulator_enable(regulator); regulator_put(regulator); regulator_hapticmotor_enabled = 1; } return VIBE_S_SUCCESS; }