blob: ef585114939792aa2734c7ac41ea7e32f18d1e04 [file] [log] [blame]
// Copyright 2015 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THERMALD_THERMAL_ZONE_H_
#define THERMALD_THERMAL_ZONE_H_
#include <limits>
#include <map>
#include <string>
#include <vector>
namespace thermald {
enum {
kTemp0K = -273150,
kTempInfinite = std::numeric_limits<int>::max(),
};
// A thermal zone is a physical area on the device which is monitored through
// periodic sampling of the temperature at one or more thermal points. At any
// given moment a zone is in a certain thermal state.
//
// Thermal states are characterized by their level of criticality, their
// thresholds for the thermal points of the zone and the actions to be executed
// when the state is entered. The enumeration of the thermal states starts with
// 1 for the least critical ("coolest") state and increases towards the most
// critical state. Id 0 is reserved for the initial state.
//
// For each sensor two threshold values can be configured (per thermal state):
// an activation threshold for a transition from a less critical state and a
// bottom (or hysteresis) threshold for a transition from the current to a less
// critical state. If a thermal state does not define thresholds for a certain
// sensor of the zone the state can be entered regardless of the temperature
// of the termal point.
//
// When a thermal state is entered it can set one or more output values.
// These values are of integer type and are identified by a key. The thermal
// daemon may drive actions based on the values of these variables.
struct ThermalPointThresholds {
int activation;
int bottom;
};
struct ThermalStateOutput {
std::string key;
int value;
};
struct ThermalState {
unsigned int id;
// Thresholds for all thermal points of the state.
std::map<std::string, ThermalPointThresholds> thresholds;
// Output values set when the state is entered.
std::vector<ThermalStateOutput> outputs;
};
struct ThermalZone {
std::string name;
// The thermal states of the zone.
//
// NOTE: the ThermalStateEngine requires these states to be ordered
// by descending criticality (from higher to lower temperatures).
std::vector<std::unique_ptr<ThermalState>> states;
};
} // namespace thermald
#endif // THERMALD_THERMAL_ZONE_H_