【Linux高级驱动】触摸屏驱动的移植
触摸屏驱动的移植
流程
注意:看框架图
1.添加input.c组件
Device Drivers --->
Input device support --->
Generic input layer (needed for keyboard, mouse, ...)
2.添加evdev.c组件
Input device support --->
<*> Event interface
3.添加s3c2410_ts.c触摸屏驱动
修改driver/input/touchscreen/Kconfig
tristate "Samsung S3C2410/generic touchscreen input driver"
depends on ARCH_S3C2410 || SAMSUNG_DEV_TS || ARCH_S5PC100 //后面的ARCH_S5PC100为新添加的
select S3C_ADC
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
配置内核选项
Input device support --->
-*- Generic input layer (needed for keyboard, mouse, ...)
[*] Touchscreens --->
<*>Samsung S3C2410/generic touchscreen input driver
4.添加设备资源(dev-ts.c)
vi arch/arm/mach-s5pc100/Kconfig
bool "SMDKC100"
select CPU_S5PC100
select S3C_DEV_FB
select S3C_DEV_I2C1
select S3C_DEV_HSMMC
select S3C_DEV_HSMMC1
select S3C_DEV_HSMMC2
select S5PC100_SETUP_FB_24BPP
select S5PC100_SETUP_I2C1
select S5PC100_SETUP_SDHCI
select S3C_DEV_LED
select S3C_DEV_RTC
select SAMSUNG_DEV_TS //添加的内容
help
Machine support for the Samsung SMDKC100
vi arch/arm/mach-s5pc100/mach-smdkc100.c
.oversampling_shift ,
};
static struct platform_device *smdkc100_devices[] __initdata = {
&s3c_device_i2c0,
&s3c_device_i2c1,
&s3c_device_fb,
&s3c_device_hsmmc0,
&s3c_device_hsmmc1,
&s3c_device_hsmmc2,
&smdkc100_lcd_powerdev,
&s5pc100_device_iis0,
&s5pc100_device_ac97,
#ifdef CONFIG_DM9000
&s5pc100_device_dm9000,
#endif
&fsled_device,
&s3c_device_rtc,
&s3c_device_ts, //添加的内容
};
static void __init smdkc100_machine_init(void)
{
...
s3c24xx_ts_set_platdata(&s5pc_tscfg); //s3c_device_ts.dev.platform_data =&s5pc_tscfg
...
}
5.修改头文件
vi arch/arm/mach-s5pc100/include/mach/map.h
6.添加adc资源(dev-adc.c)
vi arch/arm/mach-s5pc100/Kconfig
bool "SMDKC100"
select CPU_S5PC100
select S3C_DEV_FB
select S3C_DEV_I2C1
select S3C_DEV_HSMMC
select S3C_DEV_HSMMC1
select S3C_DEV_HSMMC2
select S5PC100_SETUP_FB_24BPP
select S5PC100_SETUP_I2C1
select S5PC100_SETUP_SDHCI
select S3C_DEV_LED
select S3C_DEV_RTC
select SAMSUNG_DEV_TS
select SAMSUNG_DEV_ADC //添加的内容
help
Machine support for the Samsung SMDKC100
vi arch/arm/mach-s5pc100/mach-smdkc100.c
&s3c_device_i2c0,
&s3c_device_i2c1,
&s3c_device_fb,
&s3c_device_hsmmc0,
&s3c_device_hsmmc1,
&s3c_device_hsmmc2,
&smdkc100_lcd_powerdev,
&s5pc100_device_iis0,
&s5pc100_device_ac97,
#ifdef CONFIG_DM9000
&s5pc100_device_dm9000,
#endif
&fsled_device,
&s3c_device_rtc,
&s3c_device_ts,
&s3c_device_adc //添加的内容
};
测试方式
测试方法1.驱动调试
在触摸屏驱动中s3c2410_ts.c文件的,触摸屏中断服务程序中添加如下代码
{
printk(KERN_INFO "%s():%d\n",__func__,__LINE__);
...
}
当点击触摸屏的时候,出现如下现象:
s3c_adc_start: failed to find adc //找不到ADC
问题解决:分析s3c_adc_start函数
if (!adc) {
printk(KERN_ERR "%s: failed to find adc\n", __func__);
return -EINVAL;
}
搜索adc_dev
adc_dev = adc;
static struct platform_device_id s3c_adc_driver_ids[] = {
{
.name = "s3c24xx-adc",
.driver_data = TYPE_S3C24XX,
},{
.name = "s3c64xx-adc",
.driver_data = TYPE_S3C64XX,
},
{ }
};
static struct platform_driver s3c_adc_driver = {
.id_table = s3c_adc_driver_ids, //按id.name匹配
.driver = {
.name = "s3c-adc",
.owner = THIS_MODULE,
},
.probe = s3c_adc_probe,
.remove = __devexit_p(s3c_adc_remove),
.suspend = s3c_adc_suspend,
.resume = s3c_adc_resume,
};
但是在dev-adc.c文件
.num_resources = ARRAY_SIZE(s3c_adc_resource),
.resource = s3c_adc_resource,
};
解决方法:
{
.name = "s3c24xx-adc",
.driver_data = TYPE_S3C24XX,
},{
.name = "s3c64xx-adc",
.driver_data = TYPE_S3C64XX,
},{
.name = "samsung-adc",
.driver_data = TYPE_S3C64XX,
},
{ }
};
测试方法2:移植tslib库:校准程序
2.1 tslib库的移植
1.拷贝tslib-1.4.tar.gz到ubutun的工作目录,如/home/jason/project
2.解压缩
tar -xvf tslib-1.4.tar.gz
3.配置
sudo apt-get install libtool
cd tslib
./autogen.sh
mkdir tmp
echo "ac_cv_func_mallo_0_nonnull=yes">arm-unknown-linux-gnueabi.cache
./configure --host=arm-unknown-linux-gnueabi --prefix=$(pwd)/tmp --cache-file=arm-unknown-linux-gnueabi.cache
4.编译(make)
ts_test.c:(.text+0x1e4): undefined reference to `rpl_malloc'
解决方法:将config.h.in里的 #undef malloc屏蔽掉
5.安装
make install
6.cd tmp
cp * /opt/rootfs
7.cd /opt/rootfs/lib
mkdir ts
8.cp tslib/plugins /opt/wlwfs/lib/ts
9.修改/opt/wlwfs/etc/ts.conf第一行(去掉#号和第一个空格)
#module_raw input
改为
module_raw input
10.修改etc/profile文件
vi etc/profile
在其中添加如下代码
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/lib/ts
export TSLIB_CONSOLEDEVICE=/dev/tty
export TSLIB_FBDEVICE=/dev/fb0 //lcd
记得执行:
source etc/profile
2.2 移植LCD驱动
vi linux-2.6.35.5/driver/video/Kconfig
tristate hardware windows whereas the S3C24XX series
currently only have two.
Currently the support is only for the S3C6400 and S3C6410 SoCs.
make menuconfig
编译内核:
make zImage
2.3 运行tslib库
selected device is not a touchscreen I understand
问题1:屏幕大小不对(480*272)
问题2:tslib库认为我们的设备不是触摸屏设备
解决问题1:
修改大小
vi arch/arm/mach_s5pc100/mach_smdkc100.c
.left_margin ,
.right_margin ,
.upper_margin ,
.lower_margin ,
.hsync_len ,
.vsync_len ,
.xres ,
.yres ,
},
.max_bpp ,
.default_bpp ,
};
解决问题2:
到tslib库里面,搜索selected device is not a touchscreen I understand看它怎么样认为才是一个触摸屏设备
plugins/input-raw.c:61: fprintf(stderr, "selected device is not a touchscreen I understand\n");
vi plugins/input-raw.c +61
fprintf(stderr, "selected device is not a touchscreen I understand\n");
}
由上面的代码可知,触摸屏应该还要产生压力事件
所以,我们应该修改触摸屏驱动,
vi driver/input/touchsrceen/s3c2410_ts.c
input_set_abs_params(ts.input, ABS_Y, , , , );
input_set_abs_params(ts.input, ABS_PRESSURE, , , , ); ); );
input_sync(ts.input);
...
...
}); );
input_sync(ts.input);
...
}
2.4 再次运行tslib库
ts_calibrate //需要分别点击5次
ts_test
@成鹏致远
(blogs:http://lcw.cnblogs.com)
(email:wwwlllll@126.com)
(qq:552158509)
【Linux高级驱动】触摸屏驱动的移植的更多相关文章
- ARM-Linux驱动-触摸屏驱动分析
出处:http://blog.csdn.net/geekcome/article/details/6580981 硬件平台:FL2440 内核版本:2.6.28 主机平台:Ubuntu 11.04 内 ...
- Linux/Android——usb触摸屏驱动 - usbtouchscreen (一)【转】
本文转载自:http://blog.csdn.net/jscese/article/details/41827495 最近需要往TV上装一个触摸屏设备,现在比较常见的就是使用usb接口的触摸框,适用于 ...
- Linux高级字符设备驱动
转载:http://www.linuxidc.com/Linux/2012-05/60469p4.htm 1.什么是Poll方法,功能是什么? 2.Select系统调用(功能) Select ...
- linux 高级字符设备驱动 ioctl操作介绍 例程分析实现【转】
转自:http://my.oschina.net/u/274829/blog/285014 1,ioctl介绍 ioctl控制设备读写数据以及关闭等. 用户空间函数原型:int ioctl(int f ...
- Linux高级字符设备驱动 poll方法(select多路监控原理与实现)
1.什么是Poll方法,功能是什么? 2.Select系统调用(功能) Select系统调用用于多路监控,当没有一个文件满足要求时,select将阻塞调用进程. int selec ...
- linux 触摸屏驱动
目录 linux 触摸屏驱动 输入子系统怎么写? 触摸屏事件 事件分类 事件设置 硬件配置 设计思路 完整程序 测试 ts_lib 使用 问题小结 title: linux 触摸屏驱动 tags: l ...
- 基于FT5x06嵌入式Linux电容触摸屏驱动
**************************************************************************************************** ...
- 基于设备树的TQ2440触摸屏驱动移植
平台 开发板:tq2440 内核:Linux-4.9 u-boot:u-boot-2015.04 概述 之前移植了LCD驱动,下面继续移植触摸屏驱动,然后将tslib也移植上去. 正文 一.移植触 ...
- Linux学习: 触摸屏驱动
一.Linux输入子系统的结构: 二.触摸屏驱动代码: s3c_ts.c #include <linux/errno.h> #include <linux/kernel.h> ...
随机推荐
- 网页图表Highcharts实践教程之认识Highcharts
网页图表Highcharts实践教程之认识Highcharts 认识Highcharts Highcharts是国际知名的一款图表插件.它完全使用Javascript编写实现.其结构清晰,使用简单.开 ...
- 深港DJ好听的歌曲
好听女声 Dj陈爷-全中文全国语慢歌连版音乐挑选磁性女声翻唱慢摇串烧 http://www.vvvdj.com/play/154270.html DjPad仔-全中文国粤语Rnb音乐清风主流吃鸡学猫叫 ...
- [TC14126]BagAndCards
[TC14126]BagAndCards 题目大意: 有\(n(n\le500)\)个袋子,第\(i\)个袋子里有\(count[i][j]\)张值为\(j(j\le m\le500)\)的牌.给一个 ...
- JVM的Client模式与Server模式
概述 JVM有两种运行模式Server与Client.两种模式的区别在于,Client模式启动速度较快,Server模式启动较慢:但是启动进入稳定期长期运行之后Server模式的程序运行速度比Clie ...
- U3D面试题系列二
高频问题: 一.什么是渲染管道? 是指在显示器上为了显示出图像而经过的一系列必要操作. 渲染管道中的很多步骤,都要将几何物体从一个坐标系中变换到另一个坐标系中去. 主要步骤有: 本地坐标->视图 ...
- unity小知识了解
在搜索栏的右侧有三个按钮,单击第一个按钮,弹出相应菜单,可以根据目标类型过滤搜索结果.[按钮从左到右] 第二个按钮,提供素材标签来过滤搜索结果,可以自定义标签. 第三个按钮,提供了将搜索结果添加到前面 ...
- EasyUI学习总结(六)——EasyUI布局
一.EasyUI布局介绍 easyUI布局容器包括东.西.南.北.中五个区域,其中中心面板是必须的,而东.西.南.北这四个面板是可选的,如果布局里面不需要东.西.南.北这四个面板,那么可以把相应的di ...
- selenium之关于 chromedriver的安装和使用
转自:https://blog.csdn.net/d77808675/article/details/79016271 最近在学习爬虫,用到了selenium 环境:Windows,python3 但 ...
- centos npm 安装后 command not found
ok,
- 你真的会用Gson吗?Gson使用指南(1)
JSON (官网) 是一种文本形式的数据交换格式,它比XML更轻量.比二进制容易阅读和编写,调式也更加方便.其重要性不言而喻.解析和生成的方式很多,Java中最常用的类库有:JSON-Java.Gso ...