1 /* 2 * Copyright (c) 2021-2022 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 /** 17 * @addtogroup Input 18 * @{ 19 * 20 * @brief Provides driver interfaces for the input service. 21 * 22 * These driver interfaces can be used to open and close input device files, get input events, query device information, 23 * register callback functions, and control the feature status. 24 * 25 * 26 * @since 1.0 27 * @version 1.0 28 */ 29 30 /** 31 * @file input_controller.h 32 * 33 * @brief Declares the driver interfaces for controlling the business process of input devices. 34 * 35 * @since 1.0 36 * @version 1.0 37 */ 38 39 #ifndef INPUT_CONTROLLER_H 40 #define INPUT_CONTROLLER_H 41 42 #include "input_type.h" 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /** 49 * @brief Provides interfaces for controlling the business process of input devices. 50 * 51 * The interfaces can be called to set the power status, enable or disable a feature, get driver chip information, 52 * and control the production test. 53 */ 54 typedef struct { 55 /** 56 * @brief Sets the power status. 57 * 58 * This function is called only when the power status of the OS is changed. \n 59 * The input service or the power management module can call this function to set the power status 60 * for the input device when the OS is in the Resume or Suspend status, so that the driver integrated circuit (IC) 61 * of the device can normally enter the specified status. 62 * 63 * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. 64 * The value ranges from 0 to 31, and value <b>0</b> represents the first input device. 65 * @param status Indicates the power status to set. The input service will notify the input device of entering the 66 * Resume or Suspend state specified by {@link PowerStatus}. 67 * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined in 68 * {@link RetStatus} otherwise. 69 * @since 1.0 70 * @version 1.0 71 */ 72 int32_t (*SetPowerStatus)(uint32_t devIndex, uint32_t status); 73 74 /** 75 * @brief Gets the power status. 76 * 77 * The input service or the power management module can get the power status for the input device when the OS 78 * is in the Resume or Suspend status, so that the driver IC of the device can normally enter the specified status. 79 * You can call this function to obtain the power status. 80 * 81 * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. 82 * The value ranges from 0 to 31, and value <b>0</b> represents the first input device. 83 * @param status Indicates the pointer to the power status of the device. For details, see {@link PowerStatus}. 84 * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined in 85 * {@link RetStatus} otherwise. 86 * @since 1.0 87 * @version 1.0 88 */ 89 int32_t (*GetPowerStatus)(uint32_t devIndex, uint32_t *status); 90 91 /** 92 * @brief Gets the type of the input device based on the specified device index. 93 * 94 * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. 95 * The value ranges from 0 to 31, and value <b>0</b> represents the first input device. 96 * @param deviceType Indicates the pointer to the device type. For details, see {@link InputDevType}. 97 * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined 98 * in {@link RetStatus} otherwise. 99 * @since 1.0 100 * @version 1.0 101 */ 102 int32_t (*GetDeviceType)(uint32_t devIndex, uint32_t *deviceType); 103 104 /** 105 * @brief Gets the chip information of the specified device. 106 * 107 * A product is usually equipped with modules and driver ICs provided by multiple vendors. An input service 108 * can call this function to get the specific information if needed. 109 * 110 * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. 111 * The value ranges from 0 to 31, and value <b>0</b> represents the first input device. 112 * @param chipInfo Indicates the pointer to the chip information. 113 * @param length Indicates the length of the chip information. The minimum value of length is 10. 114 * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined 115 * in {@link RetStatus} otherwise. 116 * @since 1.0 117 * @version 1.0 118 */ 119 int32_t (*GetChipInfo)(uint32_t devIndex, char *chipInfo, uint32_t length); 120 121 /** 122 * @brief Gets the module vendor name of the specified device. 123 * 124 * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. 125 * The value ranges from 0 to 31, and value <b>0</b> represents the first input device. 126 * @param vendorName Indicates the pointer to the module vendor name. 127 * @param length Indicates the length of the module vendor name. The minimum value of length is 10. 128 * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined 129 * in {@link RetStatus} otherwise. 130 * @since 1.0 131 * @version 1.0 132 */ 133 int32_t (*GetVendorName)(uint32_t devIndex, char *vendorName, uint32_t length); 134 135 /** 136 * @brief Gets the driver chip name of the specified device. 137 * 138 * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. 139 * The value ranges from 0 to 31, and value <b>0</b> represents the first input device. 140 * @param chipName Indicates the pointer to the driver chip name. 141 * @param length Indicates the length of the driver chip name. The minimum value of length is 10. 142 * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined 143 * in {@link RetStatus} otherwise. 144 * @since 1.0 145 * @version 1.0 146 */ 147 int32_t (*GetChipName)(uint32_t devIndex, char *chipName, uint32_t length); 148 149 /** 150 * @brief Sets the gesture mode. 151 * 152 * The input service can use this function to enable or disable the gesture mode by setting <b>EnableBit</b> 153 * of the gesture mode. 154 * 155 * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. 156 * The value ranges from 0 to 31, and value <b>0</b> represents the first input device. 157 * @param gestureMode Indicates the gesture mode to set. 158 * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined 159 * in {@link RetStatus} otherwise. 160 * @since 1.0 161 * @version 1.0 162 */ 163 int32_t (*SetGestureMode)(uint32_t devIndex, uint32_t gestureMode); 164 165 /** 166 * @brief Conducts a capacitance self-test. 167 * 168 * The capacitance self-test items are defined by the component vendor, such as the tests on the raw data, 169 * short circuit, open circuit, interference, and row/column difference. 170 * 171 * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. 172 * The value ranges from 0 to 31, and value <b>0</b> represents the first input device. 173 * @param testType Indicates the capacitance test type. For details, see {@link CapacitanceTest}. 174 * @param result Indicates the pointer to the capacitance test result. The value is <b>SUCC</b> for a successful 175 * operation and is an error code for a failed operation. 176 * @param length Indicates the length of the test result. The minimum value of length is 20. 177 * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined 178 * in {@link RetStatus} otherwise. 179 * @since 1.0 180 * @version 1.0 181 */ 182 int32_t (*RunCapacitanceTest)(uint32_t devIndex, uint32_t testType, char *result, uint32_t length); 183 184 /** 185 * @brief Executes the extra command. 186 * 187 * @param devIndex Indicates the index of an input device. A maximum of 32 input devices are supported. 188 * The value ranges from 0 to 31, and value <b>0</b> represents the first input device. 189 * @param cmd Indicates the pointer to the extra command data packet, including the command codes and parameters. 190 * For details, see {@link InputExtraCmd}. 191 * @return Returns <b>INPUT SUCCESS</b> if the operation is successful; returns an error code defined 192 * in {@link RetStatus} otherwise. 193 * @since 1.0 194 * @version 1.0 195 */ 196 int32_t (*RunExtraCommand)(uint32_t devIndex, InputExtraCmd *cmd); 197 } InputController; 198 199 #ifdef __cplusplus 200 } 201 #endif 202 #endif 203 /** @} */ 204