一线触摸tslib移植完全说明

我已经上传了完善好的源代码,已经加入对一线触摸的支持,如果想直接使用,不用自己加补丁:

请到http://code.google.com/p/openwrt-for-embedded/,点击Download页面,下载tslib-one-wire.tar.bz2。
但是建议你把下面的内容看完,以便使用这个已经加入对一线触摸支持的tslib。


一开始接触时,感觉友善的触摸屏好奇怪啊,和一般普通的很不一样(之前我不是使用友善的产品),都不知道该怎么移植tslib了~


一般普通的tslib-1.4之类的和这个友善提供开源tslib(源码见:http://www.arm9home.net/read.php?tid-16105.html)什么关系?首先要搞懂这个才可以继续。

        答:友善之臂提供的这个tslib实际上是标准tslib的一个模块,用来向标准的tslib提供访问一线触摸屏驱动的接口的(因为这个驱动和一般的input event based input设备不同)。你需要在板子上先加载标准的tslib, 然后再通过修改tslib的配置文件加载这个模块。


ok,下面开始移植!

1 首先安装必要的工具

[cpp]  view plain copy
  1. sudo apt-get install libtool autoconf automake git   
2 使用git获取tslib源代码
[cpp]  view plain copy
  1. git clone https://github.com/kergoth/tslib  
或者到下载我已经加入补丁的支持友善之臂一线触摸的tslib:

3 支持友善之臂一线触摸的tslib补丁tslib-one-wire.patch

友善已经提供开源tslib(源码见:http://www.arm9home.net/read.php?tid-16105.html)。

但是另外再编译它有点罗嗦,所以我直接制作一个补丁tslib-one-wire.patch来支持友善之臂一线触摸。

操作如下,把tslib-one-wire.patch拷贝到tslib根目录,然后补丁上:

[cpp]  view plain copy
  1. cp tslib-one-wire.patch tslib/  
  2. cd tslib/  
  3. patch -p1 <tslib-one-wire.patch  

tslib-one-wire.patch源码见下,copy下来然后命名成tslib-one-wire.patch就ok了,然后用上面操作。

[cpp]  view plain copy
  1. #  
  2. # This patch adds support for one wire input raw module (Linux /dev/touchscreen-1wire support).  
  3. #  
  4. # Signed-off-by: Richard Nee <richard.nee.cn@gmail.com>  
  5. #  
  6.   
  7.   
  8. --- tslib.orig/configure.ac 2012-05-07 22:28:42.000000000 +0800  
  9. +++ tslib/configure.ac  2012-05-07 23:53:18.849542215 +0800  
  10. @@ -68,6 +68,7 @@  
  11.  TSLIB_CHECK_MODULE([dmc], [yes], [Enable building of dmc raw module (HP iPaq DMC support)])  
  12.  TSLIB_CHECK_MODULE([input], [yes], [Enable building of generic input raw module (Linux /dev/input/eventN support)])  
  13.  TSLIB_CHECK_MODULE([touchkit], [yes], [Enable building of serial TouchKit raw module (Linux /dev/ttySX support)])  
  14. +TSLIB_CHECK_MODULE([one-wire-ts-input], [yes], [Enable building of one wire input raw module (Linux /dev/touchscreen-1wire support)])  
  15.    
  16.  AC_MSG_CHECKING([where to place modules])  
  17.  AC_ARG_WITH(plugindir,  
  18. --- tslib.orig/plugins/Makefile.am  2012-05-07 22:28:42.000000000 +0800  
  19. +++ tslib/plugins/Makefile.am   2012-05-08 00:08:59.229542649 +0800  
  20. @@ -114,6 +114,12 @@  
  21.  CY8MRLN_PALMPRE_MODULE =  
  22.  endif  
  23.    
  24. +if ENABLE_ONE_WIRE_TS_INPUT_MODULE  
  25. +ONE_WIRE_TS_INPUT_MODULE = one_wire_ts_input.la  
  26. +else  
  27. +ONE_WIRE_TS_INPUT_MODULE =  
  28. +endif  
  29. +  
  30.  pluginexec_LTLIBRARIES = \  
  31.     $(LINEAR_MODULE) \  
  32.     $(DEJITTER_MODULE) \  
  33. @@ -130,7 +136,8 @@  
  34.     $(H2200_LINEAR_MODULE) \  
  35.     $(INPUT_MODULE) \  
  36.     $(TOUCHKIT_MODULE) \  
  37. -   $(CY8MRLN_PALMPRE_MODULE)  
  38. +   $(CY8MRLN_PALMPRE_MODULE) \  
  39. +   $(ONE_WIRE_TS_INPUT_MODULE)  
  40.      
  41.  variance_la_SOURCES    = variance.c  
  42.  variance_la_LDFLAGS    = -module $(LTVSN)  
  43. @@ -185,3 +192,6 @@  
  44.    
  45.  cy8mrln_palmpre_la_SOURCES = cy8mrln-palmpre.c  
  46.  cy8mrln_palmpre_la_LDFLAGS = -module $(LTVSN)  
  47. +  
  48. +one_wire_ts_input_la_SOURCES = one-wire-ts-input.c  
  49. +one_wire_ts_input_la_LDFLAGS = -module $(LTVSN)  
  50. --- tslib.orig/plugins/plugins.h    2012-05-07 22:28:42.000000000 +0800  
  51. +++ tslib/plugins/plugins.h 2012-05-07 23:57:38.369542335 +0800  
  52. @@ -16,3 +16,4 @@  
  53.  TSLIB_DECLARE_MODULE(tatung);  
  54.  TSLIB_DECLARE_MODULE(input);  
  55.  TSLIB_DECLARE_MODULE(cy8mrln_palmpre);  
  56. +TSLIB_DECLARE_MODULE(one_wire_ts_input);  
  57. --- /dev/null   2012-05-08 11:52:49.481035009 +0800  
  58. +++ tslib/plugins/one-wire-ts-input.c   2012-05-08 12:04:38.749035337 +0800  
  59. @@ -0,0 +1,66 @@  
  60. +#include <termios.h>  
  61. +#include <stdio.h>  
  62. +#include <unistd.h>  
  63. +#include <stdlib.h>  
  64. +#include <sys/types.h>  
  65. +#include <sys/stat.h>  
  66. +#include <sys/ioctl.h>  
  67. +#include <fcntl.h>  
  68. +#include <linux/fs.h>  
  69. +#include <errno.h>  
  70. +#include <string.h>  
  71. +#include <sys/utsname.h>  
  72. +#include <time.h>  
  73. +  
  74. +#include "config.h"  
  75. +#include "tslib-private.h"  
  76. +  
  77. +static int misc_read(struct tslib_module_info *inf, struct ts_sample *samp, int nr)  
  78. +{  
  79. +   struct tsdev *ts = inf->dev;  
  80. +  
  81. +   int ret;  
  82. +   unsigned ts_status;  
  83. +   ret = read(ts->fd, &ts_status, sizeof ts_status);  
  84. +   if (ret < 0) {  
  85. +       return 0;  
  86. +   }  
  87. +   if (ret == 0) {  
  88. +       return 0;  
  89. +   }  
  90. +  
  91. +   samp->x = ((ts_status) >> 16) & 0x7FFF;  
  92. +   samp->y = ts_status & 0x7FFF;  
  93. +   samp->pressure = ts_status >> 31;  
  94. +   gettimeofday(&samp->tv,NULL);  
  95. +   nr = nr;  
  96. +  
  97. +   return 1;  
  98. +}  
  99. +static int ts_fini(struct tslib_module_info *inf)  
  100. +{  
  101. +        free(inf);  
  102. +        return 0;  
  103. +}  
  104. +  
  105. +static const struct tslib_ops misc_ops =  
  106. +{  
  107. +   .read   = misc_read,  
  108. +        .fini   = ts_fini,  
  109. +};  
  110. +  
  111. +TSAPI struct tslib_module_info *one_wire_ts_mod_init(struct tsdev *dev, const char *params)  
  112. +{  
  113. +   struct tslib_module_info *m;  
  114. +  
  115. +   m = malloc(sizeof(struct tslib_module_info));  
  116. +   if (m == NULL)  
  117. +       return NULL;  
  118. +  
  119. +   m->ops = &misc_ops;  
  120. +   return m;  
  121. +}  
  122. +  
  123. +#ifndef TSLIB_STATIC_FRIENDLYARM_TS_MODULE  
  124. +TSLIB_MODULE_INIT(one_wire_ts_mod_init);  
  125. +#endif  

4 下面是配置编译tslib

[cpp]  view plain copy
  1. ./autogen.sh  
  2. echo "ac_cv_func_malloc_0_nonnull=yes" > cache-file.cache  
  3. ./configure --host=arm-linux --cache-file=cache-file.cache --prefix=$PWD/install_dir  
  4.   
  5. make  
  6. make install  
安装在tslib/install-tslib/中


5 通过修改tslib的配置文件加载一线触摸模块

[cpp]  view plain copy
  1. echo "module_raw one_wire_ts_input" > ts.conf.bck  
  2. cat $PWD/install-tslib/etc/ts.conf >>ts.conf.bck  
  3. mv ts.conf.bck $PWD/install-tslib/etc/ts.conf  
到目前位置tslib已经移植成功,下面就是要把install-tslib/拷贝到开发板合适的位置,然后运行测试tslib了~


6 测试

设置环境变量tslib-env.sh

[cpp]  view plain copy
  1. #! /bin/sh  
  2.   
  3. #export TSLIB_ROOT=/opt/tslib  
  4. export TSLIB_CALIBFILE=/etc/pointercal  
  5. export TSLIB_CONFFILE=/etc/ts.conf  
  6. export TSLIB_PLUGINDIR=/usr/lib/ts  
  7. export TSLIB_CONSOLEDEVICE=none  
  8. export TSLIB_FBDEVICE=/dev/fb0  
  9. export TSLIB_TSDEVICE=/dev/touchscreen-1wire  
  10. #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSLIB_ROOT/lib  
  11. #export PATH=$PATH:$TSLIB_ROOT/bin  

运行测试,进行5点校验

[cpp]  view plain copy
  1. ts_calibrate  

ok,good luck : )



转载:http://blog.csdn.net/openme_openwrt/article/details/7546796 by 飞鸿惊雪

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值