From 0cd4e50d6f5bce1ea252fecffa0249b550a6630f Mon Sep 17 00:00:00 2001 From: Sebastiano Barezzi Date: Mon, 13 Sep 2021 01:16:43 +0200 Subject: sdm660-common: ir: Binderize Change-Id: Ib704750a56eec2e26440bdfee92976776db58812 --- ir/ConsumerIr.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'ir/ConsumerIr.cpp') 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 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 -- cgit v1.2.3