include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / input / touchscreen / ucb1400_ts.c
index 6954f55..028a536 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/device.h>
 #include <linux/interrupt.h>
 #include <linux/suspend.h>
-#include <linux/slab.h>
 #include <linux/kthread.h>
 #include <linux/freezer.h>
 #include <linux/ucb1400.h>
@@ -128,9 +127,10 @@ static inline unsigned int ucb1400_ts_read_yres(struct ucb1400_ts *ucb)
        return ucb1400_adc_read(ucb->ac97, 0, adcsync);
 }
 
-static inline int ucb1400_ts_pen_down(struct snd_ac97 *ac97)
+static inline int ucb1400_ts_pen_up(struct snd_ac97 *ac97)
 {
        unsigned short val = ucb1400_reg_read(ac97, UCB_TS_CR);
+
        return val & (UCB_TS_CR_TSPX_LOW | UCB_TS_CR_TSMX_LOW);
 }
 
@@ -170,11 +170,11 @@ static void ucb1400_handle_pending_irq(struct ucb1400_ts *ucb)
        ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, isr);
        ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0);
 
-       if (isr & UCB_IE_TSPX) {
+       if (isr & UCB_IE_TSPX)
                ucb1400_ts_irq_disable(ucb->ac97);
-               enable_irq(ucb->irq);
-       } else
-               printk(KERN_ERR "ucb1400: unexpected IE_STATUS = %#x\n", isr);
+       else
+               dev_dbg(&ucb->ts_idev->dev, "ucb1400: unexpected IE_STATUS = %#x\n", isr);
+       enable_irq(ucb->irq);
 }
 
 static int ucb1400_ts_thread(void *_ucb)
@@ -209,7 +209,7 @@ static int ucb1400_ts_thread(void *_ucb)
 
                msleep(10);
 
-               if (ucb1400_ts_pen_down(ucb->ac97)) {
+               if (ucb1400_ts_pen_up(ucb->ac97)) {
                        ucb1400_ts_irq_enable(ucb->ac97);
 
                        /*
@@ -345,6 +345,7 @@ static int ucb1400_ts_detect_irq(struct ucb1400_ts *ucb)
 static int ucb1400_ts_probe(struct platform_device *dev)
 {
        int error, x_res, y_res;
+       u16 fcsr;
        struct ucb1400_ts *ucb = dev->dev.platform_data;
 
        ucb->ts_idev = input_allocate_device();
@@ -353,10 +354,13 @@ static int ucb1400_ts_probe(struct platform_device *dev)
                goto err;
        }
 
-       error = ucb1400_ts_detect_irq(ucb);
-       if (error) {
-               printk(KERN_ERR "UCB1400: IRQ probe failed\n");
-               goto err_free_devs;
+       /* Only in case the IRQ line wasn't supplied, try detecting it */
+       if (ucb->irq < 0) {
+               error = ucb1400_ts_detect_irq(ucb);
+               if (error) {
+                       printk(KERN_ERR "UCB1400: IRQ probe failed\n");
+                       goto err_free_devs;
+               }
        }
 
        init_waitqueue_head(&ucb->ts_wait);
@@ -382,6 +386,14 @@ static int ucb1400_ts_probe(struct platform_device *dev)
        ucb->ts_idev->evbit[0]          = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY);
        ucb->ts_idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
 
+       /*
+        * Enable ADC filter to prevent horrible jitter on Colibri.
+        * This also further reduces jitter on boards where ADCSYNC
+        * pin is connected.
+        */
+       fcsr = ucb1400_reg_read(ucb->ac97, UCB_FCSR);
+       ucb1400_reg_write(ucb->ac97, UCB_FCSR, fcsr | UCB_FCSR_AVE);
+
        ucb1400_adc_enable(ucb->ac97);
        x_res = ucb1400_ts_read_xres(ucb);
        y_res = ucb1400_ts_read_yres(ucb);