/* ** Called to disable amp (disable output force) */ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex) { /*printk(KERN_ERR"[VIBRATOR] ImmVibeSPI_ForceOut_AmpDisable is called\n");*/ #if 0 if (g_bAmpEnabled) { DbgOut((KERN_DEBUG "ImmVibeSPI_ForceOut_AmpDisable.\n")); g_bAmpEnabled = false; /* Disable amp */ /* Disable PWM CLK */ } #endif if (g_bAmpEnabled) { g_bAmpEnabled = false; #if !defined(CONFIG_MACH_P4NOTE) vibtonz_pwm(0); vibtonz_en(false); #endif if (regulator_hapticmotor_enabled == 1) { regulator_hapticmotor_enabled = 0; printk(KERN_DEBUG "Motor:tspdrv: %s (%d)\n", __func__, regulator_hapticmotor_enabled); } } return VIBE_S_SUCCESS; }
/* ** Called to disable amp (disable output force) */ IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_AmpDisable(VibeUInt8 nActuatorIndex) { if (g_bAmpEnabled) { g_bAmpEnabled = false; vibtonz_pwm(0); vibtonz_en(false); if (regulator_hapticmotor_enabled == 1) { regulator_hapticmotor_enabled = 0; } } return VIBE_S_SUCCESS; }
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_SetSamples(VibeUInt8 nActuatorIndex, VibeUInt16 nOutputSignalBitDepth, VibeUInt16 nBufferSizeInBytes, VibeInt8 * pForceOutputBuffer) { VibeInt8 nForce; #if defined(CONFIG_IMM_DRV_VERSION_3_7) if (g_bOutputDataBufferEmpty) { nActuatorIndex = 0; nOutputSignalBitDepth = 8; nBufferSizeInBytes = 1; pForceOutputBuffer[0] = 0; } #endif /* CONFIG_IMM_DRV_VERSION_3_7 */ switch (nOutputSignalBitDepth) { case 8: /* pForceOutputBuffer is expected to contain 1 byte */ if (nBufferSizeInBytes != 1) { DbgOut((KERN_ERR "[ImmVibeSPI] ImmVibeSPI_ForceOut_SetSamples nBufferSizeInBytes = %d\n", nBufferSizeInBytes)); return VIBE_E_FAIL; } nForce = pForceOutputBuffer[0]; break; case 16: /* pForceOutputBuffer is expected to contain 2 byte */ if (nBufferSizeInBytes != 2) return VIBE_E_FAIL; /* Map 16-bit value to 8-bit */ nForce = ((VibeInt16 *)pForceOutputBuffer)[0] >> 8; break; default: /* Unexpected bit depth */ return VIBE_E_FAIL; } if (nForce == 0) { /* Set 50% duty cycle or disable amp */ ImmVibeSPI_ForceOut_AmpDisable(0); } else { /* Map force from [-127, 127] to [0, PWM_DUTY_MAX] */ vibtonz_pwm(nForce); ImmVibeSPI_ForceOut_AmpEnable(0); } return VIBE_S_SUCCESS; }