Home | History | Annotate | Download | only in DisplayHardware
      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 
     17 #include <stdint.h>
     18 #include <sys/types.h>
     19 
     20 #include <cutils/log.h>
     21 #include <utils/Errors.h>
     22 
     23 #include "PowerHAL.h"
     24 
     25 namespace android {
     26 // ---------------------------------------------------------------------------
     27 
     28 PowerHAL::PowerHAL() : mPowerModule(0), mVSyncHintEnabled(false) {
     29     int err = hw_get_module(POWER_HARDWARE_MODULE_ID,
     30             (const hw_module_t **)&mPowerModule);
     31     ALOGW_IF(err, "%s module not found", POWER_HARDWARE_MODULE_ID);
     32 }
     33 
     34 PowerHAL::~PowerHAL() {
     35 }
     36 
     37 status_t PowerHAL::initCheck() const {
     38     return mPowerModule ? NO_ERROR : NO_INIT;
     39 }
     40 
     41 status_t PowerHAL::vsyncHint(bool enabled) {
     42     if (!mPowerModule) {
     43         return NO_INIT;
     44     }
     45     if (mPowerModule->common.module_api_version >= POWER_MODULE_API_VERSION_0_2) {
     46         if (mPowerModule->powerHint) {
     47             if (mVSyncHintEnabled != bool(enabled)) {
     48                 mPowerModule->powerHint(mPowerModule,
     49                         POWER_HINT_VSYNC, (void*)enabled);
     50                 mVSyncHintEnabled = bool(enabled);
     51             }
     52         }
     53     }
     54     return NO_ERROR;
     55 }
     56 
     57 // ---------------------------------------------------------------------------
     58 }; // namespace android
     59 
     60