觸摸屏驅動移植的好文章:
1.http://www.usr.cc/bbs/thread-1467-1-1.html
2. http://hi.baidu.com/428501/blog/item/9d399cfb46219b62024f566d.html
3. http://www.usr.cc/bbs/thread-1476-1-1.html
這裏使用的adc和觸摸屏的驅動來自友善的linux-2.6.29-mini2440-20090708
一、把友善提供的內核中的drivers/char/s3c24xx-adc.h和drivers/char/mini2440_adc.c拷貝到drivers/char目錄下
(1)在mini2440_adc.c中添加頭文件#include <linux/sched.h>
(2)在drivers/char/Kconfig文件中增加如下代碼:
config MINI2440_ADC
bool "ADC driver for FriendlyARM Mini2440/QQ2440 development boards"
depends on ARCH_S3C2440
default y if ARCH_S3C2440
help
this is ADC driver for FriendlyARM Mini2440/QQ2440 development boards
Notes: the touch-screen-driver required this option
(3)在drivers/char/Makefile文件中添加如下代碼:
obj-$(CONFIG_MINI2440_ADC) += mini2440_adc.o
二、把友善提供的內核中的drivers/input/touchscreen/s3c2410_ts.c文件拷貝到drivers/input/touchscreen目錄下,並改名爲s3c2440_ts.c,然後作如下修改:
(1) 增加頭文件件和宏:
#include <mach/gpio-nrs.h>
#include <mach/gpio-fns.h>
#define DEBUG_LVL KERN_DEBUG
(2) 把s3c2410_ts_connect(void)函數改爲:
static inline void s3c2410_ts_connect(void)
{
s3c2410_gpio_cfgpin(S3C2410_GPG(12), S3C2410_GPG12_XMON);
s3c2410_gpio_cfgpin(S3C2410_GPG(13), S3C2410_GPG13_nXPON);
s3c2410_gpio_cfgpin(S3C2410_GPG(14), S3C2410_GPG14_YMON);
s3c2410_gpio_cfgpin(S3C2410_GPG(15), S3C2410_GPG15_nYPON);
}
(3) 在touch_timer_fire(unsigned long data)函數中,input_report_abs(dev,ABS_X,xp)語句之前,增加以下代碼:
#ifdef CONFIG_TOUCHSCREEN_S3C2440_DEBUG
{
struct timeval tv;
do_gettimeofday(&tv);
printk(DEBUG_LVL "T: %06d, X: %03ld, Y: %03ld\n", (int)tv.tv_usec, xp, yp);
printk(KERN_INFO "T: %06d, X: %03ld, Y: %03ld\n", (int)tv.tv_usec, xp, yp);
}
#endif
(4) 在drivers/input/touchscreen/Kconfig文件中,if INPUT_TOUCHSCREEN語句之後添加如下代碼:
config TOUCHSCREEN_S3C2440
tristate "Samsung S3C2440 touchscreen input driver"
depends on ARCH_S3C2440 && INPUT && INPUT_TOUCHSCREEN
select SERIO
help
Say Y here if you have the s3c2440 touchscreen.
If unsure, say N.
To compile this driver as a module, choose M here: the
module will be called s3c2440_ts.
config TOUCHSCREEN_S3C2440_DEBUG
boolean "Samsung S3C2440 touchscreen debug messages"
depends on TOUCHSCREEN_S3C2440
help
Select this if you want debug messages
(5) 在drivers/input/touchscreen/Makefile文件中的最後一行添加如下代碼:
obj-$(CONFIG_TOUCHSCREEN_S3C2440) += s3c2440_ts.o
三、配置內核
Device Drivers ―――>
Input device support ―――>
[*] Touchscreens ―――>
<*> Samsung S3C2440 touchscreen input driver
[*] Samsung S3C2440 touchscreen debug messages
Device Drivers ―――>
Character devices ―――>
[*] ADC driver for FriendlyARM Mini2440/QQ2440 development boards
四、測試
點擊觸摸屏,效果如下圖:
移植驅動常見情況:
假設有A.h、A.c、B.c三個文件,A.c和B.c都包含頭文件A.h
在A.c文件中定義了一個結構體變量x,而在B.c文件中又要使用該結構變量x,怎麼辦呢?解決辦法如下:
在A.h中將x聲明爲外部變量,然後在A.c中用EXPORT_SYMBOL(x);將x導出
於是,當編譯B.c文件時,遇到使用x變量的語句,編譯器將知道它是一個在別處定義的外部變量,在連接時,將別處定義的x的作用域擴展到本文件。
轉載來自:http://www.cnblogs.com/gumptious/archive/2010/02/21/1670196.html