idea6410 linux-3.6.6 ts触摸屏移植

//--------------------------------------------------------------------------------------------

// 作者:longtian635241(longtian_huang@urbetter.com

// 论坛ID:idea6410

// 版权:idea6410

// 平台:友坚idea6410开发板

// 发布日期:2012-11-19

// 最后修改:2012-11-19

//http://www.urbetter.com/main.asp

//----------------------------------------------------------------------------------------------

将友坚android2.3内核linux-2.6.36中的dev-ts.c  ts 板载初始化和platform 资源初始化文件。

1、arch/arm/mach-s3c64xx/mach-smdk6410.c

注销掉头文件  #include<plat/ts.h>
添加头文件    #include<mach/ts.h>
copy arch/arm/mach-s3c64xx/include/mach/ts.h 到目标内核目录并添加:

#include <linux/sizes.h>
#include <linux/gfp.h>

arch/arm/mach-s3c64xx/dev-ts.c:27: error: 'SZ_256' undeclared here (not in a function)
arch/arm/mach-s3c64xx/dev-ts.c: In function 's3c_ts_set_platdata':
arch/arm/mach-s3c64xx/dev-ts.c:58: error: 'GFP_KERNEL' undeclared (first use in this function)
arch/arm/mach-s3c64xx/dev-ts.c:58: error: (Each undeclared identifier is reported only once
arch/arm/mach-s3c64xx/dev-ts.c:58: error: for each function it appears in.)
arch/arm/mach-s3c64xx/dev-ts.c:58: warning: passing argument 3 of 'kmemdup' makes integer from pointer without a cast
arch/arm/mach-s3c64xx/dev-ts.c: At top level:
arch/arm/mach-s3c64xx/dev-ts.c:64: warning: data definition has no type or storage class
arch/arm/mach-s3c64xx/dev-ts.c:64: warning: type defaults to 'int' in declaration of 'EXPORT_SYMBOL'
arch/arm/mach-s3c64xx/dev-ts.c:64: warning: parameter names (without types) in function declaration
make[1]: *** [arch/arm/mach-s3c64xx/dev-ts.o] 错误 1
make: *** [arch/arm/mach-s3c64xx] 错误 2

在include/linux/interrupt中添加

#define IRQF_SAMPLE_RANDOM 0x00000040

drivers/input/touchscreen/s3c-ts.c: In function 's3c_ts_probe':
drivers/input/touchscreen/s3c-ts.c:494: error: 'IRQF_SAMPLE_RANDOM' undeclared (first use in this function)
drivers/input/touchscreen/s3c-ts.c:494: error: (Each undeclared identifier is reported only once
drivers/input/touchscreen/s3c-ts.c:494: error: for each function it appears in.)


copy arch/arm/mach-s3c64xx/dev-ts.c 到目标内核目录在 arch/arm/mach-s3c64xx/Makefile 中添加 
   obj-$(CONFIG_TOUCHSCREEN_S3C)   += dev-ts.o                  

2、  添加 ts  设备初始化 ,在smdk6410_machine_init ()  结构体中

   

 //s3c24xx_ts_set_platdata(NULL);  

s3c_ts_set_platdata(&s3c_ts_platform);

 

    添加结构体s3c_ts_platform

static struct s3c_ts_mach_info s3c_ts_platform __initdata = {

    .delay            = 10000,

    .presc            = 49,

    .oversampling_shift    = 2,

    .resol_bit        = 12,        

    .s3c_adc_con        = ADC_TYPE_2,    

 

};

3、把友坚恒天官方的s3c-tc.c拷贝到drivers/input/touchscreen/ (拷贝android2.3内核的linux-2.6.36中的)

     3、1      修改 drivers/input/touchscreen/Makefile 
                           添加 obj-$(CONFIG_TOUCHSCREEN_S3C)     += s3c-ts.o

     3、2       修改 drivers/input/tourch/screen/Kconfig
  添加 config TOUCHSCREEN_S3C 

config TOUCHSCREEN_S3C

tristate "S3C touchscreen driver"

depends on ARCH_S3C2410 || ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX

default y

help

Say Y here to enable the driver for the touchscreen on the

S3C SMDK board.

        4、在arch/arm/ plat-samsung/include/plat/regs-adc.h的后面添加以下代码:

 

/*--------------------------- Common definitions for S3C  ---------------------------*/
/* The following definitions will be applied to S3C24XX, S3C64XX, S5PC1XX.      */
/*-----------------------------------------------------------------------------------*/

#define S3C_ADCREG(x)    (x)

