Simon1511: Drop our custom QTI power hal Test: boot and do powerhint Bug: 62041945 Bug: 69270928 Change-Id: I7de1d2bf377fb46162171a084fca3413b1067d3bfourteen-wip
parent
b819fd367b
commit
af115b1112
@ -1,5 +0,0 @@ |
||||
cc_library_headers { |
||||
name: "qti_sm7125_powerhal_headers", |
||||
vendor_available: true, |
||||
export_include_dirs: ["."], |
||||
} |
@ -1,42 +0,0 @@ |
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
ifeq ($(call is-vendor-board-platform,QCOM),true) |
||||
|
||||
include $(CLEAR_VARS) |
||||
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
liblog \
|
||||
libcutils \
|
||||
libdl \
|
||||
libbase \
|
||||
libutils \
|
||||
android.hardware.power-ndk_platform \
|
||||
vendor.lineage.power-ndk_platform \
|
||||
libbinder_ndk
|
||||
|
||||
LOCAL_HEADER_LIBRARIES := \
|
||||
libhardware_headers
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
power-common.c \
|
||||
metadata-parser.c \
|
||||
utils.c \
|
||||
list.c \
|
||||
hint-data.c \
|
||||
Power.cpp \
|
||||
LineagePower.cpp \
|
||||
main.cpp
|
||||
|
||||
LOCAL_CFLAGS += -Wall -Wextra -Werror
|
||||
|
||||
LOCAL_MODULE := android.hardware.power-service-qti-sm7125
|
||||
LOCAL_INIT_RC := android.hardware.power-service-qti-sm7125.rc
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
LOCAL_VINTF_FRAGMENTS := power.xml
|
||||
|
||||
include $(BUILD_EXECUTABLE) |
||||
endif |
@ -1,55 +0,0 @@ |
||||
/*
|
||||
* Copyright (C) 2021 The LineageOS Project |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
#include "LineagePower.h" |
||||
#include "power-common.h" |
||||
|
||||
using ::ndk::ScopedAStatus; |
||||
|
||||
namespace aidl { |
||||
namespace vendor { |
||||
namespace lineage { |
||||
namespace power { |
||||
namespace impl { |
||||
|
||||
ScopedAStatus Power::getFeature(Feature feature, int* _aidl_return) { |
||||
switch (feature) { |
||||
case Feature::SUPPORTED_PROFILES: |
||||
*_aidl_return = get_number_of_profiles(); |
||||
break; |
||||
default: |
||||
*_aidl_return = -1; |
||||
break; |
||||
} |
||||
return ScopedAStatus::ok(); |
||||
} |
||||
|
||||
ScopedAStatus Power::setBoost(Boost type, int durationMs) { |
||||
switch (type) { |
||||
case Boost::SET_PROFILE: |
||||
set_power_profile(durationMs); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
return ScopedAStatus::ok(); |
||||
} |
||||
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
@ -1,37 +0,0 @@ |
||||
/*
|
||||
* Copyright (C) 2021 The LineageOS Project |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
#pragma once |
||||
|
||||
#include <aidl/vendor/lineage/power/BnPower.h> |
||||
|
||||
namespace aidl { |
||||
namespace vendor { |
||||
namespace lineage { |
||||
namespace power { |
||||
namespace impl { |
||||
|
||||
class Power : public BnPower { |
||||
public: |
||||
ndk::ScopedAStatus getFeature(Feature feature, int* _aidl_return) override; |
||||
ndk::ScopedAStatus setBoost(Boost type, int durationMs) override; |
||||
}; |
||||
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
} // namespace aidl
|
@ -1,32 +0,0 @@ |
||||
Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted (subject to the limitations in the |
||||
disclaimer below) 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. |
||||
|
||||
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE |
||||
GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT |
||||
HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. |
||||
|
@ -1,163 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2019-2020 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 "android.hardware.power-service-qti" |
||||
|
||||
#include "Power.h" |
||||
|
||||
#include <android-base/file.h> |
||||
#include <android-base/logging.h> |
||||
|
||||
#include <aidl/android/hardware/power/BnPower.h> |
||||
|
||||
#include <android-base/logging.h> |
||||
#include <android/binder_manager.h> |
||||
#include <android/binder_process.h> |
||||
|
||||
using ::aidl::android::hardware::power::BnPower; |
||||
using ::aidl::android::hardware::power::Boost; |
||||
using ::aidl::android::hardware::power::IPower; |
||||
using ::aidl::android::hardware::power::Mode; |
||||
|
||||
using ::ndk::ScopedAStatus; |
||||
using ::ndk::SharedRefBase; |
||||
|
||||
namespace aidl { |
||||
namespace android { |
||||
namespace hardware { |
||||
namespace power { |
||||
namespace impl { |
||||
|
||||
#ifdef MODE_EXT |
||||
extern bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return); |
||||
extern bool setDeviceSpecificMode(Mode type, bool enabled); |
||||
#endif |
||||
|
||||
void setInteractive(bool interactive) { |
||||
set_interactive(interactive ? 1 : 0); |
||||
} |
||||
|
||||
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) { |
||||
LOG(INFO) << "Power setMode: " << static_cast<int32_t>(type) << " to: " << enabled; |
||||
#ifdef MODE_EXT |
||||
if (setDeviceSpecificMode(type, enabled)) { |
||||
return ndk::ScopedAStatus::ok(); |
||||
} |
||||
#endif |
||||
switch (type) { |
||||
case Mode::DOUBLE_TAP_TO_WAKE: |
||||
::android::base::WriteStringToFile(enabled ? "aot_enable,1" : "aot_enable,0", "/sys/class/sec/tsp/cmd"); |
||||
break; |
||||
case Mode::LOW_POWER: |
||||
case Mode::EXPENSIVE_RENDERING: |
||||
case Mode::DEVICE_IDLE: |
||||
case Mode::DISPLAY_INACTIVE: |
||||
case Mode::AUDIO_STREAMING_LOW_LATENCY: |
||||
case Mode::CAMERA_STREAMING_SECURE: |
||||
case Mode::CAMERA_STREAMING_LOW: |
||||
case Mode::CAMERA_STREAMING_MID: |
||||
case Mode::CAMERA_STREAMING_HIGH: |
||||
case Mode::VR: |
||||
LOG(INFO) << "Mode " << static_cast<int32_t>(type) << "Not Supported"; |
||||
break; |
||||
case Mode::LAUNCH: |
||||
power_hint(POWER_HINT_LAUNCH, enabled ? &enabled : NULL); |
||||
break; |
||||
case Mode::INTERACTIVE: |
||||
setInteractive(enabled); |
||||
break; |
||||
case Mode::SUSTAINED_PERFORMANCE: |
||||
case Mode::FIXED_PERFORMANCE: |
||||
power_hint(POWER_HINT_SUSTAINED_PERFORMANCE, NULL); |
||||
break; |
||||
default: |
||||
LOG(INFO) << "Mode " << static_cast<int32_t>(type) << "Not Supported"; |
||||
break; |
||||
} |
||||
return ndk::ScopedAStatus::ok(); |
||||
} |
||||
|
||||
ndk::ScopedAStatus Power::isModeSupported(Mode type, bool* _aidl_return) { |
||||
LOG(INFO) << "Power isModeSupported: " << static_cast<int32_t>(type); |
||||
|
||||
#ifdef MODE_EXT |
||||
if (isDeviceSpecificModeSupported(type, _aidl_return)) { |
||||
return ndk::ScopedAStatus::ok(); |
||||
} |
||||
#endif |
||||
|
||||
switch (type) { |
||||
case Mode::DOUBLE_TAP_TO_WAKE: |
||||
*_aidl_return = true; |
||||
break; |
||||
case Mode::LAUNCH: |
||||
case Mode::INTERACTIVE: |
||||
case Mode::SUSTAINED_PERFORMANCE: |
||||
case Mode::FIXED_PERFORMANCE: |
||||
*_aidl_return = true; |
||||
break; |
||||
default: |
||||
*_aidl_return = false; |
||||
break; |
||||
} |
||||
return ndk::ScopedAStatus::ok(); |
||||
} |
||||
|
||||
ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) { |
||||
LOG(VERBOSE) << "Power setBoost: " << static_cast<int32_t>(type) |
||||
<< ", duration: " << durationMs; |
||||
switch (type) { |
||||
case Boost::INTERACTION: |
||||
power_hint(POWER_HINT_INTERACTION, &durationMs); |
||||
break; |
||||
default: |
||||
LOG(INFO) << "Boost " << static_cast<int32_t>(type) << "Not Supported"; |
||||
break; |
||||
} |
||||
return ndk::ScopedAStatus::ok(); |
||||
} |
||||
|
||||
ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool* _aidl_return) { |
||||
LOG(INFO) << "Power isBoostSupported: " << static_cast<int32_t>(type); |
||||
switch (type) { |
||||
case Boost::INTERACTION: |
||||
*_aidl_return = true; |
||||
break; |
||||
default: |
||||
*_aidl_return = false; |
||||
break; |
||||
} |
||||
return ndk::ScopedAStatus::ok(); |
||||
} |
||||
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
@ -1,56 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2019-2020 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 ANDROID_HARDWARE_POWER_POWER_H |
||||
#define ANDROID_HARDWARE_POWER_POWER_H |
||||
|
||||
#include <aidl/android/hardware/power/BnPower.h> |
||||
#include "power-common.h" |
||||
|
||||
namespace aidl { |
||||
namespace android { |
||||
namespace hardware { |
||||
namespace power { |
||||
namespace impl { |
||||
|
||||
class Power : public BnPower { |
||||
public: |
||||
Power() : BnPower() { power_init(); } |
||||
ndk::ScopedAStatus setMode(Mode type, bool enabled) override; |
||||
ndk::ScopedAStatus isModeSupported(Mode type, bool* _aidl_return) override; |
||||
ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override; |
||||
ndk::ScopedAStatus isBoostSupported(Boost type, bool* _aidl_return) override; |
||||
}; |
||||
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
#endif // ANDROID_HARDWARE_POWER_POWER_H
|
@ -1,7 +0,0 @@ |
||||
on init |
||||
chown system system /sys/class/sec/tsp/input/enabled |
||||
|
||||
service vendor.power /vendor/bin/hw/android.hardware.power-service-qti-sm7125 |
||||
class hal |
||||
user system |
||||
group system |
@ -1,46 +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); |
||||
} |
@ -1,71 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2012, 2013, 2015, 2017-2018, The Linux Foundation. All rights reserved. |
||||
* Copyright (C) 2018-2019 The LineageOS Project |
||||
* |
||||
* 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 AOSP_DELTA (0x1200) |
||||
|
||||
#define VSYNC_HINT AOSP_DELTA + POWER_HINT_VSYNC |
||||
#define INTERACTION_HINT AOSP_DELTA + POWER_HINT_INTERACTION |
||||
#define VIDEO_DECODE_HINT AOSP_DELTA + POWER_HINT_VIDEO_DECODE |
||||
#define VIDEO_ENCODE_HINT AOSP_DELTA + POWER_HINT_VIDEO_ENCODE |
||||
#define LOW_POWER_HINT AOSP_DELTA + POWER_HINT_LOW_POWER |
||||
#define SUSTAINED_PERF_HINT AOSP_DELTA + POWER_HINT_SUSTAINED_PERFORMANCE |
||||
#define VR_MODE_HINT AOSP_DELTA + POWER_HINT_VR_MODE |
||||
#define LAUNCH_HINT AOSP_DELTA + POWER_HINT_LAUNCH |
||||
#define DISABLE_TOUCH_HINT AOSP_DELTA + POWER_HINT_DISABLE_TOUCH |
||||
|
||||
// update NUM_HINTS if hints are added to AOSP
|
||||
#define NUM_HINTS (POWER_HINT_DISABLE_TOUCH + 1) |
||||
|
||||
#define VR_MODE_SUSTAINED_PERF_HINT (0x1301) |
||||
|
||||
#define DEFAULT_PROFILE_HINT_ID (0xFF00) |
||||
|
||||
struct hint_handles { |
||||
int handle; |
||||
int ref_count; |
||||
}; |
||||
|
||||
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); |
@ -1,109 +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 <log/log.h> |
||||
#include "list.h" |
||||
|
||||
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; |
||||
} |
||||
|
||||
/*
|
||||
* 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; |
||||
} |
||||
|
||||
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; |
||||
} |
@ -1,39 +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); |
||||
}; |
||||
|
||||
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); |
||||
struct list_node* find_node(struct list_node* head, void* comparison_data); |
@ -1,69 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2020, The Linux Foundation. All rights reserved. |
||||
* Copyright (c) 2021, The LineageOS Project. 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 "LineagePower.h" |
||||
#include "Power.h" |
||||
|
||||
#include <android-base/logging.h> |
||||
#include <android/binder_manager.h> |
||||
#include <android/binder_process.h> |
||||
|
||||
using aidl::android::hardware::power::impl::Power; |
||||
using LineagePower = aidl::vendor::lineage::power::impl::Power; |
||||
|
||||
int main() { |
||||
ABinderProcess_setThreadPoolMaxThreadCount(0); |
||||
std::shared_ptr<Power> vib = ndk::SharedRefBase::make<Power>(); |
||||
const std::string instance = std::string() + Power::descriptor + "/default"; |
||||
LOG(INFO) << "Instance " << instance; |
||||
if (vib) { |
||||
binder_status_t status = |
||||
AServiceManager_addService(vib->asBinder().get(), instance.c_str()); |
||||
LOG(INFO) << "Status " << status; |
||||
if (status != STATUS_OK) { |
||||
LOG(ERROR) << "Could not register" << instance; |
||||
} |
||||
} |
||||
|
||||
std::shared_ptr<LineagePower> lineage_vib = ndk::SharedRefBase::make<LineagePower>(); |
||||
const std::string lineage_instance = std::string() + LineagePower::descriptor + "/default"; |
||||
LOG(INFO) << "Instance " << lineage_instance; |
||||
if (lineage_vib) { |
||||
binder_status_t status = |
||||
AServiceManager_addService(lineage_vib->asBinder().get(), lineage_instance.c_str()); |
||||
LOG(INFO) << "Status " << status; |
||||
if (status != STATUS_OK) { |
||||
LOG(ERROR) << "Could not register" << instance; |
||||
} |
||||
} |
||||
|
||||
ABinderProcess_joinThreadPool(); |
||||
return 1; // should not reach
|
||||
} |
@ -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); |
@ -1,118 +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 "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; |
||||
} |
@ -1,362 +0,0 @@ |
||||
/* Copyright (c) 2012, 2014, The Linux Foundation. All rights reserved.
|
||||
* Copyright (C) 2018 The LineageOS Project |
||||
* |
||||
* 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 |
||||
|
||||
/* Hints sent to perf HAL from power HAL
|
||||
* These have to be kept in sync with Perf HAL side definitions |
||||
*/ |
||||
#define VENDOR_HINT_DISPLAY_OFF 0x00001040 |
||||
#define VENDOR_HINT_DISPLAY_ON 0x00001041 |
||||
|
||||
#define VENDOR_HINT_SCROLL_BOOST 0x00001080 |
||||
#define VENDOR_HINT_FIRST_LAUNCH_BOOST 0x00001081 |
||||
|
||||
enum SCROLL_BOOST_TYPE { |
||||
SCROLL_VERTICAL = 1, |
||||
SCROLL_HORIZONTAL = 2, |
||||
SCROLL_PANEL_VIEW = 3, |
||||
SCROLL_PREFILING = 4, |
||||
}; |
||||
|
||||
enum LAUNCH_BOOST_TYPE { |
||||
LAUNCH_BOOST_V1 = 1, |
||||
LAUNCH_BOOST_V2 = 2, |
||||
LAUNCH_BOOST_V3 = 3, |
||||
}; |
||||
|
||||
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 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, |
||||
HS_FREQ_800 = 0xF08, |
||||
}; |
||||
|
||||
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 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, |
||||
}; |
||||
|
||||
enum SCHED_PREFER_IDLE { |
||||
SCHED_PREFER_IDLE_DIS = 0x3E01, |
||||
}; |
||||
|
||||
enum SCHED_MIGRATE_COST_CHNG { |
||||
SCHED_MIGRATE_COST_SET = 0x3F01, |
||||
}; |
||||
|
||||
/**
|
||||
* MPCTL v3 opcodes |
||||
*/ |
||||
/* 0x1 */ |
||||
enum POWER_COLLAPSE { |
||||
ALL_CPUS_PWR_CLPS_DIS_V3 = 0x40400000, |
||||
}; |
||||
|
||||
/* 0x2 */ |
||||
enum CPUFREQ { |
||||
MIN_FREQ_BIG_CORE_0 = 0x40800000, |
||||
MIN_FREQ_BIG_CORE_0_RESIDX = 0x40802000, |
||||
MIN_FREQ_LITTLE_CORE_0 = 0x40800100, |
||||
MIN_FREQ_LITTLE_CORE_0_RESIDX = 0x40802100, |
||||
MAX_FREQ_BIG_CORE_0 = 0x40804000, |
||||
MAX_FREQ_BIG_CORE_0_RESIDX = 0x40806000, |
||||
MAX_FREQ_LITTLE_CORE_0 = 0x40804100, |
||||
MAX_FREQ_LITTLE_CORE_0_RESIDX = 0x40806100, |
||||
}; |
||||
|
||||
/* 0x3 */ |
||||
enum SCHED { |
||||
SCHED_BOOST_ON_V3 = 0x40C00000, |
||||
SCHED_PREFER_IDLE_DIS_V3 = 0x40C04000, |
||||
SCHED_MIGRATE_COST_SET_V3 = 0x40C08000, |
||||
SCHED_SMALL_TASK = 0x40C0C000, |
||||
SCHED_MOSTLY_IDLE_LOAD = 0x40C10000, |
||||
SCHED_MOSTLY_IDLE_NR_RUN = 0x40C14000, |
||||
SCHED_GROUP_ON = 0x40C28000, |
||||
SCHED_SPILL_NR_RUN = 0x40C2C000, |
||||
SCHED_RESTRICT_CLUSTER_SPILL = 0x40C34000, |
||||
SCHED_GROUP_UP_MIGRATE = 0x40C54000, |
||||
SCHED_GROUP_DOWN_MIGRATE = 0x40C58000, |
||||
}; |
||||
|
||||
/* 0x4 */ |
||||
enum CORE_HOTPLUG { |
||||
CPUS_ONLINE_MIN_BIG = 0x41000000, |
||||
CPUS_ONLINE_MAX_BIG = 0x41004000, |
||||
CPUS_ONLINE_MIN_LITTLE = 0x41000100, |
||||
CPUS_ONLINE_MAX_LITTLE = 0x41004100, |
||||
}; |
||||
|
||||
/* 0x5 */ |
||||
enum INTERACTIVE { |
||||
ABOVE_HISPEED_DELAY_BIG = 0x41400000, |
||||
ABOVE_HISPEED_DELAY_BIG_RESIDX = 0x41402000, |
||||
GO_HISPEED_LOAD_BIG = 0x41410000, |
||||
HISPEED_FREQ_BIG = 0x41414000, |
||||
TARGET_LOADS_BIG = 0x41420000, |
||||
IGNORE_HISPEED_NOTIF_BIG = 0x41438000, |
||||
ABOVE_HISPEED_DELAY_LITTLE = 0x41400100, |
||||
ABOVE_HISPEED_DELAY_LITTLE_RESIDX = 0x41402100, |
||||
GO_HISPEED_LOAD_LITTLE = 0x41410100, |
||||
HISPEED_FREQ_LITTLE = 0x41414100, |
||||
TARGET_LOADS_LITTLE = 0x41420100, |
||||
IGNORE_HISPEED_NOTIF_LITTLE = 0x41438100, |
||||
}; |
||||
|
||||
/* 0x6 */ |
||||
enum CPUBW_HWMON { |
||||
CPUBW_HWMON_MIN_FREQ = 0x41800000, |
||||
CPUBW_HWMON_MIN_FREQ_RESIDX = 0x41802000, |
||||
CPUBW_HWMON_HYST_OPT = 0x4180C000, |
||||
LOW_POWER_CEIL_MBPS = 0x41810000, |
||||
LOW_POWER_IO_PERCENT = 0x41814000, |
||||
CPUBW_HWMON_SAMPLE_MS = 0x41820000, |
||||
}; |
||||
|
||||
/* 0xA */ |
||||
enum GPU { |
||||
GPU_MIN_POWER_LEVEL = 0x42804000, |
||||
GPU_MAX_POWER_LEVEL = 0x42808000, |
||||
GPU_MIN_FREQ = 0x4280C000, |
||||
GPU_MIN_FREQ_RESIDX = 0x4280E000, |
||||
GPU_MAX_FREQ = 0x42810000, |
||||
GPU_MAX_FREQ_RESIDX = 0x42812000, |
||||
GPUBW_MIN_FREQ = 0x42814000, |
||||
GPUBW_MAX_FREQ = 0x42818000, |
||||
}; |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
@ -1,145 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. |
||||
* Copyright (C) 2017-2021 The LineageOS Project |
||||
* |
||||
* 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 <errno.h> |
||||
#include <fcntl.h> |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
#include <sys/stat.h> |
||||
#include <sys/types.h> |
||||
#include <unistd.h> |
||||
|
||||
#define LOG_TAG "QTI PowerHAL" |
||||
#include <hardware/hardware.h> |
||||
#include <hardware/power.h> |
||||
#include <log/log.h> |
||||
|
||||
#include "hint-data.h" |
||||
#include "performance.h" |
||||
#include "power-common.h" |
||||
#include "utils.h" |
||||
|
||||
static struct hint_handles handles[NUM_HINTS]; |
||||
|
||||
void power_init() { |
||||
ALOGI("Initing"); |
||||
|
||||
for (int i = 0; i < NUM_HINTS; i++) { |
||||
handles[i].handle = 0; |
||||
handles[i].ref_count = 0; |
||||
} |
||||
} |
||||
|
||||
int __attribute__((weak)) power_hint_override(power_hint_t hint, void* data) { |
||||
return HINT_NONE; |
||||
} |
||||
|
||||
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_VR_MODE: |
||||
ALOGI("VR mode power hint not handled in power_hint_override"); |
||||
break; |
||||
// fall through below, hints will fail if not defined in powerhint.xml
|
||||
case POWER_HINT_SUSTAINED_PERFORMANCE: |
||||
case POWER_HINT_VIDEO_ENCODE: |
||||
if (data) { |
||||
if (handles[hint].ref_count == 0) |
||||
handles[hint].handle = perf_hint_enable((AOSP_DELTA + hint), 0); |
||||
|
||||
if (handles[hint].handle > 0) handles[hint].ref_count++; |
||||
} else { |
||||
if (handles[hint].handle > 0) { |
||||
if (--handles[hint].ref_count == 0) { |
||||
release_request(handles[hint].handle); |
||||
handles[hint].handle = 0; |
||||
} |
||||
} else { |
||||
ALOGE("Lock for hint: %X was not acquired, cannot be released", hint); |
||||
} |
||||
} |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
int __attribute__((weak)) get_number_of_profiles() { |
||||
return 0; |
||||
} |
||||
|
||||
void __attribute__((weak)) set_power_profile(int profile) {} |
||||
|
||||
int __attribute__((weak)) set_interactive_override(int on) { |
||||
return HINT_NONE; |
||||
} |
||||
|
||||
#ifdef SET_INTERACTIVE_EXT |
||||
extern void power_set_interactive_ext(int on); |
||||
#endif |
||||
|
||||
void set_interactive(int on) { |
||||
static int display_hint_sent; |
||||
|
||||
if (!on) { |
||||
sysfs_write("/sys/class/sec/tsp/input/enabled", "0"); |
||||
/* Send Display OFF hint to perf HAL */ |
||||
perf_hint_enable(VENDOR_HINT_DISPLAY_OFF, 0); |
||||
} else { |
||||
sysfs_write("/sys/class/sec/tsp/input/enabled", "1"); |
||||
/* Send Display ON hint to perf HAL */ |
||||
perf_hint_enable(VENDOR_HINT_DISPLAY_ON, 0); |
||||
} |
||||
|
||||
/**
|
||||
* Ignore consecutive display-off hints |
||||
* Consecutive display-on hints are already handled |
||||
*/ |
||||
if (display_hint_sent && !on) return; |
||||
|
||||
display_hint_sent = !on; |
||||
|
||||
#ifdef SET_INTERACTIVE_EXT |
||||
power_set_interactive_ext(on); |
||||
#endif |
||||
|
||||
if (set_interactive_override(on) == HINT_HANDLED) { |
||||
return; |
||||
} else { |
||||
ALOGI("Hint not handled in set_interactive_override"); |
||||
} |
||||
} |
@ -1,68 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2013, 2018-2019 The Linux Foundation. All rights reserved. |
||||
* Copyright (C) 2017-2021 The LineageOS Project |
||||
* |
||||
* 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_COMMON_H__ |
||||
#define __POWER_COMMON_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#define INTERACTIVE_GOVERNOR "interactive" |
||||
#define SCHEDUTIL_GOVERNOR "schedutil" |
||||
|
||||
#define HINT_HANDLED (0) |
||||
#define HINT_NONE (-1) |
||||
|
||||
#include <hardware/power.h> |
||||
|
||||
enum CPU_GOV_CHECK { CPU0 = 0, CPU1 = 1, CPU2 = 2, CPU3 = 3 }; |
||||
|
||||
enum { |
||||
PROFILE_POWER_SAVE = 0, |
||||
PROFILE_BALANCED, |
||||
PROFILE_HIGH_PERFORMANCE, |
||||
PROFILE_BIAS_POWER, |
||||
PROFILE_BIAS_PERFORMANCE |
||||
}; |
||||
|
||||
void power_init(void); |
||||
void power_hint(power_hint_t hint, void* data); |
||||
void set_interactive(int on); |
||||
int get_number_of_profiles(); |
||||
void set_power_profile(int profile); |
||||
|
||||
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0])) |
||||
#define CHECK_HANDLE(x) ((x) > 0) |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif //__POWER_COMMON_H___
|
@ -1,37 +0,0 @@ |
||||
<!-- Copyright (c) 2020 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. |
||||
--> |
||||
<manifest version="1.0" type="device"> |
||||
<hal format="aidl"> |
||||
<name>android.hardware.power</name> |
||||
<fqname>IPower/default</fqname> |
||||
</hal> |
||||
<hal format="aidl"> |
||||
<name>vendor.lineage.power</name> |
||||
<fqname>IPower/default</fqname> |
||||
</hal> |
||||
</manifest> |
@ -1,283 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8" ?> |
||||
|
||||
<!-- |
||||
/* Copyright (c) 2016-2018, 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. |
||||
*/ |
||||
--> |
||||
<HintConfigs> |
||||
<Powerhint> |
||||
|
||||
<!-- camera 30fps and camera preview --> |
||||
<!--L CPU CORE 0 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 1 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 2 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 3 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 4 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 5 SCHED LOAD BOOST --> |
||||
<!--L CPU Hispeed freq of 1017Mhz --> |
||||
<!--L CPU - Set hispeed load 95 --> |
||||
<!--CPU-LLCC BWMON - Set polling interval 200 --> |
||||
<!--CPU-LLCC BWMON - use AB 0 --> |
||||
<!--LLCC-DDR BWMON - Set sample_ms 20 --> |
||||
<!--CPU-LLCC BWMON - Set up_scale 0 --> |
||||
<!--L CPU core ctl min cpus 6 --> |
||||
<!--CPU-LLCC BWMON - io percent 100 --> |
||||
<Config |
||||
Id="0x00001331" Enable="true" Timeout="0" Target="atoll" |
||||
Resources="0x40C68100, 0xFFFFFFFA, 0x40C68110, 0xFFFFFFFA, 0x40C68120, 0xFFFFFFFA, |
||||
0x40C68130, 0xFFFFFFFA, 0x40C68140, 0xFFFFFFFA, 0x40C68150, 0xFFFFFFFA, |
||||
0x4143C100, 0x3F9, 0x41440100, 0x5F, 0x4181C000, 0xC8, 0x41830000, 0, 0x43034000, 0x14, 0x4182C000, 0, 0x41000100, 6, 0x41808000, 100"/> |
||||
|
||||
<!-- camera 60 FPS --> |
||||
<!--L CPU CORE 0 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 1 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 2 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 3 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 4 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 5 SCHED LOAD BOOST --> |
||||
<!--CPU-LLCC BWMON - Set polling interval 200 --> |
||||
<!--CPU-LLCC BWMON - use AB 0 --> |
||||
<!--LLCC-DDR BWMON - Set sample ms 20 --> |
||||
<!--CPU-LLCC BWMON - Set up_scale 0 --> |
||||
<!--L CPU core ctl min cpus 6 --> |
||||
<!--CPU-LLCC BWMON - io percent 100 --> |
||||
<Config |
||||
Id="0x00001332" Enable="true" Timeout="0" Target="atoll" |
||||
Resources="0x40C68100, 0xFFFFFFFA, 0x40C68110, 0xFFFFFFFA, 0x40C68120, 0xFFFFFFFA, |
||||
0x40C68130, 0xFFFFFFFA, 0x40C68140, 0xFFFFFFFA, 0x40C68150, 0xFFFFFFFA, |
||||
0x4181C000, 0xC8, 0x41830000, 0, 0x43034000, 0x14, 0x4182C000, 0, 0x41000100, 6, 0x41808000, 100"/> |
||||
|
||||
<!-- camera HFR --> |
||||
<!--L CPU CORE 0 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 1 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 2 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 3 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 4 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 5 SCHED LOAD BOOST --> |
||||
<!--CPU-LLCC BWMON - Set polling interval 200 --> |
||||
<!--CPU-LLCC BWMON - use AB 0 --> |
||||
<!--LLCC-DDR BWMON - Set sample ms 20 --> |
||||
<!--CPU-LLCC BWMON - Set up_scale 0 --> |
||||
<!--L CPU core ctl min cpus 6 --> |
||||
<!--CPU-LLCC BWMON - io percent 100 --> |
||||
<Config |
||||
Id="0x00001333" Enable="true" Timeout="0" Target="atoll" |
||||
Resources="0x40C68100, 0xFFFFFFFA, 0x40C68110, 0xFFFFFFFA, 0x40C68120, 0xFFFFFFFA, |
||||
0x40C68130, 0xFFFFFFFA, 0x40C68140, 0xFFFFFFFA, 0x40C68150, 0xFFFFFFFA, |
||||
0x4181C000, 0xC8, 0x41830000, 0, 0x43034000, 0x14, 0x4182C000, 0, 0x41000100, 6, 0x41808000, 100"/> |
||||
|
||||
<!-- HFR 480fps --> |
||||
<!--L CPU CORE 0 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 1 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 2 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 3 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 4 SCHED LOAD BOOST --> |
||||
<!--L CPU CORE 5 SCHED LOAD BOOST --> |
||||
<!--CPU-LLCC BWMON - Set polling interval 200 --> |
||||
<!--CPU-LLCC BWMON - use AB 0 --> |
||||
<!--LLCC-DDR BWMON - Set sample ms 20 --> |
||||
<!--CPU CORE 0 Min freq to 1.2Ghz --> |
||||
<!--CPU-LLCC BWMON - Set up_scale 0 --> |
||||
<!--L CPU core ctl min cpus 6 --> |
||||
<!--CPU-LLCC BWMON - io percent 100 --> |
||||
<Config |
||||
Id="0x00001334" Enable="true" Timeout="0" Target="atoll" |
||||
Resources="0x40C68100, 0xFFFFFFFA, 0x40C68110, 0xFFFFFFFA, 0x40C68120, 0xFFFFFFFA, |
||||
0x40C68130, 0xFFFFFFFA, 0x40C68140, 0xFFFFFFFA, 0x40C68150, 0xFFFFFFFA, |
||||
0x4181C000, 0xC8, 0x41830000, 0, 0x43034000, 0x14, 0x40800100, 0x4B9, 0x4182C000, 0, 0x41000100, 6, 0x41808000, 100"/> |
||||
|
||||
<!-- same settings for all the qvr power levels intentionally --> |
||||
<!-- qvr level cpu1 gpu1 --> |
||||
<!-- B CPU - Cluster min freq ~.806 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~.2.169 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~.576 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.248 Ghz --> |
||||
<!-- GPU - min pwrlevel 7 (freq 180 Mhz) --> |
||||
<!-- GPU - max pwrlevel 0 (freq 825 Mhz) --> |
||||
<!-- Min Big CPUs 2 --> |
||||
<!-- Idefinite Duration --> |
||||
<Config |
||||
Id="0x0000130A" Enable="true" Target="atoll" Timeout="0" |
||||
Resources="0x40800000, 0x326, 0x40804000, 0x879, 0x40800100, 0x240, 0x40804100, 0x4E0, |
||||
0x42804000, 0x7, 0x42808000, 0x0, 0x41000000, 0x2"/> |
||||
|
||||
<!-- qvr level cpu1 gpu2 --> |
||||
<!-- B CPU - Cluster min freq ~.806 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~.2.169 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~.576 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.248 Ghz --> |
||||
<!-- GPU - min pwrlevel 7 (freq 180 Mhz) --> |
||||
<!-- GPU - max pwrlevel 0 (freq 825 Mhz) --> |
||||
<!-- Min Big CPUs 2 --> |
||||
<!-- Idefinite Duration --> |
||||
<Config |
||||
Id="0x0000130B" Enable="true" Target="atoll" Timeout="0" |
||||
Resources="0x40800000, 0x326, 0x40804000, 0x879, 0x40800100, 0x240, 0x40804100, 0x4E0, |
||||
0x42804000, 0x7, 0x42808000, 0x0, 0x41000000, 0x2"/> |
||||
|
||||
<!-- qvr level cpu1 gpu3 --> |
||||
<!-- B CPU - Cluster min freq ~.806 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~.2.169 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~.576 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.248 Ghz --> |
||||
<!-- GPU - min pwrlevel 7 (freq 180 Mhz) --> |
||||
<!-- GPU - max pwrlevel 0 (freq 825 Mhz) --> |
||||
<!-- Min Big CPUs 2 --> |
||||
<!-- Idefinite Duration --> |
||||
<Config |
||||
Id="0x0000130C" Enable="true" Target="atoll" Timeout="0" |
||||
Resources="0x40800000, 0x326, 0x40804000, 0x879, 0x40800100, 0x240, 0x40804100, 0x4E0, |
||||
0x42804000, 0x7, 0x42808000, 0x0, 0x41000000, 0x2"/> |
||||
|
||||
<!-- qvr level cpu2 gpu1 --> |
||||
<!-- B CPU - Cluster min freq ~.806 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~.2.169 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~.576 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.248 Ghz --> |
||||
<!-- GPU - min pwrlevel 7 (freq 180 Mhz) --> |
||||
<!-- GPU - max pwrlevel 0 (freq 825 Mhz) --> |
||||
<!-- Min Big CPUs 2 --> |
||||
<!-- Idefinite Duration --> |
||||
<Config |
||||
Id="0x0000130D" Enable="true" Target="atoll" Timeout="0" |
||||
Resources="0x40800000, 0x326, 0x40804000, 0x879, 0x40800100, 0x240, 0x40804100, 0x4E0, |
||||
0x42804000, 0x7, 0x42808000, 0x0, 0x41000000, 0x2"/> |
||||
|
||||
<!-- qvr level cpu2 gpu2 --> |
||||
<!-- B CPU - Cluster min freq ~.806 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~.2.169 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~.576 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.248 Ghz --> |
||||
<!-- GPU - min pwrlevel 7 (freq 180 Mhz) --> |
||||
<!-- GPU - max pwrlevel 0 (freq 825 Mhz) --> |
||||
<!-- Min Big CPUs 2 --> |
||||
<!-- Idefinite Duration --> |
||||
<Config |
||||
Id="0x0000130E" Enable="true" Target="atoll" Timeout="0" |
||||
Resources="0x40800000, 0x326, 0x40804000, 0x879, 0x40800100, 0x240, 0x40804100, 0x4E0, |
||||
0x42804000, 0x7, 0x42808000, 0x0, 0x41000000, 0x2"/> |
||||
|
||||
<!-- qvr level cpu2 gpu3 --> |
||||
<!-- B CPU - Cluster min freq ~.806 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~.2.169 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~.576 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.248 Ghz --> |
||||
<!-- GPU - min pwrlevel 7 (freq 180 Mhz) --> |
||||
<!-- GPU - max pwrlevel 0 (freq 825 Mhz) --> |
||||
<!-- Min Big CPUs 2 --> |
||||
<!-- Idefinite Duration --> |
||||
<Config |
||||
Id="0x0000130F" Enable="true" Target="atoll" Timeout="0" |
||||
Resources="0x40800000, 0x326, 0x40804000, 0x879, 0x40800100, 0x240, 0x40804100, 0x4E0, |
||||
0x42804000, 0x7, 0x42808000, 0x0, 0x41000000, 0x2"/> |
||||
|
||||
<!-- qvr level cpu3 gpu1 --> |
||||
<!-- B CPU - Cluster min freq ~.806 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~.2.169 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~.576 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.248 Ghz --> |
||||
<!-- GPU - min pwrlevel 7 (freq 180 Mhz) --> |
||||
<!-- GPU - max pwrlevel 0 (freq 825 Mhz) --> |
||||
<!-- Min Big CPUs 2 --> |
||||
<!-- Idefinite Duration --> |
||||
<Config |
||||
Id="0x00001310" Enable="true" Target="atoll" Timeout="0" |
||||
Resources="0x40800000, 0x326, 0x40804000, 0x879, 0x40800100, 0x240, 0x40804100, 0x4E0, |
||||
0x42804000, 0x7, 0x42808000, 0x0, 0x41000000, 0x2"/> |
||||
|
||||
<!-- qvr level cpu3 gpu2 --> |
||||
<!-- B CPU - Cluster min freq ~.806 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~.2.169 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~.576 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.248 Ghz --> |
||||
<!-- GPU - min pwrlevel 7 (freq 180 Mhz) --> |
||||
<!-- GPU - max pwrlevel 0 (freq 825 Mhz) --> |
||||
<!-- Min Big CPUs 2 --> |
||||
<!-- Idefinite Duration --> |
||||
<Config |
||||
Id="0x00001311" Enable="true" Target="atoll" Timeout="0" |
||||
Resources="0x40800000, 0x326, 0x40804000, 0x879, 0x40800100, 0x240, 0x40804100, 0x4E0, |
||||
0x42804000, 0x7, 0x42808000, 0x0, 0x41000000, 0x2"/> |
||||
|
||||
<!-- qvr level cpu3 gpu3 --> |
||||
<!-- B CPU - Cluster min freq ~.806 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~2.169 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~.576 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.248 Ghz --> |
||||
<!-- GPU - min pwrlevel 7 (freq 180 Mhz) --> |
||||
<!-- GPU - max pwrlevel 0 (freq 825 Mhz) --> |
||||
<!-- Min Big CPUs 2 --> |
||||
<!-- Idefinite Duration --> |
||||
<Config |
||||
Id="0x00001312" Enable="true" Target="atoll" Timeout="0" |
||||
Resources="0x40800000, 0x326, 0x40804000, 0x879, 0x40800100, 0x240, 0x40804100, 0x4E0, |
||||
0x42804000, 0x7, 0x42808000, 0x0, 0x41000000, 0x2"/> |
||||
|
||||
<!-- sustained performance --> |
||||
<!-- B CPU - Cluster min freq uncapped --> |
||||
<!-- L CPU - Cluster min freq uncapped --> |
||||
<!-- B CPU - Cluster max freq ~1.22 GHz --> |
||||
<!-- L CPU - Cluster max freq ~1.22 Ghz --> |
||||
<!-- GPU - min freq 275Mhz --> |
||||
<!-- GPU - max freq 400Mhz --> |
||||
<!-- GPUBW freq uncapped --> |
||||
<Config |
||||
Id="0x00001206" Enable="true" Timeout="0" Target="atoll" |
||||
Resources="0x40800000, 0x0, 0x40800100, 0x0, 0x40804000, 0x4CC, 0x40804100, 0x4CC, |
||||
0X4280C000, 0x113, 0X42810000, 0x190, 0x42814000, 0x0"/> |
||||
|
||||
<!-- vr mode --> |
||||
<!-- B CPU - Cluster min freq ~1.22 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~0.940 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~1.90 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.70 Ghz --> |
||||
<!-- GPU - min freq 275Mhz --> |
||||
<!-- GPU - max freq 625Mhz --> |
||||
<!-- GPUBW uncapped --> |
||||
<Config |
||||
Id="0x00001207" Enable="true" Timeout="0" Target="atoll" |
||||
Resources="0x40800000, 0x4CC, 0x40800100, 0x3AC, 0x40804000, 0x76C, 0x40804100, 0x6C0, |
||||
0X4280C000, 0x113, 0X4280C000, 0x271, 0x42814000, 0x0"/> |
||||
|
||||
<!-- vr mode sustained performance --> |
||||
<!-- B CPU - Cluster min freq ~1.22 Ghz --> |
||||
<!-- L CPU - Cluster min freq ~1.22 Ghz --> |
||||
<!-- B CPU - Cluster max freq ~1.22 Ghz --> |
||||
<!-- L CPU - Cluster max freq ~1.22 Ghz --> |
||||
<!-- GPU - min freq 400Mhz --> |
||||
<!-- GPU - max freq 400Mhz --> |
||||
<!-- GPUBW uncapped --> |
||||
<Config |
||||
Id="0x00001301" Enable="true" Timeout="0" Target="atoll" |
||||
Resources="0x40800000, 0x4CC, 0x40800100, 0x4CC, 0x40804000, 0x4CC, 0x40804100, 0x4CC, |
||||
0X4280C000, 0x190, 0X42810000, 0x190, 0x42814000, 0x0"/> |
||||
|
||||
</Powerhint> |
||||
</HintConfigs> |
||||
|
||||
|
@ -1,385 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2012-2013,2015-2018, 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 <errno.h> |
||||
#include <fcntl.h> |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
#include <unistd.h> |
||||
|
||||
#include "hint-data.h" |
||||
#include "list.h" |
||||
#include "power-common.h" |
||||
#include "utils.h" |
||||
|
||||
#define LOG_TAG "QTI PowerHAL" |
||||
#include <log/log.h> |
||||
|
||||
#define USINSEC 1000000L |
||||
#define NSINUS 1000L |
||||
|
||||
#define SOC_ID_0 "/sys/devices/soc0/soc_id" |
||||
#define SOC_ID_1 "/sys/devices/system/soc/soc0/id" |
||||
|
||||
const char* scaling_gov_path[8] = {"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", |
||||
"/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor", |
||||
"/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor", |
||||
"/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor", |
||||
"/sys/devices/system/cpu/cpu4/cpufreq/scaling_governor", |
||||
"/sys/devices/system/cpu/cpu5/cpufreq/scaling_governor", |
||||
"/sys/devices/system/cpu/cpu6/cpufreq/scaling_governor", |
||||
"/sys/devices/system/cpu/cpu7/cpufreq/scaling_governor"}; |
||||
|
||||
#define PERF_HAL_PATH "libqti-perfd-client.so" |
||||
static void* qcopt_handle; |
||||
static int (*perf_lock_acq)(int handle, int duration, int list[], int numArgs); |
||||
static int (*perf_lock_rel)(int handle); |
||||
static int (*perf_hint)(int, const char*, int, int); |
||||
static struct list_node active_hint_list_head; |
||||
const char* pkg = "QTI PowerHAL"; |
||||
|
||||
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()); |
||||
} |
||||
} |
||||
if (!handle) { |
||||
handle = dlopen(PERF_HAL_PATH, RTLD_NOW); |
||||
if (!handle) { |
||||
ALOGE("Unable to open %s: %s\n", PERF_HAL_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"); |
||||
} |
||||
|
||||
perf_hint = dlsym(qcopt_handle, "perf_hint"); |
||||
|
||||
if (!perf_hint) { |
||||
ALOGE("Unable to get perf_hint 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(const 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(const 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) { |
||||
for (size_t i = 0; i < ARRAY_SIZE(scaling_gov_path); i++) { |
||||
if (get_scaling_governor_check_cores(governor, size, i) == 0) { |
||||
// Obtained the scaling governor. Return.
|
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
return -1; |
||||
} |
||||
|
||||
int get_scaling_governor_check_cores(char governor[], int size, int core_num) { |
||||
if (sysfs_read(scaling_gov_path[core_num], governor, size) == -1) { |
||||
// Can't obtain the scaling governor. Return.
|
||||
return -1; |
||||
} |
||||
|
||||
// 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; |
||||
} |
||||
|
||||
int is_schedutil_governor(char* governor) { |
||||
if (strncmp(governor, SCHEDUTIL_GOVERNOR, (strlen(SCHEDUTIL_GOVERNOR) + 1)) == 0) return 1; |
||||
return 0; |
||||
} |
||||
|
||||
#ifndef INTERACTION_BOOST |
||||
void interaction(int duration, int num_args, int opt_list[]) { |
||||
#else |
||||
void interaction(int duration, int num_args, int opt_list[]) { |
||||
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[]) { |
||||
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; |
||||
} |
||||
|
||||
// this is interaction_with_handle using perf_hint instead of
|
||||
// perf_lock_acq
|
||||
int perf_hint_enable(int hint_id, int duration) { |
||||
int lock_handle = 0; |
||||
|
||||
if (duration < 0) return 0; |
||||
|
||||
if (qcopt_handle) { |
||||
if (perf_hint) { |
||||
lock_handle = perf_hint(hint_id, pkg, duration, -1); |
||||
if (lock_handle == -1) ALOGE("Failed to acquire lock for hint_id: %X.", hint_id); |
||||
} |
||||
} |
||||
return lock_handle; |
||||
} |
||||
|
||||
// Same as perf_hint_enable, but with the ability to
|
||||
// choose the type
|
||||
int perf_hint_enable_with_type(int hint_id, int duration, int type) { |
||||
int lock_handle = 0; |
||||
|
||||
if (qcopt_handle) { |
||||
if (perf_hint) { |
||||
lock_handle = perf_hint(hint_id, NULL, duration, type); |
||||
if (lock_handle == -1) ALOGE("Failed to acquire lock."); |
||||
} |
||||
} |
||||
return lock_handle; |
||||
} |
||||
|
||||
void release_request(int lock_handle) { |
||||
if (qcopt_handle && perf_lock_rel) perf_lock_rel(lock_handle); |
||||
} |
||||
|
||||
int perform_hint_action(int hint_id, int resource_values[], int num_resources) { |
||||
if (qcopt_handle && 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("Failed to acquire lock."); |
||||
return -EINVAL; |
||||
} |
||||
|
||||
/* Add this handle to our internal hint-list. */ |
||||
struct hint_data* new_hint = (struct hint_data*)malloc(sizeof(struct hint_data)); |
||||
|
||||
if (!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."); |
||||
return -ENOMEM; |
||||
} |
||||
|
||||
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."); |
||||
return -ENOMEM; |
||||
} |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
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."); |
||||
} |
||||
|
||||
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); |
||||
} else { |
||||
ALOGE("Invalid 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); |
||||
} |
||||
} |
||||
} |
||||
|
||||
int get_soc_id(void) { |
||||
int fd; |
||||
int soc_id = -1; |
||||
char buf[10] = {0}; |
||||
|
||||
if (!access(SOC_ID_0, F_OK)) |
||||
fd = open(SOC_ID_0, O_RDONLY); |
||||
else |
||||
fd = open(SOC_ID_1, O_RDONLY); |
||||
|
||||
if (fd >= 0) { |
||||
if (read(fd, buf, sizeof(buf) - 1) == -1) |
||||
ALOGW("Unable to read soc_id"); |
||||
else |
||||
soc_id = atoi(buf); |
||||
} |
||||
|
||||
close(fd); |
||||
return soc_id; |
||||
} |
||||
|
||||
long long calc_timespan_us(struct timespec start, struct timespec end) { |
||||
long long diff_in_us = 0; |
||||
diff_in_us += (end.tv_sec - start.tv_sec) * USINSEC; |
||||
diff_in_us += (end.tv_nsec - start.tv_nsec) / NSINUS; |
||||
return diff_in_us; |
||||
} |
@ -1,49 +0,0 @@ |
||||
/*
|
||||
* Copyright (c) 2012-2013,2015-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. |
||||
*/ |
||||
|
||||
#include <cutils/properties.h> |
||||
|
||||
int sysfs_read(const char* path, char* s, int num_bytes); |
||||
int sysfs_write(const 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*); |
||||
int is_schedutil_governor(char*); |
||||
|
||||
int perform_hint_action(int hint_id, int resource_values[], int num_resources); |
||||
void undo_hint_action(int hint_id); |
||||
void undo_initial_hint_action(); |
||||
void release_request(int lock_handle); |
||||
void interaction(int duration, int num_args, int opt_list[]); |
||||
int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]); |
||||
int perf_hint_enable(int hint_id, int duration); |
||||
int perf_hint_enable_with_type(int hint_id, int duration, int type); |
||||
|
||||
long long calc_timespan_us(struct timespec start, struct timespec end); |
||||
int get_soc_id(void); |
Loading…
Reference in new issue