1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef UINPUT_TOUCH_H 17 #define UINPUT_TOUCH_H 18 19 #include <securec.h> 20 #include <stdint.h> 21 #include "osal_time.h" 22 #include "hdf_input_device_manager.h" 23 #include "uinput_config_parser.h" 24 #include "uinput_i2c_ops.h" 25 26 #define CHIP_CHECK_RETURN(ret) do { \ 27 if ((ret) != HDF_SUCCESS) { \ 28 return ret; \ 29 } \ 30 } while (0) 31 32 #define MAX_FINGERS_NUM 10 33 #define SELF_TEST_RESULT_LEN 20 34 35 #define PWR_TYPE_INDEX 0 36 #define PWR_STATUS_INDEX 1 37 #define PWR_DIR_INDEX 2 38 #define PWR_DELAY_INDEX 3 39 #define PWR_CELL_LEN 4 40 41 typedef struct { 42 uint32_t type; 43 uint32_t code; 44 int32_t value; 45 uint64_t time; 46 } EventPackage; 47 48 typedef enum { 49 TOUCH_DOWN, 50 TOUCH_UP, 51 TOUCH_CONTACT, 52 } EventType; 53 54 typedef enum { 55 TYPE_UNKNOWN, 56 TYPE_VCC, 57 TYPE_VCI, 58 TYPE_RESET, 59 TYPE_INT, 60 } TimingType; 61 62 typedef struct { 63 int32_t x; // x coordinate 64 int32_t y; // y coordinate 65 int32_t pressure; 66 int32_t trackId; // touch ID 67 int32_t status; // record every point's status 68 bool valid; 69 } FingerData; 70 71 typedef struct { 72 FingerData fingers[MAX_FINGERS_NUM]; 73 int32_t realPointNum; 74 int32_t definedEvent; // touch event: 0-down; 1-up; 2-contact 75 OsalTimespec time; 76 } FrameData; 77 78 struct TouchChipDevice; 79 typedef struct TouchPlatformDriver { 80 struct HdfDeviceObject *hdfTouchDev; 81 InputDevice *inputDev; 82 struct TouchChipDevice *device; 83 FrameData frameData; 84 uint32_t devType; 85 const char *devName; 86 TouchBoardCfg *boardCfg; 87 InputI2cClient i2cClient; 88 struct OsalMutex mutex; 89 uint32_t pwrStatus; 90 uint32_t gestureMode; 91 bool initedFlag; 92 bool irqStopFlag; 93 } TouchDriver; 94 95 struct TouchChipOps; 96 typedef struct TouchChipDevice { 97 TouchDriver *driver; 98 const char *chipName; 99 const char *vendorName; 100 struct TouchChipOps *ops; 101 TouchChipCfg *chipCfg; 102 TouchBoardCfg *boardCfg; 103 } ChipDevice; 104 105 struct TouchChipOps { 106 int32_t (*Init)(ChipDevice *device); 107 int32_t (*Detect)(ChipDevice *device); 108 int32_t (*Resume)(ChipDevice *device); 109 int32_t (*Suspend)(ChipDevice *device); 110 int32_t (*DataHandle)(ChipDevice *device); 111 int32_t (*UpdateFirmware)(ChipDevice *device); 112 void (*SetAbility)(ChipDevice *device); 113 }; 114 115 typedef struct { 116 uint32_t testType; 117 char testResult[SELF_TEST_RESULT_LEN]; 118 } CapacitanceTestInfo; 119 120 typedef struct { 121 const char *cmdCode; 122 const char *cmdValue; 123 } InputExtraCmd; 124 125 int32_t RegisterTouchChipDevice(ChipDevice *chipDev); 126 127 #define MAX_TOUCH_DEVICE 5 128 129 #endif // UINPUT_TOUCH_H 130