From f34148bc4e9262fadc103669c4d553d6fc8b1d02 Mon Sep 17 00:00:00 2001 From: srt Date: Wed, 29 Sep 2010 09:29:46 +0800 Subject: [PATCH] add auto TScalibration in raho --- arch/arm/configs/rk2818_raho_defconfig | 4 +- drivers/input/touchscreen/Kconfig | 85 ++++++------------- drivers/input/touchscreen/Makefile | 2 +- drivers/input/touchscreen/calib_iface_ts.c | 39 +++++---- drivers/input/touchscreen/xpt2046_cbn_ts.c | 14 ++- .../input/touchscreen/xpt2046_ts_320X480.c | 16 ---- 6 files changed, 63 insertions(+), 97 deletions(-) diff --git a/arch/arm/configs/rk2818_raho_defconfig b/arch/arm/configs/rk2818_raho_defconfig index e5e272bbc08e..ee54793c7eeb 100755 --- a/arch/arm/configs/rk2818_raho_defconfig +++ b/arch/arm/configs/rk2818_raho_defconfig @@ -709,8 +709,8 @@ CONFIG_INPUT_TOUCHSCREEN=y # CONFIG_TOUCHSCREEN_AD7877 is not set # CONFIG_TOUCHSCREEN_XPT2046_SPI is not set # CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI is not set -CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI=y -# CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI is not set +# CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI is not set +CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI=y # CONFIG_TOUCHSCREEN_IT7250 is not set # CONFIG_TOUCHSCREEN_AD7879_I2C is not set # CONFIG_TOUCHSCREEN_AD7879_SPI is not set diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index ca38b951ac85..b2857fefd0ad 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -11,6 +11,30 @@ menuconfig INPUT_TOUCHSCREEN if INPUT_TOUCHSCREEN +choice + prompt "XPT2046 based touchscreens: SPI Interface" + default TOUCHSCREEN_XPT2046_CBN_SPI + + config TOUCHSCREEN_XPT2046_SPI_NOCHOOSE + bool "DO NOT CHOOSE TOUCHSCREEN_XPT2046" + + config TOUCHSCREEN_XPT2046_SPI + bool "800X480 TOUCHSCREEN" + depends on SPIM_RK2818 + + config TOUCHSCREEN_XPT2046_CBN_SPI + bool "800X480 CALIBRATION TOUCHSCREEN" + depends on SPIM_RK2818 + + config TOUCHSCREEN_XPT2046_320X480_SPI + bool "320X480 TOUCHSCREEN" + depends on SPIM_RK2818 + + config TOUCHSCREEN_XPT2046_320X480_CBN_SPI + bool "320X480 CALIBRATION TOUCHSCREEN" + depends on SPIM_RK2818 + +endchoice config TOUCHSCREEN_ADS7846 tristate "ADS7846/TSC2046 and ADS7843 based touchscreens" depends on SPI_MASTER @@ -42,57 +66,7 @@ config TOUCHSCREEN_AD7877 To compile this driver as a module, choose M here: the module will be called ad7877. -config TOUCHSCREEN_XPT2046_SPI - tristate "XPT2046 based touchscreens: XPT2046 SPI Interface" - depends on SPIM_RK2818 && TOUCHSCREEN_XPT2046_CBN_SPI = n - help - Say Y here if you have a touchscreen interface using the - xpt2046 controller, and your board-specific initialization - code includes that in its table of SPI devices. - - If unsure, say N (but it's safe to say "Y"). - - To compile this driver as a module, choose M here: the - module will be called xpt2046_ts. - -config TOUCHSCREEN_XPT2046_CBN_SPI - tristate "XPT2046 CALIBRATION based touchscreens: XPT2046 SPI Interface" - depends on SPIM_RK2818 - help - Say Y here if you have a touchscreen interface using the - xpt2046 controller, and your board-specific initialization - code includes that in its table of SPI devices. - - If unsure, say N (but it's safe to say "Y"). - To compile this driver as a module, choose M here: the - module will be called xpt2046_cbn_ts. - -config TOUCHSCREEN_XPT2046_320X480_SPI - tristate "XPT2046 320X480 based touchscreens: XPT2046 SPI Interface" - depends on SPIM_RK2818 && TOUCHSCREEN_XPT2046_320X480_CBN_SPI = n - help - Say Y here if you have a touchscreen interface using the - xpt2046 controller, and your board-specific initialization - code includes that in its table of SPI devices. - - If unsure, say N (but it's safe to say "Y"). - - To compile this driver as a module, choose M here: the - module will be called xpt2046_ts. - -config TOUCHSCREEN_XPT2046_320X480_CBN_SPI - tristate "XPT2046 320X480 CALIBRATION based touchscreens: XPT2046 SPI Interface" - depends on SPIM_RK2818 - help - Say Y here if you have a touchscreen interface using the - xpt2046 controller, and your board-specific initialization - code includes that in its table of SPI devices. - - If unsure, say N (but it's safe to say "Y"). - - To compile this driver as a module, choose M here: the - module will be called xpt2046_cbn_ts. config TOUCHSCREEN_IT7250 tristate "IT7250 based touchscreens: IT7250 Interface" @@ -598,15 +572,4 @@ config TOUCHSCREEN_PCAP To compile this driver as a module, choose M here: the module will be called pcap_ts. -choice - prompt "Touch panel resolution" - default TP_800x480 - - config TP_800x480 - bool "800x480" - - config TP_1024x600 - bool "1024x600" - -endchoice endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index d2c95118dde5..2362f6a338f1 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -46,5 +46,5 @@ obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o obj-$(CONFIG_TOUCHSCREEN_XPT2046_SPI) += xpt2046_ts.o obj-$(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI) += xpt2046_cbn_ts.o calibration_ts.o largenum_ts.o calib_iface_ts.o obj-$(CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI) += xpt2046_ts_320X480.o -#obj-$(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI) += xpt2046_cbn_ts.o calibration_ts.o largenum_ts.o +obj-$(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI) += xpt2046_cbn_ts.o calibration_ts.o largenum_ts.o calib_iface_ts.o obj-$(CONFIG_TOUCHSCREEN_IT7250) += ctp_it7250.o diff --git a/drivers/input/touchscreen/calib_iface_ts.c b/drivers/input/touchscreen/calib_iface_ts.c index 14b9c5332c57..6494d266ba63 100644 --- a/drivers/input/touchscreen/calib_iface_ts.c +++ b/drivers/input/touchscreen/calib_iface_ts.c @@ -32,29 +32,36 @@ extern volatile struct adc_point gADPoint; #ifdef TS_PRESSURE extern volatile int gZvalue[3]; #endif -#ifdef CONFIG_TP_1024x600 -int screen_x[5] = {50, 974, 50, 974, 512}; -int screen_y[5] = {50, 50, 550, 550, 300}; -#endif -#ifdef CONFIG_TP_800x480 -int screen_x[5] = { 50, 750, 50, 750, 400}; -int screen_y[5] = { 40, 40, 440, 440, 240}; + +#if defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI) + int screen_x[5] = { 50, 270, 50, 270, 160}; + int screen_y[5] = { 40, 40, 440, 440, 240}; +#elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI) + int screen_x[5] = { 50, 750, 50, 750, 400}; + int screen_y[5] = { 40, 40, 440, 440, 240}; +#elif defined(CONFIG_TOUCHSCREEN_XPT2046_1024X600_CBN_SPI) + int screen_x[5] = {50, 974, 50, 974, 512}; + int screen_y[5] = {50, 50, 550, 550, 300}; #endif -int uncali_x[5] = { 0 }; -int uncali_y[5] = { 0 }; -#ifdef CONFIG_MACH_RK2818INFO_IT50 -int uncali_x_default[5] = { 3735, 301, 3754, 290, 1993 }; -int uncali_y_default[5] = { 3442, 3497, 413, 459, 1880 }; -#endif -#ifdef CONFIG_MACH_RK2818INFO -int uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 }; -int uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 }; + +#if defined(CONFIG_MACH_RK2818INFO_IT50) && defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI) + int uncali_x_default[5] = { 3735, 301, 3754, 290, 1993 }; + int uncali_y_default[5] = { 3442, 3497, 413, 459, 1880 }; +#elif defined(CONFIG_MACH_RK2818INFO) && defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI) + int uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 }; + int uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 }; +#elif (defined(CONFIG_MACH_RAHO) || defined(CONFIG_MACH_RK2818INFO))&& defined(CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI) + int uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 }; + int uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 }; #endif +int uncali_x[5] = { 0 }; +int uncali_y[5] = { 0 }; + static ssize_t touch_mode_show(struct class *cls, char *_buf) { int count; diff --git a/drivers/input/touchscreen/xpt2046_cbn_ts.c b/drivers/input/touchscreen/xpt2046_cbn_ts.c index ca1bd122a7e3..d0c4eccc985f 100644 --- a/drivers/input/touchscreen/xpt2046_cbn_ts.c +++ b/drivers/input/touchscreen/xpt2046_cbn_ts.c @@ -46,7 +46,7 @@ * note. The strength of filtering can be set in the board-* specific * files. */ -#define XPT2046_DEBUG 0 +#define XPT2046_DEBUG 0 #if XPT2046_DEBUG #define xpt2046printk(msg...) printk(msg); #else @@ -671,10 +671,20 @@ static int __devinit setup_pendown(struct spi_device *spi, struct xpt2046 *ts) return err; } + err = gpio_direction_input(pdata->gpio_pendown); + if (err) { + dev_err(&spi->dev, "failed to switch GPIO to input%d\n", + pdata->gpio_pendown); + return err; + } + + gpio_pull_updown(pdata->gpio_pendown,GPIOPullUp); + ts->gpio_pendown = pdata->gpio_pendown; return 0; } + static int __devinit xpt2046_probe(struct spi_device *spi) { struct xpt2046 *ts; @@ -862,6 +872,8 @@ static int __devinit xpt2046_probe(struct spi_device *spi) goto err_free_gpio; } } + + xpt2046printk("***>%s:touchscreen irq %d\n",__FUNCTION__,spi->irq); /* take a first sample, leaving nPENIRQ active and vREF off; avoid diff --git a/drivers/input/touchscreen/xpt2046_ts_320X480.c b/drivers/input/touchscreen/xpt2046_ts_320X480.c index 0f3de2fcf5c6..565a8b0e73b2 100755 --- a/drivers/input/touchscreen/xpt2046_ts_320X480.c +++ b/drivers/input/touchscreen/xpt2046_ts_320X480.c @@ -201,22 +201,6 @@ struct dfr_req { struct spi_transfer xfer[4]; }; -static struct xpt2046_platform_data xpt2046_info = { - .model = 2046, - .keep_vref_on = 1, - .swap_xy = 0, - .x_min = 0, - .x_max = 320, - .y_min = 0, - .y_max = 480, - .debounce_max = 7, - .debounce_rep = DEBOUNCE_REPTIME, - .debounce_tol = 20, - .gpio_pendown = RK2818_PIN_PE1,//RK2818_PIN_PE3, //modify by zhao - .penirq_recheck_delay_usecs = 1, - -}; - //add by zhao #define LEN_TO_PIX(x) (unsigned int)( 320 * (x) / 47 ) #define KEY1_X 6.3 -- 2.34.1