blob: b02a59a90a74e266eacd2e49ca539849023f94df [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 Abraham7882ae62019-10-10 17:04:47 -070073Error ComposerClient::getSupportedDisplayVsyncPeriods(
74 Display display, Config config, std::vector<VsyncPeriodNanos>* outSupportedVsyncPeriods) {
75 Error error = Error::NONE;
76 mClient->getSupportedDisplayVsyncPeriods(
77 display, config, [&](const auto& tmpError, const auto& tmpSupportedVsyncPeriods) {
78 error = tmpError;
79 *outSupportedVsyncPeriods = tmpSupportedVsyncPeriods;
80 });
81 return error;
82}
83
84Error 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
93Error ComposerClient::setActiveConfigAndVsyncPeriod(
94 Display display, Config config, VsyncPeriodNanos vsyncPeriodNanos,
95 const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
96 int64_t* outNewVsyncAppliedTime) {
97 Error error = Error::NONE;
98 mClient->setActiveConfigAndVsyncPeriod(
99 display, config, vsyncPeriodNanos, vsyncPeriodChangeConstraints,
100 [&](const auto& tmpError, const auto& tmpNewVsyncAppliedTime) {
101 error = tmpError;
102 *outNewVsyncAppliedTime = tmpNewVsyncAppliedTime;
103 });
104 return error;
105}
106
Peiyong Lin781d0bb2019-07-03 10:57:02 -0700107} // namespace vts
108} // namespace V2_4
109} // namespace composer
110} // namespace graphics
111} // namespace hardware
112} // namespace android