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
19 namespace android {
20 namespace hardware {
21 namespace graphics {
22 namespace composer {
23 namespace V2_4 {
24 namespace vts {
25
26 using V2_4::Error;
27
Composer(const sp<IComposer> & composer)28 Composer::Composer(const sp<IComposer>& composer)
29 : V2_3::vts::Composer(composer), mComposer(composer) {}
30
createClient()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
getRaw() const41 sp<IComposerClient> ComposerClient::getRaw() const {
42 return mClient;
43 }
44
getDisplayCapabilities(Display display,std::vector<IComposerClient::DisplayCapability> * outCapabilities)45 Error ComposerClient::getDisplayCapabilities(
46 Display display, std::vector<IComposerClient::DisplayCapability>* outCapabilities) {
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
getDisplayConnectionType(Display display,IComposerClient::DisplayConnectionType * outType)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
getDisplayAttribute_2_4(android::hardware::graphics::composer::V2_1::Display display,android::hardware::graphics::composer::V2_1::Config config,IComposerClient::Attribute attribute)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;
75 });
76
77 return value;
78 }
79
registerCallback_2_4(const sp<IComposerCallback> & callback)80 void ComposerClient::registerCallback_2_4(const sp<IComposerCallback>& callback) {
81 mClient->registerCallback_2_4(callback);
82 }
83
getDisplayVsyncPeriod(Display display,VsyncPeriodNanos * outVsyncPeriod)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
setActiveConfigWithConstraints(Display display,Config config,const IComposerClient::VsyncPeriodChangeConstraints & vsyncPeriodChangeConstraints,VsyncPeriodChangeTimeline * timeline)93 Error ComposerClient::setActiveConfigWithConstraints(
94 Display display, Config config,
95 const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
96 VsyncPeriodChangeTimeline* timeline) {
97 Error error = Error::NONE;
98 mClient->setActiveConfigWithConstraints(display, config, vsyncPeriodChangeConstraints,
99 [&](const auto& tmpError, const auto& tmpTimeline) {
100 error = tmpError;
101 *timeline = tmpTimeline;
102 });
103 return error;
104 }
105
setAutoLowLatencyMode(Display display,bool on)106 Error ComposerClient::setAutoLowLatencyMode(Display display, bool on) {
107 return mClient->setAutoLowLatencyMode(display, on);
108 }
109
getSupportedContentTypes(Display display,std::vector<IComposerClient::ContentType> * outSupportedContentTypes)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
setContentType(Display display,IComposerClient::ContentType contentType)121 Error ComposerClient::setContentType(Display display, IComposerClient::ContentType contentType) {
122 return mClient->setContentType(display, contentType);
123 }
124
getLayerGenericMetadataKeys(std::vector<IComposerClient::LayerGenericMetadataKey> * outKeys)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
execute(TestCommandReader * reader,CommandWriterBase * writer)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
167 } // namespace vts
168 } // namespace V2_4
169 } // namespace composer
170 } // namespace graphics
171 } // namespace hardware
172 } // namespace android
173