1 ////////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2006-2012 MStar Semiconductor, Inc.
4 // All rights reserved.
6 // Unless otherwise stipulated in writing, any and all information contained
7 // herein regardless in any format shall remain the sole proprietary of
8 // MStar Semiconductor Inc. and be kept in strict confidence
9 // (??MStar Confidential Information??) by the recipient.
10 // Any unauthorized act including without limitation unauthorized disclosure,
11 // copying, use, reproduction, sale, distribution, modification, disassembling,
12 // reverse engineering and compiling of the contents of MStar Confidential
13 // Information is unlawful and strictly prohibited. MStar hereby reserves the
14 // rights to any and all damages, losses, costs and expenses resulting therefrom.
16 ////////////////////////////////////////////////////////////////////////////////
20 * @file mstar_drv_platform_interface.c
22 * @brief This file defines the interface of touch screen
28 /*=============================================================*/
30 /*=============================================================*/
32 #include "mstar_drv_platform_interface.h"
33 #include "mstar_drv_main.h"
34 #include "mstar_drv_ic_fw_porting_layer.h"
35 #include "mstar_drv_platform_porting_layer.h"
37 /*=============================================================*/
38 // EXTERN VARIABLE DECLARATION
39 /*=============================================================*/
41 #ifdef CONFIG_ENABLE_GESTURE_WAKEUP
42 extern u16 g_GestureWakeupMode;
43 extern u8 g_GestureWakeupFlag;
44 #endif //CONFIG_ENABLE_GESTURE_WAKEUP
46 /*=============================================================*/
47 // GLOBAL VARIABLE DEFINITION
48 /*=============================================================*/
50 extern struct input_dev *g_InputDevice;
52 /*=============================================================*/
53 // GLOBAL FUNCTION DEFINITION
54 /*=============================================================*/
56 void MsDrvInterfaceTouchDeviceSuspend(struct early_suspend *pSuspend)
58 DBG("*** %s() ***\n", __func__);
60 #ifdef CONFIG_ENABLE_GESTURE_WAKEUP
61 // g_GestureWakeupMode = 0x1FFF; // Enable all gesture wakeup mode for testing
63 if (g_GestureWakeupMode != 0x0000)
65 DrvIcFwLyrOpenGestureWakeup(g_GestureWakeupMode);
68 #endif //CONFIG_ENABLE_GESTURE_WAKEUP
70 DrvPlatformLyrFingerTouchReleased(0, 0); // Send touch end for clearing point touch
71 input_sync(g_InputDevice);
73 DrvPlatformLyrDisableFingerTouchReport();
74 DrvPlatformLyrTouchDevicePowerOff();
77 void MsDrvInterfaceTouchDeviceResume(struct early_suspend *pSuspend)
79 DBG("*** %s() ***\n", __func__);
81 #ifdef CONFIG_ENABLE_GESTURE_WAKEUP
82 if (g_GestureWakeupFlag == 1)
84 DrvIcFwLyrCloseGestureWakeup();
88 DrvPlatformLyrEnableFingerTouchReport();
90 #endif //CONFIG_ENABLE_GESTURE_WAKEUP
92 DrvPlatformLyrTouchDevicePowerOn();
94 DrvPlatformLyrFingerTouchReleased(0, 0);
95 input_sync(g_InputDevice);
97 #ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
98 DrvIcFwLyrRestoreFirmwareModeToLogDataMode();
99 #endif //CONFIG_ENABLE_FIRMWARE_DATA_LOG
101 #ifndef CONFIG_ENABLE_GESTURE_WAKEUP
102 DrvPlatformLyrEnableFingerTouchReport();
103 #endif //CONFIG_ENABLE_GESTURE_WAKEUP
106 #ifdef TOUCH_VIRTUAL_KEYS
107 /*static ssize_t virtual_keys_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
110 __stringify(EV_KEY) ":" __stringify(KEY_HOMEPAGE) ":192:1000:64:60"
111 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":256:1000:64:60"
112 ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":128:1000:64:60"
113 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":64:1000:64:60"
116 static ssize_t virtual_keys_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
118 struct msg2138_ts_platform_data *pdata = g_I2cClient->dev.platform_data;
119 return sprintf(buf,"%s:%s:%d:%d:%d:%d:%s:%s:%d:%d:%d:%d:%s:%s:%d:%d:%d:%d\n"
120 ,__stringify(EV_KEY), __stringify(KEY_APPSELECT),pdata ->virtualkeys[0],pdata ->virtualkeys[1],pdata ->virtualkeys[2],pdata ->virtualkeys[3]
121 ,__stringify(EV_KEY), __stringify(KEY_HOMEPAGE),pdata ->virtualkeys[4],pdata ->virtualkeys[5],pdata ->virtualkeys[6],pdata ->virtualkeys[7]
122 ,__stringify(EV_KEY), __stringify(KEY_BACK),pdata ->virtualkeys[8],pdata ->virtualkeys[9],pdata ->virtualkeys[10],pdata ->virtualkeys[11]);
125 static struct kobj_attribute virtual_keys_attr = {
127 .name = "virtualkeys.msg2138_ts",
130 .show = &virtual_keys_show,
133 static struct attribute *properties_attrs[] = {
134 &virtual_keys_attr.attr,
138 static struct attribute_group properties_attr_group = {
139 .attrs = properties_attrs,
142 static void pixcir_ts_virtual_keys_init(void)
145 struct kobject *properties_kobj;
147 properties_kobj = kobject_create_and_add("board_properties", NULL);
149 ret = sysfs_create_group(properties_kobj,
150 &properties_attr_group);
151 if (!properties_kobj || ret)
152 pr_err("failed to create board_properties\n");
156 /* probe function is used for matching and initializing input device */
157 s32 /*__devinit*/ MsDrvInterfaceTouchDeviceProbe(struct i2c_client *pClient, const struct i2c_device_id *pDeviceId)
161 DBG("*** %s() ***\n", __func__);
163 DrvPlatformLyrInputDeviceInitialize(pClient);
165 nRetVal = DrvPlatformLyrTouchDeviceRequestGPIO();
167 pr_err("[Mstar] DrvPlatformLyrTouchDeviceRequestGPIO failed %d\n",nRetVal);
171 #ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
172 DrvPlatformLyrTouchDeviceRegulatorPowerOn();
173 #endif //CONFIG_ENABLE_REGULATOR_POWER_ON
175 DrvPlatformLyrTouchDevicePowerOn();
177 nRetVal = DrvMainTouchDeviceInitialize();
179 pr_err("[Mstar] DrvMainTouchDeviceInitialize failed %d\n",nRetVal);
183 #ifdef TOUCH_VIRTUAL_KEYS
184 pixcir_ts_virtual_keys_init();
187 DrvPlatformLyrTouchDeviceRegisterFingerTouchInterruptHandler();
189 DrvPlatformLyrTouchDeviceRegisterEarlySuspend();
191 printk("*** MStar touch driver registered ***\n");
196 /* remove function is triggered when the input device is removed from input sub-system */
197 s32 /*__devexit*/ MsDrvInterfaceTouchDeviceRemove(struct i2c_client *pClient)
199 DBG("*** %s() ***\n", __func__);
201 return DrvPlatformLyrTouchDeviceRemove(pClient);
204 void MsDrvInterfaceTouchDeviceSetIicDataRate(struct i2c_client *pClient, u32 nIicDataRate)
206 DBG("*** %s() ***\n", __func__);
208 DrvPlatformLyrSetIicDataRate(pClient, nIicDataRate);