自己整理一下输入子系统的框架:
以gpio_keys.c 设备端例子,以evdev.c为handler端的例子。
gpio_keys.c
platform_driver_register(&gpio_keys_device_driver);
gpio_keys_probe
gpio_keys_get_devtree_pdata //设备树填充结构体信息
input->open = gpio_keys_open;
input->close = gpio_keys_close;
gpio_keys_setup_key
INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func);--->gpio_keys_gpio_work_func
input_set_capability(input, button->type ?: EV_KEY, button->code);
devm_request_any_context_irq(&pdev->dev, bdata->irq,
gpio_keys_gpio_isr, irqflags, desc, bdata);
sysfs_create_group
input_register_device
device_init_wakeup
gpio_keys_gpio_isr
mod_delayed_work(system_unbound_wq,
&bdata->work,
msecs_to_jiffies(bdata->software_debounce));
gpio_keys_gpio_work_func
gpio_keys_gpio_report_event
input_event(input, type, button->code, !!state);
input_sync(input);
input_register_device
list_for_each_entry(handler, &input_handler_list, node)
input_attach_handler(dev, handler);
id = input_match_device(handler, dev);
if (!handler->match || handler->match(handler, dev))
error = handler->connect(handler, dev, id);
input->name = pdata->name ? : pdev->name;
input->phys = "gpio-keys/input0";
input->dev.parent = &pdev->dev;
input->open = gpio_keys_open;
input->close = gpio_keys_close;
input->id.bustype = BUS_HOST;
input->id.vendor = 0x0001;
input->id.product = 0x0001;
input->id.version = 0x0100;
input.c
input_init
class_register
input_proc_init
register_chrdev_region
__register_chrdev_region
evdev.c
evdev_init
input_register_handler
error = handler->connect(handler, dev, id);
error = input_register_handle(&evdev->handle);
static struct input_handler evdev_handler = {
.event = evdev_event,
.events = evdev_events,
.connect = evdev_connect,
.disconnect = evdev_disconnect,
.legacy_minors = true,
.minor = EVDEV_MINOR_BASE,
.name = "evdev",
.id_table = evdev_ids,
};
cat event*
evdev_open
evdev_open_device
input_open_device
gpio_keys_open
gpio_keys_report_state
gpio_keys_gpio_report_event
input_event(input, type, button->code, !!state);
input_sync
evdev_read
input_event_to_user
copy_to_user
evdev_write
input_event_from_user
input_inject_event