mtk android tp 运行方式更改

本文介绍如何将TP触摸屏的运行方式从中断模式改为轮询模式,并提供具体的实现步骤及核心代码示例。

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

步骤1. probe 中创建线程

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


步骤2. 完成轮询函数

  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; 
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;
}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值