diff options
author | Ruchi Kandoi <kandoiruchi@google.com> | 2016-10-07 19:29:28 -0700 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2017-11-03 19:36:18 +0000 |
commit | 9b056b6bab9c6b36ff3baa3d84125ef5b7364105 (patch) | |
tree | 30acd2a453fa4df7ea62f876a3395492da97400c | |
parent | 4b0a32464256d18299e09c081dc32fe7a3e2517a (diff) |
power: Make powerHAL compatible for passthrough HIDL design
Bug: 31177288
Change-Id: Ia65f6b50d091a02199565af1d8855ec7473e7323
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
-rw-r--r-- | power/power.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/power/power.c b/power/power.c index 13c0193..3ad2f66 100644 --- a/power/power.c +++ b/power/power.c @@ -58,10 +58,6 @@ static int saved_mpdecision_slack_min = -1; static int slack_node_rw_failed = 0; static int display_hint_sent; -static struct hw_module_methods_t power_module_methods = { - .open = NULL, -}; - static pthread_mutex_t hint_mutex = PTHREAD_MUTEX_INITIALIZER; static void power_init(__attribute__((unused))struct power_module *module) @@ -463,6 +459,46 @@ int get_feature(struct power_module *module __unused, feature_t feature) return -1; } +static int power_open(const hw_module_t* module, const char* name, + hw_device_t** device) +{ + ALOGD("%s: enter; name=%s", __FUNCTION__, name); + int retval = 0; /* 0 is ok; -1 is error */ + + if (strcmp(name, POWER_HARDWARE_MODULE_ID) == 0) { + power_module_t *dev = (power_module_t *)calloc(1, + sizeof(power_module_t)); + + if (dev) { + /* Common hw_device_t fields */ + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.module_api_version = POWER_MODULE_API_VERSION_0_3; + dev->common.hal_api_version = HARDWARE_HAL_API_VERSION; + + dev->init = power_init; + dev->powerHint = power_hint; + dev->setInteractive = set_interactive; + dev->setFeature = set_feature; + dev->getFeature = get_feature; + dev->get_number_of_platform_modes = NULL; + dev->get_platform_low_power_stats = NULL; + dev->get_voter_list = NULL; + + *device = (hw_device_t*)dev; + } else + retval = -ENOMEM; + } else { + retval = -EINVAL; + } + + ALOGD("%s: exit %d", __FUNCTION__, retval); + return retval; +} + +static struct hw_module_methods_t power_module_methods = { + .open = power_open, +}; + struct power_module HAL_MODULE_INFO_SYM = { .common = { .tag = HARDWARE_MODULE_TAG, |