]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P05-C3000-TSPRESSURE_041207.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / linux / openzaurus-pxa27x-2.4.20-rmk2-embedix20050602 / P05-C3000-TSPRESSURE_041207.patch
1 diff -Nur c3000_pre/linux/drivers/char/Config.in c3000_work/linux/drivers/char/Config.in
2 --- c3000_pre/linux/drivers/char/Config.in      2004-08-21 09:48:25.000000000 +0900
3 +++ c3000_work/linux/drivers/char/Config.in     2004-12-06 15:53:46.000000000 +0900
4 @@ -164,6 +164,8 @@
5     if [ "$CONFIG_ARCH_SHARP_SL" = "y" ]; then
6        bool '  SL-series serial port support' CONFIG_SERIAL_SL_SERIES
7     fi
8 +   bool '  SL-series touchscreen pressure value read (EXPERIMENTAL)' CONFIG_SL_TS_PRESSURE
9 +   dep_bool '    Boot On touchscreen pressure value read' CONFIG_BOOT_PRESSURE_ON $CONFIG_SL_TS_PRESSURE
10     if [ "$CONFIG_SERIAL_SL_SERIES" = "y" ]; then
11        bool '   SL-series Bluetooth support' CONFIG_BLUETOOTH_SL
12     fi
13 diff -Nur c3000_pre/linux/drivers/char/ads7846_ts.c c3000_work/linux/drivers/char/ads7846_ts.c
14 --- c3000_pre/linux/drivers/char/ads7846_ts.c   2004-11-16 15:31:06.000000000 +0900
15 +++ c3000_work/linux/drivers/char/ads7846_ts.c  2004-12-06 15:50:06.000000000 +0900
16 @@ -86,7 +86,55 @@
17  static DECLARE_WAIT_QUEUE_HEAD(queue);
18  static int head, tail, sample;
19  static char pendown = 0;
20 -unsigned long Pressure;
21 +static unsigned long Pressure;
22 +#if defined(CONFIG_SL_TS_PRESSURE)
23 +#include <linux/proc_fs.h>
24 +#endif
25 +
26 +#if defined(CONFIG_SL_TS_PRESSURE)
27 +static unsigned long tsPressure;
28 +#if defined(CONFIG_BOOT_PRESSURE_ON)
29 +static unsigned int tspressure_mode = 1;
30 +#else
31 +static unsigned int tspressure_mode = 0;
32 +#endif
33 +
34 +static ssize_t tspressure_read_params(struct file *file, char *buf,
35 +                                     size_t nbytes, loff_t *ppos)
36 +{
37 +       char outputbuf[32];
38 +       int count;
39 +
40 +       if (*ppos>0) /* Assume reading completed in previous read*/
41 +               return 0;
42 +       count = sprintf(outputbuf, "%d\n", (unsigned int)tspressure_mode);
43 +       count++;
44 +       *ppos += count;
45 +       if (count>nbytes)       /* Assume output can be read at one time */
46 +               return -EINVAL;
47 +       if (copy_to_user(buf, outputbuf, count+1))
48 +               return -EFAULT;
49 +       return count;
50 +}
51 +
52 +static ssize_t tspressure_write_params(struct file *file, const char *buf,
53 +                                      size_t nbytes, loff_t *ppos)
54 +{
55 +       unsigned int param=0;
56 +
57 +       sscanf(buf,"%d",&param);
58 +       if (tspressure_mode != param) {
59 +               tspressure_mode = param;
60 +               printk("tspressure = %d\n", tspressure_mode);
61 +       }
62 +       return nbytes;
63 +}
64 +
65 +static struct file_operations proc_tspressure_operations = {
66 +  read:   tspressure_read_params,
67 +  write:  tspressure_write_params,
68 +};
69 +#endif
70  #if defined(CONFIG_ARCH_PXA_CORGI)
71  static char ispass = 1;
72  #endif
73 @@ -370,7 +418,11 @@
74                 ((int)((x)-(y))<(int)(d)) && \
75                 ((int)((y)-(x))<(int)(d)) )
76         unsigned long cmd;
77 +#if defined(CONFIG_SL_TS_PRESSURE)
78 +       unsigned int t,x,y,z[2],z2,dummy;
79 +#else
80         unsigned int t,x,y,z[2];
81 +#endif
82         int i,j,k;
83         int d = 8, c = 10;
84         int err = 0;
85 @@ -381,7 +433,18 @@
86                         (3u << ADSCTRL_ADR_SH) | (1u << ADSCTRL_STS_SH);
87                 t = ads7846_rw(cmd);
88                 z[i] = ads7846_rw(cmd);
89
90 +
91 +#if defined(CONFIG_SL_TS_PRESSURE)
92 +               if (tspressure_mode) {
93 +                       /* Z2 */
94 +                       cmd = (1u << ADSCTRL_PD0_SH) | (1u << ADSCTRL_PD1_SH) |
95 +                               (4u << ADSCTRL_ADR_SH) | (1u << ADSCTRL_STS_SH);
96 +                       dummy = ads7846_rw(cmd);
97 +                       udelay(1);
98 +                       z2 = ads7846_rw(cmd);
99 +               }
100 +#endif
101 +
102                 if( i ) break;
103  
104                 /* X-axis */
105 @@ -415,6 +478,10 @@
106                 }
107         }
108         Pressure = 1;
109 +#if defined(CONFIG_SL_TS_PRESSURE)
110 +       if (tspressure_mode)
111 +               if (z[1]) tsPressure = (15000 - x * (z2 - z[1]) / z[1]) >> 4;
112 +#endif
113         for(i=0;i<2;i++){
114                 if( !z[i] )
115                         Pressure = 0;
116 @@ -528,12 +595,19 @@
117  
118         //      printk("x=%d,y=%d\n",tp->xd,tp->yd);
119  
120 -       if (z1 != 0)
121 +       if (z1 != 0) {
122                 Pressure = Rx * (tp->xd) * ((10*z2/z1) - 1*10) >> 10;
123 -       else 
124 +#if defined(CONFIG_SL_TS_PRESSURE)
125 +               if (tspressure_mode)
126 +                       tsPressure = (15000 - x[3] * (z2 - z1) / z1) >> 4;
127 +       }
128 +#endif
129 +       else
130 +#if defined(CONFIG_SL_TS_PRESSURE)
131 +               tsPressure = Pressure = 0;
132 +#else
133                 Pressure = 0;
134 -
135 -
136 +#endif
137          cmd =  (1u << ADSCTRL_PD0_SH) | (1u << ADSCTRL_PD1_SH) |
138                 (4u << ADSCTRL_ADR_SH) | (1u << ADSCTRL_STS_SH);
139         /* Power-Down Enable */
140 @@ -612,11 +686,25 @@
141  //     printk("fail %d\n", fail);
142  
143         if (fail == TOUCH_PANEL_AVERAGE) {
144 +#if defined(CONFIG_SL_TS_PRESSURE)
145 +               tsPressure = Pressure = 0;
146 +#else
147                 Pressure = 0;
148 +#endif
149  //             printk("pen up\n");
150         }
151         else {
152 +#if defined(CONFIG_SL_TS_PRESSURE)
153 +               if (tspressure_mode) {
154 +                       if (z1) {
155 +                               tsPressure = Pressure = (15000 - x * (z2 - z1) / z1) >> 4;
156 +                       } else
157 +                               tsPressure = Pressure = 0;
158 +               } else
159 +                       tsPressure = Pressure = 1;
160 +#else
161                 Pressure = 1;
162 +#endif
163                 tp->xd = tx / (TOUCH_PANEL_AVERAGE - fail);
164                 tp->yd = ty / (TOUCH_PANEL_AVERAGE - fail);
165  //             printk("pen position (%d,%d)\n", tx, ty);
166 @@ -788,7 +876,11 @@
167  
168  static void new_data(void)
169  {
170 +#if !defined(CONFIG_ARCH_PXA_CORGI) && !defined(CONFIG_ARCH_PXA_POODLE)
171 +#if !defined(CONFIG_POODLE_TR0)
172         int diff0, diff1, diff2, diff3;
173 +#endif
174 +#endif
175  
176  #ifdef CONFIG_PM
177         if( PowerDownMode != PMPD_MODE_ACTIVE )
178 @@ -956,11 +1048,26 @@
179                 lock_FCS(POWER_MODE_TOUCH, 1);  // not enter FCS mode.
180  #endif
181                 if( pos_dt.xd && pos_dt.yd && Pressure ) {
182 +#if defined(CONFIG_SL_TS_PRESSURE)
183 +                       if (tspressure_mode)
184 +                               tc.pressure = Pressure;
185 +                       else
186 +                               tc.pressure = 500;
187 +#else
188                         tc.pressure = 500;
189 +#endif
190 +
191  #else
192                 if( pos_dt.xd && pos_dt.yd ){
193 +#if defined(CONFIG_SL_TS_PRESSURE)
194 +                       if (tspressure_mode)
195 +                               tc.pressure = Pressure;
196 +                       else
197 +                               tc.pressure = 1;
198 +#else
199                         tc.pressure = 1;
200  #endif
201 +#endif
202                         before_data = tc;
203                         pendown = 1;
204                         new_data();
205 @@ -1005,6 +1112,16 @@
206  static void ts_hardware_init(void)
207  {
208         unsigned int dummy;
209 +
210 +#if defined(CONFIG_SL_TS_PRESSURE)
211 +       struct proc_dir_entry *tspressure_proc;
212 +#endif
213 +
214 +#if defined(CONFIG_SL_TS_PRESSURE)
215 +       tspressure_proc = create_proc_entry("zaurus/tspressure", 0, NULL);
216 +       if (tspressure_proc)
217 +               tspressure_proc->proc_fops = &proc_tspressure_operations;
218 +#endif
219         
220  #if defined(CONFIG_ARCH_PXA_POODLE) || defined(CONFIG_ARCH_PXA_CORGI)
221         pxa_ssp_init();
222 @@ -1283,6 +1400,13 @@
223         case 17:         /* Clear all buffer data */
224             print_par();
225             break;
226 +#if defined(CONFIG_SL_TS_PRESSURE)
227 +       case 64:        /* read Pressure */
228 +           if (tspressure_mode) {
229 +                   copy_to_user((void *)arg, &tsPressure, sizeof(tsPressure));
230 +                   break;
231 +           }
232 +#endif
233         default:
234                 return -EINVAL;
235         }