Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 <errno.h> |
| 18 | #include <fcntl.h> |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 19 | #include <poll.h> |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 20 | #include <pthread.h> |
| 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
| 23 | |
| 24 | #include <sys/ioctl.h> |
| 25 | #include <sys/mman.h> |
| 26 | #include <sys/time.h> |
| 27 | #include <sys/resource.h> |
| 28 | |
| 29 | #include <s3c-fb.h> |
| 30 | |
| 31 | #include <EGL/egl.h> |
| 32 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 33 | #define HWC_REMOVE_DEPRECATED_VERSIONS 1 |
| 34 | |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 35 | #include <cutils/log.h> |
| 36 | #include <hardware/gralloc.h> |
| 37 | #include <hardware/hardware.h> |
| 38 | #include <hardware/hwcomposer.h> |
| 39 | #include <hardware_legacy/uevent.h> |
| 40 | #include <utils/Vector.h> |
| 41 | |
Greg Hackmann | f4cc0c3 | 2012-05-30 09:28:52 -0700 | [diff] [blame] | 42 | #include <sync/sync.h> |
| 43 | |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 44 | #include "ump.h" |
| 45 | #include "ion.h" |
| 46 | #include "gralloc_priv.h" |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 47 | #include "exynos_gscaler.h" |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 48 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 49 | struct hwc_callback_entry { |
| 50 | void (*callback)(void *, private_handle_t *); |
| 51 | void *data; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 52 | }; |
| 53 | typedef android::Vector<struct hwc_callback_entry> hwc_callback_queue_t; |
| 54 | |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 55 | const size_t NUM_HW_WINDOWS = 5; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 56 | const size_t NO_FB_NEEDED = NUM_HW_WINDOWS + 1; |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 57 | const size_t MAX_PIXELS = 2560 * 1600 * 2; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 58 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 59 | struct exynos5_hwc_composer_device_1_t; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 60 | |
| 61 | struct exynos5_hwc_post_data_t { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 62 | exynos5_hwc_composer_device_1_t *pdev; |
| 63 | int overlay_map[NUM_HW_WINDOWS]; |
| 64 | hwc_layer_1_t overlays[NUM_HW_WINDOWS]; |
| 65 | int num_overlays; |
| 66 | size_t fb_window; |
| 67 | int fence; |
| 68 | pthread_mutex_t completion_lock; |
| 69 | pthread_cond_t completion; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 72 | struct exynos5_hwc_composer_device_1_t { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 73 | hwc_composer_device_1_t base; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 74 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 75 | int fd; |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 76 | int vsync_fd; |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 77 | exynos5_hwc_post_data_t bufs; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 78 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 79 | const private_module_t *gralloc_module; |
| 80 | hwc_procs_t *procs; |
| 81 | pthread_t vsync_thread; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 82 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 83 | bool hdmi_hpd; |
| 84 | bool hdmi_mirroring; |
| 85 | void *hdmi_gsc; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 88 | static void dump_layer(hwc_layer_1_t const *l) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 89 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 90 | ALOGV("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, " |
| 91 | "{%d,%d,%d,%d}, {%d,%d,%d,%d}", |
| 92 | l->compositionType, l->flags, l->handle, l->transform, |
| 93 | l->blending, |
| 94 | l->sourceCrop.left, |
| 95 | l->sourceCrop.top, |
| 96 | l->sourceCrop.right, |
| 97 | l->sourceCrop.bottom, |
| 98 | l->displayFrame.left, |
| 99 | l->displayFrame.top, |
| 100 | l->displayFrame.right, |
| 101 | l->displayFrame.bottom); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | static void dump_handle(private_handle_t *h) |
| 105 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 106 | ALOGV("\t\tformat = %d, width = %u, height = %u, bpp = %u, stride = %u", |
| 107 | h->format, h->width, h->height, h->bpp, h->stride); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | static void dump_config(s3c_fb_win_config &c) |
| 111 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 112 | ALOGV("\tstate = %u", c.state); |
| 113 | if (c.state == c.S3C_FB_WIN_STATE_BUFFER) { |
| 114 | ALOGV("\t\tfd = %d, offset = %u, stride = %u, " |
| 115 | "x = %d, y = %d, w = %u, h = %u, " |
| 116 | "format = %u", |
| 117 | c.fd, c.offset, c.stride, |
| 118 | c.x, c.y, c.w, c.h, |
| 119 | c.format); |
| 120 | } |
| 121 | else if (c.state == c.S3C_FB_WIN_STATE_COLOR) { |
| 122 | ALOGV("\t\tcolor = %u", c.color); |
| 123 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | inline int WIDTH(const hwc_rect &rect) { return rect.right - rect.left; } |
| 127 | inline int HEIGHT(const hwc_rect &rect) { return rect.bottom - rect.top; } |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 128 | template<typename T> inline T max(T a, T b) { return (a > b) ? a : b; } |
| 129 | template<typename T> inline T min(T a, T b) { return (a < b) ? a : b; } |
| 130 | |
| 131 | static bool is_transformed(const hwc_layer_1_t &layer) |
| 132 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 133 | return layer.transform != 0; |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 134 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 135 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 136 | static bool is_scaled(const hwc_layer_1_t &layer) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 137 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 138 | return WIDTH(layer.displayFrame) != WIDTH(layer.sourceCrop) || |
| 139 | HEIGHT(layer.displayFrame) != HEIGHT(layer.sourceCrop); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | static enum s3c_fb_pixel_format exynos5_format_to_s3c_format(int format) |
| 143 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 144 | switch (format) { |
| 145 | case HAL_PIXEL_FORMAT_RGBA_8888: |
| 146 | return S3C_FB_PIXEL_FORMAT_RGBA_8888; |
| 147 | case HAL_PIXEL_FORMAT_RGBX_8888: |
| 148 | return S3C_FB_PIXEL_FORMAT_RGBX_8888; |
| 149 | case HAL_PIXEL_FORMAT_RGBA_5551: |
| 150 | return S3C_FB_PIXEL_FORMAT_RGBA_5551; |
| 151 | case HAL_PIXEL_FORMAT_RGBA_4444: |
| 152 | return S3C_FB_PIXEL_FORMAT_RGBA_4444; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 153 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 154 | default: |
| 155 | return S3C_FB_PIXEL_FORMAT_MAX; |
| 156 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | static bool exynos5_format_is_supported(int format) |
| 160 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 161 | return exynos5_format_to_s3c_format(format) < S3C_FB_PIXEL_FORMAT_MAX; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | static bool exynos5_format_is_supported_by_gscaler(int format) |
| 165 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 166 | switch(format) { |
| 167 | case HAL_PIXEL_FORMAT_RGBA_8888: |
| 168 | case HAL_PIXEL_FORMAT_RGBX_8888: |
| 169 | case HAL_PIXEL_FORMAT_RGB_565: |
| 170 | case HAL_PIXEL_FORMAT_YV12: |
| 171 | return true; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 172 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 173 | default: |
| 174 | return false; |
| 175 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | static uint8_t exynos5_format_to_bpp(int format) |
| 179 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 180 | switch (format) { |
| 181 | case HAL_PIXEL_FORMAT_RGBA_8888: |
| 182 | case HAL_PIXEL_FORMAT_RGBX_8888: |
| 183 | return 32; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 184 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 185 | case HAL_PIXEL_FORMAT_RGBA_5551: |
| 186 | case HAL_PIXEL_FORMAT_RGBA_4444: |
| 187 | return 16; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 188 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 189 | default: |
| 190 | ALOGW("unrecognized pixel format %u", format); |
| 191 | return 0; |
| 192 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 193 | } |
| 194 | |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 195 | static int hdmi_enable(struct exynos5_hwc_composer_device_1_t *dev) |
| 196 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 197 | if (dev->hdmi_mirroring) |
| 198 | return 0; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 199 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 200 | exynos_gsc_img src_info; |
| 201 | exynos_gsc_img dst_info; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 202 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 203 | // TODO: Don't hardcode |
| 204 | int src_w = 2560; |
| 205 | int src_h = 1600; |
| 206 | int dst_w = 1920; |
| 207 | int dst_h = 1080; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 208 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 209 | dev->hdmi_gsc = exynos_gsc_create_exclusive(3, GSC_OUTPUT_MODE, GSC_OUT_TV); |
| 210 | if (!dev->hdmi_gsc) { |
| 211 | ALOGE("%s: exynos_gsc_create_exclusive failed", __func__); |
| 212 | return -ENODEV; |
| 213 | } |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 214 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 215 | memset(&src_info, 0, sizeof(src_info)); |
| 216 | memset(&dst_info, 0, sizeof(dst_info)); |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 217 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 218 | src_info.w = src_w; |
| 219 | src_info.h = src_h; |
| 220 | src_info.fw = src_w; |
| 221 | src_info.fh = src_h; |
| 222 | src_info.format = HAL_PIXEL_FORMAT_BGRA_8888; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 223 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 224 | dst_info.w = dst_w; |
| 225 | dst_info.h = dst_h; |
| 226 | dst_info.fw = dst_w; |
| 227 | dst_info.fh = dst_h; |
| 228 | dst_info.format = HAL_PIXEL_FORMAT_YV12; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 229 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 230 | int ret = exynos_gsc_config_exclusive(dev->hdmi_gsc, &src_info, &dst_info); |
| 231 | if (ret < 0) { |
| 232 | ALOGE("%s: exynos_gsc_config_exclusive failed %d", __func__, ret); |
| 233 | exynos_gsc_destroy(dev->hdmi_gsc); |
| 234 | dev->hdmi_gsc = NULL; |
| 235 | return ret; |
| 236 | } |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 237 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 238 | dev->hdmi_mirroring = true; |
| 239 | return 0; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | static void hdmi_disable(struct exynos5_hwc_composer_device_1_t *dev) |
| 243 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 244 | if (!dev->hdmi_mirroring) |
| 245 | return; |
| 246 | exynos_gsc_destroy(dev->hdmi_gsc); |
| 247 | dev->hdmi_gsc = NULL; |
| 248 | dev->hdmi_mirroring = false; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | static int hdmi_output(struct exynos5_hwc_composer_device_1_t *dev, private_handle_t *fb) |
| 252 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 253 | exynos_gsc_img src_info; |
| 254 | exynos_gsc_img dst_info; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 255 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 256 | memset(&src_info, 0, sizeof(src_info)); |
| 257 | memset(&dst_info, 0, sizeof(dst_info)); |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 258 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 259 | src_info.yaddr = fb->fd; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 260 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 261 | int ret = exynos_gsc_run_exclusive(dev->hdmi_gsc, &src_info, &dst_info); |
| 262 | if (ret < 0) { |
| 263 | ALOGE("%s: exynos_gsc_run_exclusive failed %d", __func__, ret); |
| 264 | return ret; |
| 265 | } |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 266 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 267 | return 0; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 268 | } |
| 269 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 270 | bool exynos5_supports_overlay(hwc_layer_1_t &layer, size_t i) |
| 271 | { |
| 272 | private_handle_t *handle = private_handle_t::dynamicCast(layer.handle); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 273 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 274 | if (!handle) { |
| 275 | ALOGV("\tlayer %u: handle is NULL", i); |
| 276 | return false; |
| 277 | } |
| 278 | if (!exynos5_format_is_supported(handle->format)) { |
| 279 | ALOGV("\tlayer %u: pixel format %u not supported", i, |
| 280 | handle->format); |
| 281 | return false; |
| 282 | } |
| 283 | if (is_scaled(layer)) { |
| 284 | ALOGV("\tlayer %u: scaling not supported", i); |
| 285 | return false; |
| 286 | } |
| 287 | if (is_transformed(layer)) { |
| 288 | ALOGV("\tlayer %u: transformations not supported", i); |
| 289 | return false; |
| 290 | } |
| 291 | if (layer.blending != HWC_BLENDING_NONE) { |
| 292 | // TODO: support this |
| 293 | ALOGV("\tlayer %u: blending not supported", i); |
| 294 | return false; |
| 295 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 296 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 297 | return true; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 300 | inline bool intersect(const hwc_rect &r1, const hwc_rect &r2) |
| 301 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 302 | return !(r1.left > r2.right || |
| 303 | r1.right < r2.left || |
| 304 | r1.top > r2.bottom || |
| 305 | r1.bottom < r2.top); |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | inline hwc_rect intersection(const hwc_rect &r1, const hwc_rect &r2) |
| 309 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 310 | hwc_rect i; |
| 311 | i.top = max(r1.top, r2.top); |
| 312 | i.bottom = min(r1.bottom, r2.bottom); |
| 313 | i.left = max(r1.left, r2.left); |
| 314 | i.right = min(r1.right, r2.right); |
| 315 | return i; |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 316 | } |
| 317 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 318 | static int exynos5_prepare(hwc_composer_device_1_t *dev, hwc_layer_list_1_t* list) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 319 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 320 | if (!list) |
| 321 | return 0; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 322 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 323 | ALOGV("preparing %u layers", list->numHwLayers); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 324 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 325 | exynos5_hwc_composer_device_1_t *pdev = |
| 326 | (exynos5_hwc_composer_device_1_t *)dev; |
| 327 | memset(pdev->bufs.overlays, 0, sizeof(pdev->bufs.overlays)); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 328 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 329 | bool force_fb = false; |
| 330 | if (pdev->hdmi_hpd) { |
| 331 | hdmi_enable(pdev); |
| 332 | force_fb = true; |
| 333 | } else { |
| 334 | hdmi_disable(pdev); |
| 335 | } |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 336 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 337 | for (size_t i = 0; i < NUM_HW_WINDOWS; i++) |
| 338 | pdev->bufs.overlay_map[i] = -1; |
| 339 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 340 | bool fb_needed = false; |
| 341 | size_t first_fb = 0, last_fb = 0; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 342 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 343 | // find unsupported overlays |
| 344 | for (size_t i = 0; i < list->numHwLayers; i++) { |
| 345 | hwc_layer_1_t &layer = list->hwLayers[i]; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 346 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 347 | if (layer.compositionType == HWC_BACKGROUND && !force_fb) { |
| 348 | ALOGV("\tlayer %u: background supported", i); |
| 349 | continue; |
| 350 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 351 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 352 | if (exynos5_supports_overlay(list->hwLayers[i], i) && !force_fb) { |
| 353 | ALOGV("\tlayer %u: overlay supported", i); |
| 354 | layer.compositionType = HWC_OVERLAY; |
| 355 | continue; |
| 356 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 357 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 358 | if (!fb_needed) { |
| 359 | first_fb = i; |
| 360 | fb_needed = true; |
| 361 | } |
| 362 | last_fb = i; |
| 363 | layer.compositionType = HWC_FRAMEBUFFER; |
| 364 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 365 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 366 | // can't composite overlays sandwiched between framebuffers |
| 367 | if (fb_needed) |
| 368 | for (size_t i = first_fb; i < last_fb; i++) |
| 369 | list->hwLayers[i].compositionType = HWC_FRAMEBUFFER; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 370 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 371 | // Incrementally try to add our supported layers to hardware windows. |
| 372 | // If adding a layer would violate a hardware constraint, force it |
| 373 | // into the framebuffer and try again. (Revisiting the entire list is |
| 374 | // necessary because adding a layer to the framebuffer can cause other |
| 375 | // windows to retroactively violate constraints.) |
| 376 | bool changed; |
| 377 | do { |
| 378 | android::Vector<hwc_rect> rects; |
| 379 | android::Vector<hwc_rect> overlaps; |
| 380 | size_t pixels_left, windows_left; |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 381 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 382 | if (fb_needed) { |
| 383 | hwc_rect_t fb_rect; |
| 384 | fb_rect.top = fb_rect.left = 0; |
| 385 | fb_rect.right = pdev->gralloc_module->xres - 1; |
| 386 | fb_rect.bottom = pdev->gralloc_module->yres - 1; |
| 387 | pixels_left = MAX_PIXELS - pdev->gralloc_module->xres * |
| 388 | pdev->gralloc_module->yres; |
| 389 | windows_left = NUM_HW_WINDOWS - 1; |
| 390 | rects.push_back(fb_rect); |
| 391 | } |
| 392 | else { |
| 393 | pixels_left = MAX_PIXELS; |
| 394 | windows_left = NUM_HW_WINDOWS; |
| 395 | } |
| 396 | changed = false; |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 397 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 398 | for (size_t i = 0; i < list->numHwLayers; i++) { |
| 399 | hwc_layer_1_t &layer = list->hwLayers[i]; |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 400 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 401 | // we've already accounted for the framebuffer above |
| 402 | if (layer.compositionType == HWC_FRAMEBUFFER) |
| 403 | continue; |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 404 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 405 | // only layer 0 can be HWC_BACKGROUND, so we can |
| 406 | // unconditionally allow it without extra checks |
| 407 | if (layer.compositionType == HWC_BACKGROUND) { |
| 408 | windows_left--; |
| 409 | continue; |
| 410 | } |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 411 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 412 | size_t pixels_needed = WIDTH(layer.displayFrame) * |
| 413 | HEIGHT(layer.displayFrame); |
| 414 | bool can_compose = windows_left && pixels_needed <= pixels_left; |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 415 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 416 | // hwc_rect_t right and bottom values are normally exclusive; |
| 417 | // the intersection logic is simpler if we make them inclusive |
| 418 | hwc_rect_t visible_rect = layer.displayFrame; |
| 419 | visible_rect.right--; visible_rect.bottom--; |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 420 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 421 | // no more than 2 layers can overlap on a given pixel |
| 422 | for (size_t j = 0; can_compose && j < overlaps.size(); j++) { |
| 423 | if (intersect(visible_rect, overlaps.itemAt(j))) |
| 424 | can_compose = false; |
| 425 | } |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 426 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 427 | if (!can_compose) { |
| 428 | layer.compositionType = HWC_FRAMEBUFFER; |
| 429 | if (!fb_needed) { |
| 430 | first_fb = last_fb = i; |
| 431 | fb_needed = true; |
| 432 | } |
| 433 | else { |
| 434 | first_fb = min(i, first_fb); |
| 435 | last_fb = max(i, last_fb); |
| 436 | } |
| 437 | changed = true; |
| 438 | break; |
| 439 | } |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 440 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 441 | for (size_t j = 0; j < rects.size(); j++) { |
| 442 | const hwc_rect_t &other_rect = rects.itemAt(j); |
| 443 | if (intersect(visible_rect, other_rect)) |
| 444 | overlaps.push_back(intersection(visible_rect, other_rect)); |
| 445 | } |
| 446 | rects.push_back(visible_rect); |
| 447 | pixels_left -= pixels_needed; |
| 448 | windows_left--; |
| 449 | } |
Greg Hackmann | 31991d5 | 2012-07-13 13:23:11 -0700 | [diff] [blame] | 450 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 451 | if (changed) |
| 452 | for (size_t i = first_fb; i < last_fb; i++) |
| 453 | list->hwLayers[i].compositionType = HWC_FRAMEBUFFER; |
| 454 | } while(changed); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 455 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 456 | unsigned int nextWindow = 0; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 457 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 458 | for (size_t i = 0; i < list->numHwLayers; i++) { |
| 459 | hwc_layer_1_t &layer = list->hwLayers[i]; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 460 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 461 | if (fb_needed && i == first_fb) { |
| 462 | ALOGV("assigning framebuffer to window %u\n", |
| 463 | nextWindow); |
| 464 | nextWindow++; |
| 465 | continue; |
| 466 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 467 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 468 | if (layer.compositionType != HWC_FRAMEBUFFER) { |
| 469 | ALOGV("assigning layer %u to window %u", i, nextWindow); |
| 470 | pdev->bufs.overlay_map[nextWindow] = i; |
| 471 | nextWindow++; |
| 472 | } |
| 473 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 474 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 475 | if (fb_needed) |
| 476 | pdev->bufs.fb_window = first_fb; |
| 477 | else |
| 478 | pdev->bufs.fb_window = NO_FB_NEEDED; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 479 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 480 | for (size_t i = 0; i < list->numHwLayers; i++) { |
| 481 | dump_layer(&list->hwLayers[i]); |
| 482 | if(list->hwLayers[i].handle) |
| 483 | dump_handle(private_handle_t::dynamicCast( |
| 484 | list->hwLayers[i].handle)); |
| 485 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 486 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 487 | return 0; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | static void exynos5_config_handle(private_handle_t *handle, |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 491 | hwc_rect_t &sourceCrop, hwc_rect_t &displayFrame, |
| 492 | s3c_fb_win_config &cfg) |
| 493 | { |
| 494 | cfg.state = cfg.S3C_FB_WIN_STATE_BUFFER; |
| 495 | cfg.fd = handle->fd; |
| 496 | cfg.x = displayFrame.left; |
| 497 | cfg.y = displayFrame.top; |
| 498 | cfg.w = WIDTH(displayFrame); |
| 499 | cfg.h = HEIGHT(displayFrame); |
| 500 | cfg.format = exynos5_format_to_s3c_format(handle->format); |
| 501 | uint8_t bpp = exynos5_format_to_bpp(handle->format); |
| 502 | cfg.offset = (sourceCrop.top * handle->stride + sourceCrop.left) * bpp / 8; |
| 503 | cfg.stride = handle->stride * bpp / 8; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 504 | } |
| 505 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 506 | static void exynos5_config_overlay(hwc_layer_1_t *layer, s3c_fb_win_config &cfg, |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 507 | const private_module_t *gralloc_module) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 508 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 509 | if (layer->compositionType == HWC_BACKGROUND) { |
| 510 | hwc_color_t color = layer->backgroundColor; |
| 511 | cfg.state = cfg.S3C_FB_WIN_STATE_COLOR; |
| 512 | cfg.color = (color.r << 16) | (color.g << 8) | color.b; |
| 513 | cfg.x = 0; |
| 514 | cfg.y = 0; |
| 515 | cfg.w = gralloc_module->xres; |
| 516 | cfg.h = gralloc_module->yres; |
| 517 | return; |
| 518 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 519 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 520 | private_handle_t *handle = private_handle_t::dynamicCast(layer->handle); |
| 521 | exynos5_config_handle(handle, layer->sourceCrop, layer->displayFrame, cfg); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | static void exynos5_post_callback(void *data, private_handle_t *fb) |
| 525 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 526 | exynos5_hwc_post_data_t *pdata = (exynos5_hwc_post_data_t *)data; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 527 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 528 | struct s3c_fb_win_config_data win_data; |
| 529 | struct s3c_fb_win_config *config = win_data.config; |
| 530 | memset(config, 0, sizeof(win_data.config)); |
| 531 | for (size_t i = 0; i < NUM_HW_WINDOWS; i++) { |
| 532 | if (i == pdata->fb_window) { |
| 533 | hwc_rect_t rect = { 0, 0, fb->width, fb->height }; |
| 534 | exynos5_config_handle(fb, rect, rect, config[i]); |
| 535 | } else if ( pdata->overlay_map[i] != -1) { |
| 536 | exynos5_config_overlay(&pdata->overlays[i], config[i], |
| 537 | pdata->pdev->gralloc_module); |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 538 | if (pdata->overlays[i].acquireFenceFd != -1) { |
| 539 | int err = sync_wait(pdata->overlays[i].acquireFenceFd, 100); |
| 540 | if (err != 0) |
| 541 | ALOGW("fence for layer %zu didn't signal in 100 ms: %s", |
| 542 | i, strerror(errno)); |
| 543 | close(pdata->overlays[i].acquireFenceFd); |
| 544 | } |
| 545 | } |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 546 | dump_config(config[i]); |
| 547 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 548 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 549 | int ret = ioctl(pdata->pdev->fd, S3CFB_WIN_CONFIG, &win_data); |
| 550 | if (ret < 0) |
| 551 | ALOGE("ioctl S3CFB_WIN_CONFIG failed: %d", errno); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 552 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 553 | if (pdata->pdev->hdmi_mirroring) |
| 554 | hdmi_output(pdata->pdev, fb); |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 555 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 556 | pthread_mutex_lock(&pdata->completion_lock); |
| 557 | pdata->fence = win_data.fence; |
| 558 | pthread_cond_signal(&pdata->completion); |
| 559 | pthread_mutex_unlock(&pdata->completion_lock); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 562 | static int exynos5_set(struct hwc_composer_device_1 *dev, hwc_display_t dpy, |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 563 | hwc_surface_t sur, hwc_layer_list_1_t* list) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 564 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 565 | exynos5_hwc_composer_device_1_t *pdev = |
| 566 | (exynos5_hwc_composer_device_1_t *)dev; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 567 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 568 | if (!dpy || !sur) |
| 569 | return 0; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 570 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 571 | hwc_callback_queue_t *queue = NULL; |
| 572 | pthread_mutex_t *lock = NULL; |
| 573 | exynos5_hwc_post_data_t *data = NULL; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 574 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 575 | if (list) { |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 576 | for (size_t i = 0; i < NUM_HW_WINDOWS; i++) { |
| 577 | if (pdev->bufs.overlay_map[i] != -1) { |
| 578 | pdev->bufs.overlays[i] = |
| 579 | list->hwLayers[pdev->bufs.overlay_map[i]]; |
| 580 | } |
| 581 | } |
| 582 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 583 | data = (exynos5_hwc_post_data_t *) |
| 584 | malloc(sizeof(exynos5_hwc_post_data_t)); |
| 585 | memcpy(data, &pdev->bufs, sizeof(pdev->bufs)); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 586 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 587 | data->fence = -1; |
| 588 | pthread_mutex_init(&data->completion_lock, NULL); |
| 589 | pthread_cond_init(&data->completion, NULL); |
| 590 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 591 | if (pdev->bufs.fb_window == NO_FB_NEEDED) { |
| 592 | exynos5_post_callback(data, NULL); |
| 593 | } else { |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 594 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 595 | struct hwc_callback_entry entry; |
| 596 | entry.callback = exynos5_post_callback; |
| 597 | entry.data = data; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 598 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 599 | queue = reinterpret_cast<hwc_callback_queue_t *>( |
| 600 | pdev->gralloc_module->queue); |
| 601 | lock = const_cast<pthread_mutex_t *>( |
| 602 | &pdev->gralloc_module->queue_lock); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 603 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 604 | pthread_mutex_lock(lock); |
| 605 | queue->push_front(entry); |
| 606 | pthread_mutex_unlock(lock); |
| 607 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 608 | EGLBoolean success = eglSwapBuffers((EGLDisplay)dpy, |
| 609 | (EGLSurface)sur); |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 610 | if (!success) { |
| 611 | ALOGE("HWC_EGL_ERROR"); |
| 612 | if (list) { |
| 613 | pthread_mutex_lock(lock); |
| 614 | queue->removeAt(0); |
| 615 | pthread_mutex_unlock(lock); |
| 616 | free(data); |
| 617 | } |
| 618 | return HWC_EGL_ERROR; |
| 619 | } |
| 620 | } |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 621 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 622 | |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 623 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 624 | pthread_mutex_lock(&data->completion_lock); |
| 625 | while (data->fence == -1) |
| 626 | pthread_cond_wait(&data->completion, &data->completion_lock); |
| 627 | pthread_mutex_unlock(&data->completion_lock); |
| 628 | |
| 629 | for (size_t i = 0; i < NUM_HW_WINDOWS; i++) { |
| 630 | if (pdev->bufs.overlay_map[i] != -1) { |
| 631 | int dup_fd = dup(data->fence); |
| 632 | if (dup_fd < 0) |
| 633 | ALOGW("release fence dup failed: %s", strerror(errno)); |
| 634 | list->hwLayers[pdev->bufs.overlay_map[i]].releaseFenceFd = dup_fd; |
| 635 | } |
| 636 | } |
| 637 | close(data->fence); |
| 638 | free(data); |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 639 | return 0; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 642 | static void exynos5_registerProcs(struct hwc_composer_device_1* dev, |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 643 | hwc_procs_t const* procs) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 644 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 645 | struct exynos5_hwc_composer_device_1_t* pdev = |
| 646 | (struct exynos5_hwc_composer_device_1_t*)dev; |
| 647 | pdev->procs = const_cast<hwc_procs_t *>(procs); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 648 | } |
| 649 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 650 | static int exynos5_query(struct hwc_composer_device_1* dev, int what, int *value) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 651 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 652 | struct exynos5_hwc_composer_device_1_t *pdev = |
| 653 | (struct exynos5_hwc_composer_device_1_t *)dev; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 654 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 655 | switch (what) { |
| 656 | case HWC_BACKGROUND_LAYER_SUPPORTED: |
| 657 | // we support the background layer |
| 658 | value[0] = 1; |
| 659 | break; |
| 660 | case HWC_VSYNC_PERIOD: |
| 661 | // vsync period in nanosecond |
| 662 | value[0] = 1000000000.0 / pdev->gralloc_module->fps; |
| 663 | break; |
| 664 | default: |
| 665 | // unsupported query |
| 666 | return -EINVAL; |
| 667 | } |
| 668 | return 0; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 669 | } |
| 670 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 671 | static int exynos5_eventControl(struct hwc_composer_device_1 *dev, int event, |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 672 | int enabled) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 673 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 674 | struct exynos5_hwc_composer_device_1_t *pdev = |
| 675 | (struct exynos5_hwc_composer_device_1_t *)dev; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 676 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 677 | switch (event) { |
| 678 | case HWC_EVENT_VSYNC: |
| 679 | __u32 val = !!enabled; |
| 680 | int err = ioctl(pdev->fd, S3CFB_SET_VSYNC_INT, &val); |
| 681 | if (err < 0) { |
| 682 | ALOGE("vsync ioctl failed"); |
| 683 | return -errno; |
| 684 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 685 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 686 | return 0; |
| 687 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 688 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 689 | return -EINVAL; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 690 | } |
| 691 | |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 692 | static void handle_hdmi_uevent(struct exynos5_hwc_composer_device_1_t *pdev, |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 693 | const char *buff, int len) |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 694 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 695 | const char *s = buff; |
| 696 | s += strlen(s) + 1; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 697 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 698 | while (*s) { |
| 699 | if (!strncmp(s, "SWITCH_STATE=", strlen("SWITCH_STATE="))) |
| 700 | pdev->hdmi_hpd = atoi(s + strlen("SWITCH_STATE=")) == 1; |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 701 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 702 | s += strlen(s) + 1; |
| 703 | if (s - buff >= len) |
| 704 | break; |
| 705 | } |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 706 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 707 | ALOGV("HDMI HPD changed to %s", pdev->hdmi_hpd ? "enabled" : "disabled"); |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 708 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 709 | if (pdev->procs && pdev->procs->invalidate) |
| 710 | pdev->procs->invalidate(pdev->procs); |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 711 | } |
| 712 | |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 713 | static void handle_vsync_event(struct exynos5_hwc_composer_device_1_t *pdev) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 714 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 715 | if (!pdev->procs || !pdev->procs->vsync) |
| 716 | return; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 717 | |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 718 | char buf[4096]; |
| 719 | int err = read(pdev->vsync_fd, buf, sizeof(buf)); |
| 720 | if (err < 0) { |
| 721 | ALOGE("error reading vsync timestamp: %s", strerror(errno)); |
| 722 | return; |
Greg Hackmann | 3464b1d | 2012-07-24 09:46:23 -0700 | [diff] [blame] | 723 | } |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 724 | buf[sizeof(buf) - 1] = '\0'; |
Greg Hackmann | 3464b1d | 2012-07-24 09:46:23 -0700 | [diff] [blame] | 725 | |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 726 | errno = 0; |
| 727 | uint64_t timestamp = strtoull(buf, NULL, 0); |
| 728 | if (!errno) |
| 729 | pdev->procs->vsync(pdev->procs, 0, timestamp); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | static void *hwc_vsync_thread(void *data) |
| 733 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 734 | struct exynos5_hwc_composer_device_1_t *pdev = |
| 735 | (struct exynos5_hwc_composer_device_1_t *)data; |
| 736 | char uevent_desc[4096]; |
| 737 | memset(uevent_desc, 0, sizeof(uevent_desc)); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 738 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 739 | setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 740 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 741 | uevent_init(); |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 742 | |
| 743 | struct pollfd fds[2]; |
| 744 | fds[0].fd = pdev->vsync_fd; |
| 745 | fds[0].events = POLLPRI; |
| 746 | fds[1].fd = uevent_get_fd(); |
| 747 | fds[1].events = POLLIN; |
| 748 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 749 | while (true) { |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 750 | int err = poll(fds, 2, -1); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 751 | |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 752 | if (err > 0) { |
| 753 | if (fds[0].revents & POLLPRI) { |
| 754 | handle_vsync_event(pdev); |
| 755 | } |
| 756 | else if (fds[1].revents & POLLIN) { |
| 757 | int len = uevent_next_event(uevent_desc, |
| 758 | sizeof(uevent_desc) - 2); |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 759 | |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 760 | bool hdmi = !strcmp(uevent_desc, |
| 761 | "change@/devices/virtual/switch/hdmi"); |
| 762 | if (hdmi) |
| 763 | handle_hdmi_uevent(pdev, uevent_desc, len); |
| 764 | } |
| 765 | } |
| 766 | else if (err == -1) { |
| 767 | if (errno == EINTR) |
| 768 | break; |
| 769 | ALOGE("error in vsync thread: %s", strerror(errno)); |
| 770 | } |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 771 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 772 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 773 | return NULL; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 774 | } |
| 775 | |
Colin Cross | 00359a8 | 2012-07-12 17:54:17 -0700 | [diff] [blame] | 776 | static int exynos5_blank(struct hwc_composer_device_1 *dev, int blank) |
| 777 | { |
| 778 | struct exynos5_hwc_composer_device_1_t *pdev = |
| 779 | (struct exynos5_hwc_composer_device_1_t *)dev; |
| 780 | |
| 781 | int fb_blank = blank ? FB_BLANK_POWERDOWN : FB_BLANK_UNBLANK; |
| 782 | int err = ioctl(pdev->fd, FBIOBLANK, fb_blank); |
| 783 | if (err < 0) { |
| 784 | ALOGE("%sblank ioctl failed", blank ? "" : "un"); |
| 785 | return -errno; |
| 786 | } |
| 787 | |
| 788 | return 0; |
| 789 | } |
| 790 | |
Erik Gilling | 87e707e | 2012-06-29 17:35:13 -0700 | [diff] [blame] | 791 | struct hwc_methods_1 exynos5_methods = { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 792 | eventControl: exynos5_eventControl, |
Colin Cross | 00359a8 | 2012-07-12 17:54:17 -0700 | [diff] [blame] | 793 | blank: exynos5_blank, |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 794 | }; |
| 795 | |
| 796 | static int exynos5_close(hw_device_t* device); |
| 797 | |
| 798 | static int exynos5_open(const struct hw_module_t *module, const char *name, |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 799 | struct hw_device_t **device) |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 800 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 801 | int ret; |
| 802 | int sw_fd; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 803 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 804 | if (strcmp(name, HWC_HARDWARE_COMPOSER)) { |
| 805 | return -EINVAL; |
| 806 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 807 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 808 | struct exynos5_hwc_composer_device_1_t *dev; |
| 809 | dev = (struct exynos5_hwc_composer_device_1_t *)malloc(sizeof(*dev)); |
| 810 | memset(dev, 0, sizeof(*dev)); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 811 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 812 | if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, |
| 813 | (const struct hw_module_t **)&dev->gralloc_module)) { |
| 814 | ALOGE("failed to get gralloc hw module"); |
| 815 | ret = -EINVAL; |
| 816 | goto err_get_module; |
| 817 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 818 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 819 | dev->fd = open("/dev/graphics/fb0", O_RDWR); |
| 820 | if (dev->fd < 0) { |
| 821 | ALOGE("failed to open framebuffer"); |
| 822 | ret = dev->fd; |
| 823 | goto err_get_module; |
| 824 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 825 | |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 826 | dev->vsync_fd = open("/sys/devices/platform/exynos5-fb.1/vsync", O_RDONLY); |
| 827 | if (dev->vsync_fd < 0) { |
| 828 | ALOGE("failed to open vsync attribute"); |
| 829 | ret = dev->vsync_fd; |
| 830 | goto err_ioctl; |
| 831 | } |
| 832 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 833 | sw_fd = open("/sys/class/switch/hdmi/state", O_RDONLY); |
| 834 | if (sw_fd) { |
| 835 | char val; |
| 836 | if (read(sw_fd, &val, 1) == 1 && val == '1') |
| 837 | dev->hdmi_hpd = true; |
| 838 | } |
Benoit Goby | cdd61b3 | 2012-07-09 12:09:59 -0700 | [diff] [blame] | 839 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 840 | dev->base.common.tag = HARDWARE_DEVICE_TAG; |
| 841 | dev->base.common.version = HWC_DEVICE_API_VERSION_1_0; |
| 842 | dev->base.common.module = const_cast<hw_module_t *>(module); |
| 843 | dev->base.common.close = exynos5_close; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 844 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 845 | dev->base.prepare = exynos5_prepare; |
| 846 | dev->base.set = exynos5_set; |
| 847 | dev->base.registerProcs = exynos5_registerProcs; |
| 848 | dev->base.query = exynos5_query; |
| 849 | dev->base.methods = &exynos5_methods; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 850 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 851 | dev->bufs.pdev = dev; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 852 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 853 | *device = &dev->base.common; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 854 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 855 | ret = pthread_create(&dev->vsync_thread, NULL, hwc_vsync_thread, dev); |
| 856 | if (ret) { |
| 857 | ALOGE("failed to start vsync thread: %s", strerror(ret)); |
| 858 | ret = -ret; |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 859 | goto err_vsync; |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 860 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 861 | |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 862 | return 0; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 863 | |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 864 | err_vsync: |
| 865 | close(dev->vsync_fd); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 866 | err_ioctl: |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 867 | close(dev->fd); |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 868 | err_get_module: |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 869 | free(dev); |
| 870 | return ret; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | static int exynos5_close(hw_device_t *device) |
| 874 | { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 875 | struct exynos5_hwc_composer_device_1_t *dev = |
| 876 | (struct exynos5_hwc_composer_device_1_t *)device; |
Greg Hackmann | 2972485 | 2012-07-23 15:31:10 -0700 | [diff] [blame^] | 877 | pthread_kill(dev->vsync_thread, SIGTERM); |
| 878 | pthread_join(dev->vsync_thread, NULL); |
| 879 | close(dev->vsync_fd); |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 880 | close(dev->fd); |
| 881 | return 0; |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 882 | } |
| 883 | |
| 884 | static struct hw_module_methods_t exynos5_hwc_module_methods = { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 885 | open: exynos5_open, |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 886 | }; |
| 887 | |
| 888 | hwc_module_t HAL_MODULE_INFO_SYM = { |
Greg Hackmann | f6f2e54 | 2012-07-16 16:10:27 -0700 | [diff] [blame] | 889 | common: { |
| 890 | tag: HARDWARE_MODULE_TAG, |
| 891 | module_api_version: HWC_MODULE_API_VERSION_0_1, |
| 892 | hal_api_version: HARDWARE_HAL_API_VERSION, |
| 893 | id: HWC_HARDWARE_MODULE_ID, |
| 894 | name: "Samsung exynos5 hwcomposer module", |
| 895 | author: "Google", |
| 896 | methods: &exynos5_hwc_module_methods, |
| 897 | } |
Greg Hackmann | 86eb1c6 | 2012-05-30 09:25:51 -0700 | [diff] [blame] | 898 | }; |