Home | History | Annotate | Download | only in thermal
      1 /*
      2  * Copyright (c) 2017, The Linux Foundation. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  * *    * Redistributions of source code must retain the above copyright
      8  *       notice, this list of conditions and the following disclaimer.
      9  *     * Redistributions in binary form must reproduce the above
     10  *       copyright notice, this list of conditions and the following
     11  *       disclaimer in the documentation and/or other materials provided
     12  *       with the distribution.
     13  *     * Neither the name of The Linux Foundation nor the names of its
     14  *       contributors may be used to endorse or promote products derived
     15  *       from this software without specific prior written permission.
     16  *
     17  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
     18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
     20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
     21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     24  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     26  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     27  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 
     30 #ifndef __THERMAL_HELPER_H__
     31 #define __THERMAL_HELPER_H__
     32 
     33 #include <android/hardware/thermal/1.1/IThermal.h>
     34 
     35 namespace android {
     36 namespace hardware {
     37 namespace thermal {
     38 namespace V1_1 {
     39 namespace implementation {
     40 
     41 using ::android::hardware::thermal::V1_0::CpuUsage;
     42 using ::android::hardware::thermal::V1_0::Temperature;
     43 using ::android::hardware::thermal::V1_0::TemperatureType;
     44 
     45 constexpr const char *kCpuUsageFile = "/proc/stat";
     46 constexpr const char *kTemperatureFileFormat = "/sys/class/thermal/thermal_zone%d/temp";
     47 constexpr const char *kCpuOnlineFileFormat = "/sys/devices/system/cpu/cpu%d/online";
     48 
     49 // thermal-engine.conf
     50 constexpr unsigned int kWalleyeSkinThrottlingThreshold = 40;
     51 constexpr unsigned int kWalleyeSkinShutdownThreshold = 56;
     52 constexpr unsigned int kWalleyeVrThrottledBelowMin = 52;
     53 
     54 constexpr unsigned int kTaimenRabSkinThrottlingThreshold = 49;
     55 constexpr unsigned int kTaimenRabSkinShutdownThreshold = 66;
     56 constexpr unsigned int kTaimenRabVrThrottledBelowMin = 62;
     57 
     58 constexpr unsigned int kTaimenRcSkinThrottlingThreshold = 38;
     59 constexpr unsigned int kTaimenRcSkinShutdownThreshold = 54;
     60 constexpr unsigned int kTaimenRcVrThrottledBelowMin = 50;
     61 
     62 constexpr unsigned int kCpuNum = 8;
     63 
     64 constexpr const char *kCpuLabel[kCpuNum] = {
     65   "CPU0", "CPU1", "CPU2", "CPU3", "CPU4", "CPU5", "CPU6", "CPU7"};
     66 
     67 // Sum of kCpuNum + 4 for GPU, BATTERY, SKIN, and USB-C.
     68 constexpr unsigned int kTemperatureNum = 4 + kCpuNum;
     69 
     70 // qcom, therm-reset-temp
     71 constexpr unsigned int kCpuShutdownThreshold = 115;
     72 // qcom,freq-mitigation-temp
     73 constexpr unsigned int kCpuThrottlingThreshold = 95;
     74 
     75 // config_shutdownBatteryTemperature in overlay/frameworks/base/core/res/res/values/config.xml
     76 constexpr unsigned int kBatteryShutdownThreshold = 60;
     77 
     78 
     79 bool initThermal();
     80 ssize_t fillTemperatures(hidl_vec<Temperature> *temperatures);
     81 ssize_t fillCpuUsages(hidl_vec<CpuUsage> *cpuUsages);
     82 std::string getTargetSkinSensorType();
     83 
     84 }  // namespace implementation
     85 }  // namespace V1_1
     86 }  // namespace thermal
     87 }  // namespace hardware
     88 }  // namespace android
     89 
     90 #endif //__THERMAL_HELPER_H__
     91