kernel input handler
该篇分析通用的input handler:evdev.c
源码:
android-5.0.2\linux-3.0.86\drivers\input\Evdev.c
功能:
创建/dev/input/eventx的字符设备供上层使用
源码分析:
往input子系统注册input_handler
static struct input_handler evdev_handler = { .event = evdev_event, // 事件上报 .connect = evdev_connect, // input_device和input_handler的链接函数 .disconnect = evdev_disconnect, .fops = &evdev_fops, // 字符设备的fops .minor = EVDEV_MINOR_BASE, .name = "evdev", .id_table = evdev_ids, // input_device和该handler的匹配 }; static int __init evdev_init(void) return input_register_handler(&evdev_handler);
事件上报
input_device上报的数据放入到各自的buffer中
static void evdev_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) { // 封装input_device数据 event.type = type; event.code = code; event.value = value; // 把event数据放入到各自的buffer中 list_for_each_entry_rcu(client, &evdev->client_list, node) evdev_pass_event(client, &event); client->buffer[client->head++] = *event; client->head &= client->bufsize - 1; // 接收到sync事件后,唤醒 if (type == EV_SYN && code == SYN_REPORT) wake_up_interruptible(&evdev->wait); }