input: touch: raydium: V61.7 code drop
Xiaohui Tao [Fri, 3 Jan 2014 22:36:31 +0000 (14:36 -0800)]
[1] Fix report pointer bug
[2] Modify pointer specifier for all printf-like function
[3] Add protection in KRL_CMD_WRITE_W_COUNT
[4] Fix GPIO sensor select bug
[5] Fix slowscan function bug
[6] Refine some statements
[7] Enhance stability of idle mode on Pismo (64-bit platform)
[8] Fix Raydium_selftest bug (result in touch not work)

Change-Id: Ibc71e4178bd7b90abb2ea1397b4ee59b4d7dc498
Signed-off-by: Xiaohui Tao <xtao@nvidia.com>
Reviewed-on: http://git-master/r/351894
Reviewed-by: Raymond Poudrier <rapoudrier@nvidia.com>
Tested-by: Raymond Poudrier <rapoudrier@nvidia.com>

drivers/input/touchscreen/rm31080a_ts.c
include/linux/spi/rm31080a_ts.h

index 786dbe4..2f34b2e 100644 (file)
@@ -489,6 +489,7 @@ void raydium_report_pointer(void *p)
        int iMaxX, iMaxY;
        struct rm_touch_event *spTP;
        ssize_t missing;
+
        spTP = kmalloc(sizeof(struct rm_touch_event), GFP_KERNEL);
        if (spTP == NULL)
                return;
@@ -523,7 +524,7 @@ void raydium_report_pointer(void *p)
                                break;
 
                        if ((spTP->ucToolType[i] == POINT_TYPE_ERASER)
-                                       && (spTP->ucSlot[i] && INPUT_POINT_RESET)) {
+                                       && (spTP->ucSlot[i] & INPUT_POINT_RESET)) {
                                input_report_key(g_input_dev,
                                        BTN_TOOL_RUBBER, 0);
                                input_mt_sync(g_input_dev);
@@ -601,7 +602,7 @@ void raydium_report_pointer(void *p)
                                break;
 
                        if ((spTP->ucToolType[i] == POINT_TYPE_ERASER)
-                                       && (spTP->ucSlot[i] && INPUT_POINT_RESET)) {
+                                       && (spTP->ucSlot[i] & INPUT_POINT_RESET)) {
                                input_report_key(
                                        g_input_dev[INPUT_DEVICE_FOR_STYLUS],
                                        BTN_TOOL_RUBBER, 0);
@@ -668,7 +669,8 @@ void raydium_report_pointer(void *p)
                        }
                        input_mt_sync(g_input_dev[target_device]);
                }
-               input_sync(g_input_dev[target_device]);
+               for (i = 0; i < INPUT_DEVICE_AMOUNT; i++)
+                       input_sync(g_input_dev[i]);
                ucLastTouchCount = spTP->ucTouchCount;
        }
 #endif
@@ -813,7 +815,8 @@ static u32 rm_tch_ctrl_configure(void)
        switch (g_stTs.u8ScanModeState) {
        case RM_SCAN_ACTIVE_MODE:
                u32Flag =
-                       RM_NEED_TO_SEND_SCAN | RM_NEED_TO_READ_RAW_DATA |
+                       RM_NEED_TO_SEND_SCAN |
+                       RM_NEED_TO_READ_RAW_DATA |
                        RM_NEED_TO_SEND_SIGNAL;
                break;
 
@@ -1049,8 +1052,8 @@ static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts)
 
        if (u16TblLenth < 3) {
                if (g_stCtrl.bKernelMsg & DEBUG_DRIVER)
-                       dev_info(&g_spi->dev, "Raydium - Null CMD %s : [0x%x]\n",
-                               __func__, (u32)pCmdTbl);
+                       dev_info(&g_spi->dev, "Raydium - Null CMD %s : [%p]\n",
+                               __func__, pCmdTbl);
                mutex_unlock(&lock);
                return ret;
        }
@@ -1229,7 +1232,7 @@ static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts)
                        break;
                case KRL_CMD_READ_IMG:
                        /*rm_printk("Raydium - KRL_CMD_READ_IMG "
-                       "- 0x%x:0x%x:%d\n",
+                       "- 0x%x:%p:%d\n",
                        pCmdTbl[_ADDR],
                        g_pu8BurstReadBuf,
                        g_stCtrl.u16DataLength);*/
@@ -1249,8 +1252,11 @@ static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts)
                        /*rm_printk("Raydium - KRL_CMD_WRITE_W_COUNT "
                        "- 0x%x: 0x%x..0x%x\n", pCmdTbl[_ADDR], u8reg,
                        ts->bRepeatCounter);*/
