sm8750-common: sensors: add a wrapper for sensors.qsh.so
Change-Id: I2c2f482b7c6b3f7baad1ae2d42e9c5bba1647269
This commit is contained in:
committed by
Bruno Martins
parent
b6f38d5575
commit
4e7078ac03
1
.clang-format
Symbolic link
1
.clang-format
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../build/soong/scripts/system-clang-format
|
||||
@@ -310,7 +310,8 @@ PRODUCT_PACKAGES += \
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.sensors-service.multihal \
|
||||
sensors.dynamic_sensor_hal \
|
||||
sensors.oplus
|
||||
sensors.oplus \
|
||||
sensors.qsh_wrapper
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(LOCAL_PATH)/configs/hals.conf:$(TARGET_COPY_OUT_VENDOR)/etc/sensors/hals.conf
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
sensors.dynamic_sensor_hal.so
|
||||
sensors.oplus.so
|
||||
sensors.qsh.so
|
||||
sensors.qsh_wrapper.so
|
||||
|
||||
27
sensors/Android.bp
Normal file
27
sensors/Android.bp
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Copyright (C) 2025 The LineageOS Project
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
cc_library_shared {
|
||||
name: "sensors.qsh_wrapper",
|
||||
defaults: ["hidl_defaults"],
|
||||
srcs: [
|
||||
"SensorsSubHal.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"android.hardware.sensors@2.0",
|
||||
"android.hardware.sensors@2.1",
|
||||
"libbase",
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
],
|
||||
header_libs: [
|
||||
"android.hardware.sensors@2.X-multihal.header",
|
||||
],
|
||||
cflags: [
|
||||
"-DLOG_TAG=\"sensors.qsh_wrapper\"",
|
||||
],
|
||||
vendor: true,
|
||||
}
|
||||
104
sensors/SensorsSubHal.cpp
Normal file
104
sensors/SensorsSubHal.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "SensorsSubHal.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
using ::android::hardware::sensors::V2_1::implementation::ISensorsSubHal;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace sensors {
|
||||
namespace V2_1 {
|
||||
namespace subhal {
|
||||
namespace implementation {
|
||||
namespace qsh_wrapper {
|
||||
|
||||
namespace {
|
||||
constexpr auto kLibName = "sensors.qsh.so";
|
||||
}; // anonymous namespace
|
||||
|
||||
SensorsSubHal::SensorsSubHal()
|
||||
: lib_handle_(dlopen(kLibName, RTLD_NOW), [](void* p) {
|
||||
if (p) dlclose(p);
|
||||
}) {
|
||||
if (!lib_handle_) {
|
||||
LOG(FATAL) << __func__ << ": dlopen " << kLibName << " failed, exiting";
|
||||
}
|
||||
|
||||
auto get_sub_hal = reinterpret_cast<ISensorsSubHal* (*)(uint32_t*)>(
|
||||
dlsym(lib_handle_.get(), "sensorsHalGetSubHal_2_1"));
|
||||
uint32_t version;
|
||||
impl_ = get_sub_hal(&version);
|
||||
}
|
||||
|
||||
Return<Result> SensorsSubHal::setOperationMode(OperationMode mode) {
|
||||
return impl_->setOperationMode(mode);
|
||||
}
|
||||
|
||||
Return<Result> SensorsSubHal::activate(int32_t sensor_handle, bool enabled) {
|
||||
return impl_->activate(sensor_handle, enabled);
|
||||
}
|
||||
|
||||
Return<Result> SensorsSubHal::batch(int32_t sensor_handle, int64_t sampling_period_ns,
|
||||
int64_t max_report_latency_ns) {
|
||||
return impl_->batch(sensor_handle, sampling_period_ns, max_report_latency_ns);
|
||||
}
|
||||
|
||||
Return<Result> SensorsSubHal::flush(int32_t sensor_handle) {
|
||||
return impl_->flush(sensor_handle);
|
||||
}
|
||||
|
||||
Return<void> SensorsSubHal::registerDirectChannel(const SharedMemInfo& mem,
|
||||
ISensors::registerDirectChannel_cb _hidl_cb) {
|
||||
return impl_->registerDirectChannel(mem, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<Result> SensorsSubHal::unregisterDirectChannel(int32_t channel_handle) {
|
||||
return impl_->unregisterDirectChannel(channel_handle);
|
||||
}
|
||||
|
||||
Return<void> SensorsSubHal::configDirectReport(int32_t sensor_handle, int32_t channel_handle,
|
||||
RateLevel rate,
|
||||
ISensors::configDirectReport_cb _hidl_cb) {
|
||||
return impl_->configDirectReport(sensor_handle, channel_handle, rate, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> SensorsSubHal::getSensorsList_2_1(ISensors::getSensorsList_2_1_cb _hidl_cb) {
|
||||
return impl_->getSensorsList_2_1(_hidl_cb);
|
||||
}
|
||||
|
||||
Return<Result> SensorsSubHal::injectSensorData_2_1(const Event& event) {
|
||||
return impl_->injectSensorData_2_1(event);
|
||||
}
|
||||
|
||||
Return<void> SensorsSubHal::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) {
|
||||
return impl_->debug(fd, args);
|
||||
}
|
||||
|
||||
const std::string SensorsSubHal::getName() {
|
||||
return impl_->getName();
|
||||
}
|
||||
|
||||
Return<Result> SensorsSubHal::initialize(const sp<IHalProxyCallback>& hal_proxy_callback) {
|
||||
return impl_->initialize(hal_proxy_callback);
|
||||
}
|
||||
|
||||
} // namespace qsh_wrapper
|
||||
} // namespace implementation
|
||||
} // namespace subhal
|
||||
} // namespace V2_1
|
||||
} // namespace sensors
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
ISensorsSubHal* sensorsHalGetSubHal_2_1(uint32_t* version) {
|
||||
static ::android::hardware::sensors::V2_1::subhal::implementation::qsh_wrapper::SensorsSubHal
|
||||
sub_hal;
|
||||
*version = SUB_HAL_2_1_VERSION;
|
||||
return &sub_hal;
|
||||
}
|
||||
60
sensors/SensorsSubHal.h
Normal file
60
sensors/SensorsSubHal.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <V2_1/SubHal.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace sensors {
|
||||
namespace V2_1 {
|
||||
namespace subhal {
|
||||
namespace implementation {
|
||||
namespace qsh_wrapper {
|
||||
|
||||
using ::android::hardware::sensors::V1_0::OperationMode;
|
||||
using ::android::hardware::sensors::V1_0::RateLevel;
|
||||
using ::android::hardware::sensors::V1_0::Result;
|
||||
using ::android::hardware::sensors::V1_0::SharedMemInfo;
|
||||
using ::android::hardware::sensors::V2_1::Event;
|
||||
using ::android::hardware::sensors::V2_1::implementation::IHalProxyCallback;
|
||||
using ::android::hardware::sensors::V2_1::implementation::ISensorsSubHal;
|
||||
|
||||
class SensorsSubHal : public ISensorsSubHal {
|
||||
public:
|
||||
SensorsSubHal();
|
||||
|
||||
// ISensors
|
||||
Return<Result> setOperationMode(OperationMode mode) override;
|
||||
Return<Result> activate(int32_t sensor_handle, bool enabled) override;
|
||||
Return<Result> batch(int32_t sensor_handle, int64_t sampling_period_ns,
|
||||
int64_t max_report_latency_ns) override;
|
||||
Return<Result> flush(int32_t sensor_handle) override;
|
||||
Return<void> registerDirectChannel(const SharedMemInfo& mem,
|
||||
ISensors::registerDirectChannel_cb _hidl_cb) override;
|
||||
Return<Result> unregisterDirectChannel(int32_t channel_handle) override;
|
||||
Return<void> configDirectReport(int32_t sensor_handle, int32_t channel_handle, RateLevel rate,
|
||||
ISensors::configDirectReport_cb _hidl_cb) override;
|
||||
Return<void> getSensorsList_2_1(ISensors::getSensorsList_2_1_cb _hidl_cb) override;
|
||||
Return<Result> injectSensorData_2_1(const Event& event) override;
|
||||
|
||||
// ISensorsSubHal
|
||||
Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override;
|
||||
const std::string getName() override;
|
||||
Return<Result> initialize(const sp<IHalProxyCallback>& hal_proxy_callback) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<void, std::function<void(void*)>> lib_handle_;
|
||||
V2_1::implementation::ISensorsSubHal* impl_;
|
||||
};
|
||||
|
||||
} // namespace qsh_wrapper
|
||||
} // namespace implementation
|
||||
} // namespace subhal
|
||||
} // namespace V2_1
|
||||
} // namespace sensors
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
Reference in New Issue
Block a user