触摸屏驱动移植(mini2440,linux-2.6.32.7)

触摸屏驱动移植的好文章:

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 �D�D�D>

    Input device support �D�D�D>   

       [*] Touchscreens �D�D�D>

           <*> Samsung S3C2440 touchscreen input driver

           [*]   Samsung S3C2440 touchscreen debug messages

Device Drivers �D�D�D>

    Character devices �D�D�D>

       [*] 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

你可能感兴趣的:(linux,移植,触摸,mini2440,屏驱动)