S3C6410 && Google Android 进阶(一)



                                                                                                 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 !

---samsung-ap-2.6.28/drivers/input/touchscreen/s3c-ts.c    2009-06-13 17:39:57.000000000 +0800
+++ s3c-ts.c    2009-08-17 15:38:22.000000000 +0800
@@ -62,6 +62,9 @@
 #define CONFIG_TOUCHSCREEN_S3C_DEBUG
 #undef CONFIG_TOUCHSCREEN_S3C_DEBUG
 
+#define CONFIG_ANDROID_TOUCHSCREEN_S3C_DEBUG
+#undef CONFIG_ANDROID_TOUCHSCREEN_S3C_DEBUG                        
+
 /* For ts->dev.id.version */
 #define S3C_TSVERSION    0x0101
 
@@ -75,13 +78,20 @@
 
 #define DEBUG_LVL    KERN_DEBUG
 
+#ifdef CONFIG_S3CTS_ANDROID
+    #ifdef CONFIG_MACH_XXXX6410
+        #define ANDROID_TS_RESOLUTION_X    320
+        #define ANDROID_TS_RESOLUTION_Y    480
+        static int pointercal[7]={2701, 7, -12500804, -7, 3326, -11336568, 65536}; // For XXXXS3C6410
+    #endif
+#endif
 
 /* Touchscreen default configuration */
 struct s3c_ts_mach_info s3c_ts_default_cfg __initdata = {
                 .delay =         10000,
                 .presc =         49,
                 .oversampling_shift =     2,
-        .resol_bit =         10
+        .resol_bit =         10,
 };
 
 /*
@@ -100,6 +110,11 @@
     unsigned long data1;
     int updown;
 
+#ifdef CONFIG_S3CTS_ANDROID
+    unsigned long xtemp, ytemp;
+    unsigned long x, y;
+#endif
+
     data0 = readl(ts_base+S3C_ADCDAT0);
     data1 = readl(ts_base+S3C_ADCDAT1);
 
@@ -115,13 +130,46 @@
                 printk(KERN_INFO "T: %06d, X: %03ld, Y: %03ld/n", (int)tv.tv_usec, ts->xp, ts->yp);
             }
 #endif
+#ifdef CONFIG_S3CTS_ANDROID
+            xtemp = ts->xp;
+            ytemp = ts->yp;
+           
+            x = ( pointercal[2] + pointercal[0]*xtemp + pointercal[1]*ytemp ) / pointercal[6];
+            y = ( pointercal[5] + pointercal[3]*xtemp + pointercal[4]*ytemp ) / pointercal[6];
 
+#ifdef CONFIG_ANDROID_TOUCHSCREEN_S3C_DEBUG
+            printk("pre: x, y = %d, %d/n", x, y);
+#endif
+            if( x>ANDROID_TS_RESOLUTION_X )
+                x = ANDROID_TS_RESOLUTION_X;
+            else if(x < 0)
+                x = 0;
+           
+            if( y>ANDROID_TS_RESOLUTION_Y  )
+                y = ANDROID_TS_RESOLUTION_Y;
+            else if(y < 0)
+                y = 0;
+           
+            if( (x<=ANDROID_TS_RESOLUTION_X) && (x>=0) )
+            {
+                input_report_abs(ts->dev, ABS_X, x);
+                input_report_abs(ts->dev, ABS_Y, y);
+           
+                input_report_key(ts->dev, BTN_TOUCH, 1);                                /* 向上层应用报告校准数据*/
+                input_report_abs(ts->dev, ABS_PRESSURE, 1);
+                input_sync(ts->dev);
+#ifdef CONFIG_ANDROID_TOUCHSCREEN_S3C_DEBUG
+                printk("x, y = %d, %d/n", x, y);
+#endif
+            }
+#else    // For X-Windows
             input_report_abs(ts->dev, ABS_X, ts->xp);
             input_report_abs(ts->dev, ABS_Y, ts->yp);
 
             input_report_key(ts->dev, BTN_TOUCH, 1);
             input_report_abs(ts->dev, ABS_PRESSURE, 1);
             input_sync(ts->dev);
+#endif
         }
 
         ts->xp = 0;
@@ -318,6 +366,12 @@
     ts->dev->evbit[0] = ts->dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
     ts->dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
 
+#ifdef CONFIG_S3CTS_ANDROID
+    ts->dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);  // for android
+    input_set_abs_params(ts->dev, ABS_X, 0, ANDROID_TS_RESOLUTION_X, 0, 0);
+    input_set_abs_params(ts->dev, ABS_Y, 0, ANDROID_TS_RESOLUTION_Y, 0, 0);
+    input_set_abs_params(ts->dev, ABS_PRESSURE, 0, 1, 0, 0);
+#else
     if (s3c_ts_cfg->resol_bit==12) {
         input_set_abs_params(ts->dev, ABS_X, 0, 0xFFF, 0, 0);
         input_set_abs_params(ts->dev, ABS_Y, 0, 0xFFF, 0, 0);
@@ -328,7 +382,7 @@
     }
 
     input_set_abs_params(ts->dev, ABS_PRESSURE, 0, 1, 0, 0);
