]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Staging: mrst_touchscreen - clean up input side
authorAlan Cox <alan@linux.intel.com>
Wed, 1 Sep 2010 05:20:55 +0000 (22:20 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 2 Sep 2010 02:43:02 +0000 (19:43 -0700)
Fix most of the stuff that Dmitry pointed out. This leaves the mutex in IRQ
and misuse of SPI to sort out.

Also fix the build bits so it actually builds in staging - whoops.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/staging/Makefile
drivers/staging/mrst-touchscreen/Kconfig
drivers/staging/mrst-touchscreen/Makefile
drivers/staging/mrst-touchscreen/TODO
drivers/staging/mrst-touchscreen/intel-mid-touch.c

index 9fa25133874afc9b0c2a4c4b31a87f0aa98468d3..d071bac73acc08ba88130fc7d69f8d9092cbabdc 100644 (file)
@@ -52,5 +52,5 @@ obj-$(CONFIG_CXT1E1)          += cxt1e1/
 obj-$(CONFIG_TI_ST)            += ti-st/
 obj-$(CONFIG_ADIS16255)                += adis16255/
 obj-$(CONFIG_FB_XGI)           += xgifb/
-obj-$(CONFIG_TOUCHSCREEN_MRSTOUCH)     += mrst-touchscreen/
+obj-$(CONFIG_TOUCHSCREEN_INTEL_MID)    += mrst-touchscreen/
 obj-$(CONFIG_MSM_STAGING)      += msm/
index c2af49217084aff744d92a9cdcf0207ea6cd95a1..775d740bb61f5d4b80acd772520de20aa01c036a 100644 (file)
@@ -1,6 +1,6 @@
 config TOUCHSCREEN_INTEL_MID
        tristate "Intel MID platform resistive touchscreen"
-       depends on INTEL_SCU_IPC
+       depends on INTEL_SCU_IPC && INPUT_TOUCHSCREEN
        default y
        help
          Say Y here if you have a Intel MID based touchscreen
index 2d638b0d70bf4ecf03c8fc0ff748a09232087edb..155f58b57dbe5e9f9408ae73ca25bbb1a4d8980a 100644 (file)
@@ -1,3 +1,3 @@
-obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) := intel_mid_touch.o
+obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) := intel-mid-touch.o
 
 
index 7157028d634a63857e5c500d6c37b19091a49503..84aa6958d0aa925ae42b3b883d068a0f41c176e8 100644 (file)
@@ -1,2 +1,4 @@
 - Move the driver to not think it is SPI (requires fixing some of the SFI
   and firmware side)
+- Fix mutex in IRQ stuff - threaded IRQ ?
+
index abba22f921bec49b8f4d58123f33c8e01947380e..6fed01ee82dacf8110e7a833bd4e744574913a02 100644 (file)
@@ -23,7 +23,6 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
  * TODO:
- *     kill off mrstouch_debug eventually
  *     review conversion of r/m/w sequences
  *     Replace interrupt mutex abuse
  *     Kill of mrstouchdevp pointer
 #include <asm/intel_scu_ipc.h>
 
 
