首页 > 代码库 > andoid电阻触摸移植

andoid电阻触摸移植

这里我使用的是210的开发板 系统Android4.0.4 内核linux3.0.8

要用电阻屏一般都是使用tslib进行校准的 这里给个我在android上用的tslib

下载地址 http://download.csdn.net/detail/hclydao/8074069

直接把这个放在android源码external目录下即可 有几点需要注意的

tslib里我改了下Android.mk 以前用的时候应该是模块名input被用了 所以我改成了input1

include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE:= input1
LOCAL_PRELINK_MODULE := false
LOCAL_CFLAGS = $(CFLAGS)
LOCAL_C_INCLUDES = $(C_INCLUDES)
LOCAL_SRC_FILES =  plugins/input-raw.c
LOCAL_SHARED_LIBRARIES += libts
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
include $(BUILD_SHARED_LIBRARY)
所以相应的ts.conf里也要改 我的ts.conf内容如下


# Uncomment if you wish to use the linux input layer event interface
module_raw input1

# Uncomment if you're using a Sharp Zaurus SL-5500/SL-5000d
# module_raw collie

# Uncomment if you're using a Sharp Zaurus SL-C700/C750/C760/C860
# module_raw corgi

# Uncomment if you're using a device with a UCB1200/1300/1400 TS interface
# module_raw ucb1x00

# Uncomment if you're using an HP iPaq h3600 or similar
# module_raw h3600

# Uncomment if you're using a Hitachi Webpad
# module_raw mk712

# Uncomment if you're using an IBM Arctic II
# module_raw arctic2

module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear
直接放在system/etc/下就可以了 注意上面的 
module_raw input1

后面的input1是和上面模块名是一样的

ts.conf最好是系统编译完成后 在拷贝过去 或者可以直接改tslib下的 然后制作文件系统的时候还需要增加相应的几个节点 如下

	mkdir rootfs_dir/dev/input
	mkdir rootfs_dir/dev/graphics
	mknod rootfs_dir/dev/graphics/fb0 c 29 0
	mknod rootfs_dir/dev/input/event1  c 13 65
因为我把校准放在了init之前 基本上设备节点都没有 所以这里我自己创建 我的电阻触摸驱动是event1所以这里要加上

然后是calibrate脚本

#!/bin/sh
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CALIBFILE=/system/etc/pointercal
export TSLIB_CONFFILE=/system/etc/ts.conf
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/graphics/fb0
export TSLIB_PLUGINDIR=/system/lib/ts
exec /sbin/ts_calibrate
这里的TSDEVICE和FBDEVICE具体根据你自己的改

然后就是校准后的数据回写到驱动里 校准完成后在执行这个

/system/bin/cat /etc/pointercal > /proc/driver/micc_ts
后面的/proc/driver/micc_ts根据驱动里来的 这个你可以开个服务执行就可以了

然后就是加个idc这个直接拷贝一个 名字改成你的驱动里的名字就行了 我这里是s3c-ts

文件系统修改基本都是这样了 下面上驱动 

/* linux/drivers/input/touchscreen/s3c-ts.c
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Copyright (c) 2004 Arnaud Patard <arnaud.patard@rtp-net.org>
 * iPAQ H1940 touchscreen support
 *
 * ChangeLog
 *
 * 2004-09-05: Herbert Potzl <herbert@13thfloor.at>
 *	- added clock (de-)allocation code
 *
 * 2005-03-06: Arnaud Patard <arnaud.patard@rtp-net.org>
 *      - h1940_ -> s3c24xx (this driver is now also used on the n30
 *        machines :P)
 *      - Debug messages are now enabled with the config option
 *        TOUCHSCREEN_S3C_DEBUG
 *      - Changed the way the value are read
 *      - Input subsystem should now work
 *      - Use ioremap and readl/writel
 *
 * 2005-03-23: Arnaud Patard <arnaud.patard@rtp-net.org>
 *      - Make use of some undocumented features of the touchscreen
 *        controller
 *
 * 2006-09-05: Ryu Euiyoul <ryu.real@gmail.com>
 *      - added power management suspend and resume code
 *
 */

#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/init.h>
#include <linux/serio.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
#include <linux/io.h>
#include <asm/irq.h>
#include <mach/hardware.h>

#include <mach/regs-adc.h>
#include <mach/ts-s3c.h>
#include <mach/irqs.h>
#include <linux/proc_fs.h>
#include <asm/uaccess.h>

/* For ts->dev.id.version */
#define S3C_TSVERSION	0x0101

#define WAIT4INT(x)	(((x)<<8) | 			S3C_ADCTSC_YM_SEN | S3C_ADCTSC_YP_SEN | 			S3C_ADCTSC_XP_SEN | S3C_ADCTSC_XY_PST(3))

#define AUTOPST	(S3C_ADCTSC_YM_SEN | S3C_ADCTSC_YP_SEN | 		 S3C_ADCTSC_XP_SEN | S3C_ADCTSC_AUTO_PST | 		 S3C_ADCTSC_XY_PST(0))

#ifdef CONFIG_HAS_EARLYSUSPEND
static void ts_early_suspend(struct early_suspend *h);
static void ts_late_resume(struct early_suspend *h);
#endif

/* Touchscreen default configuration */
struct s3c_ts_mach_info s3c_ts_default_cfg __initdata = http://www.mamicode.com/{>只是在ADC驱动里加了一些东西 具体ADC驱动就不说了 大致的一些解释都写上面了 基本上就这个样了

修改完成后 测试效果还是不错地.



andoid电阻触摸移植