Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b61b061 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "surfaceflinger: remove vsync hint"

parents bb01ca70 2c321757
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -30,7 +30,6 @@ LOCAL_SRC_FILES := \
    DisplayHardware/HWC2.cpp \
    DisplayHardware/HWC2.cpp \
    DisplayHardware/HWComposer.cpp \
    DisplayHardware/HWComposer.cpp \
    DisplayHardware/HWComposerBufferCache.cpp \
    DisplayHardware/HWComposerBufferCache.cpp \
    DisplayHardware/PowerHAL.cpp \
    DisplayHardware/VirtualDisplaySurface.cpp \
    DisplayHardware/VirtualDisplaySurface.cpp \
    Effects/Daltonizer.cpp \
    Effects/Daltonizer.cpp \
    EventLog/EventLogTags.logtags \
    EventLog/EventLogTags.logtags \
@@ -89,7 +88,6 @@ LOCAL_SHARED_LIBRARIES := \
    libbinder \
    libbinder \
    libui \
    libui \
    libgui \
    libgui \
    libpowermanager \
    libvulkan \
    libvulkan \
    libsync \
    libsync \
    libprotobuf-cpp-lite \
    libprotobuf-cpp-lite \
+0 −55
Original line number Original line Diff line number Diff line
/*
 * 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 <android/hardware/power/1.0/IPower.h>
#include <stdint.h>
#include <sys/types.h>

#include <android/log.h>
#include <utils/Errors.h>

#include <binder/IServiceManager.h>
#include <powermanager/IPowerManager.h>
#include <powermanager/PowerManager.h>

#include "PowerHAL.h"

using android::hardware::power::V1_0::PowerHint;
namespace android {
// ---------------------------------------------------------------------------

status_t PowerHAL::vsyncHint(bool enabled) {
    Mutex::Autolock _l(mlock);
    if (mPowerManager == NULL) {
        const String16 serviceName("power");
        sp<IBinder> bs = defaultServiceManager()->checkService(serviceName);
        if (bs == NULL) {
            return NAME_NOT_FOUND;
        }
        mPowerManager = interface_cast<IPowerManager>(bs);
    }
    status_t status;
    status = mPowerManager->powerHint(static_cast<int>(PowerHint::VSYNC),
            enabled ? 1 : 0);
    if(status == DEAD_OBJECT) {
        mPowerManager = NULL;
    }
    return status;
}

// ---------------------------------------------------------------------------
}; // namespace android
+0 −43
Original line number Original line Diff line number Diff line
/*
 * 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 <utils/Mutex.h>

#include <powermanager/IPowerManager.h>
#include <hardware/power.h>

namespace android {
// ---------------------------------------------------------------------------

class PowerHAL
{
public:
    status_t vsyncHint(bool enabled);

private:
    sp<IPowerManager> mPowerManager;
    Mutex mlock;
};

// ---------------------------------------------------------------------------
}; // namespace android

#endif // ANDROID_SF_POWER_HAL_H
+0 −35
Original line number Original line Diff line number Diff line
@@ -34,14 +34,6 @@
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
namespace android {
namespace android {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// time to wait between VSYNC requests before sending a VSYNC OFF power hint: 40msec.
const long vsyncHintOffDelay = 40000000;

static void vsyncOffCallback(union sigval val) {
    EventThread *ev = (EventThread *)val.sival_ptr;
    ev->sendVsyncHintOff();
    return;
}


EventThread::EventThread(const sp<VSyncSource>& src, SurfaceFlinger& flinger, bool interceptVSyncs)
EventThread::EventThread(const sp<VSyncSource>& src, SurfaceFlinger& flinger, bool interceptVSyncs)
    : mVSyncSource(src),
    : mVSyncSource(src),
@@ -49,7 +41,6 @@ EventThread::EventThread(const sp<VSyncSource>& src, SurfaceFlinger& flinger, bo
      mUseSoftwareVSync(false),
      mUseSoftwareVSync(false),
      mVsyncEnabled(false),
      mVsyncEnabled(false),
      mDebugVsyncEnabled(false),
      mDebugVsyncEnabled(false),
      mVsyncHintSent(false),
      mInterceptVSyncs(interceptVSyncs) {
      mInterceptVSyncs(interceptVSyncs) {


    for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) {
    for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) {
@@ -58,18 +49,6 @@ EventThread::EventThread(const sp<VSyncSource>& src, SurfaceFlinger& flinger, bo
        mVSyncEvent[i].header.timestamp = 0;
        mVSyncEvent[i].header.timestamp = 0;
        mVSyncEvent[i].vsync.count =  0;
        mVSyncEvent[i].vsync.count =  0;
    }
    }
    struct sigevent se;
    se.sigev_notify = SIGEV_THREAD;
    se.sigev_value.sival_ptr = this;
    se.sigev_notify_function = vsyncOffCallback;
    se.sigev_notify_attributes = NULL;
    timer_create(CLOCK_MONOTONIC, &se, &mTimerId);
}

void EventThread::sendVsyncHintOff() {
    Mutex::Autolock _l(mLock);
    mPowerHAL.vsyncHint(false);
    mVsyncHintSent = false;
}
}


void EventThread::setPhaseOffset(nsecs_t phaseOffset) {
void EventThread::setPhaseOffset(nsecs_t phaseOffset) {
@@ -77,19 +56,6 @@ void EventThread::setPhaseOffset(nsecs_t phaseOffset) {
    mVSyncSource->setPhaseOffset(phaseOffset);
    mVSyncSource->setPhaseOffset(phaseOffset);
}
}


void EventThread::sendVsyncHintOnLocked() {
    struct itimerspec ts;
    if(!mVsyncHintSent) {
        mPowerHAL.vsyncHint(true);
        mVsyncHintSent = true;
    }
    ts.it_value.tv_sec = 0;
    ts.it_value.tv_nsec = vsyncHintOffDelay;
    ts.it_interval.tv_sec = 0;
    ts.it_interval.tv_nsec = 0;
    timer_settime(mTimerId, 0, &ts, NULL);
}

void EventThread::onFirstRef() {
void EventThread::onFirstRef() {
    run("EventThread", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE);
    run("EventThread", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE);
}
}
@@ -357,7 +323,6 @@ void EventThread::enableVSyncLocked() {
        }
        }
    }
    }
    mDebugVsyncEnabled = true;
    mDebugVsyncEnabled = true;
    sendVsyncHintOnLocked();
}
}


void EventThread::disableVSyncLocked() {
void EventThread::disableVSyncLocked() {
+0 −6
Original line number Original line Diff line number Diff line
@@ -29,7 +29,6 @@
#include <utils/SortedVector.h>
#include <utils/SortedVector.h>


#include "DisplayDevice.h"
#include "DisplayDevice.h"
#include "DisplayHardware/PowerHAL.h"


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
namespace android {
namespace android {
@@ -99,7 +98,6 @@ public:
            DisplayEventReceiver::Event* event);
            DisplayEventReceiver::Event* event);


    void dump(String8& result) const;
    void dump(String8& result) const;
    void sendVsyncHintOff();


    void setPhaseOffset(nsecs_t phaseOffset);
    void setPhaseOffset(nsecs_t phaseOffset);


@@ -112,11 +110,9 @@ private:
    void removeDisplayEventConnection(const wp<Connection>& connection);
    void removeDisplayEventConnection(const wp<Connection>& connection);
    void enableVSyncLocked();
    void enableVSyncLocked();
    void disableVSyncLocked();
    void disableVSyncLocked();
    void sendVsyncHintOnLocked();


    // constants
    // constants
    sp<VSyncSource> mVSyncSource;
    sp<VSyncSource> mVSyncSource;
    PowerHAL mPowerHAL;
    SurfaceFlinger& mFlinger;
    SurfaceFlinger& mFlinger;


    mutable Mutex mLock;
    mutable Mutex mLock;
@@ -132,9 +128,7 @@ private:
    // for debugging
    // for debugging
    bool mDebugVsyncEnabled;
    bool mDebugVsyncEnabled;


    bool mVsyncHintSent;
    const bool mInterceptVSyncs;
    const bool mInterceptVSyncs;
    timer_t mTimerId;
};
};


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------