You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
52 lines
1.5 KiB
4 months ago
|
/*
|
||
|
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2016-2019. All rights reserved.
|
||
|
* Description: hwc add support for vsync
|
||
|
* Author: Hisilicon
|
||
|
* Created: 2016.08.12
|
||
|
*/
|
||
|
#include"VsyncLoopThread.h"
|
||
|
#include <cutils/properties.h>
|
||
|
#include <log/log.h>
|
||
|
#include "HWCIapiAdapter.h"
|
||
|
namespace android {
|
||
|
VsyncLoopThread::VsyncLoopThread(HWCDisplay &display) :mDisplay(display)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
VsyncLoopThread::~VsyncLoopThread()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
bool VsyncLoopThread::threadLoop()
|
||
|
{
|
||
|
int fd = mDisplay.GetFrameBufferFd();
|
||
|
if (fd < 0) {
|
||
|
ALOGE("VsyncLoopThread framebuffer fd is invalid: %d", fd);
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
bool fakeVsync = property_get_bool("vendor.gfx.hwc.fake.vsync", false);
|
||
|
int64_t curTimeStamp = 0;
|
||
|
unsigned int freshRate = 0;
|
||
|
while (TRUE) {
|
||
|
if (fakeVsync) {
|
||
|
freshRate = NORMAL_FRESH_PER_SECOND;
|
||
|
usleep(SIXTY_HZ_OF_TIME);
|
||
|
curTimeStamp = systemTime(SYSTEM_TIME_MONOTONIC);
|
||
|
} else {
|
||
|
// avoid to invoke ioctl cmd too frequently although it is blocking call
|
||
|
// and DELAY_FRESH_TIME 5000us is abitrary value and less than the fastest fresh time
|
||
|
usleep(DELAY_FRESH_TIME);
|
||
|
curTimeStamp = HWCIapiAdapter::GetInstance().GetVsyncTime(fd, freshRate);
|
||
|
if (curTimeStamp == HWC_INVALID_VSYNC_TIME) {
|
||
|
ALOGE("Wait VBlank failed, try again");
|
||
|
continue;
|
||
|
}
|
||
|
}
|
||
|
mDisplay.Vsync(curTimeStamp, freshRate);
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
} // namespace android
|
||
|
|