Peiyong Lin | 781d0bb | 2019-07-03 10:57:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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.4/ComposerVts.h> |
| 18 | |
Peiyong Lin | 781d0bb | 2019-07-03 10:57:02 -0700 | [diff] [blame] | 19 | namespace android { |
| 20 | namespace hardware { |
| 21 | namespace graphics { |
| 22 | namespace composer { |
| 23 | namespace V2_4 { |
| 24 | namespace vts { |
| 25 | |
Ady Abraham | 7882ae6 | 2019-10-10 17:04:47 -0700 | [diff] [blame] | 26 | using V2_4::Error; |
Peiyong Lin | 781d0bb | 2019-07-03 10:57:02 -0700 | [diff] [blame] | 27 | |
Peiyong Lin | 781d0bb | 2019-07-03 10:57:02 -0700 | [diff] [blame] | 28 | Composer::Composer(const sp<IComposer>& composer) |
| 29 | : V2_3::vts::Composer(composer), mComposer(composer) {} |
| 30 | |
| 31 | std::unique_ptr<ComposerClient> Composer::createClient() { |
| 32 | std::unique_ptr<ComposerClient> client; |
| 33 | mComposer->createClient_2_4([&client](const auto& tmpError, const auto& tmpClient) { |
| 34 | ASSERT_EQ(Error::NONE, tmpError) << "failed to create client"; |
| 35 | client = std::make_unique<ComposerClient>(tmpClient); |
| 36 | }); |
| 37 | |
| 38 | return client; |
| 39 | } |
| 40 | |
| 41 | sp<IComposerClient> ComposerClient::getRaw() const { |
| 42 | return mClient; |
| 43 | } |
| 44 | |
| 45 | Error ComposerClient::getDisplayCapabilities( |
| 46 | Display display, std::vector<IComposerClient::DisplayCapability>* outCapabilities) { |
Peiyong Lin | 781d0bb | 2019-07-03 10:57:02 -0700 | [diff] [blame] | 47 | Error error = Error::NONE; |
| 48 | mClient->getDisplayCapabilities_2_4(display, |
| 49 | [&](const auto& tmpError, const auto& tmpCapabilities) { |
| 50 | error = tmpError; |
| 51 | *outCapabilities = tmpCapabilities; |
| 52 | }); |
| 53 | return error; |
| 54 | } |
| 55 | |
Dominik Laskowski | ce44a4b | 2019-09-19 15:50:09 -0700 | [diff] [blame] | 56 | Error ComposerClient::getDisplayConnectionType(Display display, |
| 57 | IComposerClient::DisplayConnectionType* outType) { |
| 58 | Error error = Error::NONE; |
| 59 | mClient->getDisplayConnectionType(display, [&](const auto& tmpError, const auto& tmpType) { |
| 60 | error = tmpError; |
| 61 | *outType = tmpType; |
| 62 | }); |
| 63 | return error; |
| 64 | } |
| 65 | |
Ady Abraham | a1df7c3 | 2019-10-22 16:56:08 -0700 | [diff] [blame] | 66 | int32_t ComposerClient::getDisplayAttribute_2_4( |
| 67 | android::hardware::graphics::composer::V2_1::Display display, |
| 68 | android::hardware::graphics::composer::V2_1::Config config, |
| 69 | IComposerClient::Attribute attribute) { |
| 70 | int32_t value = 0; |
| 71 | mClient->getDisplayAttribute_2_4( |
| 72 | display, config, attribute, [&](const auto& tmpError, const auto& tmpValue) { |
| 73 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get display attribute"; |
| 74 | value = tmpValue; |
Ady Abraham | 7882ae6 | 2019-10-10 17:04:47 -0700 | [diff] [blame] | 75 | }); |
Ady Abraham | a1df7c3 | 2019-10-22 16:56:08 -0700 | [diff] [blame] | 76 | |
| 77 | return value; |
Ady Abraham | 7882ae6 | 2019-10-10 17:04:47 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Ady Abraham | 5f9f9a4 | 2020-01-02 14:28:39 -0800 | [diff] [blame] | 80 | void ComposerClient::registerCallback_2_4(const sp<IComposerCallback>& callback) { |
| 81 | mClient->registerCallback_2_4(callback); |
| 82 | } |
| 83 | |
Ady Abraham | 7882ae6 | 2019-10-10 17:04:47 -0700 | [diff] [blame] | 84 | Error ComposerClient::getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriod) { |
| 85 | Error error = Error::NONE; |
| 86 | mClient->getDisplayVsyncPeriod(display, [&](const auto& tmpError, const auto& tmpVsyncPeriod) { |
| 87 | error = tmpError; |
| 88 | *outVsyncPeriod = tmpVsyncPeriod; |
| 89 | }); |
| 90 | return error; |
| 91 | } |
| 92 | |
Ady Abraham | a1df7c3 | 2019-10-22 16:56:08 -0700 | [diff] [blame] | 93 | Error ComposerClient::setActiveConfigWithConstraints( |
| 94 | Display display, Config config, |
Ady Abraham | 7882ae6 | 2019-10-10 17:04:47 -0700 | [diff] [blame] | 95 | const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints, |
Ady Abraham | a1df7c3 | 2019-10-22 16:56:08 -0700 | [diff] [blame] | 96 | VsyncPeriodChangeTimeline* timeline) { |
Ady Abraham | 7882ae6 | 2019-10-10 17:04:47 -0700 | [diff] [blame] | 97 | Error error = Error::NONE; |
Ady Abraham | a1df7c3 | 2019-10-22 16:56:08 -0700 | [diff] [blame] | 98 | mClient->setActiveConfigWithConstraints(display, config, vsyncPeriodChangeConstraints, |
| 99 | [&](const auto& tmpError, const auto& tmpTimeline) { |
| 100 | error = tmpError; |
| 101 | *timeline = tmpTimeline; |
| 102 | }); |
Ady Abraham | 7882ae6 | 2019-10-10 17:04:47 -0700 | [diff] [blame] | 103 | return error; |
| 104 | } |
| 105 | |
Galia Peycheva | a097345 | 2019-11-01 11:04:42 +0100 | [diff] [blame] | 106 | Error ComposerClient::setAutoLowLatencyMode(Display display, bool on) { |
| 107 | return mClient->setAutoLowLatencyMode(display, on); |
| 108 | } |
| 109 | |
| 110 | Error ComposerClient::getSupportedContentTypes( |
| 111 | Display display, std::vector<IComposerClient::ContentType>* outSupportedContentTypes) { |
| 112 | Error error = Error::NONE; |
| 113 | mClient->getSupportedContentTypes( |
| 114 | display, [&](const auto& tmpError, const auto& tmpSupportedContentTypes) { |
| 115 | error = tmpError; |
| 116 | *outSupportedContentTypes = tmpSupportedContentTypes; |
| 117 | }); |
| 118 | return error; |
| 119 | } |
| 120 | |
| 121 | Error ComposerClient::setContentType(Display display, IComposerClient::ContentType contentType) { |
| 122 | return mClient->setContentType(display, contentType); |
| 123 | } |
| 124 | |
Dan Stoza | a4bea0e | 2019-10-21 15:43:55 -0700 | [diff] [blame] | 125 | Error ComposerClient::getLayerGenericMetadataKeys( |
| 126 | std::vector<IComposerClient::LayerGenericMetadataKey>* outKeys) { |
| 127 | Error error = Error::NONE; |
| 128 | mClient->getLayerGenericMetadataKeys([&](const auto tmpError, const auto& tmpKeys) { |
| 129 | error = tmpError; |
| 130 | *outKeys = tmpKeys; |
| 131 | }); |
| 132 | return error; |
| 133 | } |
| 134 | |
Ady Abraham | f6820b2 | 2020-02-07 17:39:56 -0800 | [diff] [blame] | 135 | void ComposerClient::execute(TestCommandReader* reader, CommandWriterBase* writer) { |
| 136 | bool queueChanged = false; |
| 137 | uint32_t commandLength = 0; |
| 138 | hidl_vec<hidl_handle> commandHandles; |
| 139 | ASSERT_TRUE(writer->writeQueue(&queueChanged, &commandLength, &commandHandles)); |
| 140 | |
| 141 | if (queueChanged) { |
| 142 | auto ret = mClient->setInputCommandQueue(*writer->getMQDescriptor()); |
| 143 | ASSERT_EQ(V2_1::Error::NONE, ret); |
| 144 | } |
| 145 | |
| 146 | mClient->executeCommands_2_3( |
| 147 | commandLength, commandHandles, |
| 148 | [&](const auto& tmpError, const auto& tmpOutQueueChanged, const auto& tmpOutLength, |
| 149 | const auto& tmpOutHandles) { |
| 150 | ASSERT_EQ(V2_1::Error::NONE, tmpError); |
| 151 | |
| 152 | if (tmpOutQueueChanged) { |
| 153 | mClient->getOutputCommandQueue( |
| 154 | [&](const auto& tmpError, const auto& tmpDescriptor) { |
| 155 | ASSERT_EQ(V2_3::Error::NONE, tmpError); |
| 156 | reader->setMQDescriptor(tmpDescriptor); |
| 157 | }); |
| 158 | } |
| 159 | |
| 160 | ASSERT_TRUE(reader->readQueue(tmpOutLength, tmpOutHandles)); |
| 161 | reader->parse(); |
| 162 | }); |
| 163 | reader->reset(); |
| 164 | writer->reset(); |
| 165 | } |
| 166 | |
Peiyong Lin | 781d0bb | 2019-07-03 10:57:02 -0700 | [diff] [blame] | 167 | } // namespace vts |
| 168 | } // namespace V2_4 |
| 169 | } // namespace composer |
| 170 | } // namespace graphics |
| 171 | } // namespace hardware |
| 172 | } // namespace android |