mdp_version.cpp revision 29a26818d7294055539167b2fbfdaa168bcf725c
129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/*
229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Redistribution and use in source and binary forms, with or without
529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * modification, are permitted provided that the following conditions are
629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * met:
729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *   * Redistributions of source code must retain the above copyright
829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *     notice, this list of conditions and the following disclaimer.
929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *   * Redistributions in binary form must reproduce the above
1029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *     copyright notice, this list of conditions and the following
1129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *     disclaimer in the documentation and/or other materials provided
1229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *     with the distribution.
1329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *   * Neither the name of Code Aurora Forum, Inc. nor the names of its
1429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *     contributors may be used to endorse or promote products derived
1529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *     from this software without specific prior written permission.
1629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed *
1729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
1829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
2029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
2129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
2429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
2629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
2729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed */
2929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#ifndef INCLUDE_IDLEINVALIDATOR
3129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define INCLUDE_IDLEINVALIDATOR
3229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <cutils/log.h>
3429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <utils/threads.h>
3529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtypedef void (*InvalidatorHandler)(void*);
3729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass IdleInvalidator : public android::Thread {
3929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    void *mHwcContext;
4029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    bool mSleepAgain;
4129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    unsigned int mSleepTime;
4229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    static InvalidatorHandler mHandler;
4329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    static android::sp<IdleInvalidator> sInstance;
4429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
4529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    public:
4629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    IdleInvalidator();
4729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* init timer obj */
4829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    int init(InvalidatorHandler reg_handler, void* user_data, unsigned int
4929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed             idleSleepTime);
5029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    void markForSleep();
5129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /*Overrides*/
5229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    virtual bool        threadLoop();
5329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    virtual int         readyToRun();
5429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    virtual void        onFirstRef();
5529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    static IdleInvalidator *getInstance();
5629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed};
5729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
5829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#endif // INCLUDE_IDLEINVALIDATOR
59