set vsync power hint
Change-Id: I28c2faf9ff584df3e74392712971cbcf75eb9e98
This commit is contained in:
parent
627f471812
commit
03e407270c
|
@ -10,6 +10,7 @@ LOCAL_SRC_FILES:= \
|
|||
DisplayHardware/DisplayHardware.cpp \
|
||||
DisplayHardware/DisplayHardwareBase.cpp \
|
||||
DisplayHardware/HWComposer.cpp \
|
||||
DisplayHardware/PowerHAL.cpp \
|
||||
GLExtensions.cpp \
|
||||
MessageQueue.cpp \
|
||||
SurfaceFlinger.cpp \
|
||||
|
|
|
@ -358,6 +358,13 @@ void DisplayHardware::setVSyncHandler(const sp<VSyncHandler>& handler) {
|
|||
mVSyncHandler = handler;
|
||||
}
|
||||
|
||||
void DisplayHardware::eventControl(int event, int enabled) {
|
||||
if (event == EVENT_VSYNC) {
|
||||
mPowerHAL.vsyncHint(enabled);
|
||||
}
|
||||
mHwc->eventControl(event, enabled);
|
||||
}
|
||||
|
||||
void DisplayHardware::onVSyncReceived(int dpy, nsecs_t timestamp) {
|
||||
sp<VSyncHandler> handler;
|
||||
{ // scope for the lock
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "DisplayHardware/DisplayHardwareBase.h"
|
||||
#include "HWComposer.h"
|
||||
#include "PowerHAL.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
|
@ -86,6 +87,12 @@ public:
|
|||
|
||||
void setVSyncHandler(const sp<VSyncHandler>& handler);
|
||||
|
||||
enum {
|
||||
EVENT_VSYNC = HWC_EVENT_VSYNC
|
||||
};
|
||||
|
||||
void eventControl(int event, int enabled);
|
||||
|
||||
|
||||
uint32_t getPageFlipCount() const;
|
||||
EGLDisplay getEGLDisplay() const { return mDisplay; }
|
||||
|
@ -129,6 +136,8 @@ private:
|
|||
|
||||
// constant once set
|
||||
HWComposer* mHwc;
|
||||
PowerHAL mPowerHAL;
|
||||
|
||||
|
||||
mutable Mutex mLock;
|
||||
|
||||
|
|
|
@ -125,19 +125,21 @@ void HWComposer::vsync(int dpy, int64_t timestamp) {
|
|||
mEventHandler.onVSyncReceived(dpy, timestamp);
|
||||
}
|
||||
|
||||
status_t HWComposer::eventControl(int event, int enabled) {
|
||||
void HWComposer::eventControl(int event, int enabled) {
|
||||
status_t err = NO_ERROR;
|
||||
if (mHwc && mHwc->common.version >= HWC_DEVICE_API_VERSION_0_3) {
|
||||
if (!mDebugForceFakeVSync) {
|
||||
err = mHwc->methods->eventControl(mHwc, event, enabled);
|
||||
// error here should not happen -- not sure what we should
|
||||
// do if it does.
|
||||
ALOGE_IF(err, "eventControl(%d, %d) failed %s",
|
||||
event, enabled, strerror(-err));
|
||||
}
|
||||
}
|
||||
|
||||
if (err == NO_ERROR && mVSyncThread != NULL) {
|
||||
mVSyncThread->setEnabled(enabled);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void HWComposer::setFrameBuffer(EGLDisplay dpy, EGLSurface sur) {
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
EVENT_VSYNC = HWC_EVENT_VSYNC
|
||||
};
|
||||
|
||||
status_t eventControl(int event, int enabled);
|
||||
void eventControl(int event, int enabled);
|
||||
|
||||
// this class is only used to fake the VSync event on systems that don't
|
||||
// have it.
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 2012 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <cutils/log.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
#include "PowerHAL.h"
|
||||
|
||||
namespace android {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
PowerHAL::PowerHAL() : mPowerModule(0) {
|
||||
int err = hw_get_module(POWER_HARDWARE_MODULE_ID,
|
||||
(const hw_module_t **)&mPowerModule);
|
||||
ALOGW_IF(err, "%s module not found", POWER_HARDWARE_MODULE_ID);
|
||||
}
|
||||
|
||||
PowerHAL::~PowerHAL() {
|
||||
}
|
||||
|
||||
status_t PowerHAL::initCheck() const {
|
||||
return mPowerModule ? NO_ERROR : NO_INIT;
|
||||
}
|
||||
|
||||
status_t PowerHAL::vsyncHint(bool enabled) {
|
||||
if (!mPowerModule) {
|
||||
return NO_INIT;
|
||||
}
|
||||
if (mPowerModule->common.module_api_version >= POWER_MODULE_API_VERSION_0_2) {
|
||||
if (mPowerModule->powerHint) {
|
||||
mPowerModule->powerHint(mPowerModule, POWER_HINT_VSYNC, (void*)enabled);
|
||||
}
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
}; // namespace android
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2012 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_SF_POWER_HAL_H
|
||||
#define ANDROID_SF_POWER_HAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <hardware/power.h>
|
||||
|
||||
namespace android {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class PowerHAL
|
||||
{
|
||||
public:
|
||||
PowerHAL();
|
||||
~PowerHAL();
|
||||
|
||||
status_t initCheck() const;
|
||||
status_t vsyncHint(bool enabled);
|
||||
|
||||
private:
|
||||
power_module_t* mPowerModule;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_SF_POWER_HAL_H
|
|
@ -253,13 +253,13 @@ bool EventThread::threadLoop() {
|
|||
void EventThread::enableVSyncLocked() {
|
||||
if (!mUseSoftwareVSync) {
|
||||
// never enable h/w VSYNC when screen is off
|
||||
mHw.getHwComposer().eventControl(HWComposer::EVENT_VSYNC, true);
|
||||
mHw.eventControl(DisplayHardware::EVENT_VSYNC, true);
|
||||
}
|
||||
mDebugVsyncEnabled = true;
|
||||
}
|
||||
|
||||
void EventThread::disableVSyncLocked() {
|
||||
mHw.getHwComposer().eventControl(HWComposer::EVENT_VSYNC, false);
|
||||
mHw.eventControl(DisplayHardware::EVENT_VSYNC, false);
|
||||
mDebugVsyncEnabled = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue