power.c revision 868f7635b2b57d883a3978b3837a58aecc0d7131
1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16#include <errno.h> 17#include <string.h> 18#include <sys/types.h> 19#include <sys/stat.h> 20#include <sys/socket.h> 21#include <sys/un.h> 22#include <fcntl.h> 23#include <dlfcn.h> 24 25#define LOG_TAG "Qualcomm PowerHAL" 26#include <utils/Log.h> 27 28#include <hardware/hardware.h> 29#include <hardware/power.h> 30#define TOUCHBOOST_SOCKET "/dev/socket/mpdecision/touchboost" 31 32static void power_init(struct power_module *module) 33{ 34} 35 36static void power_set_interactive(struct power_module *module, int on) 37{ 38} 39 40static void touch_boost() 41{ 42 static int client_comsoc = -1; 43 static struct sockaddr_un client_addr; 44 int rc = 0; 45 46 client_comsoc = socket(PF_UNIX, SOCK_DGRAM, 0); 47 48 if (client_comsoc < 0) { 49 return; 50 } 51 52 memset(&client_addr, 0, sizeof(struct sockaddr_un)); 53 client_addr.sun_family = AF_UNIX; 54 snprintf(client_addr.sun_path, UNIX_PATH_MAX, TOUCHBOOST_SOCKET); 55 56 rc = sendto(client_comsoc, "1", 1, 0, (const struct sockaddr *)&client_addr, sizeof(struct sockaddr_un)); 57 58 if (rc == -1) { 59 ALOGE("Failed to send rc=%d", rc); 60 } 61 62 if (client_comsoc >= 0) { 63 close(client_comsoc); 64 client_comsoc = -1; 65 } 66} 67 68static void power_hint(struct power_module *module, power_hint_t hint, 69 void *data) { 70 switch (hint) { 71 72 case POWER_HINT_INTERACTION: 73 touch_boost(); 74 break; 75 default: 76 break; 77 } 78} 79 80static struct hw_module_methods_t power_module_methods = { 81 .open = NULL, 82}; 83 84struct power_module HAL_MODULE_INFO_SYM = { 85 .common = { 86 .tag = HARDWARE_MODULE_TAG, 87 .module_api_version = POWER_MODULE_API_VERSION_0_2, 88 .hal_api_version = HARDWARE_HAL_API_VERSION, 89 .id = POWER_HARDWARE_MODULE_ID, 90 .name = "Qualcomm Power HAL", 91 .author = "The Android Open Source Project", 92 .methods = &power_module_methods, 93 }, 94 95 .init = power_init, 96 .setInteractive = power_set_interactive, 97 .powerHint = power_hint, 98}; 99