[Note] mini2440 touch screen driver Transplantation

Source: Internet
Author: User

Statement in advance: The article only records the porting process for your convenience.

The touch screen of the mini2440 Development Board is the NEC touch screen, while the Android kernel provided on the FriendlyArm is for the tongbao LCD. Therefore, you need to modify the touch screen driver.

 

1. Why should I correct the touch screen?

There is an error in pixel and touch coordinates.

Http://sys.firnow.com/linux/x8002010n08m/27s90182549.html details:

 

2. Specific modification method: (not verified yet)

Compared with the device manuals of the tongbao touch screen and the NEC touch screen, the biggest difference is probably in the touch screen coordinates (or in touch screen correction)

 

Compared with the NEC touch screen driver in Linux and the TPO driver in Android, touch_timer_fire is somewhat different. The difference is:

 

About the TPO driver in Android:

 

 

If (updown ){

If (count! = 0 ){

Long tmp;

 

Tmp = xp;

Xp = yp;

Yp = tmp;

 

Xp >>=2;

YP> = 2;

XP = 0x3ff-XP;

Spin_lock (& myts_lock );

If (myts [7]) {

Disx = (myts [0] * XP) + (myts [1] * YP) + myts [2])/myts [6];

DISY = (myts [3] * XP) + (myts [4] * YP) + myts [5])/myts [6];

// Printk (kern_info "disx: % d, DISY: % d/N", disx, DISY );

Disx = disx x * 1024/240;

Disy= DISY * 1024/320;

} Else {

Disx = XP;

DISY = YP;

}

Spin_unlock (& myts_lock );

If (disx <0)

Disx = 0;

Else if (disx & gt; 1023)

Disx = 1023;

If (DISY <0)

DISY = 0;

Else if (DISY> 1023)

Disy= 1023;

 

// Printk (KERN_INFO "X: % d, Y: % d/n", disX, disY );

 

Input_report_abs (dev, ABS_X, disX );

Input_report_abs (dev, ABS_Y, disY );

 

Input_report_key (dev, BTN_TOUCH, 1 );

Input_report_abs (dev, ABS_PRESSURE, 1 );

Input_sync (dev );

}

 

Xp = 0;

Yp = 0;

Count = 0;

 

Iowrite32 (S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, base_addr + S3C2410_ADCTSC );

Iowrite32 (ioread32 (base_addr + S3C2410_ADCCON) | S3C2410_ADCCON_ENABLE_START, base_addr + S3C2410_ADCCON );

} Else {

Count = 0;

 

 

About the NEC touch screen driver in Linux

 

If (updown ){

If (ts. count! = 0 ){

Long tmp;

 

Tmp = ts. xp;

Ts. xp = ts. yp;

Ts. yp = tmp;

 

Ts. xp >>=ts. shift;

Ts. yp> = ts. shift;

 

# Ifdef CONFIG_TOUCHSCREEN_S3C2410_DEBUG

{

Struct timeval TV;

Do_gettimeofday (& TV );

Printk (DEBUG_LVL "T: % 06d, X: % 03ld, Y: % 03ld/n", (int) TV. TV _usec, ts. xp, ts. yp );

}

# Endif

 

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 );

}

 

Ts. xp = 0;

Ts. yp = 0;

Ts. count = 0;

 

Writel (S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, base_addr + S3C2410_ADCTSC );

Writel (readl (base_addr + S3C2410_ADCCON) | S3C2410_ADCCON_ENABLE_START, base_addr + S3C2410_ADCCON );

} Else {

Ts. count = 0;

 

 

After comparison, we found that the NEC driver in Linux was not

DisX = (myTS [0] * xp) + (myTS [1] * yp) + myTS [2])/myTS [6];

DisY = (myTS [3] * xp) + (myTS [4] * yp) + myTS [5])/myTS [6];

Therefore, modify the Code as follows:

 

 

# Define NEC_TOUCHSCREEN (0) // add by Roger

# DefineTPO_TOUCHSCREEN (1)

# DefineTOUCHSCREEN (NEC_TOUCHSCREEN)

 

 

 

If (updown ){

If (count! = 0 ){

Long tmp;

 

Tmp = xp;

Xp = yp;

Yp = tmp;

 

Xp >>=2;

Yp> = 2;

// Edit by Roger

# If TOUCHSCREEN = TPO_TOUCHSCREEN

Xp = 0x3FF-xp;

Spin_lock (& myTS_lock );

If (myTS [7]) {

DisX = (myTS [0] * xp) + (myTS [1] * yp) + myTS [2])/myTS [6];

DisY = (myTS [3] * xp) + (myTS [4] * yp) + myTS [5])/myTS [6];

// Printk (KERN_INFO "disX: % d, disY: % d/n", disX, disY );

DisX = disX x * 1024/240;

Disy= disY * 1024/320;

} Else {

DisX = xp;

DisY = yp;

}

Spin_unlock (& myTS_lock );

If (disX <0)

DisX = 0;

Else if (disX & gt; 1023)

DisX = 1023;

If (disY <0)

DisY = 0;

Else if (disY> 1023)

Disy= 1023;

 

// Printk (KERN_INFO "X: % d, Y: % d/n", disX, disY );

 

Input_report_abs (dev, ABS_X, disX );

Input_report_abs (dev, ABS_Y, disY );

# Elif touchscreen = nec_touchscreen

// Edit by Roger

Input_report_abs (Dev, abs_x, XP );

Input_report_abs (Dev, abs_y, YP );

# Endif

Input_report_key (Dev, btn_touch, 1 );

Input_report_abs (Dev, abs_pressure, 1 );

Input_sync (Dev );

}

 

XP = 0;

Yp = 0;

Count = 0;

 

Iowrite32 (s3c2410_adctsc_pull_up_disable | autopst, base_addr + s3c2410_adctsc );

Iowrite32 (ioread32 (base_addr + s3c2410_adccon) | s3c2410_adccon_enable_start, base_addr + s3c2410_adccon );

} Else {

Count = 0;

 

 

Modified on April 9, January 11:

After verification, the touch screen response still encountered problems using the above method. The above method did not provide the correction function, so it was not successful. For specific correction articles, refer to [note] Touch Screen driver transplantation of mini2440 (II), which provides a solution.

 

References:

1. S3C2440 touch screen driver analysis (about oversampling_shift = 2 ):

Http://blog.csdn.net/satanwxd/archive/2010/02/02/5279595.aspx

Http://blog.csdn.net/satanwxd/archive/2010/02/02/5279981.aspx

2, S3C2410 touch screen driver analysis: http://blog.csdn.net/sfrysh/archive/2010/08/04/5787645.aspx

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.