1. 按笔者前篇日志(http://blog.csdn.net/Matrix_Designer/archive/2010/10/18/5949713.aspx )编译安装Skyeye,注意第五项和第六项。
2. 按笔者前篇日志(http://blog.csdn.net/Matrix_Designer/archive/2010/10/18/5949298.aspx )编译安装LCD驱动。
3. 下载SkyEye TouchScreen For S3C2410的驱动程序(http://blog.csdn.net/Matrix_Designer/archive/2010/11/16/6013607.aspx )。这是笔者根据ksh提供的armlinux4skyeye-v0.2.3做的修改,仅修改了文件skyeye_ts_drv.c,具体做的修改如下:
将:
//#define ENABLE_PEN_IRQ { INTSR &= ~EINT2; }
//#define DISABLE_PEN_IRQ { INTSR |= EINT2; }
修改成:
#define ENABLE_PEN_IRQ
#define DISABLE_PEN_IRQ
注释掉:
if(!(INTSR&EINT2)) {
return;
}
这三句和:
#include "ep7312_sys.h"
在#define DISABLE_PEN_IRQ的下面添加:
#include <asm/io.h>
#include "asm/arch/smdk2410.h"
#ifndef MOD_DEC_USE_COUNT
#define MOD_DEC_USE_COUNT
#endif
#ifndef MOD_INC_USE_COUNT
#define MOD_INC_USE_COUNT
#endif
static inline int __deprecated verify_area(int type, const void __user * addr,
unsigned long size)
{
return access_ok(type,addr,size) ? 0 : -EFAULT;
}
将:
#define PEN_IRQ_NUM 6
修改为:
#define PEN_IRQ_NUM SMDK2410_TS_IRQ
将:
TS_Buf_start_addr=0xff00b000;
修改成:
TS_Buf_start_addr=vSMDK2410_TS_IO+0x300;
将:
static void handle_pen_irq(int irq, void *dev_id, struct pt_regs *regs);
修改成:
static irqreturn_t handle_pen_irq(int irq, void *dev_id, struct pt_regs *regs);
将:
static void handle_pen_irq(int irq, void *dev_id, struct pt_regs *regs) {
修改成:
static irqreturn_t handle_pen_irq(int irq, void *dev_id, struct pt_regs *regs) {
在函数handle_pen_irq的:
restore_flags(flags);
这一句下面添加:
return IRQ_HANDLED;
4. gedit include/asm-arm/arch-s3c2410/smdk2410.h &
添加定义:
#define pSMDK2410_TS_IO __phys_to_pfn(0x19100000)
#define vSMDK2410_TS_IO S3C2410_ADDR(0xE0100000)
#define SMDK2410_TS_IRQ IRQ_EINT19
5. gedit arch/arm/mach-s3c2410/mach-smdk2410.c &
在结构体map_desc smdk2410_iodesc中
{vSMDK2410_ETH_IO,pSMDK2410_ETH_IO, SZ_1M, MT_DEVICE},的下面添加:
/* Map the touchscreen controller SKYEYE */
{vSMDK2410_TS_IO,pSMDK2410_TS_IO, SZ_1M, MT_DEVICE},
6. cp skyeye_ts_drv.h ./drivers/input/touchscreen/
cp skyeye_ts_drv.c ./drivers/input/touchscreen/
7. gedit drivers/input/touchscreen/Kconfig &
在if INPUT_TOUCHSCREEN的下面添加以下内容:
config TOUCHSCREEN_SKYEYE
tristate "SkyEye Touch Screen support"
depends on INPUT && INPUT_TOUCHSCREEN
help
Support for skyeye based touchscreen. If you build the kernel
for skyeye, and want to use the touchscreen, say Y. To compile
this driver as a module, choose M here and read.
The module will be called skyeye_ts_drv.o.
8. gedit drivers/input/touchscreen/Makefile &
在文件最后添加以下内容:
obj-$(CONFIG_TOUCHSCREEN_SKYEYE) += skyeye_ts_drv.o
9. make menuconfig
选中Device Drivers->Input device support->Touchscreen interface
选中Device Drivers->Input device support->Event interface
选中Device Drivers->Input device support->Event Debugging
选中Device Drivers->Input device support->Touchscreens
选中Device Drivers->Input device support->Touchscreens->SKYEYE based touchscreens
10. make
至此,得到的内核已经可以支持触摸屏,修改SkyEye.conf文件,其内容如下:
# skyeye config file for S3C2410X
arch: arm
cpu: arm920t
mach: s3c2410x
# physical memory
mem_bank: map=M, type=RW, addr=0xC0000000, size=0x00800000
mem_bank: map=M, type=RW, addr=0xC0800000, size=0x01000000, file=./initrd.img
mem_bank: map=M, type=RW, addr=0xC1800000, size=0x02800000
# all peripherals I/O mapping area
mem_bank: map=I, type=RW, addr=0x48000000, size=0x20000000
mem_bank: map=I, type=RW, addr=0x19000300, size=0x00000020
mem_bank: map=I, type=RW, addr=0x19100300, size=0x00000020
net: type=cs8900a, base=0x19000300, size=0x20,int=9, mac=0:4:3:2:1:f, ethmod=tuntap, hostip=10.0.0.1, state=on
lcd: type=s3c2410x, mod=gtk
touchscreen: type=s3c2410x, mod=gtk
uart:mod=term
#dbct:state=on
#log: logon=0, logfile=./sk1.log, start=5000000, end=6000000
最后编写触摸屏测试程序,代码如下:
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
/* for data reading from /dev/ts */
typedef struct ts_pen_info {
int x,y; /* pen position */
int dx,dy; /* delta move from last position */
int event; /* event from pen (DOWN,UP,CLICK,MOVE) */
int state; /* state of pen (DOWN,UP,ERROR) */
int ev_no; /* no of the event */
unsigned long ev_time; /* time of the event (ms) since ts_open */
} TS_EVENT;
int main(int argc, char **argv)
{
static int ts = -1;
static TS_EVENT ts_event;
// touch screen
printf("touch screen test program/n");
printf("please touch the screen sizeof():%4d./n",sizeof(TS_EVENT));
ts = open ("/dev/ts", O_RDONLY);
if (ts < 0)
{
fprintf (stderr, "Can not open touch screen!/n");
return 1;
}
while(1)
{
if(read (ts, &ts_event, sizeof (TS_EVENT)))
printf ("touchscreen event: ts_event.x = %4d, ts_event.y = %4d event:%6d, ev_time:%4d/n", ts_event.x, ts_event.y,ts_event.event,ts_event.ev_time);
}
return 0;
}
编写完成后可以在SkyEye中测试触摸屏功能。这个驱动还有点不足之处,就是没有处理中断重入,呵呵。这个以后再搞吧,待续。。。