Kernel layer touch Calibration

Source: Internet
Author: User

A 10.4-inch new screen with the same resolution. After the screen is clicked, the touch is completely inaccurate. Because the Android system has not transplanted tslib, you can only report the original touch point to Android in the underlying driver for reading.

 

Underlying kernel version 2.6.27

 

First, from the touch screen click, it seems to be a reverse reaction between the left and right sides. Print the coordinate value and click the four vertices on the touch screen. The result is as follows,

(823,20) (0, 16)

 

 

(810,596) (1,601)

 

Which of the following statements is true:

 

() (823,16)

 

 

(1,596) (810,601)

 

The above is the LCD coordinate after the touch coordinate transformation. It can be seen that the value of X is reversed. Let's take a look at this part of the driver:

 

// Set the maximum touch range <br/> # define ts_x_sz800 <br/> # define ts_y_sz600 </P> <p> // timer Service Program <br/> static void touch_timer_fire (unsigned long data) <br/>{< br/> unsigned long data0; <br/> unsigned long data1; <br/> int updown; </P> <p> # ifdef android_ts <br/> int A0, A1, A2, A3, A4, A5, A6; <br/> int X, Y; </P> <p> a0 = <br/> A1 = <br/> A2 = <br/> A3 = <br/> A4 = <br/> A5 = <br/> A6 = <br/> # endif </P> <p> data0 = readl (ts_base + initi_adcdat0 ); <br/> dat A1 = readl (ts_base + jx_adcdat1); </P> <p> updown = (! (Data0 & cloud_adcdat0_updown ))&&(! (Data1 & cloud_adcdat1_updown); </P> <p> If (updown) {<br/> If (ts-> count) {</P> <p> # ifdef config_touchscreen_initi_debug <br/> {<br/> struct timeval TV; <br/> do_gettimeofday (& TV ); <br/> printk (kern_info "T: % 06d, X: % 03ld, Y: % 03ld/N", (INT) TV. TV _usec, ts-> XP, ts-> YP ); // If the kernel is selected during kernel compilation, the coordinates are printed. <br/>}< br/> # endif </P> <p> # ifdef android_ts <br/> X = (INT) ts-> XP; <br/> Y = (INT) ts-> YP; </P> <p> TS-> XP = (X-964) * 80 0)/(3088-964); <br/> TS-> Yp = (Y-1012) * 600)/(2840-1012 ); <br/> // This method is used to convert the value to LCD coordinates. The value 964/1012/3088/2840 here is also the touch value of four vertices on the LCD screen, then, based on the LCD coordinate values of the four vertices on the LCD screen, create the equation of four unknowns. Calculate the preceding four values. <Br/> // ts-> XP = (long) (A2 + (A0 * x) + (A1 * y)/a6 ); <br/> // ts-> Yp = (long) (A5 + (A3 * x) + (A4 * y)/a6 ); <br/> // printk ("x = % d, y = % d/N", (INT) ts-> XP, (INT) ts-> YP ); <br/> // another way is to convert the seven values defined above into LCD coordinates. About a0 ~ A6 there are also many methods to define these values on the Internet. You need to print the touch coordinates of the four vertices on the LCD screen first, then, according to v <br/> this implementation is a linear transformation using 7 parameters <br/> (A, B, C, D, E, F and S) to transform the device coordinates (XD, YD) <br/> into screen coordinates (XS, ys) using the following equations: </P> <p> S * xs = A * XD + B * YD + C <br/> S * ys = D * XD + E * YD + F <br/> to calculate the a0 ~ A6. This computation uses the Clem law of linear algebra learned in the first day of the year! <Br/> If (ts-> XP! = Ts-> xp_old | ts-> YP! = Ts-> yp_old) <br/>{< br/> input_report_abs (ts-> Dev, abs_x, ts-> XP ); /// * Report the absolute coordinate values of x and y */<br/> input_report_abs (ts-> Dev, abs_y, ts-> YP ); <br/> // input_report_abs (ts-> Dev, abs_z, 0); </P> <p> input_report_key (ts-> Dev, btn_touch, 1 ); /// * report the status of the touch screen. 1 indicates that the touch screen is pressed */<br/> // input_report_abs (ts-> Dev, abs_pressure, 1 ); <br/> input_sync (ts-> Dev); // synchronize <br/>}< br/> TS-> xp_old = ts-> XP; <br/> TS-> yp_old = ts-> YP; <br/> # else </P> <p> input_report_abs (ts-> Dev, abs_x, ts-> XP); <br/> input_report_abs (ts-> Dev, abs_y, ts-> YP); </P> <p> input_report_key (ts-> Dev, btn_touch, 1); <br/> input_report_abs (ts-> Dev, abs_pressure, 1); <br/> input_sync (ts-> Dev ); <br/> # endif <br/>}</P> <p> TS-> XP = 0; <br/> TS-> Yp = 0; <br/> TS-> COUNT = 0; <br/> // set the initial touch screen and * Start the ADC conversion */<br/> writel (maid | autopst, ts_base + cloud_adctsc); <br/> writel (readl (ts_base + cloud_adccon) | cloud_adccon_enable_start, ts_base + cloud_adccon ); <br/>}< br/> else {<br/> // The status is up </P> <p> TS-> COUNT = 0; <br/> # ifdef android_ts <br/> input_report_abs (ts-> Dev, abs_x, ts-> xp_old); <br/> input_report_abs (ts-> Dev, abs_y, ts-> yp_old); <br/> input_report_abs (ts-> Dev, abs_z, 0 ); <br/> # endif </P> <p> input_report_key (ts-> Dev, btn_touch, 0 ); <br/> # ifndef android_ts <br/> input_report_abs (ts-> Dev, abs_pressure, 0 ); <br/> # endif <br/> input_sync (ts-> Dev); </P> <p> writel (wait4int (0), ts_base + jx_adctsc ); <br/>}< br/> 

 

It can be determined that the X coordinate is reversed, so you only need to adjust it.

 

Ts-> XP = (X-964) * 800)/(3088-964); this is the LCD X coordinate, all you need

Ts-> XP = (800-(X-964) * 800)/(3088-964 );

After re-compilation, we can check that ~ Only under this record

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.