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

Commit 570c5f55 authored by Huihong Luo's avatar Huihong Luo Committed by Android (Google) Code Review
Browse files

Merge "Add a new api to support HDCP" into main

parents dc74779c 817ebb81
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ using AidlDisplayCapability = aidl::android::hardware::graphics::composer3::Disp
using AidlHdrCapabilities = aidl::android::hardware::graphics::composer3::HdrCapabilities;
using AidlHdrConversionCapability =
        aidl::android::hardware::graphics::common::HdrConversionCapability;
using AidlHdcpLevels = aidl::android::hardware::drm::HdcpLevels;
using AidlHdrConversionStrategy = aidl::android::hardware::graphics::common::HdrConversionStrategy;
using AidlOverlayProperties = aidl::android::hardware::graphics::composer3::OverlayProperties;
using AidlPerFrameMetadata = aidl::android::hardware::graphics::composer3::PerFrameMetadata;
@@ -223,6 +224,12 @@ public:
        return ::ndk::ScopedAStatus::ok();
    }

    ::ndk::ScopedAStatus onHdcpLevelsChanged(int64_t in_display,
                                             const AidlHdcpLevels& levels) override {
        mCallback.onComposerHalHdcpLevelsChanged(translate<Display>(in_display), levels);
        return ::ndk::ScopedAStatus::ok();
    }

private:
    HWC2::ComposerCallback& mCallback;
};
+2 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ class Layer;

namespace hal = android::hardware::graphics::composer::hal;

using aidl::android::hardware::drm::HdcpLevels;
using aidl::android::hardware::graphics::common::DisplayHotplugEvent;
using aidl::android::hardware::graphics::composer3::RefreshRateChangedDebugData;

@@ -85,6 +86,7 @@ struct ComposerCallback {
    virtual void onComposerHalSeamlessPossible(hal::HWDisplayId) = 0;
    virtual void onComposerHalVsyncIdle(hal::HWDisplayId) = 0;
    virtual void onRefreshRateChangedDebug(const RefreshRateChangedDebugData&) = 0;
    virtual void onComposerHalHdcpLevelsChanged(hal::HWDisplayId, const HdcpLevels& levels) = 0;

protected:
    ~ComposerCallback() = default;
+17 −4
Original line number Diff line number Diff line
@@ -2175,7 +2175,8 @@ void SurfaceFlinger::onComposerHalVsync(hal::HWDisplayId hwcDisplayId, int64_t t
        // use ~0 instead of -1 as AidlComposerHal.cpp passes the param as unsigned int32
        if (mIsHotplugErrViaNegVsync && vsyncPeriod.value() == ~0) {
            const auto errorCode = static_cast<int32_t>(-timestamp);
            ALOGD("%s: Hotplug error %d for display %" PRIu64, __func__, errorCode, hwcDisplayId);
            ALOGD("%s: Hotplug error %d for hwcDisplayId %" PRIu64, __func__, errorCode,
                  hwcDisplayId);
            mScheduler->dispatchHotplugError(errorCode);
            return;
        }
@@ -2185,8 +2186,8 @@ void SurfaceFlinger::onComposerHalVsync(hal::HWDisplayId hwcDisplayId, int64_t t
            // one byte is good enough to encode android.hardware.drm.HdcpLevel
            const int32_t maxLevel = (value >> 8) & 0xFF;
            const int32_t connectedLevel = value & 0xFF;
            ALOGD("%s: HDCP levels changed (connected=%d, max=%d) for display %" PRIu64, __func__,
                  connectedLevel, maxLevel, hwcDisplayId);
            ALOGD("%s: HDCP levels changed (connected=%d, max=%d) for hwcDisplayId %" PRIu64,
                  __func__, connectedLevel, maxLevel, hwcDisplayId);
            updateHdcpLevels(hwcDisplayId, connectedLevel, maxLevel);
            return;
        }
@@ -2226,7 +2227,7 @@ void SurfaceFlinger::onComposerHalHotplugEvent(hal::HWDisplayId hwcDisplayId,
    if (FlagManager::getInstance().hotplug2()) {
        // TODO(b/311403559): use enum type instead of int
        const auto errorCode = static_cast<int32_t>(event);
        ALOGD("%s: Hotplug error %d for display %" PRIu64, __func__, errorCode, hwcDisplayId);
        ALOGD("%s: Hotplug error %d for hwcDisplayId %" PRIu64, __func__, errorCode, hwcDisplayId);
        mScheduler->dispatchHotplugError(errorCode);
    }
}
@@ -2276,6 +2277,18 @@ void SurfaceFlinger::onRefreshRateChangedDebug(const RefreshRateChangedDebugData
    }));
}

void SurfaceFlinger::onComposerHalHdcpLevelsChanged(hal::HWDisplayId hwcDisplayId,
                                                    const HdcpLevels& levels) {
    if (FlagManager::getInstance().hdcp_level_hal()) {
        // TODO(b/362270040): propagate enum constants
        const int32_t maxLevel = static_cast<int32_t>(levels.maxLevel);
        const int32_t connectedLevel = static_cast<int32_t>(levels.connectedLevel);
        ALOGD("%s: HDCP levels changed (connected=%d, max=%d) for hwcDisplayId %" PRIu64, __func__,
              connectedLevel, maxLevel, hwcDisplayId);
        updateHdcpLevels(hwcDisplayId, connectedLevel, maxLevel);
    }
}

void SurfaceFlinger::configure() {
    Mutex::Autolock lock(mStateLock);
    if (configureLocked()) {
+2 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ class FrameTracer;
class ScreenCapturer;
class WindowInfosListenerInvoker;

using ::aidl::android::hardware::drm::HdcpLevels;
using ::aidl::android::hardware::graphics::common::DisplayHotplugEvent;
using ::aidl::android::hardware::graphics::composer3::RefreshRateChangedDebugData;
using frontend::TransactionHandler;
@@ -671,6 +672,7 @@ private:
    void onComposerHalSeamlessPossible(hal::HWDisplayId) override;
    void onComposerHalVsyncIdle(hal::HWDisplayId) override;
    void onRefreshRateChangedDebug(const RefreshRateChangedDebugData&) override;
    void onComposerHalHdcpLevelsChanged(hal::HWDisplayId, const HdcpLevels& levels) override;

    // ICompositor overrides:
    void configure() override REQUIRES(kMainThreadContext);
+3 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ using namespace std::chrono_literals;

using Hwc2::Config;

using ::aidl::android::hardware::drm::HdcpLevels;
using ::aidl::android::hardware::graphics::common::DisplayHotplugEvent;
using ::aidl::android::hardware::graphics::composer3::RefreshRateChangedDebugData;
using hal::IComposerClient;
@@ -454,6 +455,8 @@ struct MockHWC2ComposerCallback final : StrictMock<HWC2::ComposerCallback> {
    MOCK_METHOD1(onComposerHalSeamlessPossible, void(hal::HWDisplayId));
    MOCK_METHOD1(onComposerHalVsyncIdle, void(hal::HWDisplayId));
    MOCK_METHOD(void, onRefreshRateChangedDebug, (const RefreshRateChangedDebugData&), (override));
    MOCK_METHOD(void, onComposerHalHdcpLevelsChanged, (hal::HWDisplayId, const HdcpLevels&),
                (override));
};

struct HWComposerSetCallbackTest : HWComposerTest {