diff options
author | 2021-02-16 19:38:36 +0100 | |
---|---|---|
committer | 2021-02-23 13:13:58 +0100 | |
commit | b173f7599a8f93786342d27167facf7eae02845e (patch) | |
tree | f13d93cfb55b70020880b458b778df40d219ab89 | |
parent | 228f46b5b9c3eac674aceb579a718cd459165f2e (diff) |
SF: Move ALLM and GameContentType to DynamicDisplayInfo
ALLM and Game content type support may change after a hotplug,
for that reason we move them to DynamicDisplayInfo.
Bug: 180108954
Test: flash a device and manually test that the values are
properly piped to DisplayManager
Change-Id: I05810c620b241e204d2c01618bb8a4069c41d32d
-rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 70 | ||||
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 12 | ||||
-rw-r--r-- | libs/gui/include/gui/ISurfaceComposer.h | 27 | ||||
-rw-r--r-- | libs/gui/include/gui/SurfaceComposerClient.h | 6 | ||||
-rw-r--r-- | libs/gui/tests/Surface_test.cpp | 8 | ||||
-rw-r--r-- | libs/ui/DynamicDisplayInfo.cpp | 8 | ||||
-rw-r--r-- | libs/ui/include/ui/DynamicDisplayInfo.h | 8 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 50 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 4 |
9 files changed, 31 insertions, 162 deletions
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 2e4f858a9d..eba7b3c9fd 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -411,24 +411,6 @@ public: return static_cast<status_t>(reply.readInt32()); } - status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display, - bool* outSupport) const override { - Parcel data, reply; - data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); - status_t result = data.writeStrongBinder(display); - if (result != NO_ERROR) { - ALOGE("getAutoLowLatencyModeSupport failed to writeStrongBinder: %d", result); - return result; - } - result = remote()->transact(BnSurfaceComposer::GET_AUTO_LOW_LATENCY_MODE_SUPPORT, data, - &reply); - if (result != NO_ERROR) { - ALOGE("getAutoLowLatencyModeSupport failed to transact: %d", result); - return result; - } - return reply.readBool(outSupport); - } - void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) override { Parcel data, reply; status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); @@ -454,23 +436,6 @@ public: } } - status_t getGameContentTypeSupport(const sp<IBinder>& display, - bool* outSupport) const override { - Parcel data, reply; - data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); - status_t result = data.writeStrongBinder(display); - if (result != NO_ERROR) { - ALOGE("getGameContentTypeSupport failed to writeStrongBinder: %d", result); - return result; - } - result = remote()->transact(BnSurfaceComposer::GET_GAME_CONTENT_TYPE_SUPPORT, data, &reply); - if (result != NO_ERROR) { - ALOGE("getGameContentTypeSupport failed to transact: %d", result); - return result; - } - return reply.readBool(outSupport); - } - void setGameContentType(const sp<IBinder>& display, bool on) override { Parcel data, reply; status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); @@ -1423,23 +1388,6 @@ status_t BnSurfaceComposer::onTransact( result = reply->writeInt32(result); return result; } - - case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: { - CHECK_INTERFACE(ISurfaceComposer, data, reply); - sp<IBinder> display = nullptr; - status_t result = data.readStrongBinder(&display); - if (result != NO_ERROR) { - ALOGE("getAutoLowLatencyModeSupport failed to readStrongBinder: %d", result); - return result; - } - bool supported = false; - result = getAutoLowLatencyModeSupport(display, &supported); - if (result == NO_ERROR) { - result = reply->writeBool(supported); - } - return result; - } - case SET_AUTO_LOW_LATENCY_MODE: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = nullptr; @@ -1457,23 +1405,6 @@ status_t BnSurfaceComposer::onTransact( setAutoLowLatencyMode(display, setAllm); return result; } - - case GET_GAME_CONTENT_TYPE_SUPPORT: { - CHECK_INTERFACE(ISurfaceComposer, data, reply); - sp<IBinder> display = nullptr; - status_t result = data.readStrongBinder(&display); - if (result != NO_ERROR) { - ALOGE("getGameContentTypeSupport failed to readStrongBinder: %d", result); - return result; - } - bool supported = false; - result = getGameContentTypeSupport(display, &supported); - if (result == NO_ERROR) { - result = reply->writeBool(supported); - } - return result; - } - case SET_GAME_CONTENT_TYPE: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = nullptr; @@ -1491,7 +1422,6 @@ status_t BnSurfaceComposer::onTransact( setGameContentType(display, setGameContentTypeOn); return result; } - case CLEAR_ANIMATION_FRAME_STATS: { CHECK_INTERFACE(ISurfaceComposer, data, reply); status_t result = clearAnimationFrameStats(); diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 0bd2c8811b..f78c12e61e 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -1876,22 +1876,10 @@ status_t SurfaceComposerClient::setActiveColorMode(const sp<IBinder>& display, return ComposerService::getComposerService()->setActiveColorMode(display, colorMode); } -bool SurfaceComposerClient::getAutoLowLatencyModeSupport(const sp<IBinder>& display) { - bool supported = false; - ComposerService::getComposerService()->getAutoLowLatencyModeSupport(display, &supported); - return supported; -} - void SurfaceComposerClient::setAutoLowLatencyMode(const sp<IBinder>& display, bool on) { ComposerService::getComposerService()->setAutoLowLatencyMode(display, on); } -bool SurfaceComposerClient::getGameContentTypeSupport(const sp<IBinder>& display) { - bool supported = false; - ComposerService::getComposerService()->getGameContentTypeSupport(display, &supported); - return supported; -} - void SurfaceComposerClient::setGameContentType(const sp<IBinder>& display, bool on) { ComposerService::getComposerService()->setGameContentType(display, on); } diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h index d0ab4802e1..6289e5a5d0 100644 --- a/libs/gui/include/gui/ISurfaceComposer.h +++ b/libs/gui/include/gui/ISurfaceComposer.h @@ -219,32 +219,17 @@ public: ui::ColorMode colorMode) = 0; /** - * Returns true if the connected display reports support for HDMI 2.1 Auto - * Low Latency Mode. - * For more information, see the HDMI 2.1 specification. - */ - virtual status_t getAutoLowLatencyModeSupport(const sp<IBinder>& display, - bool* outSupport) const = 0; - - /** * Switches Auto Low Latency Mode on/off on the connected display, if it is - * available. This should only be called if #getAutoLowLatencyMode returns - * true. + * available. This should only be called if the display supports Auto Low + * Latency Mode as reported in #getDynamicDisplayInfo. * For more information, see the HDMI 2.1 specification. */ virtual void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) = 0; /** - * Returns true if the connected display reports support for Game Content Type. - * For more information, see the HDMI 1.4 specification. - */ - virtual status_t getGameContentTypeSupport(const sp<IBinder>& display, - bool* outSupport) const = 0; - - /** * This will start sending infoframes to the connected display with - * ContentType=Game (if on=true). This will switch the disply to Game mode. - * This should only be called if #getGameContentTypeSupport returns true. + * ContentType=Game (if on=true). This should only be called if the display + * Game Content Type as reported in #getDynamicDisplayInfo. * For more information, see the HDMI 1.4 specification. */ virtual void setGameContentType(const sp<IBinder>& display, bool on) = 0; @@ -563,9 +548,9 @@ public: CAPTURE_DISPLAY_BY_ID, NOTIFY_POWER_BOOST, SET_GLOBAL_SHADOW_SETTINGS, - GET_AUTO_LOW_LATENCY_MODE_SUPPORT, + GET_AUTO_LOW_LATENCY_MODE_SUPPORT, // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead. SET_AUTO_LOW_LATENCY_MODE, - GET_GAME_CONTENT_TYPE_SUPPORT, + GET_GAME_CONTENT_TYPE_SUPPORT, // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead. SET_GAME_CONTENT_TYPE, SET_FRAME_RATE, ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN, diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index 2b72b73d96..2553d40136 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -139,17 +139,11 @@ public: static status_t setActiveColorMode(const sp<IBinder>& display, ui::ColorMode colorMode); - // Reports whether the connected display supports Auto Low Latency Mode - static bool getAutoLowLatencyModeSupport(const sp<IBinder>& display); - // Switches on/off Auto Low Latency Mode on the connected display. This should only be // called if the connected display supports Auto Low Latency Mode as reported by // #getAutoLowLatencyModeSupport static void setAutoLowLatencyMode(const sp<IBinder>& display, bool on); - // Reports whether the connected display supports Game content type - static bool getGameContentTypeSupport(const sp<IBinder>& display); - // Turns Game mode on/off on the connected display. This should only be called // if the display supports Game content type, as reported by #getGameContentTypeSupport static void setGameContentType(const sp<IBinder>& display, bool on); diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index 3397198fa0..69bb86649c 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -757,15 +757,7 @@ public: const sp<IScreenCaptureListener>& /* captureListener */) override { return NO_ERROR; } - status_t getAutoLowLatencyModeSupport(const sp<IBinder>& /*display*/, - bool* /*outSupport*/) const override { - return NO_ERROR; - } void setAutoLowLatencyMode(const sp<IBinder>& /*display*/, bool /*on*/) override {} - status_t getGameContentTypeSupport(const sp<IBinder>& /*display*/, - bool* /*outSupport*/) const override { - return NO_ERROR; - } void setGameContentType(const sp<IBinder>& /*display*/, bool /*on*/) override {} status_t captureDisplay(uint64_t /*displayOrLayerStack*/, const sp<IScreenCaptureListener>& /* captureListener */) override { diff --git a/libs/ui/DynamicDisplayInfo.cpp b/libs/ui/DynamicDisplayInfo.cpp index 11acdae921..d5c4ef0c17 100644 --- a/libs/ui/DynamicDisplayInfo.cpp +++ b/libs/ui/DynamicDisplayInfo.cpp @@ -39,7 +39,9 @@ size_t DynamicDisplayInfo::getFlattenedSize() const { FlattenableHelpers::getFlattenedSize(activeDisplayModeId) + FlattenableHelpers::getFlattenedSize(supportedColorModes) + FlattenableHelpers::getFlattenedSize(activeColorMode) + - FlattenableHelpers::getFlattenedSize(hdrCapabilities); + FlattenableHelpers::getFlattenedSize(hdrCapabilities) + + FlattenableHelpers::getFlattenedSize(autoLowLatencyModeSupported) + + FlattenableHelpers::getFlattenedSize(gameContentTypeSupported); } status_t DynamicDisplayInfo::flatten(void* buffer, size_t size) const { @@ -51,6 +53,8 @@ status_t DynamicDisplayInfo::flatten(void* buffer, size_t size) const { RETURN_IF_ERROR(FlattenableHelpers::flatten(&buffer, &size, supportedColorModes)); RETURN_IF_ERROR(FlattenableHelpers::flatten(&buffer, &size, activeColorMode)); RETURN_IF_ERROR(FlattenableHelpers::flatten(&buffer, &size, hdrCapabilities)); + RETURN_IF_ERROR(FlattenableHelpers::flatten(&buffer, &size, autoLowLatencyModeSupported)); + RETURN_IF_ERROR(FlattenableHelpers::flatten(&buffer, &size, gameContentTypeSupported)); return OK; } @@ -60,6 +64,8 @@ status_t DynamicDisplayInfo::unflatten(const void* buffer, size_t size) { RETURN_IF_ERROR(FlattenableHelpers::unflatten(&buffer, &size, &supportedColorModes)); RETURN_IF_ERROR(FlattenableHelpers::unflatten(&buffer, &size, &activeColorMode)); RETURN_IF_ERROR(FlattenableHelpers::unflatten(&buffer, &size, &hdrCapabilities)); + RETURN_IF_ERROR(FlattenableHelpers::unflatten(&buffer, &size, &autoLowLatencyModeSupported)); + RETURN_IF_ERROR(FlattenableHelpers::unflatten(&buffer, &size, &gameContentTypeSupported)); return OK; } diff --git a/libs/ui/include/ui/DynamicDisplayInfo.h b/libs/ui/include/ui/DynamicDisplayInfo.h index 6c349b749d..a4c2f71a4c 100644 --- a/libs/ui/include/ui/DynamicDisplayInfo.h +++ b/libs/ui/include/ui/DynamicDisplayInfo.h @@ -41,6 +41,14 @@ struct DynamicDisplayInfo : LightFlattenable<DynamicDisplayInfo> { ui::ColorMode activeColorMode; HdrCapabilities hdrCapabilities; + // True if the display reports support for HDMI 2.1 Auto Low Latency Mode. + // For more information, see the HDMI 2.1 specification. + bool autoLowLatencyModeSupported; + + // True if the display reports support for Game Content Type. + // For more information, see the HDMI 1.4 specification. + bool gameContentTypeSupported; + std::optional<ui::DisplayMode> getActiveDisplayMode() const; bool isFixedSize() const { return false; } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index ecf535835a..549c123cde 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -966,9 +966,18 @@ status_t SurfaceFlinger::getDynamicDisplayInfo(const sp<IBinder>& displayToken, } info->activeColorMode = display->getCompositionDisplay()->getState().colorMode; - info->supportedColorModes = getDisplayColorModes(display->getPhysicalId()); + const auto displayId = display->getPhysicalId(); + info->supportedColorModes = getDisplayColorModes(displayId); info->hdrCapabilities = display->getHdrCapabilities(); + info->autoLowLatencyModeSupported = + getHwComposer().hasDisplayCapability(displayId, + hal::DisplayCapability::AUTO_LOW_LATENCY_MODE); + std::vector<hal::ContentType> types; + getHwComposer().getSupportedContentTypes(displayId, &types); + info->gameContentTypeSupported = std::any_of(types.begin(), types.end(), [](auto type) { + return type == hal::ContentType::GAME; + }); return NO_ERROR; } @@ -1243,24 +1252,6 @@ status_t SurfaceFlinger::setActiveColorMode(const sp<IBinder>& displayToken, Col return NO_ERROR; } -status_t SurfaceFlinger::getAutoLowLatencyModeSupport(const sp<IBinder>& displayToken, - bool* outSupport) const { - if (!displayToken) { - return BAD_VALUE; - } - - Mutex::Autolock lock(mStateLock); - - const auto displayId = getPhysicalDisplayIdLocked(displayToken); - if (!displayId) { - return NAME_NOT_FOUND; - } - *outSupport = - getHwComposer().hasDisplayCapability(*displayId, - hal::DisplayCapability::AUTO_LOW_LATENCY_MODE); - return NO_ERROR; -} - void SurfaceFlinger::setAutoLowLatencyMode(const sp<IBinder>& displayToken, bool on) { static_cast<void>(schedule([=]() MAIN_THREAD { if (const auto displayId = getPhysicalDisplayIdLocked(displayToken)) { @@ -1271,27 +1262,6 @@ void SurfaceFlinger::setAutoLowLatencyMode(const sp<IBinder>& displayToken, bool })); } -status_t SurfaceFlinger::getGameContentTypeSupport(const sp<IBinder>& displayToken, - bool* outSupport) const { - if (!displayToken) { - return BAD_VALUE; - } - - Mutex::Autolock lock(mStateLock); - - const auto displayId = getPhysicalDisplayIdLocked(displayToken); - if (!displayId) { - return NAME_NOT_FOUND; - } - - std::vector<hal::ContentType> types; - getHwComposer().getSupportedContentTypes(*displayId, &types); - - *outSupport = std::any_of(types.begin(), types.end(), - [](auto type) { return type == hal::ContentType::GAME; }); - return NO_ERROR; -} - void SurfaceFlinger::setGameContentType(const sp<IBinder>& displayToken, bool on) { static_cast<void>(schedule([=]() MAIN_THREAD { if (const auto displayId = getPhysicalDisplayIdLocked(displayToken)) { diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 21cd2a5682..d9af7509a1 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -561,11 +561,7 @@ private: status_t getDisplayNativePrimaries(const sp<IBinder>& displayToken, ui::DisplayPrimaries&) override; status_t setActiveColorMode(const sp<IBinder>& displayToken, ui::ColorMode colorMode) override; - status_t getAutoLowLatencyModeSupport(const sp<IBinder>& displayToken, - bool* outSupported) const override; void setAutoLowLatencyMode(const sp<IBinder>& displayToken, bool on) override; - status_t getGameContentTypeSupport(const sp<IBinder>& displayToken, - bool* outSupported) const override; void setGameContentType(const sp<IBinder>& displayToken, bool on) override; void setPowerMode(const sp<IBinder>& displayToken, int mode) override; status_t clearAnimationFrameStats() override; |