Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | |
Stéphane Marchesin | be98c8c | 2015-06-23 16:18:10 -0700 | [diff] [blame] | 17 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 18 | #define LOG_TAG "hwcomposer-drm" |
| 19 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 20 | #include "drm_hwcomposer.h" |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 21 | #include "drmresources.h" |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 22 | #include "importer.h" |
Sean Paul | 4057be3 | 2015-05-13 06:23:09 -0700 | [diff] [blame] | 23 | #include "vsyncworker.h" |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 24 | |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 25 | #include <stdlib.h> |
| 26 | |
| 27 | #include <map> |
| 28 | #include <vector> |
| 29 | |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 30 | #include <errno.h> |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 31 | #include <fcntl.h> |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 32 | #include <pthread.h> |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 33 | #include <sys/param.h> |
Sean Paul | 9aa5ad3 | 2015-01-22 15:47:54 -0500 | [diff] [blame] | 34 | #include <sys/resource.h> |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 35 | #include <xf86drm.h> |
| 36 | #include <xf86drmMode.h> |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 37 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 38 | #include <cutils/log.h> |
| 39 | #include <cutils/properties.h> |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 40 | #include <hardware/hardware.h> |
| 41 | #include <hardware/hwcomposer.h> |
Stéphane Marchesin | be98c8c | 2015-06-23 16:18:10 -0700 | [diff] [blame] | 42 | #include <utils/Trace.h> |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 43 | |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 44 | #define UM_PER_INCH 25400 |
Stéphane Marchesin | cb3f984 | 2015-06-19 14:50:45 -0700 | [diff] [blame] | 45 | #define HWC_FB_BUFFERS 3 |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 46 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 47 | namespace android { |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 48 | |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 49 | typedef struct hwc_drm_display { |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 50 | struct hwc_context_t *ctx; |
| 51 | int display; |
Sean Paul | 9aa5ad3 | 2015-01-22 15:47:54 -0500 | [diff] [blame] | 52 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 53 | std::vector<uint32_t> config_ids; |
Sean Paul | 9aa5ad3 | 2015-01-22 15:47:54 -0500 | [diff] [blame] | 54 | |
Sean Paul | 4057be3 | 2015-05-13 06:23:09 -0700 | [diff] [blame] | 55 | VSyncWorker vsync_worker; |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 56 | } hwc_drm_display_t; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 57 | |
| 58 | struct hwc_context_t { |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 59 | // map of display:hwc_drm_display_t |
| 60 | typedef std::map<int, hwc_drm_display_t> DisplayMap; |
| 61 | typedef DisplayMap::iterator DisplayMapIter; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 62 | |
Zach Reizner | 1946fa7 | 2015-08-14 11:14:38 -0700 | [diff] [blame^] | 63 | hwc_context_t() : procs(NULL), importer(NULL), use_framebuffer_target(false) { |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | ~hwc_context_t() { |
| 67 | delete importer; |
| 68 | } |
| 69 | |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 70 | hwc_composer_device_1_t device; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 71 | hwc_procs_t const *procs; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 72 | |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 73 | DisplayMap displays; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 74 | DrmResources drm; |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 75 | Importer *importer; |
Zach Reizner | 1946fa7 | 2015-08-14 11:14:38 -0700 | [diff] [blame^] | 76 | bool use_framebuffer_target; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 77 | }; |
| 78 | |
Zach Reizner | c6520e4 | 2015-08-13 14:32:09 -0700 | [diff] [blame] | 79 | static void hwc_dump(struct hwc_composer_device_1 *dev, char *buff, |
Sean Paul | 9046c64 | 2015-06-10 17:27:47 -0400 | [diff] [blame] | 80 | int buff_len) { |
| 81 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
| 82 | std::ostringstream out; |
| 83 | |
| 84 | ctx->drm.compositor()->Dump(&out); |
| 85 | std::string out_str = out.str(); |
| 86 | strncpy(buff, out_str.c_str(), std::min((size_t)buff_len, out_str.length())); |
| 87 | } |
| 88 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 89 | static int hwc_prepare(hwc_composer_device_1_t *dev, size_t num_displays, |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 90 | hwc_display_contents_1_t **display_contents) { |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 91 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
Zach Reizner | 1946fa7 | 2015-08-14 11:14:38 -0700 | [diff] [blame^] | 92 | |
| 93 | char use_framebuffer_target[PROPERTY_VALUE_MAX]; |
| 94 | property_get("hwc.drm.use_framebuffer_target", use_framebuffer_target, "0"); |
| 95 | bool new_use_framebuffer_target = atoi(use_framebuffer_target); |
| 96 | if (ctx->use_framebuffer_target != new_use_framebuffer_target) |
| 97 | ALOGW("Starting to %s HWC_FRAMEBUFFER_TARGET", |
| 98 | new_use_framebuffer_target ? "use" : "not use"); |
| 99 | ctx->use_framebuffer_target = new_use_framebuffer_target; |
| 100 | |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 101 | for (int i = 0; i < (int)num_displays; ++i) { |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 102 | if (!display_contents[i]) |
| 103 | continue; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 104 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 105 | DrmCrtc *crtc = ctx->drm.GetCrtcForDisplay(i); |
| 106 | if (!crtc) { |
| 107 | ALOGE("No crtc for display %d", i); |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 108 | return -ENODEV; |
| 109 | } |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 110 | |
Zach Reizner | 45624d3 | 2015-06-10 16:03:01 -0700 | [diff] [blame] | 111 | int num_layers = display_contents[i]->numHwLayers; |
| 112 | for (int j = 0; j < num_layers; j++) { |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 113 | hwc_layer_1_t *layer = &display_contents[i]->hwLayers[j]; |
Zach Reizner | 45624d3 | 2015-06-10 16:03:01 -0700 | [diff] [blame] | 114 | |
Zach Reizner | 1946fa7 | 2015-08-14 11:14:38 -0700 | [diff] [blame^] | 115 | if (!ctx->use_framebuffer_target) { |
| 116 | if (layer->compositionType == HWC_FRAMEBUFFER) |
| 117 | layer->compositionType = HWC_OVERLAY; |
| 118 | } else { |
| 119 | switch (layer->compositionType) { |
| 120 | case HWC_OVERLAY: |
| 121 | case HWC_BACKGROUND: |
| 122 | case HWC_SIDEBAND: |
| 123 | case HWC_CURSOR_OVERLAY: |
| 124 | layer->compositionType = HWC_FRAMEBUFFER; |
| 125 | break; |
| 126 | } |
| 127 | } |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 128 | } |
| 129 | } |
Sean Paul | dffca95 | 2015-02-04 10:19:55 -0800 | [diff] [blame] | 130 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 131 | return 0; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 132 | } |
| 133 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 134 | static void hwc_set_cleanup(size_t num_displays, |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 135 | hwc_display_contents_1_t **display_contents) { |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 136 | for (int i = 0; i < (int)num_displays; ++i) { |
| 137 | if (!display_contents[i]) |
| 138 | continue; |
| 139 | |
| 140 | hwc_display_contents_1_t *dc = display_contents[i]; |
| 141 | for (size_t j = 0; j < dc->numHwLayers; ++j) { |
| 142 | hwc_layer_1_t *layer = &dc->hwLayers[j]; |
| 143 | if (layer->acquireFenceFd >= 0) { |
| 144 | close(layer->acquireFenceFd); |
| 145 | layer->acquireFenceFd = -1; |
| 146 | } |
| 147 | } |
| 148 | if (dc->outbufAcquireFenceFd >= 0) { |
| 149 | close(dc->outbufAcquireFenceFd); |
| 150 | dc->outbufAcquireFenceFd = -1; |
| 151 | } |
| 152 | } |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 153 | } |
| 154 | |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 155 | static void hwc_add_layer_to_retire_fence( |
| 156 | hwc_layer_1_t *layer, hwc_display_contents_1_t *display_contents) { |
Sean Paul | 0420612 | 2015-07-16 15:59:24 -0400 | [diff] [blame] | 157 | if (layer->releaseFenceFd < 0) |
| 158 | return; |
| 159 | |
| 160 | if (display_contents->retireFenceFd >= 0) { |
| 161 | int old_retire_fence = display_contents->retireFenceFd; |
Zach Reizner | c6520e4 | 2015-08-13 14:32:09 -0700 | [diff] [blame] | 162 | display_contents->retireFenceFd = |
| 163 | sync_merge("dc_retire", old_retire_fence, layer->releaseFenceFd); |
Sean Paul | 0420612 | 2015-07-16 15:59:24 -0400 | [diff] [blame] | 164 | close(old_retire_fence); |
| 165 | } else { |
| 166 | display_contents->retireFenceFd = dup(layer->releaseFenceFd); |
| 167 | } |
| 168 | } |
| 169 | |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 170 | static int hwc_set(hwc_composer_device_1_t *dev, size_t num_displays, |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 171 | hwc_display_contents_1_t **display_contents) { |
Stéphane Marchesin | be98c8c | 2015-06-23 16:18:10 -0700 | [diff] [blame] | 172 | ATRACE_CALL(); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 173 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 174 | int ret; |
| 175 | std::unique_ptr<DrmComposition> composition( |
| 176 | ctx->drm.compositor()->CreateComposition(ctx->importer)); |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 177 | if (!composition) { |
| 178 | ALOGE("Drm composition init failed"); |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 179 | hwc_set_cleanup(num_displays, display_contents); |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 180 | return -EINVAL; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 181 | } |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 182 | |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 183 | std::vector<DrmCompositionDisplayLayersMap> layers_map; |
| 184 | std::vector<std::vector<size_t>> layers_indices; |
| 185 | layers_map.reserve(num_displays); |
| 186 | layers_indices.reserve(num_displays); |
| 187 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 188 | for (int i = 0; i < (int)num_displays; ++i) { |
| 189 | if (!display_contents[i]) |
| 190 | continue; |
Zach Reizner | 45624d3 | 2015-06-10 16:03:01 -0700 | [diff] [blame] | 191 | hwc_display_contents_1_t *dc = display_contents[i]; |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 192 | |
| 193 | layers_map.emplace_back(); |
| 194 | DrmCompositionDisplayLayersMap &map = layers_map[i]; |
| 195 | map.display = i; |
| 196 | map.layers = dc->hwLayers; |
| 197 | |
| 198 | std::vector<size_t> indices_to_composite; |
Zach Reizner | 45624d3 | 2015-06-10 16:03:01 -0700 | [diff] [blame] | 199 | unsigned num_dc_layers = dc->numHwLayers; |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 200 | for (int j = 0; j < (int)num_dc_layers; ++j) { |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 201 | hwc_layer_1_t *layer = &dc->hwLayers[j]; |
Zach Reizner | 45624d3 | 2015-06-10 16:03:01 -0700 | [diff] [blame] | 202 | if (layer->flags & HWC_SKIP_LAYER) |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 203 | continue; |
Zach Reizner | 1946fa7 | 2015-08-14 11:14:38 -0700 | [diff] [blame^] | 204 | if (!ctx->use_framebuffer_target) { |
| 205 | if (layer->compositionType == HWC_OVERLAY) |
| 206 | indices_to_composite.push_back(j); |
| 207 | } else { |
| 208 | if (layer->compositionType == HWC_FRAMEBUFFER_TARGET) |
| 209 | indices_to_composite.push_back(j); |
| 210 | } |
| 211 | } |
| 212 | if (ctx->use_framebuffer_target) { |
| 213 | if (indices_to_composite.size() != 1) { |
| 214 | ALOGE("Expected 1 (got %d) layer with HWC_FRAMEBUFFER_TARGET", |
| 215 | indices_to_composite.size()); |
| 216 | hwc_set_cleanup(num_displays, display_contents); |
| 217 | return -EINVAL; |
| 218 | } |
Zach Reizner | 45624d3 | 2015-06-10 16:03:01 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 221 | map.num_layers = indices_to_composite.size(); |
| 222 | layers_indices.emplace_back(std::move(indices_to_composite)); |
| 223 | map.layer_indices = layers_indices.back().data(); |
| 224 | } |
Zach Reizner | 45624d3 | 2015-06-10 16:03:01 -0700 | [diff] [blame] | 225 | |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 226 | ret = composition->SetLayers(layers_map.size(), layers_map.data()); |
| 227 | if (ret) { |
| 228 | hwc_set_cleanup(num_displays, display_contents); |
| 229 | return -EINVAL; |
| 230 | } |
Zach Reizner | 45624d3 | 2015-06-10 16:03:01 -0700 | [diff] [blame] | 231 | |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 232 | ret = ctx->drm.compositor()->QueueComposition(std::move(composition)); |
| 233 | if (ret) { |
| 234 | hwc_set_cleanup(num_displays, display_contents); |
| 235 | return -EINVAL; |
| 236 | } |
| 237 | |
| 238 | composition.reset(NULL); |
| 239 | |
| 240 | for (int i = 0; i < (int)num_displays; ++i) { |
| 241 | if (!display_contents[i]) |
| 242 | continue; |
| 243 | hwc_display_contents_1_t *dc = display_contents[i]; |
| 244 | unsigned num_dc_layers = dc->numHwLayers; |
| 245 | for (int j = 0; j < (int)num_dc_layers; ++j) { |
Zach Reizner | 45624d3 | 2015-06-10 16:03:01 -0700 | [diff] [blame] | 246 | hwc_layer_1_t *layer = &dc->hwLayers[j]; |
| 247 | if (layer->flags & HWC_SKIP_LAYER) |
| 248 | continue; |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 249 | if (layer->compositionType == HWC_OVERLAY) |
| 250 | hwc_add_layer_to_retire_fence(layer, dc); |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 251 | } |
| 252 | } |
| 253 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 254 | if (ret) { |
| 255 | ALOGE("Failed to queue the composition"); |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 256 | } |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 257 | hwc_set_cleanup(num_displays, display_contents); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 258 | return ret; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 259 | } |
| 260 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 261 | static int hwc_event_control(struct hwc_composer_device_1 *dev, int display, |
| 262 | int event, int enabled) { |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 263 | if (event != HWC_EVENT_VSYNC || (enabled != 0 && enabled != 1)) |
| 264 | return -EINVAL; |
Sean Paul | eb9e75c | 2015-01-25 23:31:30 -0500 | [diff] [blame] | 265 | |
Sean Paul | 4057be3 | 2015-05-13 06:23:09 -0700 | [diff] [blame] | 266 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
| 267 | hwc_drm_display_t *hd = &ctx->displays[display]; |
| 268 | return hd->vsync_worker.VSyncControl(enabled); |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 269 | } |
| 270 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 271 | static int hwc_set_power_mode(struct hwc_composer_device_1 *dev, int display, |
| 272 | int mode) { |
| 273 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 274 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 275 | uint64_t dpmsValue = 0; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 276 | switch (mode) { |
| 277 | case HWC_POWER_MODE_OFF: |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 278 | dpmsValue = DRM_MODE_DPMS_OFF; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 279 | break; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 280 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 281 | /* We can't support dozing right now, so go full on */ |
| 282 | case HWC_POWER_MODE_DOZE: |
| 283 | case HWC_POWER_MODE_DOZE_SUSPEND: |
| 284 | case HWC_POWER_MODE_NORMAL: |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 285 | dpmsValue = DRM_MODE_DPMS_ON; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 286 | break; |
| 287 | }; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 288 | return ctx->drm.SetDpmsMode(display, dpmsValue); |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 289 | } |
| 290 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 291 | static int hwc_query(struct hwc_composer_device_1 * /* dev */, int what, |
| 292 | int *value) { |
| 293 | switch (what) { |
| 294 | case HWC_BACKGROUND_LAYER_SUPPORTED: |
| 295 | *value = 0; /* TODO: We should do this */ |
| 296 | break; |
| 297 | case HWC_VSYNC_PERIOD: |
| 298 | ALOGW("Query for deprecated vsync value, returning 60Hz"); |
| 299 | *value = 1000 * 1000 * 1000 / 60; |
| 300 | break; |
| 301 | case HWC_DISPLAY_TYPES_SUPPORTED: |
| 302 | *value = HWC_DISPLAY_PRIMARY | HWC_DISPLAY_EXTERNAL; |
| 303 | break; |
| 304 | } |
| 305 | return 0; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 306 | } |
| 307 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 308 | static void hwc_register_procs(struct hwc_composer_device_1 *dev, |
| 309 | hwc_procs_t const *procs) { |
| 310 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 311 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 312 | ctx->procs = procs; |
Sean Paul | 4057be3 | 2015-05-13 06:23:09 -0700 | [diff] [blame] | 313 | |
| 314 | for (hwc_context_t::DisplayMapIter iter = ctx->displays.begin(); |
| 315 | iter != ctx->displays.end(); ++iter) { |
| 316 | iter->second.vsync_worker.SetProcs(procs); |
| 317 | } |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 318 | } |
| 319 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 320 | static int hwc_get_display_configs(struct hwc_composer_device_1 *dev, |
| 321 | int display, uint32_t *configs, |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 322 | size_t *num_configs) { |
| 323 | if (!*num_configs) |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 324 | return 0; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 325 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 326 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 327 | hwc_drm_display_t *hd = &ctx->displays[display]; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 328 | hd->config_ids.clear(); |
| 329 | |
| 330 | DrmConnector *connector = ctx->drm.GetConnectorForDisplay(display); |
| 331 | if (!connector) { |
| 332 | ALOGE("Failed to get connector for display %d", display); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 333 | return -ENODEV; |
| 334 | } |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 335 | |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 336 | int ret = connector->UpdateModes(); |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 337 | if (ret) { |
| 338 | ALOGE("Failed to update display modes %d", ret); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 339 | return ret; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 340 | } |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 341 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 342 | for (DrmConnector::ModeIter iter = connector->begin_modes(); |
| 343 | iter != connector->end_modes(); ++iter) { |
| 344 | size_t idx = hd->config_ids.size(); |
| 345 | if (idx == *num_configs) |
| 346 | break; |
| 347 | hd->config_ids.push_back(iter->id()); |
| 348 | configs[idx] = iter->id(); |
| 349 | } |
| 350 | *num_configs = hd->config_ids.size(); |
| 351 | return *num_configs == 0 ? -1 : 0; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 352 | } |
| 353 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 354 | static int hwc_get_display_attributes(struct hwc_composer_device_1 *dev, |
| 355 | int display, uint32_t config, |
| 356 | const uint32_t *attributes, |
| 357 | int32_t *values) { |
| 358 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 359 | DrmConnector *c = ctx->drm.GetConnectorForDisplay(display); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 360 | if (!c) { |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 361 | ALOGE("Failed to get DrmConnector for display %d", display); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 362 | return -ENODEV; |
| 363 | } |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 364 | DrmMode mode; |
| 365 | for (DrmConnector::ModeIter iter = c->begin_modes(); iter != c->end_modes(); |
| 366 | ++iter) { |
| 367 | if (iter->id() == config) { |
| 368 | mode = *iter; |
| 369 | break; |
| 370 | } |
| 371 | } |
| 372 | if (mode.id() == 0) { |
| 373 | ALOGE("Failed to find active mode for display %d", display); |
| 374 | return -ENOENT; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 375 | } |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 376 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 377 | uint32_t mm_width = c->mm_width(); |
| 378 | uint32_t mm_height = c->mm_height(); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 379 | for (int i = 0; attributes[i] != HWC_DISPLAY_NO_ATTRIBUTE; ++i) { |
| 380 | switch (attributes[i]) { |
| 381 | case HWC_DISPLAY_VSYNC_PERIOD: |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 382 | values[i] = 1000 * 1000 * 1000 / mode.v_refresh(); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 383 | break; |
| 384 | case HWC_DISPLAY_WIDTH: |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 385 | values[i] = mode.h_display(); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 386 | break; |
| 387 | case HWC_DISPLAY_HEIGHT: |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 388 | values[i] = mode.v_display(); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 389 | break; |
| 390 | case HWC_DISPLAY_DPI_X: |
| 391 | /* Dots per 1000 inches */ |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 392 | values[i] = mm_width ? (mode.h_display() * UM_PER_INCH) / mm_width : 0; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 393 | break; |
| 394 | case HWC_DISPLAY_DPI_Y: |
| 395 | /* Dots per 1000 inches */ |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 396 | values[i] = |
| 397 | mm_height ? (mode.v_display() * UM_PER_INCH) / mm_height : 0; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 398 | break; |
| 399 | } |
| 400 | } |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 401 | return 0; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 402 | } |
| 403 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 404 | static int hwc_get_active_config(struct hwc_composer_device_1 *dev, |
| 405 | int display) { |
| 406 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 407 | DrmConnector *c = ctx->drm.GetConnectorForDisplay(display); |
| 408 | if (!c) { |
| 409 | ALOGE("Failed to get DrmConnector for display %d", display); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 410 | return -ENODEV; |
| 411 | } |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 412 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 413 | DrmMode mode = c->active_mode(); |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 414 | hwc_drm_display_t *hd = &ctx->displays[display]; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 415 | for (size_t i = 0; i < hd->config_ids.size(); ++i) { |
| 416 | if (hd->config_ids[i] == mode.id()) |
| 417 | return i; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 418 | } |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 419 | return -1; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 420 | } |
| 421 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 422 | static int hwc_set_active_config(struct hwc_composer_device_1 *dev, int display, |
| 423 | int index) { |
| 424 | struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common; |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 425 | hwc_drm_display_t *hd = &ctx->displays[display]; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 426 | if (index >= (int)hd->config_ids.size()) { |
| 427 | ALOGE("Invalid config index %d passed in", index); |
| 428 | return -EINVAL; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 429 | } |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 430 | |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 431 | DrmConnector *c = ctx->drm.GetConnectorForDisplay(display); |
| 432 | if (!c) { |
| 433 | ALOGE("Failed to get connector for display %d", display); |
| 434 | return -ENODEV; |
| 435 | } |
| 436 | DrmMode mode; |
| 437 | for (DrmConnector::ModeIter iter = c->begin_modes(); iter != c->end_modes(); |
| 438 | ++iter) { |
| 439 | if (iter->id() == hd->config_ids[index]) { |
| 440 | mode = *iter; |
| 441 | break; |
| 442 | } |
| 443 | } |
| 444 | if (mode.id() != hd->config_ids[index]) { |
| 445 | ALOGE("Could not find active mode for %d/%d", index, hd->config_ids[index]); |
| 446 | return -ENOENT; |
| 447 | } |
| 448 | int ret = ctx->drm.SetDisplayActiveMode(display, mode); |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 449 | if (ret) { |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 450 | ALOGE("Failed to set active config %d", ret); |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 451 | return ret; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 452 | } |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 453 | return ret; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 454 | } |
| 455 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 456 | static int hwc_device_close(struct hw_device_t *dev) { |
| 457 | struct hwc_context_t *ctx = (struct hwc_context_t *)dev; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 458 | delete ctx; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 459 | return 0; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 460 | } |
| 461 | |
Sean Paul | 24a26e3 | 2015-02-04 10:34:47 -0800 | [diff] [blame] | 462 | /* |
| 463 | * TODO: This function sets the active config to the first one in the list. This |
| 464 | * should be fixed such that it selects the preferred mode for the display, or |
| 465 | * some other, saner, method of choosing the config. |
| 466 | */ |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 467 | static int hwc_set_initial_config(hwc_drm_display_t *hd) { |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 468 | uint32_t config; |
| 469 | size_t num_configs = 1; |
| 470 | int ret = hwc_get_display_configs(&hd->ctx->device, hd->display, &config, |
| 471 | &num_configs); |
| 472 | if (ret || !num_configs) |
| 473 | return 0; |
Sean Paul | 24a26e3 | 2015-02-04 10:34:47 -0800 | [diff] [blame] | 474 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 475 | ret = hwc_set_active_config(&hd->ctx->device, hd->display, 0); |
| 476 | if (ret) { |
| 477 | ALOGE("Failed to set active config d=%d ret=%d", hd->display, ret); |
| 478 | return ret; |
| 479 | } |
Sean Paul | 24a26e3 | 2015-02-04 10:34:47 -0800 | [diff] [blame] | 480 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 481 | return ret; |
Sean Paul | 24a26e3 | 2015-02-04 10:34:47 -0800 | [diff] [blame] | 482 | } |
| 483 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 484 | static int hwc_initialize_display(struct hwc_context_t *ctx, int display) { |
Sean Paul | e42febf | 2015-05-07 11:35:29 -0700 | [diff] [blame] | 485 | hwc_drm_display_t *hd = &ctx->displays[display]; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 486 | hd->ctx = ctx; |
| 487 | hd->display = display; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 488 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 489 | int ret = hwc_set_initial_config(hd); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 490 | if (ret) { |
| 491 | ALOGE("Failed to set initial config for d=%d ret=%d", display, ret); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 492 | return ret; |
| 493 | } |
Sean Paul | 24a26e3 | 2015-02-04 10:34:47 -0800 | [diff] [blame] | 494 | |
Sean Paul | 4057be3 | 2015-05-13 06:23:09 -0700 | [diff] [blame] | 495 | ret = hd->vsync_worker.Init(&ctx->drm, display); |
| 496 | if (ret) { |
| 497 | ALOGE("Failed to create event worker for display %d %d\n", display, ret); |
| 498 | return ret; |
| 499 | } |
| 500 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 501 | return 0; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 502 | } |
| 503 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 504 | static int hwc_enumerate_displays(struct hwc_context_t *ctx) { |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 505 | int ret; |
| 506 | for (DrmResources::ConnectorIter c = ctx->drm.begin_connectors(); |
| 507 | c != ctx->drm.end_connectors(); ++c) { |
| 508 | ret = hwc_initialize_display(ctx, (*c)->display()); |
| 509 | if (ret) { |
| 510 | ALOGE("Failed to initialize display %d", (*c)->display()); |
| 511 | return ret; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 512 | } |
| 513 | } |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 514 | |
| 515 | return 0; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 516 | } |
| 517 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 518 | static int hwc_device_open(const struct hw_module_t *module, const char *name, |
| 519 | struct hw_device_t **dev) { |
| 520 | if (strcmp(name, HWC_HARDWARE_COMPOSER)) { |
| 521 | ALOGE("Invalid module name- %s", name); |
| 522 | return -EINVAL; |
| 523 | } |
| 524 | |
| 525 | struct hwc_context_t *ctx = new hwc_context_t(); |
| 526 | if (!ctx) { |
| 527 | ALOGE("Failed to allocate hwc context"); |
| 528 | return -ENOMEM; |
| 529 | } |
| 530 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 531 | int ret = ctx->drm.Init(); |
| 532 | if (ret) { |
| 533 | ALOGE("Can't initialize Drm object %d", ret); |
| 534 | delete ctx; |
| 535 | return ret; |
| 536 | } |
| 537 | |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 538 | ctx->importer = Importer::CreateInstance(&ctx->drm); |
| 539 | if (!ctx->importer) { |
| 540 | ALOGE("Failed to create importer instance"); |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 541 | delete ctx; |
| 542 | return ret; |
| 543 | } |
| 544 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 545 | ret = hwc_enumerate_displays(ctx); |
| 546 | if (ret) { |
| 547 | ALOGE("Failed to enumerate displays: %s", strerror(ret)); |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 548 | delete ctx; |
| 549 | return ret; |
| 550 | } |
| 551 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 552 | ctx->device.common.tag = HARDWARE_DEVICE_TAG; |
| 553 | ctx->device.common.version = HWC_DEVICE_API_VERSION_1_4; |
| 554 | ctx->device.common.module = const_cast<hw_module_t *>(module); |
| 555 | ctx->device.common.close = hwc_device_close; |
| 556 | |
Sean Paul | 9046c64 | 2015-06-10 17:27:47 -0400 | [diff] [blame] | 557 | ctx->device.dump = hwc_dump; |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 558 | ctx->device.prepare = hwc_prepare; |
| 559 | ctx->device.set = hwc_set; |
| 560 | ctx->device.eventControl = hwc_event_control; |
| 561 | ctx->device.setPowerMode = hwc_set_power_mode; |
| 562 | ctx->device.query = hwc_query; |
| 563 | ctx->device.registerProcs = hwc_register_procs; |
| 564 | ctx->device.getDisplayConfigs = hwc_get_display_configs; |
| 565 | ctx->device.getDisplayAttributes = hwc_get_display_attributes; |
| 566 | ctx->device.getActiveConfig = hwc_get_active_config; |
| 567 | ctx->device.setActiveConfig = hwc_set_active_config; |
| 568 | ctx->device.setCursorPositionAsync = NULL; /* TODO: Add cursor */ |
| 569 | |
| 570 | *dev = &ctx->device.common; |
| 571 | |
| 572 | return 0; |
| 573 | } |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 574 | } |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 575 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 576 | static struct hw_module_methods_t hwc_module_methods = { |
| 577 | open : android::hwc_device_open |
| 578 | }; |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 579 | |
| 580 | hwc_module_t HAL_MODULE_INFO_SYM = { |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 581 | common : { |
| 582 | tag : HARDWARE_MODULE_TAG, |
| 583 | version_major : 1, |
| 584 | version_minor : 0, |
| 585 | id : HWC_HARDWARE_MODULE_ID, |
| 586 | name : "DRM hwcomposer module", |
| 587 | author : "The Android Open Source Project", |
| 588 | methods : &hwc_module_methods, |
| 589 | dso : NULL, |
| 590 | reserved : {0}, |
| 591 | } |
Sean Paul | e0c4c3d | 2015-01-20 16:56:04 -0500 | [diff] [blame] | 592 | }; |