S5PV210学习笔记三:S5PV210触摸屏驱动移植过程记录

       我参考的朱友鹏课程中的学习课件进行移植,可能我的kernel和文件系统与课程中存在部分微小差异,过程中遇上了一些问题,网上查阅了很多资料,目前都解决掉了,先在此记录下免得忘了。

一、/dev目录下没有/input设备目录

参考解决:dev下没有input 目录和event设备节点

修改/etc/mdev.conf

# Move input devices to input directory

event.*	0:0	0660	@(mkdir -p input&&mv $MDEV input)

mice	0:0	0660	@(mkdir -p input&&mv $MDEV input)

mouse.*	0:0	0660	@(mkdir -p input&&mv $MDEV input)

成功后可以看到:

[@192 /bin]# ls /dev/input/
event0  event1  event2  mice    mouse0  mouse1

二、移植gslX680驱动

1,将驱动源码(gslX680.c gslX680.h gsl_point_id )拷贝到/kernel/derivers/input/touchscreen中

2,修改Makefile,添加

obj-$(CONFIG_TOUCHSCREEN_GSLX680)   +=gslX680.0 gsl_point_id

3,修改Kconfig,添加

config TOUCHSCREEN_GSLX680
    tristate "gslX680 touch driver"
    depends on I2C
    help
      This enables support for gslX680 over I2C based touchscreens.

4,make menuconfig,重新编译make

此时gslX680驱动已成功编译进内核

[@192 /bin]# cat /proc/bus/input/devices
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="s3c-button"
P: Phys=s3c-button/input0
S: Sysfs=/devices/virtual/input/input0
U: Uniq=
H: Handlers=kbd event0 evbug 
B: EV=3
B: KEY=101680 0 10000 40000000

I: Bus=0013 Vendor=dead Product=beef Version=0101
N: Name="S5P TouchScreen"
P: Phys=input(ts)
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=mouse0 event1 evbug 
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003

I: Bus=0018 Vendor=0000 Product=0000 Version=0000
N: Name="gslX680"
P: Phys=
S: Sysfs=/devices/platform/s3c2440-i2c.1/i2c-1/1-0040/input/input2
U: Uniq=
H: Handlers=mouse1 event2 evbug 
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003

[@192 /bin]# 

手指在触摸屏滑动时,cat /dev/input/event2可打印出坐标信息,不过是乱码。此时即为成功。

三、tslib移植和测试

1,源码准备,解压,配置

# cd tslib
# ./autogen.sh
# echo "ac_cv_func_malloc_0_nonnull=yes">arm-linux.cache 
# mkdir /opt/tslib
# ./configure --prefix=/opt/tslib --host=arm-linux --cache-file=arm-linux.cache

2,编译和安装

参考:移植tslib 的详细步骤:

# make
# make install

成功后会在安装目录生成四个文件夹:

include               lib                 etc                 bin

          生成的库位于lib中,该目录下还有一个子目录ts,它包含了许多校准用到的库(如input.so等)。

          etc下的ts.conf为配置文件,bin目录下为校准、测试工具(如校准的ts_calibrate,测试用的ts_test)。

         然后把这个四个文件复制到根文件系统的根目录下,注意:我是将这些文件夹里的库和可执行程序考出来到根文件系统中对应的目录的。

3,部署,配置文件ts.conf内容如下:

module_raw input (去掉前面的# 和空格,其他的保持不变)
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear

module_raw有许多种,这里只使用input(即Linux的input子系统,设备文件名称为/dev/event1)/dev/event0为触模屏的设备节点

4,导出环境变量

定义tslib运行需要的环境变量,/etc/profile文件中添加如下:

export TSLIB_TSDEVICE=/dev/input/event2
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib
export TS_INFO_FILE=/sys/class/input/input2/uevent

5,运行与测试

这里我出现了三个问题,两个在朱老师视频中已讲到,

(A)No raw modules loaded.
           ts_config: No such file or directory
          解决:在etc/ts.conf中打开module raw input这行的注释就行了。

(B)执行 ts_calibrate 出现了如下错误:

selected device is not a touchscreen I understand

原因是内核用的EV_VERSION为0x0100001,交叉编译工具EV_VERSION为0x0100000 把这两个修改成一样就可以了。

这个问题我是参考了这里的方法:

[经验] 移植tslib库出现selected device is not a touchscreen I understand的解决方法

修改文件路径:

linux源码路径下:kernel/include/linux/input.h
编译器安装路径下:/usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/usr/include/linux/input.h

将内核源代码里的include/linux/input.h中的

#define EV_VERSION0x010001

改为:

#define EV_VERSION0x010000

(C)修改屏幕分辨率

参考:应用层为何不能设置分辨率

移植的核心是lcd参数的更改:主要是在mach-x210.c文件中

kernel/arch/arm/mach-s5pv210/mach-x210.c
#define S5PV210_LCD_WIDTH 800
#define S5PV210_LCD_HEIGHT 600
修改为:
#define S5PV210_LCD_WIDTH 1024
#define S5PV210_LCD_HEIGHT 600

至此驱动移植才完成。

发布了34 篇原创文章 · 获赞 15 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/fuhanga123/article/details/103923098