mtk android tp 运行方式更改

来源:互联网 发布:黄金走势分析软件 编辑:程序博客网 时间:2024/05/02 02:38

将tp运行方式由中断改为轮询模式。

步骤1. probe 中创建线程

thread = kthread_run(my_touch_event_handler, 0, "msg2133");


步骤2. 完成轮询函数

[cpp] view plaincopyprint?
  1. static int my_touch_event_handler() 
  2.     int pending = 0; 
  3.     struct TouchInfoT cinfo, pinfo; 
  4.     struct sched_param param = { .sched_priority = RTPM_PRIO_TPD }; 
  5.     sched_setscheduler(current, SCHED_RR, & param); 
  6.  
  7.     memset(&cinfo, 0, sizeof(struct TouchInfoT)); 
  8.     memset(&pinfo, 0, sizeof(struct TouchInfoT)); 
  9.     do 
  10.     { 
  11.     printk("my_touch_event_handler-------------------\n"); 
  12.         set_current_state(TASK_INTERRUPTIBLE);  
  13.         if(!kthread_should_stop()) 
  14.         { 
  15.             ///TPD_DEBUG_CHECK_NO_RESPONSE; 
  16.             do 
  17.             { 
  18.                 //if (pending)  
  19.                     wait_event_interruptible_timeout(waiter,  0, HZ/20); 
  20.                 //else  
  21.                 //  wait_event_interruptible_timeout(waiter, 0, HZ*2); 
  22.                   
  23.             }while(0); 
  24.               
  25.             //if (tpd_flag == 0 && !pending)  
  26.                 //continue; // if timeout for no touch, then re-wait. 
  27.               
  28.             //if (tpd_flag != 0 && pending > 0)  
  29.                 //pending = 0; 
  30.               
  31.             tpd_flag = 0; 
  32.             //TPD_DEBUG_SET_TIME;  
  33.         } 
  34.         set_current_state(TASK_RUNNING); 
  35.  
  36.         if (tpd_touchinfo(&cinfo, &pinfo)) 
  37.         { 
  38.             if(cinfo.count >0) 
  39.             { 
  40.                 tpd_down(cinfo.x1, cinfo.y1, cinfo.pressure); 
  41.                 if(cinfo.count>1) 
  42.                 {                
  43.                     tpd_down(cinfo.x2, cinfo.y2, cinfo.pressure); 
  44.                 } 
  45.                 input_sync(tpd->dev);         
  46.                 //TPD_LOGV("[MSG2133]press  --->\n"); 
  47.             } 
  48.             else if(cinfo.count==0 && pinfo.count!=0) 
  49.             { 
  50.              
  51.          
  52.                 input_mt_sync(tpd->dev); 
  53.                 input_sync(tpd->dev); 
  54.              
  55.                 //TPD_LOGV("[MSG2133]release --->\n"); 
  56.             } 
  57.         }           
  58.     }while(1); 
  59.  
  60.     return 0;