Latest changes
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include <linux/ctype.h>
|
||||
|
||||
#include <cybook.h>
|
||||
#include <linux/cyio.h>
|
||||
#include <linux/cyevent.h>
|
||||
|
||||
//#define DEBUG_MESSAGES
|
||||
//#define DEBUG_TRACEFUNC
|
||||
@@ -189,8 +189,7 @@ static Ots_PowerModes ots_currentPowerMode = POWER_UNDEFINED;
|
||||
/****************************** i2c configuration *****************************/
|
||||
#define OTS_ADDR_I2C 0x5C
|
||||
|
||||
static unsigned short normal_i2c[] = { OTS_ADDR_I2C,
|
||||
I2C_CLIENT_END };
|
||||
static unsigned short normal_i2c[] = { OTS_ADDR_I2C, I2C_CLIENT_END };
|
||||
|
||||
/* Insmod parameters */
|
||||
I2C_CLIENT_INSMOD_1 (ots);
|
||||
@@ -295,7 +294,7 @@ static int ots_detect (struct i2c_adapter *adapter, int address, int kind)
|
||||
goto exit_kfree;
|
||||
}
|
||||
|
||||
ots_setPowerMode(POWER_ONAUTOSTANDBY);
|
||||
ots_setPowerMode(POWER_ON/*AUTOSTANDBY*/);
|
||||
ots_setDeviceParameters(INT_MODE, X_SENS, Y_SENS);
|
||||
/* Now we are sure that the driver init successfully, then aquire the IRQ */
|
||||
set_irq_type(IRQ_EINT2, IRQT_FALLING);
|
||||
@@ -353,13 +352,19 @@ static int ots_resume (struct device *dev)
|
||||
/******************************************************************************/
|
||||
/********************** Interrupt Related functions ***************************/
|
||||
/******************************************************************************/
|
||||
static int oldX = 0, oldY = 0;
|
||||
static int oldX1 = 0, oldY1 = 0;
|
||||
static int oldX2 = 0, oldY2 = 0;
|
||||
|
||||
enum { FINGER_UP = 0, FINGER_MOVE, FINGER_DOWN };
|
||||
|
||||
static void ots_checkWorkFunction (struct work_struct *work)
|
||||
{
|
||||
unsigned long x1, y1, x2, y2;
|
||||
FUNC_IN();
|
||||
static int status = FINGER_UP;
|
||||
CyEvent_t event = NEW_CYEVENT(CYEVENT_TYPE_TOUCH);
|
||||
|
||||
FUNC_IN();
|
||||
|
||||
/* Here do what the interrupt should... (ie read touch values) */
|
||||
|
||||
/* TODO: I reversed the X / Y axis to match old driver and revese the X value */
|
||||
@@ -377,22 +382,57 @@ static void ots_checkWorkFunction (struct work_struct *work)
|
||||
|
||||
DBG("x1: %lu\ty1: %lu\tx2: %lu\ty2: %lu", x1, y1, x2, y2);
|
||||
|
||||
if ((x1 == 0) && (y1 == 0))
|
||||
if ((x1 == 0) && (y1 == 0) && (x2 == 0) && (y2 == 0))
|
||||
{ /* We assume that this is a finger up event */
|
||||
if ( Cyio_PushEvent('R', 1) >= 0 )
|
||||
if (status != FINGER_UP)
|
||||
{
|
||||
Cyio_PushEvent((oldX >> 8) & 0xFF, 0);
|
||||
Cyio_PushEvent((oldX >> 0) & 0xFF, 0);
|
||||
Cyio_PushEvent((oldY >> 8) & 0xFF, 0);
|
||||
Cyio_PushEvent((oldY >> 0) & 0xFF, 0);
|
||||
event.flags |= CYEVENT_FLAG_TOUCH_UP;
|
||||
status = FINGER_UP;
|
||||
}
|
||||
else
|
||||
goto exit; /* ignore the event */
|
||||
}
|
||||
else
|
||||
{
|
||||
oldX = 600 - x1;
|
||||
oldY = y1;
|
||||
oldX1 = 600 - x1;
|
||||
oldY1 = y1;
|
||||
|
||||
if ((x2 != 0) || (y2 != 0))
|
||||
{
|
||||
oldX2 = 600 - x2;
|
||||
oldY2 = y2;
|
||||
event.data.touch.fingers = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldX2 = oldY2 = 0;
|
||||
event.data.touch.fingers = 1;
|
||||
}
|
||||
|
||||
if (status == FINGER_UP)
|
||||
{
|
||||
event.flags |= CYEVENT_FLAG_TOUCH_DOWN;
|
||||
status = FINGER_DOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
event.flags |= CYEVENT_FLAG_TOUCH_MOVE;
|
||||
status = FINGER_MOVE;
|
||||
}
|
||||
}
|
||||
|
||||
event.data.touch.x1 = oldX1;
|
||||
event.data.touch.y1 = oldY1;
|
||||
event.data.touch.x2 = oldX2;
|
||||
event.data.touch.y2 = oldY2;
|
||||
|
||||
if (status == FINGER_UP)
|
||||
oldX1 = oldY1 = oldX2 = oldY2 = 0;
|
||||
|
||||
CyEvent_PushOrUpdateUniqueEventFlaged(&event, false, CYEVENT_FLASH_TOUCH_MASK);
|
||||
|
||||
|
||||
exit:
|
||||
/* Say I get the data */
|
||||
ots_ackInterrupt();
|
||||
|
||||
@@ -461,7 +501,7 @@ static void ots_setPowerMode (Ots_PowerModes power)
|
||||
ots_setPowerMode(POWER_ON); /* Set myself as Power ON before anything */
|
||||
|
||||
//tmpReg = i2c_smbus_read_byte_data(ots_client, 0x24);
|
||||
tmpReg = (((50) /* timeout in ms for auto sleep */ ) & 0x0F) << 4;
|
||||
tmpReg = (((16) /* timeout in ms for auto sleep */ ) & 0x0F) << 4;
|
||||
tmpReg |= (1<< 2); /* Activate auto sleep mode */
|
||||
tmpReg |= 0x1; /* Set in "Sleep Mode" */
|
||||
|
||||
@@ -510,7 +550,7 @@ static void ots_setDeviceParameters (unsigned char int_mode,
|
||||
tmpReg = i2c_smbus_read_byte_data(ots_client, 0xBE); // TEST
|
||||
DBG("0xBE = %02X", tmpReg);
|
||||
|
||||
DBG("Firmware Version =0x%x\n", i2c_smbus_read_byte_data(ots_client, 0x77));
|
||||
printk("TS Firmware Version = 0x%x\n", i2c_smbus_read_byte_data(ots_client, 0x77));
|
||||
|
||||
/* Activate the device ! */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user