Drop HIDL IR HAL
Change-Id: Ic0805a38470afae5506602ac6ccdafb58d1c7cb9
This commit is contained in:
parent
a271b57c99
commit
5a47da0c4f
6 changed files with 0 additions and 244 deletions
|
@ -1,31 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright (C) 2017-2018,2020 The LineageOS Project
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
cc_binary {
|
|
||||||
name: "android.hardware.ir@1.0-service.xiaomi",
|
|
||||||
relative_install_path: "hw",
|
|
||||||
defaults: ["hidl_defaults"],
|
|
||||||
init_rc: ["android.hardware.ir@1.0-service.xiaomi.rc"],
|
|
||||||
vintf_fragments: ["android.hardware.ir@1.0-service.xiaomi.xml"],
|
|
||||||
srcs: ["service.cpp", "ConsumerIr.cpp"],
|
|
||||||
shared_libs: [
|
|
||||||
"android.hardware.ir@1.0",
|
|
||||||
"libbase",
|
|
||||||
"libhardware",
|
|
||||||
"libhidlbase",
|
|
||||||
"libutils",
|
|
||||||
],
|
|
||||||
proprietary: true,
|
|
||||||
}
|
|
|
@ -1,102 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017-2018 The LineageOS Project
|
|
||||||
*
|
|
||||||
* 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 LOG_TAG "ConsumerIrService"
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <linux/lirc.h>
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
|
|
||||||
#include "ConsumerIr.h"
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
namespace hardware {
|
|
||||||
namespace ir {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
#define LIRC_DEV_PATH "/dev/lirc0"
|
|
||||||
|
|
||||||
static const int dutyCycle = 33;
|
|
||||||
|
|
||||||
static hidl_vec<ConsumerIrFreqRange> rangeVec{
|
|
||||||
{.min = 30000, .max = 60000},
|
|
||||||
};
|
|
||||||
|
|
||||||
static int openLircDev() {
|
|
||||||
int fd = open(LIRC_DEV_PATH, O_RDWR);
|
|
||||||
|
|
||||||
if (fd < 0) {
|
|
||||||
LOG(ERROR) << "failed to open " << LIRC_DEV_PATH << ", error " << fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methods from ::android::hardware::ir::V1_0::IConsumerIr follow.
|
|
||||||
Return<bool> ConsumerIr::transmit(int32_t carrierFreq, const hidl_vec<int32_t>& pattern) {
|
|
||||||
size_t entries = pattern.size();
|
|
||||||
int rc;
|
|
||||||
int lircFd;
|
|
||||||
|
|
||||||
lircFd = openLircDev();
|
|
||||||
if (lircFd < 0) {
|
|
||||||
return lircFd;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ioctl(lircFd, LIRC_SET_SEND_CARRIER, &carrierFreq);
|
|
||||||
if (rc < 0) {
|
|
||||||
LOG(ERROR) << "failed to set carrier " << carrierFreq << ", error: " << errno;
|
|
||||||
goto out_close;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = ioctl(lircFd, LIRC_SET_SEND_DUTY_CYCLE, &dutyCycle);
|
|
||||||
if (rc < 0) {
|
|
||||||
LOG(ERROR) << "failed to set duty cycle " << dutyCycle << ", error: " << errno;
|
|
||||||
goto out_close;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((entries & 1) != 0) {
|
|
||||||
rc = write(lircFd, pattern.data(), sizeof(int32_t) * entries);
|
|
||||||
} else {
|
|
||||||
rc = write(lircFd, pattern.data(), sizeof(int32_t) * (entries - 1));
|
|
||||||
usleep(pattern[entries - 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc < 0) {
|
|
||||||
LOG(ERROR) << "failed to write pattern " << pattern.size() << ", error: " << errno;
|
|
||||||
goto out_close;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = 0;
|
|
||||||
|
|
||||||
out_close:
|
|
||||||
close(lircFd);
|
|
||||||
|
|
||||||
return rc == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Return<void> ConsumerIr::getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) {
|
|
||||||
_hidl_cb(true, rangeVec);
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace ir
|
|
||||||
} // namespace hardware
|
|
||||||
} // namespace android
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017-2018 The LineageOS Project
|
|
||||||
*
|
|
||||||
* 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 ANDROID_HARDWARE_IR_V1_0_IR_H
|
|
||||||
#define ANDROID_HARDWARE_IR_V1_0_IR_H
|
|
||||||
|
|
||||||
#include <android/hardware/ir/1.0/IConsumerIr.h>
|
|
||||||
#include <hardware/consumerir.h>
|
|
||||||
#include <hidl/Status.h>
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
namespace hardware {
|
|
||||||
namespace ir {
|
|
||||||
namespace V1_0 {
|
|
||||||
namespace implementation {
|
|
||||||
|
|
||||||
using ::android::hardware::Return;
|
|
||||||
using ::android::hardware::Void;
|
|
||||||
using ::android::hardware::hidl_vec;
|
|
||||||
using ::android::hardware::ir::V1_0::ConsumerIrFreqRange;
|
|
||||||
using ::android::hardware::ir::V1_0::IConsumerIr;
|
|
||||||
|
|
||||||
class ConsumerIr : public IConsumerIr {
|
|
||||||
// Methods from ::android::hardware::ir::V1_0::IConsumerIr follow.
|
|
||||||
Return<bool> transmit(int32_t carrierFreq, const hidl_vec<int32_t>& pattern) override;
|
|
||||||
Return<void> getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace implementation
|
|
||||||
} // namespace V1_0
|
|
||||||
} // namespace ir
|
|
||||||
} // namespace hardware
|
|
||||||
} // namespace android
|
|
||||||
|
|
||||||
#endif // ANDROID_HARDWARE_IR_V1_0_IR_H
|
|
|
@ -1,4 +0,0 @@
|
||||||
service ir-hal-1-0 /vendor/bin/hw/android.hardware.ir@1.0-service.xiaomi
|
|
||||||
class hal
|
|
||||||
user system
|
|
||||||
group system
|
|
|
@ -1,11 +0,0 @@
|
||||||
<manifest version="1.0" type="device">
|
|
||||||
<hal format="hidl">
|
|
||||||
<name>android.hardware.ir</name>
|
|
||||||
<transport>hwbinder</transport>
|
|
||||||
<version>1.0</version>
|
|
||||||
<interface>
|
|
||||||
<name>IConsumerIr</name>
|
|
||||||
<instance>default</instance>
|
|
||||||
</interface>
|
|
||||||
</hal>
|
|
||||||
</manifest>
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2017-2018 The LineageOS Project
|
|
||||||
*
|
|
||||||
* 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 LOG_TAG "android.hardware.ir@1.0-service.xiaomi"
|
|
||||||
|
|
||||||
#include <android-base/logging.h>
|
|
||||||
#include <hidl/HidlTransportSupport.h>
|
|
||||||
|
|
||||||
#include "ConsumerIr.h"
|
|
||||||
|
|
||||||
// libhwbinder:
|
|
||||||
using android::hardware::configureRpcThreadpool;
|
|
||||||
using android::hardware::joinRpcThreadpool;
|
|
||||||
|
|
||||||
// Generated HIDL files
|
|
||||||
using android::hardware::ir::V1_0::IConsumerIr;
|
|
||||||
using android::hardware::ir::V1_0::implementation::ConsumerIr;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
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 HAL service";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(INFO) << "ConsumerIr HAL Ready.";
|
|
||||||
joinRpcThreadpool();
|
|
||||||
// Under normal cases, execution will not reach this line.
|
|
||||||
LOG(ERROR) << "ConsumerIr HAL failed to join thread pool.";
|
|
||||||
return 1;
|
|
||||||
}
|
|
Loading…
Reference in a new issue