From: Michael Gernoth Date: Wed, 18 May 2011 21:17:04 +0000 (+0200) Subject: set keypad debounce time to 5 ms X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/commitdiff_plain/d1ff9643d914a61f1d1a08bdb5a5ac7ae665aa16?ds=sidebyside set keypad debounce time to 5 ms --- diff --git a/debounce.c b/debounce.c index 8e13520..ec20fdb 100644 --- a/debounce.c +++ b/debounce.c @@ -1,8 +1,48 @@ #include +#include +#include +#include + +int find_ms2_dev(struct device *dev, void *data) +{ + if (!strncmp((char*)data, dev_name(dev), strlen((char*)data))) { + printk(KERN_INFO "Found it!\n"); + return 1; + } + return 0; +} static int __init debounce_init(void) { - printk(KERN_INFO "Hello Milestone2!\n"); + struct device *event_dev = NULL; + struct gpio_event_platform_data *gpio_epd; + struct gpio_event_info *gpio_ei; + struct gpio_event_matrix_info *gpio_evmi; + + printk(KERN_INFO "Searching for " GPIO_EVENT_DEV_NAME "...\n"); + + + event_dev = device_find_child(&platform_bus, GPIO_EVENT_DEV_NAME, find_ms2_dev); + if (event_dev == NULL) + return -ENODEV; + + gpio_epd = (struct gpio_event_platform_data*)event_dev->platform_data; + printk(KERN_INFO "And there is a %s connected...\n", gpio_epd->name); + if (strcmp(gpio_epd->name, "sholes-keypad")) + return -ENODEV; + + gpio_ei = (struct gpio_event_info*)gpio_epd->info[0]; + gpio_evmi = container_of(gpio_ei, struct gpio_event_matrix_info, info); + + printk(KERN_INFO "settle_time: %u\n", gpio_evmi->settle_time.tv.nsec); + printk(KERN_INFO "poll_time: %u\n", gpio_evmi->poll_time.tv.nsec); + printk(KERN_INFO "debounce_delay: %u\n", gpio_evmi->debounce_delay.tv.nsec); + if (!gpio_evmi->debounce_delay.tv.nsec) { + printk(KERN_INFO "Activating debounce!\n"); + gpio_evmi->debounce_delay.tv.nsec = 5 * NSEC_PER_MSEC; + printk(KERN_INFO "debounce_delay: %u\n", gpio_evmi->debounce_delay.tv.nsec); + } + return 0; }