mirror of
https://github.com/hardkernel/linux.git
synced 2026-04-05 20:53:04 +09:00
drivers/input/touchscreen: remove unused xpt2046 driver
Change-Id: Id8140d167c7aebd7d1bb6de451a275897a49a3f7 Signed-off-by: Tao Huang <huangtao@rock-chips.com>
This commit is contained in:
@@ -1,228 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Export interface in /sys/class/touchpanel for calibration.
|
||||
*
|
||||
* Yongle Lai @ Rockchip - 2010-07-26
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
#include "calibration_ts.h"
|
||||
|
||||
/*
|
||||
* The sys nodes for touch panel calibration depends on controller's name,
|
||||
* such as: /sys/bus/spi/drivers/xpt2046_ts/touchadc
|
||||
* If we use another TP controller (not xpt2046_ts), the above path will
|
||||
* be unavailable which will cause calibration to be fail.
|
||||
*
|
||||
* Another choice is:
|
||||
* sys/devices/platform/rockchip_spi_master/spi0.0/driver/touchadc
|
||||
* this path request the TP controller will be the first device of SPI.
|
||||
*
|
||||
* To make TP calibration module in Android be universal, we create
|
||||
* a class named touchpanel as the path for calibration interfaces.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TPC driver depended.
|
||||
*/
|
||||
extern volatile struct adc_point gADPoint;
|
||||
#ifdef TS_PRESSURE
|
||||
extern volatile int gZvalue[3];
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#if defined(CONFIG_MACH_RK2818INFO_IT50) && defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
|
||||
int screen_x[5] = { 50, 750, 50, 750, 400};
|
||||
int screen_y[5] = { 40, 40, 440, 440, 240};
|
||||
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 screen_x[5] = { 50, 750, 50, 750, 400};
|
||||
int screen_y[5] = { 40, 40, 440, 440, 240};
|
||||
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_RAHOSDK) || defined(CONFIG_MACH_RK2818INFO))&& 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};
|
||||
int uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 };
|
||||
int uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 };
|
||||
#elif defined(CONFIG_MACH_Z5) && defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
|
||||
int uncali_x_default[5] = { 3267, 831, 3139, 715, 1845 };
|
||||
int uncali_y_default[5] = { 3638, 3664, 564, 591, 2087 };
|
||||
int screen_x[5] = { 70, 410, 70, 410, 240};
|
||||
int screen_y[5] = { 50, 50, 740, 740, 400};
|
||||
#endif
|
||||
#endif
|
||||
int screen_x[5] = { 0 };
|
||||
int screen_y[5] = { 0 };
|
||||
int uncali_x_default[5] = { 0 };
|
||||
int uncali_y_default[5] = { 0 };
|
||||
int uncali_x[5] = { 0 };
|
||||
int uncali_y[5] = { 0 };
|
||||
|
||||
static ssize_t touch_mode_show(struct class *cls, char *_buf)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = sprintf(_buf,"TouchCheck:%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
|
||||
uncali_x[0], uncali_y[0],
|
||||
uncali_x[1], uncali_y[1],
|
||||
uncali_x[2], uncali_y[2],
|
||||
uncali_x[3], uncali_y[3],
|
||||
uncali_x[4], uncali_y[4]);
|
||||
|
||||
printk("buf: %s", _buf);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t touch_mode_store(struct class *cls, const char *_buf, size_t _count)
|
||||
{
|
||||
int i, j = 0;
|
||||
char temp[5];
|
||||
|
||||
//printk("Read data from Android: %s\n", _buf);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
strncpy(temp, _buf + 5 * (j++), 4);
|
||||
uncali_x[i] = simple_strtol(temp, NULL, 10);
|
||||
strncpy(temp, _buf + 5 * (j++), 4);
|
||||
uncali_y[i] = simple_strtol(temp, NULL, 10);
|
||||
printk("SN=%d uncali_x=%d uncali_y=%d\n",
|
||||
i, uncali_x[i], uncali_y[i]);
|
||||
}
|
||||
|
||||
return _count;
|
||||
}
|
||||
|
||||
//This code is Touch adc simple value
|
||||
static ssize_t touch_adc_show(struct class *cls,char *_buf)
|
||||
{
|
||||
printk("ADC show: x=%d y=%d\n", gADPoint.x, gADPoint.y);
|
||||
|
||||
return sprintf(_buf, "%d,%d\n", gADPoint.x, gADPoint.y);
|
||||
}
|
||||
|
||||
static ssize_t touch_cali_status(struct class *cls, char *_buf)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = TouchPanelSetCalibration(4, screen_x, screen_y, uncali_x, uncali_y);
|
||||
if (ret == 1){
|
||||
memcpy(uncali_x_default, uncali_x, sizeof(uncali_x));
|
||||
memcpy(uncali_y_default, uncali_y, sizeof(uncali_y));
|
||||
printk("touch_cali_status-0--%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
|
||||
uncali_x_default[0], uncali_y_default[0],
|
||||
uncali_x_default[1], uncali_y_default[1],
|
||||
uncali_x_default[2], uncali_y_default[2],
|
||||
uncali_x_default[3], uncali_y_default[3],
|
||||
uncali_x_default[4], uncali_y_default[4]);
|
||||
ret = sprintf(_buf, "successful\n");
|
||||
}
|
||||
else{
|
||||
printk("touchpal calibration failed, use default value.\n");
|
||||
ret = TouchPanelSetCalibration(4, screen_x, screen_y, uncali_x_default, uncali_y_default);
|
||||
printk("touch_cali_status-1---%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
|
||||
uncali_x_default[0], uncali_y_default[0],
|
||||
uncali_x_default[1], uncali_y_default[1],
|
||||
uncali_x_default[2], uncali_y_default[2],
|
||||
uncali_x_default[3], uncali_y_default[3],
|
||||
uncali_x_default[4], uncali_y_default[4]);
|
||||
if (ret == 1){
|
||||
ret = sprintf(_buf, "recovery\n");
|
||||
}
|
||||
else{
|
||||
ret = sprintf(_buf, "fail\n");
|
||||
}
|
||||
}
|
||||
|
||||
//printk("Calibration status: _buf=<%s", _buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#ifdef TS_PRESSURE
|
||||
static ssize_t touch_pressure(struct class *cls,char *_buf)
|
||||
{
|
||||
printk("enter %s gADPoint.x==%d,gADPoint.y==%d\n",__FUNCTION__,gADPoint.x,gADPoint.y);
|
||||
return sprintf(_buf,"%d,%d,%d\n",gZvalue[0],gZvalue[1],gZvalue[2]);
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct class *tp_class = NULL;
|
||||
|
||||
static CLASS_ATTR(touchcheck, 0666, touch_mode_show, touch_mode_store);
|
||||
static CLASS_ATTR(touchadc, 0666, touch_adc_show, NULL);
|
||||
static CLASS_ATTR(calistatus, 0666, touch_cali_status, NULL);
|
||||
#ifdef TS_PRESSURE
|
||||
static CLASS_ATTR(pressure, 0666, touch_pressure, NULL);
|
||||
#endif
|
||||
|
||||
int tp_calib_iface_init(int *x,int *y,int *uncali_x, int *uncali_y)
|
||||
{
|
||||
int ret = 0;
|
||||
int err = 0;
|
||||
|
||||
tp_class = class_create(THIS_MODULE, "touchpanel");
|
||||
if (IS_ERR(tp_class))
|
||||
{
|
||||
printk("Create class touchpanel failed.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(screen_x,x,5*sizeof(int));
|
||||
memcpy(screen_y,y,5*sizeof(int));
|
||||
memcpy(uncali_x_default,uncali_x,5*sizeof(int));
|
||||
memcpy(uncali_y_default,uncali_y,5*sizeof(int));
|
||||
|
||||
err = TouchPanelSetCalibration(4, screen_x, screen_y, uncali_x_default, uncali_y_default);
|
||||
printk("tp_calib_iface_init---%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
|
||||
uncali_x_default[0], uncali_y_default[0],
|
||||
uncali_x_default[1], uncali_y_default[1],
|
||||
uncali_x_default[2], uncali_y_default[2],
|
||||
uncali_x_default[3], uncali_y_default[3],
|
||||
uncali_x_default[4], uncali_y_default[4]);
|
||||
if (err == 1){
|
||||
printk("Auto set calibration successfully.\n");
|
||||
} else {
|
||||
printk("Auto set calibraion failed, reset data again please !");
|
||||
}
|
||||
|
||||
/*
|
||||
* Create ifaces for TP calibration.
|
||||
*/
|
||||
ret = class_create_file(tp_class, &class_attr_touchcheck);
|
||||
ret += class_create_file(tp_class, &class_attr_touchadc);
|
||||
ret += class_create_file(tp_class, &class_attr_calistatus);
|
||||
#ifdef TS_PRESSURE
|
||||
ret += class_create_file(tp_class, &class_attr_pressure);
|
||||
#endif
|
||||
if (ret)
|
||||
{
|
||||
printk("Fail to class ifaces for TP calibration.\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void tp_calib_iface_exit(void)
|
||||
{
|
||||
class_remove_file(tp_class, &class_attr_touchcheck);
|
||||
class_remove_file(tp_class, &class_attr_touchadc);
|
||||
class_remove_file(tp_class, &class_attr_calistatus);
|
||||
#ifdef TS_PRESSURE
|
||||
class_remove_file(tp_class, &class_attr_pressure);
|
||||
#endif
|
||||
class_destroy(tp_class);
|
||||
}
|
||||
|
||||
//module_init(tp_calib_iface_init);
|
||||
//module_exit(tp_calib_iface_exit);
|
||||
|
||||
MODULE_AUTHOR("Yongle Lai");
|
||||
MODULE_DESCRIPTION("XPT2046 TPC driver @ Rockchip");
|
||||
MODULE_LICENSE("GPL");
|
||||
@@ -1,655 +0,0 @@
|
||||
/*
|
||||
* drivers/input/touchscreen/calibration_ts.c - calibration for rk2818 spi xpt2046 device and console
|
||||
*
|
||||
* Copyright (C) 2010 ROCKCHIP, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include "calibration_ts.h"
|
||||
#include "largenum_ts.h"
|
||||
|
||||
#define MAX_POINT_ERROR 6
|
||||
|
||||
typedef struct {
|
||||
PLARGENUM pa11, pa12, pa13;
|
||||
PLARGENUM pa21, pa22, pa23;
|
||||
PLARGENUM pa31, pa32, pa33;
|
||||
} MATRIX33, *PMATRIX33;
|
||||
|
||||
typedef struct {
|
||||
int a1;
|
||||
int b1;
|
||||
int c1;
|
||||
int a2;
|
||||
int b2;
|
||||
int c2;
|
||||
int delta;
|
||||
}
|
||||
CALIBRATION_PARAMETER, *PCALIBRATION_PARAMETER;
|
||||
|
||||
static unsigned char v_Calibrated = 0;
|
||||
static CALIBRATION_PARAMETER v_CalcParam ={
|
||||
.a1 =18670 ,
|
||||
.b1 =98,
|
||||
.c1 = -2230109,
|
||||
.a2 = 291,
|
||||
.b2 = 12758,
|
||||
.c2 = -5118934,
|
||||
.delta = 91931,
|
||||
};
|
||||
static CALIBRATION_PARAMETER v_CalcParam_bak = {
|
||||
.a1=17704 ,
|
||||
.b1=-20,
|
||||
.c1= -1460283,
|
||||
.a2 = 382,
|
||||
.b2 = 12685,
|
||||
.c2 = -5595261,
|
||||
.delta = 88403,
|
||||
};
|
||||
unsigned char
|
||||
ErrorAnalysis(
|
||||
int cCalibrationPoints, //@PARM The number of calibration points
|
||||
int *pScreenXBuffer, //@PARM List of screen X coords displayed
|
||||
int *pScreenYBuffer, //@PARM List of screen Y coords displayed
|
||||
int *pUncalXBuffer, //@PARM List of X coords collected
|
||||
int *pUncalYBuffer //@PARM List of Y coords collected
|
||||
);
|
||||
|
||||
void
|
||||
ComputeMatrix33(
|
||||
PLARGENUM pResult,
|
||||
PMATRIX33 pMatrix
|
||||
);
|
||||
|
||||
unsigned char
|
||||
TouchPanelSetCalibration(
|
||||
int cCalibrationPoints, //@PARM The number of calibration points
|
||||
int *pScreenXBuffer, //@PARM List of screen X coords displayed
|
||||
int *pScreenYBuffer, //@PARM List of screen Y coords displayed
|
||||
int *pUncalXBuffer, //@PARM List of X coords collected
|
||||
int *pUncalYBuffer //@PARM List of Y coords collected
|
||||
)
|
||||
{
|
||||
LARGENUM a11;
|
||||
LARGENUM a21, a22;
|
||||
LARGENUM a31, a32, a33;
|
||||
LARGENUM b11, b12, b13;
|
||||
LARGENUM b21, b22, b23;
|
||||
LARGENUM lnScreenX;
|
||||
LARGENUM lnScreenY;
|
||||
LARGENUM lnTouchX;
|
||||
LARGENUM lnTouchY;
|
||||
LARGENUM lnTemp;
|
||||
LARGENUM delta;
|
||||
LARGENUM a1, b1, c1;
|
||||
LARGENUM a2, b2, c2;
|
||||
MATRIX33 Matrix;
|
||||
int cShift;
|
||||
int minShift;
|
||||
int i;
|
||||
|
||||
|
||||
//DEBUGMSG(1,(__TEXT("calibrating %d point set\r\n"), cCalibrationPoints));
|
||||
|
||||
//
|
||||
// If the calibration data is being cleared, set the flag so
|
||||
// that the conversion operation is a noop.
|
||||
//
|
||||
|
||||
if ( cCalibrationPoints == 0 )
|
||||
{
|
||||
v_Calibrated = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Compute these large numbers
|
||||
//
|
||||
LargeNumSet(&a11, 0);
|
||||
LargeNumSet(&a21, 0);
|
||||
LargeNumSet(&a31, 0);
|
||||
LargeNumSet(&a22, 0);
|
||||
LargeNumSet(&a32, 0);
|
||||
LargeNumSet(&a33, cCalibrationPoints);
|
||||
LargeNumSet(&b11, 0);
|
||||
LargeNumSet(&b12, 0);
|
||||
LargeNumSet(&b13, 0);
|
||||
LargeNumSet(&b21, 0);
|
||||
LargeNumSet(&b22, 0);
|
||||
LargeNumSet(&b23, 0);
|
||||
for(i=0; i<cCalibrationPoints; i++){
|
||||
LargeNumSet(&lnTouchX, pUncalXBuffer[i]);
|
||||
LargeNumSet(&lnTouchY, pUncalYBuffer[i]);
|
||||
LargeNumSet(&lnScreenX, pScreenXBuffer[i]);
|
||||
LargeNumSet(&lnScreenY, pScreenYBuffer[i]);
|
||||
LargeNumMult(&lnTouchX, &lnTouchX, &lnTemp);
|
||||
LargeNumAdd(&a11, &lnTemp, &a11);
|
||||
LargeNumMult(&lnTouchX, &lnTouchY, &lnTemp);
|
||||
LargeNumAdd(&a21, &lnTemp, &a21);
|
||||
LargeNumAdd(&a31, &lnTouchX, &a31);
|
||||
LargeNumMult(&lnTouchY, &lnTouchY, &lnTemp);
|
||||
LargeNumAdd(&a22, &lnTemp, &a22);
|
||||
LargeNumAdd(&a32, &lnTouchY, &a32);
|
||||
LargeNumMult(&lnTouchX, &lnScreenX, &lnTemp);
|
||||
LargeNumAdd(&b11, &lnTemp, &b11);
|
||||
LargeNumMult(&lnTouchY, &lnScreenX, &lnTemp);
|
||||
LargeNumAdd(&b12, &lnTemp, &b12);
|
||||
LargeNumAdd(&b13, &lnScreenX, &b13);
|
||||
LargeNumMult(&lnTouchX, &lnScreenY, &lnTemp);
|
||||
LargeNumAdd(&b21, &lnTemp, &b21);
|
||||
LargeNumMult(&lnTouchY, &lnScreenY, &lnTemp);
|
||||
LargeNumAdd(&b22, &lnTemp, &b22);
|
||||
LargeNumAdd(&b23, &lnScreenY, &b23);
|
||||
}
|
||||
|
||||
Matrix.pa11 = &a11;
|
||||
Matrix.pa21 = &a21;
|
||||
Matrix.pa31 = &a31;
|
||||
Matrix.pa12 = &a21;
|
||||
Matrix.pa22 = &a22;
|
||||
Matrix.pa32 = &a32;
|
||||
Matrix.pa13 = &a31;
|
||||
Matrix.pa23 = &a32;
|
||||
Matrix.pa33 = &a33;
|
||||
ComputeMatrix33(&delta, &Matrix);
|
||||
|
||||
Matrix.pa11 = &b11;
|
||||
Matrix.pa21 = &b12;
|
||||
Matrix.pa31 = &b13;
|
||||
ComputeMatrix33(&a1, &Matrix);
|
||||
|
||||
Matrix.pa11 = &a11;
|
||||
Matrix.pa21 = &a21;
|
||||
Matrix.pa31 = &a31;
|
||||
Matrix.pa12 = &b11;
|
||||
Matrix.pa22 = &b12;
|
||||
Matrix.pa32 = &b13;
|
||||
ComputeMatrix33(&b1, &Matrix);
|
||||
|
||||
Matrix.pa12 = &a21;
|
||||
Matrix.pa22 = &a22;
|
||||
Matrix.pa32 = &a32;
|
||||
Matrix.pa13 = &b11;
|
||||
Matrix.pa23 = &b12;
|
||||
Matrix.pa33 = &b13;
|
||||
ComputeMatrix33(&c1, &Matrix);
|
||||
|
||||
Matrix.pa13 = &a31;
|
||||
Matrix.pa23 = &a32;
|
||||
Matrix.pa33 = &a33;
|
||||
Matrix.pa11 = &b21;
|
||||
Matrix.pa21 = &b22;
|
||||
Matrix.pa31 = &b23;
|
||||
ComputeMatrix33(&a2, &Matrix);
|
||||
|
||||
Matrix.pa11 = &a11;
|
||||
Matrix.pa21 = &a21;
|
||||
Matrix.pa31 = &a31;
|
||||
Matrix.pa12 = &b21;
|
||||
Matrix.pa22 = &b22;
|
||||
Matrix.pa32 = &b23;
|
||||
ComputeMatrix33(&b2, &Matrix);
|
||||
|
||||
Matrix.pa12 = &a21;
|
||||
Matrix.pa22 = &a22;
|
||||
Matrix.pa32 = &a32;
|
||||
Matrix.pa13 = &b21;
|
||||
Matrix.pa23 = &b22;
|
||||
Matrix.pa33 = &b23;
|
||||
ComputeMatrix33(&c2, &Matrix);
|
||||
|
||||
#if 1
|
||||
{
|
||||
LARGENUM halfDelta;
|
||||
//
|
||||
// Take care of possible truncation error in later mapping operations
|
||||
//
|
||||
if(IsLargeNumNegative(&delta)){
|
||||
LargeNumDivInt32(&delta, -2, &halfDelta);
|
||||
} else {
|
||||
LargeNumDivInt32(&delta, 2, &halfDelta);
|
||||
}
|
||||
LargeNumAdd(&c1, &halfDelta, &c1);
|
||||
LargeNumAdd(&c2, &halfDelta, &c2);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// All the numbers are determined now.
|
||||
// Let's scale them back to 32 bit world
|
||||
//
|
||||
minShift = 0;
|
||||
cShift = LargeNumBits(&a1) - MAX_COEFF_PRECISION;
|
||||
if(cShift > minShift){
|
||||
minShift = cShift;
|
||||
}
|
||||
cShift = LargeNumBits(&b1) - MAX_COEFF_PRECISION;
|
||||
if(cShift > minShift){
|
||||
minShift = cShift;
|
||||
}
|
||||
cShift = LargeNumBits(&a2) - MAX_COEFF_PRECISION;
|
||||
if(cShift > minShift){
|
||||
minShift = cShift;
|
||||
}
|
||||
cShift = LargeNumBits(&b2) - MAX_COEFF_PRECISION;
|
||||
if(cShift > minShift){
|
||||
minShift = cShift;
|
||||
}
|
||||
cShift = LargeNumBits(&c1) - MAX_TERM_PRECISION;
|
||||
if(cShift > minShift){
|
||||
minShift = cShift;
|
||||
}
|
||||
cShift = LargeNumBits(&c2) - MAX_TERM_PRECISION;
|
||||
if(cShift > minShift){
|
||||
minShift = cShift;
|
||||
}
|
||||
cShift = LargeNumBits(&delta) - 31;
|
||||
if(cShift > minShift){
|
||||
minShift = cShift;
|
||||
}
|
||||
|
||||
//
|
||||
// Now, shift count is determined, shift all the numbers
|
||||
// right to obtain the 32-bit signed values
|
||||
//
|
||||
if(minShift){
|
||||
LargeNumRAShift(&a1, minShift);
|
||||
LargeNumRAShift(&a2, minShift);
|
||||
LargeNumRAShift(&b1, minShift);
|
||||
LargeNumRAShift(&b2, minShift);
|
||||
LargeNumRAShift(&c1, minShift);
|
||||
LargeNumRAShift(&c2, minShift);
|
||||
LargeNumRAShift(&delta, minShift);
|
||||
}
|
||||
v_CalcParam.a1 = a1.u.s32.u[0];
|
||||
v_CalcParam.b1 = b1.u.s32.u[0];
|
||||
v_CalcParam.c1 = c1.u.s32.u[0];
|
||||
v_CalcParam.a2 = a2.u.s32.u[0];
|
||||
v_CalcParam.b2 = b2.u.s32.u[0];
|
||||
v_CalcParam.c2 = c2.u.s32.u[0];
|
||||
v_CalcParam.delta = delta.u.s32.u[0];
|
||||
|
||||
// Don't allow delta to be zero, since it gets used as a divisor
|
||||
if( ! v_CalcParam.delta )
|
||||
{
|
||||
//RETAILMSG(1,(__TEXT("TouchPanelSetCalibration: delta of 0 invalid\r\n")));
|
||||
//RETAILMSG(1,(__TEXT("\tCalibration failed.\r\n")));
|
||||
v_CalcParam.delta = 1; // any non-zero value to prevents DivByZero traps later
|
||||
v_Calibrated = 0;
|
||||
}
|
||||
else
|
||||
v_Calibrated = 1;
|
||||
|
||||
return ErrorAnalysis(
|
||||
cCalibrationPoints,
|
||||
pScreenXBuffer,
|
||||
pScreenYBuffer,
|
||||
pUncalXBuffer,
|
||||
pUncalYBuffer
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
ComputeMatrix33(
|
||||
PLARGENUM pResult,
|
||||
PMATRIX33 pMatrix
|
||||
)
|
||||
{
|
||||
LARGENUM lnTemp;
|
||||
|
||||
LargeNumMult(pMatrix->pa11, pMatrix->pa22, &lnTemp);
|
||||
LargeNumMult(pMatrix->pa33, &lnTemp, pResult);
|
||||
LargeNumMult(pMatrix->pa21, pMatrix->pa32, &lnTemp);
|
||||
LargeNumMult(pMatrix->pa13, &lnTemp, &lnTemp);
|
||||
LargeNumAdd(pResult, &lnTemp, pResult);
|
||||
LargeNumMult(pMatrix->pa12, pMatrix->pa23, &lnTemp);
|
||||
LargeNumMult(pMatrix->pa31, &lnTemp, &lnTemp);
|
||||
LargeNumAdd(pResult, &lnTemp, pResult);
|
||||
LargeNumMult(pMatrix->pa13, pMatrix->pa22, &lnTemp);
|
||||
LargeNumMult(pMatrix->pa31, &lnTemp, &lnTemp);
|
||||
LargeNumSub(pResult, &lnTemp, pResult);
|
||||
LargeNumMult(pMatrix->pa12, pMatrix->pa21, &lnTemp);
|
||||
LargeNumMult(pMatrix->pa33, &lnTemp, &lnTemp);
|
||||
LargeNumSub(pResult, &lnTemp, pResult);
|
||||
LargeNumMult(pMatrix->pa23, pMatrix->pa32, &lnTemp);
|
||||
LargeNumMult(pMatrix->pa11, &lnTemp, &lnTemp);
|
||||
LargeNumSub(pResult, &lnTemp, pResult);
|
||||
}
|
||||
|
||||
void
|
||||
TouchPanelCalibrateAPoint(
|
||||
int UncalX, //@PARM The uncalibrated X coordinate
|
||||
int UncalY, //@PARM The uncalibrated Y coordinate
|
||||
int *pCalX, //@PARM The calibrated X coordinate
|
||||
int *pCalY //@PARM The calibrated Y coordinate
|
||||
)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if ( v_Calibrated )
|
||||
{
|
||||
|
||||
//
|
||||
// Note the *4 in the expression below. This is a workaround
|
||||
// on behalf of gwe. It provides a form of
|
||||
// sub-pixel accuracy desirable for inking
|
||||
//
|
||||
x = (v_CalcParam.a1 * UncalX + v_CalcParam.b1 * UncalY +
|
||||
v_CalcParam.c1) * 4 / v_CalcParam.delta;
|
||||
y = (v_CalcParam.a2 * UncalX + v_CalcParam.b2 * UncalY +
|
||||
v_CalcParam.c2) * 4 / v_CalcParam.delta;
|
||||
}
|
||||
else{
|
||||
x = (v_CalcParam_bak.a1 * UncalX + v_CalcParam_bak.b1 * UncalY +
|
||||
v_CalcParam_bak.c1) * 4 / v_CalcParam_bak.delta;
|
||||
y = (v_CalcParam_bak.a2 * UncalX + v_CalcParam_bak.b2 * UncalY +
|
||||
v_CalcParam_bak.c2) * 4 / v_CalcParam_bak.delta;
|
||||
}
|
||||
if ( x < 0 ){
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if (y < 0 ){
|
||||
y = 0;
|
||||
}
|
||||
|
||||
*pCalX = x;
|
||||
*pCalY = y;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
ErrorAnalysis(
|
||||
int cCalibrationPoints, //@PARM The number of calibration points
|
||||
int *pScreenXBuffer, //@PARM List of screen X coords displayed
|
||||
int *pScreenYBuffer, //@PARM List of screen Y coords displayed
|
||||
int *pUncalXBuffer, //@PARM List of X coords collected
|
||||
int *pUncalYBuffer //@PARM List of Y coords collected
|
||||
)
|
||||
{
|
||||
int i;
|
||||
unsigned int maxErr, err;
|
||||
int x,y;
|
||||
int dx,dy;
|
||||
unsigned int errThreshold = MAX_POINT_ERROR; // Can be overridden by registry entry
|
||||
#if 0
|
||||
unsigned int status, ValType, ValLen;
|
||||
|
||||
//HKEY regKey;
|
||||
|
||||
|
||||
// See if there is a Maximum Calibration Error specified in the registry
|
||||
//status = RegOpenKeyEx(
|
||||
// HKEY_LOCAL_MACHINE,
|
||||
// __TEXT("HARDWARE\\DEVICEMAP\\TOUCH"),
|
||||
// 0,
|
||||
// 0,
|
||||
// ®Key);
|
||||
if ( status == ERROR_SUCCESS ) {
|
||||
ValLen = sizeof(errThreshold);
|
||||
status = RegQueryValueEx(
|
||||
regKey,
|
||||
__TEXT("MaxCalError"),
|
||||
NULL,
|
||||
&ValType,
|
||||
(PUCHAR)&errThreshold,
|
||||
&ValLen);
|
||||
// We don't care what happened. Either we have a new value or we have the default value.
|
||||
RegCloseKey(regKey);
|
||||
}
|
||||
|
||||
RETAILMSG(1,(__TEXT("Maximum Allowed Error %d:\r\n"),
|
||||
errThreshold));
|
||||
DEBUGMSG(1,(__TEXT("Calibration Results:\r\n")));
|
||||
#endif
|
||||
|
||||
maxErr = 0;
|
||||
//DEBUGMSG(1,(__TEXT(" Screen => Mapped\r\n")));
|
||||
for(i=0; i<cCalibrationPoints; i++){
|
||||
TouchPanelCalibrateAPoint( pUncalXBuffer[i],
|
||||
pUncalYBuffer[i],
|
||||
&x,
|
||||
&y
|
||||
);
|
||||
x /= 4;
|
||||
y /= 4;
|
||||
printk("(%4d, %4d) => (%4d, %4d)\n",
|
||||
//DEBUGMSG(1,(__TEXT("(%4d, %4d) => (%4d, %4d)\r\n"),
|
||||
pScreenXBuffer[i],
|
||||
pScreenYBuffer[i],
|
||||
x,
|
||||
y
|
||||
);
|
||||
|
||||
dx = x - pScreenXBuffer[i];
|
||||
dy = y - pScreenYBuffer[i];
|
||||
err = dx * dx + dy * dy;
|
||||
if(err > maxErr){
|
||||
maxErr = err;
|
||||
}
|
||||
}
|
||||
//DEBUGMSG(1,(__TEXT("Maximum error (square of Euclidean distance in screen units) = %u\r\n"),
|
||||
// maxErr
|
||||
// ));
|
||||
|
||||
if (maxErr < (errThreshold * errThreshold))
|
||||
{
|
||||
printk(" v_CalcParam.a1=%d \n"
|
||||
"v_CalcParam.b1=%d\n"
|
||||
"v_CalcParam.c1= %d\n"
|
||||
" v_CalcParam.a2 = %d\n"
|
||||
" v_CalcParam.b2 = %d\n"
|
||||
" v_CalcParam.c2 = %d\n"
|
||||
"v_CalcParam.delta = %d\n",
|
||||
v_CalcParam.a1 , \
|
||||
v_CalcParam.b1 , \
|
||||
v_CalcParam.c1 , \
|
||||
v_CalcParam.a2 , \
|
||||
v_CalcParam.b2, \
|
||||
v_CalcParam.c2 , \
|
||||
v_CalcParam.delta);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&v_CalcParam, 0, sizeof(v_CalcParam));
|
||||
v_Calibrated = 0;
|
||||
v_CalcParam.a1 = v_CalcParam_bak.a1;
|
||||
v_CalcParam.b1 = v_CalcParam_bak.b1 ;
|
||||
v_CalcParam.c1= v_CalcParam_bak.c1;
|
||||
v_CalcParam.a2 = v_CalcParam_bak.a2;
|
||||
v_CalcParam.b2 = v_CalcParam_bak.b2;
|
||||
v_CalcParam.c2 = v_CalcParam_bak.c2;
|
||||
v_CalcParam.delta= v_CalcParam_bak.delta;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define FILTER_BUF_LEN 8
|
||||
typedef struct
|
||||
{
|
||||
unsigned short x;
|
||||
unsigned short y;
|
||||
}P;
|
||||
static P sTouchFilterBuff[FILTER_BUF_LEN];
|
||||
static int sBuffIndex = 0;
|
||||
static P sReportFilter = {0,0};
|
||||
void ClearBuff(void)
|
||||
{
|
||||
memset(sTouchFilterBuff,0,FILTER_BUF_LEN*sizeof(P));
|
||||
sReportFilter.x = 0;
|
||||
sReportFilter.y = 0;
|
||||
sBuffIndex = 0;
|
||||
}
|
||||
void addToBuff(int* x,int* y)
|
||||
{
|
||||
int index;
|
||||
index=sBuffIndex++%FILTER_BUF_LEN;
|
||||
sTouchFilterBuff[index].x = *x;
|
||||
sTouchFilterBuff[index].y = *y;
|
||||
}
|
||||
#define TS_ERR_TDOWN -1
|
||||
#define TS_ERR_LOWBUF -2
|
||||
//#define TS_MINX 138
|
||||
//#define TS_MINY 375
|
||||
//#define TS_MAXX 3935
|
||||
//#define TS_MAXY 3920
|
||||
//#define TS_xISVALID(x) (x>=TS_MINX&&x<=TS_MAXX)
|
||||
#define TS_isINVALID(X,Y) (X==4095||Y==4095||X==0||Y==0)
|
||||
#define ABS(x) ((x)>0?(x):-(x))
|
||||
static P spoint;
|
||||
int TouchFilter(unsigned short* x,unsigned short* y,bool isdown)
|
||||
{
|
||||
#if 1
|
||||
int ret = 0;
|
||||
if(isdown==0&&sBuffIndex==0)
|
||||
{
|
||||
spoint.x = *x;
|
||||
spoint.y = *y;
|
||||
ClearBuff();
|
||||
ret=TS_ERR_TDOWN;
|
||||
}
|
||||
if(!TS_isINVALID(*x,*y))
|
||||
addToBuff(x,y);
|
||||
if(sBuffIndex<FILTER_BUF_LEN)
|
||||
ret=TS_ERR_LOWBUF;
|
||||
if(ret==0)
|
||||
{
|
||||
P *p = sTouchFilterBuff;
|
||||
P *p1 = p+1;
|
||||
int index =0;
|
||||
while(1)
|
||||
{
|
||||
if(ABS(p->x-p1->x)<60||ABS(p->y-p1->y)<60)
|
||||
{
|
||||
*x=spoint.x;
|
||||
*y=spoint.y;
|
||||
//printk("p(%d,%d) p1(%d,%d)\n",p->x,p->y,p1->x,p1->y);
|
||||
//ret=-3;
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
p1++;
|
||||
if(++index>=FILTER_BUF_LEN-1)break;
|
||||
}
|
||||
spoint.x=*x;
|
||||
spoint.y=*y;
|
||||
}
|
||||
|
||||
#else
|
||||
int ret = 0;
|
||||
if(isdown==0&&sBuffIndex==0)
|
||||
{
|
||||
ClearBuff();
|
||||
ret=TS_ERR_TDOWN;
|
||||
}
|
||||
if(!TS_isINVALID(x,y))
|
||||
addToBuff(x,y);
|
||||
if(sBuffIndex<FILTER_BUF_LEN)
|
||||
ret=TS_ERR_LOWBUF;
|
||||
if(ret==0)
|
||||
{
|
||||
P adp;
|
||||
int index =0;
|
||||
while(1)
|
||||
{
|
||||
adp.x+=sTouchFilterBuff[index].x;
|
||||
adp.y+=sTouchFilterBuff[index].y;
|
||||
if(++index>=FILTER_BUF_LEN)break;
|
||||
}
|
||||
*x = adp.x/FILTER_BUF_LEN;
|
||||
*y = adp.y/FILTER_BUF_LEN;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
#define SLAP_X 2
|
||||
#define SLAP_Y 0
|
||||
void TouchReportFilter(unsigned short* x,unsigned short* y)
|
||||
{
|
||||
if((sReportFilter.x==0&&sReportFilter.y==0)||
|
||||
(ABS(sReportFilter.x - *x)>SLAP_X&&ABS(sReportFilter.y - *y)>SLAP_Y))
|
||||
{
|
||||
sReportFilter.x = *x;
|
||||
sReportFilter.y = *y;
|
||||
}
|
||||
*x = sReportFilter.x;
|
||||
*y = sReportFilter.y;
|
||||
}
|
||||
#if 0
|
||||
int main(void)
|
||||
{
|
||||
unsigned char ret;
|
||||
int cali_num = 4;
|
||||
int screen_x[4], screen_y[4];
|
||||
int uncali_x[4], uncali_y[4];
|
||||
int tst_uncali_x, tst_uncali_y, tst_cali_x, tst_cali_y;
|
||||
|
||||
screen_x[0] = 15; screen_y[0] = 15;
|
||||
screen_x[1] = 15; screen_y[1] = 465;
|
||||
screen_x[2] = 785; screen_y[2] = 15;
|
||||
screen_x[3] = 785; screen_y[3] = 465;
|
||||
|
||||
uncali_x[0] = 173; uncali_y[0] = 417;
|
||||
uncali_x[1] = 148; uncali_y[1] = 3867;
|
||||
uncali_x[2] = 3903; uncali_y[2] = 365;
|
||||
uncali_x[3] = 3924; uncali_y[3] = 3863;
|
||||
|
||||
ret = TouchPanelSetCalibration(4, screen_x,
|
||||
screen_y, uncali_x, uncali_y);
|
||||
if (ret == 1)
|
||||
printf("TouchPanelSetCalibration OK.\n");
|
||||
else
|
||||
printf("TouchPanelSetCalibration FAIL.\n");
|
||||
|
||||
tst_uncali_x = 2033;
|
||||
tst_uncali_y = 2132;
|
||||
|
||||
TouchPanelCalibrateAPoint(tst_uncali_x, tst_uncali_y,
|
||||
&tst_cali_x, &tst_cali_y);
|
||||
|
||||
printf("(%d, %d) >> (%d, %d)\n", tst_uncali_x, tst_uncali_y,
|
||||
tst_cali_x/4, tst_cali_y/4);
|
||||
|
||||
tst_uncali_x = 170;
|
||||
tst_uncali_y = 418;
|
||||
|
||||
TouchPanelCalibrateAPoint(tst_uncali_x, tst_uncali_y,
|
||||
&tst_cali_x, &tst_cali_y);
|
||||
|
||||
printf("(%d, %d) >> (%d, %d)\n", tst_uncali_x, tst_uncali_y,
|
||||
tst_cali_x/4, tst_cali_y/4);
|
||||
|
||||
tst_uncali_x = 500;
|
||||
tst_uncali_y = 707;
|
||||
|
||||
TouchPanelCalibrateAPoint(tst_uncali_x, tst_uncali_y,
|
||||
&tst_cali_x, &tst_cali_y);
|
||||
|
||||
printf("(%d, %d) >> (%d, %d)\n", tst_uncali_x, tst_uncali_y,
|
||||
tst_cali_x/4, tst_cali_y/4);
|
||||
|
||||
tst_uncali_x = 3636;
|
||||
tst_uncali_y = 2150;
|
||||
|
||||
TouchPanelCalibrateAPoint(tst_uncali_x, tst_uncali_y,
|
||||
&tst_cali_x, &tst_cali_y);
|
||||
|
||||
printf("(%d, %d) >> (%d, %d)\n", tst_uncali_x, tst_uncali_y,
|
||||
tst_cali_x/4, tst_cali_y/4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* drivers/input/touchscreen/calibration_ts.h
|
||||
*
|
||||
* Copyright (C) 2010 ROCKCHIP, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __DRIVERS_TOUCHSCREEN_CALIBRATION_TS_H
|
||||
#define __DRIVERS_TOUCHSCREEN_CALIBRATION_TS_H
|
||||
|
||||
struct adc_point
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
#define TWO_DIMENSIONAL_CALIBRATION 1
|
||||
|
||||
#define ADC_PRECISION 12 // Precision of ADC output (in bits)
|
||||
#define MAX_TERM_PRECISION 27 // Reserve 1 bit for sign and two bits for
|
||||
// three terms (there are three terms in
|
||||
// each of x and y mapping functions.)
|
||||
|
||||
//
|
||||
// All a1, a2, b1, and b2 must have less than MAX_COEFF_PRECISION bits since
|
||||
// they all are multiplied with either an X or a Y to form a term.
|
||||
// Both c1 and c2 can have up to MAX_TERM_PRECISION since they each alone
|
||||
// forms a term.
|
||||
//
|
||||
#define MAX_COEFF_PRECISION (MAX_TERM_PRECISION - ADC_PRECISION)
|
||||
|
||||
unsigned char
|
||||
TouchPanelSetCalibration(
|
||||
int cCalibrationPoints, //@PARM The number of calibration points
|
||||
int *pScreenXBuffer, //@PARM List of screen X coords displayed
|
||||
int *pScreenYBuffer, //@PARM List of screen Y coords displayed
|
||||
int *pUncalXBuffer, //@PARM List of X coords collected
|
||||
int *pUncalYBuffer //@PARM List of Y coords collected
|
||||
);
|
||||
|
||||
void
|
||||
TouchPanelCalibrateAPoint(
|
||||
int UncalX, //@PARM The uncalibrated X coordinate
|
||||
int UncalY, //@PARM The uncalibrated Y coordinate
|
||||
int *pCalX, //@PARM The calibrated X coordinate
|
||||
int *pCalY //@PARM The calibrated Y coordinate
|
||||
);
|
||||
|
||||
int tp_calib_iface_init(int *x,int *y,int *uncali_x, int *uncali_y);
|
||||
void tp_calib_iface_exit(void);
|
||||
#endif
|
||||
@@ -1,602 +0,0 @@
|
||||
/*
|
||||
* drivers/input/touchscreen/largenum_ts.c - largenum for rk2818 spi xpt2046 device and console
|
||||
*
|
||||
* Copyright (C) 2010 ROCKCHIP, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#include "largenum_ts.h"
|
||||
|
||||
unsigned int
|
||||
LargeNumSignedFormat(
|
||||
PLARGENUM pNum
|
||||
);
|
||||
|
||||
PLARGENUM
|
||||
LargeNumSet(
|
||||
PLARGENUM pNum,
|
||||
int n
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(n < 0){
|
||||
pNum->u.s32.u[0] = -n;
|
||||
pNum->fNegative = 1;
|
||||
} else{
|
||||
pNum->u.s32.u[0] = n;
|
||||
pNum->fNegative=0;
|
||||
}
|
||||
for(i=1; i<SIZE_OF_LARGENUM; i++){
|
||||
pNum->u.s32.u[i] = 0;
|
||||
}
|
||||
return pNum;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
IsLargeNumNotZero(
|
||||
PLARGENUM pNum
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<SIZE_OF_LARGENUM; i++){
|
||||
if(pNum->u.s32.u[i]){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
IsLargeNumNegative(
|
||||
PLARGENUM pNum
|
||||
)
|
||||
{
|
||||
return (pNum->fNegative ? 1 : 0);
|
||||
|
||||
}
|
||||
|
||||
unsigned char
|
||||
IsLargeNumMagGreaterThan(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=SIZE_OF_LARGENUM-1; i>=0; i--){
|
||||
if(pNum1->u.s32.u[i] > pNum2->u.s32.u[i]){
|
||||
return 1;
|
||||
} else if(pNum1->u.s32.u[i] < pNum2->u.s32.u[i]){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
IsLargeNumMagLessThan(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=SIZE_OF_LARGENUM-1; i>=0; i--){
|
||||
if(pNum1->u.s32.u[i] < pNum2->u.s32.u[i]){
|
||||
return 1;
|
||||
} else if(pNum1->u.s32.u[i] > pNum2->u.s32.u[i]){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMagInc(
|
||||
PLARGENUM pNum
|
||||
)
|
||||
{
|
||||
unsigned int c;
|
||||
int i;
|
||||
|
||||
c = 1;
|
||||
for(i=0; i<SIZE_OF_LARGENUM; i++){
|
||||
pNum->u.s32.u[i] += c;
|
||||
if(pNum->u.s32.u[i]){
|
||||
c = 0;
|
||||
}
|
||||
}
|
||||
return pNum;
|
||||
}
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMagAdd(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
)
|
||||
{
|
||||
unsigned int c;
|
||||
unsigned int i;
|
||||
unsigned int a;
|
||||
unsigned int b;
|
||||
|
||||
c = 0;
|
||||
for(i=0; i<SIZE_OF_LARGENUM; i++){
|
||||
a = pNum1->u.s32.u[i];
|
||||
b = pNum2->u.s32.u[i];
|
||||
pResult->u.s32.u[i] = a + b + c;
|
||||
if(c){
|
||||
if(pResult->u.s32.u[i] <= a){
|
||||
c = 1;
|
||||
} else {
|
||||
c = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
if(pResult->u.s32.u[i] < a){
|
||||
c = 1;
|
||||
} else {
|
||||
c = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return pResult;
|
||||
}
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMagSub(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
)
|
||||
{
|
||||
unsigned int c;
|
||||
unsigned int i;
|
||||
unsigned int a;
|
||||
unsigned int b;
|
||||
|
||||
c = 1;
|
||||
for(i=0; i<SIZE_OF_LARGENUM; i++){
|
||||
a = pNum1->u.s32.u[i];
|
||||
b = ~(pNum2->u.s32.u[i]);
|
||||
pResult->u.s32.u[i] = a + b + c;
|
||||
if(c){
|
||||
if(pResult->u.s32.u[i] <= a){
|
||||
c = 1;
|
||||
} else {
|
||||
c = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
if(pResult->u.s32.u[i] < a){
|
||||
c = 1;
|
||||
} else {
|
||||
c = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return pResult;
|
||||
}
|
||||
|
||||
PLARGENUM
|
||||
LargeNumAdd(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
)
|
||||
{
|
||||
unsigned char fNegative1;
|
||||
unsigned char fNegative2;
|
||||
|
||||
fNegative1 = IsLargeNumNegative(pNum1);
|
||||
fNegative2 = IsLargeNumNegative(pNum2);
|
||||
|
||||
if(fNegative1 != fNegative2){
|
||||
if(IsLargeNumMagGreaterThan(pNum1, pNum2)){
|
||||
LargeNumMagSub(pNum1, pNum2, pResult);
|
||||
} else {
|
||||
LargeNumMagSub(pNum2, pNum1, pResult);
|
||||
fNegative1 = !fNegative1;
|
||||
}
|
||||
} else {
|
||||
LargeNumMagAdd(pNum1, pNum2, pResult);
|
||||
}
|
||||
if(!IsLargeNumNotZero(pResult)){
|
||||
pResult->fNegative = 0;
|
||||
} else {
|
||||
pResult->fNegative = fNegative1;
|
||||
}
|
||||
return pResult;
|
||||
}
|
||||
|
||||
PLARGENUM
|
||||
LargeNumSub(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
)
|
||||
{
|
||||
unsigned char fNegative1;
|
||||
unsigned char fNegative2;
|
||||
|
||||
fNegative1 = IsLargeNumNegative(pNum1);
|
||||
fNegative2 = IsLargeNumNegative(pNum2);
|
||||
|
||||
if(fNegative1 == fNegative2){
|
||||
if(IsLargeNumMagGreaterThan(pNum1, pNum2)){
|
||||
LargeNumMagSub(pNum1, pNum2, pResult);
|
||||
} else {
|
||||
LargeNumMagSub(pNum2, pNum1, pResult);
|
||||
fNegative1 = !fNegative1;
|
||||
}
|
||||
} else {
|
||||
LargeNumMagAdd(pNum1, pNum2, pResult);
|
||||
}
|
||||
if(!IsLargeNumNotZero(pResult)){
|
||||
pResult->fNegative = 0;
|
||||
} else {
|
||||
pResult->fNegative = fNegative1;
|
||||
}
|
||||
return pResult;
|
||||
}
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMulUint32(
|
||||
unsigned int a,
|
||||
unsigned int b,
|
||||
PLARGENUM pResult
|
||||
)
|
||||
{
|
||||
unsigned int a1, a0;
|
||||
unsigned int b1, b0;
|
||||
unsigned int r0;
|
||||
unsigned int r1;
|
||||
unsigned int r2;
|
||||
unsigned int c;
|
||||
int i;
|
||||
|
||||
a1 = a >> 16;
|
||||
a0 = a & 0xffff;
|
||||
b1 = b >> 16;
|
||||
b0 = b & 0xffff;
|
||||
|
||||
r0 = a0 * b0;
|
||||
r1 = a1 * b0 + a0 * b1;
|
||||
r2 = a1 * b1;
|
||||
|
||||
pResult->u.s32.u[0] = (r1 << 16) + r0;
|
||||
if(pResult->u.s32.u[0] < r0){
|
||||
c = 1;
|
||||
} else {
|
||||
c = 0;
|
||||
}
|
||||
pResult->u.s32.u[1] = r2 + (r1 >> 16) + c;
|
||||
for(i=2; i<SIZE_OF_LARGENUM; i++){
|
||||
pResult->u.s32.u[i] = 0;
|
||||
}
|
||||
pResult->fNegative = 0;
|
||||
|
||||
return pResult;
|
||||
}
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMulInt32(
|
||||
int a,
|
||||
int b,
|
||||
PLARGENUM pResult
|
||||
)
|
||||
{
|
||||
unsigned char fNegativeA;
|
||||
unsigned char fNegativeB;
|
||||
|
||||
if(a < 0){
|
||||
fNegativeA = 1;
|
||||
a = -a;
|
||||
} else {
|
||||
fNegativeA = 0;
|
||||
}
|
||||
|
||||
if(b < 0){
|
||||
fNegativeB = 1;
|
||||
b = -b;
|
||||
} else {
|
||||
fNegativeB = 0;
|
||||
}
|
||||
|
||||
LargeNumMulUint32(a, b, pResult);
|
||||
|
||||
if(!IsLargeNumNotZero(pResult)){
|
||||
pResult->fNegative = 0;
|
||||
} else {
|
||||
if(fNegativeA != fNegativeB){
|
||||
pResult->fNegative = 1;
|
||||
}
|
||||
}
|
||||
return pResult;
|
||||
}
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMult(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
)
|
||||
{
|
||||
LARGENUM lNumTemp;
|
||||
LARGENUM lNumSum;
|
||||
LARGENUM lNumCarry;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
LargeNumSet(&lNumCarry, 0);
|
||||
for(i=0; i<SIZE_OF_LARGENUM; i++){
|
||||
LargeNumSet(&lNumSum, 0);
|
||||
for(j=0; j<=i; j++){
|
||||
LargeNumMulUint32(pNum1->u.s32.u[j], pNum2->u.s32.u[i-j], &lNumTemp);
|
||||
LargeNumMagAdd(&lNumTemp, &lNumSum, &lNumSum);
|
||||
}
|
||||
LargeNumMagAdd(&lNumCarry, &lNumSum, &lNumSum);
|
||||
for(j=0; j<SIZE_OF_LARGENUM-1; j++){
|
||||
lNumCarry.u.s32.u[j] = lNumSum.u.s32.u[j+1];
|
||||
}
|
||||
pResult->u.s32.u[i] = lNumSum.u.s32.u[0];
|
||||
}
|
||||
|
||||
if(!IsLargeNumNotZero(pResult)){
|
||||
pResult->fNegative = 0;
|
||||
} else {
|
||||
pResult->fNegative = (pNum1->fNegative != pNum2->fNegative);
|
||||
}
|
||||
return pResult;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
LargeNumSignedFormat(
|
||||
PLARGENUM pNum
|
||||
)
|
||||
{
|
||||
int i;
|
||||
unsigned int c;
|
||||
|
||||
if(IsLargeNumNegative(pNum)){
|
||||
c = 1;
|
||||
for(i=0; i<SIZE_OF_LARGENUM; i++){
|
||||
pNum->u.s32.u[i] = ~(pNum->u.s32.u[i]) + c;
|
||||
if(pNum->u.s32.u[i]){
|
||||
c = 0;
|
||||
}
|
||||
}
|
||||
return 0xffffffff;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LargeNumRAShift(
|
||||
PLARGENUM pNum,
|
||||
int count
|
||||
)
|
||||
{
|
||||
int shift32;
|
||||
int countLeft;
|
||||
unsigned int filler;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
filler = LargeNumSignedFormat(pNum);
|
||||
|
||||
shift32 = count / 32;
|
||||
|
||||
if(shift32 > (SIZE_OF_LARGENUM - 1)){
|
||||
for(i=0; i<SIZE_OF_LARGENUM; i++){
|
||||
pNum->u.s32.u[i] = filler;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
count %= 32;
|
||||
countLeft = 32 - count;
|
||||
for(i=0, j=shift32;;){
|
||||
pNum->u.s32.u[i] = (pNum->u.s32.u[j] >> count);
|
||||
if(j<(SIZE_OF_LARGENUM-1)){
|
||||
j++;
|
||||
if (countLeft < 32) {
|
||||
// Shifting by >= 32 is undefined.
|
||||
pNum->u.s32.u[i] |= pNum->u.s32.u[j] << countLeft;
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
if (countLeft < 32) {
|
||||
// Shifting by >= 32 is undefined.
|
||||
pNum->u.s32.u[i] |= filler << countLeft;
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(; i<SIZE_OF_LARGENUM; i++){
|
||||
pNum->u.s32.u[i] = filler;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
LargeNumDivInt32(
|
||||
PLARGENUM pNum,
|
||||
int divisor,
|
||||
PLARGENUM pResult
|
||||
)
|
||||
{
|
||||
unsigned int s[2*SIZE_OF_LARGENUM];
|
||||
unsigned int r;
|
||||
unsigned int q;
|
||||
unsigned int d;
|
||||
unsigned char sd;
|
||||
int i;
|
||||
|
||||
for(i=0; i<2*SIZE_OF_LARGENUM; i++){
|
||||
s[i] = pNum->u.s16.s[i];
|
||||
}
|
||||
|
||||
if(divisor < 0){
|
||||
divisor = -divisor;
|
||||
sd = 1;
|
||||
} else if(divisor == 0){
|
||||
//
|
||||
// This is a divide-by-zero error
|
||||
//
|
||||
for(i=0; i<SIZE_OF_LARGENUM; i++){
|
||||
pResult->u.s32.u[i] = 0xffffffff;
|
||||
}
|
||||
return 0xffffffff;
|
||||
} else {
|
||||
sd = 0;
|
||||
}
|
||||
|
||||
r = 0;
|
||||
for(i=(2*SIZE_OF_LARGENUM-1); i>=0; i--){
|
||||
d = (r << 16) + s[i];
|
||||
q = d / divisor;
|
||||
r = d - q * divisor;
|
||||
s[i] = q;
|
||||
}
|
||||
|
||||
for(i=0; i<2*SIZE_OF_LARGENUM; i++){
|
||||
pResult->u.s16.s[i] = s[i];
|
||||
}
|
||||
|
||||
if(pNum->fNegative){
|
||||
LargeNumMagInc(pResult);
|
||||
r = divisor - r;
|
||||
if(sd == 0 && IsLargeNumNotZero(pResult)){
|
||||
pResult->fNegative = 1;
|
||||
} else {
|
||||
pResult->fNegative = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
if(sd && IsLargeNumNotZero(pResult)){
|
||||
pResult->fNegative = 1;
|
||||
} else {
|
||||
pResult->fNegative = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
LargeNumBits(
|
||||
PLARGENUM pNum
|
||||
)
|
||||
{
|
||||
static unsigned int LargeNumMask[32] = {
|
||||
0x00000001,
|
||||
0x00000002,
|
||||
0x00000004,
|
||||
0x00000008,
|
||||
0x00000010,
|
||||
0x00000020,
|
||||
0x00000040,
|
||||
0x00000080,
|
||||
0x00000100,
|
||||
0x00000200,
|
||||
0x00000400,
|
||||
0x00000800,
|
||||
0x00001000,
|
||||
0x00002000,
|
||||
0x00004000,
|
||||
0x00008000,
|
||||
0x00010000,
|
||||
0x00020000,
|
||||
0x00040000,
|
||||
0x00080000,
|
||||
0x00100000,
|
||||
0x00200000,
|
||||
0x00400000,
|
||||
0x00800000,
|
||||
0x01000000,
|
||||
0x02000000,
|
||||
0x04000000,
|
||||
0x08000000,
|
||||
0x10000000,
|
||||
0x20000000,
|
||||
0x40000000,
|
||||
0x80000000,
|
||||
};
|
||||
|
||||
int i;
|
||||
int j;
|
||||
unsigned int u;
|
||||
|
||||
for(i=(SIZE_OF_LARGENUM-1); i>=0; i--){
|
||||
u = pNum->u.s32.u[i];
|
||||
if(u){
|
||||
for(j=31; j>=0; j--){
|
||||
if(u & (LargeNumMask[j])){
|
||||
return i * 32 + j + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
LargeNumToAscii(
|
||||
PLARGENUM pNum
|
||||
)
|
||||
{
|
||||
static char buf[SIZE_OF_LARGENUM * 10 + 2];
|
||||
LARGENUM lNum;
|
||||
char *p;
|
||||
char *q;
|
||||
unsigned int r;
|
||||
int s;
|
||||
|
||||
p = buf + sizeof(buf) - 1;
|
||||
*p= 0;
|
||||
|
||||
lNum = *pNum;
|
||||
|
||||
s = pNum->fNegative;
|
||||
lNum.fNegative = 0;
|
||||
|
||||
while(IsLargeNumNotZero(&lNum)){
|
||||
r = LargeNumDivInt32(&lNum, 10, &lNum);
|
||||
p--;
|
||||
*p = r + '0';
|
||||
}
|
||||
|
||||
q = buf;
|
||||
|
||||
if(s){
|
||||
*q++='-';
|
||||
}
|
||||
while(*p){
|
||||
//ASSERT(q <= p);
|
||||
//PREFAST_SUPPRESS(394, "q is <= p");
|
||||
*q++ = *p++;
|
||||
}
|
||||
|
||||
if((q == buf) || (s && q == &(buf[1]))){
|
||||
*q++ = '0';
|
||||
}
|
||||
*q = 0;
|
||||
return buf;
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* drivers/input/touchscreen/largenum_ts.h
|
||||
*
|
||||
* Copyright (C) 2010 ROCKCHIP, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LARGENUM_TS_H
|
||||
#define LARGENUM_TS_H
|
||||
|
||||
#define SIZE_OF_LARGENUM 3
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char fNegative;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned short s[2 * SIZE_OF_LARGENUM];
|
||||
}
|
||||
s16;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned int u[SIZE_OF_LARGENUM];
|
||||
}
|
||||
s32;
|
||||
|
||||
}
|
||||
u;
|
||||
}
|
||||
LARGENUM, *PLARGENUM;
|
||||
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
PLARGENUM
|
||||
LargeNumSet(
|
||||
PLARGENUM pNum,
|
||||
int n
|
||||
);
|
||||
|
||||
unsigned char
|
||||
IsLargeNumNotZero(
|
||||
PLARGENUM pNum
|
||||
);
|
||||
|
||||
unsigned char
|
||||
IsLargeNumNegative(
|
||||
PLARGENUM pNum
|
||||
);
|
||||
|
||||
unsigned char
|
||||
IsLargeNumMagGreaterThan(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2
|
||||
);
|
||||
|
||||
unsigned char
|
||||
IsLargeNumMagLessThan(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2
|
||||
);
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMagInc(
|
||||
PLARGENUM pNum
|
||||
);
|
||||
|
||||
char *
|
||||
LargeNumToAscii(
|
||||
PLARGENUM pNum
|
||||
);
|
||||
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMagAdd(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
);
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMagSub(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
);
|
||||
|
||||
PLARGENUM
|
||||
LargeNumAdd(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
);
|
||||
|
||||
PLARGENUM
|
||||
LargeNumSub(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
);
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMulUint32(
|
||||
unsigned int a,
|
||||
unsigned int b,
|
||||
PLARGENUM pResult
|
||||
);
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMulInt32(
|
||||
int a,
|
||||
int b,
|
||||
PLARGENUM pResult
|
||||
);
|
||||
|
||||
PLARGENUM
|
||||
LargeNumMult(
|
||||
PLARGENUM pNum1,
|
||||
PLARGENUM pNum2,
|
||||
PLARGENUM pResult
|
||||
);
|
||||
|
||||
void
|
||||
LargeNumRAShift(
|
||||
PLARGENUM pNum,
|
||||
int count
|
||||
);
|
||||
|
||||
unsigned int
|
||||
LargeNumDivInt32(
|
||||
PLARGENUM pNum,
|
||||
int divisor,
|
||||
PLARGENUM pResult
|
||||
);
|
||||
|
||||
int
|
||||
LargeNumBits(
|
||||
PLARGENUM pNum
|
||||
);
|
||||
|
||||
#endif /* LARGENUM_TS_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* drivers/input/touchscreen/xpt2046_cbn_ts.h
|
||||
*
|
||||
* Copyright (C) 2010 ROCKCHIP, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __DRIVERS_TOUCHSCREEN_XPT2046_CBN_TS_H
|
||||
#define __DRIVERS_TOUCHSCREEN_XPT2046_CBN_TS_H
|
||||
|
||||
#define IOMUX_NAME_SIZE 20
|
||||
|
||||
enum xpt2046_filter {
|
||||
XPT2046_FILTER_OK,
|
||||
XPT2046_FILTER_REPEAT,
|
||||
XPT2046_FILTER_IGNORE,
|
||||
};
|
||||
|
||||
struct xpt2046_platform_data {
|
||||
u16 model; /* 2046. */
|
||||
bool keep_vref_on; /* set to keep vref on for differential
|
||||
* measurements as well */
|
||||
bool swap_xy; /* swap x and y axes */
|
||||
|
||||
/* If set to non-zero, after samples are taken this delay is applied
|
||||
* and penirq is rechecked, to help avoid false events. This value
|
||||
* is affected by the material used to build the touch layer.
|
||||
*/
|
||||
u16 penirq_recheck_delay_usecs;
|
||||
|
||||
u16 x_min, x_max;
|
||||
u16 y_min, y_max;
|
||||
|
||||
u16 debounce_max; /* max number of additional readings
|
||||
* per sample */
|
||||
u16 debounce_tol; /* tolerance used for filtering */
|
||||
u16 debounce_rep; /* additional consecutive good readings
|
||||
* required after the first two */
|
||||
int gpio_pendown; /* the GPIO used to decide the pendown
|
||||
* state if get_pendown_state == NULL
|
||||
*/
|
||||
char pendown_iomux_name[IOMUX_NAME_SIZE];
|
||||
int pendown_iomux_mode;
|
||||
int touch_virtualkey_length;
|
||||
int screen_x[5];
|
||||
int screen_y[5];
|
||||
int uncali_x_default[5];
|
||||
int uncali_y_default[5];
|
||||
int (*get_pendown_state)(void);
|
||||
int (*filter_init) (struct xpt2046_platform_data *pdata,
|
||||
void **filter_data);
|
||||
int (*filter) (void *filter_data, int data_idx, int *val);
|
||||
void (*filter_cleanup)(void *filter_data);
|
||||
void (*wait_for_sync)(void);
|
||||
int (* io_init)(void);
|
||||
int (* io_deinit)(void);
|
||||
};
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* drivers/input/touchscreen/xpt2046_ts.h
|
||||
*
|
||||
* Copyright (C) 2010 ROCKCHIP, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __DRIVERS_TOUCHSCREEN_XPT2046_TS_H
|
||||
#define __DRIVERS_TOUCHSCREEN_XPT2046_TS_H
|
||||
|
||||
#define IOMUX_NAME_SIZE 40
|
||||
|
||||
enum xpt2046_filter {
|
||||
XPT2046_FILTER_OK,
|
||||
XPT2046_FILTER_REPEAT,
|
||||
XPT2046_FILTER_IGNORE,
|
||||
};
|
||||
|
||||
struct xpt2046_platform_data {
|
||||
u16 model; /* 2046. */
|
||||
bool keep_vref_on; /* set to keep vref on for differential
|
||||
* measurements as well */
|
||||
bool swap_xy; /* swap x and y axes */
|
||||
|
||||
/* If set to non-zero, after samples are taken this delay is applied
|
||||
* and penirq is rechecked, to help avoid false events. This value
|
||||
* is affected by the material used to build the touch layer.
|
||||
*/
|
||||
u16 penirq_recheck_delay_usecs;
|
||||
|
||||
u16 x_min, x_max;
|
||||
u16 y_min, y_max;
|
||||
|
||||
u16 debounce_max; /* max number of additional readings
|
||||
* per sample */
|
||||
u16 debounce_tol; /* tolerance used for filtering */
|
||||
u16 debounce_rep; /* additional consecutive good readings
|
||||
* required after the first two */
|
||||
int gpio_pendown; /* the GPIO used to decide the pendown
|
||||
* state if get_pendown_state == NULL
|
||||
*/
|
||||
char pendown_iomux_name[IOMUX_NAME_SIZE];
|
||||
int pendown_iomux_mode;
|
||||
int touch_ad_top;
|
||||
int touch_ad_bottom;
|
||||
int touch_ad_left;
|
||||
int touch_ad_right;
|
||||
int touch_virtualkey_length;
|
||||
int (*get_pendown_state)(void);
|
||||
int (*filter_init) (struct xpt2046_platform_data *pdata,
|
||||
void **filter_data);
|
||||
int (*filter) (void *filter_data, int data_idx, int *val);
|
||||
void (*filter_cleanup)(void *filter_data);
|
||||
void (*wait_for_sync)(void);
|
||||
int (* io_init)(void);
|
||||
int (* io_deinit)(void);
|
||||
};
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* drivers/input/touchscreen/xpt2046_ts.h
|
||||
*
|
||||
* Copyright (C) 2010 ROCKCHIP, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __DRIVERS_TOUCHSCREEN_XPT2046_TS_H
|
||||
#define __DRIVERS_TOUCHSCREEN_XPT2046_TS_H
|
||||
|
||||
#define IOMUX_NAME_SIZE 20
|
||||
|
||||
enum xpt2046_filter {
|
||||
XPT2046_FILTER_OK,
|
||||
XPT2046_FILTER_REPEAT,
|
||||
XPT2046_FILTER_IGNORE,
|
||||
};
|
||||
|
||||
struct xpt2046_platform_data {
|
||||
u16 model; /* 2046. */
|
||||
bool keep_vref_on; /* set to keep vref on for differential
|
||||
* measurements as well */
|
||||
bool swap_xy; /* swap x and y axes */
|
||||
|
||||
/* If set to non-zero, after samples are taken this delay is applied
|
||||
* and penirq is rechecked, to help avoid false events. This value
|
||||
* is affected by the material used to build the touch layer.
|
||||
*/
|
||||
u16 penirq_recheck_delay_usecs;
|
||||
|
||||
u16 x_min, x_max;
|
||||
u16 y_min, y_max;
|
||||
|
||||
u16 debounce_max; /* max number of additional readings
|
||||
* per sample */
|
||||
u16 debounce_tol; /* tolerance used for filtering */
|
||||
u16 debounce_rep; /* additional consecutive good readings
|
||||
* required after the first two */
|
||||
int gpio_pendown; /* the GPIO used to decide the pendown
|
||||
* state if get_pendown_state == NULL
|
||||
*/
|
||||
char pendown_iomux_name[IOMUX_NAME_SIZE];
|
||||
int pendown_iomux_mode;
|
||||
int touch_ad_top;
|
||||
int touch_ad_bottom;
|
||||
int touch_ad_left;
|
||||
int touch_ad_right;
|
||||
int touch_virtualkey_length;
|
||||
int (*get_pendown_state)(void);
|
||||
int (*filter_init) (struct xpt2046_platform_data *pdata,
|
||||
void **filter_data);
|
||||
int (*filter) (void *filter_data, int data_idx, int *val);
|
||||
void (*filter_cleanup)(void *filter_data);
|
||||
void (*wait_for_sync)(void);
|
||||
int (* io_init)(void);
|
||||
int (* io_deinit)(void);
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user