Home | History | Annotate | Download | only in power
      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 __POWER_HELPER_H__
     31 #define __POWER_HELPER_H__
     32 
     33 #ifdef __cplusplus
     34 extern "C" {
     35 #endif
     36 
     37 #include "hardware/power.h"
     38 
     39 
     40 enum stats_type {
     41     //Platform Stats
     42     RPM_MODE_XO = 0,
     43     RPM_MODE_VMIN,
     44     RPM_MODE_MAX,
     45     XO_VOTERS_START = RPM_MODE_MAX,
     46     VOTER_APSS = XO_VOTERS_START,
     47     VOTER_MPSS,
     48     VOTER_ADSP,
     49     VOTER_SLPI,
     50     MAX_PLATFORM_STATS,
     51 
     52     //WLAN Stats
     53     WLAN_POWER_DEBUG_STATS = 0,
     54     MAX_WLAN_STATS,
     55 };
     56 
     57 enum subsystem_type {
     58     SUBSYSTEM_WLAN = 0,
     59 
     60     //Don't add any lines after this line
     61     SUBSYSTEM_COUNT
     62 };
     63 
     64 enum wlan_sleep_states {
     65     WLAN_STATE_ACTIVE = 0,
     66     WLAN_STATE_DEEP_SLEEP,
     67 
     68     //Don't add any lines after this line
     69     WLAN_STATES_COUNT
     70 };
     71 
     72 enum wlan_power_params {
     73     CUMULATIVE_SLEEP_TIME_MS = 0,
     74     CUMULATIVE_TOTAL_ON_TIME_MS,
     75     DEEP_SLEEP_ENTER_COUNTER,
     76     LAST_DEEP_SLEEP_ENTER_TSTAMP_MS,
     77 
     78     //Don't add any lines after this line
     79     WLAN_POWER_PARAMS_COUNT
     80 };
     81 
     82 
     83 #define PLATFORM_SLEEP_MODES_COUNT RPM_MODE_MAX
     84 
     85 #define MAX_RPM_PARAMS 2
     86 #define XO_VOTERS (MAX_PLATFORM_STATS - XO_VOTERS_START)
     87 #define VMIN_VOTERS 0
     88 
     89 struct stat_pair {
     90     enum stats_type stat;
     91     const char *label;
     92     const char **parameters;
     93     size_t num_parameters;
     94 };
     95 
     96 
     97 void power_init(void);
     98 void power_hint(power_hint_t hint, void *data);
     99 void power_set_interactive(int on);
    100 int extract_platform_stats(uint64_t *list);
    101 int extract_wlan_stats(uint64_t *list);
    102 
    103 int is_perf_hint_active(int hint);
    104 
    105 #ifdef __cplusplus
    106 }
    107 #endif
    108 
    109 #endif //__POWER_HELPER_H__
    110