static int touch_event_handler(void *unused) { struct sched_param param = { .sched_priority = RTPM_PRIO_TPD }; struct touch_info cinfo, sinfo; int pending = 0; struct i2c_client * i2c_client = ft5316_i2c_client ; TPD_DEBUG("touch_event_handler\n"); cinfo.pending=0; sched_setscheduler(current, SCHED_RR, ¶m); do { //Ivan added for testing if (tpd_status == 1){ mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); // possibly to lose event? } set_current_state(TASK_INTERRUPTIBLE); if (!kthread_should_stop()) { // TPD_DEBUG_CHECK_NO_RESPONSE; do { if(pending) wait_event_interruptible_timeout(waiter, tpd_flag!=0, HZ/10); else wait_event_interruptible_timeout(waiter,tpd_flag!=0, HZ*2); } while(0); if(tpd_flag==0 && !pending) continue; // if timeout for no touch, then re-wait. if(tpd_flag!=0 && pending>0) pending=0; tpd_flag=0; TPD_DEBUG_SET_TIME; } set_current_state(TASK_RUNNING); if(!pending) if(tpd_gettouchinfo(&cinfo, &sinfo)) continue; if(pending>1) { pending--; continue; } //Ivan ++ if (tpd_init_skip) {tpd_init_skip = 0; continue; } TPD_DEBUG("cinfo->count == %d!\n", cinfo.count); if(cinfo.count > 0) { int i; for ( i=0; i < cinfo.count; i++ ) { TPD_DEBUG("cinfo->count == %d!\n", cinfo.count); TPD_DEBUG("Point ID == %d, x == %d , y == %d ,z ==%d\n!",cinfo.pt[i].id,cinfo.pt[i].x,cinfo.pt[i].y,cinfo.pt[i].z ); tpd_down(cinfo.pt[i].x, cinfo.pt[i].y, cinfo.pt[i].id); } input_sync(tpd->dev); } else { TPD_DEBUG("TPD up x == %d , y == %d\n!",x_history[cinfo.count], y_history[cinfo.count]); tpd_up(x_history[cinfo.count], y_history[cinfo.count], 0); input_sync(tpd->dev); } } while (!kthread_should_stop()); return 0; }
static int touch_event_handler(void *unused) { struct sched_param param = { .sched_priority = RTPM_PRIO_TPD }; struct touch_info cinfo, sinfo; int pending = 0, down = 0; struct touch_info buf[3]; int buf_p=1, buf_c=2, buf_f=0; int dx; cinfo.pending=0; sched_setscheduler(current, SCHED_RR, ¶m); do { MT6516_EINTIRQUnmask(CUST_EINT_TOUCH_PANEL_NUM); // possibly to lose event? set_current_state(TASK_INTERRUPTIBLE); if (!kthread_should_stop()) { TPD_DEBUG_CHECK_NO_RESPONSE; do { if(pending) wait_event_interruptible_timeout(waiter, tpd_flag!=0, HZ/10); else wait_event_interruptible_timeout(waiter,tpd_flag!=0, HZ*2); } while(0); if(tpd_flag==0 && !pending) continue; // if timeout for no touch, then re-wait. if(tpd_flag!=0 && pending>0) pending=0; tpd_flag=0; TPD_DEBUG_SET_TIME; } set_current_state(TASK_RUNNING); if(!pending) if(tpd_gettouchinfo(&cinfo, &sinfo)) continue; if(pending>1) { pending--; continue; } if(cinfo.count==-1) continue; if(tpd_mode==TPD_MODE_KEYPAD && ((tpd_mode_axis==0 && cinfo.y1>=tpd_mode_min && cinfo.y1<=tpd_mode_max) || (tpd_mode_axis==1 && cinfo.x1>=tpd_mode_min && cinfo.x1<=tpd_mode_max))) { buf_f = ((buf_f+1)%3); buf_c = ((buf_f+2)%3); buf_p = ((buf_f+1)%3); buf[buf_f].x1 = cinfo.x1; buf[buf_f].y1 = cinfo.y1; dx = cinfo.x1 - buf[buf_c].x1; buf[buf_f].count = (cinfo.count?(dx*dx<tpd_mode_keypad_tolerance?buf[buf_c].count+1:1):0); if(buf[buf_c].count<2) if(tpd_up(raw_x1, raw_y1, buf[buf_p].x1, buf[buf_p].y1,&down)) input_sync(tpd->dev); if(buf[buf_c].count>1 || (buf[buf_c].count==1 && ( buf[buf_p].count==0 || buf[buf_f].count==0 || (buf[buf_f].x1-buf[buf_c].x1)*(buf[buf_c].x1-buf[buf_p].x1)<=0))) { tpd_down(raw_x1, raw_y1, buf[buf_c].x1, buf[buf_c].y1, 1); input_sync(tpd->dev); down=1; } if(cinfo.count==0) if(tpd_up(raw_x1, raw_y1, buf[buf_p].x1, buf[buf_p].y1,&down)) input_sync(tpd->dev); } else { switch(cinfo.count) { case 0: if(cinfo.pending>0) pending+=cinfo.pending, cinfo.pending=0; else { if(sinfo.count>=2) { if(pending==0) pending+=1; else { if(tpd_up(raw_x1, raw_y1, sinfo.x1, sinfo.y1, &down) + tpd_up(raw_x2, raw_y2, sinfo.x2,sinfo.y2, &down)) input_sync(tpd->dev); sinfo.count = 0; pending = 0; } } else if(sinfo.count==1) { #ifdef TPD_HAVE_BUTTON if(boot_mode!=NORMAL_BOOT && tpd->btn_state) tpd_button(cinfo.x1, cinfo.y1,0); #endif if(tpd_up(raw_x1, raw_y1, cinfo.x1,cinfo.y1, &down)) input_sync(tpd->dev); sinfo.count = 0; pending=0; } else pending = 0; } TPD_DEBUG_PRINT_UP; break; case 1: if(sinfo.count>=3 || pending==1) { pending = 0; if(sinfo.count==3 && down>1) { if(tpd_up(raw_x1, raw_y1, sinfo.x1,sinfo.y1, &down)) input_sync(tpd->dev); /*tpd_down(cinfo.x1, cinfo.y1, 1); if( (cinfo.x1-sinfo.x1)*(cinfo.x1-sinfo.x1)+(cinfo.y1-sinfo.y1)*(cinfo.y1-sinfo.y1) > (cinfo.x1-sinfo.x2)*(cinfo.x1-sinfo.x2)+(cinfo.y1-sinfo.y2)*(cinfo.y1-sinfo.y2) ) { if(tpd_up(sinfo.x1,sinfo.y1, &down)) input_sync(tpd->dev); } else { if(tpd_up(sinfo.x2,sinfo.y2, &down)) input_sync(tpd->dev); }*/ } } else if(sinfo.count==2) { if(pending==0) pending=1; else { if(tpd_up(raw_x1, raw_y1, cinfo.x1,cinfo.y1, &down) + tpd_up(raw_x2, raw_y2, sinfo.x2,sinfo.y2, &down)) input_sync(tpd->dev); sinfo.x1 = cinfo.x1; sinfo.y1=cinfo.y1; } sinfo.count = 3; } else { #ifdef TPD_HAVE_BUTTON if(boot_mode!=NORMAL_BOOT && cinfo.y1>=TPD_RES_Y) { if(tpd_up(raw_x1, raw_y1, cinfo.x1, cinfo.y1, &down)) input_sync(tpd->dev); tpd_button(cinfo.x1, cinfo.y1, 1); sinfo.count = 1; } else #endif do { #ifdef TPD_HAVE_BUTTON if(boot_mode!=NORMAL_BOOT && tpd->btn_state) tpd_button(cinfo.x1,cinfo.y1,0); #endif tpd_down(raw_x1, raw_y1, cinfo.x1,cinfo.y1, cinfo.p); input_sync(tpd->dev); down = 1; sinfo.count = 1; } while(0); } TPD_DEBUG_PRINT_DOWN; break; case 2: // hold one finger, press another, this code will release both fingers if(sinfo.count==3) { if(tpd_up(raw_x1, raw_y1, sinfo.x1, sinfo.y1, &down) + tpd_up(raw_x2, raw_y2, sinfo.x2, sinfo.y2, &down)) input_sync(tpd->dev); } tpd_smoothing(&cinfo, &sinfo); tpd_down(raw_x1, raw_y1, sinfo.x1, sinfo.y1, 1); tpd_down(raw_x2, raw_y2, sinfo.x2, sinfo.y2, 1); down = 2; sinfo.count = 2; input_sync(tpd->dev); TPD_DEBUG_PRINT_DOWN; break; default: break; } } } while (!kthread_should_stop()); return 0; }
static int touch_event_handler(void *unused) { struct sched_param param = { .sched_priority = RTPM_PRIO_TPD }; int index; uint8_t Firmware_version[3] = {0x20,0x00,0x00}; sched_setscheduler(current, SCHED_RR, ¶m); do { set_current_state(TASK_INTERRUPTIBLE); if (!kthread_should_stop()) { TPD_DEBUG_CHECK_NO_RESPONSE; do { while (tpd_halt) {tpd_flag = 0;sinfo.TouchpointFlag=0; msleep(20);} wait_event_interruptible(waiter,tpd_flag!=0); tpd_flag = 0; } while(0); TPD_DEBUG_SET_TIME; } set_current_state(TASK_RUNNING); #if 0 if (tpd_show_version) { tpd_show_version = 0; if(tpd_i2c_master_rs_send(i2c_client,Firmware_version,3<<8|1) < 0) { TPD_DMESG("I2C transfer error, line: %d\n", __LINE__); } else { TPD_DMESG(" mcs6024 Hardware version is %x\n",Firmware_version[0]); TPD_DMESG(" mcs6024 Firmware version is %x\n",Firmware_version[1]); TPD_DMESG(" mcs6024 Panel Type is %x\n",Firmware_version[2]); } } if((tpd_gettouchinfo(&cinfo)) && (sinfo.TouchpointFlag==0) && ((sinfo.VirtualKeyFlag & 0x03) == 0)) continue; TPD_DEBUG("sinfo.TouchpointFlag = %d\n",sinfo.TouchpointFlag); TPD_DEBUG("cinfo.TouchpointFlag = %d\n",cinfo.TouchpointFlag); TPD_DEBUG("sinfo.VirtualKeyFlag = %d\n",sinfo.VirtualKeyFlag); TPD_DEBUG("cinfo.VirtualKeyFlag = %d\n",cinfo.VirtualKeyFlag); #ifdef TPD_HAVE_BUTTON int index = (cinfo.VirtualKeyFlag >> 2) & 0x03; if (index >= TPD_KEY_COUNT) continue; if ((cinfo.VirtualKeyFlag & 0x03) == 1) { if ((sinfo.VirtualKeyFlag & 0x03) == 0) { tpd_down(tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], 128); if (boot_mode != NORMAL_BOOT) tpd_button(tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], 1); } } else { if ((sinfo.VirtualKeyFlag & 0x03) == 1) { tpd_up(tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1]); if (boot_mode != NORMAL_BOOT) tpd_button(tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], 0); } } #endif for(index = 0;index<MAX_POINT;index++) { if(cinfo.TouchpointFlag&(1<<index)) { raw_x[index] = cinfo.x[index]; raw_y[index] = cinfo.y[index]; tpd_down(raw_x[index], raw_y[index], cinfo.x[index],cinfo.y[index], 128); sinfo.x[index] = cinfo.x[index]; sinfo.y[index] = cinfo.y[index]; sinfo.TouchpointFlag |=(1<<index); } else { if(sinfo.TouchpointFlag&(1<<index)) { tpd_up(raw_x[index], raw_y[index], sinfo.x[index], sinfo.y[index]); sinfo.TouchpointFlag &=~(1<<index); } } } input_sync(tpd->dev); #endif msg21xx_data_disposal(); } while (!kthread_should_stop()); return 0; }