summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/msg2138/mstar_drv_platform_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/msg2138/mstar_drv_platform_interface.c')
-rw-r--r--drivers/input/touchscreen/msg2138/mstar_drv_platform_interface.c209
1 files changed, 209 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/msg2138/mstar_drv_platform_interface.c b/drivers/input/touchscreen/msg2138/mstar_drv_platform_interface.c
new file mode 100644
index 00000000..24314f47
--- /dev/null
+++ b/drivers/input/touchscreen/msg2138/mstar_drv_platform_interface.c
@@ -0,0 +1,209 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2006-2012 MStar Semiconductor, Inc.
+// All rights reserved.
+//
+// Unless otherwise stipulated in writing, any and all information contained
+// herein regardless in any format shall remain the sole proprietary of
+// MStar Semiconductor Inc. and be kept in strict confidence
+// (??MStar Confidential Information??) by the recipient.
+// Any unauthorized act including without limitation unauthorized disclosure,
+// copying, use, reproduction, sale, distribution, modification, disassembling,
+// reverse engineering and compiling of the contents of MStar Confidential
+// Information is unlawful and strictly prohibited. MStar hereby reserves the
+// rights to any and all damages, losses, costs and expenses resulting therefrom.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ *
+ * @file mstar_drv_platform_interface.c
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ * @version v2.2.0.0
+ *
+ */
+
+/*=============================================================*/
+// INCLUDE FILE
+/*=============================================================*/
+
+#include "mstar_drv_platform_interface.h"
+#include "mstar_drv_main.h"
+#include "mstar_drv_ic_fw_porting_layer.h"
+#include "mstar_drv_platform_porting_layer.h"
+
+/*=============================================================*/
+// EXTERN VARIABLE DECLARATION
+/*=============================================================*/
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+extern u16 g_GestureWakeupMode;
+extern u8 g_GestureWakeupFlag;
+#endif //CONFIG_ENABLE_GESTURE_WAKEUP
+
+/*=============================================================*/
+// GLOBAL VARIABLE DEFINITION
+/*=============================================================*/
+
+extern struct input_dev *g_InputDevice;
+
+/*=============================================================*/
+// GLOBAL FUNCTION DEFINITION
+/*=============================================================*/
+
+void MsDrvInterfaceTouchDeviceSuspend(struct early_suspend *pSuspend)
+{
+ DBG("*** %s() ***\n", __func__);
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+// g_GestureWakeupMode = 0x1FFF; // Enable all gesture wakeup mode for testing
+
+ if (g_GestureWakeupMode != 0x0000)
+ {
+ DrvIcFwLyrOpenGestureWakeup(g_GestureWakeupMode);
+ return;
+ }
+#endif //CONFIG_ENABLE_GESTURE_WAKEUP
+
+ DrvPlatformLyrFingerTouchReleased(0, 0); // Send touch end for clearing point touch
+ input_sync(g_InputDevice);
+
+ DrvPlatformLyrDisableFingerTouchReport();
+ DrvPlatformLyrTouchDevicePowerOff();
+}
+
+void MsDrvInterfaceTouchDeviceResume(struct early_suspend *pSuspend)
+{
+ DBG("*** %s() ***\n", __func__);
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+ if (g_GestureWakeupFlag == 1)
+ {
+ DrvIcFwLyrCloseGestureWakeup();
+ }
+ else
+ {
+ DrvPlatformLyrEnableFingerTouchReport();
+ }
+#endif //CONFIG_ENABLE_GESTURE_WAKEUP
+
+ DrvPlatformLyrTouchDevicePowerOn();
+/*
+ DrvPlatformLyrFingerTouchReleased(0, 0);
+ input_sync(g_InputDevice);
+*/
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ DrvIcFwLyrRestoreFirmwareModeToLogDataMode();
+#endif //CONFIG_ENABLE_FIRMWARE_DATA_LOG
+
+#ifndef CONFIG_ENABLE_GESTURE_WAKEUP
+ DrvPlatformLyrEnableFingerTouchReport();
+#endif //CONFIG_ENABLE_GESTURE_WAKEUP
+}
+
+#ifdef TOUCH_VIRTUAL_KEYS
+/*static ssize_t virtual_keys_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf,
+ __stringify(EV_KEY) ":" __stringify(KEY_HOMEPAGE) ":192:1000:64:60"
+ ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":256:1000:64:60"
+ ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":128:1000:64:60"
+ ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":64:1000:64:60"
+ "\n");
+}*/
+static ssize_t virtual_keys_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+ struct msg2138_ts_platform_data *pdata = g_I2cClient->dev.platform_data;
+ return sprintf(buf,"%s:%s:%d:%d:%d:%d:%s:%s:%d:%d:%d:%d:%s:%s:%d:%d:%d:%d\n"
+ ,__stringify(EV_KEY), __stringify(KEY_APPSELECT),pdata ->virtualkeys[0],pdata ->virtualkeys[1],pdata ->virtualkeys[2],pdata ->virtualkeys[3]
+ ,__stringify(EV_KEY), __stringify(KEY_HOMEPAGE),pdata ->virtualkeys[4],pdata ->virtualkeys[5],pdata ->virtualkeys[6],pdata ->virtualkeys[7]
+ ,__stringify(EV_KEY), __stringify(KEY_BACK),pdata ->virtualkeys[8],pdata ->virtualkeys[9],pdata ->virtualkeys[10],pdata ->virtualkeys[11]);
+}
+
+static struct kobj_attribute virtual_keys_attr = {
+ .attr = {
+ .name = "virtualkeys.msg2138_ts",
+ .mode = S_IRUGO,
+ },
+ .show = &virtual_keys_show,
+};
+
+static struct attribute *properties_attrs[] = {
+ &virtual_keys_attr.attr,
+ NULL
+};
+
+static struct attribute_group properties_attr_group = {
+ .attrs = properties_attrs,
+};
+
+static void pixcir_ts_virtual_keys_init(void)
+{
+ int ret;
+ struct kobject *properties_kobj;
+
+ properties_kobj = kobject_create_and_add("board_properties", NULL);
+ if (properties_kobj)
+ ret = sysfs_create_group(properties_kobj,
+ &properties_attr_group);
+ if (!properties_kobj || ret)
+ pr_err("failed to create board_properties\n");
+}
+#endif
+
+/* probe function is used for matching and initializing input device */
+s32 /*__devinit*/ MsDrvInterfaceTouchDeviceProbe(struct i2c_client *pClient, const struct i2c_device_id *pDeviceId)
+{
+ s32 nRetVal = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ DrvPlatformLyrInputDeviceInitialize(pClient);
+
+ nRetVal = DrvPlatformLyrTouchDeviceRequestGPIO();
+ if(nRetVal < 0) {
+ pr_err("[Mstar] DrvPlatformLyrTouchDeviceRequestGPIO failed %d\n",nRetVal);
+ return nRetVal;
+ }
+
+#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
+ DrvPlatformLyrTouchDeviceRegulatorPowerOn();
+#endif //CONFIG_ENABLE_REGULATOR_POWER_ON
+
+ DrvPlatformLyrTouchDevicePowerOn();
+
+ nRetVal = DrvMainTouchDeviceInitialize();
+ if(nRetVal < 0) {
+ pr_err("[Mstar] DrvMainTouchDeviceInitialize failed %d\n",nRetVal);
+ return nRetVal;
+ }
+
+#ifdef TOUCH_VIRTUAL_KEYS
+ pixcir_ts_virtual_keys_init();
+#endif
+
+ DrvPlatformLyrTouchDeviceRegisterFingerTouchInterruptHandler();
+
+ DrvPlatformLyrTouchDeviceRegisterEarlySuspend();
+
+ printk("*** MStar touch driver registered ***\n");
+
+ return nRetVal;
+}
+
+/* remove function is triggered when the input device is removed from input sub-system */
+s32 /*__devexit*/ MsDrvInterfaceTouchDeviceRemove(struct i2c_client *pClient)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ return DrvPlatformLyrTouchDeviceRemove(pClient);
+}
+
+void MsDrvInterfaceTouchDeviceSetIicDataRate(struct i2c_client *pClient, u32 nIicDataRate)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ DrvPlatformLyrSetIicDataRate(pClient, nIicDataRate);
+}