blob: 8a9c00608d9ccbea8a2eb976e1fad74fb31103b5 [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
19#include <VtsHalHidlTargetTestBase.h>
20
21namespace android {
22namespace hardware {
23namespace graphics {
24namespace composer {
25namespace V2_4 {
26namespace vts {
27
Ady Abraham7882ae62019-10-10 17:04:47 -070028using V2_4::Error;
Peiyong Lin781d0bb2019-07-03 10:57:02 -070029
30Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {}
31
32Composer::Composer(const std::string& name)
33 : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name)) {}
34
35Composer::Composer(const sp<IComposer>& composer)
36 : V2_3::vts::Composer(composer), mComposer(composer) {}
37
38std::unique_ptr<ComposerClient> Composer::createClient() {
39 std::unique_ptr<ComposerClient> client;
40 mComposer->createClient_2_4([&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
48sp<IComposerClient> ComposerClient::getRaw() const {
49 return mClient;
50}
51
52Error ComposerClient::getDisplayCapabilities(
53 Display display, std::vector<IComposerClient::DisplayCapability>* outCapabilities) {
Peiyong Lin781d0bb2019-07-03 10:57:02 -070054 Error error = Error::NONE;
55 mClient->getDisplayCapabilities_2_4(display,
56 [&](const auto& tmpError, const auto& tmpCapabilities) {
57 error = tmpError;
58 *outCapabilities = tmpCapabilities;
59 });
60 return error;
61}
62
Dominik Laskowskice44a4b2019-09-19 15:50:09 -070063Error ComposerClient::getDisplayConnectionType(Display display,
64 IComposerClient::DisplayConnectionType* outType) {
65 Error error = Error::NONE;
66 mClient->getDisplayConnectionType(display, [&](const auto& tmpError, const auto& tmpType) {
67 error = tmpError;
68 *outType = tmpType;
69 });
70 return error;
71}
72
Ady Abrahama1df7c32019-10-22 16:56:08 -070073int32_t ComposerClient::getDisplayAttribute_2_4(
74 android::hardware::graphics::composer::V2_1::Display display,
75 android::hardware::graphics::composer::V2_1::Config config,
76 IComposerClient::Attribute attribute) {
77 int32_t value = 0;
78 mClient->getDisplayAttribute_2_4(
79 display, config, attribute, [&](const auto& tmpError, const auto& tmpValue) {
80 ASSERT_EQ(Error::NONE, tmpError) << "failed to get display attribute";
81 value = tmpValue;
Ady Abraham7882ae62019-10-10 17:04:47 -070082 });
Ady Abrahama1df7c32019-10-22 16:56:08 -070083
84 return value;
Ady Abraham7882ae62019-10-10 17:04:47 -070085}
86
Ady Abraham5f9f9a42020-01-02 14:28:39 -080087void ComposerClient::registerCallback_2_4(const sp<IComposerCallback>& callback) {
88 mClient->registerCallback_2_4(callback);
89}
90
Ady Abraham7882ae62019-10-10 17:04:47 -070091Error ComposerClient::getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriod) {
92 Error error = Error::NONE;
93 mClient->getDisplayVsyncPeriod(display, [&](const auto& tmpError, const auto& tmpVsyncPeriod) {
94 error = tmpError;
95 *outVsyncPeriod = tmpVsyncPeriod;
96 });
97 return error;
98}
99
Ady Abrahama1df7c32019-10-22 16:56:08 -0700100Error ComposerClient::setActiveConfigWithConstraints(
101 Display display, Config config,
Ady Abraham7882ae62019-10-10 17:04:47 -0700102 const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
Ady Abrahama1df7c32019-10-22 16:56:08 -0700103 VsyncPeriodChangeTimeline* timeline) {
Ady Abraham7882ae62019-10-10 17:04:47 -0700104 Error error = Error::NONE;
Ady Abrahama1df7c32019-10-22 16:56:08 -0700105 mClient->setActiveConfigWithConstraints(display, config, vsyncPeriodChangeConstraints,
106 [&](const auto& tmpError, const auto& tmpTimeline) {
107 error = tmpError;
108 *timeline = tmpTimeline;
109 });
Ady Abraham7882ae62019-10-10 17:04:47 -0700110 return error;
111}
112
Galia Peychevaa0973452019-11-01 11:04:42 +0100113Error ComposerClient::setAutoLowLatencyMode(Display display, bool on) {
114 return mClient->setAutoLowLatencyMode(display, on);
115}
116
117Error ComposerClient::getSupportedContentTypes(
118 Display display, std::vector<IComposerClient::ContentType>* outSupportedContentTypes) {
119 Error error = Error::NONE;
120 mClient->getSupportedContentTypes(
121 display, [&](const auto& tmpError, const auto& tmpSupportedContentTypes) {
122 error = tmpError;
123 *outSupportedContentTypes = tmpSupportedContentTypes;
124 });
125 return error;
126}
127
128Error ComposerClient::setContentType(Display display, IComposerClient::ContentType contentType) {
129 return mClient->setContentType(display, contentType);
130}
131
Peiyong Lin781d0bb2019-07-03 10:57:02 -0700132} // namespace vts
133} // namespace V2_4
134} // namespace composer
135} // namespace graphics
136} // namespace hardware
137} // namespace android