diff --git a/hardware/rockchip/sensor/st_iio/android_data_config b/hardware/rockchip/sensor/st_iio/android_data_config deleted file mode 100644 index b6ce59d071..0000000000 --- a/hardware/rockchip/sensor/st_iio/android_data_config +++ /dev/null @@ -1,9 +0,0 @@ -export PLATFORM_VERSION=13 -export DEFCONFIG= -export ST_HAL_ANDROID_VERSION= -export ST_HAL_HAS_FDFD_LIB=n -export ST_HAL_HAS_GBIAS_LIB=n -export ST_HAL_HAS_GEOMAG_LIB=n -export ST_HAL_HAS_9X_6X_LIB=n -export ST_HAL_HAS_MAGN_CALIB_LIB=n -export ST_HAL_HAS_ACCEL_CALIB_LIB=n diff --git a/hardware/rockchip/sensor/st_iio/configuration.h b/hardware/rockchip/sensor/st_iio/configuration.h deleted file mode 100644 index 4a95017ccc..0000000000 --- a/hardware/rockchip/sensor/st_iio/configuration.h +++ /dev/null @@ -1,7 +0,0 @@ -/* configuration.h -- Autogenerated file! Do not edit. */ - -#ifndef __ST_SENSOR_HAL_CONFIG_H -#define __ST_SENSOR_HAL_CONFIG_H - - -#endif /* __ST_SENSOR_HAL_CONFIG_H */ diff --git a/hardware/rockchip/sensor/st_iio/src/CorrelatedColorTemp.cpp b/hardware/rockchip/sensor/st_iio/src/CorrelatedColorTemp.cpp deleted file mode 100644 index 88ce214200..0000000000 --- a/hardware/rockchip/sensor/st_iio/src/CorrelatedColorTemp.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Ultra Capteur Color-Based Light Sensor Class - * - * Copyright 2022 Rockchip Electronics Co., Ltd - * Author: Jason Zhang - - * - * Licensed under the Apache License, Version 2.0 (the "License"). - */ - -#include -#include -#include - -#include "CorrelatedColorTemp.h" - -CorrelatedColorTemp::CorrelatedColorTemp(HWSensorBaseCommonData *data, const char *name, - struct device_iio_sampling_freqs *sfa, int handle, - unsigned int hw_fifo_len, float power_consumption, bool wakeup) : - HWSensorBaseWithPollrate(data, name, sfa, handle, - SENSOR_TYPE_CCT, hw_fifo_len, power_consumption) -{ -#if (CONFIG_ST_HAL_ANDROID_VERSION > ST_HAL_KITKAT_VERSION) - sensor_t_data.stringType = SENSOR_STRING_TYPE_CCT; - sensor_t_data.flags |= SENSOR_FLAG_ON_CHANGE_MODE; - - if (wakeup) - sensor_t_data.flags |= SENSOR_FLAG_WAKE_UP; -#else /* CONFIG_ST_HAL_ANDROID_VERSION */ - (void)wakeup; -#endif /* CONFIG_ST_HAL_ANDROID_VERSION */ - - sensor_t_data.resolution = 1.0f; - sensor_t_data.maxRange = 9.0f; -} - -CorrelatedColorTemp::~CorrelatedColorTemp() -{ - -} - -int CorrelatedColorTemp::Enable(int handle, bool enable, bool lock_en_mutex) -{ -#ifdef CONFIG_ST_HAL_ACCEL_CALIB_ENABLED - int err; - - if (lock_en_mutex) - pthread_mutex_lock(&enable_mutex); - - err = HWSensorBaseWithPollrate::Enable(handle, enable, false); - if (err < 0) { - if (lock_en_mutex) - pthread_mutex_unlock(&enable_mutex); - - return err; - } - - if (enable) - ST_AccCalibration_API_Init(CALIBRATION_PERIOD_MS); - else - ST_AccCalibration_API_DeInit(CALIBRATION_PERIOD_MS); - - if (lock_en_mutex) - pthread_mutex_unlock(&enable_mutex); - - return 0; -#else /* CONFIG_ST_HAL_ACCEL_CALIB_ENABLED */ - return HWSensorBaseWithPollrate::Enable(handle, enable, lock_en_mutex); -#endif /* CONFIG_ST_HAL_ACCEL_CALIB_ENABLED */ -} - -void CorrelatedColorTemp::ProcessData(SensorBaseData *data) -{ - float cyan; - float magenta; - float yellow; - float red; - float green; - float blue; - float X, Y, Z; /* CIE XYZ */ - float x, y, n; /* CIE xyY */ - float cct; -#if (CONFIG_ST_HAL_DEBUG_LEVEL >= ST_HAL_DEBUG_EXTRA_VERBOSE) - ALOGD("\"%s\": red=%f green=%f blue=%f white=%f, timestamp=%" PRIu64 "ns, deltatime=%" PRIu64, - sensor_t_data.name, data->raw[0], data->raw[1], data->raw[2], data->raw[3], - data->timestamp, data->timestamp - sensor_event.timestamp); -#endif /* CONFIG_ST_HAL_DEBUG_LEVEL */ - - /* Complementary Color Method */ - cyan = data->raw[3] - data->raw[0]; - magenta = data->raw[3] - data->raw[1]; - yellow = data->raw[3] - data->raw[2]; - - red = magenta + yellow; - green = cyan + yellow; - blue = cyan + magenta; - - /* Calculate CIE XYZ */ - X = red * X_A + green * X_B + blue * X_C; - Y = red * Y_A + green * Y_B + blue * Y_C; - Z = red * Z_A + green * Z_B + blue * Z_C; - -#ifdef CONFIG_ST_HAL_SW_LIGHT_ENABLED - /* NOTE: Pass the illumination in Lux to dependency */ - data->processed[0] = Y; -#endif /* CONFIG_ST_HAL_SW_LIGHT_ENABLED */ - - /* Calculate CIE xyY */ - x = X / (X + Y + Z); - y = Y / (X + Y + Z); - n = (x - 0.332) / (y - 0.1858); - - /* Calculate CCT */ - cct = -449 * pow(n, 3) + 3525 * pow(n, 2) - 6823.3 * n + 5520.33; - - /* - * The first value is Correlated Color Temperature in Kelvins (K). - * The rest of values are in lux and measure the R, G, B channel. - */ - sensor_event.data[0] = cct; - sensor_event.data[1] = data->raw[0]; - sensor_event.data[2] = data->raw[1]; - sensor_event.data[3] = data->raw[2]; - sensor_event.data[4] = data->raw[3]; - sensor_event.data[5] = data->orig[0]; - sensor_event.data[6] = data->orig[1]; - sensor_event.data[7] = data->orig[2]; - sensor_event.data[8] = data->orig[3]; - sensor_event.timestamp = data->timestamp; - - HWSensorBaseWithPollrate::WriteDataToPipe(data->pollrate_ns); - HWSensorBaseWithPollrate::ProcessData(data); -} diff --git a/hardware/rockchip/sensor/st_iio/src/CorrelatedColorTemp.h b/hardware/rockchip/sensor/st_iio/src/CorrelatedColorTemp.h deleted file mode 100644 index 7b67068356..0000000000 --- a/hardware/rockchip/sensor/st_iio/src/CorrelatedColorTemp.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2015-2016 STMicroelectronics - * Author: Denis Ciocca - - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ST_CCT_SENSOR_H -#define ST_CCT_SENSOR_H - -#include "HWSensorBase.h" - -/* Transformation Matrix */ -#define X_A (-0.121714589f) -#define X_B (6.266768206f) -#define X_C (-4.368804016f) - -#define Y_A (-2.360768324f) -#define Y_B (8.38127456f) -#define Y_C (-4.476796103f) - -#define Z_A (-5.097694084f) -#define Z_B (-1.42651259f) -#define Z_C (10.32534666f) - -/* - * class CorrelatedColorTemp - */ -class CorrelatedColorTemp : public HWSensorBaseWithPollrate { -private: -#if (CONFIG_ST_HAL_ANDROID_VERSION >= ST_HAL_PIE_VERSION) -#if (CONFIG_ST_HAL_ADDITIONAL_INFO_ENABLED) - int getSensorAdditionalInfoPayLoadFramesArray(additional_info_event_t **array_sensorAdditionalInfoPLFrames); -#endif /* CONFIG_ST_HAL_ADDITIONAL_INFO_ENABLED */ -#endif /* CONFIG_ST_HAL_ANDROID_VERSION */ -public: - CorrelatedColorTemp(HWSensorBaseCommonData *data, const char *name, - struct device_iio_sampling_freqs *sfa, int handle, - unsigned int hw_fifo_len, - float power_consumption, bool wakeup); - ~CorrelatedColorTemp(); - - virtual int Enable(int handle, bool enable, bool lock_en_mutex); - virtual void ProcessData(SensorBaseData *data); -}; - -#endif /* ST_CCT_SENSOR_H */ diff --git a/hardware/rockchip/sensor/st_iio/src/Proximity.cpp b/hardware/rockchip/sensor/st_iio/src/Proximity.cpp deleted file mode 100644 index 9b65d72fe5..0000000000 --- a/hardware/rockchip/sensor/st_iio/src/Proximity.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * STMicroelectronics Proximity Sensor Class - * - * Copyright 2015-2016 STMicroelectronics Inc. - * Author: Denis Ciocca - - * - * Licensed under the Apache License, Version 2.0 (the "License"). - */ - -#include -#include -#include - -#include "Proximity.h" - -#ifdef CONFIG_ST_HAL_ACCEL_CALIB_ENABLED -#define CALIBRATION_FREQUENCY 25 -#define CALIBRATION_PERIOD_MS (1000.0f / CALIBRATION_FREQUENCY) - -extern "C" { - #include "STAccCalibration_API.h" -} -#endif /* CONFIG_ST_HAL_ACCEL_CALIB_ENABLED */ - -Proximity::Proximity(HWSensorBaseCommonData *data, const char *name, - struct device_iio_sampling_freqs *sfa, int handle, - unsigned int hw_fifo_len, float power_consumption, bool wakeup) : - HWSensorBaseWithPollrate(data, name, sfa, handle, - SENSOR_TYPE_PROXIMITY, hw_fifo_len, power_consumption) -{ -#if (CONFIG_ST_HAL_ANDROID_VERSION > ST_HAL_KITKAT_VERSION) - sensor_t_data.stringType = SENSOR_STRING_TYPE_PROXIMITY; - sensor_t_data.flags |= SENSOR_FLAG_ON_CHANGE_MODE; - - (void)wakeup; - sensor_t_data.flags |= SENSOR_FLAG_WAKE_UP; -#else /* CONFIG_ST_HAL_ANDROID_VERSION */ - (void)wakeup; -#endif /* CONFIG_ST_HAL_ANDROID_VERSION */ - - sensor_t_data.resolution = 1.0f; - sensor_t_data.maxRange = 9.0f; - - info = 0; - if (!strcmp(name, "VL6180 Proximity Sensor")) - info |= ST_PROXIMITY_VL6180; - else if (!strcmp(name, "VL53L0X Proximity Sensor")) - info |= ST_PROXIMITY_VL53L0X; -} - -Proximity::~Proximity() -{ - -} - -int Proximity::Enable(int handle, bool enable, bool lock_en_mutex) -{ -#ifdef CONFIG_ST_HAL_ACCEL_CALIB_ENABLED - int err; - - if (lock_en_mutex) - pthread_mutex_lock(&enable_mutex); - - err = HWSensorBaseWithPollrate::Enable(handle, enable, false); - if (err < 0) { - if (lock_en_mutex) - pthread_mutex_unlock(&enable_mutex); - - return err; - } - - if (enable) - ST_AccCalibration_API_Init(CALIBRATION_PERIOD_MS); - else - ST_AccCalibration_API_DeInit(CALIBRATION_PERIOD_MS); - - if (lock_en_mutex) - pthread_mutex_unlock(&enable_mutex); - - return 0; -#else /* CONFIG_ST_HAL_ACCEL_CALIB_ENABLED */ - return HWSensorBaseWithPollrate::Enable(handle, enable, lock_en_mutex); -#endif /* CONFIG_ST_HAL_ACCEL_CALIB_ENABLED */ -} - -void Proximity::ProcessData(SensorBaseData *data) -{ -#if (CONFIG_ST_HAL_DEBUG_LEVEL >= ST_HAL_DEBUG_EXTRA_VERBOSE) - ALOGD("\"%s\": received new sensor data: x=%f y=%f z=%f, timestamp=%" PRIu64 "ns, deltatime=%" PRIu64 "ns (sensor type: %d).", - sensor_t_data.name, data->raw[0], data->raw[1], data->raw[2], - data->timestamp, data->timestamp - sensor_event.timestamp, sensor_t_data.type); -#endif /* CONFIG_ST_HAL_DEBUG_LEVEL */ - - /* driver reports meter, scale to cm */ - if (info & ST_PROXIMITY_VL6180) { - data->processed[0] = data->raw[1] * 100; - } else if (info & ST_PROXIMITY_VL53L0X) { - data->processed[0] = data->raw[0] * 100; - if (data->processed[0] > ST_PROXIMITY_VL53L0X_MAX_RANGE_CM) - data->processed[0] = ST_PROXIMITY_VL53L0X_MAX_RANGE_CM; - } else { - data->processed[0] = 0; - } - - sensor_event.distance = data->processed[0]; - sensor_event.timestamp = data->timestamp; - - HWSensorBaseWithPollrate::WriteDataToPipe(data->pollrate_ns); - HWSensorBaseWithPollrate::ProcessData(data); -} - - -#if (CONFIG_ST_HAL_ANDROID_VERSION >= ST_HAL_PIE_VERSION) -#if (CONFIG_ST_HAL_ADDITIONAL_INFO_ENABLED) -int Proximity::getSensorAdditionalInfoPayLoadFramesArray(additional_info_event_t **array_sensorAdditionalInfoPLFrames) -{ - additional_info_event_t* p_custom_SAI_Placement_event = nullptr; - - // place for ODM/OEM to fill custom_SAI_Placement_event - // p_custom_SAI_Placement_event = &custom_SAI_Placement_event - -/* //Custom Placement example - additional_info_event_t custom_SAI_Placement_event; - custom_SAI_Placement_event = { - .type = AINFO_SENSOR_PLACEMENT, - .serial = 0, - .data_float = {-1, 0, 0, 1, 0, -1, 0, 2, 0, 0, -1, 3}, - }; - p_custom_SAI_Placement_event = &custom_SAI_Placement_event; -*/ - - return UseCustomAINFOSensorPlacementPLFramesArray(array_sensorAdditionalInfoPLFrames, p_custom_SAI_Placement_event); - -} -#endif /* CONFIG_ST_HAL_ADDITIONAL_INFO_ENABLED */ -#endif /* CONFIG_ST_HAL_ANDROID_VERSION */ diff --git a/hardware/rockchip/sensor/st_iio/src/Proximity.h b/hardware/rockchip/sensor/st_iio/src/Proximity.h deleted file mode 100644 index 14f5afa03b..0000000000 --- a/hardware/rockchip/sensor/st_iio/src/Proximity.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2015-2016 STMicroelectronics - * Author: Denis Ciocca - - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ST_PROXIMITY_SENSOR_H -#define ST_PROXIMITY_SENSOR_H - -#include "HWSensorBase.h" - -/* - * Proximity informations, used for compatibility. - */ -#define ST_PROXIMITY_VL6180 0x01 -#define ST_PROXIMITY_VL53L0X 0x02 - -#define ST_PROXIMITY_VL53L0X_MAX_RANGE_CM 120 - -/* - * class Proximity - */ -class Proximity : public HWSensorBaseWithPollrate { -private: - uint8_t info; -#if (CONFIG_ST_HAL_ANDROID_VERSION >= ST_HAL_PIE_VERSION) -#if (CONFIG_ST_HAL_ADDITIONAL_INFO_ENABLED) - int getSensorAdditionalInfoPayLoadFramesArray(additional_info_event_t **array_sensorAdditionalInfoPLFrames); -#endif /* CONFIG_ST_HAL_ADDITIONAL_INFO_ENABLED */ -#endif /* CONFIG_ST_HAL_ANDROID_VERSION */ -public: - Proximity(HWSensorBaseCommonData *data, const char *name, - struct device_iio_sampling_freqs *sfa, int handle, - unsigned int hw_fifo_len, - float power_consumption, bool wakeup); - ~Proximity(); - - virtual int Enable(int handle, bool enable, bool lock_en_mutex); - virtual void ProcessData(SensorBaseData *data); -}; - -#endif /* ST_PROXIMITY_SENSOR_H */ diff --git a/hardware/rockchip/sensor/st_iio/src/SWLight.cpp b/hardware/rockchip/sensor/st_iio/src/SWLight.cpp deleted file mode 100644 index c78e0b4bc0..0000000000 --- a/hardware/rockchip/sensor/st_iio/src/SWLight.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Virtual Light Sensor Class - * - * Copyright (C) 2022 Rockchip Electronics Co., Ltd. - * Author: Jason Zhang - - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define __STDC_LIMIT_MACROS -#define __STDINT_LIMITS - -#include -#include -#include -#include - -#include "SWLight.h" - -SWLight::SWLight(const char *name, int handle) : - SWSensorBaseWithPollrate(name, handle, SENSOR_TYPE_LIGHT, - false, false, true, false) -{ -#if (CONFIG_ST_HAL_ANDROID_VERSION > ST_HAL_KITKAT_VERSION) - sensor_t_data.flags |= SENSOR_FLAG_CONTINUOUS_MODE; - sensor_t_data.maxDelay = FREQUENCY_TO_US(FLT_MAX); -#endif /* CONFIG_ST_HAL_ANDROID_VERSION */ - - sensor_t_data.resolution = ST_SENSOR_FUSION_RESOLUTION(1.0f); - sensor_t_data.maxRange = 1.0f; - - dependencies_type_list[SENSOR_DEPENDENCY_ID_0] = SENSOR_TYPE_CCT; - id_sensor_trigger = SENSOR_DEPENDENCY_ID_0; - -#if (CONFIG_ST_HAL_ANDROID_VERSION >= ST_HAL_PIE_VERSION) -#if (CONFIG_ST_HAL_ADDITIONAL_INFO_ENABLED) - supportsSensorAdditionalInfo = true; - sensor_t_data.flags |= SENSOR_FLAG_ADDITIONAL_INFO; -#endif /* CONFIG_ST_HAL_ADDITIONAL_INFO_ENABLED */ -#endif /* CONFIG_ST_HAL_ANDROID_VERSION */ -} - -SWLight::~SWLight() -{ - -} - -int SWLight::Enable(int handle, bool enable, bool lock_en_mutex) -{ - int err; - bool old_status; - bool old_status_no_handle; - - if (lock_en_mutex) - pthread_mutex_lock(&enable_mutex); - - old_status = GetStatus(false); - old_status_no_handle = GetStatusExcludeHandle(handle); - - err = SWSensorBaseWithPollrate::Enable(handle, enable, false); - if (err < 0) { - if (lock_en_mutex) - pthread_mutex_unlock(&enable_mutex); - - return err; - } - - if ((enable && !old_status) || (!enable && !old_status_no_handle)) { - if (enable) - sensor_global_enable = android::elapsedRealtimeNano(); - else - sensor_global_disable = android::elapsedRealtimeNano(); - } - - if (lock_en_mutex) - pthread_mutex_unlock(&enable_mutex); - - return 0; -} - -int SWLight::SetDelay(int handle, int64_t period_ns, int64_t timeout, bool lock_en_mutex) -{ - int err; - - if ((period_ns > FREQUENCY_TO_NS(FLT_MAX)) && (period_ns != INT64_MAX)) - period_ns = FREQUENCY_TO_NS(FLT_MAX); - - if (lock_en_mutex) - pthread_mutex_lock(&enable_mutex); - - err = SWSensorBaseWithPollrate::SetDelay(handle, period_ns, timeout, false); - if (err < 0){ - if (lock_en_mutex) - pthread_mutex_unlock(&enable_mutex); - - return err; - } - - if (lock_en_mutex) - pthread_mutex_unlock(&enable_mutex); - - return 0; -} - -void SWLight::ProcessData(SensorBaseData *data) -{ -#if (CONFIG_ST_HAL_DEBUG_LEVEL >= ST_HAL_DEBUG_EXTRA_VERBOSE) - ALOGD("\"%s\": received new sensor data from trigger: x=%f y=%f z=%f, timestamp=%" PRIu64 "ns, deltatime=%" PRIu64 "ns (sensor type: %d).", - sensor_t_data.name, data->raw[0], data->raw[1], data->raw[2], - data->timestamp, data->timestamp - sensor_event.timestamp, sensor_t_data.type); -#endif /* CONFIG_ST_HAL_DEBUG_LEVEL */ - - sensor_event.light = data->processed[0]; - sensor_event.timestamp = data->timestamp; - SWSensorBaseWithPollrate::WriteDataToPipe(data->pollrate_ns); -} diff --git a/hardware/rockchip/sensor/st_iio/src/SWLight.h b/hardware/rockchip/sensor/st_iio/src/SWLight.h deleted file mode 100644 index 3c10dc67e1..0000000000 --- a/hardware/rockchip/sensor/st_iio/src/SWLight.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Virtual Light Sensor Class - * - * Copyright (C) 2022 Rockchip Electronics Co., Ltd. - * Author: Jason Zhang - - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ST_SW_LIGHT_H -#define ST_SW_LIGHT_H - -#include "SWSensorBase.h" - -class SWLight : public SWSensorBaseWithPollrate { -protected: - SensorBaseData outdata; - -public: - SWLight(const char *name, int handle); - ~SWLight(); - - // virtual int CustomInit(); - virtual int Enable(int handle, bool enable, bool lock_en_mutex); - virtual int SetDelay(int handle, int64_t period_ns, int64_t timeout, bool lock_en_mutex); - virtual void ProcessData(SensorBaseData *data); -}; - -#endif /* ST_SW_LIGHT_H */