📄 触摸屏移植(成功)for2.6.rtf
字号:
在 linux2.6.14 中没有提供 s3c2410 的驱动,所以我们要新建驱动文件,我们在 linux2.6.14/drivers/input/touchscreen 目录下建立新的文件 hfrk_s3c2410_ts.c 文件,驱动文件我们可以参考类似的触摸屏驱动,具体的内容参看网站或者光盘提供的源代码。
首先:我们需要修改 linux2.6.14/drivers/input/touchscreen 目录下的 makefile 文件,在文件的最后 添加 :
obj-$(CONFIG_TOUCHSCREEN_S3C2410) += hfrk_s3c2410_ts.o
第二:我们需要修改 linux2.6.14/ drivers/input/touchscreen/Kconfig 中添加:
config TOUCHSCREEN_S
tristate "Samsung S3C2410 touchscreen input driver"
depends on ARCH_SMDK2410 && INPUT && INPUT_TOUCHSCREEN
select SERIO
help
Say Y here if you have the s3c2410 touchscreen.
If unsure, say N.
To compile this driver as a module, choose M here: the
module will be called s3c2410_ts.
config TOUCHSCREEN_S3C2410_DEBUG
boolean "Samsung S3C2410 touchscreen debug messages"
depends on TOUCHSCREEN_S3C2410
help
Select this if you want debug messages
修改完成以后,在我们配置内核的时候,就会增加关系s3c2410的触摸屏配置,我们选择上这些配置就可以把驱动增加进去了
Device drivers - à
Input device support à
Touchscreens à
<*>Samsung S3C2410 touchscreen input driver
[]Samsung s3c2410 touchscreen debug message
第三:在 /linux-2.6.14/arch/arm/mach-s3c2410/mach-smdk2410.c, 中增加如下内容:
static struct s3c2410_ts_mach_info sbc2410_ts_cfg __initdata = {
.delay = 10000,
.presc = 49,
.oversampling_shift = 2,
};
在smdk2410_devices结构中,添加:
&s3c_device_ts,
在smdk2410_map_io函数中添加:
set_s3c2410ts_info(&sbc2410_ts_cfg);
第四:在 /linux-2.6.14/ arch/arm/mach-s3c2410/devs.h 文件中添加:
extern struct platform_device s3c_device_ts;
第五:在arch/arm/mach-s3c2410/devs.c文件中添加如下几行:
/* Touchscreen */
static struct s3c2410_ts_mach_info s3c2410ts_info;
void __init set_s3c2410ts_info(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
{
memcpy(&s3c2410ts_info,hard_s3c2410ts_info,sizeof(struct s3c2410_ts_mach_info));
}
EXPORT_SYMBOL(set_s3c2410ts_info);
struct platform_device s3c_device_ts = {
.name = "s3c2410-ts",
.id = -1,
.dev = {
.platform_data = &s3c2410ts_info,
}
};
EXPORT_SYMBOL(s3c_device_ts);
经过这些修改,我们的触摸屏驱动已经完成 , 我们编译就可以了。我们的 这个触摸屏驱动在内核注册为 /dev/input/mouse0 十.创建设备文件 根据你的配置情况创建相应的设备文件例如: mknod -m 666 ts -c 13 128 等首先需要有调试好的2.6触摸屏驱动,该驱动在网上可以找到,它将触摸屏注册为input设备,将坐标信息传输到input层。tslib可以直接从input层获取坐标信息,因此,下面将要介绍如何让qte3.3.5支持tslib。这样qte3.3.5的程序就可以用触摸屏控制了。 qte2,qtopia都直接支持tslib,而qte3不能直接支持tslib,需要加patch。具体方法如下:1.编译qte3.3.5 * cd qte-3.3.5 * export QTDIR=$PWD * cp uic bin/(拷贝x-11的bin/uic工具到bin下) * (关键步骤,否则编译时会报错说libts不兼容) $ echo yes |./configure -embedded arm -thread $ cd src/moc $ make * 从网上寻找tslib-patch。该patch针对qte3.3.4,此处根据patch内容手动patch:增加两个文件到 src/embedded/下(src/embedded/qmousetslib_qws.h, src/embedded/qmousetslib_qws.cpp),修改相应文件 (src/embedded/qmousedriverfactory_qws.cpp, src/embedded/qt_embedded.pri,configure) * 编译tslib,拷贝tslib.h到include,libts.so等库到lib下。 * $ echo yes |./configure -embedded arm –thread –qt-mouse-tslib –I$QTDIR/include –L$QTDIR/lib –lts * make * make install2.拷贝文件到目标板 拷贝qte3.3.5/lib到目标板,拷贝tslib的build目录到目标板(记住,要拷贝和编译qte时使用的相同的tslib版本)3.设置环境变量export QTDIR=/hjcaiexport LD_LIBRARY_PATH=/hjcai/libexport QWS_MOUSE_PROTO=tslib:/dev/input/tsraw0export TSLIB_TSDEVICE=/dev/input/tsraw0export TSLIB_CONSOLEDEVICE=noneexport TSLIB_FBDEVICE=/dev/fb0export TSLIB_CONFFILE=/hjcai/build/etc/ts.confexport TSLIB_PLUGINDIR=/hjcai/build/share/ts/pluginsexport TSLIB_TSEVENTTYPE="H3600"export TSLIB_CALIBFILE=/etc/pointercal4 触摸屏校正先进行触摸屏校正,注释掉build/etc/ts.conf中的dejitter模块,执行build/bin下的ts_calibrate程序,此时会在/etc下生成pointercal文件。5 测试拷贝qte3.3.5下examples/hello/hello文件到目标板,修改权限,然后执行./hello –qws发现程序可以用触摸屏控制。关于硬件。 从LCD的型号来来看,与s3c2410兼容得比较好的LCD是Sumsung自己产的LTS系列,如LTS350Q1PD1,LTS350Q1PE1。但是这类型号现在已停产,基本上无法买到。代替的型号是LTV系列,如LTV350QVF04,LTV350QVF05。 我使用的是LTV350QVF05。这是一款3.5寸,由TFT LCD,背光电路,触摸屏,内置驱动四部分组成的LCD模块。由于内置了驱动电路,因此它可以和s3c2410之间可以直接相连,硬件设计简单。少量购买的价格在300左右。 LTV350QVF05通过一个60pin的软平线接口和外面相连,其中除了和s3c2410相连接的信号外,最重要的是它的几个电源信号,包括背光部分的电源。调试硬件,首先要保证它的几个电源信号满足要求。Max1779芯片提供三路电源输出,能很好地满足需求。另外需要提供一个Vcom信号。该信号用于LCD的行翻转,是一个低电平0V,高电平3.3V左右的方波信号。LCD模块内部提供一个M信号,只需要将该信号取反就可以得到Vcom信号。通常会搭一个可调的运放电路来实现,调整放大倍数和偏移可以改变屏的亮度和对比度。 在调试好几个电源信号后,上电,应该可以把屏点亮。起初应该是白屏。 下面介绍驱动的移植。 关于驱动移植。 网上可以找到代码s3c2410fb.c,基本上可以直接使用。移植的基本步骤是:1. 添加s3c2410fb.c到drivers/video目录下。2. 在s3c2410fb.c中添加适当的LCD初始化代码。LTV350QV接口中有一个spi接口用来启动LCD,设计中可以采用gpio口来模拟spi口输出控制信号。编写一个初始化函数,然后在s3c2410fb_init函数中调用即可。3. 修改video目录的Kconfig和Makefile,保证s3c2410fb.c被编译进内核。4. 在arch/arm/mach-s3c2410/mach-smdk2410.c中添加static struct s3c2410fb_mach_info smdk2410_lcd_platdata结构。该结构的参数用于设置s3c2410的LCD控制寄存器,需要认真根据自己的LCD参数来设置。包括分辨率、帧频、图像格式等参数。5. 在arch/arm/mach-s3c2410/mach-smdk2410.c函数smdk2410_map_io中添加代码:set_s3c2410fb_info(&smdk2410_lcd_platdata)6. 在arch/arm/mach-s3c2410/devs.c中添加以下代码:static struct s3c2410fb_mach_info s3c2410fb_info;void __init set_s3c2410fb_info(struct s3c2410fb_mach_info *hard_s3c2410fb_info){ memcpy(&s3c2410fb_info,hard_s3c2410fb_info,sizeof(struct s3c2410fb_mach_info)); s3c_device_lcd.dev.platform_data = &s3c2410fb_info;}EXPORT_SYMBOL(set_s3c2410fb_info);7. 配置内核,添加对LCD的支持,包括启动logo(小企鹅)的支持。 如果启动后可以看见小企鹅,说明LCD驱动移植成功。 可能的问题:1. smdk2410_lcd_platdata结构中帧频(Vsync的频率)的设置不能高于LCD的最高帧频,可以增大lcdcon1中clkval的值Vclk,进而降低Vsync。2. 图像深度最好设为16bpp,我用过24bpp,结果无法显示企鹅,可能是内核驱动本身不支持。3. 如果过几分钟后,图像没了。注释掉drivers/char/vt.c中的blank_screen_t()函数内容。调试过程:按照以上步骤做好后,在终端输入命令:make bzImage确保linux-2.6.14/include/asm/arch-s3c2410/s3c2410_ts.h有该文件出现以下错误:
CC arch/arm/mach-s3c2410/mach-smdk2410.oarch/arm/mach-s3c2410/mach-smdk2410.c:131: error: variable `sbc2410_ts_cfg' has initializer but incomplete typearch/arm/mach-s3c2410/mach-smdk2410.c:132: error: unknown field `delay' specified in initializerarch/arm/mach-s3c2410/mach-smdk2410.c:132: warning: excess elements in struct initializerarch/arm/mach-s3c2410/mach-smdk2410.c:132: warning: (near initialization for `sbc2410_ts_cfg')arch/arm/mach-s3c2410/mach-smdk2410.c:133: error: unknown field `presc' specified in initializerarch/arm/mach-s3c2410/mach-smdk2410.c:133: warning: excess elements in struct initializerarch/arm/mach-s3c2410/mach-smdk2410.c:133: warning: (near initialization for `sbc2410_ts_cfg')arch/arm/mach-s3c2410/mach-smdk2410.c:134: error: unknown field `oversampling_shift' specified in initializerarch/arm/mach-s3c2410/mach-smdk2410.c:134: warning: excess elements in struct initializerarch/arm/mach-s3c2410/mach-smdk2410.c:134: warning: (near initialization for `sbc2410_ts_cfg')arch/arm/mach-s3c2410/mach-smdk2410.c: In function `smdk2410_map_io':arch/arm/mach-s3c2410/mach-smdk2410.c:143: warning: implicit declaration of function `set_s3c2410ts_info'arch/arm/mach-s3c2410/mach-smdk2410.c: At top level:arch/arm/mach-s3c2410/mach-smdk2410.c:131: error: storage size of `sbc2410_ts_cfg' isn't knownmake[1]: *** [arch/arm/mach-s3c2410/mach-smdk2410.o] 错误 1make: *** [arch/arm/mach-s3c2410] 错误 2在arch/arm/mach-s3c2410/devs.c文件中添加如下几行:
#include <asm/arch/s3c2440_ts.h> 在 /linux-2.6.14/arch/arm/mach-s3c2410/mach-smdk2410.c, 中增加如下内容:
#include <asm/arch/s3c2440_ts.h> 重新编译,有下面的错误:CC drivers/input/touchscreen/s3c2410_ts.odrivers/input/touchscreen/s3c2410_ts.c: In function `touch_timer_fire':drivers/input/touchscreen/s3c2410_ts.c:145: error: called object is not a functiondrivers/input/touchscreen/s3c2410_ts.c:154: error: called object is not a functiondrivers/input/touchscreen/s3c2410_ts.c: In function `stylus_action':drivers/input/touchscreen/s3c2410_ts.c:196: error: called object is not a functiondrivers/input/touchscreen/s3c2410_ts.c:200: error: called object is not a functiondrivers/input/touchscreen/s3c2410_ts.c: In function `s3c2410ts_probe':drivers/input/touchscreen/s3c2410_ts.c:261: error: called object is not a functiondrivers/input/touchscreen/s3c2410_ts.c: In function `touch_timer_fire':drivers/input/touchscreen/s3c2410_ts.c:145: warning: statement with no effectdrivers/input/touchscreen/s3c2410_ts.c:154: warning: statement with no effectdrivers/input/touchscreen/s3c2410_ts.c: In function `stylus_action':drivers/input/touchscreen/s3c2410_ts.c:196: warning: statement with no effectdrivers/input/touchscreen/s3c2410_ts.c:200: warning: statement with no effectdrivers/input/touchscreen/s3c2410_ts.c: In function `s3c2410ts_probe':drivers/input/touchscreen/s3c2410_ts.c:261: warning: statement with no effectmake[3]: *** [drivers/input/touchscreen/s3c2410_ts.o] 错误 1make[2]: *** [drivers/input/touchscreen] 错误 2make[1]: *** [drivers/input] 错误 2make: *** [drivers] 错误 2在文件位置在 include/asm-arm/arch-s3c2410/regs-adc.h, 并在其添加如下内容#define S3C2410_ADCTSC_XY_PST_N (0x0<<0)#define S3C2410_ADCTSC_XY_PST_X (0x1<<0)#define S3C2410_ADCTSC_XY_PST_Y (0x2<<0)#define S3C2410_ADCTSC_XY_PST_W (0x3<<0)但好象没效果。下面是使用胡军国给的tsFrom军国的s3c2410_ts.c和s3c2410_ts.h(需复制到linux-2.6.14/include/asm/arch)文件,$make bzImage出现以下错误:CC drivers/input/touchscreen/s3c2410_ts.odrivers/input/touchscreen/s3c2410_ts.c:107:1: warning: "IRQ_HANDLED" redefinedIn file included from include/linux/rcuref.h:36,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -