hidl: Add stub mtkpower service

* This keeps Camera HAL happy without MediaTek's
  PowerHAL.

Signed-off-by: bengris32 <bengris32@protonmail.ch>
Change-Id: I4d955b4da6ab4dfc3a3e9ca4522219a17039cd52
This commit is contained in:
bengris32
2022-05-27 23:05:45 +01:00
committed by Matsvei Niaverau
parent 5ec6df8a4e
commit 075e79bb19
9 changed files with 389 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
cc_binary {
name: "vendor.mediatek.hardware.mtkpower@1.2-service.stub",
defaults: ["hidl_defaults"],
init_rc: ["vendor.mediatek.hardware.mtkpower@1.2-service.stub.rc"],
vendor: true,
relative_install_path: "hw",
srcs: [
"MtkPerf.cpp",
"MtkPower.cpp",
"MtkPowerCallback.cpp",
"service.cpp",
],
shared_libs: [
"libbase",
"libhidlbase",
"libutils",
"vendor.mediatek.hardware.mtkpower@1.0",
"vendor.mediatek.hardware.mtkpower@1.1",
"vendor.mediatek.hardware.mtkpower@1.2",
],
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.1 (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.1
*
* 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 "vendor.mediatek.hardware.mtkpower@1.2-service.stub"
#include <android-base/logging.h>
#include "MtkPerf.h"
namespace vendor::mediatek::hardware::mtkpower::implementation {
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_0::IMtkPerf follow.
Return<int32_t> MtkPerf::perfLockAcquire(int32_t pl_handle, uint32_t duration, const hidl_vec<int32_t>& /* boostsList */, int32_t reserved) {
LOG(INFO) << "perfLockAcquire pl_handle: " << pl_handle
<< " duration: " << duration << " reserved: "
<< reserved;
return pl_handle;
}
Return<void> MtkPerf::perfLockRelease(int32_t pl_handle, int32_t reserved) {
LOG(INFO) << "perfLockRelease pl_handle: " << pl_handle
<< " reserved: " << reserved;
return Void();
}
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPerf follow.
Return<int32_t> MtkPerf::perfCusLockHint(int32_t hint, uint32_t duration) {
LOG(INFO) << "perfCusLockHint hint: " << hint
<< " duraton: " << duration;
return 233;
}
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPerf follow.
Return<int32_t> MtkPerf::perfLockReleaseSync(int32_t pl_handle, int32_t reserved) {
LOG(INFO) << "perfLockReleaseSync pl_handle: " << pl_handle
<< " reserved: " << reserved;
return 0;
}
} // namespace vendor::mediatek::hardware::mtkpower::implementation

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.1 (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.1
*
* 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.
*/
#pragma once
#include <vendor/mediatek/hardware/mtkpower/1.2/IMtkPerf.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace vendor::mediatek::hardware::mtkpower::implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
struct MtkPerf : public V1_2::IMtkPerf {
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_0::IMtkPerf follow.
Return<int32_t> perfLockAcquire(int32_t pl_handle, uint32_t duration, const hidl_vec<int32_t>& boostsList, int32_t reserved) override;
Return<void> perfLockRelease(int32_t pl_handle, int32_t reserved) override;
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPerf follow.
Return<int32_t> perfCusLockHint(int32_t hint, uint32_t duration) override;
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPerf follow.
Return<int32_t> perfLockReleaseSync(int32_t pl_handle, int32_t reserved) override;
};
} // namespace vendor::mediatek::hardware::mtkpower::implementation

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.1 (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.1
*
* 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 "vendor.mediatek.hardware.mtkpower@1.2-service.stub"
#include <android-base/logging.h>
#include "MtkPower.h"
namespace vendor::mediatek::hardware::mtkpower::implementation {
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_0::IMtkPower follow.
Return<void> MtkPower::mtkCusPowerHint(int32_t hint, int32_t data) {
LOG(INFO) << "mtkCusPowerHint hint: " << hint
<< " data: " << data;
return Void();
}
Return<void> MtkPower::mtkPowerHint(int32_t hint, int32_t data) {
LOG(INFO) << "mtkPowerHint hint: " << hint
<< " data: " << data;
return Void();
}
Return<void> MtkPower::notifyAppState(const hidl_string& pack, const hidl_string& act, int32_t pid, int32_t state, int32_t uid) {
LOG(INFO) << "notifyAppState pack: " << pack
<< " act: " << act << " pid: " << pid
<< " state: " << state << " uid: " << uid;
return Void();
}
Return<int32_t> MtkPower::querySysInfo(int32_t cmd, int32_t param) {
LOG(INFO) << "querySysInfo cmd: " << cmd
<< " param: " << param;
return 0;
}
Return<int32_t> MtkPower::setSysInfo(int32_t type, const hidl_string& data) {
LOG(INFO) << "setSysInfo type: " << type
<< " data: " << data;
return 0;
}
Return<int32_t> MtkPower::setSysInfoAsync(int32_t type, const hidl_string& data) {
LOG(INFO) << "setSysInfoAsync type: " << type
<< " data: " << data;
return 0;
}
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPower follow.
Return<int32_t> MtkPower::setMtkPowerCallback(const sp<::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPowerCallback>& /* callback */) {
LOG(WARNING) << "setMtkPowerCallback";
return 0;
}
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPower follow.
Return<int32_t> MtkPower::setMtkScnUpdateCallback(int32_t /* hint */, const sp<::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPowerCallback>& /* callback */) {
LOG(WARNING) << "setMtkScnUpdateCallback";
return 0;
}
} // namespace vendor::mediatek::hardware::mtkpower::implementation

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.1 (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.1
*
* 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.
*/
#pragma once
#include <vendor/mediatek/hardware/mtkpower/1.2/IMtkPower.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace vendor::mediatek::hardware::mtkpower::implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
struct MtkPower : public V1_2::IMtkPower {
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_0::IMtkPower follow.
Return<void> mtkCusPowerHint(int32_t hint, int32_t data) override;
Return<void> mtkPowerHint(int32_t hint, int32_t data) override;
Return<void> notifyAppState(const hidl_string& pack, const hidl_string& act, int32_t pid, int32_t state, int32_t uid) override;
Return<int32_t> querySysInfo(int32_t cmd, int32_t param) override;
Return<int32_t> setSysInfo(int32_t type, const hidl_string& data) override;
Return<int32_t> setSysInfoAsync(int32_t type, const hidl_string& data) override;
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPower follow.
Return<int32_t> setMtkPowerCallback(const sp<::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPowerCallback>& callback) override;
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPower follow.
Return<int32_t> setMtkScnUpdateCallback(int32_t hint, const sp<::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPowerCallback>& callback) override;
};
} // namespace vendor::mediatek::hardware::mtkpower::implementation

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.1 (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.1
*
* 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 "vendor.mediatek.hardware.mtkpower@1.2-service.stub"
#include <android-base/logging.h>
#include "MtkPowerCallback.h"
namespace vendor::mediatek::hardware::mtkpower::implementation {
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPowerCallback follow.
Return<void> MtkPowerCallback::mtkPowerHint(int32_t /* hint */, int32_t /* duration */) {
return Void();
}
Return<void> MtkPowerCallback::notifyAppState(const hidl_string& /* pack */, const hidl_string& /* act */, int32_t /* pid */, int32_t /* state */, int32_t /* uid */) {
return Void();
}
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPowerCallback follow.
Return<void> MtkPowerCallback::notifyScnUpdate(int32_t /* hint */, int32_t /* data */) {
return Void();
}
} // namespace vendor::mediatek::hardware::mtkpower::implementation

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.1 (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.1
*
* 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.
*/
#pragma once
#include <vendor/mediatek/hardware/mtkpower/1.2/IMtkPowerCallback.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace vendor::mediatek::hardware::mtkpower::implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
struct MtkPowerCallback : public V1_2::IMtkPowerCallback {
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_1::IMtkPowerCallback follow.
Return<void> mtkPowerHint(int32_t hint, int32_t duration) override;
Return<void> notifyAppState(const hidl_string& pack, const hidl_string& act, int32_t pid, int32_t state, int32_t uid) override;
// Methods from ::vendor::mediatek::hardware::mtkpower::V1_2::IMtkPowerCallback follow.
Return<void> notifyScnUpdate(int32_t hint, int32_t data) override;
};
} // namespace vendor::mediatek::hardware::mtkpower::implementation

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.1 (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.1
*
* 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 "vendor.mediatek.hardware.mtkpower@1.2-service.stub"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include "MtkPower.h"
#include "MtkPerf.h"
using android::OK;
using android::sp;
using android::status_t;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using vendor::mediatek::hardware::mtkpower::V1_2::IMtkPower;
using vendor::mediatek::hardware::mtkpower::V1_2::IMtkPerf;
using vendor::mediatek::hardware::mtkpower::implementation::MtkPower;
using vendor::mediatek::hardware::mtkpower::implementation::MtkPerf;
int main() {
configureRpcThreadpool(1, true /*callerWillJoin*/);
sp<IMtkPower> mtkPower = new MtkPower();
sp<IMtkPerf> mtkPerf = new MtkPerf();
if (mtkPower->registerAsService() != android::OK) {
LOG(ERROR) << "Can't register MtkPower Stub HAL service";
return 1;
}
if (mtkPerf->registerAsService() != android::OK) {
LOG(ERROR) << "Can't register MtkPerf Stub HAL service";
return 1;
}
joinRpcThreadpool();
return 0; // should never get here
}

View File

@@ -0,0 +1,4 @@
service power-hal-1-2 /vendor/bin/hw/vendor.mediatek.hardware.mtkpower@1.2-service.stub
class hal
user system
group system