-#if defined(MRSTOUCH_DEBUG)
-#define mrstouch_debug(fmt, args...)\
-       do { \
-               printk(KERN_DEBUG "\n[MRSTOUCH(%d)] - ", __LINE__); \
-               printk(KERN_DEBUG fmt, ##args); \
-       } while (0);
-#else
-#define mrstouch_debug(fmt, args...)
-#endif
-
 /* PMIC Interrupt registers */
 #define PMIC_REG_ID1   0x00 /*PMIC ID1 register */
 
 #define MAX_X          1024
 #define MIN_Y          10
 #define MAX_Y          1024
+#define MIN_P          0
+#define MAX_P          TOUCH_PRESSURE_FS
+
 #define WAIT_ADC_COMPLETION 10
 
 /* PMIC ADC round robin delays */
@@ -124,8 +116,6 @@ struct mrstouch_dev {
        int             irq;    /* Touch screen IRQ # */
        uint            vendor;  /* PMIC vendor */
        uint            rev;  /* PMIC revision */
-       bool            suspended; /* Device suspended status */
-       bool            disabled;  /* Device disabled status */
        u16             x;  /* X coordinate */
        u16             y;  /* Y coordinate */
        bool            pendown;  /* PEN position */
@@ -320,8 +310,6 @@ static int mrstouch_adc_init(struct mrstouch_dev *tsdev)
 
        tsdev->asr = start;
 
-       mrstouch_debug("Channel offset(%d): 0x%X\n", tsdev->asr, tsdev->vendor);
-
        /* ADC power on, start, enable PENDET and set loop delay
         * ADC loop delay is set to 4.5 ms approximately
         * Loop delay more than this results in jitter in adc readings
@@ -355,7 +343,6 @@ static void mrstouch_report_xy(struct mrstouch_dev *tsdev, u16 x, u16 y, u16 z)
 
        if (tsdev->pendown && z <= TOUCH_PRESSURE) {
                /* Pen removed, report button release */
-               mrstouch_debug("BTN REL(%d)", z);
                input_report_key(tsdev->input, BTN_TOUCH, 0);
                tsdev->pendown = false;
        }
@@ -371,7 +358,6 @@ static void mrstouch_report_xy(struct mrstouch_dev *tsdev, u16 x, u16 y, u16 z)
        if (x < MIN_X || x > MAX_X || y < MIN_Y || y > MAX_Y) {
                /* Spurious values, release button if touched and return */
                if (tsdev->pendown) {
-                       mrstouch_debug("BTN REL(%d)", z);
                        input_report_key(tsdev->input, BTN_TOUCH, 0);
                        tsdev->pendown = false;
                }
@@ -382,13 +368,13 @@ static void mrstouch_report_xy(struct mrstouch_dev *tsdev, u16 x, u16 y, u16 z)
 
                input_report_abs(tsdev->input, ABS_X, x);
                input_report_abs(tsdev->input, ABS_Y, y);
+               input_report_abs(tsdev->input, ABS_PRESSURE, z);
                input_sync(tsdev->input);
        }
 
 
        if (!tsdev->pendown && z > TOUCH_PRESSURE) {
                /* Pen touched, report button touch */
-               mrstouch_debug("BTN TCH(%d, %d, %d)", x, y, z);
                input_report_key(tsdev->input, BTN_TOUCH, 1);
                tsdev->pendown = true;
        }
@@ -446,18 +432,7 @@ static int mrstouch_pmic_fs_adc_read(struct mrstouch_dev *tsdev)
        z |= data[1] & 0x7; /* Lower 3 bits */
        z &= 0x3FF;
 
-#if defined(MRSTOUCH_PRINT_XYZP)
-       mrstouch_debug("X: %d, Y: %d, Z: %d", x, y, z);
-#endif
-
-       if (z >= TOUCH_PRESSURE_FS) {
-               mrstouch_report_xy(tsdev, x, y, TOUCH_PRESSURE - 1); /* Pen Removed */
-               return TOUCH_PRESSURE - 1;
-       } else {
-               mrstouch_report_xy(tsdev, x, y, TOUCH_PRESSURE + 1); /* Pen Touched */
-               return TOUCH_PRESSURE + 1;
-       }
-
+       mrstouch_report_xy(tsdev, x, y, z);
        return 0;
 
 ipc_error:
@@ -615,14 +590,6 @@ static int mrstouch_adc_read(struct mrstouch_dev *tsdev)
        if (err)
                goto ipc_error;
 
-#if defined(MRSTOUCH_PRINT_XYZP)
-       printk(KERN_INFO "X+: %d, Y+: %d, Z+: %d\n", xp, yp, zp);
-#endif
-
-#if defined(MRSTOUCH_PRINT_XYZM)
-       printk(KERN_INFO "X-: %d, Y-: %d, Z-: %d\n", xm, ym, zm);
-#endif
-
        mrstouch_report_xy(tsdev, xp, yp, zp); /* report x and y to eventX */
 
        return zp;
@@ -694,12 +661,10 @@ static int ts_input_dev_init(struct mrstouch_dev *tsdev, struct spi_device *spi)
 {
        int err = 0;
 
-       mrstouch_debug("%s", __func__);
-
        tsdev->input = input_allocate_device();
        if (!tsdev->input) {
                dev_err(&tsdev->spi->dev, "Unable to allocate input device.\n");
-               return -EINVAL;
+               return -ENOMEM;
        }
 
        tsdev->input->name = "mrst_touchscreen";
@@ -714,8 +679,9 @@ static int ts_input_dev_init(struct mrstouch_dev *tsdev, struct spi_device *spi)
        tsdev->input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
        tsdev->input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
 
-       input_set_abs_params(tsdev->input, ABS_X, MIN_X, MIN_Y, 0, 0);
-       input_set_abs_params(tsdev->input, ABS_Y, MIN_X, MIN_Y, 0, 0);
+       input_set_abs_params(tsdev->input, ABS_X, MIN_X, MAX_X, 0, 0);
+       input_set_abs_params(tsdev->input, ABS_Y, MIN_Y, MAX_Y, 0, 0);
+       input_set_abs_params(tsdev->input, ABS_PRESSURE, MIN_P, MAX_P, 0, 0);
 
        err = input_register_device(tsdev->input);
        if (err) {
@@ -723,9 +689,6 @@ static int ts_input_dev_init(struct mrstouch_dev *tsdev, struct spi_device *spi)
                input_free_device(tsdev->input);
                return err;
        }
-
-       mrstouch_debug("%s", "mrstouch initialized");
-
        return 0;
 
 }
@@ -737,8 +700,6 @@ static int __devinit mrstouch_probe(struct spi_device *mrstouch_spi)
        unsigned int myirq;
        struct mrstouch_dev *tsdev;
 
-       mrstouch_debug("%s(%p)", __func__, mrstouch_spi);
-
        mrstouchdevp = NULL;
        myirq = mrstouch_spi->irq;
 
@@ -768,18 +729,17 @@ static int __devinit mrstouch_probe(struct spi_device *mrstouch_spi)
        err = ts_input_dev_init(tsdev, mrstouch_spi);
        if (err) {
                dev_err(&tsdev->spi->dev, "ts_input_dev_init failed");
-               goto mrstouch_err_free_mem;
+               goto mrstouch_err_free_dev;
        }
 
        mutex_init(&tsdev->lock);
-       mutex_lock(&tsdev->lock)
+       mutex_lock(&tsdev->lock);
 
-       mrstouch_debug("Requesting IRQ-%d", myirq);
        err = request_irq(myirq, pendet_intr_handler,
                                0, "mrstouch", tsdev);
        if (err) {
                dev_err(&tsdev->spi->dev, "unable to allocate irq\n");
-               goto mrstouch_err_free_mem;
+               goto mrstouch_err_free_dev;
        }
 
        tsdev->pendet_thrd = kthread_run(mrstouch_pendet,
@@ -787,38 +747,24 @@ static int __devinit mrstouch_probe(struct spi_device *mrstouch_spi)
        if (IS_ERR(tsdev->pendet_thrd)) {
                dev_err(&tsdev->spi->dev, "kthread_run failed\n");
                err = PTR_ERR(tsdev->pendet_thrd);
-               goto mrstouch_err_free_mem;
+               goto mrstouch_err_free_irq;
        }
-       mrstouch_debug("%s", "Driver initialized");
        return 0;
-
+mrstouch_err_free_irq:
+       free_irq(myirq, tsdev);
+mrstouch_err_free_dev:
+       input_unregister_device(tsdev->input);
 mrstouch_err_free_mem:
        kfree(tsdev);
        return err;
 }
 
-static int mrstouch_suspend(struct spi_device *spi, pm_message_t msg)
-{
-       mrstouch_debug("%s", __func__);
-       mrstouchdevp->suspended = 1;
-       return 0;
-}
-
-static int mrstouch_resume(struct spi_device *spi)
-{
-       mrstouch_debug("%s", __func__);
-       mrstouchdevp->suspended = 0;
-       return 0;
-}
-
 static int mrstouch_remove(struct spi_device *spi)
 {
-       mrstouch_debug("%s", __func__);
        free_irq(mrstouchdevp->irq, mrstouchdevp);
-       input_unregister_device(mrstouchdevp->input);
-       input_free_device(mrstouchdevp->input);
        if (mrstouchdevp->pendet_thrd)
                kthread_stop(mrstouchdevp->pendet_thrd);
+       input_unregister_device(mrstouchdevp->input);
        kfree(mrstouchdevp);
        return 0;
 }
@@ -830,8 +776,6 @@ static struct spi_driver mrstouch_driver = {
                .owner  = THIS_MODULE,
        },
        .probe          = mrstouch_probe,
-       .suspend        = mrstouch_suspend,
-       .resume         = mrstouch_resume,
        .remove         = mrstouch_remove,
 };
 
@@ -839,11 +783,10 @@ static int __init mrstouch_module_init(void)
 {
        int err;
 
-       mrstouch_debug("%s", __func__);
        err = spi_register_driver(&mrstouch_driver);
        if (err) {
-               mrstouch_debug("%s(%d)", "SPI PENDET failed", err);
-               return -1;
+               printk(KERN_ERR "%s(%d)", "SPI PENDET failed", err);
+               return err;;
        }
 
        return 0;
@@ -851,7 +794,6 @@ static int __init mrstouch_module_init(void)
 
 static void __exit mrstouch_module_exit(void)
 {
-       mrstouch_debug("%s", __func__);
        spi_unregister_driver(&mrstouch_driver);
        return;
 }