开发板:FL2440
内核:Linux3.0
一、移植
1、修改/arch/arm/mach-s3c2440/mach-smdk2440.c
添加头文件
#include
添加
/*Touch Screen driver info add by huangyidong */
static struct s3c2410_ts_mach_info smdk2440_ts_cfg __initdata = {
.delay = 10000,
.presc = 49,
.oversampling_shift = 2,
};
修改结构体
static void __init smdk2440_machine_init(void)
{
s3c24xx_fb_set_platdata(&smdk2440_fb_info);
s3c_i2c0_set_platdata(NULL);
s3c24xx_ts_set_platdata(&smdk2440_ts_cfg);
platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));
smdk_machine_init();
}
添加设备
static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_ohci,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&s3c_device_dm9000,
&s3c_device_adc,
&s3c_device_ts,
};
2、修改drivers/input/touchscreen/s3c2410_ts.c
130行左右
input_report_key(ts.input, BTN_TOUCH, 1);
input_report_abs(ts.input, ABS_PRESSURE, 1);//add by huangyidong
input_sync(ts.input);
140多行
input_report_key(ts.input, BTN_TOUCH, 0);
input_report_abs(ts.input, ABS_PRESSURE, 0);//add by huangyidong
input_sync(ts.input);
320行左右
ts.input = input_dev;
ts.input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | BIT(EV_SYN);//add by huangyidong
ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0);
input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0);
input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0);//add by huangyidong
二、配置make menuconfig
Device Drivers --->
Input device support --->
[*] Touchscreens --->
Samsung S3C2410/generic touchscreen input driver
三、编译、烧录
烧录后重启开发板会发现多出来设备event0
四、测试
测试程序
#include
#include
static int event0_fd = -1;
struct input_event ev0[64];
static int handle_event0()
{
int button = 0, realx=0, realy=0, i, rd;
rd = read(event0_fd, ev0, sizeof(struct input_event)* 64);
if(rd < sizeof(struct input_event)) return 0;
for(i=0;i
{
if(EV_ABS == ev0[i].type)
{
if(ev0[i].code == 0) {
realx = ev0[i].value;
} else if(ev0[i].code == 1) {
realy = ev0[i].value;
}
}
printf("event(%d):type:%d; code:%3d; value:%3d; realx:%3d; realy:%3d\n",i,ev0[i].type,ev0[i].code,ev0[i].value,realx,realy);
}
return 1;
}
int main(void)
{
int done = 1;
event0_fd = open("/dev/event0",02);
if(event0_fd <0) {
printf("open input device error\n");
return -1;
}
while (done)
{
printf("begin handle_event0...\n");
done = handle_event0();
printf("end handle_event0...\n");
}
if(event0_fd > 0)
{
close(event0_fd);
event0_fd = -1;
}
return 0;
}
运行结果:
按触摸屏产生: