android触摸屏ar1011驱动

来源:互联网 发布:js拖拽事件绑定数据 编辑:程序博客网 时间:2024/06/06 03:11
前些天,工作需要,把ar1011的驱动从linux移来支持imx6q + android4.3.0。

ar1011是TI出的一块串口类型的触摸控制芯片,支持4,5,8线屏。接口是串口的,这个芯片有点贵,但支持温度广。原理上是通过串口上传x,y,pre值。


1.在kernel下,把driver配置编译进去。具体修改源码.linux 和android 有些不同。
  linux相对说来比较简单,在driver/input/touchsreen下加进去,源码都不用修改。但在/udev下增加自动配置脚本。在android里面,每次上送的值是转换后的值。
  这个转换算法是把实际的值,通过校正坐标的值来转换,得到转换后的坐标,再上传到应用层。


  //static int a[7] = {30258,-56,-17665136,26,20336,-17534240,65536};
static int a[7] =   {30336,210,-18065312,77,20355,-17794560,65536};
//static int a[7] =   {30159,970,-17729008,102,20210,-17375808,65536};


static int ts_linear_scale(int *x, int *y, int swap_xy)  
{  
    int xtemp, ytemp;   
     
    xtemp = *x; ytemp = *y;  
    if (a[6] == 0)  
        return -EINVAL;  
  
    *x = (a[2] + a[0] * xtemp + a[1] * ytemp) / a[6];  
    *y = (a[5] + a[3] * xtemp + a[4] * ytemp) / a[6];  
  
    if (swap_xy) {  
        int tmp = *x;  
        *x = *y;  
        *y = tmp;  
    }  
    return 0;  



2.在externl里,把inputactivty作为一个应用编译进去。这个编写Android.mk


3.在system/usr/idc里增加配置文件.这个配置文件命名必须和driver里注册名是一样的。MicrochiptouchScreen.idc
# Basic Parameters
touch.deviceType = touchScreen
touch.orientationAware = 1
# Size 
touch.size.calibration = diameter
touch.size.scale = 10
touch.size.bias = 0
touch.size.isSummed = 0


# Pressure 
# Driver reports signal strength as pressure.
# A normal thumb touch typically registers about 200 signal strength
# units although we don't expect these values to be accurate.


touch.pressure.calibration = amplitude
touch.pressure.scale = 0.005


# Orientation
touch.orientation.calibration = none




4.在启动脚本里,增加启动配置脚本
  service touchscreen /system/bin/inputactivate -ar1xxx /dev/ttySAC3
    class late_start
    oneshot
 
校验值要么在linux得到,要到移植tslib到android系统下进,对屏进行校正后得到的。还在在转换时,要注意屏的解析度大小。   

0 0
原创粉丝点击