blob: b3f3374dae8b30d68f280d56ae081c2f3848d6b5 [file] [log] [blame]
Peiyong Lin781d0bb2019-07-03 10:57:02 -07001/*
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 Lin781d0bb2019-07-03 10:57:02 -070019namespace android {
20namespace hardware {
21namespace graphics {
22namespace composer {
23namespace V2_4 {
24namespace vts {
25
Ady Abraham7882ae62019-10-10 17:04:47 -070026using V2_4::Error;
Peiyong Lin781d0bb2019-07-03 10:57:02 -070027
Peiyong Lin781d0bb2019-07-03 10:57:02 -070028Composer::Composer(const sp<IComposer>& composer)
29 : V2_3::vts::Composer(composer), mComposer(composer) {}
30
31std::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
41sp<IComposerClient> ComposerClient::getRaw() const {
42 return mClient;
43}
44
45Error ComposerClient::getDisplayCapabilities(
46 Display display, std::vector<IComposerClient::DisplayCapability>* outCapabilities) {
Peiyong Lin781d0bb2019-07-03 10:57:02 -070047 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 Laskowskice44a4b2019-09-19 15:50:09 -070056Error 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 Abrahama1df7c32019-10-22 16:56:08 -070066int32_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 Abraham7882ae62019-10-10 17:04:47 -070075 });
Ady Abrahama1df7c32019-10-22 16:56:08 -070076
77 return value;
Ady Abraham7882ae62019-10-10 17:04:47 -070078}
79
Ady Abraham5f9f9a42020-01-02 14:28:39 -080080void ComposerClient::registerCallback_2_4(const sp<IComposerCallback>& callback) {
81 mClient->registerCallback_2_4(callback);
82}
83
Ady Abraham7882ae62019-10-10 17:04:47 -070084Error 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 Abrahama1df7c32019-10-22 16:56:08 -070093Error ComposerClient::setActiveConfigWithConstraints(
94 Display display, Config config,
Ady Abraham7882ae62019-10-10 17:04:47 -070095 const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
Ady Abrahama1df7c32019-10-22 16:56:08 -070096 VsyncPeriodChangeTimeline* timeline) {
Ady Abraham7882ae62019-10-10 17:04:47 -070097 Error error = Error::NONE;
Ady Abrahama1df7c32019-10-22 16:56:08 -070098 mClient->setActiveConfigWithConstraints(display, config, vsyncPeriodChangeConstraints,
99 [&](const auto& tmpError, const auto& tmpTimeline) {
100 error = tmpError;
101 *timeline = tmpTimeline;
102 });
Ady Abraham7882ae62019-10-10 17:04:47 -0700103 return error;
104}
105
Galia Peychevaa0973452019-11-01 11:04:42 +0100106Error ComposerClient::setAutoLowLatencyMode(Display display, bool on) {
107 return mClient->setAutoLowLatencyMode(display, on);
108}
109
110Error 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
121Error ComposerClient::setContentType(Display display, IComposerClient::ContentType contentType) {
122 return mClient->setContentType(display, contentType);
123}
124
Dan Stozaa4bea0e2019-10-21 15:43:55 -0700125Error 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 Abrahamf6820b22020-02-07 17:39:56 -0800135void 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 Lin781d0bb2019-07-03 10:57:02 -0700167} // namespace vts
168} // namespace V2_4
169} // namespace composer
170} // namespace graphics
171} // namespace hardware
172} // namespace android