diff options
author | Mirko Vogt <mirko@openwrt.org> | 2008-12-13 01:54:56 +0000 |
---|---|---|
committer | Mirko Vogt <mirko@openwrt.org> | 2008-12-13 01:54:56 +0000 |
commit | 4eec5435530060db9fa75ee3d363252eb73695e9 (patch) | |
tree | 01f2bf78edb2e3bb1466df9bca72e068632d0e74 /target/linux/s3c24xx/patches-2.6.26/1111-fix-jack-debounce.patch.patch | |
parent | b0f5b5307126b277c44fa71bbd8f105f6702a8c0 (diff) | |
download | master-187ad058-4eec5435530060db9fa75ee3d363252eb73695e9.tar.gz master-187ad058-4eec5435530060db9fa75ee3d363252eb73695e9.tar.bz2 master-187ad058-4eec5435530060db9fa75ee3d363252eb73695e9.zip |
change prefix for kernelpatchbase 2.6.26
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13619 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/s3c24xx/patches-2.6.26/1111-fix-jack-debounce.patch.patch')
-rwxr-xr-x | target/linux/s3c24xx/patches-2.6.26/1111-fix-jack-debounce.patch.patch | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/target/linux/s3c24xx/patches-2.6.26/1111-fix-jack-debounce.patch.patch b/target/linux/s3c24xx/patches-2.6.26/1111-fix-jack-debounce.patch.patch new file mode 100755 index 0000000000..419bfd2e97 --- /dev/null +++ b/target/linux/s3c24xx/patches-2.6.26/1111-fix-jack-debounce.patch.patch @@ -0,0 +1,118 @@ +From 4c83444bd41a70fe47731e589c6575da2bfc78c8 Mon Sep 17 00:00:00 2001 +From: Andy Green <andy@openmoko.com> +Date: Fri, 25 Jul 2008 23:06:05 +0100 +Subject: [PATCH] fix-jack-debounce.patch + +Headphone jack detection is bouncy, it can trigger multiple interrupts +on insertion or removal. This patch adds a workqueue that waits out the +interrupt spew in 100ms units, and if it sees no more interrupts for 100ms +only then samples and reports the jack state. I was unable to get a bounce +after 20 or so tries after this. + +Signed-off-by: Andy Green <andy@openmoko.com> +--- + drivers/input/keyboard/neo1973kbd.c | 63 ++++++++++++++++++++++++++++++++-- + 1 files changed, 59 insertions(+), 4 deletions(-) + +diff --git a/drivers/input/keyboard/neo1973kbd.c b/drivers/input/keyboard/neo1973kbd.c +index 06fa8e0..6c96660 100644 +--- a/drivers/input/keyboard/neo1973kbd.c ++++ b/drivers/input/keyboard/neo1973kbd.c +@@ -21,6 +21,7 @@ + #include <linux/jiffies.h> + #include <linux/module.h> + #include <linux/slab.h> ++#include <linux/workqueue.h> + + #include <asm/gpio.h> + #include <asm/mach-types.h> +@@ -28,6 +29,11 @@ + struct neo1973kbd { + struct input_dev *input; + unsigned int suspended; ++ struct work_struct work; ++ int work_in_progress; ++ int hp_irq_count_in_work; ++ int hp_irq_count; ++ int jack_irq; + }; + + static irqreturn_t neo1973kbd_aux_irq(int irq, void *dev_id) +@@ -52,14 +58,61 @@ static irqreturn_t neo1973kbd_hold_irq(int irq, void *dev_id) + return IRQ_HANDLED; + } + ++ ++static void neo1973kbd_debounce_jack(struct work_struct *work) ++{ ++ struct neo1973kbd *kbd = container_of(work, struct neo1973kbd, work); ++ ++ /* we wait out any multiple interrupt stuttering in 100ms lumps */ ++ ++ do { ++ kbd->hp_irq_count_in_work = kbd->hp_irq_count; ++ msleep(100); ++ } while (kbd->hp_irq_count != kbd->hp_irq_count_in_work); ++ ++ /* no new interrupts on jack for 100ms... ok we will report it */ ++ ++ input_report_switch(kbd->input, ++ SW_HEADPHONE_INSERT, ++ gpio_get_value(irq_to_gpio(kbd->jack_irq))); ++ input_sync(kbd->input); ++ ++ /* next time we get an interrupt on jack we need new work action */ ++ kbd->work_in_progress = 0; ++} ++ ++ ++ + static irqreturn_t neo1973kbd_headphone_irq(int irq, void *dev_id) + { + struct neo1973kbd *neo1973kbd_data = dev_id; + +- int key_pressed = gpio_get_value(irq_to_gpio(irq)); +- input_report_switch(neo1973kbd_data->input, +- SW_HEADPHONE_INSERT, key_pressed); +- input_sync(neo1973kbd_data->input); ++ /* ++ * this interrupt is prone to bouncing and userspace doesn't like ++ * to have to deal with that kind of thing. So we do not accept ++ * that a jack interrupt is equal to a jack event. Instead we fire ++ * some work on the first interrupt, and it hangs about in 100ms units ++ * until no more interrupts come. Then it accepts the state it finds ++ * for jack insert and reports it once ++ */ ++ ++ neo1973kbd_data->hp_irq_count++; ++ /* ++ * the first interrupt we see for a while, we fire the work item ++ * and record the interrupt count when we did that. If more interrupts ++ * come in the meanwhile, we can tell by the difference in that ++ * stored count and hp_irq_count which increments every interrupt ++ */ ++ if (!neo1973kbd_data->work_in_progress) { ++ neo1973kbd_data->jack_irq = irq; ++ neo1973kbd_data->hp_irq_count_in_work = ++ neo1973kbd_data->hp_irq_count; ++ if (!schedule_work(&neo1973kbd_data->work)) ++ printk(KERN_ERR ++ "Unable to schedule headphone debounce\n"); ++ else ++ neo1973kbd_data->work_in_progress = 1; ++ } + + return IRQ_HANDLED; + } +@@ -120,6 +173,8 @@ static int neo1973kbd_probe(struct platform_device *pdev) + + neo1973kbd->input = input_dev; + ++ INIT_WORK(&neo1973kbd->work, neo1973kbd_debounce_jack); ++ + input_dev->name = "Neo1973 Buttons"; + input_dev->phys = "neo1973kbd/input0"; + input_dev->id.bustype = BUS_HOST; +-- +1.5.6.3 + |