#define S3C_ADCCON      S3C_ADCREG(0x00)
#define S3C_ADCTSC     S3C_ADCREG(0x04)
#define S3C_ADCDLY      S3C_ADCREG(0x08)
#define S3C_ADCDAT0      S3C_ADCREG(0x0C)
#define S3C_ADCDAT1      S3C_ADCREG(0x10)
#define S3C_ADCUPDN   S3C_ADCREG(0x14)
#define S3C_ADCCLRINT   S3C_ADCREG(0x18)
#define S3C_ADCMUX   S3C_ADCREG(0x1C)
#define S3C_ADCCLRWK   S3C_ADCREG(0x20)

/* ADCCON Register Bits */
#define S3C_ADCCON_RESSEL_10BIT  (0x0<<16)
#define S3C_ADCCON_RESSEL_12BIT  (0x1<<16)
#define S3C_ADCCON_ECFLG  (1<<15)
#define S3C_ADCCON_PRSCEN  (1<<14)
#define S3C_ADCCON_PRSCVL(x)  (((x)&0xFF)<<6)
#define S3C_ADCCON_PRSCVLMASK  (0xFF<<6)
#define S3C_ADCCON_SELMUX(x)  (((x)&0x7)<<3)
#define S3C_ADCCON_SELMUX_1(x)  (((x)&0xF)<<0)
#define S3C_ADCCON_MUXMASK  (0x7<<3)
#define S3C_ADCCON_RESSEL_10BIT_1 (0x0<<3)
#define S3C_ADCCON_RESSEL_12BIT_1 (0x1<<3)
#define S3C_ADCCON_STDBM  (1<<2)
#define S3C_ADCCON_READ_START  (1<<1)
#define S3C_ADCCON_ENABLE_START  (1<<0)
#define S3C_ADCCON_STARTMASK  (0x3<<0)

/* ADCTSC Register Bits */
#define S3C_ADCTSC_UD_SEN  (1<<8)
#define S3C_ADCTSC_YM_SEN  (1<<7)
#define S3C_ADCTSC_YP_SEN  (1<<6)
#define S3C_ADCTSC_XM_SEN  (1<<5)
#define S3C_ADCTSC_XP_SEN  (1<<4)
#define S3C_ADCTSC_PULL_UP_DISABLE (1<<3)
#define S3C_ADCTSC_AUTO_PST  (1<<2)
#define S3C_ADCTSC_XY_PST(x)  (((x)&0x3)<<0)

/* ADCDAT0 Bits */
#define S3C_ADCDAT0_UPDOWN  (1<<15)
#define S3C_ADCDAT0_AUTO_PST  (1<<14)
#define S3C_ADCDAT0_XY_PST  (0x3<<12)
#define S3C_ADCDAT0_XPDATA_MASK  (0x03FF)
#define S3C_ADCDAT0_XPDATA_MASK_12BIT (0x0FFF)

/* ADCDAT1 Bits */
#define S3C_ADCDAT1_UPDOWN  (1<<15)
#define S3C_ADCDAT1_AUTO_PST  (1<<14)
#define S3C_ADCDAT1_XY_PST  (0x3<<12)
#define S3C_ADCDAT1_YPDATA_MASK  (0x03FF)
#define S3C_ADCDAT1_YPDATA_MASK_12BIT (0x0FFF)

         5、在arch/arm/plat-samsung/devs.c中添加

//add by hcm
#undef CONFIG_SAMSUNG_DEV_TS
//add hcm end
#ifdef CONFIG_SAMSUNG_DEV_TS

static struct resource s3c_ts_resource[] = {
 [0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC, SZ_256),
 [1] = DEFINE_RES_IRQ(IRQ_TC),
};

static struct s3c2410_ts_mach_info default_ts_data __initdata = {
 .delay   = 10000,
 .presc   = 49,
 .oversampling_shift = 2,
};

struct platform_device s3c_device_ts = {
 .name  = "s3c64xx-ts",
 .id  = -1,
 .num_resources = ARRAY_SIZE(s3c_ts_resource),
 .resource = s3c_ts_resource,
};

void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *pd)
{
 if (!pd)
  pd = &default_ts_data;

 s3c_set_platdata(pd, sizeof(struct s3c2410_ts_mach_info),
    &s3c_device_ts);
}
#endif /* CONFIG_SAMSUNG_DEV_TS */

 