-                       ret = rm_tch_spi_byte_write(pCmdTbl[_ADDR],
+                       if (ts)
+                               ret = rm_tch_spi_byte_write(pCmdTbl[_ADDR],
                                                u8reg | (ts->bRepeatCounter));
+                       else
+                               ret = FAIL;
                        break;
                case KRL_CMD_RETURN_RESULT:
                        g_stTs.u16ReadPara = u8reg;
@@ -1269,9 +1275,9 @@ static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts)
                //      break;
 
                if (ret == FAIL) {
-                       dev_err(&g_spi->dev, "Raydium - %s : [0x%x] cmd failed\n",
+                       dev_err(&g_spi->dev, "Raydium - %s : [%p] cmd failed\n",
                                __func__,
-                               (u32)pCmdTbl);
+                               pCmdTbl);
                        dev_err(&g_spi->dev, "Raydium - cmd:0x%x, addr:0x%x, data:0x%x\n",
                                pCmdTbl[_CMD],
                                pCmdTbl[_ADDR],
@@ -1337,7 +1343,7 @@ int rm_set_kernel_tbl(int iFuncIdx, u8 *u8pSrc)
                break;
 
        default:
-               dev_err(&g_spi->dev, "Raydium - %s : no kernel table - err:%d\n",
+               dev_err(&g_spi->dev, "Raydium - %s : no such kernel table - err:%d\n",
                        __func__, iFuncIdx);
                return FAIL;
        }
@@ -1366,8 +1372,8 @@ int rm_set_kernel_tbl(int iFuncIdx, u8 *u8pSrc)
                return FAIL;
        }
 
-       /*dev_info(&g_spi->dev, "Raydium - %s : CMD_TAB_%d[0x%x]\n",
-       __func__, iFuncIdx, (u32)u8pDst);*/
+       /*dev_info(&g_spi->dev, "Raydium - %s : CMD_TAB_%d[%p]\n",
+       __func__, iFuncIdx, u8pDst);*/
 
        kfree(u8pLen);
        return OK;
@@ -1927,50 +1933,36 @@ static ssize_t rm_tch_slowscan_handler(const char *buf, size_t count)
        unsigned long val;
        ssize_t error;
        ssize_t ret;
-       u8 *pMyBuf;
-       ssize_t missing;
 
        if (count < 2)
-               return count;
+               return -EINVAL;
 
        ret = (ssize_t) count;
 
-       pMyBuf = kmalloc(count, GFP_KERNEL);
-       if (pMyBuf == NULL)
-               return -ENOMEM;
-
-       missing = copy_from_user(pMyBuf, buf, count);
-       if (missing) {
-               dev_err(&g_spi->dev, "Raydium - %s : copy failed - len:%d, miss:%d\n",
-                       __func__, count, missing);
-               return count;
-       }
-
        mutex_lock(&g_stTs.mutex_scan_mode);
 
        if (count == 2) {
-               if (pMyBuf[0] == '0') {
+               if (buf[0] == '0') {
                        g_stTs.bEnableSlowScan = false;
                        rm_tch_ctrl_slowscan(RM_SLOW_SCAN_LEVEL_MAX);
-               } else if (pMyBuf[0] == '1') {
+               } else if (buf[0] == '1') {
                        g_stTs.bEnableSlowScan = true;
                        rm_tch_ctrl_slowscan(RM_SLOW_SCAN_LEVEL_60);
                        g_stTs.u32SlowScanLevel = RM_SLOW_SCAN_LEVEL_60;
                }
-       } else if ((pMyBuf[0] == '2') && (pMyBuf[1] == ' ')) {
-               error = kstrtoul(&pMyBuf[2], 10, &val);
+       } else if ((buf[0] == '2') && (buf[1] == ' ')) {
+               error = kstrtoul(&buf[2], 10, &val);
 
                if (error) {
                        ret = error;
                } else {
                        g_stTs.bEnableSlowScan = true;
-                       g_stTs.u32SlowScanLevel = rm_tch_slowscan_round(val);
+                       g_stTs.u32SlowScanLevel = rm_tch_slowscan_round((u32)val);
                        rm_tch_ctrl_slowscan(g_stTs.u32SlowScanLevel);
                }
        }
 
        mutex_unlock(&g_stTs.mutex_scan_mode);
-       kfree(pMyBuf);
        return ret;
 }
 #endif
@@ -2158,9 +2150,9 @@ static void rm_tch_report_mode_change(unsigned long val)
        g_stTs.u8ReportMode = (u8)val;
 
        iInfo = (RM_SIGNAL_PARA_REPORT_MODE_CHANGE << 24) |
-                       (val << 16) |
+                       (g_stTs.u8ReportMode << 16) |
                        RM_SIGNAL_REPORT_MODE_CHANGE;
+
        rm_tch_ts_send_signal(g_stTs.ulHalPID, iInfo);
 }
 
@@ -2683,7 +2675,7 @@ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq,
                goto err_out;
        }
 
-       ts = kzalloc(sizeof(*ts), GFP_KERNEL);
+       ts = kzalloc(sizeof(struct rm_tch_ts), GFP_KERNEL);
 
        input_dev = input_allocate_device();
 
index 2b7161e..b780d31 100644 (file)
@@ -44,8 +44,8 @@
 #define RM_VARIABLE_TEST_VERSION                               0x08
 #define RM_VARIABLE_SET_SPI_UNLOCK                             0x09
 #define RM_VARIABLE_SET_WAKE_UNLOCK                            0x0A
-#define RM_VARIABLE_DPW                                                0x0B
-#define RM_VARIABLE_NS_MODE                                    0x0C
+#define RM_VARIABLE_DPW                                                        0x0B
+#define RM_VARIABLE_NS_MODE                                            0x0C
 #define RM_IOCTL_GET_VARIABLE                          0x1011
 #define RM_VARIABLE_PLATFORM_ID                                        0x01
 #define RM_VARIABLE_GPIO_SELECT                                        0x02
  *     DO NOT MODIFY
  *     NOTE: Need to sync with HAL
  ***************************************************************************/
-#define INPUT_POINT_RESET 0x80
-#define MAX_REPORT_TOUCHED_POINTS 10
+#define INPUT_POINT_RESET      0x80
+#define MAX_REPORT_TOUCHED_POINTS      10
 
 #define POINT_TYPE_NONE                        0x00
 #define POINT_TYPE_STYLUS              0x01