我已经上传了完善好的源代码,已经加入对一线触摸的支持,如果想直接使用,不用自己加补丁:
请到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 首先安装必要的工具
- sudo apt-get install libtool autoconf automake git
- git clone https://github.com/kergoth/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根目录,然后补丁上:
- cp tslib-one-wire.patch tslib/
- cd tslib/
- patch -p1 <tslib-one-wire.patch
tslib-one-wire.patch源码见下,copy下来然后命名成tslib-one-wire.patch就ok了,然后用上面操作。
- #
- # This patch adds support for one wire input raw module (Linux /dev/touchscreen-1wire support).
- #
- # Signed-off-by: Richard Nee <richard.nee.cn@gmail.com>
- #
- --- tslib.orig/configure.ac 2012-05-07 22:28:42.000000000 +0800
- +++ tslib/configure.ac 2012-05-07 23:53:18.849542215 +0800
- @@ -68,6 +68,7 @@
- TSLIB_CHECK_MODULE([dmc], [yes], [Enable building of dmc raw module (HP iPaq DMC support)])
- TSLIB_CHECK_MODULE([input], [yes], [Enable building of generic input raw module (Linux /dev/input/eventN support)])
- TSLIB_CHECK_MODULE([touchkit], [yes], [Enable building of serial TouchKit raw module (Linux /dev/ttySX support)])
- +TSLIB_CHECK_MODULE([one-wire-ts-input], [yes], [Enable building of one wire input raw module (Linux /dev/touchscreen-1wire support)])
- AC_MSG_CHECKING([where to place modules])
- AC_ARG_WITH(plugindir,
- --- tslib.orig/plugins/Makefile.am 2012-05-07 22:28:42.000000000 +0800
- +++ tslib/plugins/Makefile.am 2012-05-08 00:08:59.229542649 +0800
- @@ -114,6 +114,12 @@
- CY8MRLN_PALMPRE_MODULE =
- endif
- +if ENABLE_ONE_WIRE_TS_INPUT_MODULE
- +ONE_WIRE_TS_INPUT_MODULE = one_wire_ts_input.la
- +else
- +ONE_WIRE_TS_INPUT_MODULE =
- +endif
- +
- pluginexec_LTLIBRARIES = \
- $(LINEAR_MODULE) \
- $(DEJITTER_MODULE) \
- @@ -130,7 +136,8 @@
- $(H2200_LINEAR_MODULE) \
- $(INPUT_MODULE) \
- $(TOUCHKIT_MODULE) \
- - $(CY8MRLN_PALMPRE_MODULE)
- + $(CY8MRLN_PALMPRE_MODULE) \
- + $(ONE_WIRE_TS_INPUT_MODULE)
- variance_la_SOURCES = variance.c
- variance_la_LDFLAGS = -module $(LTVSN)
- @@ -185,3 +192,6 @@
- cy8mrln_palmpre_la_SOURCES = cy8mrln-palmpre.c
- cy8mrln_palmpre_la_LDFLAGS = -module $(LTVSN)
- +
- +one_wire_ts_input_la_SOURCES = one-wire-ts-input.c
- +one_wire_ts_input_la_LDFLAGS = -module $(LTVSN)
- --- tslib.orig/plugins/plugins.h 2012-05-07 22:28:42.000000000 +0800
- +++ tslib/plugins/plugins.h 2012-05-07 23:57:38.369542335 +0800
- @@ -16,3 +16,4 @@
- TSLIB_DECLARE_MODULE(tatung);
- TSLIB_DECLARE_MODULE(input);
- TSLIB_DECLARE_MODULE(cy8mrln_palmpre);
- +TSLIB_DECLARE_MODULE(one_wire_ts_input);
- --- /dev/null 2012-05-08 11:52:49.481035009 +0800
- +++ tslib/plugins/one-wire-ts-input.c 2012-05-08 12:04:38.749035337 +0800
- @@ -0,0 +1,66 @@
- +#include <termios.h>
- +#include <stdio.h>
- +#include <unistd.h>
- +#include <stdlib.h>
- +#include <sys/types.h>
- +#include <sys/stat.h>
- +#include <sys/ioctl.h>
- +#include <fcntl.h>
- +#include <linux/fs.h>
- +#include <errno.h>
- +#include <string.h>
- +#include <sys/utsname.h>
- +#include <time.h>
- +
- +#include "config.h"
- +#include "tslib-private.h"
- +
- +static int misc_read(struct tslib_module_info *inf, struct ts_sample *samp, int nr)
- +{
- + struct tsdev *ts = inf->dev;
- +
- + int ret;
- + unsigned ts_status;
- + ret = read(ts->fd, &ts_status, sizeof ts_status);
- + if (ret < 0) {
- + return 0;
- + }
- + if (ret == 0) {
- + return 0;
- + }
- +
- + samp->x = ((ts_status) >> 16) & 0x7FFF;
- + samp->y = ts_status & 0x7FFF;
- + samp->pressure = ts_status >> 31;
- + gettimeofday(&samp->tv,NULL);
- + nr = nr;
- +
- + return 1;
- +}
- +static int ts_fini(struct tslib_module_info *inf)
- +{
- + free(inf);
- + return 0;
- +}
- +
- +static const struct tslib_ops misc_ops =
- +{
- + .read = misc_read,
- + .fini = ts_fini,
- +};
- +
- +TSAPI struct tslib_module_info *one_wire_ts_mod_init(struct tsdev *dev, const char *params)
- +{
- + struct tslib_module_info *m;
- +
- + m = malloc(sizeof(struct tslib_module_info));
- + if (m == NULL)
- + return NULL;
- +
- + m->ops = &misc_ops;
- + return m;
- +}
- +
- +#ifndef TSLIB_STATIC_FRIENDLYARM_TS_MODULE
- +TSLIB_MODULE_INIT(one_wire_ts_mod_init);
- +#endif
4 下面是配置编译tslib
- ./autogen.sh
- echo "ac_cv_func_malloc_0_nonnull=yes" > cache-file.cache
- ./configure --host=arm-linux --cache-file=cache-file.cache --prefix=$PWD/install_dir
- make
- make install
5 通过修改tslib的配置文件加载一线触摸模块
- echo "module_raw one_wire_ts_input" > ts.conf.bck
- cat $PWD/install-tslib/etc/ts.conf >>ts.conf.bck
- mv ts.conf.bck $PWD/install-tslib/etc/ts.conf
6 测试
设置环境变量tslib-env.sh
- #! /bin/sh
- #export TSLIB_ROOT=/opt/tslib
- export TSLIB_CALIBFILE=/etc/pointercal
- export TSLIB_CONFFILE=/etc/ts.conf
- export TSLIB_PLUGINDIR=/usr/lib/ts
- export TSLIB_CONSOLEDEVICE=none
- export TSLIB_FBDEVICE=/dev/fb0
- export TSLIB_TSDEVICE=/dev/touchscreen-1wire
- #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TSLIB_ROOT/lib
- #export PATH=$PATH:$TSLIB_ROOT/bin
运行测试,进行5点校验
- ts_calibrate
ok,good luck : )
转载:http://blog.csdn.net/openme_openwrt/article/details/7546796 by 飞鸿惊雪