summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorDan Gittik <dangittik@google.com>2019-01-18 19:28:52 +0000
committerMichael Wright <michaelwr@google.com>2019-03-08 17:14:17 +0000
commit3e83c4558a60af8938d9e2e3955a4b87faeb0c9d (patch)
tree61685d8544d00ce39621778c93c8f2beef941691 /graphics
parentfc084a1c1fb5fa2c0e002263d9259ef7493dfc94 (diff)
downloadandroid_hardware_interfaces-3e83c4558a60af8938d9e2e3955a4b87faeb0c9d.tar.gz
android_hardware_interfaces-3e83c4558a60af8938d9e2e3955a4b87faeb0c9d.tar.bz2
android_hardware_interfaces-3e83c4558a60af8938d9e2e3955a4b87faeb0c9d.zip
Moved brightness from Lights to SF.
Test: manual. Check that brightness works. Fixes: 111435292 Change-Id: I3d19bc2fc4088bc9a956a5cf38c3b163fe35256f
Diffstat (limited to 'graphics')
-rw-r--r--graphics/composer/2.3/IComposerClient.hal39
-rw-r--r--graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h14
-rw-r--r--graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h2
-rw-r--r--graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h30
-rw-r--r--graphics/composer/2.3/utils/vts/ComposerVts.cpp13
-rw-r--r--graphics/composer/2.3/utils/vts/include/composer-vts/2.3/ComposerVts.h8
-rw-r--r--graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp30
7 files changed, 132 insertions, 4 deletions
diff --git a/graphics/composer/2.3/IComposerClient.hal b/graphics/composer/2.3/IComposerClient.hal
index 5fcc0e67d..1eea30652 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 a272e72d7..1b4079507 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<Interfac
return Void();
}
- protected:
+ Return<void> 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<Error> setDisplayBrightness(Display display, float brightness) override {
+ return mHal->setDisplayBrightness(display, brightness);
+ }
+
+ protected:
std::unique_ptr<V2_1::hal::ComposerCommandEngine> createCommandEngine() override {
return std::make_unique<ComposerCommandEngine>(
mHal, static_cast<V2_2::hal::ComposerResources*>(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 a0812ad9a..186b00481 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<IComposerClient::PerFrameMetadataBlob>& 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 41e333ac5..070cf80e4 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<Hal> {
return static_cast<Error>(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);
+ }
+
+ 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>(error);
+ }
+
+ protected:
bool initDispatch() override {
if (!BaseType2_2::initDispatch()) {
return false;
@@ -265,6 +287,10 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
&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<Hal> {
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<Hal>;
diff --git a/graphics/composer/2.3/utils/vts/ComposerVts.cpp b/graphics/composer/2.3/utils/vts/ComposerVts.cpp
index 0e541ed2e..4de85d6aa 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<IComposerClient::DisplayCapability> 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 ad4ef0b51..a0e764d5e 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<ComposerClient> createClient();
- protected:
+ protected:
explicit Composer(const sp<IComposer>& composer);
private:
@@ -99,7 +99,11 @@ class ComposerClient : public V2_2::vts::ComposerClient {
std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys_2_3(Display display);
- private:
+ bool getDisplayBrightnessSupport(Display display);
+
+ Error setDisplayBrightness(Display display, float brightness);
+
+ private:
const sp<IComposerClient> mClient;
};
diff --git a/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp b/graphics/composer/2.3/vts/functional/VtsHalGraphicsComposerV2_3TargetTest.cpp
index de74e28cc..b983e42d1 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