diff --git a/current.txt b/current.txt index 9149d95366..10b9b18e39 100644 --- a/current.txt +++ b/current.txt @@ -480,7 +480,7 @@ b826892686850a9cf2b60ca5845db7185c2196ea4dd765cd80cd163169678a78 android.hardwar 01c6398c90fc6be0640810e2c5d8a4863b457280132bb3f97dd5682e19632b62 android.hardware.graphics.bufferqueue@2.0::types 7a2d64095252f85781b2d521f4f11d04ce774544feececcec2088c568656e93c android.hardware.graphics.common@1.2::types 3dff04a36b86660b5807414587e530bb0c294ed56fdff06f8915ba0a9b73f974 android.hardware.graphics.composer@2.3::IComposer -daa44e83d7709bf1c9e0bd9a6b552feff496fd14574a9461ee93c21980fc5b15 android.hardware.graphics.composer@2.3::IComposerClient +54bc1dc874f8bc0781767786075dafd33a0796c1eea7d2317231b8929280e946 android.hardware.graphics.composer@2.3::IComposerClient 5c8bf8e1af9efe225a4661db8c08ff1b7e13fdc8ed49f35291bd0b6c9436b8f2 android.hardware.graphics.mapper@3.0::IMapper 7183d9d9acfa41a61a64bdfed548e98299265a7bb1821a3ed204173b5c2cfd4a android.hardware.graphics.mapper@3.0::types c3f831a66d5815baf74f5b82fe79cf099542ddae4dfab3f388e1d41828e794fc android.hardware.health.storage@1.0::IGarbageCollectCallback diff --git a/graphics/composer/2.3/IComposerClient.hal b/graphics/composer/2.3/IComposerClient.hal index 5fcc0e67d6..1eea306523 100644 --- a/graphics/composer/2.3/IComposerClient.hal +++ b/graphics/composer/2.3/IComposerClient.hal @@ -61,6 +61,11 @@ interface IComposerClient extends @2.2::IComposerClient { * PowerMode::DOZE_SUSPEND. */ DOZE = 2, + + /** + * Indicates that the display supports brightness operations. + */ + BRIGHTNESS = 3, }; /** @@ -495,4 +500,38 @@ interface IComposerClient extends @2.2::IComposerClient { float maxLuminance, float maxAverageLuminance, float minLuminance); + + /** + * Gets whether brightness operations are supported on a display. + * + * @param display + * The display. + * + * @return error is NONE upon success. Otherwise, + * BAD_DISPLAY when the display is invalid, or + * BAD_PARAMETER when the output parameter is invalid. + * @return support + * Whether brightness operations are supported on the display. + */ + getDisplayBrightnessSupport(Display display) generates (Error error, bool support); + + /** + * Sets the brightness of a display. + * + * Ideally, the brightness change should take effect in the next frame post (so that it can be + * aligned with color transforms). + * + * @param display + * The display whose brightness is set. + * @param brightness + * A number between 0.0f (minimum brightness) and 1.0f (maximum brightness), or -1.0 to + * turn the backlight off. + * + * @return error is NONE upon success. Otherwise, + * BAD_DISPLAY when the display is invalid, or + * UNSUPPORTED when brightness operations are not supported, or + * BAD_PARAMETER when the brightness is invalid, or + * NO_RESOURCES when the brightness cannot be applied. + */ + setDisplayBrightness(Display display, float brightness) generates (Error error); }; diff --git a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h index a272e72d74..1b4079507a 100644 --- a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h +++ b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h @@ -172,7 +172,19 @@ class ComposerClientImpl : public V2_2::hal::detail::ComposerClientImpl getDisplayBrightnessSupport( + Display display, IComposerClient::getDisplayBrightnessSupport_cb hidl_cb) override { + bool support = false; + Error error = mHal->getDisplayBrightnessSupport(display, &support); + hidl_cb(error, support); + return Void(); + } + + Return setDisplayBrightness(Display display, float brightness) override { + return mHal->setDisplayBrightness(display, brightness); + } + + protected: std::unique_ptr createCommandEngine() override { return std::make_unique( mHal, static_cast(mResources.get())); diff --git a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h index a0812ad9a7..186b004810 100644 --- a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h +++ b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h @@ -119,6 +119,8 @@ class ComposerHal : public V2_2::hal::ComposerHal { virtual Error setLayerPerFrameMetadataBlobs( Display display, Layer layer, std::vector& blobs) = 0; + virtual Error getDisplayBrightnessSupport(Display display, bool* outSupport) = 0; + virtual Error setDisplayBrightness(Display display, float brightness) = 0; }; } // namespace hal diff --git a/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h b/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h index 41e333ac5e..070cf80e44 100644 --- a/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h +++ b/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h @@ -245,7 +245,29 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl { return static_cast(err); } - protected: + Error getDisplayBrightnessSupport(Display display, bool* outSupport) { + if (!mDispatch.getDisplayBrightnessSupport) { + return Error::UNSUPPORTED; + } + bool support = false; + int32_t error = mDispatch.getDisplayBrightnessSupport(mDevice, display, &support); + *outSupport = support; + return static_cast(error); + } + + Error setDisplayBrightness(Display display, float brightness) { + if (std::isnan(brightness) || brightness > 1.0f || + (brightness < 0.0f && brightness != -1.0f)) { + return Error::BAD_PARAMETER; + } + if (!mDispatch.setDisplayBrightness) { + return Error::UNSUPPORTED; + } + int32_t error = mDispatch.setDisplayBrightness(mDevice, display, brightness); + return static_cast(error); + } + + protected: bool initDispatch() override { if (!BaseType2_2::initDispatch()) { return false; @@ -265,6 +287,10 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl { &mDispatch.getDisplayCapabilities); this->initOptionalDispatch(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS, &mDispatch.setLayerPerFrameMetadataBlobs); + this->initOptionalDispatch(HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT, + &mDispatch.getDisplayBrightnessSupport); + this->initOptionalDispatch(HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS, + &mDispatch.setDisplayBrightness); return true; } @@ -277,6 +303,8 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl { HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE getDisplayedContentSample; HWC2_PFN_GET_DISPLAY_CAPABILITIES getDisplayCapabilities; HWC2_PFN_SET_LAYER_PER_FRAME_METADATA_BLOBS setLayerPerFrameMetadataBlobs; + HWC2_PFN_GET_DISPLAY_BRIGHTNESS_SUPPORT getDisplayBrightnessSupport; + HWC2_PFN_SET_DISPLAY_BRIGHTNESS setDisplayBrightness; } mDispatch = {}; using BaseType2_2 = V2_2::passthrough::detail::HwcHalImpl; diff --git a/graphics/composer/2.3/utils/vts/ComposerVts.cpp b/graphics/composer/2.3/utils/vts/ComposerVts.cpp index 0e541ed2e3..4de85d6aa4 100644 --- a/graphics/composer/2.3/utils/vts/ComposerVts.cpp +++ b/graphics/composer/2.3/utils/vts/ComposerVts.cpp @@ -186,6 +186,19 @@ std::vector ComposerClient::getDisplayCapabi return capabilities; } +bool ComposerClient::getDisplayBrightnessSupport(Display display) { + bool support = false; + mClient->getDisplayBrightnessSupport(display, [&](const auto& error, const auto& tmpSupport) { + ASSERT_EQ(Error::NONE, error) << "failed to get brightness support"; + support = tmpSupport; + }); + return support; +} + +Error ComposerClient::setDisplayBrightness(Display display, float brightness) { + return mClient->setDisplayBrightness(display, brightness); +} + } // namespace vts } // namespace V2_3 } // namespace composer diff --git a/graphics/composer/2.3/utils/vts/include/composer-vts/2.3/ComposerVts.h b/graphics/composer/2.3/utils/vts/include/composer-vts/2.3/ComposerVts.h index ad4ef0b51e..a0e764d5e6 100644 --- a/graphics/composer/2.3/utils/vts/include/composer-vts/2.3/ComposerVts.h +++ b/graphics/composer/2.3/utils/vts/include/composer-vts/2.3/ComposerVts.h @@ -52,7 +52,7 @@ class Composer : public V2_2::vts::Composer { std::unique_ptr createClient(); - protected: + protected: explicit Composer(const sp& composer); private: @@ -99,7 +99,11 @@ class ComposerClient : public V2_2::vts::ComposerClient { std::vector getPerFrameMetadataKeys_2_3(Display display); - private: + bool getDisplayBrightnessSupport(Display display); + + Error setDisplayBrightness(Display display, float brightness); + + private: const sp mClient; }; diff --git a/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp b/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp index de74e28cc7..b983e42d16 100644 --- a/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp +++ b/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp @@ -600,6 +600,36 @@ TEST_F(GraphicsComposerHidlTest, SetLayerPerFrameMetadataBlobs) { } } +/* + * Test that getDisplayBrightnessSupport works as expected. + */ +TEST_F(GraphicsComposerHidlTest, getDisplayBrightnessSupport) { + auto capabilities = mComposerClient->getDisplayCapabilities(mPrimaryDisplay); + bool brightnessSupport = + std::find(capabilities.begin(), capabilities.end(), + IComposerClient::DisplayCapability::BRIGHTNESS) != capabilities.end(); + EXPECT_EQ(mComposerClient->getDisplayBrightnessSupport(mPrimaryDisplay), brightnessSupport); +} + +/* + * Test that if brightness operations are supported, setDisplayBrightness works as expected. + */ +TEST_F(GraphicsComposerHidlTest, setDisplayBrightness) { + if (!mComposerClient->getDisplayBrightnessSupport(mPrimaryDisplay)) { + EXPECT_EQ(mComposerClient->getRaw()->setDisplayBrightness(mPrimaryDisplay, 0.5f), + Error::UNSUPPORTED); + GTEST_SUCCEED() << "Brightness operations are not supported"; + } + + EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 0.0f), Error::NONE); + EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 0.5f), Error::NONE); + EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, 1.0f), Error::NONE); + EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, -1.0f), Error::NONE); + + EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, +2.0f), Error::BAD_PARAMETER); + EXPECT_EQ(mComposerClient->setDisplayBrightness(mPrimaryDisplay, -2.0f), Error::BAD_PARAMETER); +} + } // namespace } // namespace vts } // namespace V2_3