arch/arm/plat-samsung/built-in.o:(.data+0x9a8): multiple definition of `s3c_device_ts'
arch/arm/mach-s3c64xx/built-in.o:(.data+0x3a30): first defined here
make: *** [vmlinux] 错

          6、配置内核:

System Type --->   

          [ ] ADC common driver support (一定不能选,否则占用触摸adc)

Device Drivers --->

    Input device support --->

         <*> Event interface

        [*] Touchscreens --->

<*> S3C touchscreen driver (只选这一个,其他的不要选)

     7、    移植成功serial则显示:

S3C Touchscreen driver, (c) 2008 Samsung Electronics
s3c-ts.c SCREEN_X=800 SCREEN_Y=480
S3C TouchScreen got loaded successfully : 12 bits
input: S3C TouchScreen as /devices/virtual/input/input0

        8、测试

进入界面测试ok,可tslib不能用(转载(*^__^*) 嘻嘻……)(tslib更新请关注后面更新)

在移植tslib库的过程中,出现selected device is not a touchscreen I understand了吗
其实出现这个问题的原因和很简单,就是tslib中的输入系统和内核input系统版本不匹配,当然也有其他原因,这是最常见的情况,先分析一下tslib的代码,看看这句话在什么情况下被打印就知道了
将tslib库中c和H文件加入Source Insight
在 input-raw.c文件中有这么一段代码
static int check_fd(struct tslib_input *i)
{
struct tsdev *ts = i->module.dev;
int version;
u_int32_t bit;
u_int64_t absbit;

if (! ((ioctl(ts->fd, EVIOCGVERSION, &version) >= 0) &&
  (version == EV_VERSION) &&
  (ioctl(ts->fd, EVIOCGBIT(0, sizeof(bit) * 8), &bit) >= 0) &&
  (bit & (1 << EV_ABS)) &&
  (ioctl(ts->fd, EVIOCGBIT(EV_ABS, sizeof(absbit) * 8), &absbit) >= 0) &&
  (absbit & (1 << ABS_X)) &&
  (absbit & (1 << ABS_Y)) && (absbit & (1 << ABS_PRESSURE)))) {
  fprintf(stderr, "selected device is not a touchscreen I understand\n");
  return -1;
}

if (bit & (1 << EV_SYN))
  i->using_syn = 1;

return 0;
}
其中关键的就是version == EV_VERSION这个判断语句,如果这俩不等,那么就会打印出selected device is not a touchscreen I understand


tslib中的input版本号是在交叉编译的时候指定的,赋值给version,而EV_VERSION是内核中的定义的,我做tslib时,用的2.6.39内核,这个EV_VERSION定义在include/linux/input.h中,为0x010001,而tslib中的是和交叉编译器相同,于是查看编译器,在/usr/include/linux/input.h中,指定为0x010000,这俩明显不相等,当然不会满足version == EV_VERSION了,由此可见问题就出现在内核的输入子系统的版本号不匹配的问题

所以,一下提供两种解决方法

1.将内核源代码里的include/linux/input.h中的
    #define EV_VERSION        0x010001
    改为:
    #define EV_VERSION        0x010000
2.将arm交叉编译工具中的头文件库中的
    linux/input.h中的
    #define EV_VERSION        0x010000
    改为
    #define EV_VERSION        0x010001
    再编译tslib库

一般第一种就可以解决问题了,因此,出现上面情况时,先不要急于换版本,如果二者版本不等,那么改一个就可以
 
第二、可能是由于事件不匹配
可以用cat /proc/bus/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
B: PROP=0
B: EV=3
B: KEY=1680 0 0 10000002
 
I: Bus=0013 Vendor=dead Product=beef Version=0101
N: Name="S3C TouchScreen"
P: Phys=input(ts)
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=mouse0 event1
B: PROP=0
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003
 
I: Bus=0003 Vendor=15d9 Product=0a4c Version=0111
N: Name=" USB OPTICAL MOUSE"
P: Phys=usb-s3c24xx-1/input0
S: Sysfs=/devices/platform/s3c2410-ohci/usb1/1-1/1-1:1.0/input/input2
U: Uniq=
H: Handlers=mouse1 event2
B: PROP=0
B: EV=17
B: KEY=70000 0 0 0 0 0 0 0 0
B: REL=103
B: MSC=10
从上可以看出touchscreen的事件为event1,所以在/bin/qtopia中的修改一致:
export TSLIB_TSDEVICE=/dev/input/event1
 
 
友坚最近推出了一款android210,调试了wifi,AVIN,camera,Wcdma,GPS,还有重力加速器,有兴趣的朋友可以关注哦~标配价格990,优惠多多哦(*^__^*) 嘻嘻……
 
 
 
 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值