修改VGA输出电脑屏超出显示范围的问题

时间:2022-11-15 16:26:30

在hdmi720p里把blank改大,200,600,2 300,800,40


zhuan移植tslib1.4到友善之臂的mini2440, 终于搞定了,真是麻烦. tslib

移植tslib1.4到友善之臂的mini2440, 终于搞定了,真是麻烦. tslib


利用中断和ADC改写科胜讯电阻触摸屏.c
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/console.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/input-polldev.h>
#include <asm/io.h>
//#include "ra/ra_gp.h"
#include "ra/ra_ea.h"
//#include "dc_adc_api.h"
#include "ra/radef.h"
#include "type.h"
#include "mach/irqs.h"
#include "ra_gp.h"
#include "dc_gp_api.h"
#include "ra_ic.h"
#include "dc_int_soc_api.h"
#include "ospl.h"
#include "dc_resistive_4wire_ts.h"

#define RELEASE_STATIC static

#define RESISTIVE_4WIRE_TS_VERSION          "0.01"
#define RESISTIVE_4WIRE_TS_MAJOR            0
#define RESISTIVE_4WIRE_TS_MINOR            1
#define RESISTIVE_4WIRE_TS_MINOR_START      0
#define RESISTIVE_4WIRE_TS_PIN_SETTLE_SLEEP 1
//#define _7_inch_800x600
#define _7_inch_900x480
#if defined(_7_inch_800x600)
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_HW_MIN_IRQ 130
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_HW_MAX_IRQ 930
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_HW_MIN_IRQ 150
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_HW_MAX_IRQ 880
//   res_ts_info.y_hw_size = abs(res_ts_info.y_hw_max - res_ts_info.y_hw_min);
//#endif
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_TRANS_MIN_IRQ 0
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_TRANS_MAX_IRQ 800
//    res_ts_info.x_trans_size = abs(res_ts_info.x_trans_max - res_ts_info.x_trans_min);
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_TRANS_MIN_IRQ 0
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_TRANS_MAX_IRQ 600
//    res_ts_info.y_trans_size = abs(res_ts_info.y_trans_max - res_ts_info.y_trans_min);
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_MOVEMENT_THRESHOLD_IRQ 5
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_PRESSURE_THRESHOLD_IRQ 50
#elif defined(_7_inch_800x480)
#elif defined(_10_inch_1024x600)
#elif defined(_7_inch_900x480)
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_HW_MIN_IRQ 66
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_HW_MAX_IRQ 930
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_HW_MIN_IRQ 220
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_HW_MAX_IRQ 840
//   res_ts_info.y_hw_size = abs(res_ts_info.y_hw_max - res_ts_info.y_hw_min);
//#endif
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_TRANS_MIN_IRQ 0
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_TRANS_MAX_IRQ 930
//    res_ts_info.x_trans_size = abs(res_ts_info.x_trans_max - res_ts_info.x_trans_min);
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_TRANS_MIN_IRQ 0
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_TRANS_MAX_IRQ 480
//    res_ts_info.y_trans_size = abs(res_ts_info.y_trans_max - res_ts_info.y_trans_min);
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_MOVEMENT_THRESHOLD_IRQ 5
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_PRESSURE_THRESHOLD_IRQ 240
#elif defined(_4_3_inch_480x272)
#endif
//#defined CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_DEBUG
//static DC_RESISTIVE_4WIRE_TS_INFO res_ts_info;
//#define DEBUG 1
OSPL_EVENT_FLAGS_GROUP event_flags;
RELEASE_STATIC DC_RESISTIVE_4WIRE_TS_INFO res_ts_info;
//#if DEBUG
//res_ts_info.debug_output=1;
//#else 
//res_ts_info.debug=0;
//#endif
//RELEASE_STATIC struct timer_list pen_timer;
//RELEASE_STATIC atomic_t counter;
//static char time_flag;
//static dev_t  dev;
//struct cdev *dc_ts_irq_devices; 
//static int dc_ts_irq_major=0;
//struct class *dc_ts_irq_class;
//#define MODULE_NAME "dc_ts_irq"
RELEASE_STATIC int     dc_resistive_4wire_ts_open(struct inode *inode, struct file *filp);
RELEASE_STATIC int     dc_resistive_4wire_ts_release(struct inode *inode, struct file *filp);
RELEASE_STATIC void    dc_resistive_4wire_ts_poll_func(void);
RELEASE_STATIC int          dc_resistive_4wire_ts_touch_test(void);
RELEASE_STATIC int          dc_resistive_4wire_ts_pressure_test(void);
RELEASE_STATIC void         dc_resistive_4wire_ts_set_pins_for_sense(void);
RELEASE_STATIC void         dc_resistive_4wire_ts_set_pins_for_coord(int axis);
RELEASE_STATIC void         dc_resistive_4wire_ts_set_pins_for_pressure(int axis);
RELEASE_STATIC int          dc_resistive_4wire_ts_acquire_coord(int axis, int *hard_coord);
RELEASE_STATIC int          dc_resistive_4wire_ts_acquire_pressure(int axis, int *pressure);
RELEASE_STATIC void         dc_resistive_4wire_ts_submit_input_abs(int x, int y, int button);
RELEASE_STATIC void         dc_resistive_4wire_ts_initialize_pins(void);
RELEASE_STATIC int          dc_resistive_4wire_ts_translate_coord(int hw_value,
                                                                  int hw_min,
                                                                  int hw_max,
                                                                  int hw_size,
                                                                  int trans_min,
                                                                  int trans_max,
                                                                  int trans_size);
