diff --git a/sensor/hal/src/sensor_controller.c b/sensor/hal/src/sensor_controller.c index 74c166bdd7..5c9396ba9d 100644 --- a/sensor/hal/src/sensor_controller.c +++ b/sensor/hal/src/sensor_controller.c @@ -476,6 +476,12 @@ static int32_t SdcSensorActive(int32_t sensorId, bool enabled, int32_t rateLevel return HDF_SUCCESS; } +static int32_t GetSdcSensorInfo(std::vector& sdcSensorInfos) +{ + (void)sdcSensorInfos; + return HDF_SUCCESS; +} + void GetSensorDeviceMethods(struct SensorInterface *device) { CHECK_NULL_PTR_RETURN(device); diff --git a/sensor/hdi_impl/sensor_impl.cpp b/sensor/hdi_impl/sensor_impl.cpp index 4ba1df3d4b..7af993f5e8 100644 --- a/sensor/hdi_impl/sensor_impl.cpp +++ b/sensor/hdi_impl/sensor_impl.cpp @@ -343,6 +343,21 @@ int32_t SensorImpl::SdcSensorActive(int32_t sensorId, bool enabled, int32_t rate return ret; } +int32_t SensorImpl::GetSdcSensorInfo(std::vector& sdcSensorInfoVdis) +{ + HDF_LOGI("%{public}s: Enter the GetSdcSensorInfo function", __func__); + CHECK_SENSOR_MODULE_INSTANCE(sensorInterface, sensorInterface->GetSdcSensorInfo); + + StartTrace(HITRACE_TAG_SENSORS, "GetSdcSensorInfo"); + int32_t ret = sensorInterface->GetSdcSensorInfo(sdcSensorInfoVdis); + FinishTrace(HITRACE_TAG_SENSORS); + if (ret != SENSOR_SUCCESS) { + HDF_LOGE("%{public}s failed, error code is %{public}d", __func__, ret); + } + + return ret; +} + int32_t SensorImpl::UnregisterImpl(int32_t groupId, IRemoteObject *callbackObj) { CHECK_SENSOR_MODULE_INSTANCE(sensorInterface, sensorInterface->Unregister); diff --git a/sensor/hdi_impl/sensor_impl.h b/sensor/hdi_impl/sensor_impl.h index 9bb117f221..ebb806da06 100644 --- a/sensor/hdi_impl/sensor_impl.h +++ b/sensor/hdi_impl/sensor_impl.h @@ -49,6 +49,7 @@ public: int32_t Register(int32_t groupId, const sptr& callbackObj) override; int32_t Unregister(int32_t groupId, const sptr& callbackObj) override; int32_t SdcSensorActive(int32_t sensorId, bool enabled, int32_t rateLevel) override; + int32_t GetSdcSensorInfo(std::vector& sdcSensorInfoVdis) override; void OnRemoteDied(const wptr &object); private: const SensorInterface *sensorInterface; diff --git a/sensor/hdi_service/sensor_if_service.cpp b/sensor/hdi_service/sensor_if_service.cpp index 58f2bac65e..0f0a6060f3 100644 --- a/sensor/hdi_service/sensor_if_service.cpp +++ b/sensor/hdi_service/sensor_if_service.cpp @@ -303,7 +303,8 @@ int32_t SensorIfService::ReadData(int32_t sensorId, std::vector return HDF_SUCCESS; } -int32_t SensorIfService::SdcSensorActive(int32_t sensorId, bool enabled, int32_t rateLevel){ +int32_t SensorIfService::SdcSensorActive(int32_t sensorId, bool enabled, int32_t rateLevel) +{ HDF_LOGI("%{public}s: Enter the SdcSensorActive function, sensorId is %{public}d, enabled is %{public}u, \ rateLevel is %{public}u", __func__, sensorId, enabled, rateLevel); if (sensorVdiImpl_ == nullptr) { @@ -321,6 +322,24 @@ int32_t SensorIfService::SdcSensorActive(int32_t sensorId, bool enabled, int32_t return ret; } +int32_t SensorIfService::GetSdcSensorInfo(std::vector& sdcSensorInfos) +{ + HDF_LOGI("%{public}s: Enter the GetSdcSensorInfo function", __func__); + if (sensorVdiImpl_ == nullptr) { + HDF_LOGE("%{public}s: get sensor vdi impl failed", __func__); + return HDF_FAILURE; + } + + StartTrace(HITRACE_TAG_HDF, "GetSdcSensorInfo"); + int32_t ret = sensorVdiImpl_->GetSdcSensorInfo(sdcSensorInfos); + if (ret != SENSOR_SUCCESS) { + HDF_LOGE("%{public}s GetSdcSensorInfo failed, error code is %{public}d", __func__, ret); + } + FinishTrace(HITRACE_TAG_HDF); + + return ret; +} + extern "C" ISensorInterface *SensorInterfaceImplGetInstance(void) { SensorIfService *impl = new (std::nothrow) SensorIfService(); diff --git a/sensor/hdi_service/sensor_if_service.h b/sensor/hdi_service/sensor_if_service.h index c9b52d96d2..caac1fd6c2 100644 --- a/sensor/hdi_service/sensor_if_service.h +++ b/sensor/hdi_service/sensor_if_service.h @@ -45,6 +45,7 @@ public: int32_t Unregister(int32_t groupId, const sptr &callbackObj) override; int32_t ReadData(int32_t sensorId, std::vector &event) override; int32_t SdcSensorActive(int32_t sensorId, bool enabled, int32_t rateLevel) override; + int32_t GetSdcSensorInfo(std::vector& sdcSensorInfos) override; int32_t GetSensorVdiImpl(); std::mutex sensorCbMutex_; diff --git a/sensor/interfaces/include/sensor_if.h b/sensor/interfaces/include/sensor_if.h index 3c77833b82..2ee27a771d 100644 --- a/sensor/interfaces/include/sensor_if.h +++ b/sensor/interfaces/include/sensor_if.h @@ -190,9 +190,20 @@ struct SensorInterface { * @return Returns 0 if the event data is obtained; returns a negative value otherwise. * * @since 4.1 - * @version 1.1 + * @version 2.0 */ int32_t (*SdcSensorActive)(int32_t sensorId, bool enabled, int32_t rateLevel); + + /** + * @brief Obtain sensor information for SDC + * + * @param sdcSensorInfos Indicates the data of the SDC type. + * @return Returns 0 if the event data is obtained; returns a negative value otherwise. + * + * @since 4.1 + * @version 2.0 + */ + int32_t (*GetSdcSensorInfo)(std::vector& sdcSensorInfos); }; /** diff --git a/sensor/interfaces/include/sensor_type.h b/sensor/interfaces/include/sensor_type.h index 0414121bd6..fb487407b6 100644 --- a/sensor/interfaces/include/sensor_type.h +++ b/sensor/interfaces/include/sensor_type.h @@ -163,6 +163,15 @@ enum SensorGroupType { SENSOR_GROUP_TYPE_MAX, /**< Maximum sensor type*/ }; +enum SdcRateLevel { + SDC_RATE_STOP, + SDC_RATE_NORMAL, + SDC_RATE_GEN_FAST, + SDC_RATE_FAST, + SDC_RATE_FASTER, + SDC_RATE_VERY_FAST, +}; + /** * @brief Defines basic sensor information. * @@ -205,6 +214,15 @@ struct SensorEvents { uint32_t dataLen; /**< Sensor data length */ }; +struct SdcSensorInfo { + uint64_t offset; + int32_t type; + int32_t ddrSize; + SdcRateLevel minRateLevel; + SdcRateLevel maxRateLevel; + int32_t reserved; +}; + /** * @brief Defines the callback for reporting sensor data. This callback needs to be registered when * a sensor user subscribes to sensor data. Only after the sensor is enabled, the sensor data subscriber can receive diff --git a/sensor/interfaces/v1_0/isensor_interface_vdi.h b/sensor/interfaces/v1_0/isensor_interface_vdi.h index e4c3387bb0..e44c4daa46 100644 --- a/sensor/interfaces/v1_0/isensor_interface_vdi.h +++ b/sensor/interfaces/v1_0/isensor_interface_vdi.h @@ -42,6 +42,24 @@ struct HdfSensorInformationVdi { uint32_t reserved; }; +enum SdcRateLevelVdi { + SDC_RATE_STOP, + SDC_RATE_NORMAL, + SDC_RATE_GEN_FAST, + SDC_RATE_FAST, + SDC_RATE_FASTER, + SDC_RATE_VERY_FAST, +}; + +struct SdcSensorInfoVdi { + uint64_t offset; + int32_t type; + int32_t ddrSize; + SdcRateLevelVdi minRateLevel; + SdcRateLevelVdi maxRateLevel; + int32_t reserved; +}; + class ISensorInterfaceVdi { public: virtual ~ISensorInterfaceVdi() = default; @@ -55,6 +73,7 @@ public: virtual int32_t Register(int32_t groupId, const sptr& callbackObj) = 0; virtual int32_t Unregister(int32_t groupId, const sptr& callbackObj) = 0; virtual int32_t SdcSensorActive(int32_t sensorId, bool enabled, int32_t rateLevel) = 0; + virtual int32_t GetSdcSensorInfo(std::vector& sdcSensorInfoVdis) = 0; }; struct WrapperSensorVdi {