高通vibrator是用leds下面的leds-qpnp-vibrator-ldo.c比较多,一般是pmic下面的ldo输出的方式控制振动。
HAL层
hal层用的是vendor/qcom/opensource/vibrator/aidl/Vibrator.cpp
振动的时候会调用ndk::ScopedAStatus Vibrator::on
这里会有判断振动驱动的类型
if (ledVib.mDetected){
ret = ledVib.on(timeoutMs);
}else{
ret = ff.on(timeoutMs);
}
如果leds下面的驱动注册成功,那么会调用
static const char LED_DEVICE[] = "/sys/class/leds/vibrator";
int LedVibratorDevice::on(int32_t timeoutMs) {
char file[PATH_MAX];
char value[32];
int ret;
snprintf(file, sizeof(file), "%s/%s", LED_DEVICE, "state");
ret = write_value(file, "1");
if (ret < 0)
goto error;
snprintf(file, sizeof(file), "%s/%s", LED_DEVICE, "duration");