blob: 93049929db8bc94e8e7b169e6399075fefd7e62d [file] [log] [blame]
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -07001/*
2 * Copyright (C) 2018 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.3/ComposerVts.h>
18
19#include <VtsHalHidlTargetTestBase.h>
20
21namespace android {
22namespace hardware {
23namespace graphics {
24namespace composer {
25namespace V2_3 {
26namespace vts {
27
28using V2_1::Error;
29
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_2::vts::Composer(composer), mComposer(composer) {}
37
38std::unique_ptr<ComposerClient> Composer::createClient() {
39 std::unique_ptr<ComposerClient> client;
40 mComposer->createClient_2_3([&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
Valerie Hauec983062018-10-09 16:09:12 -070048sp<IComposerClient> ComposerClient::getRaw() const {
49 return mClient;
50}
51
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -070052bool ComposerClient::getDisplayIdentificationData(Display display, uint8_t* outPort,
53 std::vector<uint8_t>* outData) {
54 bool supported = true;
55 mClient->getDisplayIdentificationData(
56 display, [&](const auto& tmpError, const auto& tmpPort, const auto& tmpData) {
57 if (tmpError == Error::UNSUPPORTED) {
58 supported = false;
59 return;
60 }
61 ASSERT_EQ(Error::NONE, tmpError) << "failed to get display identification data";
62
63 *outPort = tmpPort;
64 *outData = tmpData;
65 ASSERT_FALSE(outData->empty()) << "data is empty";
66 });
67
68 return supported;
69}
70
Valerie Hauec983062018-10-09 16:09:12 -070071std::vector<ColorMode> ComposerClient::getColorModes_2_3(Display display) {
72 std::vector<ColorMode> modes;
73 mClient->getColorModes_2_3(display, [&](const auto& tmpError, const auto& tmpModes) {
74 ASSERT_EQ(Error::NONE, tmpError) << "failed to get color modes";
75 modes = tmpModes;
76 });
77 return modes;
78}
79
80void ComposerClient::setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent) {
81 Error error = mClient->setColorMode_2_3(display, mode, intent);
82 ASSERT_TRUE(error == Error::NONE || error == Error::UNSUPPORTED) << "failed to set color mode";
83}
84
85std::vector<RenderIntent> ComposerClient::getRenderIntents_2_3(Display display, ColorMode mode) {
86 std::vector<RenderIntent> intents;
87 mClient->getRenderIntents_2_3(display, mode, [&](const auto& tmpError, const auto& tmpIntents) {
88 ASSERT_EQ(Error::NONE, tmpError) << "failed to get render intents";
89 intents = tmpIntents;
90 });
91 return intents;
92}
93
94void ComposerClient::getReadbackBufferAttributes_2_3(Display display, PixelFormat* outPixelFormat,
95 Dataspace* outDataspace) {
96 mClient->getReadbackBufferAttributes_2_3(
97 display,
98 [&](const auto& tmpError, const auto& tmpOutPixelFormat, const auto& tmpOutDataspace) {
99 ASSERT_EQ(Error::NONE, tmpError) << "failed to get readback buffer attributes";
100 *outPixelFormat = tmpOutPixelFormat;
101 *outDataspace = tmpOutDataspace;
102 });
103}
104
105bool ComposerClient::getClientTargetSupport_2_3(Display display, uint32_t width, uint32_t height,
106 PixelFormat format, Dataspace dataspace) {
107 Error error = mClient->getClientTargetSupport_2_3(display, width, height, format, dataspace);
108 return error == Error::NONE;
109}
110
Kevin DuBoisbf141482018-09-10 09:07:54 -0700111Error ComposerClient::getDisplayedContentSamplingAttributes(
112 uint64_t display, PixelFormat& format, Dataspace& dataspace,
113 hidl_bitfield<IComposerClient::FormatColorComponent>& componentMask) {
114 auto error = Error::BAD_PARAMETER;
115 mClient->getDisplayedContentSamplingAttributes(
116 display, [&](const auto& tmpError, const auto& tmpFormat, const auto& tmpDataspace,
117 const auto& tmpComponentMask) {
118 error = tmpError;
119 format = tmpFormat;
120 dataspace = tmpDataspace;
121 componentMask = tmpComponentMask;
122 });
123 return error;
124}
125
126Error ComposerClient::setDisplayedContentSamplingEnabled(
127 uint64_t display, IComposerClient::DisplayedContentSampling enable,
128 hidl_bitfield<IComposerClient::FormatColorComponent> componentMask, uint64_t maxFrames) {
129 return mClient->setDisplayedContentSamplingEnabled(display, enable, componentMask, maxFrames);
130}
131
132Error ComposerClient::getDisplayedContentSample(uint64_t display, uint64_t maxFrames,
133 uint64_t timestamp, uint64_t& frameCount,
134 hidl_vec<uint64_t>& sampleComponent0,
135 hidl_vec<uint64_t>& sampleComponent1,
136 hidl_vec<uint64_t>& sampleComponent2,
137 hidl_vec<uint64_t>& sampleComponent3) {
138 auto error = Error::BAD_PARAMETER;
139 mClient->getDisplayedContentSample(
140 display, maxFrames, timestamp,
141 [&](const auto& tmpError, const auto& tmpFrameCount, const auto& tmpSamples0,
142 const auto& tmpSamples1, const auto& tmpSamples2, const auto& tmpSamples3) {
143 error = tmpError;
144 frameCount = tmpFrameCount;
145 sampleComponent0 = tmpSamples0;
146 sampleComponent1 = tmpSamples1;
147 sampleComponent2 = tmpSamples2;
148 sampleComponent3 = tmpSamples3;
149 });
150 return error;
151}
152
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -0700153} // namespace vts
154} // namespace V2_3
155} // namespace composer
156} // namespace graphics
157} // namespace hardware
158} // namespace android