3951|0

3836

帖子

19

TA的资源

纯净的硅(中级)

楼主
 

S3C6410 Google Android 进阶 [复制链接]

转自:www.embed-training.com/


触摸屏篇:
Samsung-2.6.28 Patch:

S3C6410 Android 触摸屏校准可以在应用层用tslib来触准,生成校准文件,也可以将校准数据直接写到内核触摸屏驱动里面。

下面我将XXXX6410 2.6.28的android的触摸屏patch以及我的2.6.24 BSP 代码补丁列出来,这里主要是借鉴了Openmoko ben的patch !

  1. ---samsung-ap-2.6.28/drivers/input/touchscreen/s3c-ts.c 2009-06-13 17:39:57.000000000 +0800
  2. +++ s3c-ts.c 2009-08-17 15:38:22.000000000 +0800
  3. @@ -62,6 +62,9 @@
  4. #define CONFIG_TOUCHSCREEN_S3C_DEBUG
  5. #undef CONFIG_TOUCHSCREEN_S3C_DEBUG

  6. +#define CONFIG_ANDROID_TOUCHSCREEN_S3C_DEBUG
  7. +#undef CONFIG_ANDROID_TOUCHSCREEN_S3C_DEBUG
  8. +
  9. /* For ts->dev.id.version */
  10. #define S3C_TSVERSION 0x0101

  11. @@ -75,13 +78,20 @@

  12. #define DEBUG_LVL KERN_DEBUG

  13. +#ifdef CONFIG_S3CTS_ANDROID
  14. + #ifdef CONFIG_MACH_XXXX6410
  15. + #define ANDROID_TS_RESOLUTION_X 320
  16. + #define ANDROID_TS_RESOLUTION_Y 480
  17. + static int pointercal[7]={2701, 7, -12500804, -7, 3326, -11336568, 65536}; // For XXXXS3C6410
  18. + #endif
  19. +#endif

  20. /* Touchscreen default configuration */
  21. struct s3c_ts_mach_info s3c_ts_default_cfg __initdata = {
  22. .delay = 10000,
  23. .presc = 49,
  24. .oversampling_shift = 2,
  25. - .resol_bit = 10
  26. + .resol_bit = 10,
  27. };

  28. /*
  29. @@ -100,6 +110,11 @@
  30. unsigned long data1;
  31. int updown;

  32. +#ifdef CONFIG_S3CTS_ANDROID
  33. + unsigned long xtemp, ytemp;
  34. + unsigned long x, y;
  35. +#endif
  36. +
  37. data0 = readl(ts_base+S3C_ADCDAT0);
  38. data1 = readl(ts_base+S3C_ADCDAT1);

  39. @@ -115,13 +130,46 @@
  40. printk(KERN_INFO "T: %06d, X: %03ld, Y: %03ld\n", (int)tv.tv_usec, ts->xp, ts->yp);
  41. }
  42. #endif
  43. +#ifdef CONFIG_S3CTS_ANDROID
  44. + xtemp = ts->xp;
  45. + ytemp = ts->yp;
  46. +
  47. + x = ( pointercal[2] + pointercal[0]*xtemp + pointercal[1]*ytemp ) / pointercal[6];
  48. + y = ( pointercal[5] + pointercal[3]*xtemp + pointercal[4]*ytemp ) / pointercal[6];

  49. +#ifdef CONFIG_ANDROID_TOUCHSCREEN_S3C_DEBUG
  50. + printk("pre: x, y = %d, %d\n", x, y);
  51. +#endif
  52. + if( x>ANDROID_TS_RESOLUTION_X )
  53. + x = ANDROID_TS_RESOLUTION_X;
  54. + else if(x < 0)
  55. + x = 0;
  56. +
  57. + if( y>ANDROID_TS_RESOLUTION_Y )
  58. + y = ANDROID_TS_RESOLUTION_Y;
  59. + else if(y < 0)
  60. + y = 0;
  61. +
  62. + if( (x<=ANDROID_TS_RESOLUTION_X) && (x>=0) )
  63. + {
  64. + input_report_abs(ts->dev, ABS_X, x);
  65. + input_report_abs(ts->dev, ABS_Y, y);
  66. +
  67. + input_report_key(ts->dev, BTN_TOUCH, 1); /* 向上层应用报告校准数据*/
  68. + input_report_abs(ts->dev, ABS_PRESSURE, 1);
  69. + input_sync(ts->dev);
  70. +#ifdef CONFIG_ANDROID_TOUCHSCREEN_S3C_DEBUG
  71. + printk("x, y = %d, %d\n", x, y);
  72. +#endif
  73. + }
  74. +#else // For X-Windows
  75. input_report_abs(ts->dev, ABS_X, ts->xp);
  76. input_report_abs(ts->dev, ABS_Y, ts->yp);

  77. input_report_key(ts->dev, BTN_TOUCH, 1);
  78. input_report_abs(ts->dev, ABS_PRESSURE, 1);
  79. input_sync(ts->dev);
  80. +#endif
  81. }

  82. ts->xp = 0;
  83. @@ -318,6 +366,12 @@
  84. ts->dev->evbit[0] = ts->dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  85. ts->dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);

  86. +#ifdef CONFIG_S3CTS_ANDROID
  87. + ts->dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y); // for android
  88. + input_set_abs_params(ts->dev, ABS_X, 0, ANDROID_TS_RESOLUTION_X, 0, 0);
  89. + input_set_abs_params(ts->dev, ABS_Y, 0, ANDROID_TS_RESOLUTION_Y, 0, 0);
  90. + input_set_abs_params(ts->dev, ABS_PRESSURE, 0, 1, 0, 0);
  91. +#else
  92. if (s3c_ts_cfg->resol_bit==12) {
  93. input_set_abs_params(ts->dev, ABS_X, 0, 0xFFF, 0, 0);
  94. input_set_abs_params(ts->dev, ABS_Y, 0, 0xFFF, 0, 0);
  95. @@ -328,7 +382,7 @@
  96. }

  97. input_set_abs_params(ts->dev, ABS_PRESSURE, 0, 1, 0, 0);
  98. -
  99. +#endif
  100. sprintf(ts->phys, "input(ts)");

  101. ts->dev->name = s3c_ts_name;

  102. Samsung-ap-2.6.24 BSP Patch
  103. --- drivers/input/touchscreen/s3c-ts.c 2009-08-17 15:46:41.000000000 +0800
  104. +++ /work2/project_study/samsung-ap-2.6.24-6410/drivers/input/touchscreen/s3c-ts.c 2009-05-18 22:20:15.000000000 +0800
  105. @@ -61,11 +61,8 @@
  106. #include
  107. #include

  108. -/*add by tommy for Samsung 6410 Android touchscreen*/
  109. -int axis_table[] = {5025, -18, -14593120, 0, -5132, 56919216, 16}; // from /etc/pointercal by ts_calibrate
  110. -/*end add*/

  111. -//#define CONFIG_TOUCHSCREEN_S3C_DEBUG
  112. +#define CONFIG_TOUCHSCREEN_S3C_DEBUG
  113. #undef CONFIG_TOUCHSCREEN_S3C_DEBUG

  114. /* For ts->dev.id.version */
  115. @@ -117,39 +114,18 @@

  116. #ifdef CONFIG_TOUCHSCREEN_S3C_DEBUG
  117. {
  118. - //struct timeval tv;
  119. - //do_gettimeofday(&tv);
  120. - //printk(KERN_INFO "T: %06d, X: %03ld, Y: %03ld\n", (int)tv.tv_usec, ts->xp, ts->yp);
  121. + struct timeval tv;
  122. + do_gettimeofday(&tv);
  123. + printk(KERN_INFO "T: %06d, X: %03ld, Y: %03ld\n", (int)tv.tv_usec, ts->xp, ts->yp);
  124. }
  125. #endif

  126. -#if 0
  127. - int tmpy;
  128. input_report_abs(ts->dev, ABS_X, ts->xp);
  129. input_report_abs(ts->dev, ABS_Y, ts->yp);
  130. - printk(KERN_ERR "x:%d , y:%d \n", ts->xp, ts->yp);

  131. input_report_key(ts->dev, BTN_TOUCH, 1);
  132. input_report_abs(ts->dev, ABS_PRESSURE, 1);
  133. input_sync(ts->dev);
  134. -#else
  135. - int xraw, yraw, xtmp, ytmp;
  136. - xraw=ts->xp;
  137. - yraw=ts->yp;
  138. - xtmp = (axis_table[2] + axis_table[0]*xraw + axis_table[1]*yraw ) >> axis_table[6];
  139. - ytmp = (axis_table[5] + axis_table[3]*xraw + axis_table[4]*yraw ) >> axis_table[6];
  140. -
  141. - //printk(KERN_ERR "x:%d , y:%d \n", xtmp, ytmp);
  142. -
  143. - //report button touch
  144. - input_report_key(ts->dev, BTN_TOUCH, 1);
  145. -
  146. - input_report_abs(ts->dev, ABS_X, xtmp);
  147. - input_report_abs(ts->dev, ABS_Y, ytmp);
  148. - input_report_abs(ts->dev, ABS_PRESSURE, 1);
  149. - input_sync(ts->dev);
  150. -#endif
  151. -
  152. }

  153. ts->xp = 0;
  154. @@ -163,7 +139,6 @@

  155. ts->count = 0;

  156. - // printk(KERN_ERR "pen up \n");
  157. input_report_key(ts->dev, BTN_TOUCH, 0);
  158. input_report_abs(ts->dev, ABS_PRESSURE, 0);
  159. input_sync(ts->dev);
  160. @@ -328,16 +303,10 @@

  161. ts->dev->evbit[0] = ts->dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  162. ts->dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);


  163. - bitmap_fill(ts->dev->absbit, ABS_MAX);
  164. -
  165. +
  166. #if defined(CONFIG_CPU_S3C2450) || defined(CONFIG_CPU_S3C6410) || defined(CONFIG_CPU_S3C2416)
  167. - input_set_abs_params(ts->dev, ABS_X, 0, 800, 0, 0);
  168. - input_set_abs_params(ts->dev, ABS_Y, 0, 480, 0, 0);
  169. -
  170. - //input_set_abs_params(ts->dev, ABS_X, 0, 0xFFF, 0, 0);
  171. - //input_set_abs_params(ts->dev, ABS_Y, 0, 0xFFF, 0, 0);
  172. + input_set_abs_params(ts->dev, ABS_X, 0, 0xFFF, 0, 0);
  173. + input_set_abs_params(ts->dev, ABS_Y, 0, 0xFFF, 0, 0);
  174. #else
  175. input_set_abs_params(ts->dev, ABS_X, 0, 0x3FF, 0, 0);
  176. input_set_abs_params(ts->dev, ABS_Y, 0, 0x3FF, 0, 0);


  177. Linux will make your life easier
复制代码
点赞 关注

回复
举报
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/7 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表