Chinaunix首页 | 论坛 | 博客
  • 博客访问: 36895
  • 博文数量: 61
  • 博客积分: 105
  • 博客等级: 民兵
  • 技术积分: 345
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-23 20:25
文章存档

2013年(1)

2012年(60)

我的朋友

分类:

2012-07-25 17:14:40

内核自带s3c2440的触摸屏控制器驱动,属于input子系统的驱动,触摸屏驱动需要ADC驱动的支持,触摸屏驱动文件为:drivers/input/touchscreen/s3c2410_ts.c

在mach-xc2440.c文件中加入对触摸屏驱动的支持, 创建s3c2410_ts_mach_info平台数据

加入必要的头文件:
#include

xc2440_devices[ ]结构体中加入:
&s3c_device_ts,

构建触摸屏设备的平台数据:
  1. /* TouchPanel */
  2. static struct s3c2410_ts_mach_info xc2440_ts_cfg __initdata = {
  3.     .delay = 10000,
  4.     .presc = 49,
  5.     .oversampling_shift = 2,
  6. };

在xc2440_machine_init函数中加入:
s3c24xx_ts_set_platdata(&xc2440_ts_cfg);

修改s3c2410_ts.c文件:
在s3c2410ts_probe函数中,318行开始
  1. ts.input = input_dev;
  2. ts.input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_SYN);
  3. ts.input->keybit[BITS_TO_LONGS(BTN_TOUCH)] = BIT(BTN_TOUCH);

  4. input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0);
  5. input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0);
  6. input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0);

touch_timer_fire函数中:
  1. input_report_abs(ts.input, ABS_X, ts.xp);
  2. input_report_abs(ts.input, ABS_Y, ts.yp);

  3. input_report_key(ts.input, BTN_TOUCH, 1);
  4. input_report_abs(ts.input, ABS_PRESSURE, 1);
  5. input_sync(ts.input);

  6. input_report_key(ts.input, BTN_TOUCH, 0);
  7. input_report_abs(ts.input, ABS_PRESSURE, 0);
  8. input_sync(ts.input);

  9. writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC);

配置内核,支持触摸屏:
  1. Device Drivers --->
  2.     Input devices support --->
  3.         <*> Event interface
  4. [*] Touchscreens --->
  5. <*> Samsung S3C2410/generic touchscreen input driver

启动时输出:
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0

查看设备:
/dev/event0

说明: 
1. 内核自带的触摸屏驱动有BUG,需要修改才能正常使用,具体修改内容请参考XC2440的linux源码包中的s3c2410_ts.c文件。
2. Input子系统设备的设备名可能会随着内核中input设备的增加而改变,比如内核中加入一个按键驱动,那么触摸屏的设备名可能会从event0变为event1。后面移植的input子系统驱动也是同样的原理,这点请注意。

阅读(119) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~