mtk android tp 运行方式更改

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

步骤1. probe 中创建线程

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


步骤2. 完成轮询函数

static int my_touch_event_handler()
{
	int pending = 0;
	struct TouchInfoT cinfo, pinfo;
	struct sched_param param = { .sched_priority = RTPM_PRIO_TPD };
	sched_setscheduler(current, SCHED_RR, & param);

    memset(&cinfo, 0, sizeof(struct TouchInfoT));
    memset(&pinfo, 0, sizeof(struct TouchInfoT));
	do
	{
	printk("my_touch_event_handler-------------------\n");
		set_current_state(TASK_INTERRUPTIBLE); 
		if(!kthread_should_stop())
		{
			///TPD_DEBUG_CHECK_NO_RESPONSE;
			do
			{
				//if (pending) 
					wait_event_interruptible_timeout(waiter,  0, HZ/20);
				//else 
				//	wait_event_interruptible_timeout(waiter, 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 (tpd_touchinfo(&cinfo, &pinfo))
		{
			if(cinfo.count >0)
			{
				tpd_down(cinfo.x1, cinfo.y1, cinfo.pressure);
				if(cinfo.count>1)
             	{            	
					tpd_down(cinfo.x2, cinfo.y2, cinfo.pressure);
				}
				input_sync(tpd->dev);		
				//TPD_LOGV("[MSG2133]press  --->\n");
			}
			else if(cinfo.count==0 && pinfo.count!=0)
			{
			
        
			    input_mt_sync(tpd->dev);
			    input_sync(tpd->dev);
			
				//TPD_LOGV("[MSG2133]release --->\n"); 
			}
		}		   
	}while(1);

	return 0;
}


你可能感兴趣的:(mtk android tp 运行方式更改)