Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Arun Kumar K.R | ba9eed5 | 2013-01-04 00:51:29 -0800 | [diff] [blame] | 3 | * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 4 | * |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 5 | * Not a Contribution, Apache license notifications and license are retained |
| 6 | * for attribution purposes only. |
| 7 | * |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | * you may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | * |
| 14 | * Unless required by applicable law or agreed to in writing, software |
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | * See the License for the specific language governing permissions and |
| 18 | * limitations under the License. |
| 19 | */ |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 20 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 21 | #include <fcntl.h> |
| 22 | #include <errno.h> |
| 23 | |
| 24 | #include <cutils/log.h> |
| 25 | #include <cutils/atomic.h> |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 26 | #include <EGL/egl.h> |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 27 | #include <utils/Trace.h> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 28 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 29 | #include <overlay.h> |
| 30 | #include <fb_priv.h> |
Naseer Ahmed | 96c4c95 | 2012-07-25 18:27:14 -0700 | [diff] [blame] | 31 | #include <mdp_version.h> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 32 | #include "hwc_utils.h" |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 33 | #include "hwc_video.h" |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 34 | #include "hwc_fbupdate.h" |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 35 | #include "hwc_mdpcomp.h" |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 36 | #include "external.h" |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 37 | #include "hwc_copybit.h" |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 38 | |
| 39 | using namespace qhwc; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 40 | #define VSYNC_DEBUG 0 |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 41 | |
| 42 | static int hwc_device_open(const struct hw_module_t* module, |
| 43 | const char* name, |
| 44 | struct hw_device_t** device); |
| 45 | |
| 46 | static struct hw_module_methods_t hwc_module_methods = { |
| 47 | open: hwc_device_open |
| 48 | }; |
| 49 | |
| 50 | hwc_module_t HAL_MODULE_INFO_SYM = { |
| 51 | common: { |
| 52 | tag: HARDWARE_MODULE_TAG, |
| 53 | version_major: 2, |
| 54 | version_minor: 0, |
| 55 | id: HWC_HARDWARE_MODULE_ID, |
| 56 | name: "Qualcomm Hardware Composer Module", |
| 57 | author: "CodeAurora Forum", |
| 58 | methods: &hwc_module_methods, |
| 59 | dso: 0, |
| 60 | reserved: {0}, |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | /* |
| 65 | * Save callback functions registered to HWC |
| 66 | */ |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 67 | static void hwc_registerProcs(struct hwc_composer_device_1* dev, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 68 | hwc_procs_t const* procs) |
| 69 | { |
Iliyan Malchev | 0f9c397 | 2012-10-11 15:16:15 -0700 | [diff] [blame] | 70 | ALOGI("%s", __FUNCTION__); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 71 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
| 72 | if(!ctx) { |
| 73 | ALOGE("%s: Invalid context", __FUNCTION__); |
| 74 | return; |
| 75 | } |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 76 | ctx->proc = procs; |
| 77 | |
Naseer Ahmed | ff4f025 | 2012-10-01 13:03:01 -0400 | [diff] [blame] | 78 | // Now that we have the functions needed, kick off |
| 79 | // the uevent & vsync threads |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 80 | init_uevent_thread(ctx); |
Naseer Ahmed | ff4f025 | 2012-10-01 13:03:01 -0400 | [diff] [blame] | 81 | init_vsync_thread(ctx); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Saurabh Shah | 649cda6 | 2012-09-16 16:05:58 -0700 | [diff] [blame] | 84 | //Helper |
Naseer Ahmed | b1c7632 | 2012-10-17 00:32:50 -0400 | [diff] [blame] | 85 | static void reset(hwc_context_t *ctx, int numDisplays, |
| 86 | hwc_display_contents_1_t** displays) { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 87 | memset(ctx->listStats, 0, sizeof(ctx->listStats)); |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 88 | for(int i = 0; i < MAX_DISPLAYS; i++) { |
Naseer Ahmed | b1c7632 | 2012-10-17 00:32:50 -0400 | [diff] [blame] | 89 | hwc_display_contents_1_t *list = displays[i]; |
| 90 | // XXX:SurfaceFlinger no longer guarantees that this |
| 91 | // value is reset on every prepare. However, for the layer |
| 92 | // cache we need to reset it. |
| 93 | // We can probably rethink that later on |
| 94 | if (LIKELY(list && list->numHwLayers > 1)) { |
| 95 | for(uint32_t j = 0; j < list->numHwLayers; j++) { |
| 96 | if(list->hwLayers[j].compositionType != HWC_FRAMEBUFFER_TARGET) |
| 97 | list->hwLayers[j].compositionType = HWC_FRAMEBUFFER; |
| 98 | } |
| 99 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 100 | |
| 101 | if(ctx->mFBUpdate[i]) |
| 102 | ctx->mFBUpdate[i]->reset(); |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 103 | |
| 104 | if(ctx->mCopyBit[i]) |
| 105 | ctx->mCopyBit[i]->reset(); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 106 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 107 | VideoOverlay::reset(); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 110 | //clear prev layer prop flags and realloc for current frame |
| 111 | static void reset_layer_prop(hwc_context_t* ctx, int dpy) { |
| 112 | int layer_count = ctx->listStats[dpy].numAppLayers; |
| 113 | |
| 114 | if(ctx->layerProp[dpy]) { |
| 115 | delete[] ctx->layerProp[dpy]; |
| 116 | ctx->layerProp[dpy] = NULL; |
| 117 | } |
| 118 | |
| 119 | if(layer_count) { |
| 120 | ctx->layerProp[dpy] = new LayerProp[layer_count]; |
| 121 | } |
| 122 | } |
| 123 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 124 | static int hwc_prepare_primary(hwc_composer_device_1 *dev, |
| 125 | hwc_display_contents_1_t *list) { |
| 126 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 127 | const int dpy = HWC_DISPLAY_PRIMARY; |
Saurabh Shah | bf1e02a | 2013-02-26 13:38:05 -0800 | [diff] [blame] | 128 | if (LIKELY(list && list->numHwLayers > 1 && |
| 129 | list->numHwLayers <= MAX_NUM_LAYERS) && ctx->dpyAttr[dpy].isActive) { |
Saurabh Shah | 86623d7 | 2012-09-25 19:39:17 -0700 | [diff] [blame] | 130 | uint32_t last = list->numHwLayers - 1; |
Saurabh Shah | 1a8cda0 | 2012-10-12 17:00:39 -0700 | [diff] [blame] | 131 | hwc_layer_1_t *fbLayer = &list->hwLayers[last]; |
| 132 | if(fbLayer->handle) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 133 | setListStats(ctx, list, dpy); |
| 134 | reset_layer_prop(ctx, dpy); |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 135 | int ret = ctx->mMDPComp->prepare(ctx, list); |
| 136 | if(!ret) { |
| 137 | // IF MDPcomp fails use this route |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 138 | VideoOverlay::prepare(ctx, list, dpy); |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 139 | ctx->mFBUpdate[dpy]->prepare(ctx, list); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 140 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 141 | ctx->mLayerCache[dpy]->updateLayerCache(list); |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 142 | // Use Copybit, when MDP comp fails |
| 143 | if(!ret && ctx->mCopyBit[dpy]) |
| 144 | ctx->mCopyBit[dpy]->prepare(ctx, list, dpy); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | static int hwc_prepare_external(hwc_composer_device_1 *dev, |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 151 | hwc_display_contents_1_t *list, int dpy) { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 152 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 153 | |
Saurabh Shah | bf1e02a | 2013-02-26 13:38:05 -0800 | [diff] [blame] | 154 | if (LIKELY(list && list->numHwLayers > 1 && |
| 155 | list->numHwLayers <= MAX_NUM_LAYERS) && |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 156 | ctx->dpyAttr[dpy].isActive && |
| 157 | ctx->dpyAttr[dpy].connected) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 158 | uint32_t last = list->numHwLayers - 1; |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 159 | if(!ctx->dpyAttr[dpy].isPause) { |
| 160 | hwc_layer_1_t *fbLayer = &list->hwLayers[last]; |
| 161 | if(fbLayer->handle) { |
| 162 | setListStats(ctx, list, dpy); |
| 163 | reset_layer_prop(ctx, dpy); |
| 164 | VideoOverlay::prepare(ctx, list, dpy); |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 165 | ctx->mFBUpdate[dpy]->prepare(ctx, list); |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 166 | ctx->mLayerCache[dpy]->updateLayerCache(list); |
| 167 | if(ctx->mCopyBit[dpy]) |
| 168 | ctx->mCopyBit[dpy]->prepare(ctx, list, dpy); |
| 169 | ctx->mExtDispConfiguring = false; |
| 170 | } |
| 171 | } else { |
| 172 | // External Display is in Pause state. |
| 173 | // ToDo: |
| 174 | // Mark all application layers as OVERLAY so that |
| 175 | // GPU will not compose. This is done for power |
| 176 | // optimization |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 177 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 178 | } |
| 179 | return 0; |
Saurabh Shah | 649cda6 | 2012-09-16 16:05:58 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 182 | static int hwc_prepare(hwc_composer_device_1 *dev, size_t numDisplays, |
| 183 | hwc_display_contents_1_t** displays) |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 184 | { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 185 | int ret = 0; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 186 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 187 | Locker::Autolock _l(ctx->mBlankLock); |
Naseer Ahmed | b1c7632 | 2012-10-17 00:32:50 -0400 | [diff] [blame] | 188 | reset(ctx, numDisplays, displays); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 189 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 190 | ctx->mOverlay->configBegin(); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 191 | |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 192 | for (int32_t i = numDisplays; i >= 0; i--) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 193 | hwc_display_contents_1_t *list = displays[i]; |
| 194 | switch(i) { |
| 195 | case HWC_DISPLAY_PRIMARY: |
| 196 | ret = hwc_prepare_primary(dev, list); |
| 197 | break; |
| 198 | case HWC_DISPLAY_EXTERNAL: |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 199 | case HWC_DISPLAY_VIRTUAL: |
| 200 | ret = hwc_prepare_external(dev, list, i); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 201 | break; |
| 202 | default: |
| 203 | ret = -EINVAL; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 204 | } |
| 205 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 206 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 207 | ctx->mOverlay->configDone(); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 208 | return ret; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 211 | static int hwc_eventControl(struct hwc_composer_device_1* dev, int dpy, |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 212 | int event, int enabled) |
| 213 | { |
| 214 | int ret = 0; |
Naseer Ahmed | ff4f025 | 2012-10-01 13:03:01 -0400 | [diff] [blame] | 215 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 216 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
| 217 | private_module_t* m = reinterpret_cast<private_module_t*>( |
| 218 | ctx->mFbDev->common.module); |
Iliyan Malchev | eac8965 | 2012-10-04 10:38:28 -0700 | [diff] [blame] | 219 | pthread_mutex_lock(&ctx->vstate.lock); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 220 | switch(event) { |
| 221 | case HWC_EVENT_VSYNC: |
Omprakash Dhyade | 1ef881c | 2012-10-03 02:26:55 -0700 | [diff] [blame] | 222 | if (ctx->vstate.enable == enabled) |
| 223 | break; |
Iliyan Malchev | eac8965 | 2012-10-04 10:38:28 -0700 | [diff] [blame] | 224 | ctx->vstate.enable = !!enabled; |
Naseer Ahmed | c7faa70 | 2012-10-04 15:10:30 -0400 | [diff] [blame] | 225 | pthread_cond_signal(&ctx->vstate.cond); |
Iliyan Malchev | eac8965 | 2012-10-04 10:38:28 -0700 | [diff] [blame] | 226 | ALOGD_IF (VSYNC_DEBUG, "VSYNC state changed to %s", |
| 227 | (enabled)?"ENABLED":"DISABLED"); |
| 228 | break; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 229 | default: |
| 230 | ret = -EINVAL; |
| 231 | } |
Iliyan Malchev | eac8965 | 2012-10-04 10:38:28 -0700 | [diff] [blame] | 232 | pthread_mutex_unlock(&ctx->vstate.lock); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 233 | return ret; |
| 234 | } |
| 235 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 236 | static int hwc_blank(struct hwc_composer_device_1* dev, int dpy, int blank) |
| 237 | { |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 238 | ATRACE_CALL(); |
Naseer Ahmed | 934790c | 2012-08-16 18:11:09 -0700 | [diff] [blame] | 239 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
| 240 | private_module_t* m = reinterpret_cast<private_module_t*>( |
| 241 | ctx->mFbDev->common.module); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 242 | Locker::Autolock _l(ctx->mBlankLock); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 243 | int ret = 0; |
| 244 | ALOGD("%s: Doing Dpy=%d, blank=%d", __FUNCTION__, dpy, blank); |
| 245 | switch(dpy) { |
| 246 | case HWC_DISPLAY_PRIMARY: |
| 247 | if(blank) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 248 | ctx->mOverlay->configBegin(); |
| 249 | ctx->mOverlay->configDone(); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 250 | ret = ioctl(m->framebuffer->fd, FBIOBLANK, FB_BLANK_POWERDOWN); |
Ramkumar Radhakrishnan | 893d6ee | 2013-02-26 10:48:05 -0800 | [diff] [blame] | 251 | |
| 252 | if(ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected == true) { |
| 253 | // Surfaceflinger does not send Blank/unblank event to hwc |
| 254 | // for virtual display, handle it explicitly when blank for |
| 255 | // primary is invoked, so that any pipes unset get committed |
| 256 | if (!ctx->mExtDisplay->post()) { |
| 257 | ret = -1; |
| 258 | ALOGE("%s:post failed for virtual display !!", |
| 259 | __FUNCTION__); |
| 260 | } else { |
| 261 | ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive = !blank; |
| 262 | } |
| 263 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 264 | } else { |
| 265 | ret = ioctl(m->framebuffer->fd, FBIOBLANK, FB_BLANK_UNBLANK); |
Ramkumar Radhakrishnan | 893d6ee | 2013-02-26 10:48:05 -0800 | [diff] [blame] | 266 | if(ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected == true) { |
| 267 | ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive = !blank; |
| 268 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 269 | } |
| 270 | break; |
| 271 | case HWC_DISPLAY_EXTERNAL: |
| 272 | if(blank) { |
Ramkumar Radhakrishnan | 893d6ee | 2013-02-26 10:48:05 -0800 | [diff] [blame] | 273 | // External post commits the changes to display |
Arun Kumar K.R | ba9eed5 | 2013-01-04 00:51:29 -0800 | [diff] [blame] | 274 | // Call this on blank, so that any pipe unsets gets committed |
| 275 | if (!ctx->mExtDisplay->post()) { |
| 276 | ret = -1; |
Ramkumar Radhakrishnan | 893d6ee | 2013-02-26 10:48:05 -0800 | [diff] [blame] | 277 | ALOGE("%s:post failed for external display !! ", |
| 278 | __FUNCTION__); |
Arun Kumar K.R | ba9eed5 | 2013-01-04 00:51:29 -0800 | [diff] [blame] | 279 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 280 | } else { |
| 281 | } |
| 282 | break; |
| 283 | default: |
| 284 | return -EINVAL; |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 285 | } |
Arun Kumar K.R | f6f49a1 | 2012-11-27 11:46:50 -0800 | [diff] [blame] | 286 | // Enable HPD here, as during bootup unblank is called |
| 287 | // when SF is completely initialized |
| 288 | ctx->mExtDisplay->setHPD(1); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 289 | |
| 290 | if(ret < 0) { |
| 291 | ALOGE("%s: failed. Dpy=%d, blank=%d : %s", |
| 292 | __FUNCTION__, dpy, blank, strerror(errno)); |
| 293 | return ret; |
| 294 | } |
| 295 | ALOGD("%s: Done Dpy=%d, blank=%d", __FUNCTION__, dpy, blank); |
| 296 | ctx->dpyAttr[dpy].isActive = !blank; |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | static int hwc_query(struct hwc_composer_device_1* dev, |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 301 | int param, int* value) |
| 302 | { |
| 303 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
| 304 | private_module_t* m = reinterpret_cast<private_module_t*>( |
| 305 | ctx->mFbDev->common.module); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 306 | int supported = HWC_DISPLAY_PRIMARY_BIT; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 307 | |
| 308 | switch (param) { |
| 309 | case HWC_BACKGROUND_LAYER_SUPPORTED: |
| 310 | // Not supported for now |
| 311 | value[0] = 0; |
| 312 | break; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 313 | case HWC_VSYNC_PERIOD: //Not used for hwc > 1.1 |
Saurabh Shah | 2e2798c | 2012-08-30 14:47:10 -0700 | [diff] [blame] | 314 | value[0] = m->fps; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 315 | ALOGI("fps: %d", value[0]); |
| 316 | break; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 317 | case HWC_DISPLAY_TYPES_SUPPORTED: |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 318 | if(ctx->mMDP.hasOverlay) |
| 319 | supported |= HWC_DISPLAY_EXTERNAL_BIT; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 320 | value[0] = supported; |
| 321 | break; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 322 | default: |
| 323 | return -EINVAL; |
| 324 | } |
| 325 | return 0; |
| 326 | |
| 327 | } |
| 328 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 329 | static int hwc_set_primary(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 330 | ATRACE_CALL(); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 331 | int ret = 0; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 332 | const int dpy = HWC_DISPLAY_PRIMARY; |
Amara Venkata Mastan Manoj Kumar | 57e3c81 | 2013-01-11 13:36:33 -0800 | [diff] [blame] | 333 | if (LIKELY(list) && ctx->dpyAttr[dpy].isActive) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 334 | uint32_t last = list->numHwLayers - 1; |
| 335 | hwc_layer_1_t *fbLayer = &list->hwLayers[last]; |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 336 | int fd = -1; //FenceFD from the Copybit(valid in async mode) |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 337 | bool copybitDone = false; |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 338 | if(ctx->mCopyBit[dpy]) |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 339 | copybitDone = ctx->mCopyBit[dpy]->draw(ctx, list, dpy, &fd); |
Amara Venkata Mastan Manoj Kumar | 57e3c81 | 2013-01-11 13:36:33 -0800 | [diff] [blame] | 340 | if(list->numHwLayers > 1) |
| 341 | hwc_sync(ctx, list, dpy, fd); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 342 | if (!VideoOverlay::draw(ctx, list, dpy)) { |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 343 | ALOGE("%s: VideoOverlay::draw fail!", __FUNCTION__); |
| 344 | ret = -1; |
| 345 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 346 | if (!ctx->mMDPComp->draw(ctx, list)) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 347 | ALOGE("%s: MDPComp::draw fail!", __FUNCTION__); |
| 348 | ret = -1; |
| 349 | } |
| 350 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 351 | //TODO We dont check for SKIP flag on this layer because we need PAN |
| 352 | //always. Last layer is always FB |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 353 | private_handle_t *hnd = NULL; |
| 354 | if(copybitDone) { |
| 355 | hnd = ctx->mCopyBit[dpy]->getCurrentRenderBuffer(); |
| 356 | } else { |
| 357 | hnd = (private_handle_t *)fbLayer->handle; |
| 358 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 359 | if(fbLayer->compositionType == HWC_FRAMEBUFFER_TARGET && hnd) { |
Amara Venkata Mastan Manoj Kumar | 57e3c81 | 2013-01-11 13:36:33 -0800 | [diff] [blame] | 360 | if(!(fbLayer->flags & HWC_SKIP_LAYER) && |
| 361 | (list->numHwLayers > 1)) { |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 362 | if (!ctx->mFBUpdate[dpy]->draw(ctx, hnd)) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 363 | ALOGE("%s: FBUpdate::draw fail!", __FUNCTION__); |
| 364 | ret = -1; |
| 365 | } |
| 366 | } |
Saurabh Shah | 4333330 | 2013-02-06 13:30:27 -0800 | [diff] [blame] | 367 | } |
| 368 | if (ctx->mFbDev->post(ctx->mFbDev, fbLayer->handle)) { |
| 369 | ALOGE("%s: ctx->mFbDev->post fail!", __FUNCTION__); |
Saurabh Shah | 747af1e | 2013-02-26 10:25:12 -0800 | [diff] [blame] | 370 | ret = -1; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 371 | } |
| 372 | } |
Saurabh Shah | 747af1e | 2013-02-26 10:25:12 -0800 | [diff] [blame] | 373 | |
| 374 | closeAcquireFds(list); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 375 | return ret; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | static int hwc_set_external(hwc_context_t *ctx, |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 379 | hwc_display_contents_1_t* list, int dpy) |
| 380 | { |
| 381 | ATRACE_CALL(); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 382 | int ret = 0; |
Kinjal Bhavsar | f83d448 | 2012-10-10 15:56:21 -0700 | [diff] [blame] | 383 | Locker::Autolock _l(ctx->mExtSetLock); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 384 | |
Amara Venkata Mastan Manoj Kumar | 57e3c81 | 2013-01-11 13:36:33 -0800 | [diff] [blame] | 385 | if (LIKELY(list) && ctx->dpyAttr[dpy].isActive && |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 386 | !ctx->dpyAttr[dpy].isPause && |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 387 | ctx->dpyAttr[dpy].connected) { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 388 | uint32_t last = list->numHwLayers - 1; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 389 | hwc_layer_1_t *fbLayer = &list->hwLayers[last]; |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 390 | int fd = -1; //FenceFD from the Copybit(valid in async mode) |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 391 | bool copybitDone = false; |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 392 | if(ctx->mCopyBit[dpy]) |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 393 | copybitDone = ctx->mCopyBit[dpy]->draw(ctx, list, dpy, &fd); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 394 | |
Amara Venkata Mastan Manoj Kumar | 57e3c81 | 2013-01-11 13:36:33 -0800 | [diff] [blame] | 395 | if(list->numHwLayers > 1) |
| 396 | hwc_sync(ctx, list, dpy, fd); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 397 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 398 | if (!VideoOverlay::draw(ctx, list, dpy)) { |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 399 | ALOGE("%s: VideoOverlay::draw fail!", __FUNCTION__); |
| 400 | ret = -1; |
| 401 | } |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 402 | |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 403 | private_handle_t *hnd = NULL; |
| 404 | if(copybitDone) { |
| 405 | hnd = ctx->mCopyBit[dpy]->getCurrentRenderBuffer(); |
| 406 | } else { |
| 407 | hnd = (private_handle_t *)fbLayer->handle; |
| 408 | } |
| 409 | |
Saurabh Shah | 150806a | 2012-10-09 15:38:23 -0700 | [diff] [blame] | 410 | if(fbLayer->compositionType == HWC_FRAMEBUFFER_TARGET && |
Amara Venkata Mastan Manoj Kumar | 57e3c81 | 2013-01-11 13:36:33 -0800 | [diff] [blame] | 411 | !(fbLayer->flags & HWC_SKIP_LAYER) && hnd && |
| 412 | (list->numHwLayers > 1)) { |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 413 | if (!ctx->mFBUpdate[dpy]->draw(ctx, hnd)) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 414 | ALOGE("%s: FBUpdate::draw fail!", __FUNCTION__); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 415 | ret = -1; |
| 416 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 417 | } |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 418 | if (!ctx->mExtDisplay->post()) { |
| 419 | ALOGE("%s: ctx->mExtDisplay->post fail!", __FUNCTION__); |
Saurabh Shah | 747af1e | 2013-02-26 10:25:12 -0800 | [diff] [blame] | 420 | ret = -1; |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 421 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 422 | } |
Saurabh Shah | 747af1e | 2013-02-26 10:25:12 -0800 | [diff] [blame] | 423 | |
| 424 | closeAcquireFds(list); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 425 | return ret; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 426 | } |
| 427 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 428 | static int hwc_set(hwc_composer_device_1 *dev, |
| 429 | size_t numDisplays, |
| 430 | hwc_display_contents_1_t** displays) |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 431 | { |
| 432 | int ret = 0; |
| 433 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Naseer Ahmed | 32ff225 | 2012-09-29 01:41:21 -0400 | [diff] [blame] | 434 | Locker::Autolock _l(ctx->mBlankLock); |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 435 | for (uint32_t i = 0; i <= numDisplays; i++) { |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 436 | hwc_display_contents_1_t* list = displays[i]; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 437 | switch(i) { |
| 438 | case HWC_DISPLAY_PRIMARY: |
| 439 | ret = hwc_set_primary(ctx, list); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 440 | break; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 441 | case HWC_DISPLAY_EXTERNAL: |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 442 | case HWC_DISPLAY_VIRTUAL: |
| 443 | /* ToDo: We are using hwc_set_external path for both External and |
| 444 | Virtual displays on HWC1.1. Eventually, we will have |
| 445 | separate functions when we move to HWC1.2 |
| 446 | */ |
| 447 | ret = hwc_set_external(ctx, list, i); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 448 | break; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 449 | default: |
| 450 | ret = -EINVAL; |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 451 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 452 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 453 | return ret; |
| 454 | } |
| 455 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 456 | int hwc_getDisplayConfigs(struct hwc_composer_device_1* dev, int disp, |
| 457 | uint32_t* configs, size_t* numConfigs) { |
| 458 | int ret = 0; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 459 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 460 | //in 1.1 there is no way to choose a config, report as config id # 0 |
| 461 | //This config is passed to getDisplayAttributes. Ignore for now. |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 462 | switch(disp) { |
| 463 | case HWC_DISPLAY_PRIMARY: |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 464 | if(*numConfigs > 0) { |
| 465 | configs[0] = 0; |
| 466 | *numConfigs = 1; |
| 467 | } |
| 468 | ret = 0; //NO_ERROR |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 469 | break; |
| 470 | case HWC_DISPLAY_EXTERNAL: |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 471 | ret = -1; //Not connected |
| 472 | if(ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected) { |
| 473 | ret = 0; //NO_ERROR |
| 474 | if(*numConfigs > 0) { |
| 475 | configs[0] = 0; |
| 476 | *numConfigs = 1; |
| 477 | } |
| 478 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 479 | break; |
| 480 | } |
| 481 | return ret; |
| 482 | } |
| 483 | |
| 484 | int hwc_getDisplayAttributes(struct hwc_composer_device_1* dev, int disp, |
| 485 | uint32_t config, const uint32_t* attributes, int32_t* values) { |
| 486 | |
| 487 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 488 | //If hotpluggable displays are inactive return error |
| 489 | if(disp == HWC_DISPLAY_EXTERNAL && !ctx->dpyAttr[disp].connected) { |
| 490 | return -1; |
| 491 | } |
| 492 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 493 | //From HWComposer |
| 494 | static const uint32_t DISPLAY_ATTRIBUTES[] = { |
| 495 | HWC_DISPLAY_VSYNC_PERIOD, |
| 496 | HWC_DISPLAY_WIDTH, |
| 497 | HWC_DISPLAY_HEIGHT, |
| 498 | HWC_DISPLAY_DPI_X, |
| 499 | HWC_DISPLAY_DPI_Y, |
| 500 | HWC_DISPLAY_NO_ATTRIBUTE, |
| 501 | }; |
| 502 | |
| 503 | const int NUM_DISPLAY_ATTRIBUTES = (sizeof(DISPLAY_ATTRIBUTES) / |
| 504 | sizeof(DISPLAY_ATTRIBUTES)[0]); |
| 505 | |
| 506 | for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) { |
| 507 | switch (attributes[i]) { |
| 508 | case HWC_DISPLAY_VSYNC_PERIOD: |
| 509 | values[i] = ctx->dpyAttr[disp].vsync_period; |
| 510 | break; |
| 511 | case HWC_DISPLAY_WIDTH: |
| 512 | values[i] = ctx->dpyAttr[disp].xres; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 513 | ALOGD("%s disp = %d, width = %d",__FUNCTION__, disp, |
| 514 | ctx->dpyAttr[disp].xres); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 515 | break; |
| 516 | case HWC_DISPLAY_HEIGHT: |
| 517 | values[i] = ctx->dpyAttr[disp].yres; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 518 | ALOGD("%s disp = %d, height = %d",__FUNCTION__, disp, |
| 519 | ctx->dpyAttr[disp].yres); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 520 | break; |
| 521 | case HWC_DISPLAY_DPI_X: |
Naseer Ahmed | 7b80d9c | 2012-09-26 20:14:38 -0400 | [diff] [blame] | 522 | values[i] = (int32_t) (ctx->dpyAttr[disp].xdpi*1000.0); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 523 | break; |
| 524 | case HWC_DISPLAY_DPI_Y: |
Naseer Ahmed | 7b80d9c | 2012-09-26 20:14:38 -0400 | [diff] [blame] | 525 | values[i] = (int32_t) (ctx->dpyAttr[disp].ydpi*1000.0); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 526 | break; |
| 527 | default: |
| 528 | ALOGE("Unknown display attribute %d", |
| 529 | attributes[i]); |
| 530 | return -EINVAL; |
| 531 | } |
| 532 | } |
| 533 | return 0; |
| 534 | } |
| 535 | |
Naseer Ahmed | 1d183f5 | 2012-11-26 12:35:16 -0500 | [diff] [blame] | 536 | void hwc_dump(struct hwc_composer_device_1* dev, char *buff, int buff_len) |
| 537 | { |
| 538 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 539 | android::String8 aBuf(""); |
| 540 | dumpsys_log(aBuf, "Qualcomm HWC state:\n"); |
| 541 | dumpsys_log(aBuf, " MDPVersion=%d\n", ctx->mMDP.version); |
| 542 | dumpsys_log(aBuf, " DisplayPanel=%c\n", ctx->mMDP.panel); |
| 543 | ctx->mMDPComp->dump(aBuf); |
| 544 | char ovDump[2048] = {'\0'}; |
| 545 | ctx->mOverlay->getDump(ovDump, 2048); |
| 546 | dumpsys_log(aBuf, ovDump); |
| 547 | strlcpy(buff, aBuf.string(), buff_len); |
Naseer Ahmed | 1d183f5 | 2012-11-26 12:35:16 -0500 | [diff] [blame] | 548 | } |
| 549 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 550 | static int hwc_device_close(struct hw_device_t *dev) |
| 551 | { |
| 552 | if(!dev) { |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 553 | ALOGE("%s: NULL device pointer", __FUNCTION__); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 554 | return -1; |
| 555 | } |
| 556 | closeContext((hwc_context_t*)dev); |
| 557 | free(dev); |
| 558 | |
| 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | static int hwc_device_open(const struct hw_module_t* module, const char* name, |
| 563 | struct hw_device_t** device) |
| 564 | { |
| 565 | int status = -EINVAL; |
| 566 | |
| 567 | if (!strcmp(name, HWC_HARDWARE_COMPOSER)) { |
| 568 | struct hwc_context_t *dev; |
| 569 | dev = (hwc_context_t*)malloc(sizeof(*dev)); |
| 570 | memset(dev, 0, sizeof(*dev)); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 571 | |
| 572 | //Initialize hwc context |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 573 | initContext(dev); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 574 | |
| 575 | //Setup HWC methods |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 576 | dev->device.common.tag = HARDWARE_DEVICE_TAG; |
| 577 | dev->device.common.version = HWC_DEVICE_API_VERSION_1_1; |
| 578 | dev->device.common.module = const_cast<hw_module_t*>(module); |
| 579 | dev->device.common.close = hwc_device_close; |
| 580 | dev->device.prepare = hwc_prepare; |
| 581 | dev->device.set = hwc_set; |
| 582 | dev->device.eventControl = hwc_eventControl; |
| 583 | dev->device.blank = hwc_blank; |
| 584 | dev->device.query = hwc_query; |
| 585 | dev->device.registerProcs = hwc_registerProcs; |
Naseer Ahmed | 1d183f5 | 2012-11-26 12:35:16 -0500 | [diff] [blame] | 586 | dev->device.dump = hwc_dump; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 587 | dev->device.getDisplayConfigs = hwc_getDisplayConfigs; |
| 588 | dev->device.getDisplayAttributes = hwc_getDisplayAttributes; |
| 589 | *device = &dev->device.common; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 590 | status = 0; |
| 591 | } |
| 592 | return status; |
| 593 | } |