summaryrefslogtreecommitdiffstats
path: root/thermal-8998.c
blob: 94bf3759971bb1cdb5b236313232c2322e38436d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
 * Not a contribution
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#define LOG_TAG "ThermalHAL-8998"
#include <utils/Log.h>

#include <hardware/hardware.h>
#include <hardware/thermal.h>
#include "thermal_common.h"

static char *cpu_sensors_8998[] =
{
    "tsens_tz_sensor1",
    "tsens_tz_sensor2",
    "tsens_tz_sensor3",
    "tsens_tz_sensor4",
    "tsens_tz_sensor7",
    "tsens_tz_sensor8",
    "tsens_tz_sensor9",
    "tsens_tz_sensor10",
};

static char *misc_sensors_8998[] =
{
    "tsens_tz_sensor12",
    "battery",
    "quiet_therm"
};

static struct target_therm_cfg sensor_cfg_8998[] = {
    {
        .type = DEVICE_TEMPERATURE_CPU,
        .sensor_list = cpu_sensors_8998,
        .sens_cnt = ARRAY_SIZE(cpu_sensors_8998),
        .mult = 0.1,
        .throt_thresh = 60,
        .shutdwn_thresh = 115,
    },
    {
        .type = DEVICE_TEMPERATURE_GPU,
        .sensor_list = &misc_sensors_8998[0],
        .sens_cnt = 1,
        .mult = 0.1,
        .label = "GPU",
    },
    {
        .type = DEVICE_TEMPERATURE_BATTERY,
        .sensor_list = &misc_sensors_8998[1],
        .sens_cnt = 1,
        .mult = 0.001,
        .shutdwn_thresh = 60,
        .label = "battery",
    },
    {
        .type = DEVICE_TEMPERATURE_SKIN,
        .sensor_list = &misc_sensors_8998[2],
        .sens_cnt = 1,
        .mult = 1.0,
        .throt_thresh = 44,
        .shutdwn_thresh = 70,
        .vr_thresh = 58,
        .label = "skin",
    }
};

ssize_t get_temperatures(thermal_module_t *module, temperature_t *list, size_t size) {
    ALOGD("Entering %s",__func__);
    static int thermal_sens_size;

    if (!thermal_sens_size) {
        thermal_sens_size = thermal_zone_init(sensor_cfg_8998,
                                ARRAY_SIZE(sensor_cfg_8998));
        if (thermal_sens_size <= 0) {
            ALOGE("thermal sensor initialization is failed\n");
            thermal_sens_size = 0;
            return 0;
        }
    }

    if (list == NULL)
        return thermal_sens_size;

    return get_temperature_for_all(list, size);
}