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 OHOS_HDI_SENSOR_V1_1_ISENSORINTERFACE_VDI_H 17 #define OHOS_HDI_SENSOR_V1_1_ISENSORINTERFACE_VDI_H 18 19 #include "hdf_load_vdi.h" 20 #include "isensor_callback_vdi.h" 21 22 namespace OHOS { 23 namespace HDI { 24 namespace Sensor { 25 namespace V1_1 { 26 27 #define HDI_SENSOR_VDI_LIBNAME "libhdi_sensor_impl.z.so" 28 29 struct HdfSensorInformationVdi { 30 std::string sensorName; 31 std::string vendorName; 32 std::string firmwareVersion; 33 std::string hardwareVersion; 34 int32_t sensorTypeId; 35 int32_t sensorId; 36 float maxRange; 37 float accuracy; 38 float power; 39 int64_t minDelay; 40 int64_t maxDelay; 41 uint32_t fifoMaxEventCount; 42 uint32_t reserved; 43 }; 44 45 struct SdcSensorInfoVdi { 46 uint64_t offset; 47 int32_t sensorId; 48 int32_t ddrSize; 49 int32_t minRateLevel; 50 int32_t maxRateLevel; 51 uint64_t memAddr; 52 int32_t reserved; 53 }; 54 55 class ISensorInterfaceVdi { 56 public: 57 virtual ~ISensorInterfaceVdi() = default; 58 virtual int32_t Init() = 0; 59 virtual int32_t GetAllSensorInfo(std::vector<HdfSensorInformationVdi>& info) = 0; 60 virtual int32_t Enable(int32_t sensorId) = 0; 61 virtual int32_t Disable(int32_t sensorId) = 0; 62 virtual int32_t SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) = 0; 63 virtual int32_t SetMode(int32_t sensorId, int32_t mode) = 0; 64 virtual int32_t SetOption(int32_t sensorId, uint32_t option) = 0; 65 virtual int32_t Register(int32_t groupId, const sptr<ISensorCallbackVdi>& callbackObj) = 0; 66 virtual int32_t Unregister(int32_t groupId, const sptr<ISensorCallbackVdi>& callbackObj) = 0; GetSdcSensorInfo(std::vector<SdcSensorInfoVdi> & sdcSensorInfo)67 virtual int32_t GetSdcSensorInfo(std::vector<SdcSensorInfoVdi>& sdcSensorInfo) { return HDF_SUCCESS; }; SetSaBatch(int32_t sensorId,int64_t samplingInterval,int64_t reportInterval)68 virtual int32_t SetSaBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) 69 { 70 return HDF_SUCCESS; 71 }; 72 }; 73 74 struct WrapperSensorVdi { 75 struct HdfVdiBase base; 76 ISensorInterfaceVdi *sensorModule; 77 }; 78 } // V1_1 79 } // Sensor 80 } // HDI 81 } // OHOS 82 83 #endif // OHOS_HDI_SENSOR_V1_1_ISENSORINTERFACE_VDI_H 84