RELEASE_STATIC irqreturn_t dc_resistive_4wire_ts_isr(int irq, void *dummy);
RELEASE_STATIC int dc_resistive_4wire_ts_timer_handler(void);
RELEASE_STATIC void dc_resistive_4wire_ts_enable_gp_interrupt_index(void);
RELEASE_STATIC void dc_resistive_4wire_ts_disable_gp_interrupt_index(void);
RELEASE_STATIC void dc_resistive_4wire_ts_set_gp_interrupt_hidetect(void);
RELEASE_STATIC void dc_resistive_4wire_ts_set_gp_interrupt_lodetect(void);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("G. B. Volpicelli");
MODULE_DESCRIPTION("DigiColor RESISTIVE 4WIRE TS Driver");
MODULE_VERSION(RESISTIVE_4WIRE_TS_VERSION);
static const char __initdata banner[] = "DigiColor RESISTIVE 4WIRE TS driver\n";
//static int     dc_ts_irq_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
static struct timer_list pen_timer =
  TIMER_INITIALIZER(dc_resistive_4wire_ts_timer_handler, 0, 0);
RELEASE_STATIC int     dc_resistive_4wire_ts_open(struct inode *inode, struct file *filp)
{
        printk("dc_resistive_4wire_ts_open \n");
        udelay(10);
         enable_irq(DC_INT_GP_DETECT);
     //    dc_resistive_4wire_ts_enable_gp_interrupt_index();
         return 0; 
}
RELEASE_STATIC int     dc_resistive_4wire_ts_release(struct inode *inode, struct file *filp)
{
   printk("dc_resistive_4wire_ts_closed \n");
   udelay(10);
   disable_irq(DC_INT_GP_DETECT);
   //dc_resistive_4wire_ts_disable_gp_interrupt_index();
   return 0;
 
}
 
RELEASE_STATIC void dc_resistive_4wire_ts_submit_input_abs(int x, int y, int button)
{
    input_report_abs(res_ts_info.input, ABS_X, x);
    input_report_abs(res_ts_info.input, ABS_Y, y);
   // if (res_ts_info.debug_output)
   // {
   /*     if (button == -1)
            printk(KERN_INFO "   -MOVE-    X: %d Y: %d\n",x,y);
        else if (button == 0)
            printk(KERN_INFO " -TOUCH UP-  X: %d Y: %d\n",x,y);
        else if (button == 1)
            printk(KERN_INFO "-TOUCH DOWN- X: %d Y: %d\n",x,y);
  //  }*/
    if (button == 0)
    {
        input_report_abs(res_ts_info.input, ABS_PRESSURE, 0);
        input_report_key(res_ts_info.input, BTN_TOUCH, button);
    }
    if (button == 1)
    {
        input_report_abs(res_ts_info.input,ABS_PRESSURE, 255);
        input_report_key(res_ts_info.input, BTN_TOUCH, button);
    }
    input_sync(res_ts_info.input);
}
RELEASE_STATIC void dc_resistive_4wire_ts_poll_func(void)
{
 
  //  int new_touched = 0;
    int new_hw_x = 0;
    int new_hw_y = 0;
    int new_trans_x = 0;
    int new_trans_y = 0;
   // disable_irq(DC_INT_GP_DETECT);
   // printk("dc_resistive_4wire_ts_poll_func\n");
   // while (1)
   // {
    //    if (!dc_resistive_4wire_ts_pressure_test()) return; //continue below
       
 if (!dc_resistive_4wire_ts_acquire_coord(ABS_X, &new_hw_x)) return;
       if (!dc_resistive_4wire_ts_acquire_coord(ABS_Y, &new_hw_y)) return;
        //confirm that these coords are valid
       if (!dc_resistive_4wire_ts_pressure_test()) return;
     //   new_touched = 1; //new vals are presumably good 
      //  if (res_ts_info.debug_output)
            printk(KERN_INFO "HW X: %d Y: %d\n",new_hw_x,new_hw_y);
        new_trans_x = dc_resistive_4wire_ts_translate_coord(new_hw_x,
                                                            res_ts_info.x_hw_min,
                                                            res_ts_info.x_hw_max,
                                                            res_ts_info.x_hw_size,
                                                            res_ts_info.x_trans_min,
                                                            res_ts_info.x_trans_max,
                                                            res_ts_info.x_trans_size);
        new_trans_y = dc_resistive_4wire_ts_translate_coord(new_hw_y,
                                                            res_ts_info.y_hw_min,
                                                            res_ts_info.y_hw_max,
                                                            res_ts_info.y_hw_size,
                                                            res_ts_info.y_trans_min,
                                                            res_ts_info.y_trans_max,
                                                            res_ts_info.y_trans_size);
        if (res_ts_info.debug_output)
            printk(KERN_INFO "TRANS X: %d Y: %d\n",new_trans_x,new_trans_y);
    
            //send a touchdown with the new points
            dc_resistive_4wire_ts_submit_input_abs(new_trans_x,new_trans_y,1);
            res_ts_info.old_trans_x = new_trans_x;
            res_ts_info.old_trans_y = new_trans_y;
    
}
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/*RELEASE_STATIC int dc_resistive_4wire_ts_touch_test(void)
{
        //dc_resistive_4wire_ts_set_pins_for_pressure();
        if (dc_resistive_4wire_ts_pressure_test())
        {  
           printk("dc_resistive_4wire_ts_touch_test done1\n");
            return 1;
        }
   printk("dc_resistive_4wire_ts_touch_test failed\n");
    return 0;
}*/
RELEASE_STATIC int dc_resistive_4wire_ts_pressure_test(void)
{
    int x_pressure;
    int y_pressure;
    //printk("dc_resistive_4wire_ts_pressure_test\n");
    if (!dc_resistive_4wire_ts_acquire_pressure(ABS_X, &x_pressure)) return 0;
    if (!dc_resistive_4wire_ts_acquire_pressure(ABS_Y, &y_pressure)) return 0;
  // if (res_ts_info.debug_output)
        printk(KERN_INFO "RESISTIVE 4WIRE TS: PRESSURE %d\n", x_pressure + y_pressure);
    if (x_pressure + y_pressure > CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_PRESSURE_THRESHOLD_IRQ) return 0;
    return 1; //pressed hard enough
}

