static int __pmic8058_kp_scan_matrix(struct pmic8058_kp *kp, u16 *new_state, u16 *old_state) { int row, col, code; for (row = 0; row < kp->pdata->num_rows; row++) { int bits_changed = new_state[row] ^ old_state[row]; if (!bits_changed) continue; for (col = 0; col < kp->pdata->num_cols; col++) { if (!(bits_changed & (1 << col))) continue; dev_dbg(kp->dev, "key [%d:%d] %s\n", row, col, !(new_state[row] & (1 << col)) ? "pressed" : "released"); code = MATRIX_SCAN_CODE(row, col, PM8058_ROW_SHIFT); input_event(kp->input, EV_MSC, MSC_SCAN, code); input_report_key(kp->input, kp->keycodes[code], !(new_state[row] & (1 << col))); input_sync(kp->input); #if defined (CONFIG_TARGET_LOCALE_USA) pr_info("key [%d:%d] %s\n", row, col, !(new_state[row] & (1 << col)) ? "pressed" : "released"); #else pr_info("key [%d:%d] %s keycode [%d]\n", row, col, !(new_state[row] & (1 << col)) ? "pressed" : "released", kp->keycodes[code]); #endif #if defined (CONFIG_TOUCHSCREEN_MELFAS) #if defined (CONFIG_KOR_MODEL_SHV_E120L) || defined (CONFIG_KOR_MODEL_SHV_E120S) || defined (CONFIG_KOR_MODEL_SHV_E120K) || defined(CONFIG_KOR_MODEL_SHV_E160S) || defined(CONFIG_KOR_MODEL_SHV_E160K) || defined(CONFIG_KOR_MODEL_SHV_E160L) if(!(new_state[row] & (1 << col)) && (kp->keycodes[code] == KEY_HOME)){ TSP_force_released(); } #endif #endif #if defined(CONFIG_SEC_DEBUG) sec_debug_check_crash_key(kp->keycodes[code], !(new_state[row] & (1 << col))); #endif } } return 0; }
static int melfas_fb_notifier_callback(struct notifier_block *self, unsigned long event, void *fb_evdata) { struct melfas_ts_data *data; struct fb_event *evdata = fb_evdata; int blank; /* If we aren't interested in this event, skip it immediately ... */ if (event != FB_EVENT_BLANK) return 0; data = container_of(self, struct melfas_ts_data, fb_notif); blank = *(int *)evdata->data; switch (blank) { case FB_BLANK_UNBLANK: if (tsp_enabled == 0) { data->power(true); enable_irq(data->client->irq); tsp_enabled = 1; } else { pr_err("[TSP] touchscreen already on\n"); } break; case FB_BLANK_POWERDOWN: TSP_force_released(); if (tsp_enabled == 1) { disable_irq(data->client->irq); data->power(false); tsp_enabled = 0; } else { pr_err("[TSP] touchscreen already off\n"); } break; default: break; } return 0; }
static void melfas_ts_get_data(struct work_struct *work) { struct melfas_ts_data *ts = container_of(work, struct melfas_ts_data, work); int ret = 0, i; int _touch_is_pressed; u8 read_num = 0, FingerID = 0; u8 buf[TS_READ_REGS_LEN]; int pre_status = 0; ret = melfas_i2c_read(ts->client, TS_READ_START_ADDR, 1, &read_num); if (ret < 0) { pr_err("%s: i2c failed(%d)\n", __func__, __LINE__); return ; } if (read_num > 0) { ret = melfas_i2c_read(ts->client, TS_READ_START_ADDR2, read_num, buf); if (ret < 0) { pr_err("%s: i2c failed(%d)\n", \ __func__, __LINE__); return ; } switch (buf[0]) { case TSP_STATUS_ESD: printk(KERN_DEBUG "[TSP] ESD protection.\n"); disable_irq_nosync(ts->client->irq); ts->power(0); TSP_force_released(); mdelay(200); ts->power(1); mdelay(200); enable_irq(ts->client->irq); return ; default: break; } if (read_num % 8 != 0) { pr_err("[TSP] incorrect read_num %d\n", read_num); read_num = (read_num / 8) * 8; } for (i = 0; i < read_num; i = i + 8) { FingerID = (buf[i] & 0x0F) - 1; g_Mtouch_info[FingerID].posX = (uint16_t) (buf[i + 1] & 0x0F) << 8 | buf[i + 2]; g_Mtouch_info[FingerID].posY = (uint16_t) (buf[i + 1] & 0xF0) << 4 | buf[i + 3]; #if !defined(CONFIG_MACH_C1) && !defined(CONFIG_MACH_C1VZW) && \ !defined(CONFIG_MACH_M0) && \ !defined(CONFIG_MACH_SLP_PQ) && \ !defined(CONFIG_MACH_SLP_PQ_LTE) && \ !defined(CONFIG_MACH_M3) g_Mtouch_info[FingerID].posX = 720 - g_Mtouch_info[FingerID].posX; g_Mtouch_info[FingerID].posY = 1280 - g_Mtouch_info[FingerID].posY; #endif g_Mtouch_info[FingerID].width = buf[i + 4]; g_Mtouch_info[FingerID].angle = (buf[i + 5] >= 127) ? (-(256 - buf[i + 5])) : buf[i + 5]; g_Mtouch_info[FingerID].major = buf[i + 6]; g_Mtouch_info[FingerID].minor = buf[i + 7]; g_Mtouch_info[FingerID].palm = (buf[i] & 0x10) >> 4; pre_status = g_Mtouch_info[FingerID].status; if ((buf[i] & 0x80) == 0) { g_Mtouch_info[FingerID].strength = 0; g_Mtouch_info[FingerID].status = TSP_STATE_RELEASE; } else { g_Mtouch_info[FingerID].strength = buf[i + 4]; if (TSP_STATE_PRESS == \ g_Mtouch_info[FingerID].status) g_Mtouch_info[FingerID].status = TSP_STATE_MOVE; else g_Mtouch_info[FingerID].status = TSP_STATE_PRESS; } /*g_Mtouch_info[FingerID].width = buf[i + 5];*/ } }