blob: a5a6f27590b56551e7be7ccf8ca520ea49158c6c [file] [log] [blame]
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -07001/*
2 * Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
dianlujitao5ec37732018-01-18 21:24:30 +08003 * Copyright (C) 2017-2018 The LineageOS Project
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -07004 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 * * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution.
14 * * Neither the name of The Linux Foundation nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
25 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef __POWER_HELPER_H__
32#define __POWER_HELPER_H__
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#include "hardware/power.h"
39
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +020040#ifdef LEGACY_STATS
41enum platform_param_id {
42 VLOW_COUNT = 0,
43 ACCUMULATED_VLOW_TIME,
44 VMIN_COUNT,
45 ACCUMULATED_VMIN_TIME,
46 RPM_PARAM_COUNT,
47
48 XO_ACCUMULATED_DURATION_APSS = RPM_PARAM_COUNT,
49 XO_COUNT_APSS,
50 XO_ACCUMULATED_DURATION_MPSS,
51 XO_COUNT_MPSS,
52 XO_ACCUMULATED_DURATION_ADSP,
53 XO_COUNT_ADSP,
54 XO_ACCUMULATED_DURATION_SLPI,
55 XO_COUNT_SLPI,
56
57 //Don't add any lines after that line
58 PLATFORM_PARAM_COUNT
59};
60#endif
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070061
62enum stats_type {
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +020063 //Platform Stats
64 RPM_MODE_XO = 0,
65 RPM_MODE_VMIN,
66 RPM_MODE_MAX,
67 XO_VOTERS_START = RPM_MODE_MAX,
68 VOTER_APSS = XO_VOTERS_START,
69 VOTER_MPSS,
70 VOTER_ADSP,
71 VOTER_SLPI,
Michael Bestas3e0af9c2018-06-09 23:05:31 +030072 VOTER_PRONTO,
73 VOTER_TZ,
74 VOTER_LPASS,
75 VOTER_SPSS,
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +020076 MAX_PLATFORM_STATS,
77
Rashed Abdel-Tawabbd767ce2018-09-17 12:14:16 -070078#ifndef NO_WLAN_STATS
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070079 //WLAN Stats
80 WLAN_POWER_DEBUG_STATS = 0,
81 MAX_WLAN_STATS,
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +020082#endif
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070083};
84
Rashed Abdel-Tawabbd767ce2018-09-17 12:14:16 -070085#ifndef NO_WLAN_STATS
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -070086enum subsystem_type {
87 SUBSYSTEM_WLAN = 0,
88
89 //Don't add any lines after this line
90 SUBSYSTEM_COUNT
91};
92
93enum wlan_sleep_states {
94 WLAN_STATE_ACTIVE = 0,
95 WLAN_STATE_DEEP_SLEEP,
96
97 //Don't add any lines after this line
98 WLAN_STATES_COUNT
99};
100
101enum wlan_power_params {
102 CUMULATIVE_SLEEP_TIME_MS = 0,
103 CUMULATIVE_TOTAL_ON_TIME_MS,
104 DEEP_SLEEP_ENTER_COUNTER,
105 LAST_DEEP_SLEEP_ENTER_TSTAMP_MS,
106
107 //Don't add any lines after this line
108 WLAN_POWER_PARAMS_COUNT
109};
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +0200110#endif
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -0700111
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +0200112#define PLATFORM_SLEEP_MODES_COUNT RPM_MODE_MAX
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -0700113
114#define MAX_RPM_PARAMS 2
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +0200115#ifdef LEGACY_STATS
116#define XO_VOTERS 4
117#else
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -0700118#define XO_VOTERS (MAX_PLATFORM_STATS - XO_VOTERS_START)
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +0200119#endif
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -0700120#define VMIN_VOTERS 0
121
122struct stat_pair {
123 enum stats_type stat;
124 const char *label;
125 const char **parameters;
126 size_t num_parameters;
127};
128
129
130void power_init(void);
131void power_hint(power_hint_t hint, void *data);
132void power_set_interactive(int on);
133void set_feature(feature_t feature, int state);
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +0200134int extract_platform_stats(uint64_t *list);
Rashed Abdel-Tawabbd767ce2018-09-17 12:14:16 -0700135#ifndef NO_WLAN_STATS
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -0700136int extract_wlan_stats(uint64_t *list);
Rashed Abdel-Tawab067a9072017-12-30 00:41:49 +0200137#endif
dianlujitao5ec37732018-01-18 21:24:30 +0800138int __attribute__ ((weak)) get_number_of_profiles();
Rashed Abdel-Tawab00b21852017-11-03 12:44:16 -0700139
140#ifdef __cplusplus
141}
142#endif
143
144#endif //__POWER_HELPER_H__