Remove perfd
We have moved to new PowerHAL implementation.
Test: build and boot
Bug: 62041945
Change-Id: If8deaf131ccc829653932c8d3310b4c2ecd4a7ac
diff --git a/init.hardware.rc b/init.hardware.rc
index ed6eb20..11755f1 100644
--- a/init.hardware.rc
+++ b/init.hardware.rc
@@ -523,13 +523,6 @@
on property:init.svc.zygote=stopped
stop vendor.folio_daemon
-service vendor.perfd /vendor/bin/perfd
- class main
- user root
- group root readproc system
- socket perfd seqpacket 0666 root system
- disabled
-
service vendor.thermal-engine /vendor/bin/thermal-engine -c ${sys.qcom.thermalcfg:-/vendor/etc/thermal-engine.conf}
class hal
user root
diff --git a/init.power.sh b/init.power.sh
index 949eae7..586608d 100755
--- a/init.power.sh
+++ b/init.power.sh
@@ -41,9 +41,6 @@
# write $memlat/mem_latency/ratio_ceil 400
#done
-# Signal perfd that boot has completed
-setprop sys.post_boot.parsed 1
-
# On debuggable builds, enable console_suspend if uart is enabled to save power
# Otherwise, disable console_suspend to get better logging for kernel crashes
if [[ $(getprop ro.debuggable) == "1" && ! -e /sys/class/tty/ttyMSM0 ]]
diff --git a/power/Android.mk b/power/Android.mk
deleted file mode 100644
index 2d935ab..0000000
--- a/power/Android.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright (C) 2017 The Android Open Source 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_OWNER := qcom
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := android.hardware.power@1.2-service.wahoo
-LOCAL_INIT_RC := android.hardware.power@1.2-service.wahoo.rc
-LOCAL_SRC_FILES := service.cpp \
- Power.cpp \
- InteractionHandler.cpp \
- power-helper.c \
- metadata-parser.c \
- utils.c \
- list.c \
- hint-data.c \
- powerhintparser.c
-
-LOCAL_C_INCLUDES := external/libxml2/include \
- external/icu/icu4c/source/common
-
-# Include target-specific files.
-LOCAL_SRC_FILES += power-8998.c
-
-
-# Enable interaction boost all the time
-LOCAL_CFLAGS += -DINTERACTION_BOOST -Werror
-
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- liblog \
- libcutils \
- libdl \
- libxml2 \
- libhidlbase \
- libhidltransport \
- libhardware \
- libutils \
- android.hardware.power@1.0 \
- android.hardware.power@1.1 \
- android.hardware.power@1.2 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/power/InteractionHandler.cpp b/power/InteractionHandler.cpp
deleted file mode 100644
index ca142a9..0000000
--- a/power/InteractionHandler.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source 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_NDEBUG 0
-
-#define LOG_TAG "PowerInteractionHandler"
-#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
-
-#include <fcntl.h>
-#include <poll.h>
-#include <sys/eventfd.h>
-#include <time.h>
-#include <unistd.h>
-#include <utils/Log.h>
-#include <utils/Trace.h>
-
-#include "InteractionHandler.h"
-#include "power-common.h"
-#include "power-helper.h"
-#include "powerhintparser.h"
-#include "hint-data.h"
-#include "utils.h"
-
-#define FB_IDLE_PATH "/sys/class/graphics/fb0/idle_state"
-#define MAX_LENGTH 64
-
-#define MSINSEC 1000L
-#define USINMS 1000000L
-
-InteractionHandler::InteractionHandler()
- : mState(INTERACTION_STATE_UNINITIALIZED),
- mWaitMs(100),
- mMinDurationMs(1400),
- mMaxDurationMs(5650),
- mDurationMs(0),
- mHandle(0) {
-}
-
-InteractionHandler::~InteractionHandler() {
- Exit();
-}
-
-bool InteractionHandler::Init() {
- std::lock_guard<std::mutex> lk(mLock);
-
- if (mState != INTERACTION_STATE_UNINITIALIZED)
- return true;
-
- mIdleFd = open(FB_IDLE_PATH, O_RDONLY);
- if (mIdleFd < 0) {
- ALOGE("Unable to open idle state path (%d)", errno);
- return false;
- }
-
- mEventFd = eventfd(0, EFD_NONBLOCK);
- if (mEventFd < 0) {
- ALOGE("Unable to create event fd (%d)", errno);
- close(mIdleFd);
- return false;
- }
-
- mState = INTERACTION_STATE_IDLE;
- mThread = std::unique_ptr<std::thread>(
- new std::thread(&InteractionHandler::Routine, this));
-
- return true;
-}
-
-void InteractionHandler::Exit() {
- std::unique_lock<std::mutex> lk(mLock);
- if (mState == INTERACTION_STATE_UNINITIALIZED)
- return;
-
- AbortWaitLocked();
- mState = INTERACTION_STATE_UNINITIALIZED;
- lk.unlock();
-
- mCond.notify_all();
- mThread->join();
-
- close(mEventFd);
- close(mIdleFd);
-}
-
-void InteractionHandler::PerfLock() {
- int *resource_values;
- int num_resources;
-
- resource_values = getPowerhint(INTERACTION_HINT_ID, &num_resources);
- if (resource_values != NULL) {
- ALOGV("%s: acquiring perf lock", __func__);
- mHandle = interaction_with_handle(mHandle, 0, num_resources, resource_values);
- ATRACE_INT("interaction_lock", 1);
- }
-}
-
-void InteractionHandler::PerfRel() {
- ALOGV("%s: releasing perf lock", __func__);
- release_request(mHandle);
- ATRACE_INT("interaction_lock", 0);
-}
-
-long long InteractionHandler::CalcTimespecDiffMs(struct timespec start,
- struct timespec end) {
- long long diff_in_us = 0;
- diff_in_us += (end.tv_sec - start.tv_sec) * MSINSEC;
- diff_in_us += (end.tv_nsec - start.tv_nsec) / USINMS;
- return diff_in_us;
-}
-
-void InteractionHandler::Acquire(int32_t duration) {
- if (is_perf_hint_active(SUSTAINED_PERF_HINT_ID) ||
- is_perf_hint_active(VR_MODE_HINT_ID)) {
- ALOGV("%s: ignoring due to other active perf hints", __func__);
- return;
- }
-
- ATRACE_CALL();
-
- std::lock_guard<std::mutex> lk(mLock);
- if (mState == INTERACTION_STATE_UNINITIALIZED) {
- ALOGW("%s: called while uninitialized", __func__);
- return;
- }
-
- int inputDuration = duration + 650;
- int finalDuration;
- if (inputDuration > mMaxDurationMs)
- finalDuration = mMaxDurationMs;
- else if (inputDuration > mMinDurationMs)
- finalDuration = inputDuration;
- else
- finalDuration = mMinDurationMs;
-
- struct timespec cur_timespec;
- clock_gettime(CLOCK_MONOTONIC, &cur_timespec);
- if (mState != INTERACTION_STATE_IDLE && finalDuration <= mDurationMs) {
- long long elapsed_time = CalcTimespecDiffMs(mLastTimespec, cur_timespec);
- // don't hint if previous hint's duration covers this hint's duration
- if (elapsed_time <= (mDurationMs - finalDuration)) {
- ALOGV("%s: Previous duration (%d) cover this (%d) elapsed: %lld",
- __func__, mDurationMs, finalDuration, elapsed_time);
- return;
- }
- }
- mLastTimespec = cur_timespec;
- mDurationMs = finalDuration;
-
- ALOGV("%s: input: %d final duration: %d", __func__,
- duration, finalDuration);
-
- if (mState == INTERACTION_STATE_WAITING)
- AbortWaitLocked();
- else if (mState == INTERACTION_STATE_IDLE)
- PerfLock();
-
- mState = INTERACTION_STATE_INTERACTION;
- mCond.notify_one();
-}
-
-void InteractionHandler::Release() {
- std::lock_guard<std::mutex> lk(mLock);
- if (mState == INTERACTION_STATE_WAITING) {
- ATRACE_CALL();
- PerfRel();
- mState = INTERACTION_STATE_IDLE;
- } else {
- // clear any wait aborts pending in event fd
- uint64_t val;
- ssize_t ret = read(mEventFd, &val, sizeof(val));
-
- ALOGW_IF(ret < 0, "%s: failed to clear eventfd (%zd, %d)",
- __func__, ret, errno);
- }
-}
-
-// should be called while locked
-void InteractionHandler::AbortWaitLocked() {
- uint64_t val = 1;
- ssize_t ret = write(mEventFd, &val, sizeof(val));
- if (ret != sizeof(val))
- ALOGW("Unable to write to event fd (%zd)", ret);
-}
-
-void InteractionHandler::WaitForIdle(int32_t wait_ms, int32_t timeout_ms) {
- char data[MAX_LENGTH];
- ssize_t ret;
- struct pollfd pfd[2];
-
- ATRACE_CALL();
-
- ALOGV("%s: wait:%d timeout:%d", __func__, wait_ms, timeout_ms);
-
- pfd[0].fd = mEventFd;
- pfd[0].events = POLLIN;
- pfd[1].fd = mIdleFd;
- pfd[1].events = POLLPRI | POLLERR;
-
- ret = poll(pfd, 1, wait_ms);
- if (ret > 0) {
- ALOGV("%s: wait aborted", __func__);
- return;
- } else if (ret < 0) {
- ALOGE("%s: error in poll while waiting", __func__);
- return;
- }
-
- ret = pread(mIdleFd, data, sizeof(data), 0);
- if (!ret) {
- ALOGE("%s: Unexpected EOF!", __func__);
- return;
- }
-
- if (!strncmp(data, "idle", 4)) {
- ALOGV("%s: already idle", __func__);
- return;
- }
-
- ret = poll(pfd, 2, timeout_ms);
- if (ret < 0)
- ALOGE("%s: Error on waiting for idle (%zd)", __func__, ret);
- else if (ret == 0)
- ALOGV("%s: timed out waiting for idle", __func__);
- else if (pfd[0].revents)
- ALOGV("%s: wait for idle aborted", __func__);
- else if (pfd[1].revents)
- ALOGV("%s: idle detected", __func__);
-}
-
-void InteractionHandler::Routine() {
- std::unique_lock<std::mutex> lk(mLock, std::defer_lock);
-
- while (true) {
- lk.lock();
- mCond.wait(lk, [&] { return mState != INTERACTION_STATE_IDLE; });
- if (mState == INTERACTION_STATE_UNINITIALIZED)
- return;
- mState = INTERACTION_STATE_WAITING;
- lk.unlock();
-
- WaitForIdle(mWaitMs, mDurationMs);
- Release();
- }
-}
diff --git a/power/InteractionHandler.h b/power/InteractionHandler.h
deleted file mode 100644
index a7f14f3..0000000
--- a/power/InteractionHandler.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source 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 INTERACTIONHANDLER_H
-#define INTERACTIONHANDLER_H
-
-#include <condition_variable>
-#include <mutex>
-#include <thread>
-
-enum interaction_state {
- INTERACTION_STATE_UNINITIALIZED,
- INTERACTION_STATE_IDLE,
- INTERACTION_STATE_INTERACTION,
- INTERACTION_STATE_WAITING,
-};
-
-struct InteractionHandler {
- InteractionHandler();
- ~InteractionHandler();
- bool Init();
- void Exit();
- void Acquire(int32_t duration);
-
- private:
- void Release();
- void WaitForIdle(int32_t wait_ms, int32_t timeout_ms);
- void AbortWaitLocked();
- void Routine();
-
- void PerfLock();
- void PerfRel();
-
- long long CalcTimespecDiffMs(struct timespec start, struct timespec end);
-
- enum interaction_state mState;
-
- int mIdleFd;
- int mEventFd;
-
- int32_t mWaitMs;
- int32_t mMinDurationMs;
- int32_t mMaxDurationMs;
- int32_t mDurationMs;
-
- struct timespec mLastTimespec;
-
- std::unique_ptr<std::thread> mThread;
- std::mutex mLock;
- std::condition_variable mCond;
- int mHandle;
-};
-
-#endif //INTERACTIONHANDLER_H
diff --git a/power/Power.cpp b/power/Power.cpp
deleted file mode 100644
index 700663a..0000000
--- a/power/Power.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source 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.power@1.2-service.wahoo"
-
-#include <android-base/file.h>
-#include <android-base/logging.h>
-#include <android-base/properties.h>
-#include <android-base/strings.h>
-#include <utils/Log.h>
-#include "Power.h"
-#include "power-common.h"
-#include "power-helper.h"
-
-/* RPM runs at 19.2Mhz. Divide by 19200 for msec */
-#define RPM_CLK 19200
-
-extern struct stat_pair rpm_stat_map[];
-
-namespace android {
-namespace hardware {
-namespace power {
-namespace V1_2 {
-namespace implementation {
-
-using ::android::hardware::power::V1_0::Feature;
-using ::android::hardware::power::V1_0::PowerStatePlatformSleepState;
-using ::android::hardware::power::V1_0::Status;
-using ::android::hardware::power::V1_1::PowerStateSubsystem;
-using ::android::hardware::power::V1_1::PowerStateSubsystemSleepState;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-
-Power::Power() {
- power_init();
- mInteractionHandler.Init();
-}
-
-// Methods from ::android::hardware::power::V1_0::IPower follow.
-Return<void> Power::setInteractive(bool interactive) {
- if (!isSupportedGovernor()) {
- return Void();
- }
- power_set_interactive(interactive ? 1 : 0);
- return Void();
-}
-
-Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
- if (android::base::GetProperty("init.svc.vendor.perfd", "") != "running") {
- LOG(WARNING) << "perfd is not started";
- return Void();
- }
-
- power_hint_t h = static_cast<power_hint_t>(hint);
- if (!isSupportedGovernor()) {
- return Void();
- }
- if (h == POWER_HINT_INTERACTION) {
- mInteractionHandler.Acquire(data);
- return Void();
- }
- power_hint(h, data ? &data : NULL);
- return Void();
-}
-
-Return<void> Power::setFeature(Feature /*feature*/, bool /*activate*/) {
- //Nothing to do
- return Void();
-}
-
-Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) {
-
- hidl_vec<PowerStatePlatformSleepState> states;
- uint64_t stats[MAX_PLATFORM_STATS * MAX_RPM_PARAMS] = {0};
- uint64_t *values;
- struct PowerStatePlatformSleepState *state;
- int ret;
-
- states.resize(PLATFORM_SLEEP_MODES_COUNT);
-
- ret = extract_platform_stats(stats);
- if (ret != 0) {
- states.resize(0);
- goto done;
- }
-
- /* Update statistics for XO_shutdown */
- state = &states[RPM_MODE_XO];
- state->name = "XO_shutdown";
- values = stats + (RPM_MODE_XO * MAX_RPM_PARAMS);
-
- state->residencyInMsecSinceBoot = values[1];
- state->totalTransitions = values[0];
- state->supportedOnlyInSuspend = false;
- state->voters.resize(XO_VOTERS);
- for(size_t i = 0; i < XO_VOTERS; i++) {
- int voter = static_cast<int>(i + XO_VOTERS_START);
- state->voters[i].name = rpm_stat_map[voter].label;
- values = stats + (voter * MAX_RPM_PARAMS);
- state->voters[i].totalTimeInMsecVotedForSinceBoot = values[0] / RPM_CLK;
- state->voters[i].totalNumberOfTimesVotedSinceBoot = values[1];
- }
-
- /* Update statistics for VMIN state */
- state = &states[RPM_MODE_VMIN];
- state->name = "VMIN";
- values = stats + (RPM_MODE_VMIN * MAX_RPM_PARAMS);
-
- state->residencyInMsecSinceBoot = values[1];
- state->totalTransitions = values[0];
- state->supportedOnlyInSuspend = false;
- state->voters.resize(VMIN_VOTERS);
- //Note: No filling of state voters since VMIN_VOTERS = 0
-
-done:
- _hidl_cb(states, Status::SUCCESS);
- return Void();
-}
-
-static int get_wlan_low_power_stats(struct PowerStateSubsystem &subsystem) {
-
- uint64_t stats[WLAN_POWER_PARAMS_COUNT] = {0};
- struct PowerStateSubsystemSleepState *state;
- int ret;
-
- ret = extract_wlan_stats(stats);
- if (ret)
- return ret;
-
- subsystem.name = "wlan";
- subsystem.states.resize(WLAN_STATES_COUNT);
-
- /* Update statistics for Active State */
- state = &subsystem.states[WLAN_STATE_ACTIVE];
- state->name = "Active";
- state->residencyInMsecSinceBoot = stats[CUMULATIVE_TOTAL_ON_TIME_MS];
- state->totalTransitions = stats[DEEP_SLEEP_ENTER_COUNTER];
- state->lastEntryTimestampMs = 0; //FIXME need a new value from Qcom
- state->supportedOnlyInSuspend = false;
-
- /* Update statistics for Deep-Sleep state */
- state = &subsystem.states[WLAN_STATE_DEEP_SLEEP];
- state->name = "Deep-Sleep";
- state->residencyInMsecSinceBoot = stats[CUMULATIVE_SLEEP_TIME_MS];
- state->totalTransitions = stats[DEEP_SLEEP_ENTER_COUNTER];
- state->lastEntryTimestampMs = stats[LAST_DEEP_SLEEP_ENTER_TSTAMP_MS];
- state->supportedOnlyInSuspend = false;
-
- return 0;
-}
-
-// Methods from ::android::hardware::power::V1_1::IPower follow.
-Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) {
-
- hidl_vec<PowerStateSubsystem> subsystems;
- int ret;
-
- subsystems.resize(SUBSYSTEM_COUNT);
-
- //We currently have only one Subsystem for WLAN
- ret = get_wlan_low_power_stats(subsystems[SUBSYSTEM_WLAN]);
- if (ret != 0)
- goto done;
-
- //Add query for other subsystems here
-
-done:
- _hidl_cb(subsystems, Status::SUCCESS);
- return Void();
-}
-
-bool Power::isSupportedGovernor() {
- std::string buf;
- if (android::base::ReadFileToString(SCALING_GOVERNOR_PATH, &buf)) {
- buf = android::base::Trim(buf);
- }
- // Only support EAS 1.2, legacy EAS and HMP
- if (buf == SCHEDUTIL_GOVERNOR || buf == SCHED_GOVERNOR || buf == INTERACTIVE_GOVERNOR) {
- return true;
- } else {
- LOG(ERROR) << "Governor not supported by powerHAL, skipping";
- return false;
- }
-}
-
-Return<void> Power::powerHintAsync(PowerHint_1_0 hint, int32_t data) {
- // just call the normal power hint in this oneway function
- return powerHint(hint, data);
-}
-
-// Methods from ::android::hardware::power::V1_2::IPower follow.
-Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) {
- switch(hint) {
- case PowerHint_1_2::AUDIO_LOW_LATENCY:
- process_audio_low_latency_hint(data);
- break;
- case PowerHint_1_2::AUDIO_STREAMING:
- process_audio_streaming_hint(data);
- break;
- case PowerHint_1_2::CAMERA_LAUNCH:
- process_camera_launch_hint(data);
- break;
- case PowerHint_1_2::CAMERA_STREAMING:
- process_camera_streaming_hint(data);
- break;
- case PowerHint_1_2::CAMERA_SHOT:
- process_camera_shot_hint(data);
- break;
- default:
- return powerHint(static_cast<PowerHint_1_0>(hint), data);
- }
- return Void();
-}
-
-} // namespace implementation
-} // namespace V1_2
-} // namespace power
-} // namespace hardware
-} // namespace android
diff --git a/power/Power.h b/power/Power.h
deleted file mode 100644
index 650a518..0000000
--- a/power/Power.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source 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_POWER_V1_2_POWER_H
-#define ANDROID_HARDWARE_POWER_V1_2_POWER_H
-
-#include <android/hardware/power/1.2/IPower.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-#include <hardware/power.h>
-
-#include "InteractionHandler.h"
-
-namespace android {
-namespace hardware {
-namespace power {
-namespace V1_2 {
-namespace implementation {
-
-using ::android::hardware::power::V1_0::Feature;
-using ::android::hardware::power::V1_2::IPower;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::InteractionHandler;
-using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint;
-using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint;
-
-struct Power : public IPower {
- // Methods from ::android::hardware::power::V1_0::IPower follow.
-
- Power();
-
- Return<void> setInteractive(bool interactive) override;
- Return<void> powerHint(PowerHint_1_0 hint, int32_t data) override;
- Return<void> setFeature(Feature feature, bool activate) override;
- Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override;
-
- // Methods from ::android::hardware::power::V1_1::IPower follow.
- Return<void> getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override;
- Return<void> powerHintAsync(PowerHint_1_0 hint, int32_t data) override;
-
- // Methods from ::android::hardware::power::V1_2::IPower follow.
- Return<void> powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) override;
-
- // Methods from ::android::hidl::base::V1_0::IBase follow.
-
- private:
- InteractionHandler mInteractionHandler;
- static bool isSupportedGovernor();
-};
-
-} // namespace implementation
-} // namespace V1_2
-} // namespace power
-} // namespace hardware
-} // namespace android
-
-#endif // ANDROID_HARDWARE_POWER_V1_2_POWER_H
diff --git a/power/android.hardware.power@1.2-service.wahoo.rc b/power/android.hardware.power@1.2-service.wahoo.rc
deleted file mode 100644
index dd5537c..0000000
--- a/power/android.hardware.power@1.2-service.wahoo.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service vendor.power-hal-1-2 /vendor/bin/hw/android.hardware.power@1.2-service.wahoo
- class hal
- user system
- group system
diff --git a/power/hint-data.c b/power/hint-data.c
deleted file mode 100644
index f3403b7..0000000
--- a/power/hint-data.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <utils/Log.h>
-
-#include "hint-data.h"
-
-int hint_compare(struct hint_data *first_hint,
- struct hint_data *other_hint) {
- if (first_hint == other_hint) {
- return 0;
- } else if ((first_hint && other_hint) &&
- (first_hint->hint_id == other_hint->hint_id)) {
- return 0;
- } else {
- return 1;
- }
-}
-
-void hint_dump(struct hint_data *hint)
-{
- ALOGV("hint_id: %lu", hint->hint_id);
-}
diff --git a/power/hint-data.h b/power/hint-data.h
deleted file mode 100644
index 6885396..0000000
--- a/power/hint-data.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* Default use-case hint IDs */
-#define DEFAULT_VIDEO_ENCODE_HINT_ID (0x0A00)
-#define DEFAULT_VIDEO_DECODE_HINT_ID (0x0B00)
-#define DISPLAY_STATE_HINT_ID (0x0C00)
-#define DISPLAY_STATE_HINT_ID_2 (0x0D00)
-#define CAM_PREVIEW_HINT_ID (0x0E00)
-#define SUSTAINED_PERF_HINT_ID (0x0F00)
-#define VR_MODE_HINT_ID (0x1000)
-#define VR_MODE_SUSTAINED_PERF_HINT_ID (0x1001)
-#define INTERACTION_HINT_ID (0x1A00)
-#define BOOST_HINT_ID (0x1B00)
-
-#define CAMERA_LAUNCH_HINT_ID (0x0B0A)
-#define CAMERA_STREAMING_HINT_ID (0x0C0A)
-#define CAMERA_SHOT_HINT_ID (0x0D0A)
-#define AUDIO_STREAMING_HINT_ID (0x0E0A)
-#define AUDIO_LOW_LATENCY_HINT_ID (0x0F0A)
-
-struct hint_data {
- unsigned long hint_id; /* This is our key. */
- unsigned long perflock_handle;
-};
-
-int hint_compare(struct hint_data *first_hint,
- struct hint_data *other_hint);
-void hint_dump(struct hint_data *hint);
diff --git a/power/list.c b/power/list.c
deleted file mode 100644
index 30a1694..0000000
--- a/power/list.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "list.h"
-#include <utils/Log.h>
-
-int init_list_head(struct list_node *head)
-{
- if (head == NULL)
- return -1;
-
- memset(head, 0, sizeof(*head));
-
- return 0;
-}
-
-struct list_node *add_list_node(struct list_node *head, void *data)
-{
- /* Create a new list_node. And put 'data' into it. */
- struct list_node *new_node;
-
- if (head == NULL) {
- return NULL;
- }
-
- if (!(new_node = malloc(sizeof(struct list_node)))) {
- return NULL;
- }
-
- new_node->data = data;
- new_node->next = head->next;
- new_node->compare = head->compare;
- new_node->dump = head->dump;
- head->next = new_node;
-
- return new_node;
-}
-
-int is_list_empty(struct list_node *head)
-{
- return (head == NULL || head->next == NULL);
-}
-
-/*
- * Delink and de-allocate 'node'.
- */
-int remove_list_node(struct list_node *head, struct list_node *del_node)
-{
- struct list_node *current_node;
- struct list_node *saved_node;
-
- if (head == NULL || head->next == NULL) {
- return -1;
- }
-
- current_node = head->next;
- saved_node = head;
-
- while (current_node && current_node != del_node) {
- saved_node = current_node;
- current_node = current_node->next;
- }
-
- if (saved_node) {
- if (current_node) {
- saved_node->next = current_node->next;
- } else {
- /* Node not found. */
- return -1;
- }
- }
-
- if (del_node) {
- free(del_node);
- }
-
- return 0;
-}
-
-void dump_list(struct list_node *head)
-{
- struct list_node *current_node = head;
-
- if (head == NULL)
- return;
-
- ALOGV("List:\n");
-
- while ((current_node = current_node->next)) {
- if (current_node->dump) {
- current_node->dump(current_node->data);
- }
- }
-}
-
-struct list_node *find_node(struct list_node *head, void *comparison_data)
-{
- struct list_node *current_node = head;
-
- if (head == NULL)
- return NULL;
-
- while ((current_node = current_node->next)) {
- if (current_node->compare) {
- if (current_node->compare(current_node->data,
- comparison_data) == 0) {
- /* Match found. Return current_node. */
- return current_node;
- }
- }
- }
-
- /* No match found. */
- return NULL;
-}
diff --git a/power/list.h b/power/list.h
deleted file mode 100644
index d68c3df..0000000
--- a/power/list.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-struct list_node {
- struct list_node *next;
- void *data;
- int (*compare)(void *data1, void *data2);
- void (*dump)(void *data);
-};
-
-int init_list_head(struct list_node *head);
-struct list_node * add_list_node(struct list_node *head, void *data);
-int remove_list_node(struct list_node *head, struct list_node *del_node);
-void dump_list(struct list_node *head);
-struct list_node *find_node(struct list_node *head, void *comparison_data);
diff --git a/power/metadata-defs.h b/power/metadata-defs.h
deleted file mode 100644
index e3ce944..0000000
--- a/power/metadata-defs.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define ATTRIBUTE_VALUE_DELIM ('=')
-#define ATTRIBUTE_STRING_DELIM (";")
-
-#define METADATA_PARSING_ERR (-1)
-#define METADATA_PARSING_CONTINUE (0)
-#define METADATA_PARSING_DONE (1)
-
-#define MIN(x,y) (((x)>(y))?(y):(x))
-
-struct video_encode_metadata_t {
- int hint_id;
- int state;
-};
-
-struct video_decode_metadata_t {
- int hint_id;
- int state;
-};
-
-int parse_metadata(char *metadata, char **metadata_saveptr,
- char *attribute, unsigned int attribute_size, char *value, unsigned int value_size);
-int parse_video_encode_metadata(char *metadata,
- struct video_encode_metadata_t *video_encode_metadata);
-int parse_video_decode_metadata(char *metadata,
- struct video_decode_metadata_t *video_decode_metadata);
diff --git a/power/metadata-parser.c b/power/metadata-parser.c
deleted file mode 100644
index ffe092b..0000000
--- a/power/metadata-parser.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "metadata-defs.h"
-
-int parse_metadata(char *metadata, char **metadata_saveptr,
- char *attribute, unsigned int attribute_size, char *value, unsigned int value_size)
-{
- char *attribute_string;
- char *attribute_value_delim;
- unsigned int bytes_to_copy;
-
- attribute_string = strtok_r(metadata, ATTRIBUTE_STRING_DELIM,
- metadata_saveptr);
-
- if (attribute_string == NULL)
- return METADATA_PARSING_DONE;
-
- attribute[0] = value[0] = '\0';
-
- if ((attribute_value_delim = strchr(attribute_string,
- ATTRIBUTE_VALUE_DELIM)) != NULL) {
- unsigned int attribute_len = (unsigned int) (attribute_value_delim - attribute_string);
- /* copy only attribute len + NUL character, or as much as can be fit */
- bytes_to_copy = MIN(attribute_len + 1, attribute_size);
-
- strlcpy(attribute, attribute_string, bytes_to_copy);
- strlcpy(value, attribute_value_delim + 1, value_size);
- }
-
- return METADATA_PARSING_CONTINUE;
-}
-
-int parse_video_encode_metadata(char *metadata,
- struct video_encode_metadata_t *video_encode_metadata)
-{
- char attribute[1024], value[1024], *saveptr;
- char *temp_metadata = metadata;
- int parsing_status;
-
- while ((parsing_status = parse_metadata(temp_metadata, &saveptr,
- attribute, sizeof(attribute), value, sizeof(value))) == METADATA_PARSING_CONTINUE) {
- if (strlen(attribute) == strlen("hint_id") &&
- (strncmp(attribute, "hint_id", strlen("hint_id")) == 0)) {
- if (strlen(value) > 0) {
- video_encode_metadata->hint_id = atoi(value);
- }
- }
-
- if (strlen(attribute) == strlen("state") &&
- (strncmp(attribute, "state", strlen("state")) == 0)) {
- if (strlen(value) > 0) {
- video_encode_metadata->state = atoi(value);
- }
- }
-
- temp_metadata = NULL;
- }
-
- if (parsing_status == METADATA_PARSING_ERR)
- return -1;
-
- return 0;
-}
-
-int parse_video_decode_metadata(char *metadata,
- struct video_decode_metadata_t *video_decode_metadata)
-{
- char attribute[1024], value[1024], *saveptr;
- char *temp_metadata = metadata;
- int parsing_status;
-
- while ((parsing_status = parse_metadata(temp_metadata, &saveptr,
- attribute, sizeof(attribute), value, sizeof(value))) == METADATA_PARSING_CONTINUE) {
- if (strlen(attribute) == strlen("hint_id") &&
- (strncmp(attribute, "hint_id", strlen("hint_id")) == 0)) {
- if (strlen(value) > 0) {
- video_decode_metadata->hint_id = atoi(value);
- }
- }
-
- if (strlen(attribute) == strlen("state") &&
- (strncmp(attribute, "state", strlen("state")) == 0)) {
- if (strlen(value) > 0) {
- video_decode_metadata->state = atoi(value);
- }
- }
-
- temp_metadata = NULL;
- }
-
- if (parsing_status == METADATA_PARSING_ERR)
- return -1;
-
- return 0;
-}
diff --git a/power/performance.h b/power/performance.h
deleted file mode 100755
index 85a611d..0000000
--- a/power/performance.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/* Copyright (c) 2012, 2014, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define FAILED -1
-#define SUCCESS 0
-#define INDEFINITE_DURATION 0
-
-enum SCREEN_DISPLAY_TYPE {
- DISPLAY_OFF = 0x00FF,
-};
-
-enum PWR_CLSP_TYPE {
- ALL_CPUS_PWR_CLPS_DIS = 0x101,
-};
-
-/* For CPUx min freq, the leftmost byte
- * represents the CPU and the
- * rightmost byte represents the frequency
- * All intermediate frequencies on the
- * device are supported. The hex value
- * passed into PerfLock will be multiplied
- * by 10^5. This frequency or the next
- * highest frequency available will be set
- *
- * For example, if 1.4 Ghz is required on
- * CPU0, use 0x20E
- *
- * If the highest available frequency
- * on the device is required, use
- * CPUx_MIN_FREQ_TURBO_MAX
- * where x represents the CPU
- */
-enum CPU0_MIN_FREQ_LVL {
- CPU0_MIN_FREQ_NONTURBO_MAX = 0x20A,
- CPU0_MIN_FREQ_TURBO_MAX = 0x2FE,
-};
-
-enum CPU1_MIN_FREQ_LVL {
- CPU1_MIN_FREQ_NONTURBO_MAX = 0x30A,
- CPU1_MIN_FREQ_TURBO_MAX = 0x3FE,
-};
-
-enum CPU2_MIN_FREQ_LVL {
- CPU2_MIN_FREQ_NONTURBO_MAX = 0x40A,
- CPU2_MIN_FREQ_TURBO_MAX = 0x4FE,
-};
-
-enum CPU3_MIN_FREQ_LVL {
- CPU3_MIN_FREQ_NONTURBO_MAX = 0x50A,
- CPU3_MIN_FREQ_TURBO_MAX = 0x5FE,
-};
-
-enum CPU0_MAX_FREQ_LVL {
- CPU0_MAX_FREQ_NONTURBO_MAX = 0x150A,
-};
-
-enum CPU1_MAX_FREQ_LVL {
- CPU1_MAX_FREQ_NONTURBO_MAX = 0x160A,
-};
-
-enum CPU2_MAX_FREQ_LVL {
- CPU2_MAX_FREQ_NONTURBO_MAX = 0x170A,
-};
-
-enum CPU3_MAX_FREQ_LVL {
- CPU3_MAX_FREQ_NONTURBO_MAX = 0x180A,
-};
-
-enum MIN_CPUS_ONLINE_LVL {
- CPUS_ONLINE_MIN_2 = 0x702,
- CPUS_ONLINE_MIN_3 = 0x703,
- CPUS_ONLINE_MIN_4 = 0x704,
- CPUS_ONLINE_MPD_OVERRIDE = 0x777,
- CPUS_ONLINE_MAX = 0x7FF,
-};
-
-enum MAX_CPUS_ONLINE_LVL {
- CPUS_ONLINE_MAX_LIMIT_1 = 0x8FE,
- CPUS_ONLINE_MAX_LIMIT_2 = 0x8FD,
- CPUS_ONLINE_MAX_LIMIT_3 = 0x8FC,
- CPUS_ONLINE_MAX_LIMIT_4 = 0x8FB,
- CPUS_ONLINE_MAX_LIMIT_MAX = 0x8FB,
-};
-
-enum SAMPLING_RATE_LVL {
- MS_500 = 0xBCD,
- MS_50 = 0xBFA,
- MS_20 = 0xBFD,
-};
-
-enum ONDEMAND_IO_BUSY_LVL {
- IO_BUSY_OFF = 0xC00,
- IO_BUSY_ON = 0xC01,
-};
-
-enum ONDEMAND_SAMPLING_DOWN_FACTOR_LVL {
- SAMPLING_DOWN_FACTOR_1 = 0xD01,
- SAMPLING_DOWN_FACTOR_4 = 0xD04,
-};
-
-enum INTERACTIVE_TIMER_RATE_LVL {
- TR_MS_500 = 0xECD,
- TR_MS_100 = 0xEF5,
- TR_MS_50 = 0xEFA,
- TR_MS_30 = 0xEFC,
- TR_MS_20 = 0xEFD,
-};
-
-/* This timer rate applicable to cpu0
- across 8939 series chipset */
-enum INTERACTIVE_TIMER_RATE_LVL_CPU0_8939 {
- TR_MS_CPU0_500 = 0x30CD,
- TR_MS_CPU0_100 = 0x30F5,
- TR_MS_CPU0_50 = 0x30FA,
- TR_MS_CPU0_30 = 0x30FC,
- TR_MS_CPU0_20 = 0x30FD,
-};
-
-/* This timer rate applicable to cpu4
- across 8939 series chipset */
-enum INTERACTIVE_TIMER_RATE_LVL_CPU4_8939 {
- TR_MS_CPU4_500 = 0x3BCD,
- TR_MS_CPU4_100 = 0x3BF5,
- TR_MS_CPU4_50 = 0x3BFA,
- TR_MS_CPU4_30 = 0x3BFC,
- TR_MS_CPU4_20 = 0x3BFD,
-};
-
-/* This timer rate applicable to big.little arch */
-enum INTERACTIVE_TIMER_RATE_LVL_BIG_LITTLE {
- BIG_LITTLE_TR_MS_100 = 0x64,
- BIG_LITTLE_TR_MS_50 = 0x32,
- BIG_LITTLE_TR_MS_40 = 0x28,
- BIG_LITTLE_TR_MS_30 = 0x1E,
- BIG_LITTLE_TR_MS_20 = 0x14,
-};
-
-/* INTERACTIVE opcodes */
-enum INTERACTIVE_OPCODES {
- INT_OP_CLUSTER0_TIMER_RATE = 0x41424000,
- INT_OP_CLUSTER1_TIMER_RATE = 0x41424100,
- INT_OP_CLUSTER0_USE_SCHED_LOAD = 0x41430000,
- INT_OP_CLUSTER1_USE_SCHED_LOAD = 0x41430100,
- INT_OP_CLUSTER0_USE_MIGRATION_NOTIF = 0x41434000,
- INT_OP_CLUSTER1_USE_MIGRATION_NOTIF = 0x41434100,
- INT_OP_NOTIFY_ON_MIGRATE = 0x4241C000
-};
-
-enum INTERACTIVE_HISPEED_FREQ_LVL {
- HS_FREQ_1026 = 0xF0A,
-};
-
-enum INTERACTIVE_HISPEED_LOAD_LVL {
- HISPEED_LOAD_90 = 0x105A,
-};
-
-enum SYNC_FREQ_LVL {
- SYNC_FREQ_300 = 0x1103,
- SYNC_FREQ_600 = 0X1106,
- SYNC_FREQ_384 = 0x1103,
- SYNC_FREQ_NONTURBO_MAX = 0x110A,
- SYNC_FREQ_TURBO = 0x110F,
-};
-
-enum OPTIMAL_FREQ_LVL {
- OPTIMAL_FREQ_300 = 0x1203,
- OPTIMAL_FREQ_600 = 0x1206,
- OPTIMAL_FREQ_384 = 0x1203,
- OPTIMAL_FREQ_NONTURBO_MAX = 0x120A,
- OPTIMAL_FREQ_TURBO = 0x120F,
-};
-
-enum SCREEN_PWR_CLPS_LVL {
- PWR_CLPS_DIS = 0x1300,
- PWR_CLPS_ENA = 0x1301,
-};
-
-enum THREAD_MIGRATION_LVL {
- THREAD_MIGRATION_SYNC_OFF = 0x1400,
-};
-
-enum SCHED_GUIDED_LVL {
- INTERACTIVE_USE_SCHED_LOAD_OFF = 0x5201,
- INTERACTIVE_USE_MIGRATION_NOTIF_OFF = 0x5301
-};
-
-enum INTERACTIVE_IO_BUSY_LVL {
- INTERACTIVE_IO_BUSY_OFF = 0x1B00,
- INTERACTIVE_IO_BUSY_ON = 0x1B01,
-};
-
-enum SCHED_BOOST_LVL {
- SCHED_BOOST_ON = 0x1E01,
-};
-
-enum CPU4_MIN_FREQ_LVL {
- CPU4_MIN_FREQ_NONTURBO_MAX = 0x1F0A,
- CPU4_MIN_FREQ_TURBO_MAX = 0x1FFE,
-};
-
-enum CPU5_MIN_FREQ_LVL {
- CPU5_MIN_FREQ_NONTURBO_MAX = 0x200A,
- CPU5_MIN_FREQ_TURBO_MAX = 0x20FE,
-};
-
-enum CPU6_MIN_FREQ_LVL {
- CPU6_MIN_FREQ_NONTURBO_MAX = 0x210A,
- CPU6_MIN_FREQ_TURBO_MAX = 0x21FE,
-};
-
-enum CPU7_MIN_FREQ_LVL {
- CPU7_MIN_FREQ_NONTURBO_MAX = 0x220A,
- CPU7_MIN_FREQ_TURBO_MAX = 0x22FE,
-};
-
-enum CPU4_MAX_FREQ_LVL {
- CPU4_MAX_FREQ_NONTURBO_MAX = 0x230A,
-};
-
-enum CPU5_MAX_FREQ_LVL {
- CPU5_MAX_FREQ_NONTURBO_MAX = 0x240A,
-};
-
-enum CPU6_MAX_FREQ_LVL {
- CPU6_MAX_FREQ_NONTURBO_MAX = 0x250A,
-};
-
-enum CPU7_MAX_FREQ_LVL {
- CPU7_MAX_FREQ_NONTURBO_MAX = 0x260A,
-};
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/power/power-8998.c b/power/power-8998.c
deleted file mode 100644
index 3c68a27..0000000
--- a/power/power-8998.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#define LOG_NIDEBUG 0
-
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dlfcn.h>
-#include <stdlib.h>
-
-#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
-#define LOG_TAG "QCOM PowerHAL"
-#include <utils/Log.h>
-#include <cutils/trace.h>
-#include <hardware/hardware.h>
-#include <hardware/power.h>
-
-#include "utils.h"
-#include "metadata-defs.h"
-#include "hint-data.h"
-#include "performance.h"
-#include "power-common.h"
-#include "powerhintparser.h"
-
-static int sustained_mode_handle = 0;
-static int vr_mode_handle = 0;
-static int launch_handle = 0;
-static int sustained_performance_mode = 0;
-static int vr_mode = 0;
-static int launch_mode = 0;
-#define CHECK_HANDLE(x) (((x)>0) && ((x)!=-1))
-
-int is_perf_hint_active(int hint)
-{
- switch (hint) {
- case SUSTAINED_PERF_HINT_ID:
- return sustained_performance_mode != 0;
- case VR_MODE_HINT_ID:
- return vr_mode != 0;
- case VR_MODE_SUSTAINED_PERF_HINT_ID:
- return vr_mode != 0 && sustained_performance_mode != 0;
- }
- return 0;
-}
-
-static int process_sustained_perf_hint(void *data)
-{
- int duration = 0;
- int *resource_values = NULL;
- int resources = 0;
-
- if (data && sustained_performance_mode == 0) {
- if (vr_mode == 0) { // Sustained mode only.
- resource_values = getPowerhint(SUSTAINED_PERF_HINT_ID, &resources);
- if (!resource_values) {
- ALOGE("Can't get sustained perf hints from xml ");
- return HINT_NONE;
- }
- sustained_mode_handle = interaction_with_handle(
- sustained_mode_handle, duration, resources, resource_values);
- if (!CHECK_HANDLE(sustained_mode_handle)) {
- ALOGE("Failed interaction_with_handle for sustained_mode_handle");
- return HINT_NONE;
- }
- } else if (vr_mode == 1) { // Sustained + VR mode.
- release_request(vr_mode_handle);
- resource_values = getPowerhint(VR_MODE_SUSTAINED_PERF_HINT_ID, &resources);
- if (!resource_values) {
- ALOGE("Can't get VR mode sustained perf hints from xml ");
- return HINT_NONE;
- }
- sustained_mode_handle = interaction_with_handle(
- sustained_mode_handle, duration, resources, resource_values);
- if (!CHECK_HANDLE(sustained_mode_handle)) {
- ALOGE("Failed interaction_with_handle for sustained_mode_handle");
- return HINT_NONE;
- }
- }
- sustained_performance_mode = 1;
- } else if (sustained_performance_mode == 1) {
- release_request(sustained_mode_handle);
- if (vr_mode == 1) { // Switch back to VR Mode.
- resource_values = getPowerhint(VR_MODE_HINT_ID, &resources);
- if (!resource_values) {
- ALOGE("Can't get VR mode perf hints from xml ");
- return HINT_NONE;
- }
- vr_mode_handle = interaction_with_handle(
- vr_mode_handle, duration, resources, resource_values);
- if (!CHECK_HANDLE(vr_mode_handle)) {
- ALOGE("Failed interaction_with_handle for vr_mode_handle");
- return HINT_NONE;
- }
- }
- sustained_performance_mode = 0;
- }
- return HINT_HANDLED;
-}
-
-static int process_vr_mode_hint(void *data)
-{
- int duration = 0;
- int *resource_values = NULL;
- int resources = 0;
-
- if (data && vr_mode == 0) {
- if (sustained_performance_mode == 0) { // VR mode only.
- resource_values = getPowerhint(VR_MODE_HINT_ID, &resources);
- if (!resource_values) {
- ALOGE("Can't get VR mode perf hints from xml ");
- return HINT_NONE;
- }
- vr_mode_handle = interaction_with_handle(
- vr_mode_handle, duration, resources, resource_values);
- if (!CHECK_HANDLE(vr_mode_handle)) {
- ALOGE("Failed interaction_with_handle for vr_mode_handle");
- return HINT_NONE;
- }
- } else if (sustained_performance_mode == 1) { // Sustained + VR mode.
- release_request(sustained_mode_handle);
- resource_values = getPowerhint(VR_MODE_SUSTAINED_PERF_HINT_ID, &resources);
- if (!resource_values) {
- ALOGE("Can't get VR mode sustained perf hints from xml ");
- return HINT_NONE;
- }
- vr_mode_handle = interaction_with_handle(
- vr_mode_handle, duration, resources, resource_values);
- if (!CHECK_HANDLE(vr_mode_handle)) {
- ALOGE("Failed interaction_with_handle for vr_mode_handle");
- return HINT_NONE;
- }
- }
- vr_mode = 1;
- } else if (vr_mode == 1) {
- release_request(vr_mode_handle);
- if (sustained_performance_mode == 1) { // Switch back to sustained Mode.
- resource_values = getPowerhint(SUSTAINED_PERF_HINT_ID, &resources);
- if (!resource_values) {
- ALOGE("Can't get sustained perf hints from xml ");
- return HINT_NONE;
- }
- sustained_mode_handle = interaction_with_handle(
- sustained_mode_handle, duration, resources, resource_values);
- if (!CHECK_HANDLE(sustained_mode_handle)) {
- ALOGE("Failed interaction_with_handle for sustained_mode_handle");
- return HINT_NONE;
- }
- }
- vr_mode = 0;
- }
-
- return HINT_HANDLED;
-}
-
-static int process_boost(int hint_id, int boost_handle, int duration)
-{
- int *resource_values;
- int resources;
-
- resource_values = getPowerhint(hint_id, &resources);
-
- if (resource_values != NULL) {
- boost_handle = interaction_with_handle(
- boost_handle, duration, resources, resource_values);
- if (!CHECK_HANDLE(boost_handle)) {
- ALOGE("Failed interaction_with_handle for hint_id %d", hint_id);
- }
- }
-
- return boost_handle;
-}
-
-static int process_video_encode_hint(void *data)
-{
- if (data) {
- int *resource_values = NULL;
- int resources = 0;
- resource_values = getPowerhint(DEFAULT_VIDEO_ENCODE_HINT_ID, &resources);
- if (resource_values != NULL)
- perform_hint_action(DEFAULT_VIDEO_ENCODE_HINT_ID, resource_values, resources);
- ALOGD("Video Encode hint start");
- return HINT_HANDLED;
- } else {
- undo_hint_action(DEFAULT_VIDEO_ENCODE_HINT_ID);
- ALOGD("Video Encode hint stop");
- return HINT_HANDLED;
- }
- return HINT_NONE;
-}
-
-int process_camera_launch_hint(int32_t duration)
-{
- static int cam_launch_handle = -1;
- static int boost_handle = -1;
-
- if (duration > 0) {
- cam_launch_handle = process_boost(CAMERA_LAUNCH_HINT_ID, cam_launch_handle, duration);
- ALOGD("CAMERA LAUNCH ON: %d MS", duration);
- // boosts 2.5s for launching
- boost_handle = process_boost(BOOST_HINT_ID, boost_handle, 2500);
- return HINT_HANDLED;
- } else if (duration == 0) {
- release_request(cam_launch_handle);
- ALOGD("CAMERA LAUNCH OFF");
- return HINT_HANDLED;
- } else {
- ALOGE("CAMERA LAUNCH INVALID DATA: %d", duration);
- }
- return HINT_NONE;
-}
-
-int process_camera_streaming_hint(int32_t duration)
-{
- static int cam_streaming_handle = -1;
-
- if (duration > 0) {
- cam_streaming_handle = process_boost(CAMERA_STREAMING_HINT_ID, cam_streaming_handle, duration);
- ALOGD("CAMERA STREAMING ON: %d MS", duration);
- return HINT_HANDLED;
- } else if (duration == 0) {
- release_request(cam_streaming_handle);
- ALOGD("CAMERA STREAMING OFF");
- return HINT_HANDLED;
- } else {
- ALOGE("CAMERA STREAMING INVALID DATA: %d", duration);
- }
- return HINT_NONE;
-}
-
-int process_camera_shot_hint(int32_t duration)
-{
- static int cam_shot_handle = -1;
-
- if (duration > 0) {
- cam_shot_handle = process_boost(CAMERA_SHOT_HINT_ID, cam_shot_handle, duration);
- ALOGD("CAMERA SHOT ON: %d MS", duration);
- return HINT_HANDLED;
- } else if (duration == 0) {
- release_request(cam_shot_handle);
- ALOGD("CAMERA SHOT OFF");
- return HINT_HANDLED;
- } else {
- ALOGE("CAMERA SHOT INVALID DATA: %d", duration);
- }
- return HINT_NONE;
-}
-
-int process_audio_streaming_hint(int32_t duration)
-{
- static int audio_streaming_handle = -1;
-
- if (duration > 0) {
- // set max duration 2s for starting audio
- audio_streaming_handle = process_boost(AUDIO_STREAMING_HINT_ID, audio_streaming_handle, 2000);
- ALOGD("AUDIO STREAMING ON");
- return HINT_HANDLED;
- } else if (duration == 0) {
- release_request(audio_streaming_handle);
- ALOGD("AUDIO STREAMING OFF");
- return HINT_HANDLED;
- } else {
- ALOGE("AUDIO STREAMING INVALID DATA: %d", duration);
- }
- return HINT_NONE;
-}
-
-int process_audio_low_latency_hint(int32_t data)
-{
- static int audio_low_latency_handle = -1;
-
- if (data) {
- // Hint until canceled
- audio_low_latency_handle = process_boost(AUDIO_LOW_LATENCY_HINT_ID, audio_low_latency_handle, 0);
- ALOGD("AUDIO LOW LATENCY ON");
- } else {
- release_request(audio_low_latency_handle);
- ALOGD("AUDIO LOW LATENCY OFF");
- return HINT_HANDLED;
- }
- return HINT_HANDLED;
-}
-
-static int process_activity_launch_hint(void *data)
-{
- // boost will timeout in 5s
- int duration = 5000;
- ATRACE_BEGIN("launch");
- if (sustained_performance_mode || vr_mode) {
- ATRACE_END();
- return HINT_HANDLED;
- }
-
- ALOGD("LAUNCH HINT: %s", data ? "ON" : "OFF");
- // restart the launch hint if the framework has not yet released
- // this shouldn't happen, but we've seen bugs where it could
- if (data) {
- launch_handle = process_boost(BOOST_HINT_ID, launch_handle, duration);
- if (launch_handle > 0) {
- launch_mode = 1;
- ALOGD("Activity launch hint handled");
- ATRACE_INT("launch_lock", 1);
- ATRACE_END();
- return HINT_HANDLED;
- } else {
- ATRACE_END();
- return HINT_NONE;
- }
- } else if (data == NULL && launch_mode == 1) {
- release_request(launch_handle);
- ATRACE_INT("launch_lock", 0);
- launch_mode = 0;
- ATRACE_END();
- return HINT_HANDLED;
- }
- ATRACE_END();
- return HINT_NONE;
-}
-
-int power_hint_override(power_hint_t hint, void *data)
-{
- int ret_val = HINT_NONE;
- switch(hint) {
- case POWER_HINT_VIDEO_ENCODE:
- ret_val = process_video_encode_hint(data);
- break;
- case POWER_HINT_SUSTAINED_PERFORMANCE:
- ret_val = process_sustained_perf_hint(data);
- break;
- case POWER_HINT_VR_MODE:
- ret_val = process_vr_mode_hint(data);
- break;
- case POWER_HINT_LAUNCH:
- ret_val = process_activity_launch_hint(data);
- break;
- default:
- break;
- }
- return ret_val;
-}
-
-int set_interactive_override(int UNUSED(on))
-{
- return HINT_HANDLED; /* Don't excecute this code path, not in use */
-}
diff --git a/power/power-common.h b/power/power-common.h
deleted file mode 100644
index aff3cd2..0000000
--- a/power/power-common.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#define NODE_MAX (64)
-
-#define SCALING_GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
-#define DCVS_CPU0_SLACK_MAX_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_max_us"
-#define DCVS_CPU0_SLACK_MIN_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_min_us"
-#define MPDECISION_SLACK_MAX_NODE "/sys/module/msm_mpdecision/slack_time_max_us"
-#define MPDECISION_SLACK_MIN_NODE "/sys/module/msm_mpdecision/slack_time_min_us"
-#define SCALING_MIN_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
-#define ONDEMAND_GOVERNOR "ondemand"
-#define INTERACTIVE_GOVERNOR "interactive"
-#define SCHEDUTIL_GOVERNOR "schedutil"
-#define SCHED_GOVERNOR "sched"
-
-#define MSMDCVS_GOVERNOR "msm-dcvs"
-#define SCHED_GOVERNOR "sched"
-
-#define HINT_HANDLED (0)
-#define HINT_NONE (-1)
-
-enum CPU_GOV_CHECK {
- CPU0 = 0,
- CPU1 = 1,
- CPU2 = 2,
- CPU3 = 3
-};
-
-#define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
diff --git a/power/power-helper.c b/power/power-helper.c
deleted file mode 100644
index e449ac1..0000000
--- a/power/power-helper.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define LOG_NIDEBUG 0
-
-#include <errno.h>
-#include <inttypes.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dlfcn.h>
-#include <stdlib.h>
-
-#define LOG_TAG "QCOM PowerHAL"
-#include <utils/Log.h>
-#include <hardware/power.h>
-
-#include "utils.h"
-#include "metadata-defs.h"
-#include "hint-data.h"
-#include "performance.h"
-#include "power-common.h"
-#include "power-helper.h"
-
-#ifndef RPM_SYSTEM_STAT
-#define RPM_SYSTEM_STAT "/d/system_stats"
-#endif
-
-#ifndef WLAN_POWER_STAT
-#define WLAN_POWER_STAT "/d/wlan0/power_stats"
-#endif
-
-#define ARRAY_SIZE(x) (sizeof((x))/sizeof((x)[0]))
-#define LINE_SIZE 128
-
-const char *rpm_stat_params[MAX_RPM_PARAMS] = {
- "count",
- "actual last sleep(msec)",
-};
-
-const char *master_stat_params[MAX_RPM_PARAMS] = {
- "Accumulated XO duration",
- "XO Count",
-};
-
-struct stat_pair rpm_stat_map[] = {
- { RPM_MODE_XO, "RPM Mode:vlow", rpm_stat_params, ARRAY_SIZE(rpm_stat_params) },
- { RPM_MODE_VMIN, "RPM Mode:vmin", rpm_stat_params, ARRAY_SIZE(rpm_stat_params) },
- { VOTER_APSS, "APSS", master_stat_params, ARRAY_SIZE(master_stat_params) },
- { VOTER_MPSS, "MPSS", master_stat_params, ARRAY_SIZE(master_stat_params) },
- { VOTER_ADSP, "ADSP", master_stat_params, ARRAY_SIZE(master_stat_params) },
- { VOTER_SLPI, "SLPI", master_stat_params, ARRAY_SIZE(master_stat_params) },
-};
-
-
-const char *wlan_power_stat_params[] = {
- "cumulative_sleep_time_ms",
- "cumulative_total_on_time_ms",
- "deep_sleep_enter_counter",
- "last_deep_sleep_enter_tstamp_ms"
-};
-
-struct stat_pair wlan_stat_map[] = {
- { WLAN_POWER_DEBUG_STATS, "POWER DEBUG STATS", wlan_power_stat_params, ARRAY_SIZE(wlan_power_stat_params) },
-};
-
-static int saved_dcvs_cpu0_slack_max = -1;
-static int saved_dcvs_cpu0_slack_min = -1;
-static int saved_mpdecision_slack_max = -1;
-static int saved_mpdecision_slack_min = -1;
-static int saved_interactive_mode = -1;
-static int slack_node_rw_failed = 0;
-static int display_hint_sent;
-
-void power_init(void)
-{
- ALOGI("QCOM power HAL initing.");
-}
-
-int __attribute__ ((weak)) power_hint_override(power_hint_t UNUSED(hint),
- void *UNUSED(data))
-{
- return HINT_NONE;
-}
-
-/* Declare function before use */
-void interaction(int duration, int num_args, int opt_list[]);
-
-void power_hint(power_hint_t hint, void *data)
-{
- /* Check if this hint has been overridden. */
- if (power_hint_override(hint, data) == HINT_HANDLED) {
- /* The power_hint has been handled. We can skip the rest. */
- return;
- }
-
- switch(hint) {
- case POWER_HINT_VSYNC:
- break;
- case POWER_HINT_SUSTAINED_PERFORMANCE:
- ALOGD("Sustained perf power hint not handled in power_hint_override");
- break;
- case POWER_HINT_VR_MODE:
- ALOGD("VR mode power hint not handled in power_hint_override");
- break;
- case POWER_HINT_INTERACTION:
- {
- int resources[] = {0x702, 0x20F, 0x30F};
- int duration = 3000;
-
- interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
- }
- break;
- default:
- break;
- }
-}
-
-int __attribute__ ((weak)) is_perf_hint_active(int UNUSED(hint))
-{
- return 0;
-}
-
-int __attribute__ ((weak)) set_interactive_override(int UNUSED(on))
-{
- return HINT_NONE;
-}
-
-void power_set_interactive(int on)
-{
- char governor[80];
- char tmp_str[NODE_MAX];
- struct video_encode_metadata_t video_encode_metadata;
- int rc = 0;
-
- if (set_interactive_override(on) == HINT_HANDLED) {
- return;
- }
-
- ALOGD("Got set_interactive hint");
-
- if (get_scaling_governor(governor, sizeof(governor)) == -1) {
- ALOGE("Can't obtain scaling governor.");
-
- return;
- }
-
- if (!on) {
- /* Display off. */
- if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
- int resource_values[] = {DISPLAY_OFF, MS_500, THREAD_MIGRATION_SYNC_OFF};
-
- if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
- display_hint_sent = 1;
- }
- } else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- int resource_values[] = {TR_MS_50, THREAD_MIGRATION_SYNC_OFF};
-
- if (!display_hint_sent) {
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, sizeof(resource_values)/sizeof(resource_values[0]));
- display_hint_sent = 1;
- }
- } else if ((strncmp(governor, MSMDCVS_GOVERNOR, strlen(MSMDCVS_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(MSMDCVS_GOVERNOR))) {
- if (saved_interactive_mode == 1){
- /* Display turned off. */
- if (sysfs_read(DCVS_CPU0_SLACK_MAX_NODE, tmp_str, NODE_MAX - 1)) {
- if (!slack_node_rw_failed) {
- ALOGE("Failed to read from %s", DCVS_CPU0_SLACK_MAX_NODE);
- }
-
- rc = 1;
- } else {
- saved_dcvs_cpu0_slack_max = atoi(tmp_str);
- }
-
- if (sysfs_read(DCVS_CPU0_SLACK_MIN_NODE, tmp_str, NODE_MAX - 1)) {
- if (!slack_node_rw_failed) {
- ALOGE("Failed to read from %s", DCVS_CPU0_SLACK_MIN_NODE);
- }
-
- rc = 1;
- } else {
- saved_dcvs_cpu0_slack_min = atoi(tmp_str);
- }
-
- if (sysfs_read(MPDECISION_SLACK_MAX_NODE, tmp_str, NODE_MAX - 1)) {
- if (!slack_node_rw_failed) {
- ALOGE("Failed to read from %s", MPDECISION_SLACK_MAX_NODE);
- }
-
- rc = 1;
- } else {
- saved_mpdecision_slack_max = atoi(tmp_str);
- }
-
- if (sysfs_read(MPDECISION_SLACK_MIN_NODE, tmp_str, NODE_MAX - 1)) {
- if(!slack_node_rw_failed) {
- ALOGE("Failed to read from %s", MPDECISION_SLACK_MIN_NODE);
- }
-
- rc = 1;
- } else {
- saved_mpdecision_slack_min = atoi(tmp_str);
- }
-
- /* Write new values. */
- if (saved_dcvs_cpu0_slack_max != -1) {
- snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_dcvs_cpu0_slack_max);
-
- if (sysfs_write(DCVS_CPU0_SLACK_MAX_NODE, tmp_str) != 0) {
- if (!slack_node_rw_failed) {
- ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MAX_NODE);
- }
-
- rc = 1;
- }
- }
-
- if (saved_dcvs_cpu0_slack_min != -1) {
- snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_dcvs_cpu0_slack_min);
-
- if (sysfs_write(DCVS_CPU0_SLACK_MIN_NODE, tmp_str) != 0) {
- if(!slack_node_rw_failed) {
- ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MIN_NODE);
- }
-
- rc = 1;
- }
- }
-
- if (saved_mpdecision_slack_max != -1) {
- snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_mpdecision_slack_max);
-
- if (sysfs_write(MPDECISION_SLACK_MAX_NODE, tmp_str) != 0) {
- if(!slack_node_rw_failed) {
- ALOGE("Failed to write to %s", MPDECISION_SLACK_MAX_NODE);
- }
-
- rc = 1;
- }
- }
-
- if (saved_mpdecision_slack_min != -1) {
- snprintf(tmp_str, NODE_MAX, "%d", 10 * saved_mpdecision_slack_min);
-
- if (sysfs_write(MPDECISION_SLACK_MIN_NODE, tmp_str) != 0) {
- if(!slack_node_rw_failed) {
- ALOGE("Failed to write to %s", MPDECISION_SLACK_MIN_NODE);
- }
-
- rc = 1;
- }
- }
- }
-
- slack_node_rw_failed = rc;
- }
- } else {
- /* Display on. */
- if ((strncmp(governor, ONDEMAND_GOVERNOR, strlen(ONDEMAND_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(ONDEMAND_GOVERNOR))) {
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- display_hint_sent = 0;
- } else if ((strncmp(governor, INTERACTIVE_GOVERNOR, strlen(INTERACTIVE_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- display_hint_sent = 0;
- } else if ((strncmp(governor, MSMDCVS_GOVERNOR, strlen(MSMDCVS_GOVERNOR)) == 0) &&
- (strlen(governor) == strlen(MSMDCVS_GOVERNOR))) {
- if (saved_interactive_mode == -1 || saved_interactive_mode == 0) {
- /* Display turned on. Restore if possible. */
- if (saved_dcvs_cpu0_slack_max != -1) {
- snprintf(tmp_str, NODE_MAX, "%d", saved_dcvs_cpu0_slack_max);
-
- if (sysfs_write(DCVS_CPU0_SLACK_MAX_NODE, tmp_str) != 0) {
- if (!slack_node_rw_failed) {
- ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MAX_NODE);
- }
-
- rc = 1;
- }
- }
-
- if (saved_dcvs_cpu0_slack_min != -1) {
- snprintf(tmp_str, NODE_MAX, "%d", saved_dcvs_cpu0_slack_min);
-
- if (sysfs_write(DCVS_CPU0_SLACK_MIN_NODE, tmp_str) != 0) {
- if (!slack_node_rw_failed) {
- ALOGE("Failed to write to %s", DCVS_CPU0_SLACK_MIN_NODE);
- }
-
- rc = 1;
- }
- }
-
- if (saved_mpdecision_slack_max != -1) {
- snprintf(tmp_str, NODE_MAX, "%d", saved_mpdecision_slack_max);
-
- if (sysfs_write(MPDECISION_SLACK_MAX_NODE, tmp_str) != 0) {
- if (!slack_node_rw_failed) {
- ALOGE("Failed to write to %s", MPDECISION_SLACK_MAX_NODE);
- }
-
- rc = 1;
- }
- }
-
- if (saved_mpdecision_slack_min != -1) {
- snprintf(tmp_str, NODE_MAX, "%d", saved_mpdecision_slack_min);
-
- if (sysfs_write(MPDECISION_SLACK_MIN_NODE, tmp_str) != 0) {
- if (!slack_node_rw_failed) {
- ALOGE("Failed to write to %s", MPDECISION_SLACK_MIN_NODE);
- }
-
- rc = 1;
- }
- }
- }
-
- slack_node_rw_failed = rc;
- }
- }
-
- saved_interactive_mode = !!on;
-}
-
-
-static int parse_stats(const char **params, size_t params_size,
- uint64_t *list, FILE *fp) {
- ssize_t nread;
- size_t len = LINE_SIZE;
- char *line;
- size_t params_read = 0;
- size_t i;
-
- line = malloc(len);
- if (!line) {
- ALOGE("%s: no memory to hold line", __func__);
- return -ENOMEM;
- }
-
- while ((params_read < params_size) &&
- (nread = getline(&line, &len, fp) > 0)) {
- char *key = line + strspn(line, " \t");
- char *value = strchr(key, ':');
- if (!value || (value > (line + len)))
- continue;
- *value++ = '\0';
-
- for (i = 0; i < params_size; i++) {
- if (!strcmp(key, params[i])) {
- list[i] = strtoull(value, NULL, 0);
- params_read++;
- break;
- }
- }
- }
- free(line);
-
- return 0;
-}
-
-
-static int extract_stats(uint64_t *list, char *file,
- struct stat_pair *map, size_t map_size) {
- FILE *fp;
- ssize_t read;
- size_t len = LINE_SIZE;
- char *line;
- size_t i, stats_read = 0;
- int ret = 0;
-
- fp = fopen(file, "re");
- if (fp == NULL) {
- ALOGE("%s: failed to open: %s Error = %s", __func__, file, strerror(errno));
- return -errno;
- }
-
- line = malloc(len);
- if (!line) {
- ALOGE("%s: no memory to hold line", __func__);
- fclose(fp);
- return -ENOMEM;
- }
-
- while ((stats_read < map_size) && (read = getline(&line, &len, fp) != -1)) {
- size_t begin = strspn(line, " \t");
-
- for (i = 0; i < map_size; i++) {
- if (!strncmp(line + begin, map[i].label, strlen(map[i].label))) {
- stats_read++;
- break;
- }
- }
-
- if (i == map_size)
- continue;
-
- ret = parse_stats(map[i].parameters, map[i].num_parameters,
- &list[map[i].stat * MAX_RPM_PARAMS], fp);
- if (ret < 0)
- break;
- }
- free(line);
- fclose(fp);
-
- return ret;
-}
-
-int extract_platform_stats(uint64_t *list) {
- return extract_stats(list, RPM_SYSTEM_STAT, rpm_stat_map, ARRAY_SIZE(rpm_stat_map));
-}
-
-int extract_wlan_stats(uint64_t *list) {
- return extract_stats(list, WLAN_POWER_STAT, wlan_stat_map, ARRAY_SIZE(wlan_stat_map));
-}
diff --git a/power/power-helper.h b/power/power-helper.h
deleted file mode 100644
index 6117cab..0000000
--- a/power/power-helper.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2017, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __POWER_HELPER_H__
-#define __POWER_HELPER_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "hardware/power.h"
-
-
-enum stats_type {
- //Platform Stats
- RPM_MODE_XO = 0,
- RPM_MODE_VMIN,
- RPM_MODE_MAX,
- XO_VOTERS_START = RPM_MODE_MAX,
- VOTER_APSS = XO_VOTERS_START,
- VOTER_MPSS,
- VOTER_ADSP,
- VOTER_SLPI,
- MAX_PLATFORM_STATS,
-
- //WLAN Stats
- WLAN_POWER_DEBUG_STATS = 0,
- MAX_WLAN_STATS,
-};
-
-enum subsystem_type {
- SUBSYSTEM_WLAN = 0,
-
- //Don't add any lines after this line
- SUBSYSTEM_COUNT
-};
-
-enum wlan_sleep_states {
- WLAN_STATE_ACTIVE = 0,
- WLAN_STATE_DEEP_SLEEP,
-
- //Don't add any lines after this line
- WLAN_STATES_COUNT
-};
-
-enum wlan_power_params {
- CUMULATIVE_SLEEP_TIME_MS = 0,
- CUMULATIVE_TOTAL_ON_TIME_MS,
- DEEP_SLEEP_ENTER_COUNTER,
- LAST_DEEP_SLEEP_ENTER_TSTAMP_MS,
-
- //Don't add any lines after this line
- WLAN_POWER_PARAMS_COUNT
-};
-
-
-#define PLATFORM_SLEEP_MODES_COUNT RPM_MODE_MAX
-
-#define MAX_RPM_PARAMS 2
-#define XO_VOTERS (MAX_PLATFORM_STATS - XO_VOTERS_START)
-#define VMIN_VOTERS 0
-
-struct stat_pair {
- enum stats_type stat;
- const char *label;
- const char **parameters;
- size_t num_parameters;
-};
-
-
-void power_init(void);
-void power_hint(power_hint_t hint, void *data);
-void power_set_interactive(int on);
-int extract_platform_stats(uint64_t *list);
-int extract_wlan_stats(uint64_t *list);
-
-int is_perf_hint_active(int hint);
-
-int process_camera_launch_hint(int32_t duration);
-int process_camera_streaming_hint(int32_t duration);
-int process_camera_shot_hint(int32_t duration);
-int process_audio_streaming_hint(int32_t duration);
-int process_audio_low_latency_hint(int32_t data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //__POWER_HELPER_H__
diff --git a/power/powerhintparser.c b/power/powerhintparser.c
deleted file mode 100644
index 31d9625..0000000
--- a/power/powerhintparser.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_TAG "QCOM PowerHAL"
-
-#include <unistd.h>
-#include <log/log.h>
-#include <libxml/parser.h>
-#include "powerhintparser.h"
-
-int parsePowerhintXML() {
-
- xmlDocPtr doc;
- xmlNodePtr currNode;
- const char *opcode_str, *value_str, *type_str;
- int opcode = 0, value = 0, type = 0;
- int numParams = 0;
- static int hintCount;
-
- if(access(POWERHINT_XML, F_OK) < 0) {
- return -1;
- }
-
- doc = xmlReadFile(POWERHINT_XML, "UTF-8", XML_PARSE_RECOVER);
- if(!doc) {
- ALOGE("Document not parsed successfully");
- return -1;
- }
-
- currNode = xmlDocGetRootElement(doc);
- if(!currNode) {
- ALOGE("Empty document");
- xmlFreeDoc(doc);
- xmlCleanupParser();
- return -1;
- }
-
- // Confirm the root-element of the tree
- if(xmlStrcmp(currNode->name, BAD_CAST "Powerhint")) {
- ALOGE("document of the wrong type, root node != root");
- xmlFreeDoc(doc);
- xmlCleanupParser();
- return -1;
- }
-
- currNode = currNode->xmlChildrenNode;
-
- for(; currNode != NULL; currNode=currNode->next) {
-
- if(currNode->type != XML_ELEMENT_NODE)
- continue;
-
- xmlNodePtr node = currNode;
-
- if(hintCount == MAX_HINT) {
- ALOGE("Number of hints exceeded the max count of %d\n",MAX_HINT);
- break;
- }
-
- if(!xmlStrcmp(node->name, BAD_CAST "Hint")) {
- if(xmlHasProp(node, BAD_CAST "type")) {
- type_str = (const char*)xmlGetProp(node, BAD_CAST "type");
- if (type_str == NULL)
- {
- ALOGE("xmlGetProp failed on type");
- xmlFreeDoc(doc);
- xmlCleanupParser();
- return -1;
- }
- type = strtol(type_str, NULL, 16);
- }
-
- node = node->children;
- while(node != NULL) {
- if(!xmlStrcmp(node->name, BAD_CAST "Resource")) {
-
- if(xmlHasProp(node, BAD_CAST "opcode")) {
- opcode_str = (const char*)xmlGetProp(node, BAD_CAST "opcode");
- if (opcode_str == NULL)
- {
- ALOGE("xmlGetProp failed on opcode");
- xmlFreeDoc(doc);
- xmlCleanupParser();
- return -1;
- }
- opcode = strtol(opcode_str, NULL, 16);
- }
- if(xmlHasProp(node, BAD_CAST "value")) {
- value_str = (const char*)xmlGetProp(node, BAD_CAST "value");
- if (value_str == NULL)
- {
- ALOGE("xmlGetProp failed on value");
- xmlFreeDoc(doc);
- xmlCleanupParser();
- return -1;
- }
- value = strtol(value_str, NULL, 16);
- }
- if(opcode > 0) {
- if(numParams < (MAX_PARAM-1)) {
- powerhint[hintCount].paramList[numParams++] = opcode;
- powerhint[hintCount].paramList[numParams++] = value;
- } else {
- ALOGE("Maximum parameters exceeded for Hint ID %x\n",type);
- opcode = value = 0;
- break;
- }
- }
-
- opcode = value = 0;
- }
- node = node->next;
- }
- powerhint[hintCount].type = type;
- powerhint[hintCount].numParams = numParams;
- numParams = 0;
- }
- hintCount++;
- }
-
- xmlFreeDoc(doc);
- xmlCleanupParser();
- return 0;
-}
-
-int* getPowerhint(int hint_id, int *params) {
-
- int *result = NULL;
-
- if(!hint_id)
- return result;
-
- ALOGV("Powerhal hint received=%x\n",hint_id);
-
- if(!powerhint[0].numParams) {
- parsePowerhintXML();
- }
-
- for(int i = 0; i < MAX_HINT; i++) {
- if(hint_id == powerhint[i].type) {
- *params = powerhint[i].numParams;
- result = powerhint[i].paramList;
- break;
- }
- }
-
- return result;
-}
diff --git a/power/powerhintparser.h b/power/powerhintparser.h
deleted file mode 100644
index 971a472..0000000
--- a/power/powerhintparser.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef __POWERHINTPARSER__
-#define __POWERHINTPARSER__
-
-#define POWERHINT_XML "/vendor/etc/powerhint.xml"
-#define MAX_HINT 16
-#define MAX_PARAM 30
-
-typedef struct perflock_param_t {
- int type;
- int numParams;
- int paramList[MAX_PARAM];//static limit on number of hints - 15
-}perflock_param_t;
-
-static perflock_param_t powerhint[MAX_HINT];
-
-int parsePowerhintXML();
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int *getPowerhint(int, int *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __POWERHINTPARSER__ */
diff --git a/power/service.cpp b/power/service.cpp
deleted file mode 100644
index 54e6d82..0000000
--- a/power/service.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source 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.power@1.2-service.wahoo"
-
-#include <android/log.h>
-#include <hidl/HidlTransportSupport.h>
-#include <hardware/power.h>
-#include "Power.h"
-
-using android::sp;
-using android::status_t;
-using android::OK;
-
-// libhwbinder:
-using android::hardware::configureRpcThreadpool;
-using android::hardware::joinRpcThreadpool;
-
-// Generated HIDL files
-using android::hardware::power::V1_2::IPower;
-using android::hardware::power::V1_2::implementation::Power;
-
-int main() {
-
- status_t status;
- android::sp<IPower> service = nullptr;
-
- ALOGI("Power HAL Service 1.2 for Wahoo is starting.");
-
- service = new Power();
- if (service == nullptr) {
- ALOGE("Can not create an instance of Power HAL Iface, exiting.");
-
- goto shutdown;
- }
-
- configureRpcThreadpool(1, true /*callerWillJoin*/);
-
- status = service->registerAsService();
- if (status != OK) {
- ALOGE("Could not register service for Power HAL Iface (%d).", status);
- goto shutdown;
- }
-
- ALOGI("Power Service is ready");
- joinRpcThreadpool();
- //Should not pass this line
-
-shutdown:
- // In normal operation, we don't expect the thread pool to exit
-
- ALOGE("Power Service is shutting down");
- return 1;
-}
diff --git a/power/utils.c b/power/utils.c
deleted file mode 100644
index 9661e5e..0000000
--- a/power/utils.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright (c) 2012-2013,2015-2016, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#define LOG_NIDEBUG 0
-
-#include <dlfcn.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "utils.h"
-#include "list.h"
-#include "hint-data.h"
-#include "power-common.h"
-
-#define LOG_TAG "QCOM PowerHAL"
-#include <utils/Log.h>
-
-static void *qcopt_handle;
-static int (*perf_lock_acq)(unsigned long handle, int duration,
- int list[], int numArgs);
-static int (*perf_lock_rel)(unsigned long handle);
-static struct list_node active_hint_list_head;
-
-static void *get_qcopt_handle()
-{
- char qcopt_lib_path[PATH_MAX] = {0};
- void *handle = NULL;
-
- dlerror();
-
- if (property_get("ro.vendor.extension_library", qcopt_lib_path,
- NULL)) {
- handle = dlopen(qcopt_lib_path, RTLD_NOW);
- if (!handle) {
- ALOGE("Unable to open %s: %s\n", qcopt_lib_path,
- dlerror());
- }
- }
-
- return handle;
-}
-
-static void __attribute__ ((constructor)) initialize(void)
-{
- qcopt_handle = get_qcopt_handle();
-
- if (!qcopt_handle) {
- ALOGE("Failed to get qcopt handle.\n");
- } else {
- /*
- * qc-opt handle obtained. Get the perflock acquire/release
- * function pointers.
- */
- perf_lock_acq = dlsym(qcopt_handle, "perf_lock_acq");
-
- if (!perf_lock_acq) {
- ALOGE("Unable to get perf_lock_acq function handle.\n");
- }
-
- perf_lock_rel = dlsym(qcopt_handle, "perf_lock_rel");
-
- if (!perf_lock_rel) {
- ALOGE("Unable to get perf_lock_rel function handle.\n");
- }
- }
-}
-
-static void __attribute__ ((destructor)) cleanup(void)
-{
- if (qcopt_handle) {
- if (dlclose(qcopt_handle))
- ALOGE("Error occurred while closing qc-opt library.");
- }
-}
-
-int sysfs_read(char *path, char *s, int num_bytes)
-{
- char buf[80];
- int count;
- int ret = 0;
- int fd = open(path, O_RDONLY);
-
- if (fd < 0) {
- strerror_r(errno, buf, sizeof(buf));
- ALOGE("Error opening %s: %s\n", path, buf);
-
- return -1;
- }
-
- if ((count = read(fd, s, num_bytes - 1)) < 0) {
- strerror_r(errno, buf, sizeof(buf));
- ALOGE("Error writing to %s: %s\n", path, buf);
-
- ret = -1;
- } else {
- s[count] = '\0';
- }
-
- close(fd);
-
- return ret;
-}
-
-int sysfs_write(char *path, char *s)
-{
- char buf[80];
- int len;
- int ret = 0;
- int fd = open(path, O_WRONLY);
-
- if (fd < 0) {
- strerror_r(errno, buf, sizeof(buf));
- ALOGE("Error opening %s: %s\n", path, buf);
- return -1 ;
- }
-
- len = write(fd, s, strlen(s));
- if (len < 0) {
- strerror_r(errno, buf, sizeof(buf));
- ALOGE("Error writing to %s: %s\n", path, buf);
-
- ret = -1;
- }
-
- close(fd);
-
- return ret;
-}
-
-int get_scaling_governor(char governor[], int size)
-{
- if (sysfs_read(SCALING_GOVERNOR_PATH, governor,
- size) == -1) {
- // Can't obtain the scaling governor. Return.
- return -1;
- } else {
- // Strip newline at the end.
- int len = strlen(governor);
-
- len--;
-
- while (len >= 0 && (governor[len] == '\n' || governor[len] == '\r'))
- governor[len--] = '\0';
- }
-
- return 0;
-}
-
-int is_interactive_governor(char* governor) {
- if (strncmp(governor, INTERACTIVE_GOVERNOR, (strlen(INTERACTIVE_GOVERNOR)+1)) == 0)
- return 1;
- return 0;
-}
-
-void interaction(int duration, int num_args, int opt_list[])
-{
-#ifdef INTERACTION_BOOST
- static int lock_handle = 0;
-
- if (duration < 0 || num_args < 1 || opt_list[0] == 0)
- return;
-
- if (qcopt_handle) {
- if (perf_lock_acq) {
- lock_handle = perf_lock_acq(lock_handle, duration, opt_list, num_args);
- if (lock_handle == -1)
- ALOGE("Failed to acquire lock.");
- }
- }
-#endif
-}
-
-int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[])
-{
-#ifdef INTERACTION_BOOST
- if (duration < 0 || num_args < 1 || opt_list[0] == 0)
- return 0;
-
- if (qcopt_handle) {
- if (perf_lock_acq) {
- lock_handle = perf_lock_acq(lock_handle, duration, opt_list, num_args);
- if (lock_handle == -1)
- ALOGE("Failed to acquire lock.");
- }
- }
- return lock_handle;
-#else
- return 0;
-#endif
-}
-
-void release_request(int lock_handle) {
- if (qcopt_handle && perf_lock_rel)
- perf_lock_rel(lock_handle);
-}
-
-void perform_hint_action(int hint_id, int resource_values[], int num_resources)
-{
- if (qcopt_handle) {
- struct hint_data temp_hint_data = {
- .hint_id = hint_id
- };
- struct list_node *found_node = find_node(&active_hint_list_head,
- &temp_hint_data);
- if (found_node) {
- ALOGE("hint ID %d already active", hint_id);
- return;
- }
- if (perf_lock_acq) {
- /* Acquire an indefinite lock for the requested resources. */
- int lock_handle = perf_lock_acq(0, 0, resource_values,
- num_resources);
-
- if (lock_handle == -1) {
- ALOGE("%s: Failed to acquire lock.", __func__);
- } else {
- /* Add this handle to our internal hint-list. */
- struct hint_data *new_hint =
- (struct hint_data *)malloc(sizeof(struct hint_data));
-
- if (new_hint) {
- if (!active_hint_list_head.compare) {
- active_hint_list_head.compare =
- (int (*)(void *, void *))hint_compare;
- active_hint_list_head.dump = (void (*)(void *))hint_dump;
- }
-
- new_hint->hint_id = hint_id;
- new_hint->perflock_handle = lock_handle;
-
- if (add_list_node(&active_hint_list_head, new_hint) == NULL) {
- free(new_hint);
- /* Can't keep track of this lock. Release it. */
- if (perf_lock_rel)
- perf_lock_rel(lock_handle);
-
- ALOGE("Failed to process hint.");
- }
- } else {
- /* Can't keep track of this lock. Release it. */
- if (perf_lock_rel)
- perf_lock_rel(lock_handle);
-
- ALOGE("Failed to process hint.");
- }
- }
- }
- }
-}
-
-void undo_hint_action(int hint_id)
-{
- if (qcopt_handle) {
- if (perf_lock_rel) {
- /* Get hint-data associated with this hint-id */
- struct list_node *found_node;
- struct hint_data temp_hint_data = {
- .hint_id = hint_id
- };
-
- found_node = find_node(&active_hint_list_head,
- &temp_hint_data);
-
- if (found_node) {
- /* Release this lock. */
- struct hint_data *found_hint_data =
- (struct hint_data *)(found_node->data);
-
- if (found_hint_data) {
- if (perf_lock_rel(found_hint_data->perflock_handle) == -1)
- ALOGE("Perflock release failed: %d", hint_id);
- }
-
- if (found_node->data) {
- /* We can free the hint-data for this node. */
- free(found_node->data);
- }
-
- remove_list_node(&active_hint_list_head, found_node);
- ALOGV("Undo of hint ID %d succeeded", hint_id);
- } else {
- ALOGE("Invalid hint ID: %d", hint_id);
- }
- }
- }
-}
-
-/*
- * Used to release initial lock holding
- * two cores online when the display is on
- */
-void undo_initial_hint_action()
-{
- if (qcopt_handle) {
- if (perf_lock_rel) {
- perf_lock_rel(1);
- }
- }
-}
diff --git a/power/utils.h b/power/utils.h
deleted file mode 100644
index fb7aa11..0000000
--- a/power/utils.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2012-2013,2015-2016, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#ifndef UTILS_H
-#define UTILS_H
-#include <cutils/properties.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int sysfs_read(char *path, char *s, int num_bytes);
-int sysfs_write(char *path, char *s);
-int get_scaling_governor(char governor[], int size);
-int get_scaling_governor_check_cores(char governor[], int size, int core_num);
-int is_interactive_governor(char *);
-
-void vote_ondemand_io_busy_off();
-void unvote_ondemand_io_busy_off();
-void vote_ondemand_sdf_low();
-void unvote_ondemand_sdf_low();
-void perform_hint_action(int hint_id, int resource_values[],
- int num_resources);
-void undo_hint_action(int hint_id);
-void release_request(int lock_handle);
-int interaction_with_handle(int lock_handle,
- int duration,
- int num_args,
- int opt_list[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //UTILS_H
\ No newline at end of file