118 lines
3.5 KiB
C++
118 lines
3.5 KiB
C++
/*
|
|||
|
|
* ThermalManager.h
|
||
|
|
*
|
||
|
|
* Copyright (C) 2016 Spreadtrum Communications Inc.
|
||
|
|
*/
|
||
|
|
#ifndef THERMALMANAGER_H_
|
||
|
|
#define THERMALMANAGER_H_
|
||
|
|
|
||
|
|
#include <deque>
|
||
|
|
#include <queue>
|
||
|
|
#include <pthread.h>
|
||
|
|
|
||
|
|
namespace android {
|
||
|
|
|
||
|
|
class ThermalSensor;
|
||
|
|
class ThermalXmlParser;
|
||
|
|
class ThermalZoneLevel;
|
||
|
|
class ThermalTrip;
|
||
|
|
class ThermalAction;
|
||
|
|
class ChargeDetect;
|
||
|
|
|
||
|
|
class ThermalManager {
|
||
|
|
public:
|
||
|
|
const char* PA_SENSOR = "pa sensor";
|
||
|
|
const char* CPU_SENSOR = "cpu sensor";
|
||
|
|
const char* CHARGE_SENSOR = "charge sensor";
|
||
|
|
const char* ACT_POWERBACK = "powerback";
|
||
|
|
const char* ACT_CHARGE = "charge";
|
||
|
|
const char* GOVERNOR_ENABLE = "persist.vendor.thermal.goven";
|
||
|
|
const char* GOVERNOR_PA_ENABLE = "persist.vendor.thermal.pagoven";
|
||
|
|
const char* LIMIT_TRIP_EN = "persist.vendor.thermal.limen";
|
||
|
|
const char* BOARD_SCORE_EN = "persist.vendor.bsservice.enable";
|
||
|
|
ThermalManager();
|
||
|
|
~ThermalManager();
|
||
|
|
void run(void);
|
||
|
|
enum EventType {
|
||
|
|
EVENT_TRIP = 0x1,
|
||
|
|
EVENT_GOVDIS = 0x2,
|
||
|
|
EVENT_GOVEN = 0x4,
|
||
|
|
EVENT_LIMEN = 0x8,
|
||
|
|
EVENT_LIMDIS = 0x10,
|
||
|
|
EVENT_PADIS = 0x20,
|
||
|
|
EVENT_PAEN = 0x40,
|
||
|
|
EVENT_CHGDIS = 0x80,
|
||
|
|
EVENT_CHGEN = 0x100,
|
||
|
|
};
|
||
|
|
void sendEvent(enum EventType type);
|
||
|
|
#if 0
|
||
|
|
enum ExtThermalCmd {
|
||
|
|
THMCMD_SET_EN = 0, /* set thermal enable, persistent */
|
||
|
|
THMCMD_SET_DIS = 1, /* set thermal disable */
|
||
|
|
THMCMD_SET_PERF_EN = 2, /* enable performance mode, equal SET_DIS, but no persist */
|
||
|
|
THMCMD_SET_PERF_DIS = 3, /* disable performance mode, equal SET_EN, but no persist */
|
||
|
|
THMCMD_GET_STAT = 4, /* get thermal en/dis status */
|
||
|
|
THMCMD_SET_PA_EN = 5, /* set PA power back-off enable, persistent */
|
||
|
|
THMCMD_SET_PA_DIS = 6, /* set PA power back-off disable, persistent */
|
||
|
|
THMCMD_GET_PA_STAT = 7, /* get PA power back-off status */
|
||
|
|
THMCMD_SET_CHG_EN = 8, /* set limit charge current enable, persistent */
|
||
|
|
THMCMD_SET_CHG_DIS = 9, /* set limit charge current disable, persistent */
|
||
|
|
THMCMD_GET_CHG_STAT = 10, /* get limit charge current status */
|
||
|
|
THMCMD_SET_LIM_EN = 11, /* trigger thermal limit trip for scenario, no persist */
|
||
|
|
THMCMD_SET_LIM_DIS = 12, /* disable trigger thermal limit trip, no persist */
|
||
|
|
THMCMD_SET_LIM_EN_PRST = 13, /* equal SET_LIM_EN, but persistent */
|
||
|
|
THMCMD_SET_LIM_DIS_PRST = 14, /* equal SET_LIM_DIS, but persistent */
|
||
|
|
THMCMD_MAX = 15,
|
||
|
|
};
|
||
|
|
const char* mCmdMsg[15] = {
|
||
|
|
"THMCMD_SET_EN",
|
||
|
|
"THMCMD_SET_DIS",
|
||
|
|
"THMCMD_SET_PERF_EN",
|
||
|
|
"THMCMD_SET_PERF_DIS",
|
||
|
|
"THMCMD_GET_STAT",
|
||
|
|
"THMCMD_SET_PA_EN",
|
||
|
|
"THMCMD_SET_PA_DIS",
|
||
|
|
"THMCMD_GET_PA_STAT",
|
||
|
|
"THMCMD_SET_CHG_EN",
|
||
|
|
"THMCMD_SET_CHG_DIS",
|
||
|
|
"THMCMD_GET_CHG_STAT",
|
||
|
|
"THMCMD_SET_LIM_EN",
|
||
|
|
"THMCMD_SET_LIM_DIS",
|
||
|
|
"THMCMD_SET_LIM_EN_PRST",
|
||
|
|
"THMCMD_SET_LIM_DIS_PRST",
|
||
|
|
};
|
||
|
|
#endif
|
||
|
|
private:
|
||
|
|
int mGovEnCnt;
|
||
|
|
int mPaEnCnt;
|
||
|
|
int mChgEnCnt;
|
||
|
|
int mLimEnCnt;
|
||
|
|
int mGovEnPrst;
|
||
|
|
int mLimEnPrst;
|
||
|
|
static void* thermalMonitor(void* ptr);
|
||
|
|
//static void* socketListen(void* ptr);
|
||
|
|
void receiveEvent(void);
|
||
|
|
bool getChargeEn(void);
|
||
|
|
int enableCharge(bool en);
|
||
|
|
void check_property(void);
|
||
|
|
pthread_mutex_t mCountLock;
|
||
|
|
pthread_mutex_t mThreadLock;
|
||
|
|
pthread_mutex_t mEnCntLock;
|
||
|
|
pthread_cond_t mCountFlag;
|
||
|
|
std::deque<ThermalSensor*> mSensorDeque;
|
||
|
|
ThermalXmlParser* mpXmlParser;
|
||
|
|
ChargeDetect* mChgDetector;
|
||
|
|
class ThermalEvent {
|
||
|
|
public:
|
||
|
|
ThermalEvent(enum EventType type, ThermalSensor* sensor);
|
||
|
|
ThermalEvent();
|
||
|
|
~ThermalEvent();
|
||
|
|
enum EventType mType;
|
||
|
|
ThermalSensor* mSensor;
|
||
|
|
};
|
||
|
|
std::queue<ThermalEvent*> mEventQueue;
|
||
|
|
};
|
||
|
|
}; // namespace android
|
||
|
|
|
||
|
|
#endif // THERMALMANAGER_H_
|