forked from CyanogenMod/android_hardware_nvidia_power
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpower.cpp
More file actions
170 lines (147 loc) · 5.29 KB
/
power.cpp
File metadata and controls
170 lines (147 loc) · 5.29 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
* Copyright (C) 2012 The Android Open Source Project
* Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved.
* Copyright (C) 2015 The CyanogenMod 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 "powerHAL"
#include "powerhal.h"
#ifdef ENABLE_SATA_STANDBY_MODE
#include "tegra_sata_hal.h"
#define FOSTER_E_HDD "/dev/block/sda"
#define HDD_STANDBY_TIMEOUT 60
#endif
static struct powerhal_info *pInfo;
static struct input_dev_map input_devs[] = {
{-1, "raydium_ts\n"},
{-1, "touch\n"},
{-1, "touch_fusion\n"}
};
static void shield_power_init(struct power_module *module)
{
if (!pInfo)
pInfo = (powerhal_info*)calloc(1, sizeof(powerhal_info));
// pInfo->input_devs = input_devs;
// pInfo->input_cnt = sizeof(input_devs)/sizeof(struct input_dev_map);
common_power_init(module, pInfo);
}
static char hispeed_freq[10];
static char emc_max[10];
static void shield_power_set_interactive(struct power_module *module, int on)
{
int error = 0;
#ifdef HAVE_TEGRA_LP_CLUSTER
if (on) {
sysfs_write("/sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/no_lp", "1");
sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/hispeed_freq", hispeed_freq);
sysfs_write("/sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/emc_max", emc_max);
}
#endif
common_power_set_interactive(module, pInfo, on);
#ifdef HAVE_TEGRA_LP_CLUSTER
if (!on) {
sysfs_write("/sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/no_lp", "0");
sysfs_write("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", "51000");
memset(hispeed_freq, 0, sizeof(hispeed_freq));
sysfs_read("/sys/devices/system/cpu/cpufreq/interactive/hispeed_freq", hispeed_freq, 10);
sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/hispeed_freq", "510000");
memset(emc_max, 0, sizeof(emc_max));
sysfs_read("/sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/emc_max", emc_max, 10);
sysfs_write("/sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/emc_max", "408000000");
}
#endif
#ifdef ENABLE_SATA_STANDBY_MODE
if (!access(FOSTER_E_HDD, F_OK)) {
/*
* Turn-off Foster HDD at display off
*/
ALOGI("HAL: Display is %s, set HDD to %s standby mode.", on?"on":"off", on?"disable":"enter");
if (on) {
error = hdd_disable_standby_timer();
if (error)
ALOGE("HAL: Failed to set standby timer, error: %d", error);
}
else {
error = hdd_set_standby_timer(HDD_STANDBY_TIMEOUT);
if (error)
ALOGE("HAL: Failed to set standby timer, error: %d", error);
}
}
#endif
}
static void shield_power_hint(struct power_module *module, power_hint_t hint,
void *data)
{
common_power_hint(module, pInfo, hint, data);
}
static int shield_power_open(__attribute__ ((unused)) const hw_module_t *module, const char *name,
__attribute__ ((unused)) hw_device_t **device)
{
if (strcmp(name, POWER_HARDWARE_MODULE_ID))
return -EINVAL;
if (!pInfo) {
pInfo = (powerhal_info*)calloc(1, sizeof(powerhal_info));
common_power_open(pInfo);
}
return 0;
}
static void shield_set_feature(__attribute__ ((unused)) struct power_module *module, feature_t feature, __attribute__ ((unused)) int state)
{
switch (feature) {
case POWER_FEATURE_DOUBLE_TAP_TO_WAKE:
ALOGW("Double tap to wake is not supported\n");
break;
default:
ALOGW("Error setting the feature, it doesn't exist %d\n", feature);
break;
}
}
#if PLATFORM_SDK_VERSION >= 23
static int shield_get_feature(__attribute__ ((unused)) struct power_module *module, feature_t feature)
{
switch (feature) {
case POWER_FEATURE_DOUBLE_TAP_TO_WAKE:
return 0;
case POWER_FEATURE_SUPPORTED_PROFILES:
return 3;
default:
ALOGW("Error setting the feature, it doesn't exist %d\n", feature);
break;
}
return 0;
}
#endif
static struct hw_module_methods_t power_module_methods = {
.open = shield_power_open,
};
struct power_module HAL_MODULE_INFO_SYM = {
.common = {
.tag = HARDWARE_MODULE_TAG,
.module_api_version = POWER_MODULE_API_VERSION_0_3,
.hal_api_version = HARDWARE_HAL_API_VERSION,
.id = POWER_HARDWARE_MODULE_ID,
.name = "Shield Power HAL",
.author = "The CyanogenMod Project",
.methods = &power_module_methods,
.dso = NULL,
.reserved = {0},
},
.init = shield_power_init,
.setInteractive = shield_power_set_interactive,
.powerHint = shield_power_hint,
.setFeature = shield_set_feature,
#if PLATFORM_SDK_VERSION >= 23
.getFeature = shield_get_feature,
#endif
};
static void *reserved[24];