RELEASE_STATIC void dc_resistive_4wire_ts_set_pins_for_coord(int axis)
{
    if (axis == ABS_X)
    {
        // 4 WIRE:
        // X+  X-  Y+  Y-
        // GND VCC HiZ ADC
        //drive XPLUS low
          regwr(RA_GP_CLIENTSEL_R_HI,0x10);
        regwr(RA_GP_DRIVE0_R, (dcreg(RA_GP_DRIVE0_R)  |
                                                  (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
        regwr(RA_GP_OUTPUT0_R,(dcreg(RA_GP_OUTPUT0_R) &
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
        //drive XMINUS high
        regwr(RA_GP_DRIVE0_R, (dcreg(RA_GP_DRIVE0_R)  |
                                                  (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
        regwr(RA_GP_OUTPUT0_R,(dcreg(RA_GP_OUTPUT0_R)|
                                                  (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
        //don't drive YPLUS 
        regwr(RA_GP_DRIVE0_R, (dcreg(RA_GP_DRIVE0_R)  &
                                                 ~ (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
        regwr(RA_GP_OUTPUT0_R,(dcreg(RA_GP_OUTPUT0_R) &
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
        //don't drive YMINUS, we'll be reading its input for adc
        regwr(RA_GP_DRIVE0_R, (dcreg(RA_GP_DRIVE0_R)  &
                                                 ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
        regwr(RA_GP_OUTPUT0_R,(dcreg(RA_GP_OUTPUT0_R) &
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
    }
    if (axis == ABS_Y)
    {
        // 4 WIRE:
        // X+  X-  Y+  Y-
        // HiZ ADC GND VCC 
        //don't drive XPLUS
          regwr(RA_GP_CLIENTSEL_R_HI,0x04);
        regwr(RESISTIVE_4WIRE_TS_GP_XPLUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_XPLUS_DRIVE)  & 
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_XPLUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_XPLUS_OUTPUT) & 
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
        //don't drive XMINUS, we'll be reading its input for adc
        regwr(RESISTIVE_4WIRE_TS_GP_XMINUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_XMINUS_DRIVE)  & 
                                                   ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_XMINUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_XMINUS_OUTPUT) & 
                                                   ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
        //drive YPLUS low
        regwr(RESISTIVE_4WIRE_TS_GP_YPLUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_YPLUS_DRIVE)  |
                                                  (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_YPLUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_YPLUS_OUTPUT) &
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
        //drive YMINUS high
        regwr(RESISTIVE_4WIRE_TS_GP_YMINUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_YMINUS_DRIVE)  |
                                                   (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_YMINUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_YMINUS_OUTPUT) | 
                                                   (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
    }
    mdelay(RESISTIVE_4WIRE_TS_PIN_SETTLE_SLEEP);//wait for capacitor to settle
   // res_ts_info.pins_sensing = 0;
}
RELEASE_STATIC void dc_resistive_4wire_ts_set_pins_for_pressure(int axis)
{
    if (axis == ABS_X)
    {
        // 4 WIRE:
        // X+  X-  Y+  Y-
        // VCC ADC HiZ GND 
         regwr(RA_GP_CLIENTSEL_R_HI,0x04);          //set XMINUS for adc and others for gpio;
        //drive XPLUS high
        
        regwr(RESISTIVE_4WIRE_TS_GP_XPLUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_XPLUS_DRIVE)  |
                                                  (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_XPLUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_XPLUS_OUTPUT) |
                                                 (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
        //don't drive XMINUS, we'll be reading its input for adc
        regwr(RESISTIVE_4WIRE_TS_GP_XMINUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_XMINUS_DRIVE)  &
                                                   ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_XMINUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_XMINUS_OUTPUT) &
                                                   ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
        //don't drive YPLUS
        regwr(RESISTIVE_4WIRE_TS_GP_YPLUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_YPLUS_DRIVE)  &
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_YPLUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_YPLUS_OUTPUT) &
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
        //drive YMINUS low
        regwr(RESISTIVE_4WIRE_TS_GP_YMINUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_YMINUS_DRIVE)  | 
                                                   (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_YMINUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_YMINUS_OUTPUT) & 
                                                   ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
    }
    if (axis == ABS_Y)
    {
        // 4 WIRE:
        // X+  X-  Y+  Y-
        // HiZ GND VCC ADC
         regwr(RA_GP_CLIENTSEL_R_HI,0x10);    //set YMINUS for adc and others for gpio;
        //don't drive XPLUS
        regwr(RESISTIVE_4WIRE_TS_GP_XPLUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_XPLUS_DRIVE)  &
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_XPLUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_XPLUS_OUTPUT) &
                                                  ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
        //drive XMINUS low
        regwr(RESISTIVE_4WIRE_TS_GP_XMINUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_XMINUS_DRIVE)  |
                                                   (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_XMINUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_XMINUS_OUTPUT) &
                                                   ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
        //drive YPLUS high
        regwr(RESISTIVE_4WIRE_TS_GP_YPLUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_YPLUS_DRIVE)  |
                                                  (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_YPLUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_YPLUS_OUTPUT) |
                                                  (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
        //don't drive YMINUS, RESISTIVE_4WIRE_we'll be reading its input for adc
        regwr(RESISTIVE_4WIRE_TS_GP_YMINUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_YMINUS_DRIVE)  &
                                                   ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
        regwr(RESISTIVE_4WIRE_TS_GP_YMINUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_YMINUS_OUTPUT) &
                                                   ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
    }
    mdelay(RESISTIVE_4WIRE_TS_PIN_SETTLE_SLEEP);//wait for capacitor to settle
 //   res_ts_info.pins_sensing = 0;
}
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
RELEASE_STATIC int dc_resistive_4wire_ts_acquire_coord(int axis, int *hard_coord)
{
    UINT16 hex_value = 0x00;
    dc_resistive_4wire_ts_set_pins_for_coord(axis);
    if (axis == ABS_Y)
    {
      if (!dc_adc_take_sample(RESISTIVE_4WIRE_TS_XCHANNEL,
                                RESISTIVE_4WIRE_TS_SAMPLES,
                                RESISTIVE_4WIRE_TS_UPDATEMODE,
                                RESISTIVE_4WIRE_TS_VREF,
                                &hex_value))
            return 0;
    if (res_ts_info.debug_output)
   printk("ABS --------x=%d\n",hex_value);
    }
 
    if (axis == ABS_X)
    {
        if (!dc_adc_take_sample(RESISTIVE_4WIRE_TS_YCHANNEL,
                                RESISTIVE_4WIRE_TS_SAMPLES,
                                RESISTIVE_4WIRE_TS_UPDATEMODE,
                                RESISTIVE_4WIRE_TS_VREF,
                                &hex_value))
            return 0;
   if (res_ts_info.debug_output)
  printk("ABS --------y=%d\n",hex_value);
    }
    *hard_coord = hex_value;
    return 1;
}
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
RELEASE_STATIC int dc_resistive_4wire_ts_acquire_pressure(int axis, int *pressure)
{
    UINT16 hex_value = 0x00;
    dc_resistive_4wire_ts_set_pins_for_pressure(axis);
    if (axis == ABS_X)
    {
     
        if (!dc_adc_take_sample(RESISTIVE_4WIRE_TS_YCHANNEL,
                                RESISTIVE_4WIRE_TS_SAMPLES,
                                RESISTIVE_4WIRE_TS_UPDATEMODE,
                                RESISTIVE_4WIRE_TS_VREF,
                                &hex_value))
            return 0;
    }
    if (axis == ABS_Y)
    {
        if (!dc_adc_take_sample(RESISTIVE_4WIRE_TS_XCHANNEL,
                                RESISTIVE_4WIRE_TS_SAMPLES,
                                RESISTIVE_4WIRE_TS_UPDATEMODE,
                                RESISTIVE_4WIRE_TS_VREF,
                                &hex_value))
            return 0;
    }
    *pressure = 0 | hex_value;
    return 1;
}
RELEASE_STATIC void dc_resistive_4wire_ts_set_pins_for_sense(void)
{
    // 4 WIRE:
    // X+  X-  Y+  Y-
    // GND HiZ HiZ PULLUP/INT
    regwr(RA_GP_CLIENTSEL_R_HI,0x00); //set all to gpio;
    //drive XPLUS low
    regwr(RESISTIVE_4WIRE_TS_GP_XPLUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_XPLUS_DRIVE)  &~
                                              (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
    regwr(RESISTIVE_4WIRE_TS_GP_XPLUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_XPLUS_OUTPUT) &
                                              ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)));
    //don't drive XMINUS
    regwr(RESISTIVE_4WIRE_TS_GP_XMINUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_XMINUS_DRIVE)  &
                                               ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
    regwr(RESISTIVE_4WIRE_TS_GP_XMINUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_XMINUS_OUTPUT) &
                                               ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
    //don't drive YPLUS
    regwr(RESISTIVE_4WIRE_TS_GP_YPLUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_YPLUS_DRIVE) | 
                                             (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
    regwr(RESISTIVE_4WIRE_TS_GP_YPLUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_YPLUS_OUTPUT) & 
                                              ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
    //don't drive YMINUS, we'll be reading its input for sense
    regwr(RESISTIVE_4WIRE_TS_GP_YMINUS_DRIVE, (dcreg(RESISTIVE_4WIRE_TS_GP_YMINUS_DRIVE)  |
                                               (1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
    regwr(RESISTIVE_4WIRE_TS_GP_YMINUS_OUTPUT,(dcreg(RESISTIVE_4WIRE_TS_GP_YMINUS_OUTPUT) &
                                               ~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
    mdelay(RESISTIVE_4WIRE_TS_PIN_SETTLE_SLEEP);//wait for capacitor to settle
  //  res_ts_info.pins_sensing = 1;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
RELEASE_STATIC int dc_resistive_4wire_ts_translate_coord(int hw_value,
                                                         int hw_min,
                                                         int hw_max,
                                                         int hw_size,
                                                         int trans_min,
                                                         int trans_max,
                                                         int trans_size)
{
    int hw_offset_1000;
    int trans_offset;
    //first find out how far we are into the hardware range and multiply by 1000.
    if (hw_min > hw_max)
    {
        //check the boundaries. Are we in range?
        if (hw_value > hw_min)
            hw_value = hw_min;
        if (hw_value < hw_max)
            hw_value = hw_max;
        hw_offset_1000 = (hw_min - hw_value) * 1000;
    }
    else
    {
        //check the boundaries. Are we in range?
        if (hw_value < hw_min)
            hw_value = hw_min;
        if (hw_value > hw_max)
            hw_value = hw_max;
        hw_offset_1000 = (hw_value - hw_min) * 1000;
    }
    //now apply that offset to the translation range.
    trans_offset = ((hw_offset_1000 / hw_size) * trans_size) / 1000;
    if (trans_min > trans_max)
        return trans_min - trans_offset;
    else 
        return trans_offset + trans_min;
}
/*void dc_resistive_4wire_ts_initialize_pins(void)
{
   
      regwr(RA_GP_CLIENTSEL_R_HI,(dcreg(RA_GP_CLIENTSEL_R_HI) |
                                                    0x10));
      regwr(RA_GP_CLIENTSEL_R_HI,(dcreg(RA_GP_CLIENTSEL_R_HI) |
                                                    0x04));
   
}*/
RELEASE_STATIC void dc_resistive_4wire_ts_initialize_pins(void)
{
   /* regwr16(RESISTIVE_4WIRE_TS_GP_XPLUS_CLIENTSEL,(dcreg16(RESISTIVE_4WIRE_TS_GP_XPLUS_CLIENTSEL) &
                                                   ~RESISTIVE_4WIRE_TS_GP_XPLUS_CLIENTSEL_MASK));
    regwr16(RESISTIVE_4WIRE_TS_GP_XMINUS_CLIENTSEL,(dcreg16(RESISTIVE_4WIRE_TS_GP_XMINUS_CLIENTSEL) &
                                                    ~RESISTIVE_4WIRE_TS_GP_XMINUS_CLIENTSEL_MASK));
    regwr16(RESISTIVE_4WIRE_TS_GP_YPLUS_CLIENTSEL,(dcreg16(RESISTIVE_4WIRE_TS_GP_YPLUS_CLIENTSEL) &
                                                   ~RESISTIVE_4WIRE_TS_GP_YPLUS_CLIENTSEL_MASK));*/
      regwr(RA_GP_CLIENTSEL_R_HI,(dcreg(RA_GP_CLIENTSEL_R_HI) &0x00));
      regwr(RA_GP_CLIENTSEL_A_LO,(dcreg(RA_GP_CLIENTSEL_A_LO) &~0x0C));
      regwr(RA_GP_DRIVE0_R,(dcreg(RA_GP_DRIVE0_R)|(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
      regwr(RA_GP_DRIVE0_R,(dcreg(RA_GP_DRIVE0_R)|(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
     // |(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)\
    //  |(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)\
    //  |(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
      regwr(RA_GP_OUTPUT0_R,(dcreg(RA_GP_OUTPUT0_R)&~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)));
      regwr(RA_GP_OUTPUT0_R,(dcreg(RA_GP_OUTPUT0_R)&~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)));
       regwr(RA_GP_DRIVE0_R,(dcreg(RA_GP_DRIVE0_R)&~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
     // regwr(RA_GP_OUTPUT0_R,(dcreg(RA_GP_INPUT_R)|(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)));
      //&~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)\
     // &~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)\
     // &~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN))); 
}
/*void dc_dc_resistive_4wire_ts_initialize_pins(void)
{
    regwr16(IR_REMOTE_GP_CLIENTSEL,(dcreg16(IR_REMOTE_GP_CLIENTSEL) & ~(0x3 << (2*IR_REMOTE_GP_PIN))));
    regwr(IR_REMOTE_GP_DRIVE,(dcreg(IR_REMOTE_GP_DRIVE) & ~(1 << IR_REMOTE_GP_PIN)));
}*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
RELEASE_STATIC void dc_resistive_4wire_ts_enable_gp_interrupt_index(void)
{
    //Set the IntAssign register for our pin to the correct index and enable it.
    dcreg(RESISTIVE_4WIRE_TS_GP_INTASSIGN_REGISTER) = DC_INT_GP_CHANNEL_7| 0x80;
    //clear the interrupt.
    regwr(RA_GP_INTFLAG_CLEAR_LO,(dcreg(RA_GP_INTFLAG_CLEAR_LO) | (1 << DC_INT_GP_CHANNEL_7)));
    //Enable the index to trigger the combined interrupt line
    regwr(RA_GP_INTENABLE_LO,(dcreg(RA_GP_INTENABLE_LO) | (1 << DC_INT_GP_CHANNEL_7)));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
RELEASE_STATIC void dc_resistive_4wire_ts_disable_gp_interrupt_index(void)
{
    //clear the IntAssign register for our pin
    dcreg(RESISTIVE_4WIRE_TS_GP_INTASSIGN_REGISTER) = 0x00;
    //Disable the index
    regwr(RA_GP_INTENABLE_LO,(dcreg(RA_GP_INTENABLE_LO) & ~(1 << DC_INT_GP_CHANNEL_7)));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
RELEASE_STATIC void dc_resistive_4wire_ts_set_gp_interrupt_hidetect(void)
{
    //turn off lodetect for the index and turn on hidetect
    regwr(RA_GP_LODETECT_LO,(dcreg(RA_GP_LODETECT_LO) & ~(1 << DC_INT_GP_CHANNEL_7)));
    regwr(RA_GP_HIDETECT_LO,(dcreg(RA_GP_HIDETECT_LO) | (1 << DC_INT_GP_CHANNEL_7)));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
RELEASE_STATIC void dc_resistive_4wire_ts_set_gp_interrupt_lodetect(void)
{
    //turn on lodetect for the index and turn off hidetect
    regwr(RA_GP_LODETECT_LO,(dcreg(RA_GP_LODETECT_LO) | (1 << DC_INT_GP_CHANNEL_7)));
    regwr(RA_GP_HIDETECT_LO,(dcreg(RA_GP_HIDETECT_LO) & ~(1 << DC_INT_GP_CHANNEL_7)));
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
RELEASE_STATIC irqreturn_t dc_resistive_4wire_ts_isr(int irq, void *dummy)
{
   res_ts_info.pen_down=1;
   mod_timer(&pen_timer, jiffies+2*HZ/1000);
          
        //  disable_irq(DC_INT_GP_DETECT);
   dc_resistive_4wire_ts_disable_gp_interrupt_index();
     //    printk("irq detected!\n");
       regwr(RA_GP_INTFLAG_CLEAR_LO,(dcreg(RA_GP_INTFLAG_CLEAR_LO) | (1 << DC_INT_GP_CHANNEL_7)));
    //  printk("RA_GP_INTFLAG_CLEAR_LO=%d\n",dcreg(RA_GP_INTFLAG_CLEAR_LO));  
    return IRQ_HANDLED; 
 
}
RELEASE_STATIC int dc_resistive_4wire_ts_timer_handler(void)
{
 //      printk("dc_resistive_4wire_ts_timer_handler,res_ts_info.pen_down=%d\n",res_ts_info.pen_down);
       // 
       
        if( res_ts_info.pen_down==1)
        {
         //  dc_resistive_4wire_ts_disable_gp_interrupt_index();
          
          disable_irq(DC_INT_GP_DETECT);
        //   printk("dc_resistive_4wire_ts_timer_handler int clear& disable\n");
         
            dc_resistive_4wire_ts_poll_func();
            udelay(120);
             mod_timer(&pen_timer, jiffies+HZ/1000);
          res_ts_info.pen_down=0; 
          res_ts_info.old_touched=1;
       }
       else if(res_ts_info.old_touched==1)
       {
       //     printk("intstatus=%d\n",dcreg(RA_GP_INTSTATUS));
                     dc_resistive_4wire_ts_set_pins_for_sense();
                   if ((dcreg(RESISTIVE_4WIRE_TS_GP_XMINUS_INPUT) & 0x20) == 0x00)
                   {
                      dc_resistive_4wire_ts_poll_func();
                      // dc_resistive_4wire_ts_submit_input_abs(res_ts_info.old_trans_x,res_ts_info.old_trans_y,1);
                      // res_ts_info.pen_down=1;
                       mod_timer(&pen_timer, jiffies+HZ/1000);
                 //     printk("dc_resistive_4wire_ts_timer_handler old_touched\n ");
                      
                   }      
                   else
               {
                  //     printk("touch up\n ");
                       dc_resistive_4wire_ts_submit_input_abs(res_ts_info.old_trans_x,res_ts_info.old_trans_y,0);
            dc_resistive_4wire_ts_initialize_pins();
            udelay(120);
                  regwr(RA_GP_INTFLAG_CLEAR_LO,(dcreg(RA_GP_INTFLAG_CLEAR_LO) | (1 << DC_INT_GP_CHANNEL_7)));
           dc_resistive_4wire_ts_enable_gp_interrupt_index();
           enable_irq(DC_INT_GP_DETECT);
         }
            return 0;
       }
 return 0;
}
static int __init dc_resistive_4wire_ts_init(void)
{
  
   int result;
   printk(banner);
   struct input_dev *input_dev;   
    
   input_dev = input_allocate_device();
 if (!input_dev) {
  printk(KERN_ERR "input_allocate_device() failed\n");
  result = -ENOMEM;
 } 
    
      res_ts_info.input = input_dev;
 res_ts_info.input->name = "Digicolor RESISTIVE 4WIRE TS";
 res_ts_info.input->phys = "dc4wrts";
 //res_ts_info.input->id.bustype = BUS_HOST;
 res_ts_info.input->id.vendor = 0;
 res_ts_info.input->id.product = 0;
 res_ts_info.input->id.version = 0;
 //res_ts_info.input->private = adc;
    res_ts_info.input->open = dc_resistive_4wire_ts_open;
    res_ts_info.input->close = dc_resistive_4wire_ts_release;
    set_bit(EV_KEY,res_ts_info.input->evbit);
    set_bit(EV_ABS,res_ts_info.input->evbit);
    set_bit(EV_SYN,res_ts_info.input->evbit);
    set_bit(BTN_TOUCH,res_ts_info.input->keybit);
    set_bit(ABS_X, res_ts_info.input->absbit);
    set_bit(ABS_Y, res_ts_info.input->absbit);
    set_bit(ABS_PRESSURE, res_ts_info.input->absbit);
    input_set_abs_params(res_ts_info.input, ABS_X, res_ts_info.x_trans_min, res_ts_info.x_trans_max, 0, 0);
    input_set_abs_params(res_ts_info.input, ABS_Y, res_ts_info.y_trans_min, res_ts_info.y_trans_max, 0, 0);
    input_set_abs_params(res_ts_info.input, ABS_PRESSURE, 0, 255, 0, 0);
 printk("Pen Driver 1.4.0\n");
  res_ts_info.x_hw_min = CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_HW_MIN_IRQ;
    res_ts_info.x_hw_max = CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_HW_MAX_IRQ;
    res_ts_info.x_hw_size = abs(res_ts_info.x_hw_max - res_ts_info.x_hw_min);
 res_ts_info.y_hw_min = CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_HW_MIN_IRQ;
    res_ts_info.y_hw_max = CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_HW_MAX_IRQ;
    res_ts_info.y_hw_size = abs(res_ts_info.y_hw_max - res_ts_info.y_hw_min);
     res_ts_info.x_trans_min = CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_TRANS_MIN_IRQ;
    res_ts_info.x_trans_max = CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_X_TRANS_MAX_IRQ;
    res_ts_info.x_trans_size = abs(res_ts_info.x_trans_max - res_ts_info.x_trans_min);
 res_ts_info.y_trans_min = CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_TRANS_MIN_IRQ;
    res_ts_info.y_trans_max = CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_Y_TRANS_MAX_IRQ;
    res_ts_info.y_trans_size = abs(res_ts_info.y_trans_max - res_ts_info.y_trans_min);
    res_ts_info.old_trans_x = 0;
    res_ts_info.old_trans_y = 0;
    res_ts_info.pen_down =0;
    res_ts_info.old_touched = 0;
 
 dc_resistive_4wire_ts_initialize_pins();
     regwr(RA_GP_DRIVE0_A,(dcreg(RA_GP_DRIVE0_R)&~(1<<CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_DETECT)));
     
     regwr(RA_GP_INTFLAG_CLEAR_LO,(dcreg(RA_GP_INTFLAG_CLEAR_LO) | (1 << DC_INT_GP_CHANNEL_7)));
      regwr(RESISTIVE_4WIRE_TS_GP_INTASSIGN_REGISTER, 0x80 | DC_INT_GP_CHANNEL_7);
      regwr(RA_GP_LODETECT,( dcreg(RA_GP_LODETECT) |(1<<DC_INT_GP_CHANNEL_7)));
      regwr(RA_GP_HIDETECT_LO,(dcreg(RA_GP_HIDETECT_LO) & ~(1 << DC_INT_GP_CHANNEL_7)));
      regwr(RA_GP_INTENABLE_LO,(dcreg(RA_GP_INTENABLE_LO)|(1 << DC_INT_GP_CHANNEL_7)));
 ospl_int_set_priority(DC_INT_GP_DETECT,OSPL_INT_PRIORITY_GPIO);
 
   result = request_irq(DC_INT_GP_DETECT,dc_resistive_4wire_ts_isr,0, "4wiretsirq", &res_ts_info);
  
 if(result)
 {
  printk("4wiresirq:cannot init  irq=%d\n",  DC_INT_GP_DETECT);
    result -ENOMEM;   
  }
 else
     printk("4wiresirq:can init irq=%d\n", DC_INT_GP_DETECT);
  dc_adc_init();
 
 result = input_register_device(res_ts_info.input);
 regwr(RA_GP_INTFLAG_CLEAR_LO,(dcreg(RA_GP_INTFLAG_CLEAR_LO) | (1 << DC_INT_GP_CHANNEL_7)));
//    dc_gp_int_clear(DC_INT_GP_CHANNEL_7);
 // enable_irq(DC_INT_GP_DETECT); 
 
// disable_irq(DC_INT_GP_DETECT);
 //  dc_resistive_4wire_ts_disable_gp_interrupt_index();
 return result;
}
static void __exit dc_resistive_4wire_ts_exit(void)
{
 //    dc_int_gp_flag_clear(DC_INT_GP_CHANNEL_7);
   //  dc_int_gp_disable(DC_INT_GP_CHANNEL_7); 
       del_timer(&pen_timer);
        free_irq(DC_INT_GP_DETECT,&res_ts_info);
        printk("---cx_cleanup---cdev_del---\n");       
       input_unregister_device(res_ts_info.input);
       dc_resistive_4wire_ts_disable_gp_interrupt_index();
       disable_irq(DC_INT_GP_DETECT);
    
}
module_init( dc_resistive_4wire_ts_init );
module_exit( dc_resistive_4wire_ts_exit ); 
MODULE_LICENSE("Dual BSD/GPL");

利用中断和ADC改写科胜讯电阻触摸屏.h
/*
 *
 * Copyright (C) 2009 Conexant Systems Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef _dc_resistive_4wire_ts_h_
#define _dc_resistive_4wire_ts_h_
#include "type.h"
 
#include "ra/radef.h"
#include "ra/ra_gp.h"
#include "ra/ra_ea.h"
#include "dc_adc_api.h"
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_DETECT 5  
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN 5
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN  7
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN 6
#define CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN  4
//XPLUS 
#define RESISTIVE_4WIRE_TS_GP_XPLUS_INPUT              RA_GP_INPUT_R
#define RESISTIVE_4WIRE_TS_GP_XPLUS_OUTPUT             RA_GP_OUTPUT0_R
#define RESISTIVE_4WIRE_TS_GP_XPLUS_DRIVE              RA_GP_DRIVE0_R
#define RESISTIVE_4WIRE_TS_GP_XPLUS_CLIENTSEL          RA_GP_CLIENTSEL_R_LO
//XMINUS 
#define RESISTIVE_4WIRE_TS_GP_XMINUS_INPUT             RA_GP_INPUT_R
#define RESISTIVE_4WIRE_TS_GP_XMINUS_OUTPUT            RA_GP_OUTPUT0_R
#define RESISTIVE_4WIRE_TS_GP_XMINUS_DRIVE             RA_GP_DRIVE0_R
#define RESISTIVE_4WIRE_TS_GP_XMINUS_CLIENTSEL         RA_GP_CLIENTSEL_R_LO
//YMINUS 
#define RESISTIVE_4WIRE_TS_GP_YMINUS_INPUT             RA_GP_INPUT_R
#define RESISTIVE_4WIRE_TS_GP_YMINUS_OUTPUT            RA_GP_OUTPUT0_R
#define RESISTIVE_4WIRE_TS_GP_YMINUS_DRIVE             RA_GP_DRIVE0_R
#define RESISTIVE_4WIRE_TS_GP_YMINUS_CLIENTSEL         RA_GP_CLIENTSEL_R_HI
//YPLUS 
#define RESISTIVE_4WIRE_TS_GP_YPLUS_INPUT              RA_GP_INPUT_R
#define RESISTIVE_4WIRE_TS_GP_YPLUS_OUTPUT             RA_GP_OUTPUT0_R
#define RESISTIVE_4WIRE_TS_GP_YPLUS_DRIVE              RA_GP_DRIVE0_R
#define RESISTIVE_4WIRE_TS_GP_YPLUS_CLIENTSEL          RA_GP_CLIENTSEL_R_HI
#define RESISTIVE_4WIRE_TS_XCHANNEL                    DC_ADC_CHANNEL_13 //match the XMINUS PIN's ADC
#define RESISTIVE_4WIRE_TS_YCHANNEL                    DC_ADC_CHANNEL_14 //match the YMINUS PIN's ADC
#define RESISTIVE_4WIRE_TS_UPDATEMODE                  DC_ADC_UPDATEMODE_REPLACE
#define RESISTIVE_4WIRE_TS_SAMPLES                     DC_ADC_SAMPLES_8
#define RESISTIVE_4WIRE_TS_VREF                        DC_ADC_VREF_INTERNAL
#define RESISTIVE_4WIRE_TS_GP_INTASSIGN_REGISTER                RA_GP_INTASSIGN_R5

#define RESISTIVE_4WIRE_TS_GP_XMINUS_MASK               (0x01 << CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN)
#define RESISTIVE_4WIRE_TS_GP_XMINUS_CLIENTSEL_MASK     (0x0003 << (CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XMINUS_PIN * 2))
#define RESISTIVE_4WIRE_TS_GP_XPLUS_MASK                (0x01 << CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN)
#define RESISTIVE_4WIRE_TS_GP_XPLUS_CLIENTSEL_MASK      (0x0003 << (CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_XPLUS_PIN * 2))
#define RESISTIVE_4WIRE_TS_GP_YMINUS_MASK               (0x01 << CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN)
#define RESISTIVE_4WIRE_TS_GP_YMINUS_CLIENTSEL_MASK     (0x0003 << (CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YMINUS_PIN * 2))
#define RESISTIVE_4WIRE_TS_GP_YPLUS_MASK                (0x01 << CONFIG_TOUCHSCREEN_DIGICOLOR_RESISTIVE_4WIRE_YPLUS_PIN)
#define RESISTIVE_4WIRE_TS_GP_YPLUS_CLIENTSEL_MASK      (0x0003 << (5 * 2))
typedef struct DC_RESISTIVE_4WIRE_TS_INFO 
{
// struct input_polled_dev *input_poll;
    struct input_dev        *input;
   int pins_sensing;
   int pen_down;
    int x_hw_min;
    int x_hw_max;
    int x_hw_size;
    int y_hw_min;
    int y_hw_max;
    int y_hw_size;
    int x_trans_min;
    int x_trans_max;
    int x_trans_size;
    int y_trans_min;
    int y_trans_max;
    int y_trans_size;
    int movement_threshold;
    int pressure_threshold;
    bool debug_output;
    int old_trans_x;
    int old_trans_y;
    int old_touched;
}DC_RESISTIVE_4WIRE_TS_INFO;
#endif /* _dc_resistive_4wire_ts_h_ */