记录高通MSM8909平台的vibrator manual mode的工作方式:
static int qpnp_vibrator_probe(struct spmi_device *spmi)
{
INIT_WORK(&vib->work, qpnp_vib_update);
hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
vib->vib_timer.function = qpnp_vib_timer_func;
vib->timed_dev.get_time = qpnp_vib_get_time;
//获取timer的剩余时间
vib->timed_dev.enable = qpnp_vib_enable;
timed_output_dev_register(&vib->timed_dev);
}
函数调用关系:
echo 1 > /sys/class/timed_output/vibrator/enable --> drivers/staging/android/timed_output.c enable_store --> qpnp-vibrator.c qpnp_vib_enable --> start vib_timer --> qpnp_vib_update --> qpnp_vib_set(直接操作寄存器来达到enable/disable vib的效果) --> 当timer timeout的时候,将vib->state的状态从0->1 --> qpnp_vib_timer_func --> qpnp_vib_update --> qpnp_vib_set.