sdm660-common: ir: Binderize
Change-Id: Ib704750a56eec2e26440bdfee92976776db58812 Signed-off-by: clarencelol <clarencekuiek@icloud.com> Signed-off-by: OdSazib <odsazib@gmail.com>
This commit is contained in:
parent
d6907ddb9f
commit
7111774653
4 changed files with 45 additions and 43 deletions
|
@ -4,28 +4,17 @@
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
|
|
||||||
cc_library_shared {
|
|
||||||
name: "android.hardware.ir@1.0-impl",
|
|
||||||
defaults: ["hidl_defaults"],
|
|
||||||
relative_install_path: "hw",
|
|
||||||
srcs: ["ConsumerIr.cpp"],
|
|
||||||
shared_libs: [
|
|
||||||
"libhidlbase",
|
|
||||||
"libhardware",
|
|
||||||
"libbase",
|
|
||||||
"libutils",
|
|
||||||
"android.hardware.ir@1.0",
|
|
||||||
],
|
|
||||||
vendor: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_binary {
|
cc_binary {
|
||||||
name: "android.hardware.ir@1.0-service",
|
name: "android.hardware.ir@1.0-service",
|
||||||
defaults: ["hidl_defaults"],
|
defaults: ["hidl_defaults"],
|
||||||
relative_install_path: "hw",
|
relative_install_path: "hw",
|
||||||
init_rc: ["android.hardware.ir@1.0-service.rc"],
|
init_rc: ["android.hardware.ir@1.0-service.rc"],
|
||||||
srcs: ["service.cpp"],
|
srcs: [
|
||||||
|
"ConsumerIr.cpp",
|
||||||
|
"service.cpp",
|
||||||
|
],
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
|
"libbase",
|
||||||
"libhardware",
|
"libhardware",
|
||||||
"libhidlbase",
|
"libhidlbase",
|
||||||
"libutils",
|
"libutils",
|
||||||
|
|
|
@ -19,8 +19,25 @@ namespace ir {
|
||||||
namespace V1_0 {
|
namespace V1_0 {
|
||||||
namespace implementation {
|
namespace implementation {
|
||||||
|
|
||||||
ConsumerIr::ConsumerIr(consumerir_device_t *device) {
|
ConsumerIr::ConsumerIr() : mDevice(nullptr) {
|
||||||
mDevice = device;
|
const hw_module_t *hw_module = NULL;
|
||||||
|
|
||||||
|
int ret = hw_get_module(CONSUMERIR_HARDWARE_MODULE_ID, &hw_module);
|
||||||
|
if (ret != 0) {
|
||||||
|
LOG(FATAL) << "hw_get_module " CONSUMERIR_HARDWARE_MODULE_ID " failed: " << ret;
|
||||||
|
}
|
||||||
|
ret = hw_module->methods->open(hw_module, CONSUMERIR_TRANSMITTER, (hw_device_t **) &mDevice);
|
||||||
|
if (ret < 0) {
|
||||||
|
LOG(FATAL) << "Can't open consumer IR transmitter, error: " << ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsumerIr::~ConsumerIr() {
|
||||||
|
if (mDevice == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mDevice->common.close((hw_device_t *) mDevice);
|
||||||
|
mDevice = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods from ::android::hardware::consumerir::V1_0::IConsumerIr follow.
|
// Methods from ::android::hardware::consumerir::V1_0::IConsumerIr follow.
|
||||||
|
@ -52,24 +69,6 @@ Return<void> ConsumerIr::getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) {
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IConsumerIr* HIDL_FETCH_IConsumerIr(const char * /*name*/) {
|
|
||||||
consumerir_device_t *dev;
|
|
||||||
const hw_module_t *hw_module = NULL;
|
|
||||||
|
|
||||||
int ret = hw_get_module(CONSUMERIR_HARDWARE_MODULE_ID, &hw_module);
|
|
||||||
if (ret != 0) {
|
|
||||||
LOG(ERROR) << "hw_get_module " CONSUMERIR_HARDWARE_MODULE_ID " failed: " << ret;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
ret = hw_module->methods->open(hw_module, CONSUMERIR_TRANSMITTER, (hw_device_t **) &dev);
|
|
||||||
if (ret < 0) {
|
|
||||||
LOG(ERROR) << "Can't open consumer IR transmitter, error: " << ret;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return new ConsumerIr(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace V1_0
|
} // namespace V1_0
|
||||||
} // namespace ir
|
} // namespace ir
|
||||||
|
|
|
@ -28,7 +28,8 @@ using ::android::hardware::Void;
|
||||||
using ::android::sp;
|
using ::android::sp;
|
||||||
|
|
||||||
struct ConsumerIr : public IConsumerIr {
|
struct ConsumerIr : public IConsumerIr {
|
||||||
ConsumerIr(consumerir_device_t *device);
|
ConsumerIr();
|
||||||
|
~ConsumerIr();
|
||||||
// Methods from ::android::hardware::ir::V1_0::IConsumerIr follow.
|
// Methods from ::android::hardware::ir::V1_0::IConsumerIr follow.
|
||||||
Return<bool> transmit(int32_t carrierFreq, const hidl_vec<int32_t>& pattern) override;
|
Return<bool> transmit(int32_t carrierFreq, const hidl_vec<int32_t>& pattern) override;
|
||||||
Return<void> getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) override;
|
Return<void> getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) override;
|
||||||
|
@ -36,8 +37,6 @@ private:
|
||||||
consumerir_device_t *mDevice;
|
consumerir_device_t *mDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" IConsumerIr* HIDL_FETCH_IConsumerIr(const char* name);
|
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
} // namespace V1_0
|
} // namespace V1_0
|
||||||
} // namespace ir
|
} // namespace ir
|
||||||
|
|
|
@ -6,12 +6,27 @@
|
||||||
|
|
||||||
#define LOG_TAG "android.hardware.ir@1.0-service"
|
#define LOG_TAG "android.hardware.ir@1.0-service"
|
||||||
|
|
||||||
#include <android/hardware/ir/1.0/IConsumerIr.h>
|
#include <android-base/logging.h>
|
||||||
#include <hidl/LegacySupport.h>
|
#include <hidl/HidlTransportSupport.h>
|
||||||
|
#include "ConsumerIr.h"
|
||||||
|
|
||||||
using android::hardware::ir::V1_0::IConsumerIr;
|
using android::hardware::ir::V1_0::IConsumerIr;
|
||||||
using android::hardware::defaultPassthroughServiceImplementation;
|
using android::hardware::ir::V1_0::implementation::ConsumerIr;
|
||||||
|
using android::hardware::configureRpcThreadpool;
|
||||||
|
using android::hardware::joinRpcThreadpool;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
return defaultPassthroughServiceImplementation<IConsumerIr>();
|
android::sp<IConsumerIr> service = new ConsumerIr();
|
||||||
|
|
||||||
|
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||||
|
|
||||||
|
android::status_t status = service->registerAsService();
|
||||||
|
if (status != android::OK) {
|
||||||
|
LOG(ERROR) << "Cannot register ConsumerIr service";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
joinRpcThreadpool();
|
||||||
|
|
||||||
|
return 1; // should never get here
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue