1/* 2// Copyright (c) 2014 Intel Corporation 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#ifndef VSYNC_MANAGER_H 17#define VSYNC_MANAGER_H 18 19#include <IDisplayDevice.h> 20#include <utils/threads.h> 21 22namespace android { 23namespace intel { 24 25 26class Hwcomposer; 27 28class VsyncManager { 29public: 30 VsyncManager(Hwcomposer& hwc); 31 virtual ~VsyncManager(); 32 33public: 34 bool initialize(); 35 void deinitialize(); 36 bool handleVsyncControl(int disp, bool enabled); 37 void resetVsyncSource(); 38 int getVsyncSource(); 39 void enableDynamicVsync(bool enable); 40 41private: 42 inline int getCandidate(); 43 inline bool enableVsync(int candidate); 44 inline void disableVsync(); 45 IDisplayDevice* getDisplayDevice(int dispType); 46 47private: 48 Hwcomposer &mHwc; 49 bool mInitialized; 50 bool mEnableDynamicVsync; 51 bool mEnabled; 52 int mVsyncSource; 53 Mutex mLock; 54 55private: 56 // toggle this constant to use primary vsync only or enable dynamic vsync. 57 static const bool scUsePrimaryVsyncOnly = false; 58}; 59 60} // namespace intel 61} // namespace android 62 63 64 65#endif /* VSYNC_MANAGER_H */ 66