2 // Copyright (c) 2018 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef _ALIOS_HWC1_H_
18 #define _ALIOS_HWC1_H_
20 #include <cutils/hwflinger.h>
21 #include <cutils/hwflinger_defs.h>
23 #include <nativedisplay.h>
25 #include <gpudevice.h>
32 #define USER_FENCE_SYNC 0
35 typedef struct hwf_module_wrapper_t
38 void *priv; /**< Driver private data */
39 } hwf_module_wrapper_t;
42 namespace hwcomposer {
44 class DisplayTimeLine {
48 timeline_fd_ = open("/dev/sw_sync", O_RDWR);
61 if (timeline_fd_ > 0) {
67 int32_t IncrementTimeLine() {
70 sw_sync_fence_create(timeline_fd_, "display fence", timeline_pt_ + 1);
72 LOG_E("Failed to create display fence %d %d", ret, timeline_fd_);
78 ret = sw_sync_timeline_inc(timeline_fd_, 1);
80 LOG_E("Failed to increment display sync timeline %d", ret);
97 typedef struct HwfLayer {
99 delete hwc_layer_; // TO DO
103 HwfLayer() = default;
105 HwfLayer(const HwfLayer& rhs) = delete;
106 HwfLayer& operator=(const HwfLayer& rhs) = delete;
108 struct yalloc_handle native_handle_; // TO DO
109 hwcomposer::HwcLayer* hwc_layer_ = NULL;
112 int InitFromHwcLayer(hwf_layer_t* sf_layer);
115 typedef struct HwfDisplay {
116 // struct HwfDevice *ctx;
117 hwcomposer::NativeDisplay* display_ = NULL; // TO DO
118 uint32_t display_id_ = 0;
120 int last_render_layers_size = -1;
121 std::vector<HwfLayer*> layers_;
122 DisplayTimeLine timeline_;
123 bool gl_composition_ = false;
132 hwcomposer::GpuDevice device_;
133 std::vector<HwfDisplay> extended_displays_;
134 HwfDisplay primary_display_;
135 HwfDisplay virtual_display_;
137 /* Note: explicit sync isn't implemented currently, set it to 'false' just
138 let the logic run, all the fence is set as -1.
140 bool disable_explicit_sync_ = false;
142 hwf_callback* m_phwf_callback;
144 HwfDisplay* GetDisplay(int display);
146 static int detect(struct hwf_device_t* device, int dispCount,
147 hwf_display_t** displays);
149 static int flip(struct hwf_device_t* device, int dispCount,
150 hwf_display_t** displays);
152 static int setEventState(struct hwf_device_t* device, int disp, int event,
155 static int setDisplayState(struct hwf_device_t* device, int disp, int state);
157 static int lookup(struct hwf_device_t* device, int what, int* value);
159 static void registerCallback(struct hwf_device_t* device,
160 hwf_callback_t const* callback);
162 static int queryDispConfigs(struct hwf_device_t* device, int disp,
163 uint32_t* configs, int* numConfigs);
165 static int queryDispAttribs(struct hwf_device_t* device, int disp,
166 uint32_t config, const uint32_t* attributes,
169 static void dump(struct hwf_device_t* device, char* buff, int buff_len);
172 class ia_hwf_yunhal {
180 HwfDevice* get_hwf_hw();