-
+#endif
     sprintf(ts->phys, "input(ts)");
 
     ts->dev->name = s3c_ts_name;

Samsung-ap-2.6.24 BSP Patch
--- drivers/input/touchscreen/s3c-ts.c    2009-08-17 15:46:41.000000000 +0800
+++ /work2/project_study/samsung-ap-2.6.24-6410/drivers/input/touchscreen/s3c-ts.c    2009-05-18 22:20:15.000000000 +0800
@@ -61,11 +61,8 @@
 #include <asm/plat-s3c/ts.h>
 #include <asm/arch/irqs.h>
 
-/*add by tommy for Samsung 6410 Android touchscreen*/
-int axis_table[] = {5025, -18, -14593120, 0, -5132, 56919216, 16}; // from /etc/pointercal by ts_calibrate
-/*end add*/
 
-//#define CONFIG_TOUCHSCREEN_S3C_DEBUG
+#define CONFIG_TOUCHSCREEN_S3C_DEBUG
 #undef CONFIG_TOUCHSCREEN_S3C_DEBUG
 
 /* For ts->dev.id.version */
@@ -117,39 +114,18 @@
 
 #ifdef CONFIG_TOUCHSCREEN_S3C_DEBUG
             {
-                //struct timeval tv;
-                //do_gettimeofday(&tv);
-                //printk(KERN_INFO "T: %06d, X: %03ld, Y: %03ld/n", (int)tv.tv_usec, ts->xp, ts->yp);
+                struct timeval tv;
+                do_gettimeofday(&tv);
+                printk(KERN_INFO "T: %06d, X: %03ld, Y: %03ld/n", (int)tv.tv_usec, ts->xp, ts->yp);
             }
 #endif
 
-#if 0
-            int tmpy;
             input_report_abs(ts->dev, ABS_X, ts->xp);
             input_report_abs(ts->dev, ABS_Y, ts->yp);
-            printk(KERN_ERR "x:%d , y:%d  /n", ts->xp, ts->yp);
 
             input_report_key(ts->dev, BTN_TOUCH, 1);
             input_report_abs(ts->dev, ABS_PRESSURE, 1);
             input_sync(ts->dev);
-#else       
-            int xraw, yraw, xtmp, ytmp;
-            xraw=ts->xp;
-            yraw=ts->yp;
-            xtmp = (axis_table[2] + axis_table[0]*xraw + axis_table[1]*yraw ) >> axis_table[6];
-            ytmp = (axis_table[5] + axis_table[3]*xraw + axis_table[4]*yraw ) >> axis_table[6];
-
-            //printk(KERN_ERR "x:%d , y:%d  /n", xtmp, ytmp);
-
-            //report button touch
-            input_report_key(ts->dev, BTN_TOUCH, 1);
-
-            input_report_abs(ts->dev, ABS_X, xtmp);
-            input_report_abs(ts->dev, ABS_Y, ytmp);
-            input_report_abs(ts->dev, ABS_PRESSURE, 1);
-            input_sync(ts->dev);
-#endif
-                       
         }
 
         ts->xp = 0;
@@ -163,7 +139,6 @@
 
         ts->count = 0;
 
-    //    printk(KERN_ERR "pen up /n");
         input_report_key(ts->dev, BTN_TOUCH, 0);
         input_report_abs(ts->dev, ABS_PRESSURE, 0);
         input_sync(ts->dev);
@@ -328,16 +303,10 @@
 
     ts->dev->evbit[0] = ts->dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
     ts->dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);


-    bitmap_fill(ts->dev->absbit, ABS_MAX);
-
+   
 #if defined(CONFIG_CPU_S3C2450) || defined(CONFIG_CPU_S3C6410) || defined(CONFIG_CPU_S3C2416)
-    input_set_abs_params(ts->dev, ABS_X, 0, 800, 0, 0);
-    input_set_abs_params(ts->dev, ABS_Y, 0, 480, 0, 0);
-
-    //input_set_abs_params(ts->dev, ABS_X, 0, 0xFFF, 0, 0);
-    //input_set_abs_params(ts->dev, ABS_Y, 0, 0xFFF, 0, 0);
+    input_set_abs_params(ts->dev, ABS_X, 0, 0xFFF, 0, 0);
+    input_set_abs_params(ts->dev, ABS_Y, 0, 0xFFF, 0, 0);
 #else
     input_set_abs_params(ts->dev, ABS_X, 0, 0x3FF, 0, 0);
     input_set_abs_params(ts->dev, ABS_Y, 0, 0x3FF, 0, 0);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值