diff options
| -rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 71 | ||||
| -rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 10 | ||||
| -rw-r--r-- | libs/gui/include/gui/ISurfaceComposer.h | 10 | ||||
| -rw-r--r-- | libs/gui/include/gui/SurfaceComposerClient.h | 7 | ||||
| -rw-r--r-- | libs/gui/tests/Surface_test.cpp | 5 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 18 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 2 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/Android.bp | 1 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/DisplayConfigs_test.cpp | 40 |
9 files changed, 164 insertions, 0 deletions
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 580579759f..da7369db1b 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -878,6 +878,45 @@ public: return reply.readInt32(); } + virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, + int32_t defaultModeId, float minRefreshRate, + float maxRefreshRate) { + Parcel data, reply; + status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result); + return result; + } + result = data.writeStrongBinder(displayToken); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result); + return result; + } + result = data.writeInt32(defaultModeId); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs failed to write defaultModeId: %d", result); + return result; + } + result = data.writeFloat(minRefreshRate); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs failed to write minRefreshRate: %d", result); + return result; + } + result = data.writeFloat(maxRefreshRate); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs failed to write maxRefreshRate: %d", result); + return result; + } + + result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data, + &reply); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result); + return result; + } + return reply.readInt32(); + } + virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken, std::vector<int32_t>* outAllowedConfigs) { if (!outAllowedConfigs) return BAD_VALUE; @@ -1554,6 +1593,38 @@ status_t BnSurfaceComposer::onTransact( reply->writeInt32(result); return result; } + case SET_DESIRED_DISPLAY_CONFIG_SPECS: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); + sp<IBinder> displayToken = data.readStrongBinder(); + int32_t defaultModeId; + status_t result = data.readInt32(&defaultModeId); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultModeId: %d", result); + return result; + } + float minRefreshRate; + result = data.readFloat(&minRefreshRate); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs: failed to read minRefreshRate: %d", result); + return result; + } + float maxRefreshRate; + result = data.readFloat(&maxRefreshRate); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs: failed to read maxRefreshRate: %d", result); + return result; + } + result = setDesiredDisplayConfigSpecs(displayToken, defaultModeId, minRefreshRate, + maxRefreshRate); + if (result != NO_ERROR) { + ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: " + "%d", + result); + return result; + } + reply->writeInt32(result); + return result; + } case GET_DISPLAY_BRIGHTNESS_SUPPORT: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> displayToken; diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index a538e14dfc..1a1a68c4d2 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -1616,6 +1616,16 @@ status_t SurfaceComposerClient::getAllowedDisplayConfigs(const sp<IBinder>& disp outAllowedConfigs); } +status_t SurfaceComposerClient::setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, + int32_t defaultModeId, + float minRefreshRate, + float maxRefreshRate) { + return ComposerService::getComposerService()->setDesiredDisplayConfigSpecs(displayToken, + defaultModeId, + minRefreshRate, + maxRefreshRate); +} + status_t SurfaceComposerClient::getDisplayColorModes(const sp<IBinder>& display, Vector<ColorMode>* outColorModes) { return ComposerService::getComposerService()->getDisplayColorModes(display, outColorModes); diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h index f2bae98be2..b16e0492cf 100644 --- a/libs/gui/include/gui/ISurfaceComposer.h +++ b/libs/gui/include/gui/ISurfaceComposer.h @@ -399,6 +399,15 @@ public: virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken, std::vector<int32_t>* outAllowedConfigs) = 0; /* + * Sets the refresh rate boundaries for display configuration. + * For all other parameters, default configuration is used. The index for the default is + * corresponding to the configs returned from getDisplayConfigs(). + */ + virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, + int32_t defaultModeId, float minRefreshRate, + float maxRefreshRate) = 0; + + /* * Gets whether brightness operations are supported on a display. * * displayToken @@ -488,6 +497,7 @@ public: REMOVE_REGION_SAMPLING_LISTENER, SET_ALLOWED_DISPLAY_CONFIGS, GET_ALLOWED_DISPLAY_CONFIGS, + SET_DESIRED_DISPLAY_CONFIG_SPECS, GET_DISPLAY_BRIGHTNESS_SUPPORT, SET_DISPLAY_BRIGHTNESS, CAPTURE_SCREEN_BY_ID, diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index 37387acfc6..16721c8caf 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -129,6 +129,13 @@ public: static status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken, std::vector<int32_t>* outAllowedConfigs); + // Sets the refresh rate boundaries for display configuration. + // For all other parameters, default configuration is used. The index for the default is + // corresponting to the configs returned from getDisplayConfigs(). + static status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, + int32_t defaultModeId, float minRefreshRate, + float maxRefreshRate); + // Gets the list of supported color modes for the given display static status_t getDisplayColorModes(const sp<IBinder>& display, Vector<ui::ColorMode>* outColorModes); diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index a4fdb35595..5928822a1b 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -831,6 +831,11 @@ public: std::vector<int32_t>* /*outAllowedConfigs*/) override { return NO_ERROR; } + status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& /*displayToken*/, + int32_t /*defaultModeId*/, float /*minRefreshRate*/, + float /*maxRefreshRate*/) override { + return NO_ERROR; + } status_t notifyPowerHint(int32_t /*hintId*/) override { return NO_ERROR; } protected: diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index ec15bad456..73eaa360ef 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -4378,6 +4378,7 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) { case SET_ACTIVE_CONFIG: case SET_ALLOWED_DISPLAY_CONFIGS: case GET_ALLOWED_DISPLAY_CONFIGS: + case SET_DESIRED_DISPLAY_CONFIG_SPECS: case SET_ACTIVE_COLOR_MODE: case INJECT_VSYNC: case SET_POWER_MODE: @@ -5471,6 +5472,23 @@ status_t SurfaceFlinger::getAllowedDisplayConfigs(const sp<IBinder>& displayToke return NO_ERROR; } +status_t SurfaceFlinger::setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, + int32_t defaultModeId, float minRefreshRate, + float maxRefreshRate) { + ATRACE_CALL(); + + if (!displayToken) { + return BAD_VALUE; + } + + ALOGD("setDesiredDisplayConfigSpecs: defaultId: %d min: %.f max: %.f", defaultModeId, + minRefreshRate, maxRefreshRate); + // TODO(b/142507213): In order to minimize the changelist size, this is going to be implemented + // in the follow up CL. + + return NO_ERROR; +} + void SurfaceFlinger::SetInputWindowsListener::onSetInputWindowsFinished() { mFlinger->setInputWindowsFinished(); } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 50b3ae4ecd..a089cb62a9 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -466,6 +466,8 @@ private: const std::vector<int32_t>& allowedConfigs) override; status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken, std::vector<int32_t>* outAllowedConfigs) override; + status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, int32_t displayModeId, + float minRefreshRate, float maxRefreshRate) override; status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken, bool* outSupport) const override; status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) const override; diff --git a/services/surfaceflinger/tests/Android.bp b/services/surfaceflinger/tests/Android.bp index d021fc2859..cc5f57514c 100644 --- a/services/surfaceflinger/tests/Android.bp +++ b/services/surfaceflinger/tests/Android.bp @@ -21,6 +21,7 @@ cc_test { "Credentials_test.cpp", "DereferenceSurfaceControl_test.cpp", "DisplayActiveConfig_test.cpp", + "DisplayConfigs_test.cpp", "InvalidHandles_test.cpp", "LayerCallback_test.cpp", "LayerRenderTypeTransaction_test.cpp", diff --git a/services/surfaceflinger/tests/DisplayConfigs_test.cpp b/services/surfaceflinger/tests/DisplayConfigs_test.cpp new file mode 100644 index 0000000000..d75220513c --- /dev/null +++ b/services/surfaceflinger/tests/DisplayConfigs_test.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019 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 <thread> +#include "LayerTransactionTest.h" +namespace android { + +using android::hardware::graphics::common::V1_1::BufferUsage; + +::testing::Environment* const binderEnv = + ::testing::AddGlobalTestEnvironment(new BinderEnvironment()); + +/** + * Test class for setting display configs and passing around refresh rate ranges. + */ +class RefreshRateRangeTest : public ::testing::Test { +protected: + void SetUp() override { mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); } + + sp<IBinder> mDisplayToken; +}; + +TEST_F(RefreshRateRangeTest, helloWorldTest) { + status_t res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, 0, 0, 0); + EXPECT_EQ(res, NO_ERROR); +} +} // namespace android |