android实现的timed_output驱动架构用于定时输出设备。例如马达、leds等。
代码路径:
kernel/drivers/staging/android/timed_output.c,timed_output.h。
实现结构体:
struct timed_output_dev {
const char *name;
/* enable the output and set the timer */
void (*enable)(struct timed_output_dev *sdev, int timeout);
/* returns the current number of milliseconds remaining on the timer */
int (*get_time)(struct timed_output_dev *sdev);
/* private data */
struct device *dev;
int index;
int state;
};
注册接口:
timed_output_dev_register()
timed_output_dev_unregister()
代码应用:
vib->timed_dev.name = "vibrator";
vib->timed_dev.get_time = pm8xxx_vib_get_time;
vib->timed_dev.enable = pm8xxx_vib_enable;
rc = timed_output_dev_register(&vib->timed_dev);//注册为/sys/class/timed_output/vibrator
调试接口:
最终 #echo 1000 > /sys/class/timed_output/vibrator/enable
最终 #cat /sys/class/timed_output/vibrator/enable