summaryrefslogtreecommitdiff
path: root/ir/ConsumerIr.cpp
diff options
context:
space:
mode:
authorSebastiano Barezzi <barezzisebastiano@gmail.com>2021-09-13 01:16:43 +0200
committerSebastiano Barezzi <barezzisebastiano@gmail.com>2021-09-20 14:19:36 +0200
commit0cd4e50d6f5bce1ea252fecffa0249b550a6630f (patch)
tree2e17aee6cdd6dc4c8117eec62d91c20628fccfc6 /ir/ConsumerIr.cpp
parentec4147512ce8d3519e8b345370f4425ca7158d35 (diff)
sdm660-common: ir: Binderize
Change-Id: Ib704750a56eec2e26440bdfee92976776db58812
Diffstat (limited to 'ir/ConsumerIr.cpp')
-rw-r--r--ir/ConsumerIr.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/ir/ConsumerIr.cpp b/ir/ConsumerIr.cpp
index 3e7ea35..14aa26a 100644
--- a/ir/ConsumerIr.cpp
+++ b/ir/ConsumerIr.cpp
@@ -19,8 +19,25 @@ namespace ir {
namespace V1_0 {
namespace implementation {
-ConsumerIr::ConsumerIr(consumerir_device_t *device) {
- mDevice = device;
+ConsumerIr::ConsumerIr() : mDevice(nullptr) {
+ 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.
@@ -52,24 +69,6 @@ Return<void> ConsumerIr::getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) {
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 V1_0
} // namespace ir