static void tpd_resume(struct early_suspend *h) { if ( g_pts ){ CTP_DBG("TPD wake up\n"); if (atomic_read(&g_pts->isp_opened)){ CTP_DBG("isp is already opened."); return; } #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP fts_5x06_hw_init(); #else //!CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mt_set_gpio_mode(GPIO_CTP_WAKE_PIN, GPIO_CTP_WAKE_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_WAKE_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_WAKE_PIN, GPIO_OUT_ZERO); msleep(1); mt_set_gpio_mode(GPIO_CTP_WAKE_PIN, GPIO_CTP_WAKE_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_WAKE_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_WAKE_PIN, GPIO_OUT_ONE); #endif//CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mutex_unlock(&g_pts->mutex);//Lock on suspend mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); atomic_set( &g_pts->ts_sleepState, 0 ); //LINE<JIRA_ID><DATE20130320><add charger flag>zenghaihui g_need_refresh_tp_flag = 1; } }
static int tpd_up(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { CTP_DBG("x=%03d, y=%03d, ID=%03d", x, y, trackID); input_report_abs(tpd->dev, ABS_PRESSURE, 0); input_report_abs(tpd->dev, ABS_MT_PRESSURE, 0); input_report_key(tpd->dev, BTN_TOUCH, 0); input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); #ifdef FTS_SUPPORT_TRACK_ID input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); #endif input_report_abs(tpd->dev, ABS_MT_WIDTH_MAJOR, 0); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 0);// This must be placed at the last one. input_mt_sync(tpd->dev); }else{//Android 4.0 don't need to report these up events. int i, have_down_cnt = 0; for ( i=0; i < TINNO_TOUCH_TRACK_IDS; i++ ){ if ( test_bit(i, &ts->fingers_flag) ){ ++have_down_cnt; } } if ( have_down_cnt < 2 ){ input_mt_sync(tpd->dev); } CTP_DBG("x=%03d, y=%03d, ID=%03d, have_down=%d", x, y, trackID, have_down_cnt); } __clear_bit(trackID, &ts->fingers_flag); TPD_UP_DEBUG_TRACK(x,y); if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 0); } return 0; }
static int tpd_up(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { CTP_DBG("x=%03d, y=%03d, ID=%03d", x, y, trackID); input_report_abs(tpd->dev, ABS_PRESSURE, 0); input_report_abs(tpd->dev, ABS_MT_PRESSURE, 0); input_report_key(tpd->dev, BTN_TOUCH, 0); input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); #ifdef FTS_SUPPORT_TRACK_ID input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); #endif input_report_abs(tpd->dev, ABS_MT_WIDTH_MAJOR, 0); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 0);// This must be placed at the last one. input_mt_sync(tpd->dev); }else{//Android 4.0 don't need to report these up events. int i, have_down_cnt = 0; for ( i=0; i < TINNO_TOUCH_TRACK_IDS; i++ ){ if ( test_bit(i, &ts->fingers_flag) ){ ++have_down_cnt; } } if ( have_down_cnt < 2 ){ input_mt_sync(tpd->dev); } CTP_DBG("x=%03d, y=%03d, ID=%03d, have_down=%d", x, y, trackID, have_down_cnt); } __clear_bit(trackID, &ts->fingers_flag); #ifdef CONFIG_TOUCHSCREEN_SWEEP2WAKE s2w_st_flag = 0; if (sweep2wake > 0) { //printk("[sweep2wake]:line : %d | func : %s\n", __LINE__, __func__); //printk("[SWEEP2WAKE]: resetin s2w param\n"); //printk("[sweep2wake]:line : %d | func : %s\n", __LINE__, __func__); exec_count = true; barrier[0] = false; barrier[1] = false; scr_on_touch = false; tripoff = 0; tripon = 0; triptime = 0; } if (doubletap2wake && scr_suspended) { printk("[SWEEP2WAKE]: detecting d2w\n"); doubletap2wake_func(x, y, jiffies); } #endif TPD_UP_DEBUG_TRACK(x,y); if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 0); } return 0; }
static void tpd_resume(struct early_suspend *h) { char data; #ifdef TPD_PROXIMITY if (tpd_proximity_flag == 1) { if(tpd_proximity_flag_one == 1) { tpd_proximity_flag_one = 0; TPD_DMESG(TPD_DEVICE " tpd_proximity_flag_one \n"); return; } } #endif if ( g_pts ){ CTP_DBG("TPD wake up\n"); if (atomic_read(&g_pts->isp_opened)){ CTP_DBG("isp is already opened."); return; } #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP fts_6x06_hw_init(); #else //!CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP //BEGIN <JIRA ID (KeyCode)> <DATE> <BUG INFO> zhangxiaofei //mt_set_gpio_mode(GPIO_CTP_WAKE_PIN, GPIO_CTP_WAKE_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_CTP_WAKE_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_CTP_WAKE_PIN, GPIO_OUT_ZERO); //msleep(1); //mt_set_gpio_mode(GPIO_CTP_WAKE_PIN, GPIO_CTP_WAKE_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_CTP_WAKE_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_CTP_WAKE_PIN, GPIO_OUT_ONE); //END <JIRA ID (KeyCode)> <DATE> <BUG INFO> zhangxiaofei //BEGIN <tp> <DATE20130507> <tp resume> zhangxiaofei // reset ctp mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO); msleep(10); mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE); msleep(200);//add this line CTP_DBG("TPD wake up done\n"); //END <tp> <DATE20130507> <tp resume> zhangxiaofei #endif//CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mutex_unlock(&g_pts->mutex);//Lock on suspend mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); atomic_set( &g_pts->ts_sleepState, 0 ); } }
static void tp_delay_process(struct work_struct *work) { struct keystorevalue key; CTP_DBG("tp_delay_process!\r\n"); while(!tp_buf_get(&key)){ CTP_DBG("key code=%d,value=%d!\r\n",key.code,key.value); input_report_key( tp_keystore->dev, key.code, key.value); input_sync(tp_keystore->dev); msleep(100); } }
static int update_firmware_thread(void *priv) { CTP_DBG("current touchpanl is: %s \n", tpd_desc); //fts_ctpm_fw_upgrade_with_i_file(); if( 0 == memcmp(tpd_desc, "HUARUICHUANG", 12)) { ft6x06_tp_upgrade(ftbin_HRC, sizeof(ftbin_HRC)); }else if(0 == memcmp(tpd_desc, "YEJI",4)) { ft6x06_tp_upgrade(ftbin_YEJI, sizeof(ftbin_YEJI)); }else if(0 == memcmp(tpd_desc, "JIEMIAN",7)) { ft6x06_tp_upgrade(ftbin_JIEMIAN, sizeof(ftbin_JIEMIAN)); } else if(0 == memcmp(tpd_desc, "DIJING",6)) { ft6x06_tp_upgrade(ftbin_DIJING, sizeof(ftbin_DIJING)); } // only for s5300 wrong firmware, force to upgrade #if defined(PROJECT_S5300AP) else if(0 == memcmp(tpd_desc, "DEFAULT",7)) { ft6x06_tp_upgrade(ftbin_DIJING, sizeof(ftbin_DIJING)); } #endif kthread_should_stop(); return NULL; }
static int tp_buf_put(int keycode,int keyvalue) { int ret=0; CTP_DBG("head=%d,tail=%d!\r\n",tp_keystore->head,tp_keystore->tail); mutex_lock(&tp_keystore->tp_key_mutex); if(!Is_tp_buf_full){ tp_keystore->value[tp_keystore->head].code=keycode; tp_keystore->value[tp_keystore->head].value=keyvalue; tp_keystore->head=(tp_keystore->head+1)%KEY_STORE_MAX; } else ret=-1; mutex_unlock(&tp_keystore->tp_key_mutex); CTP_DBG("1 head=%d,tail=%d!\r\n",tp_keystore->head,tp_keystore->tail); return ret; }
static void tpd_dump_touchinfo(tinno_ts_data *ts) { uint8_t *pdata = ts->buffer; CTP_DBG("0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x" , pdata[0], pdata[1], pdata[2], pdata[3], pdata[4], pdata[5], pdata[6], pdata[7], pdata[8], pdata[9], pdata[10], pdata[11], pdata[12], pdata[13], pdata[15], pdata[15], pdata[16], pdata[17], pdata[18], pdata[19], pdata[20], pdata[21], pdata[22], pdata[23], pdata[24], pdata[25], pdata[26], pdata[27], pdata[28], pdata[29], pdata[30], pdata[31], pdata[32], pdata[33], pdata[34], pdata[35], pdata[36], pdata[37], pdata[38], pdata[39], pdata[40], pdata[41], pdata[42], pdata[43], pdata[44], pdata[45], pdata[46], pdata[47], pdata[48], pdata[49], pdata[50], pdata[51], pdata[52], pdata[53], pdata[54], pdata[55], pdata[56], pdata[57], pdata[58], pdata[59], pdata[60]); }
static int tp_key_exit(void) { CTP_DBG(); fts_6x06_key_cancel(); if (tp_keystore->tp_key_wq) destroy_workqueue(tp_keystore->tp_key_wq); kfree(tp_keystore); return 0; }
static int __devexit tpd_remove(struct i2c_client *client) { CTP_DBG("TPD removed\n"); //LINE<tp><DATE20130619><add for focaltech debug>zhangxiaofei #ifdef FTS_CTL_IIC ft_rw_iic_drv_exit(); #endif return 0; }
int focaltech_auto_upgrade(void) { int err; focaltech_update_thread = kthread_run(update_firmware_thread, 0, TPD_DEVICE); if (IS_ERR(focaltech_update_thread)) { err = PTR_ERR(focaltech_update_thread); CTP_DBG(TPD_DEVICE " failed to create update_firmware_thread thread: %d\n", err); } return err; }
int fts_6x06_key_cancel(void) { CTP_DBG(); tp_buf_clear(); if(tp_keystore->tp_key_init_flag){ del_timer(&tp_keystore->tp_key_delay_timer); cancel_work_sync(&tp_keystore->tp_queue); } return 0; }
static int __devexit tpd_remove(struct i2c_client *client) { CTP_DBG("TPD removed\n"); //LINE<JIRA_ID><DATE20130402><add for focaltech debug>zenghaihui #ifdef FTS_CTL_IIC ft_rw_iic_drv_exit(); #endif return 0; }
static void tpd_resume(struct early_suspend *h) { #ifdef CONFIG_TOUCHSCREEN_SWEEP2WAKE printk("[SWEEP2WAKE]: resume\n"); scr_suspended = false; if ((sweep2wake == 0 || sweep2wake == 3) && doubletap2wake == 0) { #endif if ( g_pts ){ CTP_DBG("TPD wake up\n"); if (atomic_read(&g_pts->isp_opened)){ CTP_DBG("isp is already opened."); return; } #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP fts_5x06_hw_init(); #else //!CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mt_set_gpio_mode(GPIO_CTP_WAKE_PIN, GPIO_CTP_WAKE_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_WAKE_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_WAKE_PIN, GPIO_OUT_ZERO); msleep(1); mt_set_gpio_mode(GPIO_CTP_WAKE_PIN, GPIO_CTP_WAKE_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_WAKE_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_WAKE_PIN, GPIO_OUT_ONE); #endif//CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mutex_unlock(&g_pts->mutex);//Lock on suspend mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); atomic_set( &g_pts->ts_sleepState, 0 ); } #ifdef CONFIG_TOUCHSCREEN_SWEEP2WAKE } else if ((sweep2wake > 0 && sweep2wake < 3) || doubletap2wake > 0) mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); #endif }
static int tp_key_handle(int keycode,int keyvalue) { int ret =0; if(Is_tp_buf_empty){ CTP_DBG("tp mod_timer!\r\n"); mod_timer(&tp_keystore->tp_key_delay_timer,jiffies + HZ/5); } tp_buf_put(keycode,keyvalue); return ret; }
static void tpd_dump_touchinfo(tinno_ts_data *ts) { uint8_t *pdata = ts->buffer; CTP_DBG("0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" " 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" , pdata[0], pdata[1], pdata[2], pdata[3], pdata[4], pdata[5], pdata[6], pdata[7], pdata[8], pdata[9], pdata[10], pdata[11], pdata[12], pdata[13], pdata[15], pdata[15], pdata[16], pdata[17], pdata[18], pdata[19], pdata[20], pdata[21], pdata[22], pdata[23], pdata[24], pdata[25], pdata[26]); }
static int tpd_up(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { CTP_DBG("x=%03d, y=%03d, ID=%03d", x, y, trackID); //input_report_abs(tpd->dev, ABS_PRESSURE, 0); input_report_key(tpd->dev, BTN_TOUCH, 0); //input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 0); //input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); //input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); //input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); input_mt_sync(tpd->dev); //TPD_UP_DEBUG_TRACK(x,y); if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 0); } return 0; }
static void tpd_down(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { CTP_DBG("x=%03d, y=%03d, pressure=%03d, ID=%03d", x, y, pressure, trackID); input_report_key(tpd->dev, BTN_TOUCH, 1); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 20); input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); input_mt_sync(tpd->dev); if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 1); } //TPD_DOWN_DEBUG_TRACK(x,y); }
static void tpd_down(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { CTP_DBG("x=%03d, y=%03d, pressure=%03d, ID=%03d", x, y, pressure, trackID); input_report_abs(tpd->dev, ABS_PRESSURE, pressure); input_report_abs(tpd->dev, ABS_MT_PRESSURE, pressure); input_report_key(tpd->dev, BTN_TOUCH, 1); input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); #ifdef FTS_SUPPORT_TRACK_ID input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); #endif input_report_abs(tpd->dev, ABS_MT_WIDTH_MAJOR, pressure*pressure/112); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, pressure*pressure/112); input_mt_sync(tpd->dev); __set_bit(trackID, &ts->fingers_flag); ts->touch_point_pre[trackID].x=x; ts->touch_point_pre[trackID].y=y; if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 1); } TPD_DOWN_DEBUG_TRACK(x,y); }
static void tpd_down(tinno_ts_data *ts, int x, int y, int pressure, int trackID) { int iPressure = pressure*pressure/110; if ( iPressure < 1 ){ iPressure = 1; } CTP_DBG("x=%03d, y=%03d, pressure=%03d, ID=%03d", x, y, pressure, trackID); input_report_abs(tpd->dev, ABS_PRESSURE, iPressure); input_report_abs(tpd->dev, ABS_MT_PRESSURE, iPressure); input_report_key(tpd->dev, BTN_TOUCH, 1); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, 20); input_report_abs(tpd->dev, ABS_MT_POSITION_X, x); input_report_abs(tpd->dev, ABS_MT_POSITION_Y, y); printk("[SWEEP2WAKE]: tpd down\n"); #ifdef CONFIG_TOUCHSCREEN_SWEEP2WAKE if (sweep2wake) { //printk("[SWEEP2WAKE]: detecting sweep\n"); detect_sweep2wake(x, y, jiffies, trackID); } #endif #ifdef FTS_SUPPORT_TRACK_ID input_report_abs(tpd->dev, ABS_MT_TRACKING_ID, trackID); #endif input_report_abs(tpd->dev, ABS_MT_WIDTH_MAJOR, iPressure); input_report_abs(tpd->dev, ABS_MT_TOUCH_MAJOR, iPressure); input_mt_sync(tpd->dev); __set_bit(trackID, &ts->fingers_flag); ts->touch_point_pre[trackID].x=x; ts->touch_point_pre[trackID].y=y; if (FACTORY_BOOT == get_boot_mode() || RECOVERY_BOOT == get_boot_mode()) { tpd_button(x, y, 1); } TPD_DOWN_DEBUG_TRACK(x,y); }
static void tpd_suspend(struct early_suspend *h) { int ret = 0; int iRetry = 5; const char data = 0x3; //release all touch points input_report_key(tpd->dev, BTN_TOUCH, 0); input_mt_sync(tpd->dev); input_sync(tpd->dev); //NEGIN <touch panel> <DATE20130831> <tp proximity> zhangxiaofei #ifdef TPD_PROXIMITY if (tpd_proximity_flag == 1) { tpd_proximity_flag_one = 1; return; } #endif //END <touch panel> <DATE20130831> <tp proximity> zhangxiaofei if ( g_pts ){ CTP_DBG("TPD enter sleep\n"); if (atomic_read(&g_pts->isp_opened)){ CTP_DBG("isp is already opened."); return; } mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); //mutex_lock(&g_pts->mutex);//Unlock on resume mutex_trylock(&g_pts->mutex);//Unlock on resume #ifdef CONFIG_TOUCHSCREEN_FT5X05_DISABLE_KEY_WHEN_SLIDE fts_6x06_key_cancel(); #endif #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO); msleep(2); #ifdef MT6577 hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); #else hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); #endif #else //!CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP //make sure the WakeUp is high before it enter sleep mode, //otherwise the touch can't be resumed. //mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ONE); //msleep(1); while (iRetry) { ret = i2c_smbus_write_i2c_block_data(g_pts->client, 0xA5, 1, &data); //TP enter sleep mode if ( ret < 0 ){ TPD_DMESG("Enter sleep mode is %d\n", ret); #ifdef MT6577 hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); #else //hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); //mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ZERO); #endif msleep(2); fts_6x06_hw_init(); }else{ break; } iRetry--; msleep(100); } #endif//CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP #if 0//Android 4.0 don't need to report these up events. ft6x06_complete_unfinished_event(); #endif atomic_set( &g_pts->ts_sleepState, 1 ); } }
static int tpd_touchinfo(tinno_ts_data *ts, tinno_ts_point *touch_point) { int i = 0; int iInvalidTrackIDs = 0; int iTouchID, iSearchDeep; fts_report_data_t *pReportData = (fts_report_data_t *)ts->buffer; int ret; uint8_t start_reg = 0x00; #if 1 if ( tpd_read_touchinfo(ts) ){ CTP_DBG("Read touch information error. \n"); return -EAGAIN; } #else memset((void *)ts->buffer, FTS_INVALID_DATA, FTS_PROTOCOL_LEN); mutex_lock(&g_pts->mutex); start_reg = 0x02; ret = i2c_master_send(ts->client, &start_reg,1); ret = i2c_master_recv(ts->client, &ts->buffer[2], 5); if (ts->buffer[2] > 1) { start_reg = 9; ret = i2c_master_send(ts->client,&start_reg,1); ret = i2c_master_recv(ts->client, &ts->buffer[9], 4); } //edit by Magnum 2012-8-6 if (ts->buffer[9] > 1) { start_reg = 0x0f; ret = i2c_master_send(ts->client,&start_reg,1); ret = i2c_master_recv(ts->client, &ts->buffer[15], 4); } if (ts->buffer[15] > 1) { start_reg = 0x15; ret = i2c_master_send(ts->client,&start_reg,1); ret = i2c_master_recv(ts->client, &ts->buffer[21], 4); } if (ts->buffer[21] > 1) { start_reg = 0x1b; ret = i2c_master_send(ts->client,&start_reg,1); ret = i2c_master_recv(ts->client, &ts->buffer[27], 4); } // ret = i2c_master_recv(i2c_client, &buffer[0],8 ); //ret = i2c_master_recv(i2c_client, &buffer[8],8 ); //ret = i2c_master_recv(i2c_client, &buffer[16],8 ); //ret = i2c_master_recv(i2c_client, &buffer[24],8 ); //ret = i2c_master_recv(i2c_client, &buffer[32],1 ); mutex_unlock(&g_pts->mutex); if (ret < 0) { TPD_DEBUG("i2c_transfer failed"); return 1; //Error } #endif // tpd_dump_touchinfo( ts ); if ( 0 != pReportData->device_mode ){ CTP_DBG("device mode is %d\n", pReportData->device_mode); return -EPERM; } //We need only valid points... if ( pReportData->fingers > TINNO_TOUCH_TRACK_IDS ){ CTP_DBG("fingers is %d\n", pReportData->fingers); return -EAGAIN; } // For processing gestures. if (pReportData->gesture >= 0xF0 && pReportData->gesture <= 0xF3) { //fts_5x06_parase_keys(ts, pReportData); } iSearchDeep = 0; #ifdef FTS_SUPPORT_TRACK_ID for ( i = 0; i < TINNO_TOUCH_TRACK_IDS; i++ ){ iSearchDeep += ((pReportData->xy_data[i].event_flag != FTS_EF_RESERVED)?1:0); } #else if (pReportData->fingers >= ts->last_fingers ){ iSearchDeep = pReportData->fingers; }else{ iSearchDeep = ts->last_fingers; } ts->last_fingers = pReportData->fingers; #endif if ( iSearchDeep ) { #ifdef FTS_SUPPORT_TRACK_ID for ( i=0; i < TINNO_TOUCH_TRACK_IDS; i++ ){ #else for ( i=0; i < iSearchDeep; i++ ){ #endif if (pReportData->xy_data[i].event_flag != FTS_EF_RESERVED) { #ifdef FTS_SUPPORT_TRACK_ID iTouchID = pReportData->xy_data[i].touch_id; if ( iTouchID >= TINNO_TOUCH_TRACK_IDS ) { CTP_DBG("i: Invalied Track ID(%d)\n!", i, iTouchID); iInvalidTrackIDs++; continue; } #else iTouchID = i; #endif touch_point[iTouchID].flag = pReportData->xy_data[i].event_flag; touch_point[iTouchID].x = pReportData->xy_data[i].x_h << 8 | pReportData->xy_data[i].x_l; touch_point[iTouchID].y = pReportData->xy_data[i].y_h << 8 | pReportData->xy_data[i].y_l; touch_point[iTouchID].pressure = pReportData->xy_data[i].pressure; #ifdef TPD_FIRST_FIRWARE ft_map_coordinate(&(touch_point[iTouchID].x), &(touch_point[iTouchID].y)); #endif }else{ //CTP_DBG("We got a invalied point, we take it the same as a up event!"); //CTP_DBG("As it has no valid track ID, we assume it's order is the same as it's layout in the memory!"); //touch_point[i].flag = FTS_EF_RESERVED; } } if ( TINNO_TOUCH_TRACK_IDS == iInvalidTrackIDs ){ CTP_DBG("All points are Invalied, Ignore the interrupt!\n"); return -EAGAIN; } } CTP_DBG("p0_flag=0x%x x0=0x%03x y0=0x%03x pressure0=0x%03x " "p1_flag=0x%x x1=0x%03x y1=0x%03x pressure1=0x%03x " "gesture = 0x%x fingers=0x%x", touch_point[0].flag, touch_point[0].x, touch_point[0].y, touch_point[0].pressure, touch_point[1].flag, touch_point[1].x, touch_point[1].y, touch_point[1].pressure, pReportData->gesture, pReportData->fingers); return 0; }; static int touch_event_handler(void *para) { int i; tinno_ts_point touch_point[TINNO_TOUCH_TRACK_IDS]; struct sched_param param = { .sched_priority = RTPM_PRIO_TPD }; tinno_ts_data *ts = (tinno_ts_data *)para; sched_setscheduler(current, SCHED_RR, ¶m); do { set_current_state(TASK_INTERRUPTIBLE); wait_event_interruptible(waiter, tpd_flag!=0); tpd_flag = 0; memset(touch_point, FTS_INVALID_DATA, sizeof(touch_point)); set_current_state(TASK_RUNNING); if (!tpd_touchinfo(ts, &touch_point)) { //report muti point then for ( i=0; i < TINNO_TOUCH_TRACK_IDS; i++ ){ if ( FTS_INVALID_DATA != touch_point[i].x ){ if ( FTS_EF_UP == touch_point[i].flag ){ if( test_bit(i, &ts->fingers_flag) ){ tpd_up(ts, ts->touch_point_pre[i].x, ts->touch_point_pre[i].y, touch_point[i].pressure, i); }else{ CTP_DBG("This is a invalid up event.(%d)", i); } }else{//FTS_EF_CONTACT or FTS_EF_DOWN if ( test_bit(i, &ts->fingers_flag) && (FTS_EF_DOWN == touch_point[i].flag) ){ CTP_DBG("Ignore a invalid down event.(%d)", i); continue; } tpd_down(ts, touch_point[i].x, touch_point[i].y, touch_point[i].pressure, i); } }else if ( test_bit(i, &ts->fingers_flag) ){ CTP_DBG("Complete a invalid down or move event.(%d)", i); tpd_up(ts, ts->touch_point_pre[i].x, ts->touch_point_pre[i].y, touch_point[i].pressure, i); } } input_sync(tpd->dev); } mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); }while(!kthread_should_stop()); mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); return 0; }
static int __devinit tpd_probe(struct i2c_client *client, const struct i2c_device_id *id) { int retval = TPD_OK; int panel_version = 0; int panel_vendor = 0; int iRetry = 3; tinno_ts_data *ts; int ret = 0; if ( tpd_load_status ){ CTP_DBG("Already probed a TP, needn't to probe any more!"); return -1; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(&client->dev,"need I2C_FUNC_I2C"); ret = -ENODEV; goto err_check_functionality_failed; } ts = kzalloc(sizeof(*ts), GFP_KERNEL); if (ts == NULL) { ret = -ENOMEM; goto err_alloc_data_failed; } CTP_DBG("TPD enter tpd_probe ts=0x%p, TPD_RES_X=%d, TPD_RES_Y=%d, addr=0x%x\n", ts, TPD_RES_X, TPD_RES_Y, client->addr); memset(ts, 0, sizeof(*ts)); g_pts = ts; client->timing = I2C_MASTER_CLOCK; ts->client = client; ts->start_reg = 0x00; atomic_set( &ts->ts_sleepState, 0 ); mutex_init(&ts->mutex); i2c_set_clientdata(client, ts); fts_6x06_hw_init(); msleep(120); fts_iic_init(ts); if ( fts_6x06_isp_init(ts) ){ goto err_isp_register; } while (iRetry) { ret = ft6x06_get_vendor_version(ts, &panel_vendor, &panel_version); if ( panel_version < 0 || panel_vendor<0 || ret<0 ){ CTP_DBG("Product version is %d\n", panel_version); fts_6x06_hw_reset(); }else{ break; } iRetry--; msleep(15); } if ( panel_version < 0 || panel_vendor<0 || ret<0 ){ goto err_get_version; } #ifdef TPD_HAVE_BUTTON tinno_update_tp_button_dim(panel_vendor); #endif #ifdef CONFIG_TOUCHSCREEN_FT5X05_DISABLE_KEY_WHEN_SLIDE if ( fts_keys_init(ts) ){ fts_keys_deinit(); goto err_get_version; } #endif mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT); mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP); //mt65xx_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE); //mt65xx_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN); //mt65xx_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_EN, CUST_EINT_TOUCH_PANEL_POLARITY, tpd_eint_interrupt_handler, 0); mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, tpd_eint_interrupt_handler, 1); ts->thread = kthread_run(touch_event_handler, ts, TPD_DEVICE); if (IS_ERR(ts->thread)){ retval = PTR_ERR(ts->thread); TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", retval); goto err_start_touch_kthread; } tpd_load_status = 1; mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); CTP_DBG("Touch Panel Device(%s) Probe PASS\n", fts_get_vendor_name(panel_vendor)); //BEGIN <tp> <DATE20130507> <tp version> zhangxiaofei { extern char tpd_desc[50]; extern int tpd_fw_version; sprintf(tpd_desc, "%s", fts_get_vendor_name(panel_vendor)); tpd_fw_version = panel_version; } //END <tp> <DATE20130507> <tp version> zhangxiaofei //LINE<tp><DATE20130619><add for focaltech debug>zhangxiaofei #ifdef FTS_CTL_IIC if (ft_rw_iic_drv_init(client) < 0) dev_err(&client->dev, "%s:[FTS] create fts control iic driver failed\n", __func__); #endif //BEGIN <touch panel> <DATE20130831> <tp proximity> zhangxiaofei #if defined TPD_PROXIMITY struct hwmsen_object obj_ps; int err=0; obj_ps.polling = 0;//interrupt mode obj_ps.sensor_operate = tpd_ps_operate; if((err = hwmsen_attach(ID_PROXIMITY, &obj_ps))) { APS_ERR("proxi_fts attach fail = %d\n", err); } else { APS_ERR("proxi_fts attach ok = %d\n", err); } #endif //END <touch panel> <DATE20130831> <tp proximity> zhangxiaofei //BEGIN<touch panel><date20131028><tp auto update>yinhuiyong #if defined(FTS_AUTO_TP_UPGRADE) focaltech_auto_upgrade(); #endif //END<touch panel><date20131028><tp auto update>yinhuiyong return 0; err_start_touch_kthread: mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); err_get_version: err_isp_register: #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); #endif fts_6x06_isp_exit(); mutex_destroy(&ts->mutex); g_pts = NULL; kfree(ts); err_alloc_data_failed: err_check_functionality_failed: CTP_DBG("Touch Panel Device Probe FAIL\n"); return -1; }
static int __devinit tpd_probe(struct i2c_client *client, const struct i2c_device_id *id) { int retval = TPD_OK; int panel_version = 0; int panel_vendor = 0; int iRetry = 3; tinno_ts_data *ts; int ret = 0; if ( tpd_load_status ){ CTP_DBG("Already probed a TP, needn't to probe any more!"); return -1; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(&client->dev,"need I2C_FUNC_I2C"); ret = -ENODEV; goto err_check_functionality_failed; } ts = kzalloc(sizeof(*ts), GFP_KERNEL); if (ts == NULL) { ret = -ENOMEM; goto err_alloc_data_failed; } CTP_DBG("TPD enter tpd_probe ts=0x%p, TPD_RES_X=%d, TPD_RES_Y=%d, addr=0x%x\n", ts, TPD_RES_X, TPD_RES_Y, client->addr); memset(ts, 0, sizeof(*ts)); g_pts = ts; client->timing = I2C_MASTER_CLOCK; ts->client = client; ts->start_reg = 0x00; atomic_set( &ts->ts_sleepState, 0 ); mutex_init(&ts->mutex); i2c_set_clientdata(client, ts); fts_5x06_hw_init(); msleep(120); fts_iic_init(ts); if ( fts_5x06_isp_init(ts) ){ goto err_isp_register; } while (iRetry) { ret = ft5x06_get_vendor_version(ts, &panel_vendor, &panel_version); if ( panel_version < 0 || panel_vendor<0 || ret<0 ){ TPD_DMESG("Product version is %d\n", panel_version); fts_5x06_hw_reset(); }else{ break; } iRetry--; msleep(15); } if ( panel_version < 0 || panel_vendor<0 || ret<0 ){ goto err_get_version; } #ifdef TPD_HAVE_BUTTON tinno_update_tp_button_dim(panel_vendor); #endif #ifdef CONFIG_TOUCHSCREEN_FT5X05_DISABLE_KEY_WHEN_SLIDE if ( fts_keys_init(ts) ){ fts_keys_deinit(); goto err_get_version; } #endif mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT); mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP); mt_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE); mt_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN); mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, tpd_eint_interrupt_handler, 0); ts->thread = kthread_run(touch_event_handler, ts, TPD_DEVICE); if (IS_ERR(ts->thread)){ retval = PTR_ERR(ts->thread); TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", retval); goto err_start_touch_kthread; } tpd_load_status = 1; mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); CTP_DBG("Touch Panel Device(%s) Probe PASS\n", fts_get_vendor_name(panel_vendor)); #if defined (TINNO_ANDROID_S9091) || defined (TINNO_ANDROID_S9050) { extern char tpd_desc[50]; extern int tpd_fw_version; sprintf(tpd_desc, "%s-%s(0x%X)", DRIVER_NAME, fts_get_vendor_name(panel_vendor),panel_vendor); tpd_fw_version = panel_version; } #endif return 0; err_start_touch_kthread: mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); err_get_version: err_isp_register: #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP hwPowerDown(MT65XX_POWER_LDO_VGP, "touch"); #endif fts_5x06_isp_exit(); mutex_destroy(&ts->mutex); g_pts = NULL; kfree(ts); err_alloc_data_failed: err_check_functionality_failed: CTP_DBG("Touch Panel Device Probe FAIL\n"); return -1; }
static int __devexit tpd_remove(struct i2c_client *client) { CTP_DBG("TPD removed\n"); return 0; }
static int touch_event_handler(void *para) { int i; tinno_ts_point touch_point[TINNO_TOUCH_TRACK_IDS]; struct sched_param param = { .sched_priority = RTPM_PRIO_TPD }; tinno_ts_data *ts = (tinno_ts_data *)para; sched_setscheduler(current, SCHED_RR, ¶m); //BEGIN <touch panel> <DATE20130831> <tp proximity> zhangxiaofei #if defined TPD_PROXIMITY int err; hwm_sensor_data sensor_data; u8 proximity_status; u8 state; #endif //END <touch panel> <DATE20130831> <tp proximity> zhangxiaofei do { set_current_state(TASK_INTERRUPTIBLE); wait_event_interruptible(waiter, tpd_flag!=0); tpd_flag = 0; memset(touch_point, FTS_INVALID_DATA, sizeof(touch_point)); set_current_state(TASK_RUNNING); //BEGIN <touch panel> <DATE20130831> <tp proximity> zhangxiaofei #if defined TPD_PROXIMITY if (tpd_proximity_flag == 1) { i2c_smbus_read_i2c_block_data(g_pts->client, TPD_PROXIMITY_ENABLE_REG, 1, &state); TPD_PROXIMITY_DBG("proxi_5206 0xB0 state value is 1131 0x%02X\n", state); if(!(state&0x01)) { tpd_enable_ps(1); } i2c_smbus_read_i2c_block_data(g_pts->client, 0x01, 1, &proximity_status); TPD_PROXIMITY_DBG("proxi_5206 0x01 value is 1139 0x%02X\n", proximity_status); if (proximity_status == TPD_PROXIMITY_CLOSE_VALUE) { tpd_proximity_detect = 0; } else if(proximity_status == TPD_PROXIMITY_FARAWAY_VALUE) { tpd_proximity_detect = 1; } TPD_PROXIMITY_DBG("tpd_proximity_detect 1149 = %d\n", tpd_proximity_detect); if ((err = tpd_read_ps())) { TPD_PROXIMITY_DBG("proxi_5206 read ps data 1156: %d\n", err); } sensor_data.values[0] = tpd_get_ps_value(); sensor_data.value_divide = 1; sensor_data.status = SENSOR_STATUS_ACCURACY_MEDIUM; if ((err = hwmsen_get_interrupt_data(ID_PROXIMITY, &sensor_data))) { TPD_PROXIMITY_DBG(" proxi_5206 call hwmsen_get_interrupt_data failed= %d\n", err); } } #endif //END <touch panel> <DATE20130831> <tp proximity> zhangxiaofei //BEGIN <add changing flag> <DATE20130330> <add changing flag> zhangxiaofei if(g_tp_charger_flag != g_pre_tp_charger_flag){ g_pre_tp_charger_flag = g_tp_charger_flag; fts_ft6x06_switch_charger_status(g_tp_charger_flag); } //END <add changing flag> <DATE20130330> <add changing flag> zhangxiaofei if (!tpd_touchinfo(ts, &touch_point)) { //report muti point then for ( i=0; i < TINNO_TOUCH_TRACK_IDS; i++ ){ if ( FTS_INVALID_DATA != touch_point[i].x ){ if ( FTS_EF_UP == touch_point[i].flag ){ if( test_bit(i, &ts->fingers_flag) ){ tpd_up(ts, ts->touch_point_pre[i].x, ts->touch_point_pre[i].y, touch_point[i].pressure, i); }else{ CTP_DBG("This is a invalid up event.(%d)", i); } }else{//FTS_EF_CONTACT or FTS_EF_DOWN if ( test_bit(i, &ts->fingers_flag) && (FTS_EF_DOWN == touch_point[i].flag) ){ CTP_DBG("Ignore a invalid down event.(%d)", i); continue; } tpd_down(ts, touch_point[i].x, touch_point[i].y, touch_point[i].pressure, i); } }else if ( test_bit(i, &ts->fingers_flag) ){ CTP_DBG("Complete a invalid down or move event.(%d)", i); tpd_up(ts, ts->touch_point_pre[i].x, ts->touch_point_pre[i].y, touch_point[i].pressure, i); } } input_sync(tpd->dev); } mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); }while(!kthread_should_stop()); mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); return 0; }
static int tpd_touchinfo(tinno_ts_data *ts, tinno_ts_point *touch_point) { int i = 0; int iInvalidTrackIDs = 0; int iTouchID, iSearchDeep; fts_report_data_t *pReportData = (fts_report_data_t *)ts->buffer; if ( tpd_read_touchinfo(ts) ){ CTP_DBG("Read touch information error. \n"); return -EAGAIN; } // tpd_dump_touchinfo( ts ); if ( 0 != pReportData->device_mode ){ CTP_DBG("device mode is %d\n", pReportData->device_mode); return -EPERM; } //We need only valid points... if ( pReportData->fingers > TINNO_TOUCH_TRACK_IDS ){ CTP_DBG("fingers is %d\n", pReportData->fingers); return -EAGAIN; } // For processing gestures. if (pReportData->gesture >= 0xF0 && pReportData->gesture <= 0xF3) { //fts_6x06_parase_keys(ts, pReportData); } iSearchDeep = 0; #ifdef FTS_SUPPORT_TRACK_ID for ( i = 0; i < TINNO_TOUCH_TRACK_IDS; i++ ){ iSearchDeep += ((pReportData->xy_data[i].event_flag != FTS_EF_RESERVED)?1:0); } #else if (pReportData->fingers >= ts->last_fingers ){ iSearchDeep = pReportData->fingers; }else{ iSearchDeep = ts->last_fingers; } ts->last_fingers = pReportData->fingers; #endif if ( iSearchDeep ) { #ifdef FTS_SUPPORT_TRACK_ID for ( i=0; i < TINNO_TOUCH_TRACK_IDS; i++ ){ #else for ( i=0; i < iSearchDeep; i++ ){ #endif if (pReportData->xy_data[i].event_flag != FTS_EF_RESERVED) { #ifdef FTS_SUPPORT_TRACK_ID iTouchID = pReportData->xy_data[i].touch_id; if ( iTouchID >= TINNO_TOUCH_TRACK_IDS ) { CTP_DBG("i: Invalied Track ID(%d)\n!", i, iTouchID); iInvalidTrackIDs++; continue; } #else iTouchID = i; #endif touch_point[iTouchID].flag = pReportData->xy_data[i].event_flag; touch_point[iTouchID].x = pReportData->xy_data[i].x_h << 8 | pReportData->xy_data[i].x_l; touch_point[iTouchID].y = pReportData->xy_data[i].y_h << 8 | pReportData->xy_data[i].y_l; touch_point[iTouchID].pressure = pReportData->xy_data[i].pressure; #ifdef TPD_FIRST_FIRWARE ft_map_coordinate(&(touch_point[iTouchID].x), &(touch_point[iTouchID].y)); #endif }else{ //CTP_DBG("We got a invalied point, we take it the same as a up event!"); //CTP_DBG("As it has no valid track ID, we assume it's order is the same as it's layout in the memory!"); //touch_point[i].flag = FTS_EF_RESERVED; } } if ( TINNO_TOUCH_TRACK_IDS == iInvalidTrackIDs ){ CTP_DBG("All points are Invalied, Ignore the interrupt!\n"); return -EAGAIN; } } CTP_DBG("p0_flag=0x%x x0=0x%03x y0=0x%03x pressure0=0x%03x " "p1_flag=0x%x x1=0x%03x y1=0x%03x pressure1=0x%03x " "gesture = 0x%x fingers=0x%x", touch_point[0].flag, touch_point[0].x, touch_point[0].y, touch_point[0].pressure, touch_point[1].flag, touch_point[1].x, touch_point[1].y, touch_point[1].pressure, pReportData->gesture, pReportData->fingers); return 0; }; //BEGIN <touch panel> <DATE20130831> <tp proximity> zhangxiaofei #if defined TPD_PROXIMITY int tpd_read_ps(void) { tpd_proximity_detect; return 0; }
static void tpd_suspend(struct early_suspend *h) { int ret = 0; int iRetry = 5; const char data = 0x3; #ifdef CONFIG_TOUCHSCREEN_SWEEP2WAKE scr_suspended = true; printk("[SWEEP2WAKE]: power suspend\n"); if ((sweep2wake == 0 || sweep2wake == 3) && doubletap2wake == 0) { #endif if ( g_pts ){ CTP_DBG("TPD enter sleep\n"); if (atomic_read(&g_pts->isp_opened)){ CTP_DBG("isp is already opened."); return; } mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); mutex_lock(&g_pts->mutex);//Unlock on resume #ifdef CONFIG_TOUCHSCREEN_FT5X05_DISABLE_KEY_WHEN_SLIDE fts_5x06_key_cancel(); #endif #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO); msleep(2); #ifdef MT6577 hwPowerDown(MT65XX_POWER_LDO_VGP, "touch"); #else mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ZERO); #endif #else //!CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP //make sure the WakeUp is high before it enter sleep mode, //otherwise the touch can't be resumed. //mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ONE); //msleep(1); while (iRetry) { ret = i2c_smbus_write_i2c_block_data(g_pts->client, 0xA5, 1, &data); //TP enter sleep mode if ( ret < 0 ){ TPD_DMESG("Enter sleep mode is %d\n", ret); #ifdef MT6577 hwPowerDown(MT65XX_POWER_LDO_VGP, "touch"); #else mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ZERO); #endif msleep(2); fts_5x06_hw_init(); }else{ break; } iRetry--; msleep(100); } #endif//CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP #if 0//Android 4.0 don't need to report these up events. ft5x06_complete_unfinished_event(); #endif atomic_set( &g_pts->ts_sleepState, 1 ); } #ifdef CONFIG_TOUCHSCREEN_SWEEP2WAKE } else if ((sweep2wake > 0 && sweep2wake < 3) || doubletap2wake > 0) mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); #endif }
static ssize_t fts_bin_write_block_no_dma(uint8_t* pbt_buf, int dw_lenth) { unsigned char reg_val[3] = {0}; int i = 0, j; char buf[256] = {0}; int packet_number; int temp; int lenght; unsigned char packet_buf[FTS_PACKET_LENGTH + 6]; unsigned char bt_ecc; int ret; int bak_dw_lenth = dw_lenth; bt_ecc = 0; CTP_DBG("[FT520X]: start upgrade. \n"); dw_lenth = dw_lenth - 8; CTP_DBG("####Packet length = 0x %x\n", dw_lenth); packet_number = (dw_lenth) / FTS_PACKET_LENGTH; buf[0] = 0xbf; buf[1] = 0x00; for (j=0;j<packet_number;j++) { temp = j * FTS_PACKET_NO_DMA_LENGTH; buf[2] = (u8)(temp>>8); buf[3] = (u8)temp; lenght = FTS_PACKET_NO_DMA_LENGTH; buf[4] = (u8)(lenght>>8); buf[5] = (u8)lenght; for (i=0;i<FTS_PACKET_NO_DMA_LENGTH;i++) { buf[6+i] = pbt_buf[j*FTS_PACKET_NO_DMA_LENGTH + i]; bt_ecc ^= buf[6+i]; } mutex_lock(&g_pts->mutex); ret = i2c_master_send(g_pts->client, buf, FTS_PACKET_NO_DMA_LENGTH + 6); mdelay(5); mutex_unlock(&g_pts->mutex); if (ret < 0) { CTP_DBG("[Error]TP write data error!! packet_number=%d\n", j); return j * FTS_PACKET_NO_DMA_LENGTH; } if ((j * FTS_PACKET_NO_DMA_LENGTH % 1024) == 0) { CTP_DBG("[FT520X] upgrade the 0x%x th byte.\n", ((unsigned int)j) * FTS_PACKET_NO_DMA_LENGTH); } } if ((dw_lenth) % FTS_PACKET_NO_DMA_LENGTH > 0) { temp = packet_number * FTS_PACKET_NO_DMA_LENGTH; buf[2] = (u8)(temp>>8); buf[3] = (u8)temp; temp = (dw_lenth) % FTS_PACKET_NO_DMA_LENGTH; buf[4] = (u8)(temp>>8); buf[5] = (u8)temp; for (i=0;i<temp;i++) { buf[6+i] = pbt_buf[ packet_number*FTS_PACKET_NO_DMA_LENGTH + i]; bt_ecc ^= buf[6+i]; } mutex_lock(&g_pts->mutex); ret = i2c_master_send(g_pts->client, buf, temp+6); mdelay(5); mutex_unlock(&g_pts->mutex); if (ret < 0) { CTP_DBG("[Error]TP write data error!! temp=%d\n", temp); return packet_number * FTS_PACKET_NO_DMA_LENGTH; } g_pts->client->addr = g_pts->client->addr & I2C_MASK_FLAG; }
int fts_6x06_parase_keys(tinno_ts_data *ts, fts_report_data_t *pReportData) { const unsigned int izKeyCode[] = {KEY_HOME, KEY_MENU, KEY_BACK, KEY_SEARCH}; int iKeyCode = izKeyCode[pReportData->gesture - 0xF0]; //CTP_DBG("The touch key is (%d) !", iKeyCode); #ifdef CONFIG_TOUCHSCREEN_FT5X05_DISABLE_KEY_WHEN_SLIDE curtime=get_time(); #endif if ( FTS_EF_DOWN == pReportData->xy_data[0].event_flag ){ if ( TKS_DOWNED == ts->key_state || TKS_MOVING == ts->key_state ){ CTP_DBG("The touch key state(%d) is error, we should append a key up event for last key!", ts->key_state); #ifdef CONFIG_TOUCHSCREEN_FT6X05_DISABLE_KEY_WHEN_SLIDE tp_key_handle(iKeyCode,0); #else input_report_key( ts->keys_dev, ts->mLastKeyCode, 0 ); input_sync(ts->keys_dev); #endif ts->key_state = TKS_IDLE; }else if ( TKS_UPPED == ts->key_state ){ ts->key_state = TKS_IDLE; } if ( TKS_IDLE == ts->key_state ){ ts->key_state = TKS_DOWNED; #ifdef CONFIG_TOUCHSCREEN_FT6X05_DISABLE_KEY_WHEN_SLIDE tp_key_handle(iKeyCode,1); #else input_report_key( ts->keys_dev, iKeyCode, 1 ); input_sync(ts->keys_dev); #endif CTP_DBG("The touch key(%d) DOWM!", iKeyCode); } }else if ( FTS_EF_CONTACT == pReportData->xy_data[0].event_flag ){ if ( TKS_IDLE == ts->key_state ){ CTP_DBG("The touch key state(%d) is error, we should append a key down event!", ts->key_state); ts->key_state = TKS_DOWNED; #ifdef CONFIG_TOUCHSCREEN_FT6X05_DISABLE_KEY_WHEN_SLIDE tp_key_handle(iKeyCode,1); #else input_report_key( ts->keys_dev, iKeyCode, 1 ); input_sync(ts->keys_dev); #endif } if ( TKS_DOWNED == ts->key_state ){ ts->key_state = TKS_MOVING; } CTP_DBG("The touch key is moving, we should ignore this event!"); }else if ( FTS_EF_UP == pReportData->xy_data[0].event_flag ){ if ( TKS_MOVING == ts->key_state || TKS_DOWNED == ts->key_state ){ ts->key_state = TKS_UPPED; #ifdef CONFIG_TOUCHSCREEN_FT6X05_DISABLE_KEY_WHEN_SLIDE tp_key_handle(iKeyCode,0); #else input_report_key( ts->keys_dev, iKeyCode, 0 ); input_sync(ts->keys_dev); #endif CTP_DBG("The touch key(%d) UP!", iKeyCode); } } if ( TKS_UPPED == ts->key_state ){ ts->key_state = TKS_IDLE; } ts->mLastKeyCode = iKeyCode; return 0; }