summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJitendra Lanka <jlanka@nvidia.com>2010-05-25 15:31:01 +0530
committerYu-Huan Hsu <yhsu@nvidia.com>2010-05-25 13:21:45 -0700
commit70d6156f3c68b4513925e187b0486617c760a541 (patch)
tree63cced73a60a05ab187bca9c33eb736d60c57221
parentea51db0afcf5f4a1c7b61df64262dbbda00cd397 (diff)
tegra: E1206: multi touch enable and config changes
Enable the config level changes required for multi touch to work on tegra-E1206. Update the odm touch driver to enable multi touch events. Change-Id: I9d8a664d251992a864bd3da8777ce50eb37baab0 Reviewed-on: http://git-master/r/1532 Tested-by: Jitendra Aditya Lanka <jlanka@nvidia.com> Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>
-rw-r--r--arch/arm/configs/tegra_harmony_android_defconfig4
-rw-r--r--arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.c1208
-rw-r--r--arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.h376
3 files changed, 795 insertions, 793 deletions
diff --git a/arch/arm/configs/tegra_harmony_android_defconfig b/arch/arm/configs/tegra_harmony_android_defconfig
index 8aec13ebb57e..200ae1a7ffcf 100644
--- a/arch/arm/configs/tegra_harmony_android_defconfig
+++ b/arch/arm/configs/tegra_harmony_android_defconfig
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.29
-# Mon May 17 20:18:35 2010
+# Tue May 25 15:27:54 2010
#
CONFIG_ARM=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -891,7 +891,7 @@ CONFIG_INPUT_TOUCHSCREEN=y
# CONFIG_TOUCHSCREEN_MK712 is not set
# CONFIG_TOUCHSCREEN_PENMOUNT is not set
# CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI is not set
-# CONFIG_TOUCHSCREEN_TEGRA_ODM is not set
+CONFIG_TOUCHSCREEN_TEGRA_ODM=y
# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
CONFIG_TOUCHSCREEN_USB_COMPOSITE=y
diff --git a/arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.c b/arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.c
index 6516ccbce839..17401ddc5e65 100644
--- a/arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.c
+++ b/arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.c
@@ -1,603 +1,605 @@
-/*
- * Copyright (c) 2010 NVIDIA Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of the NVIDIA Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include "nvodm_touch_panjit.h"
-#include "nvodm_query_discovery.h"
-#include "nvos.h"
-
-#define PANJIT_BENCHMARK_SAMPLE 0
-#define PANJIT_TOUCH_DEVICE_GUID NV_ODM_GUID('p','a','n','j','i','t','_','0')
-#define PANJIT_READ(dev, reg, buffer, len) \
- PANJIT_ReadRegister(dev, reg, buffer, len)
-#define PANJIT_I2C_SPEED_KHZ 400
-#define SAMPLES_PER_SECOND 80
-
-#define SLEEP_MODE_NORMAL 0x00
-#define SLEEP_MODE_SENSOR_SLEEP 0x01
-
-#define X_MIN 0x00
-#define Y_MIN 0x00
-#define X_MAX 4095
-#define Y_MAX 4095
-#define PANJIT_I2C_TIMEOUT 1000
-#define PANJIT_DEBOUNCE_TIME_MS 1
-#define TP_DATA_LENGTH 12
-#define TP_TOUCH_STATE_BYTE 0
-#define TP_FINGER_ONE_MASK 0x01
-#define TP_FINGER_TWO_MASK 0x02
-#define TP_SPECIAL_FUNCTION_BYTE 9
-
-static const
-NvOdmTouchCapabilities PANJIT_Capabilities =
-{
- 1, // IsMultiTouchSupported
- 2, // MaxNumberOfFingerCoordReported;
- 0, // IsRelativeDataSupported
- 0, // MaxNumberOfRelativeCoordReported
- 0, // MaxNumberOfWidthReported
- 0, // MaxNumberOfPressureReported
- (NvU32)NvOdmTouchGesture_Not_Supported, // Gesture
- 0, // IsWidthSupported
- 0, // IsPressureSupported
- 1, // IsFingersSupported
- X_MIN, // XMinPosition
- Y_MIN, // YMinPosition
- X_MAX, // XMaxPosition
- Y_MAX, // YMaxPosition
- 0
-};
-
-#define INT_PIN_ACTIVE_STATE 0
-
-static NvBool
-PANJIT_ReadRegister(
- PANJIT_TouchDevice* hTouch,
- NvU8 reg,
- NvU8* buffer,
- NvU32 len)
-{
- NvOdmI2cStatus Error;
- NvOdmI2cTransactionInfo TransactionInfo;
-
- TransactionInfo.Address = (hTouch->DeviceAddr | 0x1);
- TransactionInfo.Buf = buffer;
- TransactionInfo.Flags = 0;
- TransactionInfo.NumBytes = len;
-
- Error = NvOdmI2cTransaction(hTouch->hOdmI2c,
- &TransactionInfo,
- 1,
- hTouch->I2cClockSpeedKHz,
- PANJIT_I2C_TIMEOUT);
-
- if (Error != NvOdmI2cStatus_Success)
- {
- NVODMTOUCH_PRINTF(("I2C Read Failure = %d (addr=0x%x, reg=0x%x)\r\n", Error,
- hTouch->DeviceAddr, reg));
- return NV_FALSE;
- }
-
- return NV_TRUE;
-}
-
-static NvBool
-PANJIT_WriteRegister(
- PANJIT_TouchDevice* hTouch,
- NvU8 reg,
- NvU8* buffer,
- NvU32 len)
-{
- NvOdmI2cStatus Error;
- NvOdmI2cTransactionInfo TransactionInfo;
-
- TransactionInfo.Address = hTouch->DeviceAddr;
- TransactionInfo.Buf = buffer;
- TransactionInfo.Flags = NVODM_I2C_IS_WRITE;
- TransactionInfo.NumBytes = len;
-
- Error = NvOdmI2cTransaction(hTouch->hOdmI2c,
- &TransactionInfo,
- 1,
- hTouch->I2cClockSpeedKHz,
- PANJIT_I2C_TIMEOUT);
-
- if (Error != NvOdmI2cStatus_Success)
- {
- NVODMTOUCH_PRINTF(("I2C Write Failure = %d (addr=0x%x, reg=0x%x)\r\n",
- Error, hTouch->DeviceAddr, reg));
- return NV_FALSE;
- }
- return NV_TRUE;
-}
-
-static void PANJIT_EnableScanMode(PANJIT_TouchDevice* hTouch)
-{
- NvU8 buff[4];
-
- // Enable Scan Mode.
- buff[0] = 0;
- buff[1] = 8;
- PANJIT_WriteRegister(hTouch, 0, buff, 2);
-}
-
-static void PANJIT_ClearInterrupt(PANJIT_TouchDevice* hTouch)
-{
- NvU8 buff[4];
-
- // Clear Interrupt.
- buff[0] = 1;
- buff[1] = 0;
- PANJIT_WriteRegister(hTouch, 0, buff, 2);
-}
-
-static NvBool PANJIT_Configure(PANJIT_TouchDevice* hTouch)
-{
-
- NVODMTOUCH_PRINTF(("PANJIT_Configure\r\n"));
-
- hTouch->SleepMode = SLEEP_MODE_NORMAL;
- hTouch->SampleRate = SAMPLES_PER_SECOND;
-
- // Enable Scan Mode.
- PANJIT_EnableScanMode(hTouch);
- // Clear Interrupt.
- PANJIT_ClearInterrupt(hTouch);
- return NV_TRUE;
-}
-
-static NvBool
-PANJIT_GetSample(
- PANJIT_TouchDevice* hTouch,
- NvOdmTouchCoordinateInfo* coord)
-{
- NvU8 TouchData[TP_DATA_LENGTH] = {0};
-
- NVODMTOUCH_PRINTF(("PANJIT_GetSample+\r\n"));
-
- if (!hTouch || !coord)
- return NV_FALSE;
-
- if (!PANJIT_READ(hTouch, 0, &TouchData[0], TP_DATA_LENGTH))
- return NV_FALSE;
-
- NVODMTOUCH_PRINTF(("TouchData=0x%x %x %x %x %x %x %x %x %x %x %x %x\r\n",
- TouchData[0], TouchData[1], TouchData[2], TouchData[3], TouchData[4],
- TouchData[5], TouchData[6], TouchData[7],TouchData[8], TouchData[9],
- TouchData[10], TouchData[11]));
-
- /* Ignore No finger */
- coord->fingerstate = (TouchData[10] & (TP_FINGER_ONE_MASK | TP_FINGER_TWO_MASK)) ?
- NvOdmTouchSampleValidFlag : NvOdmTouchSampleIgnore;
-
- if (coord->fingerstate == NvOdmTouchSampleIgnore)
- {
- if (hTouch->PrevFingers == 0)
- {
- NVODMTOUCH_PRINTF(("NvOdmTouchSampleIgnore\r\n"));
- return NV_TRUE;
- }
- coord->fingerstate = NvOdmTouchSampleValidFlag;
- }
-
- // get the finger count
- coord->additionalInfo.Fingers = TouchData[10];
- if (coord->additionalInfo.Fingers > hTouch->Caps.MaxNumberOfFingerCoordReported)
- coord->additionalInfo.Fingers = hTouch->Caps.MaxNumberOfFingerCoordReported;
-
- NVODMTOUCH_PRINTF(("coord->additionalInfo.Fingers = %d\r\n",
- coord->additionalInfo.Fingers));
-
- if (coord->additionalInfo.Fingers)
- {
- coord->fingerstate |= NvOdmTouchSampleDownFlag;
- coord->xcoord = TouchData[2];
- coord->xcoord = ((coord->xcoord<<8)|(TouchData[3]));
- coord->ycoord = TouchData[4];
- coord->ycoord = ((coord->ycoord<<8)|(TouchData[5]));
- coord->additionalInfo.multi_XYCoords[0][0] = coord->xcoord;
- coord->additionalInfo.multi_XYCoords[0][1] = coord->ycoord;
- coord->additionalInfo.multi_XYCoords[1][0] = (TouchData[6]<<8) | (TouchData[7]);
- coord->additionalInfo.multi_XYCoords[1][1] = (TouchData[8]<<8) | (TouchData[9]);
- }
- hTouch->PrevFingers = coord->additionalInfo.Fingers;
- NVODMTOUCH_PRINTF(("(%d,%d)\r\n", coord->xcoord, coord->ycoord));
- return NV_TRUE;
-}
-
-static void PANJIT_GpioIsr(void *arg)
-{
- PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)arg;
-
- /* Signal the touch thread to read the sample. After it is done reading the
- * sample it should re-enable the interrupt. */
- NvOdmOsSemaphoreSignal(hTouch->hIntSema);
-}
-
-NvBool
-PANJIT_ReadCoordinate(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmTouchCoordinateInfo* coord)
-{
- PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
- NvBool status = NV_FALSE;
- static NvU32 prevSamleTime;
- NvU32 CurrentSampleTime;
-#if PANJIT_BENCHMARK_SAMPLE
- NvU32 time;
-#endif
- NvU32 pinValue;
-
- NvOdmGpioGetState(hTouch->hGpio, hTouch->hPin, &pinValue);
- if (pinValue != INT_PIN_ACTIVE_STATE)
- return NV_FALSE;
-
- CurrentSampleTime = NvOdmOsGetTimeMS();
- if (prevSamleTime)
- {
- if ((1000/hTouch->SampleRate) > (CurrentSampleTime - prevSamleTime))
- {
- NvOsSleepMS((1000/hTouch->SampleRate) - (CurrentSampleTime - prevSamleTime));
- }
- }
- prevSamleTime = CurrentSampleTime;
-
-#if PANJIT_BENCHMARK_SAMPLE
- time = CurrentSampleTime;
-#endif
-
- status = PANJIT_GetSample(hTouch, coord);
-
-#if PANJIT_BENCHMARK_SAMPLE
- NvOdmOsDebugPrintf("Touch sample time %d\r\n", NvOdmOsGetTimeMS() - time);
-#endif
- return status;
-}
-
-void
-PANJIT_GetCapabilities(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmTouchCapabilities* pCapabilities)
-{
- PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
-
- if (hTouch && pCapabilities)
- *pCapabilities = hTouch->Caps;
-}
-
-void PANJIT_Close (NvOdmTouchDeviceHandle hDevice)
-{
- PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
-
- if (hTouch)
- {
- if (hTouch->hGpio)
- {
- if (hTouch->hGpioIntr)
- {
- NvOdmGpioInterruptUnregister(hTouch->hGpio,
- hTouch->hPin, hTouch->hGpioIntr);
- hTouch->hGpioIntr = NULL;
- }
-
- if (hTouch->hPin)
- {
- NvOdmGpioReleasePinHandle(hTouch->hGpio, hTouch->hPin);
- hTouch->hPin = NULL;
- }
-
- NvOdmGpioClose(hTouch->hGpio);
- hTouch->hGpio = NULL;
- }
-
- if (hTouch->hOdmI2c)
- {
- NvOdmI2cClose(hTouch->hOdmI2c);
- hTouch->hOdmI2c = NULL;
- }
-
- NvOdmOsFree(hTouch);
- hTouch = NULL;
- }
-}
-
-static void InitOdmTouch (NvOdmTouchDevice *pDev)
-{
- if (pDev)
- {
- pDev->Close = PANJIT_Close;
- pDev->GetCapabilities = PANJIT_GetCapabilities;
- pDev->ReadCoordinate = PANJIT_ReadCoordinate;
- pDev->EnableInterrupt = PANJIT_EnableInterrupt;
- pDev->HandleInterrupt = PANJIT_HandleInterrupt;
- pDev->GetSampleRate = PANJIT_GetSampleRate;
- pDev->SetSampleRate = PANJIT_SetSampleRate;
- pDev->PowerControl = PANJIT_PowerControl;
- pDev->PowerOnOff = PANJIT_PowerOnOff;
- pDev->GetCalibrationData = PANJIT_GetCalibrationData;
- pDev->OutputDebugMessage = NV_TRUE;
- }
-}
-
-NvBool PANJIT_Open(NvOdmTouchDeviceHandle *hDevice)
-{
- PANJIT_TouchDevice *hTouch = NULL;
- NvU32 i = 0;
- NvU32 found = 0;
- NvU32 GpioPort = 0;
- NvU32 GpioPin = 0;
- NvU32 I2cInstance = 0;
- NvOdmIoModule IoModule = NvOdmIoModule_I2c;
- const NvOdmPeripheralConnectivity *pConnectivity = NULL;
-
- NVODMTOUCH_PRINTF(("NvOdm Touch : PANJIT_Open() \r\n"));
-
- // allocate memory to be used for the handle
- hTouch = NvOdmOsAlloc(sizeof(PANJIT_TouchDevice));
- if (!hTouch)
- return NV_FALSE;
-
- NvOdmOsMemset(hTouch, 0, sizeof(PANJIT_TouchDevice));
-
- /* set function pointers */
- InitOdmTouch(&hTouch->OdmTouch);
-
- // read the query database
- pConnectivity = NvOdmPeripheralGetGuid(PANJIT_TOUCH_DEVICE_GUID);
- if (!pConnectivity)
- {
- NVODMTOUCH_PRINTF(("NvOdm Touch : pConnectivity is NULL Error \r\n"));
- goto fail;
- }
-
- if (pConnectivity->Class != NvOdmPeripheralClass_HCI)
- {
- NVODMTOUCH_PRINTF(("NvOdm Touch : didn't find any periperal\
- in discovery query for touch device Error \r\n"));
- goto fail;
- }
-
- for (i = 0; i < pConnectivity->NumAddress; i++)
- {
- switch (pConnectivity->AddressList[i].Interface)
- {
- case NvOdmIoModule_I2c:
- case NvOdmIoModule_I2c_Pmu:
- hTouch->DeviceAddr = pConnectivity->AddressList[i].Address;
- I2cInstance = pConnectivity->AddressList[i].Instance;
- found |= 1;
- IoModule = pConnectivity->AddressList[i].Interface;
- break;
-
- case NvOdmIoModule_Gpio:
- GpioPort = pConnectivity->AddressList[i].Instance;
- GpioPin = pConnectivity->AddressList[i].Address;
- found |= 2;
- break;
-
- default:
- break;
- }
- }
-
- // see if we found the bus and GPIO used by the hardware
- if ((found & 3) != 3)
- {
- NVODMTOUCH_PRINTF(("NvOdm Touch:peripheral connectivity problem \r\n"));
- goto fail;
- }
-
- // allocate I2C instance
- hTouch->hOdmI2c = NvOdmI2cOpen(IoModule, I2cInstance);
- if (!hTouch->hOdmI2c)
- {
- NVODMTOUCH_PRINTF(("NvOdm Touch : NvOdmI2cOpen Error \r\n"));
- goto fail;
- }
-
- // get the handle to the pin used as pen down interrupt
- hTouch->hGpio = (NvOdmServicesGpioHandle)NvOdmGpioOpen();
- if (!hTouch->hGpio)
- {
- NVODMTOUCH_PRINTF(("NvOdm Touch : NvOdmGpioOpen Error \r\n"));
- goto fail;
- }
-
- hTouch->hPin = NvOdmGpioAcquirePinHandle(hTouch->hGpio, GpioPort, GpioPin);
- if (!hTouch->hPin)
- {
- NVODMTOUCH_PRINTF(("NvOdm Touch : Couldn't get GPIO pin \r\n"));
- goto fail;
- }
-
- NvOdmGpioConfig(hTouch->hGpio, hTouch->hPin, NvOdmGpioPinMode_InputData);
-
- /* set default capabilities */
- NvOdmOsMemcpy(&hTouch->Caps, &PANJIT_Capabilities,
- sizeof(NvOdmTouchCapabilities));
-
- /* set default I2C speed */
- hTouch->I2cClockSpeedKHz = PANJIT_I2C_SPEED_KHZ;
-
- /* set max positions */
- hTouch->Caps.XMaxPosition = X_MAX;
- hTouch->Caps.YMaxPosition = Y_MAX;
-
- PANJIT_Configure(hTouch);
-
- *hDevice = (NvOdmTouchDeviceHandle)hTouch;
- return NV_TRUE;
-
- fail:
- PANJIT_Close((NvOdmTouchDeviceHandle)hTouch);
- hTouch = NULL;
- return NV_FALSE;
-}
-
-NvBool
-PANJIT_EnableInterrupt(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmOsSemaphoreHandle hIntSema)
-{
- PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
-
- NV_ASSERT(hIntSema);
-
- /* can only be initialized once */
- if (hTouch->hGpioIntr || hTouch->hIntSema)
- return NV_FALSE;
-
- hTouch->hIntSema = hIntSema;
-
- if (NvOdmGpioInterruptRegister(
- hTouch->hGpio,
- &hTouch->hGpioIntr,
- hTouch->hPin,
- NvOdmGpioPinMode_InputInterruptLow,
- PANJIT_GpioIsr,
- (void*)hTouch,
- PANJIT_DEBOUNCE_TIME_MS) == NV_FALSE)
- {
- return NV_FALSE;
- }
-
- if (!hTouch->hGpioIntr)
- return NV_FALSE;
- return NV_TRUE;
-}
-
-NvBool PANJIT_HandleInterrupt(NvOdmTouchDeviceHandle hDevice)
-{
- PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
- NvU32 pinValue;
-
- if (hTouch)
- {
- NvOdmGpioGetState(hTouch->hGpio, hTouch->hPin, &pinValue);
- if (pinValue == INT_PIN_ACTIVE_STATE)
- {
- // Clear Interrupt.
- PANJIT_ClearInterrupt(hTouch);
- NvOdmGpioInterruptDone(hTouch->hGpioIntr);
- return NV_TRUE;
- }
- }
- return NV_FALSE;
-}
-
-NvBool
-PANJIT_GetSampleRate(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmTouchSampleRate* pTouchSampleRate)
-{
- if (pTouchSampleRate)
- {
- pTouchSampleRate->NvOdmTouchSampleRateHigh = SAMPLES_PER_SECOND;
- pTouchSampleRate->NvOdmTouchSampleRateLow = SAMPLES_PER_SECOND;
- pTouchSampleRate->NvOdmTouchCurrentSampleRate = 0; // 0 = low , 1 = high
- }
- return NV_TRUE;
-}
-
-NvBool PANJIT_SetSampleRate(NvOdmTouchDeviceHandle hDevice, NvU32 rate)
-{
- PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
-
- if (hTouch)
- {
- if (rate > SAMPLES_PER_SECOND)
- hTouch->SampleRate = SAMPLES_PER_SECOND;
- else
- hTouch->SampleRate = rate;
- }
- return NV_TRUE;
-}
-
-NvBool
-PANJIT_PowerControl(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmTouchPowerModeType mode)
-{
- PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
- NvU8 SleepMode;
-
- switch(mode)
- {
- case NvOdmTouch_PowerMode_0:
- SleepMode = SLEEP_MODE_NORMAL;
- break;
- case NvOdmTouch_PowerMode_1:
- case NvOdmTouch_PowerMode_2:
- case NvOdmTouch_PowerMode_3:
- SleepMode = SLEEP_MODE_SENSOR_SLEEP;
- break;
- default:
- return NV_FALSE;
- }
-
- if (hTouch->SleepMode == SleepMode)
- return NV_TRUE;
- hTouch->SleepMode = SleepMode;
- return NV_TRUE;
-}
-
-NvBool
-PANJIT_GetCalibrationData(
- NvOdmTouchDeviceHandle hDevice,
- NvU32 NumOfCalibrationData,
- NvS32* pRawCoordBuffer)
-{
- static NvS32 RawCoordBuffer[] = {2048,2048,840,840,840,3330,3280,3330,3280,840};
-
- if (!pRawCoordBuffer)
- return NV_FALSE;
-
- if (NumOfCalibrationData * 2 != (sizeof(RawCoordBuffer) / sizeof(NvS32)))
- {
- NVODMTOUCH_PRINTF(("WARNING: number of calibration data isn't matched\r\n"));
- return NV_FALSE;
- }
-
- NvOdmOsMemcpy(pRawCoordBuffer, RawCoordBuffer, sizeof(RawCoordBuffer));
- return NV_TRUE;
-}
-
-NvBool PANJIT_PowerOnOff(NvOdmTouchDeviceHandle hDevice, NvBool OnOff)
-{
- if (!hDevice)
- return NV_FALSE;
-
- if (OnOff)
- return PANJIT_PowerControl(hDevice, NvOdmTouch_PowerMode_0); // power ON
- else
- return PANJIT_PowerControl(hDevice, NvOdmTouch_PowerMode_3); // power OFF
-}
-
+/*
+ * Copyright (c) 2010 NVIDIA Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of the NVIDIA Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <linux/module.h>
+#include "nvodm_touch_panjit.h"
+#include "nvodm_query_discovery.h"
+#include "nvos.h"
+
+#define PANJIT_BENCHMARK_SAMPLE 0
+#define PANJIT_TOUCH_DEVICE_GUID NV_ODM_GUID('p','a','n','j','i','t','_','0')
+#define PANJIT_READ(dev, reg, buffer, len) \
+ PANJIT_ReadRegister(dev, reg, buffer, len)
+#define PANJIT_I2C_SPEED_KHZ 400
+#define SAMPLES_PER_SECOND 80
+
+#define SLEEP_MODE_NORMAL 0x00
+#define SLEEP_MODE_SENSOR_SLEEP 0x01
+
+#define X_MIN 0x00
+#define Y_MIN 0x00
+#define X_MAX 4095
+#define Y_MAX 4095
+#define PANJIT_I2C_TIMEOUT 1000
+#define PANJIT_DEBOUNCE_TIME_MS 1
+#define TP_DATA_LENGTH 12
+#define TP_TOUCH_STATE_BYTE 0
+#define TP_FINGER_ONE_MASK 0x01
+#define TP_FINGER_TWO_MASK 0x02
+#define TP_SPECIAL_FUNCTION_BYTE (TP_DATA_LENGTH-1)
+#define TP_FINGER_POSITION (TP_SPECIAL_FUNCTION_BYTE-1)
+
+static const
+NvOdmTouchCapabilities PANJIT_Capabilities =
+{
+ 1, // IsMultiTouchSupported
+ 2, // MaxNumberOfFingerCoordReported;
+ 0, // IsRelativeDataSupported
+ 1, // MaxNumberOfRelativeCoordReported
+ 15, // MaxNumberOfWidthReported
+ 255, // MaxNumberOfPressureReported
+ (NvU32)NvOdmTouchGesture_Not_Supported, // Gesture
+ 1, // IsWidthSupported
+ 1, // IsPressureSupported
+ 1, // IsFingersSupported
+ X_MIN, // XMinPosition
+ Y_MIN, // YMinPosition
+ X_MAX, // XMaxPosition
+ Y_MAX, // YMaxPosition
+ 0
+};
+
+#define INT_PIN_ACTIVE_STATE 0
+
+static NvBool
+PANJIT_ReadRegister(
+ PANJIT_TouchDevice* hTouch,
+ NvU8 reg,
+ NvU8* buffer,
+ NvU32 len)
+{
+ NvOdmI2cStatus Error;
+ NvOdmI2cTransactionInfo TransactionInfo;
+
+ TransactionInfo.Address = (hTouch->DeviceAddr | 0x1);
+ TransactionInfo.Buf = buffer;
+ TransactionInfo.Flags = 0;
+ TransactionInfo.NumBytes = len;
+
+ Error = NvOdmI2cTransaction(hTouch->hOdmI2c,
+ &TransactionInfo,
+ 1,
+ hTouch->I2cClockSpeedKHz,
+ PANJIT_I2C_TIMEOUT);
+
+ if (Error != NvOdmI2cStatus_Success)
+ {
+ NVODMTOUCH_PRINTF(("I2C Read Failure = %d (addr=0x%x, reg=0x%x)\r\n", Error,
+ hTouch->DeviceAddr, reg));
+ return NV_FALSE;
+ }
+
+ return NV_TRUE;
+}
+
+static NvBool
+PANJIT_WriteRegister(
+ PANJIT_TouchDevice* hTouch,
+ NvU8 reg,
+ NvU8* buffer,
+ NvU32 len)
+{
+ NvOdmI2cStatus Error;
+ NvOdmI2cTransactionInfo TransactionInfo;
+
+ TransactionInfo.Address = hTouch->DeviceAddr;
+ TransactionInfo.Buf = buffer;
+ TransactionInfo.Flags = NVODM_I2C_IS_WRITE;
+ TransactionInfo.NumBytes = len;
+
+ Error = NvOdmI2cTransaction(hTouch->hOdmI2c,
+ &TransactionInfo,
+ 1,
+ hTouch->I2cClockSpeedKHz,
+ PANJIT_I2C_TIMEOUT);
+
+ if (Error != NvOdmI2cStatus_Success)
+ {
+ NVODMTOUCH_PRINTF(("I2C Write Failure = %d (addr=0x%x, reg=0x%x)\r\n",
+ Error, hTouch->DeviceAddr, reg));
+ return NV_FALSE;
+ }
+ return NV_TRUE;
+}
+
+static void PANJIT_EnableScanMode(PANJIT_TouchDevice* hTouch)
+{
+ NvU8 buff[4];
+
+ // Enable Scan Mode.
+ buff[0] = 0;
+ buff[1] = 8;
+ PANJIT_WriteRegister(hTouch, 0, buff, 2);
+}
+
+static void PANJIT_ClearInterrupt(PANJIT_TouchDevice* hTouch)
+{
+ NvU8 buff[4];
+
+ // Clear Interrupt.
+ buff[0] = 1;
+ buff[1] = 0;
+ PANJIT_WriteRegister(hTouch, 0, buff, 2);
+}
+
+static NvBool PANJIT_Configure(PANJIT_TouchDevice* hTouch)
+{
+
+ NVODMTOUCH_PRINTF(("PANJIT_Configure\r\n"));
+
+ hTouch->SleepMode = SLEEP_MODE_NORMAL;
+ hTouch->SampleRate = SAMPLES_PER_SECOND;
+
+ // Enable Scan Mode.
+ PANJIT_EnableScanMode(hTouch);
+ // Clear Interrupt.
+ PANJIT_ClearInterrupt(hTouch);
+ return NV_TRUE;
+}
+
+static NvBool
+PANJIT_GetSample(
+ PANJIT_TouchDevice* hTouch,
+ NvOdmTouchCoordinateInfo* coord)
+{
+ NvU8 TouchData[TP_DATA_LENGTH] = {0};
+
+ NVODMTOUCH_PRINTF(("PANJIT_GetSample+\r\n"));
+
+ if (!hTouch || !coord)
+ return NV_FALSE;
+
+ if (!PANJIT_READ(hTouch, 0, &TouchData[0], TP_DATA_LENGTH))
+ return NV_FALSE;
+
+ NVODMTOUCH_PRINTF(("TouchData=0x%x %x %x %x %x %x %x %x %x %x %x %x\r\n",
+ TouchData[0], TouchData[1], TouchData[2], TouchData[3], TouchData[4],
+ TouchData[5], TouchData[6], TouchData[7],TouchData[8], TouchData[9],
+ TouchData[10], TouchData[11]));
+
+ /* Ignore No finger */
+ coord->fingerstate = (TouchData[TP_FINGER_POSITION] & (TP_FINGER_ONE_MASK | TP_FINGER_TWO_MASK)) ?
+ NvOdmTouchSampleValidFlag : NvOdmTouchSampleIgnore;
+
+ if (coord->fingerstate == NvOdmTouchSampleIgnore)
+ {
+ if (hTouch->PrevFingers == 0)
+ {
+ NVODMTOUCH_PRINTF(("NvOdmTouchSampleIgnore\r\n"));
+ return NV_TRUE;
+ }
+ coord->fingerstate = NvOdmTouchSampleValidFlag;
+ }
+
+ // get the finger count
+ coord->additionalInfo.Fingers = TouchData[TP_FINGER_POSITION];
+ if (coord->additionalInfo.Fingers > hTouch->Caps.MaxNumberOfFingerCoordReported)
+ coord->additionalInfo.Fingers = hTouch->Caps.MaxNumberOfFingerCoordReported;
+
+ NVODMTOUCH_PRINTF(("coord->additionalInfo.Fingers = %d\r\n",
+ coord->additionalInfo.Fingers));
+
+ if (coord->additionalInfo.Fingers)
+ {
+ coord->fingerstate |= NvOdmTouchSampleDownFlag;
+ coord->xcoord = TouchData[2];
+ coord->xcoord = ((coord->xcoord<<8)|(TouchData[3]));
+ coord->ycoord = TouchData[4];
+ coord->ycoord = ((coord->ycoord<<8)|(TouchData[5]));
+ coord->additionalInfo.multi_XYCoords[0][0] = coord->xcoord;
+ coord->additionalInfo.multi_XYCoords[0][1] = coord->ycoord;
+ coord->additionalInfo.multi_XYCoords[1][0] = (TouchData[6]<<8) | (TouchData[7]);
+ coord->additionalInfo.multi_XYCoords[1][1] = (TouchData[8]<<8) | (TouchData[9]);
+ }
+ hTouch->PrevFingers = coord->additionalInfo.Fingers;
+ NVODMTOUCH_PRINTF(("(%d,%d)\r\n", coord->xcoord, coord->ycoord));
+ return NV_TRUE;
+}
+
+static void PANJIT_GpioIsr(void *arg)
+{
+ PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)arg;
+
+ /* Signal the touch thread to read the sample. After it is done reading the
+ * sample it should re-enable the interrupt. */
+ NvOdmOsSemaphoreSignal(hTouch->hIntSema);
+}
+
+NvBool
+PANJIT_ReadCoordinate(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmTouchCoordinateInfo* coord)
+{
+ PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
+ NvBool status = NV_FALSE;
+ static NvU32 prevSamleTime;
+ NvU32 CurrentSampleTime;
+#if PANJIT_BENCHMARK_SAMPLE
+ NvU32 time;
+#endif
+ NvU32 pinValue;
+
+ NvOdmGpioGetState(hTouch->hGpio, hTouch->hPin, &pinValue);
+ if (pinValue != INT_PIN_ACTIVE_STATE)
+ return NV_FALSE;
+
+ CurrentSampleTime = NvOdmOsGetTimeMS();
+ if (prevSamleTime)
+ {
+ if ((1000/hTouch->SampleRate) > (CurrentSampleTime - prevSamleTime))
+ {
+ NvOsSleepMS((1000/hTouch->SampleRate) - (CurrentSampleTime - prevSamleTime));
+ }
+ }
+ prevSamleTime = CurrentSampleTime;
+
+#if PANJIT_BENCHMARK_SAMPLE
+ time = CurrentSampleTime;
+#endif
+
+ status = PANJIT_GetSample(hTouch, coord);
+
+#if PANJIT_BENCHMARK_SAMPLE
+ NvOdmOsDebugPrintf("Touch sample time %d\r\n", NvOdmOsGetTimeMS() - time);
+#endif
+ return status;
+}
+
+void
+PANJIT_GetCapabilities(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmTouchCapabilities* pCapabilities)
+{
+ PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
+
+ if (hTouch && pCapabilities)
+ *pCapabilities = hTouch->Caps;
+}
+
+void PANJIT_Close (NvOdmTouchDeviceHandle hDevice)
+{
+ PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
+
+ if (hTouch)
+ {
+ if (hTouch->hGpio)
+ {
+ if (hTouch->hGpioIntr)
+ {
+ NvOdmGpioInterruptUnregister(hTouch->hGpio,
+ hTouch->hPin, hTouch->hGpioIntr);
+ hTouch->hGpioIntr = NULL;
+ }
+
+ if (hTouch->hPin)
+ {
+ NvOdmGpioReleasePinHandle(hTouch->hGpio, hTouch->hPin);
+ hTouch->hPin = NULL;
+ }
+
+ NvOdmGpioClose(hTouch->hGpio);
+ hTouch->hGpio = NULL;
+ }
+
+ if (hTouch->hOdmI2c)
+ {
+ NvOdmI2cClose(hTouch->hOdmI2c);
+ hTouch->hOdmI2c = NULL;
+ }
+
+ NvOdmOsFree(hTouch);
+ hTouch = NULL;
+ }
+}
+
+static void InitOdmTouch (NvOdmTouchDevice *pDev)
+{
+ if (pDev)
+ {
+ pDev->Close = PANJIT_Close;
+ pDev->GetCapabilities = PANJIT_GetCapabilities;
+ pDev->ReadCoordinate = PANJIT_ReadCoordinate;
+ pDev->EnableInterrupt = PANJIT_EnableInterrupt;
+ pDev->HandleInterrupt = PANJIT_HandleInterrupt;
+ pDev->GetSampleRate = PANJIT_GetSampleRate;
+ pDev->SetSampleRate = PANJIT_SetSampleRate;
+ pDev->PowerControl = PANJIT_PowerControl;
+ pDev->PowerOnOff = PANJIT_PowerOnOff;
+ pDev->GetCalibrationData = PANJIT_GetCalibrationData;
+ pDev->OutputDebugMessage = NV_TRUE;
+ }
+}
+
+NvBool PANJIT_Open(NvOdmTouchDeviceHandle *hDevice)
+{
+ PANJIT_TouchDevice *hTouch = NULL;
+ NvU32 i = 0;
+ NvU32 found = 0;
+ NvU32 GpioPort = 0;
+ NvU32 GpioPin = 0;
+ NvU32 I2cInstance = 0;
+ NvOdmIoModule IoModule = NvOdmIoModule_I2c;
+ const NvOdmPeripheralConnectivity *pConnectivity = NULL;
+
+ NVODMTOUCH_PRINTF(("NvOdm Touch : PANJIT_Open() \r\n"));
+
+ // allocate memory to be used for the handle
+ hTouch = NvOdmOsAlloc(sizeof(PANJIT_TouchDevice));
+ if (!hTouch)
+ return NV_FALSE;
+
+ NvOdmOsMemset(hTouch, 0, sizeof(PANJIT_TouchDevice));
+
+ /* set function pointers */
+ InitOdmTouch(&hTouch->OdmTouch);
+
+ // read the query database
+ pConnectivity = NvOdmPeripheralGetGuid(PANJIT_TOUCH_DEVICE_GUID);
+ if (!pConnectivity)
+ {
+ NVODMTOUCH_PRINTF(("NvOdm Touch : pConnectivity is NULL Error \r\n"));
+ goto fail;
+ }
+
+ if (pConnectivity->Class != NvOdmPeripheralClass_HCI)
+ {
+ NVODMTOUCH_PRINTF(("NvOdm Touch : didn't find any periperal\
+ in discovery query for touch device Error \r\n"));
+ goto fail;
+ }
+
+ for (i = 0; i < pConnectivity->NumAddress; i++)
+ {
+ switch (pConnectivity->AddressList[i].Interface)
+ {
+ case NvOdmIoModule_I2c:
+ case NvOdmIoModule_I2c_Pmu:
+ hTouch->DeviceAddr = pConnectivity->AddressList[i].Address;
+ I2cInstance = pConnectivity->AddressList[i].Instance;
+ found |= 1;
+ IoModule = pConnectivity->AddressList[i].Interface;
+ break;
+
+ case NvOdmIoModule_Gpio:
+ GpioPort = pConnectivity->AddressList[i].Instance;
+ GpioPin = pConnectivity->AddressList[i].Address;
+ found |= 2;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ // see if we found the bus and GPIO used by the hardware
+ if ((found & 3) != 3)
+ {
+ NVODMTOUCH_PRINTF(("NvOdm Touch:peripheral connectivity problem \r\n"));
+ goto fail;
+ }
+
+ // allocate I2C instance
+ hTouch->hOdmI2c = NvOdmI2cOpen(IoModule, I2cInstance);
+ if (!hTouch->hOdmI2c)
+ {
+ NVODMTOUCH_PRINTF(("NvOdm Touch : NvOdmI2cOpen Error \r\n"));
+ goto fail;
+ }
+
+ // get the handle to the pin used as pen down interrupt
+ hTouch->hGpio = (NvOdmServicesGpioHandle)NvOdmGpioOpen();
+ if (!hTouch->hGpio)
+ {
+ NVODMTOUCH_PRINTF(("NvOdm Touch : NvOdmGpioOpen Error \r\n"));
+ goto fail;
+ }
+
+ hTouch->hPin = NvOdmGpioAcquirePinHandle(hTouch->hGpio, GpioPort, GpioPin);
+ if (!hTouch->hPin)
+ {
+ NVODMTOUCH_PRINTF(("NvOdm Touch : Couldn't get GPIO pin \r\n"));
+ goto fail;
+ }
+
+ NvOdmGpioConfig(hTouch->hGpio, hTouch->hPin, NvOdmGpioPinMode_InputData);
+
+ /* set default capabilities */
+ NvOdmOsMemcpy(&hTouch->Caps, &PANJIT_Capabilities,
+ sizeof(NvOdmTouchCapabilities));
+
+ /* set default I2C speed */
+ hTouch->I2cClockSpeedKHz = PANJIT_I2C_SPEED_KHZ;
+
+ /* set max positions */
+ hTouch->Caps.XMaxPosition = X_MAX;
+ hTouch->Caps.YMaxPosition = Y_MAX;
+
+ PANJIT_Configure(hTouch);
+
+ *hDevice = (NvOdmTouchDeviceHandle)hTouch;
+ return NV_TRUE;
+
+ fail:
+ PANJIT_Close((NvOdmTouchDeviceHandle)hTouch);
+ hTouch = NULL;
+ return NV_FALSE;
+}
+
+NvBool
+PANJIT_EnableInterrupt(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmOsSemaphoreHandle hIntSema)
+{
+ PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
+
+ NV_ASSERT(hIntSema);
+
+ /* can only be initialized once */
+ if (hTouch->hGpioIntr || hTouch->hIntSema)
+ return NV_FALSE;
+
+ hTouch->hIntSema = hIntSema;
+
+ if (NvOdmGpioInterruptRegister(
+ hTouch->hGpio,
+ &hTouch->hGpioIntr,
+ hTouch->hPin,
+ NvOdmGpioPinMode_InputInterruptLow,
+ PANJIT_GpioIsr,
+ (void*)hTouch,
+ PANJIT_DEBOUNCE_TIME_MS) == NV_FALSE)
+ {
+ return NV_FALSE;
+ }
+
+ if (!hTouch->hGpioIntr)
+ return NV_FALSE;
+ return NV_TRUE;
+}
+
+NvBool PANJIT_HandleInterrupt(NvOdmTouchDeviceHandle hDevice)
+{
+ PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
+ NvU32 pinValue;
+
+ if (hTouch)
+ {
+ NvOdmGpioGetState(hTouch->hGpio, hTouch->hPin, &pinValue);
+ if (pinValue == INT_PIN_ACTIVE_STATE)
+ {
+ // Clear Interrupt.
+ PANJIT_ClearInterrupt(hTouch);
+ NvOdmGpioInterruptDone(hTouch->hGpioIntr);
+ return NV_TRUE;
+ }
+ }
+ return NV_FALSE;
+}
+
+NvBool
+PANJIT_GetSampleRate(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmTouchSampleRate* pTouchSampleRate)
+{
+ if (pTouchSampleRate)
+ {
+ pTouchSampleRate->NvOdmTouchSampleRateHigh = SAMPLES_PER_SECOND;
+ pTouchSampleRate->NvOdmTouchSampleRateLow = SAMPLES_PER_SECOND;
+ pTouchSampleRate->NvOdmTouchCurrentSampleRate = 0; // 0 = low , 1 = high
+ }
+ return NV_TRUE;
+}
+
+NvBool PANJIT_SetSampleRate(NvOdmTouchDeviceHandle hDevice, NvU32 rate)
+{
+ PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
+
+ if (hTouch)
+ {
+ if (rate > SAMPLES_PER_SECOND)
+ hTouch->SampleRate = SAMPLES_PER_SECOND;
+ else
+ hTouch->SampleRate = rate;
+ }
+ return NV_TRUE;
+}
+
+NvBool
+PANJIT_PowerControl(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmTouchPowerModeType mode)
+{
+ PANJIT_TouchDevice *hTouch = (PANJIT_TouchDevice *)hDevice;
+ NvU8 SleepMode;
+
+ switch(mode)
+ {
+ case NvOdmTouch_PowerMode_0:
+ SleepMode = SLEEP_MODE_NORMAL;
+ break;
+ case NvOdmTouch_PowerMode_1:
+ case NvOdmTouch_PowerMode_2:
+ case NvOdmTouch_PowerMode_3:
+ SleepMode = SLEEP_MODE_SENSOR_SLEEP;
+ break;
+ default:
+ return NV_FALSE;
+ }
+
+ if (hTouch->SleepMode == SleepMode)
+ return NV_TRUE;
+ hTouch->SleepMode = SleepMode;
+ return NV_TRUE;
+}
+
+NvBool
+PANJIT_GetCalibrationData(
+ NvOdmTouchDeviceHandle hDevice,
+ NvU32 NumOfCalibrationData,
+ NvS32* pRawCoordBuffer)
+{
+ static NvS32 RawCoordBuffer[] = {2048,2048,840,840,840,3330,3280,3330,3280,840};
+
+ if (!pRawCoordBuffer)
+ return NV_FALSE;
+
+ if (NumOfCalibrationData * 2 != (sizeof(RawCoordBuffer) / sizeof(NvS32)))
+ {
+ NVODMTOUCH_PRINTF(("WARNING: number of calibration data isn't matched\r\n"));
+ return NV_FALSE;
+ }
+
+ NvOdmOsMemcpy(pRawCoordBuffer, RawCoordBuffer, sizeof(RawCoordBuffer));
+ return NV_TRUE;
+}
+
+NvBool PANJIT_PowerOnOff(NvOdmTouchDeviceHandle hDevice, NvBool OnOff)
+{
+ if (!hDevice)
+ return NV_FALSE;
+
+ if (OnOff)
+ return PANJIT_PowerControl(hDevice, NvOdmTouch_PowerMode_0); // power ON
+ else
+ return PANJIT_PowerControl(hDevice, NvOdmTouch_PowerMode_3); // power OFF
+}
+
diff --git a/arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.h b/arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.h
index bfff86fe21ce..adca8e16b2e1 100644
--- a/arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.h
+++ b/arch/arm/mach-tegra/odm_kit/platform/touch/nvodm_touch_panjit.h
@@ -1,188 +1,188 @@
-/*
- * Copyright (c) 2010 NVIDIA Corporation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of the NVIDIA Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef INCLUDED_NVODM_TOUCH_PANJIT_H
-#define INCLUDED_NVODM_TOUCH_PANJIT_H
-
-#include "nvodm_touch_int.h"
-#include "nvodm_services.h"
-
-#if defined(__cplusplus)
-extern "C"
-{
-#endif
-
-typedef struct PANJIT_TouchDevice_Rec
-{
- NvOdmTouchDevice OdmTouch;
- NvOdmTouchCapabilities Caps;
- NvOdmServicesI2cHandle hOdmI2c;
- NvOdmServicesGpioHandle hGpio;
- NvOdmServicesPmuHandle hPmu;
- NvOdmGpioPinHandle hPin;
- NvOdmServicesGpioIntrHandle hGpioIntr;
- NvOdmOsSemaphoreHandle hIntSema;
- NvU32 PrevFingers;
- NvU32 DeviceAddr;
- NvU32 SampleRate;
- NvU32 SleepMode;
- NvBool PowerOn;
- NvU32 I2cClockSpeedKHz;
-} PANJIT_TouchDevice;
-
-/**
- * Gets a handle to the touch pad in the system.
- *
- * @param hDevice A pointer to the handle of the touch pad.
- * @return NV_TRUE if successful, or NV_FALSE otherwise.
- */
-NvBool PANJIT_Open(NvOdmTouchDeviceHandle *hDevice);
-
-/**
- * Releases the touch pad handle.
- *
- * @param hDevice The touch pad handle to be released. If
- * NULL, this API has no effect.
- */
-void PANJIT_Close(NvOdmTouchDeviceHandle hDevice);
-
-/**
- * Gets capabilities for the specified touch device.
- *
- * @param hDevice The handle of the touch pad.
- * @param pCapabilities A pointer to the targeted
- * capabilities returned by the ODM.
- */
-void
-PANJIT_GetCapabilities(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmTouchCapabilities* pCapabilities);
-
-/**
- * Gets coordinate info from the touch device.
- *
- * @param hDevice The handle to the touch pad.
- * @param coord A pointer to the structure holding coordinate info.
- * @return NV_TRUE if successful, or NV_FALSE otherwise.
- */
-NvBool
-PANJIT_ReadCoordinate(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmTouchCoordinateInfo *pCoord);
-
-/**
- * Hooks up the interrupt handle to the GPIO interrupt and enables the interrupt.
- *
- * @param hDevice The handle to the touch pad.
- * @param hInterruptSemaphore A handle to hook up the interrupt.
- * @return NV_TRUE if successful, or NV_FALSE otherwise.
- */
-NvBool
-PANJIT_EnableInterrupt(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmOsSemaphoreHandle hInterruptSemaphore);
-
-/**
- * Prepares the next interrupt to get notified from the touch device.
- *
- * @param hDevice A handle to the touch pad.
- * @return NV_TRUE if successful, or NV_FALSE otherwise.
- */
-NvBool PANJIT_HandleInterrupt(NvOdmTouchDeviceHandle hDevice);
-
-/**
- * Gets the touch ADC sample rate.
- *
- * @param hDevice A handle to the touch ADC.
- * @param pTouchSampleRate A pointer to the NvOdmTouchSampleRate stucture.
- *
- * @return NV_TRUE if successful, or NV_FALSE otherwise.
-*/
-NvBool
-PANJIT_GetSampleRate(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmTouchSampleRate* pTouchSampleRate);
-
-/**
- * Sets the touch ADC sample rate.
- *
- * @param hDevice A handle to the touch ADC.
- * @param SampleRate 1 indicates high frequency, 0 indicates low frequency.
- *
- * @return NV_TRUE if successful, or NV_FALSE otherwise.
-*/
-NvBool PANJIT_SetSampleRate(NvOdmTouchDeviceHandle hDevice, NvU32 rate);
-
-/**
- * Sets the touch panel power mode.
- *
- * @param hDevice A handle to the touch ADC.
- * @param mode The mode, ranging from full power to power off.
- *
- * @return NV_TRUE if successful, or NV_FALSE otherwise.
-*/
-NvBool
-PANJIT_PowerControl(
- NvOdmTouchDeviceHandle hDevice,
- NvOdmTouchPowerModeType mode);
-
-/**
- * Gets the touch panel calibration data.
- * This is optional as calibration may perform after the OS is up.
- * This is not required to bring up the touch panel.
- *
- * @param hDevice A handle to the touch panel.
- * @param NumOfCalibrationData Indicates the number of calibration points.
- * @param pRawCoordBuffer The collection of X/Y coordinate data.
- *
- * @return NV_TRUE if preset calibration data is required, or NV_FALSE otherwise.
- */
-NvBool
-PANJIT_GetCalibrationData(
- NvOdmTouchDeviceHandle hDevice,
- NvU32 NumOfCalibrationData,
- NvS32* pRawCoordBuffer);
-
-/**
- * Powers the touch device on or off.
- *
- * @param hDevice A handle to the touch ADC.
- * @param OnOff Specify 1 to power ON, 0 to power OFF.
-*/
-NvBool PANJIT_PowerOnOff(NvOdmTouchDeviceHandle hDevice, NvBool OnOff);
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif // INCLUDED_NVODM_TOUCH_PANJIT_H
-
+/*
+ * Copyright (c) 2010 NVIDIA Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of the NVIDIA Corporation nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef INCLUDED_NVODM_TOUCH_PANJIT_H
+#define INCLUDED_NVODM_TOUCH_PANJIT_H
+
+#include "nvodm_touch_int.h"
+#include "nvodm_services.h"
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+typedef struct PANJIT_TouchDevice_Rec
+{
+ NvOdmTouchDevice OdmTouch;
+ NvOdmTouchCapabilities Caps;
+ NvOdmServicesI2cHandle hOdmI2c;
+ NvOdmServicesGpioHandle hGpio;
+ NvOdmServicesPmuHandle hPmu;
+ NvOdmGpioPinHandle hPin;
+ NvOdmServicesGpioIntrHandle hGpioIntr;
+ NvOdmOsSemaphoreHandle hIntSema;
+ NvU32 PrevFingers;
+ NvU32 DeviceAddr;
+ NvU32 SampleRate;
+ NvU32 SleepMode;
+ NvBool PowerOn;
+ NvU32 I2cClockSpeedKHz;
+} PANJIT_TouchDevice;
+
+/**
+ * Gets a handle to the touch pad in the system.
+ *
+ * @param hDevice A pointer to the handle of the touch pad.
+ * @return NV_TRUE if successful, or NV_FALSE otherwise.
+ */
+NvBool PANJIT_Open(NvOdmTouchDeviceHandle *hDevice);
+
+/**
+ * Releases the touch pad handle.
+ *
+ * @param hDevice The touch pad handle to be released. If
+ * NULL, this API has no effect.
+ */
+void PANJIT_Close(NvOdmTouchDeviceHandle hDevice);
+
+/**
+ * Gets capabilities for the specified touch device.
+ *
+ * @param hDevice The handle of the touch pad.
+ * @param pCapabilities A pointer to the targeted
+ * capabilities returned by the ODM.
+ */
+void
+PANJIT_GetCapabilities(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmTouchCapabilities* pCapabilities);
+
+/**
+ * Gets coordinate info from the touch device.
+ *
+ * @param hDevice The handle to the touch pad.
+ * @param coord A pointer to the structure holding coordinate info.
+ * @return NV_TRUE if successful, or NV_FALSE otherwise.
+ */
+NvBool
+PANJIT_ReadCoordinate(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmTouchCoordinateInfo *pCoord);
+
+/**
+ * Hooks up the interrupt handle to the GPIO interrupt and enables the interrupt.
+ *
+ * @param hDevice The handle to the touch pad.
+ * @param hInterruptSemaphore A handle to hook up the interrupt.
+ * @return NV_TRUE if successful, or NV_FALSE otherwise.
+ */
+NvBool
+PANJIT_EnableInterrupt(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmOsSemaphoreHandle hInterruptSemaphore);
+
+/**
+ * Prepares the next interrupt to get notified from the touch device.
+ *
+ * @param hDevice A handle to the touch pad.
+ * @return NV_TRUE if successful, or NV_FALSE otherwise.
+ */
+NvBool PANJIT_HandleInterrupt(NvOdmTouchDeviceHandle hDevice);
+
+/**
+ * Gets the touch ADC sample rate.
+ *
+ * @param hDevice A handle to the touch ADC.
+ * @param pTouchSampleRate A pointer to the NvOdmTouchSampleRate stucture.
+ *
+ * @return NV_TRUE if successful, or NV_FALSE otherwise.
+*/
+NvBool
+PANJIT_GetSampleRate(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmTouchSampleRate* pTouchSampleRate);
+
+/**
+ * Sets the touch ADC sample rate.
+ *
+ * @param hDevice A handle to the touch ADC.
+ * @param SampleRate 1 indicates high frequency, 0 indicates low frequency.
+ *
+ * @return NV_TRUE if successful, or NV_FALSE otherwise.
+*/
+NvBool PANJIT_SetSampleRate(NvOdmTouchDeviceHandle hDevice, NvU32 rate);
+
+/**
+ * Sets the touch panel power mode.
+ *
+ * @param hDevice A handle to the touch ADC.
+ * @param mode The mode, ranging from full power to power off.
+ *
+ * @return NV_TRUE if successful, or NV_FALSE otherwise.
+*/
+NvBool
+PANJIT_PowerControl(
+ NvOdmTouchDeviceHandle hDevice,
+ NvOdmTouchPowerModeType mode);
+
+/**
+ * Gets the touch panel calibration data.
+ * This is optional as calibration may perform after the OS is up.
+ * This is not required to bring up the touch panel.
+ *
+ * @param hDevice A handle to the touch panel.
+ * @param NumOfCalibrationData Indicates the number of calibration points.
+ * @param pRawCoordBuffer The collection of X/Y coordinate data.
+ *
+ * @return NV_TRUE if preset calibration data is required, or NV_FALSE otherwise.
+ */
+NvBool
+PANJIT_GetCalibrationData(
+ NvOdmTouchDeviceHandle hDevice,
+ NvU32 NumOfCalibrationData,
+ NvS32* pRawCoordBuffer);
+
+/**
+ * Powers the touch device on or off.
+ *
+ * @param hDevice A handle to the touch ADC.
+ * @param OnOff Specify 1 to power ON, 0 to power OFF.
+*/
+NvBool PANJIT_PowerOnOff(NvOdmTouchDeviceHandle hDevice, NvBool OnOff);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // INCLUDED_NVODM_TOUCH_PANJIT_H
+