1 /*
2  * Copyright 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 #pragma once
18 
19 #include <android-base/unique_fd.h>
20 #include <android/hardware/graphics/composer/2.2/IComposer.h>
21 #include <android/hardware/graphics/composer/2.2/IComposerClient.h>
22 #include <composer-hal/2.1/ComposerHal.h>
23 
24 namespace android {
25 namespace hardware {
26 namespace graphics {
27 namespace composer {
28 namespace V2_2 {
29 namespace hal {
30 
31 using common::V1_1::ColorMode;
32 using common::V1_1::Dataspace;
33 using common::V1_1::PixelFormat;
34 using common::V1_1::RenderIntent;
35 using V2_1::Display;
36 using V2_1::Error;
37 using V2_1::Layer;
38 
39 class ComposerHal : public V2_1::hal::ComposerHal {
40    public:
createVirtualDisplay(uint32_t width,uint32_t height,common::V1_0::PixelFormat * format,Display * outDisplay)41     Error createVirtualDisplay(uint32_t width, uint32_t height, common::V1_0::PixelFormat* format,
42                                Display* outDisplay) override {
43         return createVirtualDisplay_2_2(width, height, reinterpret_cast<PixelFormat*>(format),
44                                         outDisplay);
45     }
getClientTargetSupport(Display display,uint32_t width,uint32_t height,common::V1_0::PixelFormat format,common::V1_0::Dataspace dataspace)46     Error getClientTargetSupport(Display display, uint32_t width, uint32_t height,
47                                  common::V1_0::PixelFormat format,
48                                  common::V1_0::Dataspace dataspace) override {
49         return getClientTargetSupport_2_2(display, width, height, static_cast<PixelFormat>(format),
50                                           static_cast<Dataspace>(dataspace));
51     }
52     // superceded by setPowerMode_2_2
setPowerMode(Display display,V2_1::IComposerClient::PowerMode mode)53     Error setPowerMode(Display display, V2_1::IComposerClient::PowerMode mode) override {
54         return setPowerMode_2_2(display, static_cast<IComposerClient::PowerMode>(mode));
55     }
56 
57     // superceded by getColorModes_2_2
getColorModes(Display display,hidl_vec<common::V1_0::ColorMode> * outModes)58     Error getColorModes(Display display, hidl_vec<common::V1_0::ColorMode>* outModes) override {
59         return getColorModes_2_2(display, reinterpret_cast<hidl_vec<ColorMode>*>(outModes));
60     }
61 
62     // superceded by setColorMode_2_2
setColorMode(Display display,common::V1_0::ColorMode mode)63     Error setColorMode(Display display, common::V1_0::ColorMode mode) override {
64         return setColorMode_2_2(display, static_cast<ColorMode>(mode), RenderIntent::COLORIMETRIC);
65     }
66 
67     virtual Error getPerFrameMetadataKeys(
68         Display display, std::vector<IComposerClient::PerFrameMetadataKey>* outKeys) = 0;
69     virtual Error setLayerPerFrameMetadata(
70         Display display, Layer layer,
71         const std::vector<IComposerClient::PerFrameMetadata>& metadata) = 0;
72 
73     virtual Error getReadbackBufferAttributes(Display display, PixelFormat* outFormat,
74                                               Dataspace* outDataspace) = 0;
75     virtual Error setReadbackBuffer(Display display, const native_handle_t* bufferHandle,
76                                     base::unique_fd fenceFd) = 0;
77     virtual Error getReadbackBufferFence(Display display, base::unique_fd* outFenceFd) = 0;
78     virtual Error createVirtualDisplay_2_2(uint32_t width, uint32_t height, PixelFormat* format,
79                                            Display* outDisplay) = 0;
80     virtual Error getClientTargetSupport_2_2(Display display, uint32_t width, uint32_t height,
81                                              PixelFormat format, Dataspace dataspace) = 0;
82     virtual Error setPowerMode_2_2(Display display, IComposerClient::PowerMode mode) = 0;
83 
84     virtual Error setLayerFloatColor(Display display, Layer layer,
85                                      IComposerClient::FloatColor color) = 0;
86 
87     virtual Error getColorModes_2_2(Display display, hidl_vec<ColorMode>* outModes) = 0;
88     virtual Error getRenderIntents(Display display, ColorMode mode,
89                                    std::vector<RenderIntent>* outIntents) = 0;
90     virtual Error setColorMode_2_2(Display display, ColorMode mode, RenderIntent intent) = 0;
91 
92     virtual std::array<float, 16> getDataspaceSaturationMatrix(Dataspace dataspace) = 0;
93 };
94 
95 }  // namespace hal
96 }  // namespace V2_2
97 }  // namespace composer
98 }  // namespace graphics
99 }  // namespace hardware
100 }  // namespace android
101