Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <composer-vts/2.3/ComposerVts.h> |
| 18 | |
| 19 | #include <VtsHalHidlTargetTestBase.h> |
| 20 | |
| 21 | namespace android { |
| 22 | namespace hardware { |
| 23 | namespace graphics { |
| 24 | namespace composer { |
| 25 | namespace V2_3 { |
| 26 | namespace vts { |
| 27 | |
| 28 | using V2_1::Error; |
| 29 | |
| 30 | Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {} |
| 31 | |
| 32 | Composer::Composer(const std::string& name) |
| 33 | : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name)) {} |
| 34 | |
| 35 | Composer::Composer(const sp<IComposer>& composer) |
| 36 | : V2_2::vts::Composer(composer), mComposer(composer) {} |
| 37 | |
| 38 | std::unique_ptr<ComposerClient> Composer::createClient() { |
| 39 | std::unique_ptr<ComposerClient> client; |
| 40 | mComposer->createClient_2_3([&client](const auto& tmpError, const auto& tmpClient) { |
| 41 | ASSERT_EQ(Error::NONE, tmpError) << "failed to create client"; |
| 42 | client = std::make_unique<ComposerClient>(tmpClient); |
| 43 | }); |
| 44 | |
| 45 | return client; |
| 46 | } |
| 47 | |
Valerie Hau | ec98306 | 2018-10-09 16:09:12 -0700 | [diff] [blame] | 48 | sp<IComposerClient> ComposerClient::getRaw() const { |
| 49 | return mClient; |
| 50 | } |
| 51 | |
Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 52 | bool ComposerClient::getDisplayIdentificationData(Display display, uint8_t* outPort, |
| 53 | std::vector<uint8_t>* outData) { |
| 54 | bool supported = true; |
| 55 | mClient->getDisplayIdentificationData( |
| 56 | display, [&](const auto& tmpError, const auto& tmpPort, const auto& tmpData) { |
| 57 | if (tmpError == Error::UNSUPPORTED) { |
| 58 | supported = false; |
| 59 | return; |
| 60 | } |
| 61 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get display identification data"; |
| 62 | |
| 63 | *outPort = tmpPort; |
| 64 | *outData = tmpData; |
| 65 | ASSERT_FALSE(outData->empty()) << "data is empty"; |
| 66 | }); |
| 67 | |
| 68 | return supported; |
| 69 | } |
| 70 | |
Valerie Hau | ec98306 | 2018-10-09 16:09:12 -0700 | [diff] [blame] | 71 | std::vector<ColorMode> ComposerClient::getColorModes_2_3(Display display) { |
| 72 | std::vector<ColorMode> modes; |
| 73 | mClient->getColorModes_2_3(display, [&](const auto& tmpError, const auto& tmpModes) { |
| 74 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get color modes"; |
| 75 | modes = tmpModes; |
| 76 | }); |
| 77 | return modes; |
| 78 | } |
| 79 | |
| 80 | void ComposerClient::setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent) { |
| 81 | Error error = mClient->setColorMode_2_3(display, mode, intent); |
| 82 | ASSERT_TRUE(error == Error::NONE || error == Error::UNSUPPORTED) << "failed to set color mode"; |
| 83 | } |
| 84 | |
| 85 | std::vector<RenderIntent> ComposerClient::getRenderIntents_2_3(Display display, ColorMode mode) { |
| 86 | std::vector<RenderIntent> intents; |
| 87 | mClient->getRenderIntents_2_3(display, mode, [&](const auto& tmpError, const auto& tmpIntents) { |
| 88 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get render intents"; |
| 89 | intents = tmpIntents; |
| 90 | }); |
| 91 | return intents; |
| 92 | } |
| 93 | |
| 94 | void ComposerClient::getReadbackBufferAttributes_2_3(Display display, PixelFormat* outPixelFormat, |
| 95 | Dataspace* outDataspace) { |
| 96 | mClient->getReadbackBufferAttributes_2_3( |
| 97 | display, |
| 98 | [&](const auto& tmpError, const auto& tmpOutPixelFormat, const auto& tmpOutDataspace) { |
| 99 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get readback buffer attributes"; |
| 100 | *outPixelFormat = tmpOutPixelFormat; |
| 101 | *outDataspace = tmpOutDataspace; |
| 102 | }); |
| 103 | } |
| 104 | |
| 105 | bool ComposerClient::getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height, |
| 106 | PixelFormat format, Dataspace dataspace) { |
| 107 | Error error = mClient->getClientTargetSupport_2_3(display, width, height, format, dataspace); |
| 108 | return error == Error::NONE; |
| 109 | } |
| 110 | |
Valerie Hau | c25748d | 2018-10-29 14:53:40 -0700 | [diff] [blame] | 111 | std::vector<IComposerClient::PerFrameMetadataKey> ComposerClient::getPerFrameMetadataKeys_2_3( |
| 112 | Display display) { |
| 113 | std::vector<IComposerClient::PerFrameMetadataKey> keys; |
| 114 | mClient->getPerFrameMetadataKeys_2_3(display, [&](const auto& tmpError, const auto& tmpKeys) { |
| 115 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get perFrameMetadataKeys"; |
| 116 | keys = tmpKeys; |
| 117 | }); |
| 118 | return keys; |
| 119 | } |
| 120 | |
| 121 | std::vector<Hdr> ComposerClient::getHdrCapabilities_2_3(Display display, float* outMaxLuminance, |
| 122 | float* outMaxAverageLuminance, |
| 123 | float* outMinLuminance) { |
| 124 | std::vector<Hdr> types; |
| 125 | mClient->getHdrCapabilities_2_3( |
| 126 | display, [&](const auto& tmpError, const auto& tmpTypes, const auto& tmpMaxLuminance, |
| 127 | const auto& tmpMaxAverageLuminance, const auto& tmpMinLuminance) { |
| 128 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get HDR capabilities"; |
| 129 | types = tmpTypes; |
| 130 | *outMaxLuminance = tmpMaxLuminance; |
| 131 | *outMaxAverageLuminance = tmpMaxAverageLuminance; |
| 132 | *outMinLuminance = tmpMinLuminance; |
| 133 | }); |
| 134 | |
| 135 | return types; |
| 136 | } |
| 137 | |
Kevin DuBois | bf14148 | 2018-09-10 09:07:54 -0700 | [diff] [blame] | 138 | Error ComposerClient::getDisplayedContentSamplingAttributes( |
| 139 | uint64_t display, PixelFormat& format, Dataspace& dataspace, |
| 140 | hidl_bitfield<IComposerClient::FormatColorComponent>& componentMask) { |
| 141 | auto error = Error::BAD_PARAMETER; |
| 142 | mClient->getDisplayedContentSamplingAttributes( |
| 143 | display, [&](const auto& tmpError, const auto& tmpFormat, const auto& tmpDataspace, |
| 144 | const auto& tmpComponentMask) { |
| 145 | error = tmpError; |
| 146 | format = tmpFormat; |
| 147 | dataspace = tmpDataspace; |
| 148 | componentMask = tmpComponentMask; |
| 149 | }); |
| 150 | return error; |
| 151 | } |
| 152 | |
| 153 | Error ComposerClient::setDisplayedContentSamplingEnabled( |
| 154 | uint64_t display, IComposerClient::DisplayedContentSampling enable, |
| 155 | hidl_bitfield<IComposerClient::FormatColorComponent> componentMask, uint64_t maxFrames) { |
| 156 | return mClient->setDisplayedContentSamplingEnabled(display, enable, componentMask, maxFrames); |
| 157 | } |
| 158 | |
| 159 | Error ComposerClient::getDisplayedContentSample(uint64_t display, uint64_t maxFrames, |
| 160 | uint64_t timestamp, uint64_t& frameCount, |
| 161 | hidl_vec<uint64_t>& sampleComponent0, |
| 162 | hidl_vec<uint64_t>& sampleComponent1, |
| 163 | hidl_vec<uint64_t>& sampleComponent2, |
| 164 | hidl_vec<uint64_t>& sampleComponent3) { |
| 165 | auto error = Error::BAD_PARAMETER; |
| 166 | mClient->getDisplayedContentSample( |
| 167 | display, maxFrames, timestamp, |
| 168 | [&](const auto& tmpError, const auto& tmpFrameCount, const auto& tmpSamples0, |
| 169 | const auto& tmpSamples1, const auto& tmpSamples2, const auto& tmpSamples3) { |
| 170 | error = tmpError; |
| 171 | frameCount = tmpFrameCount; |
| 172 | sampleComponent0 = tmpSamples0; |
| 173 | sampleComponent1 = tmpSamples1; |
| 174 | sampleComponent2 = tmpSamples2; |
| 175 | sampleComponent3 = tmpSamples3; |
| 176 | }); |
| 177 | return error; |
| 178 | } |
| 179 | |
Peiyong Lin | 55d50d6 | 2018-10-26 18:24:46 -0700 | [diff] [blame] | 180 | std::vector<IComposerClient::DisplayCapability> ComposerClient::getDisplayCapabilities( |
| 181 | Display display) { |
| 182 | std::vector<IComposerClient::DisplayCapability> capabilities; |
| 183 | mClient->getDisplayCapabilities( |
| 184 | display, [&](const auto&, const auto& tmpCapabilities) { capabilities = tmpCapabilities; }); |
| 185 | |
| 186 | return capabilities; |
| 187 | } |
| 188 | |
Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 189 | } // namespace vts |
| 190 | } // namespace V2_3 |
| 191 | } // namespace composer |
| 192 | } // namespace graphics |
| 193 | } // namespace hardware |
| 194 | } // namespace android |