Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Dileep Kumar Reddi | bf2678b | 2014-01-29 15:33:32 +0530 | [diff] [blame] | 3 | * Copyright (C) 2012-2014, 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 | 099a693 | 2013-09-09 14:25:20 -0400 | [diff] [blame] | 20 | #define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL) |
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> |
Jeykumar Sankaran | c1f8682 | 2013-02-20 18:32:01 -0800 | [diff] [blame] | 28 | #include <sys/ioctl.h> |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 29 | #include <overlay.h> |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 30 | #include <overlayRotator.h> |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 31 | #include <overlayWriteback.h> |
Naseer Ahmed | 96c4c95 | 2012-07-25 18:27:14 -0700 | [diff] [blame] | 32 | #include <mdp_version.h> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 33 | #include "hwc_utils.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" |
Ramkumar Radhakrishnan | d224a1a | 2013-04-05 17:46:55 -0700 | [diff] [blame] | 36 | #include "hwc_dump_layers.h" |
Tatenda Chipeperekwa | af2c004 | 2014-09-17 12:55:01 -0700 | [diff] [blame] | 37 | #include "hdmi.h" |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 38 | #include "hwc_copybit.h" |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 39 | #include "hwc_ad.h" |
Naseer Ahmed | 0d05d4f | 2013-03-28 14:49:07 -0400 | [diff] [blame] | 40 | #include "profiler.h" |
Ramkumar Radhakrishnan | 8bb48d3 | 2013-12-30 23:11:27 -0800 | [diff] [blame] | 41 | #include "hwc_virtual.h" |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 42 | |
| 43 | using namespace qhwc; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 44 | using namespace overlay; |
| 45 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 46 | #define VSYNC_DEBUG 0 |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 47 | #define POWER_MODE_DEBUG 1 |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 48 | |
| 49 | static int hwc_device_open(const struct hw_module_t* module, |
| 50 | const char* name, |
| 51 | struct hw_device_t** device); |
| 52 | |
| 53 | static struct hw_module_methods_t hwc_module_methods = { |
| 54 | open: hwc_device_open |
| 55 | }; |
| 56 | |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 57 | static void reset_panel(struct hwc_composer_device_1* dev); |
| 58 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 59 | hwc_module_t HAL_MODULE_INFO_SYM = { |
| 60 | common: { |
| 61 | tag: HARDWARE_MODULE_TAG, |
| 62 | version_major: 2, |
| 63 | version_minor: 0, |
| 64 | id: HWC_HARDWARE_MODULE_ID, |
| 65 | name: "Qualcomm Hardware Composer Module", |
| 66 | author: "CodeAurora Forum", |
| 67 | methods: &hwc_module_methods, |
| 68 | dso: 0, |
| 69 | reserved: {0}, |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | /* |
| 74 | * Save callback functions registered to HWC |
| 75 | */ |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 76 | static void hwc_registerProcs(struct hwc_composer_device_1* dev, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 77 | hwc_procs_t const* procs) |
| 78 | { |
Iliyan Malchev | 0f9c397 | 2012-10-11 15:16:15 -0700 | [diff] [blame] | 79 | ALOGI("%s", __FUNCTION__); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 80 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
| 81 | if(!ctx) { |
| 82 | ALOGE("%s: Invalid context", __FUNCTION__); |
| 83 | return; |
| 84 | } |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 85 | ctx->proc = procs; |
| 86 | |
Naseer Ahmed | ff4f025 | 2012-10-01 13:03:01 -0400 | [diff] [blame] | 87 | // Now that we have the functions needed, kick off |
| 88 | // the uevent & vsync threads |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 89 | init_uevent_thread(ctx); |
Naseer Ahmed | ff4f025 | 2012-10-01 13:03:01 -0400 | [diff] [blame] | 90 | init_vsync_thread(ctx); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Raj Kamal | 794c36f | 2014-04-10 16:58:44 +0530 | [diff] [blame] | 93 | static void setPaddingRound(hwc_context_t *ctx, int numDisplays, |
| 94 | hwc_display_contents_1_t** displays) { |
| 95 | ctx->isPaddingRound = false; |
| 96 | for(int i = 0; i < numDisplays; i++) { |
| 97 | hwc_display_contents_1_t *list = displays[i]; |
| 98 | if (LIKELY(list && list->numHwLayers > 0)) { |
| 99 | if((ctx->mPrevHwLayerCount[i] == 1 or |
| 100 | ctx->mPrevHwLayerCount[i] == 0) and |
| 101 | (list->numHwLayers > 1)) { |
| 102 | /* If the previous cycle for dpy 'i' has 0 AppLayers and the |
| 103 | * current cycle has atleast 1 AppLayer, padding round needs |
| 104 | * to be invoked in current cycle on all the active displays |
| 105 | * to free up the resources. |
| 106 | */ |
| 107 | ctx->isPaddingRound = true; |
| 108 | } |
| 109 | ctx->mPrevHwLayerCount[i] = (int)list->numHwLayers; |
| 110 | } else { |
| 111 | ctx->mPrevHwLayerCount[i] = 0; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /* Based on certain conditions, isPaddingRound will be set |
| 117 | * to make this function self-contained */ |
| 118 | static void setDMAState(hwc_context_t *ctx, int numDisplays, |
| 119 | hwc_display_contents_1_t** displays) { |
| 120 | |
| 121 | if(ctx->mRotMgr->getNumActiveSessions() == 0) |
| 122 | Overlay::setDMAMode(Overlay::DMA_LINE_MODE); |
| 123 | |
Ramkumar Radhakrishnan | 2b9b245 | 2014-04-28 20:56:52 -0700 | [diff] [blame] | 124 | for(int dpy = 0; dpy < numDisplays; dpy++) { |
| 125 | hwc_display_contents_1_t *list = displays[dpy]; |
Raj Kamal | 794c36f | 2014-04-10 16:58:44 +0530 | [diff] [blame] | 126 | if (LIKELY(list && list->numHwLayers > 0)) { |
Ramkumar Radhakrishnan | 2b9b245 | 2014-04-28 20:56:52 -0700 | [diff] [blame] | 127 | for(size_t layerIndex = 0; layerIndex < list->numHwLayers; |
| 128 | layerIndex++) { |
| 129 | if(list->hwLayers[layerIndex].compositionType != |
| 130 | HWC_FRAMEBUFFER_TARGET) |
Raj Kamal | 794c36f | 2014-04-10 16:58:44 +0530 | [diff] [blame] | 131 | { |
Ramkumar Radhakrishnan | 2b9b245 | 2014-04-28 20:56:52 -0700 | [diff] [blame] | 132 | hwc_layer_1_t const* layer = &list->hwLayers[layerIndex]; |
Raj Kamal | 794c36f | 2014-04-10 16:58:44 +0530 | [diff] [blame] | 133 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 134 | |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 135 | /* If a layer requires rotation, set the DMA state |
Raj Kamal | 794c36f | 2014-04-10 16:58:44 +0530 | [diff] [blame] | 136 | * to BLOCK_MODE */ |
| 137 | |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 138 | if (canUseRotator(ctx, dpy) && |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 139 | (has90Transform(layer) || getRotDownscale(ctx, layer)) |
| 140 | && isRotationDoable(ctx, hnd)) { |
Justin Philip | 535a1bd | 2014-09-11 14:24:27 +0530 | [diff] [blame] | 141 | if(not (ctx->mOverlay->isDMAMultiplexingSupported() && |
| 142 | dpy)) { |
Raj Kamal | 794c36f | 2014-04-10 16:58:44 +0530 | [diff] [blame] | 143 | if(ctx->mOverlay->isPipeTypeAttached( |
| 144 | overlay::utils::OV_MDP_PIPE_DMA)) |
| 145 | ctx->isPaddingRound = true; |
| 146 | } |
| 147 | Overlay::setDMAMode(Overlay::DMA_BLOCK_MODE); |
| 148 | } |
| 149 | } |
| 150 | } |
Ramkumar Radhakrishnan | 2b9b245 | 2014-04-28 20:56:52 -0700 | [diff] [blame] | 151 | if(dpy) { |
Raj Kamal | 794c36f | 2014-04-10 16:58:44 +0530 | [diff] [blame] | 152 | /* Uncomment the below code for testing purpose. |
| 153 | Assuming the orientation value is in terms of HAL_TRANSFORM, |
| 154 | this needs mapping to HAL, if its in different convention */ |
| 155 | |
| 156 | /* char value[PROPERTY_VALUE_MAX]; |
| 157 | property_get("sys.ext_orientation", value, "0"); |
| 158 | ctx->mExtOrientation = atoi(value);*/ |
| 159 | |
| 160 | if(ctx->mExtOrientation || ctx->mBufferMirrorMode) { |
| 161 | if(ctx->mOverlay->isPipeTypeAttached( |
| 162 | overlay::utils::OV_MDP_PIPE_DMA)) { |
| 163 | ctx->isPaddingRound = true; |
| 164 | } |
| 165 | Overlay::setDMAMode(Overlay::DMA_BLOCK_MODE); |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | static void setNumActiveDisplays(hwc_context_t *ctx, int numDisplays, |
| 173 | hwc_display_contents_1_t** displays) { |
| 174 | |
| 175 | ctx->numActiveDisplays = 0; |
| 176 | for(int i = 0; i < numDisplays; i++) { |
| 177 | hwc_display_contents_1_t *list = displays[i]; |
| 178 | if (LIKELY(list && list->numHwLayers > 0)) { |
| 179 | /* For display devices like SSD and screenrecord, we cannot |
| 180 | * rely on isActive and connected attributes of dpyAttr to |
| 181 | * determine if the displaydevice is active. Hence in case if |
| 182 | * the layer-list is non-null and numHwLayers > 0, we assume |
| 183 | * the display device to be active. |
| 184 | */ |
| 185 | ctx->numActiveDisplays += 1; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
Naseer Ahmed | b1c7632 | 2012-10-17 00:32:50 -0400 | [diff] [blame] | 190 | static void reset(hwc_context_t *ctx, int numDisplays, |
| 191 | hwc_display_contents_1_t** displays) { |
Raj Kamal | 9ed3d6b | 2014-02-07 16:15:17 +0530 | [diff] [blame] | 192 | |
Raj Kamal | 9ed3d6b | 2014-02-07 16:15:17 +0530 | [diff] [blame] | 193 | |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 194 | for(int i = 0; i < numDisplays; i++) { |
Naseer Ahmed | b1c7632 | 2012-10-17 00:32:50 -0400 | [diff] [blame] | 195 | hwc_display_contents_1_t *list = displays[i]; |
| 196 | // XXX:SurfaceFlinger no longer guarantees that this |
| 197 | // value is reset on every prepare. However, for the layer |
| 198 | // cache we need to reset it. |
| 199 | // We can probably rethink that later on |
Raj Kamal | 52b4fdb | 2014-01-27 19:35:13 +0530 | [diff] [blame] | 200 | if (LIKELY(list && list->numHwLayers > 0)) { |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 201 | for(size_t j = 0; j < list->numHwLayers; j++) { |
Naseer Ahmed | b1c7632 | 2012-10-17 00:32:50 -0400 | [diff] [blame] | 202 | if(list->hwLayers[j].compositionType != HWC_FRAMEBUFFER_TARGET) |
| 203 | list->hwLayers[j].compositionType = HWC_FRAMEBUFFER; |
| 204 | } |
Raj Kamal | 52b4fdb | 2014-01-27 19:35:13 +0530 | [diff] [blame] | 205 | |
Naseer Ahmed | b1c7632 | 2012-10-17 00:32:50 -0400 | [diff] [blame] | 206 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 207 | |
Raj Kamal | 4393eaa | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 208 | if(ctx->mMDPComp[i]) |
| 209 | ctx->mMDPComp[i]->reset(); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 210 | if(ctx->mFBUpdate[i]) |
| 211 | ctx->mFBUpdate[i]->reset(); |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 212 | if(ctx->mCopyBit[i]) |
| 213 | ctx->mCopyBit[i]->reset(); |
Amara Venkata Mastan Manoj Kumar | 310d04f | 2013-08-13 12:42:34 -0700 | [diff] [blame] | 214 | if(ctx->mLayerRotMap[i]) |
| 215 | ctx->mLayerRotMap[i]->reset(); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 216 | } |
Saurabh Shah | a9da08f | 2013-07-03 13:27:53 -0700 | [diff] [blame] | 217 | |
| 218 | ctx->mAD->reset(); |
Manoj Kumar AVM | fb472b0 | 2014-08-21 15:13:37 -0700 | [diff] [blame] | 219 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 220 | } |
| 221 | |
Dileep Kumar Reddi | bf2678b | 2014-01-29 15:33:32 +0530 | [diff] [blame] | 222 | static void scaleDisplayFrame(hwc_context_t *ctx, int dpy, |
| 223 | hwc_display_contents_1_t *list) { |
Dileep Kumar Reddi | e351d84 | 2014-03-25 10:39:21 +0530 | [diff] [blame] | 224 | uint32_t origXres = ctx->dpyAttr[dpy].xres; |
| 225 | uint32_t origYres = ctx->dpyAttr[dpy].yres; |
| 226 | uint32_t newXres = ctx->dpyAttr[dpy].xres_new; |
| 227 | uint32_t newYres = ctx->dpyAttr[dpy].yres_new; |
| 228 | float xresRatio = (float)origXres / (float)newXres; |
| 229 | float yresRatio = (float)origYres / (float)newYres; |
Dileep Kumar Reddi | bf2678b | 2014-01-29 15:33:32 +0530 | [diff] [blame] | 230 | for (size_t i = 0; i < list->numHwLayers; i++) { |
| 231 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
| 232 | hwc_rect_t& displayFrame = layer->displayFrame; |
| 233 | hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf); |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 234 | uint32_t layerWidth = displayFrame.right - displayFrame.left; |
| 235 | uint32_t layerHeight = displayFrame.bottom - displayFrame.top; |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 236 | displayFrame.left = (int)(xresRatio * (float)displayFrame.left); |
| 237 | displayFrame.top = (int)(yresRatio * (float)displayFrame.top); |
| 238 | displayFrame.right = (int)((float)displayFrame.left + |
| 239 | (float)layerWidth * xresRatio); |
| 240 | displayFrame.bottom = (int)((float)displayFrame.top + |
| 241 | (float)layerHeight * yresRatio); |
Dileep Kumar Reddi | bf2678b | 2014-01-29 15:33:32 +0530 | [diff] [blame] | 242 | } |
| 243 | } |
| 244 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 245 | static int hwc_prepare_primary(hwc_composer_device_1 *dev, |
| 246 | hwc_display_contents_1_t *list) { |
Naseer Ahmed | 099a693 | 2013-09-09 14:25:20 -0400 | [diff] [blame] | 247 | ATRACE_CALL(); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 248 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 249 | const int dpy = HWC_DISPLAY_PRIMARY; |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 250 | bool fbComp = false; |
Saurabh Shah | 2b03339 | 2013-03-22 11:29:44 -0700 | [diff] [blame] | 251 | if (LIKELY(list && list->numHwLayers > 1) && |
Tatenda Chipeperekwa | d80b617 | 2014-09-23 11:29:37 -0700 | [diff] [blame^] | 252 | (ctx->dpyAttr[dpy].isActive || |
| 253 | ctx->mHDMIDisplay->isHDMIPrimaryDisplay())) { |
| 254 | |
| 255 | // When HDMI is primary we should rely on the first valid |
| 256 | // draw call in order to activate the display |
| 257 | if (!ctx->dpyAttr[dpy].isActive) { |
| 258 | // If the cable is connected after HWC initialization and before |
| 259 | // the UEvent thread is initialized then we will miss the ONLINE |
| 260 | // event. We need to update the display appropriately when we get |
| 261 | // the first valid frame. |
| 262 | int cableConnected = ctx->mHDMIDisplay->getConnectedState(); |
| 263 | if ((cableConnected == 1) && !ctx->dpyAttr[dpy].connected) { |
| 264 | qhwc::handle_online(ctx, dpy); |
| 265 | } |
| 266 | ctx->mHDMIDisplay->activateDisplay(); |
| 267 | ctx->dpyAttr[dpy].isActive = true; |
| 268 | } |
Dileep Kumar Reddi | bf2678b | 2014-01-29 15:33:32 +0530 | [diff] [blame] | 269 | |
Dileep Kumar Reddi | e351d84 | 2014-03-25 10:39:21 +0530 | [diff] [blame] | 270 | if (ctx->dpyAttr[dpy].customFBSize && |
| 271 | list->flags & HWC_GEOMETRY_CHANGED) |
Dileep Kumar Reddi | bf2678b | 2014-01-29 15:33:32 +0530 | [diff] [blame] | 272 | scaleDisplayFrame(ctx, dpy, list); |
| 273 | |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 274 | reset_layer_prop(ctx, dpy, (int)list->numHwLayers - 1); |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 275 | setListStats(ctx, list, dpy); |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 276 | |
Naseer Ahmed | 330a282 | 2014-03-05 11:57:23 -0500 | [diff] [blame] | 277 | fbComp = (ctx->mMDPComp[dpy]->prepare(ctx, list) < 0); |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 278 | |
| 279 | if (fbComp) { |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 280 | const int fbZ = 0; |
Saurabh Shah | ef19fe3 | 2014-04-22 15:31:58 -0700 | [diff] [blame] | 281 | if(not ctx->mFBUpdate[dpy]->prepareAndValidate(ctx, list, fbZ)) { |
| 282 | ctx->mOverlay->clear(dpy); |
| 283 | ctx->mLayerRotMap[dpy]->clear(); |
| 284 | } |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 285 | } |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 286 | |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 287 | if (ctx->mMDP.version < qdutils::MDP_V4_0) { |
| 288 | if(ctx->mCopyBit[dpy]) |
| 289 | ctx->mCopyBit[dpy]->prepare(ctx, list, dpy); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 290 | } |
Ramkumar Radhakrishnan | fb82291 | 2014-03-14 17:28:14 -0700 | [diff] [blame] | 291 | setGPUHint(ctx, list); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 292 | } |
| 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | static int hwc_prepare_external(hwc_composer_device_1 *dev, |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 297 | hwc_display_contents_1_t *list) { |
Naseer Ahmed | 099a693 | 2013-09-09 14:25:20 -0400 | [diff] [blame] | 298 | ATRACE_CALL(); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 299 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 300 | const int dpy = HWC_DISPLAY_EXTERNAL; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 301 | |
Saurabh Shah | 2b03339 | 2013-03-22 11:29:44 -0700 | [diff] [blame] | 302 | if (LIKELY(list && list->numHwLayers > 1) && |
| 303 | ctx->dpyAttr[dpy].isActive && |
| 304 | ctx->dpyAttr[dpy].connected) { |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 305 | reset_layer_prop(ctx, dpy, (int)list->numHwLayers - 1); |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 306 | if(!ctx->dpyAttr[dpy].isPause) { |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 307 | ctx->dpyAttr[dpy].isConfiguring = false; |
| 308 | setListStats(ctx, list, dpy); |
| 309 | if(ctx->mMDPComp[dpy]->prepare(ctx, list) < 0) { |
| 310 | const int fbZ = 0; |
Saurabh Shah | ef19fe3 | 2014-04-22 15:31:58 -0700 | [diff] [blame] | 311 | if(not ctx->mFBUpdate[dpy]->prepareAndValidate(ctx, list, fbZ)) |
| 312 | { |
| 313 | ctx->mOverlay->clear(dpy); |
| 314 | ctx->mLayerRotMap[dpy]->clear(); |
| 315 | } |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 316 | } |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 317 | } else { |
Raj Kamal | ed5a13a | 2013-12-10 22:19:12 +0530 | [diff] [blame] | 318 | /* External Display is in Pause state. |
| 319 | * Mark all application layers as OVERLAY so that |
| 320 | * GPU will not compose. |
| 321 | */ |
| 322 | for(size_t i = 0 ;i < (size_t)(list->numHwLayers - 1); i++) { |
| 323 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
| 324 | layer->compositionType = HWC_OVERLAY; |
| 325 | } |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 326 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 327 | } |
| 328 | return 0; |
Saurabh Shah | 649cda6 | 2012-09-16 16:05:58 -0700 | [diff] [blame] | 329 | } |
| 330 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 331 | static int hwc_prepare(hwc_composer_device_1 *dev, size_t numDisplays, |
| 332 | hwc_display_contents_1_t** displays) |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 333 | { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 334 | int ret = 0; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 335 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 336 | |
| 337 | if (ctx->mPanelResetStatus) { |
| 338 | ALOGW("%s: panel is in bad state. reset the panel", __FUNCTION__); |
| 339 | reset_panel(dev); |
| 340 | } |
| 341 | |
Saurabh Shah | 188e433 | 2013-07-18 10:33:22 -0700 | [diff] [blame] | 342 | //Will be unlocked at the end of set |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 343 | ctx->mDrawLock.lock(); |
Shalaj Jain | a70b435 | 2014-06-15 13:47:47 -0700 | [diff] [blame] | 344 | setPaddingRound(ctx, (int)numDisplays, displays); |
| 345 | setDMAState(ctx, (int)numDisplays, displays); |
| 346 | setNumActiveDisplays(ctx, (int)numDisplays, displays); |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 347 | reset(ctx, (int)numDisplays, displays); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 348 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 349 | ctx->mOverlay->configBegin(); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 350 | ctx->mRotMgr->configBegin(); |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 351 | overlay::Writeback::configBegin(); |
| 352 | |
Manoj Kumar AVM | 9591a5e | 2014-08-21 22:50:21 -0700 | [diff] [blame] | 353 | for (int32_t dpy = ((int32_t)numDisplays-1); dpy >=0 ; dpy--) { |
| 354 | hwc_display_contents_1_t *list = displays[dpy]; |
Jeykumar Sankaran | f53022a | 2014-08-19 10:54:09 -0700 | [diff] [blame] | 355 | resetROI(ctx, dpy); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 356 | switch(dpy) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 357 | case HWC_DISPLAY_PRIMARY: |
| 358 | ret = hwc_prepare_primary(dev, list); |
| 359 | break; |
| 360 | case HWC_DISPLAY_EXTERNAL: |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 361 | ret = hwc_prepare_external(dev, list); |
| 362 | break; |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 363 | case HWC_DISPLAY_VIRTUAL: |
Ramkumar Radhakrishnan | 8bb48d3 | 2013-12-30 23:11:27 -0800 | [diff] [blame] | 364 | if(ctx->mHWCVirtual) |
| 365 | ret = ctx->mHWCVirtual->prepare(dev, list); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 366 | break; |
| 367 | default: |
| 368 | ret = -EINVAL; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 369 | } |
| 370 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 371 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 372 | ctx->mOverlay->configDone(); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 373 | ctx->mRotMgr->configDone(); |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 374 | overlay::Writeback::configDone(); |
Manoj Kumar AVM | fb472b0 | 2014-08-21 15:13:37 -0700 | [diff] [blame] | 375 | // If VD list is deleted, mdp overlay pipe objects and writeback object |
| 376 | // are deleted as part of configDone functions. |
| 377 | // Proceed with HWCVirtualVDS object deletion. |
| 378 | if(ctx->mHWCVirtual) |
| 379 | ctx->mHWCVirtual->destroy(ctx, numDisplays, displays); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 380 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 381 | return ret; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 382 | } |
| 383 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 384 | static int hwc_eventControl(struct hwc_composer_device_1* dev, int dpy, |
Naseer Ahmed | 56601cd | 2013-03-05 11:34:14 -0500 | [diff] [blame] | 385 | int event, int enable) |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 386 | { |
Naseer Ahmed | 099a693 | 2013-09-09 14:25:20 -0400 | [diff] [blame] | 387 | ATRACE_CALL(); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 388 | int ret = 0; |
| 389 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 390 | switch(event) { |
| 391 | case HWC_EVENT_VSYNC: |
Naseer Ahmed | 56601cd | 2013-03-05 11:34:14 -0500 | [diff] [blame] | 392 | if (ctx->vstate.enable == enable) |
Omprakash Dhyade | 1ef881c | 2012-10-03 02:26:55 -0700 | [diff] [blame] | 393 | break; |
Naseer Ahmed | 56601cd | 2013-03-05 11:34:14 -0500 | [diff] [blame] | 394 | ret = hwc_vsync_control(ctx, dpy, enable); |
Naseer Ahmed | 8bb8f9d | 2013-05-11 07:29:45 -0400 | [diff] [blame] | 395 | if(ret == 0) |
Naseer Ahmed | 56601cd | 2013-03-05 11:34:14 -0500 | [diff] [blame] | 396 | ctx->vstate.enable = !!enable; |
Iliyan Malchev | eac8965 | 2012-10-04 10:38:28 -0700 | [diff] [blame] | 397 | ALOGD_IF (VSYNC_DEBUG, "VSYNC state changed to %s", |
Naseer Ahmed | 56601cd | 2013-03-05 11:34:14 -0500 | [diff] [blame] | 398 | (enable)?"ENABLED":"DISABLED"); |
Iliyan Malchev | eac8965 | 2012-10-04 10:38:28 -0700 | [diff] [blame] | 399 | break; |
Naseer Ahmed | edbe518 | 2013-05-28 19:56:11 -0400 | [diff] [blame] | 400 | #ifdef QCOM_BSP |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 401 | case HWC_EVENT_ORIENTATION: |
| 402 | if(dpy == HWC_DISPLAY_PRIMARY) { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 403 | Locker::Autolock _l(ctx->mDrawLock); |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 404 | // store the primary display orientation |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 405 | ctx->deviceOrientation = enable; |
| 406 | } |
| 407 | break; |
Naseer Ahmed | edbe518 | 2013-05-28 19:56:11 -0400 | [diff] [blame] | 408 | #endif |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 409 | default: |
| 410 | ret = -EINVAL; |
| 411 | } |
| 412 | return ret; |
| 413 | } |
| 414 | |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 415 | static int hwc_setPowerMode(struct hwc_composer_device_1* dev, int dpy, |
| 416 | int mode) |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 417 | { |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 418 | ATRACE_CALL(); |
Naseer Ahmed | 934790c | 2012-08-16 18:11:09 -0700 | [diff] [blame] | 419 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 420 | int ret = 0, value = 0; |
Raj Kamal | 2464cce | 2013-09-06 16:20:12 +0530 | [diff] [blame] | 421 | |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 422 | Locker::Autolock _l(ctx->mDrawLock); |
| 423 | ALOGD_IF(POWER_MODE_DEBUG, "%s: Setting mode %d on display: %d", |
| 424 | __FUNCTION__, mode, dpy); |
| 425 | |
| 426 | switch(mode) { |
| 427 | case HWC_POWER_MODE_OFF: |
| 428 | // free up all the overlay pipes in use |
| 429 | // when we get a blank for either display |
| 430 | // makes sure that all pipes are freed |
| 431 | ctx->mOverlay->configBegin(); |
| 432 | ctx->mOverlay->configDone(); |
| 433 | ctx->mRotMgr->clear(); |
| 434 | // If VDS is connected, do not clear WB object as it |
| 435 | // will end up detaching IOMMU. This is required |
| 436 | // to send black frame to WFD sink on power suspend. |
| 437 | // Note: With this change, we keep the WriteBack object |
| 438 | // alive on power suspend for AD use case. |
| 439 | value = FB_BLANK_POWERDOWN; |
| 440 | break; |
| 441 | case HWC_POWER_MODE_DOZE: |
| 442 | case HWC_POWER_MODE_DOZE_SUSPEND: |
| 443 | value = FB_BLANK_VSYNC_SUSPEND; |
| 444 | break; |
| 445 | case HWC_POWER_MODE_NORMAL: |
| 446 | value = FB_BLANK_UNBLANK; |
| 447 | break; |
Arun Kumar K.R | e740837 | 2013-03-28 18:41:06 -0700 | [diff] [blame] | 448 | } |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 449 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 450 | switch(dpy) { |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 451 | case HWC_DISPLAY_PRIMARY: |
Tatenda Chipeperekwa | d80b617 | 2014-09-23 11:29:37 -0700 | [diff] [blame^] | 452 | if(ctx->mHDMIDisplay->isHDMIPrimaryDisplay()) { |
| 453 | if(ctx->dpyAttr[dpy].connected) { |
| 454 | // When HDMI is connected as primary we clean up resources |
| 455 | // and call commit to generate a black frame on the interface. |
| 456 | // However, we do not call blank since we need the timing |
| 457 | // generator and HDMI core to remain turned on. |
| 458 | if((mode == HWC_POWER_MODE_OFF) && |
| 459 | (!Overlay::displayCommit(ctx->dpyAttr[dpy].fd))) { |
| 460 | ALOGE("%s: display commit fail for %d", __FUNCTION__, dpy); |
| 461 | ret = -1; |
| 462 | } |
| 463 | } |
| 464 | } else { |
| 465 | if(ioctl(ctx->dpyAttr[dpy].fd, FBIOBLANK, value) < 0 ) { |
| 466 | ALOGE("%s: ioctl FBIOBLANK failed for Primary with error %s" |
| 467 | " value %d", __FUNCTION__, strerror(errno), value); |
| 468 | return -errno; |
| 469 | } |
Ramkumar Radhakrishnan | 893d6ee | 2013-02-26 10:48:05 -0800 | [diff] [blame] | 470 | |
Tatenda Chipeperekwa | d80b617 | 2014-09-23 11:29:37 -0700 | [diff] [blame^] | 471 | if(mode == HWC_POWER_MODE_NORMAL) { |
| 472 | // Enable HPD here, as during bootup POWER_MODE_NORMAL is set |
| 473 | // when SF is completely initialized |
| 474 | ctx->mHDMIDisplay->setHPD(1); |
| 475 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 476 | |
Tatenda Chipeperekwa | d80b617 | 2014-09-23 11:29:37 -0700 | [diff] [blame^] | 477 | ctx->dpyAttr[dpy].isActive = not(mode == HWC_POWER_MODE_OFF); |
| 478 | } |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 479 | //Deliberate fall through since there is no explicit power mode for |
| 480 | //virtual displays. |
Raj Kamal | 2464cce | 2013-09-06 16:20:12 +0530 | [diff] [blame] | 481 | case HWC_DISPLAY_VIRTUAL: |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 482 | if(ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected) { |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 483 | const int dpy = HWC_DISPLAY_VIRTUAL; |
| 484 | if(mode == HWC_POWER_MODE_OFF and |
| 485 | (not ctx->dpyAttr[dpy].isPause)) { |
Amara Venkata Mastan Manoj Kumar | 95e8bc6 | 2013-08-20 18:24:16 -0700 | [diff] [blame] | 486 | if(!Overlay::displayCommit(ctx->dpyAttr[dpy].fd)) { |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 487 | ALOGE("%s: displayCommit failed for virtual", __FUNCTION__); |
Amara Venkata Mastan Manoj Kumar | 95e8bc6 | 2013-08-20 18:24:16 -0700 | [diff] [blame] | 488 | ret = -1; |
| 489 | } |
| 490 | } |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 491 | ctx->dpyAttr[dpy].isActive = not(mode == HWC_POWER_MODE_OFF); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 492 | } |
| 493 | break; |
| 494 | case HWC_DISPLAY_EXTERNAL: |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 495 | if(mode == HWC_POWER_MODE_OFF) { |
Amara Venkata Mastan Manoj Kumar | 95e8bc6 | 2013-08-20 18:24:16 -0700 | [diff] [blame] | 496 | if(!Overlay::displayCommit(ctx->dpyAttr[dpy].fd)) { |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 497 | ALOGE("%s: displayCommit failed for external", __FUNCTION__); |
Amara Venkata Mastan Manoj Kumar | 95e8bc6 | 2013-08-20 18:24:16 -0700 | [diff] [blame] | 498 | ret = -1; |
| 499 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 500 | } |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 501 | ctx->dpyAttr[dpy].isActive = not(mode == HWC_POWER_MODE_OFF); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 502 | break; |
| 503 | default: |
| 504 | return -EINVAL; |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 505 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 506 | |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 507 | ALOGD_IF(POWER_MODE_DEBUG, "%s: Done setting mode %d on display %d", |
| 508 | __FUNCTION__, mode, dpy); |
Amara Venkata Mastan Manoj Kumar | 95e8bc6 | 2013-08-20 18:24:16 -0700 | [diff] [blame] | 509 | return ret; |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 510 | } |
| 511 | |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 512 | static void reset_panel(struct hwc_composer_device_1* dev) |
| 513 | { |
| 514 | int ret = 0; |
| 515 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
| 516 | |
Neti Ravi Kumar | 8f470d8 | 2014-02-18 12:19:44 +0530 | [diff] [blame] | 517 | if (!ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isActive) { |
| 518 | ALOGD ("%s : Display OFF - Skip BLANK & UNBLANK", __FUNCTION__); |
| 519 | ctx->mPanelResetStatus = false; |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 520 | return; |
Neti Ravi Kumar | 8f470d8 | 2014-02-18 12:19:44 +0530 | [diff] [blame] | 521 | } |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 522 | |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 523 | ALOGD("%s: setting power mode off", __FUNCTION__); |
| 524 | ret = hwc_setPowerMode(dev, HWC_DISPLAY_PRIMARY, HWC_POWER_MODE_OFF); |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 525 | if (ret < 0) { |
| 526 | ALOGE("%s: FBIOBLANK failed to BLANK: %s", __FUNCTION__, |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 527 | strerror(errno)); |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 528 | } |
| 529 | |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 530 | ALOGD("%s: setting power mode normal and enabling vsync", __FUNCTION__); |
| 531 | ret = hwc_setPowerMode(dev, HWC_DISPLAY_PRIMARY, HWC_POWER_MODE_NORMAL); |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 532 | if (ret < 0) { |
| 533 | ALOGE("%s: FBIOBLANK failed to UNBLANK : %s", __FUNCTION__, |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 534 | strerror(errno)); |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 535 | } |
| 536 | hwc_vsync_control(ctx, HWC_DISPLAY_PRIMARY, 1); |
| 537 | |
| 538 | ctx->mPanelResetStatus = false; |
| 539 | } |
| 540 | |
| 541 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 542 | static int hwc_query(struct hwc_composer_device_1* dev, |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 543 | int param, int* value) |
| 544 | { |
| 545 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 546 | int supported = HWC_DISPLAY_PRIMARY_BIT; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 547 | |
| 548 | switch (param) { |
| 549 | case HWC_BACKGROUND_LAYER_SUPPORTED: |
| 550 | // Not supported for now |
| 551 | value[0] = 0; |
| 552 | break; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 553 | case HWC_DISPLAY_TYPES_SUPPORTED: |
Ramkumar Radhakrishnan | 8bb48d3 | 2013-12-30 23:11:27 -0800 | [diff] [blame] | 554 | if(ctx->mMDP.hasOverlay) { |
| 555 | supported |= HWC_DISPLAY_VIRTUAL_BIT; |
radhakrishna | 2e792f9 | 2014-03-13 11:39:33 +0530 | [diff] [blame] | 556 | if(!(qdutils::MDPVersion::getInstance().is8x26() || |
Prabhanjan Kandula | 958ffa9 | 2014-05-12 14:56:56 +0530 | [diff] [blame] | 557 | qdutils::MDPVersion::getInstance().is8x16() || |
| 558 | qdutils::MDPVersion::getInstance().is8x39())) |
Ramkumar Radhakrishnan | 8bb48d3 | 2013-12-30 23:11:27 -0800 | [diff] [blame] | 559 | supported |= HWC_DISPLAY_EXTERNAL_BIT; |
| 560 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 561 | value[0] = supported; |
| 562 | break; |
Sushil Chauhan | 1f6d68f | 2013-10-11 11:49:35 -0700 | [diff] [blame] | 563 | case HWC_FORMAT_RB_SWAP: |
| 564 | value[0] = 1; |
| 565 | break; |
Sushil Chauhan | 943797c | 2013-10-21 17:35:55 -0700 | [diff] [blame] | 566 | case HWC_COLOR_FILL: |
| 567 | value[0] = 1; |
| 568 | break; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 569 | default: |
| 570 | return -EINVAL; |
| 571 | } |
| 572 | return 0; |
| 573 | |
| 574 | } |
| 575 | |
Jeykumar Sankaran | c1f8682 | 2013-02-20 18:32:01 -0800 | [diff] [blame] | 576 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 577 | 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] | 578 | ATRACE_CALL(); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 579 | int ret = 0; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 580 | const int dpy = HWC_DISPLAY_PRIMARY; |
Amara Venkata Mastan Manoj Kumar | 57e3c81 | 2013-01-11 13:36:33 -0800 | [diff] [blame] | 581 | if (LIKELY(list) && ctx->dpyAttr[dpy].isActive) { |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 582 | size_t last = list->numHwLayers - 1; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 583 | hwc_layer_1_t *fbLayer = &list->hwLayers[last]; |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 584 | int fd = -1; //FenceFD from the Copybit(valid in async mode) |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 585 | bool copybitDone = false; |
Sushil Chauhan | defd352 | 2014-05-13 18:17:12 -0700 | [diff] [blame] | 586 | |
| 587 | if (ctx->mCopyBit[dpy]) { |
| 588 | if (ctx->mMDP.version < qdutils::MDP_V4_0) |
| 589 | copybitDone = ctx->mCopyBit[dpy]->draw(ctx, list, dpy, &fd); |
| 590 | else |
| 591 | fd = ctx->mMDPComp[dpy]->drawOverlap(ctx, list); |
| 592 | } |
| 593 | |
Amara Venkata Mastan Manoj Kumar | 57e3c81 | 2013-01-11 13:36:33 -0800 | [diff] [blame] | 594 | if(list->numHwLayers > 1) |
| 595 | hwc_sync(ctx, list, dpy, fd); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 596 | |
Ramkumar Radhakrishnan | d224a1a | 2013-04-05 17:46:55 -0700 | [diff] [blame] | 597 | // Dump the layers for primary |
| 598 | if(ctx->mHwcDebug[dpy]) |
| 599 | ctx->mHwcDebug[dpy]->dumpLayers(list); |
| 600 | |
Naseer Ahmed | 330a282 | 2014-03-05 11:57:23 -0500 | [diff] [blame] | 601 | if (!ctx->mMDPComp[dpy]->draw(ctx, list)) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 602 | ALOGE("%s: MDPComp draw failed", __FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 603 | ret = -1; |
| 604 | } |
| 605 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 606 | //TODO We dont check for SKIP flag on this layer because we need PAN |
| 607 | //always. Last layer is always FB |
Saurabh Shah | 2b03339 | 2013-03-22 11:29:44 -0700 | [diff] [blame] | 608 | private_handle_t *hnd = (private_handle_t *)fbLayer->handle; |
Terence Hampson | c67b037 | 2013-10-09 11:32:21 -0400 | [diff] [blame] | 609 | if(copybitDone && ctx->mMDP.version >= qdutils::MDP_V4_0) { |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 610 | hnd = ctx->mCopyBit[dpy]->getCurrentRenderBuffer(); |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 611 | } |
Saurabh Shah | 2b03339 | 2013-03-22 11:29:44 -0700 | [diff] [blame] | 612 | |
Ramakant Singh | 0def28c | 2014-03-28 20:43:13 +0530 | [diff] [blame] | 613 | if(isAbcInUse(ctx) == true) { |
| 614 | int index = ctx->listStats[dpy].renderBufIndexforABC; |
| 615 | hwc_layer_1_t *tempLayer = &list->hwLayers[index]; |
| 616 | hnd = (private_handle_t *)tempLayer->handle; |
| 617 | } |
| 618 | |
Saurabh Shah | 2b03339 | 2013-03-22 11:29:44 -0700 | [diff] [blame] | 619 | if(hnd) { |
| 620 | if (!ctx->mFBUpdate[dpy]->draw(ctx, hnd)) { |
| 621 | ALOGE("%s: FBUpdate draw failed", __FUNCTION__); |
| 622 | ret = -1; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 623 | } |
Saurabh Shah | 4333330 | 2013-02-06 13:30:27 -0800 | [diff] [blame] | 624 | } |
Jeykumar Sankaran | c1f8682 | 2013-02-20 18:32:01 -0800 | [diff] [blame] | 625 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 626 | int lSplit = getLeftSplit(ctx, dpy); |
Jeykumar Sankaran | 54a8018 | 2014-05-20 10:05:46 -0700 | [diff] [blame] | 627 | qhwc::ovutils::Dim lRoi = qhwc::ovutils::Dim( |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 628 | ctx->listStats[dpy].lRoi.left, |
| 629 | ctx->listStats[dpy].lRoi.top, |
| 630 | ctx->listStats[dpy].lRoi.right - ctx->listStats[dpy].lRoi.left, |
Jeykumar Sankaran | 54a8018 | 2014-05-20 10:05:46 -0700 | [diff] [blame] | 631 | ctx->listStats[dpy].lRoi.bottom - ctx->listStats[dpy].lRoi.top); |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 632 | |
Jeykumar Sankaran | 54a8018 | 2014-05-20 10:05:46 -0700 | [diff] [blame] | 633 | qhwc::ovutils::Dim rRoi = qhwc::ovutils::Dim( |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 634 | ctx->listStats[dpy].rRoi.left - lSplit, |
| 635 | ctx->listStats[dpy].rRoi.top, |
| 636 | ctx->listStats[dpy].rRoi.right - ctx->listStats[dpy].rRoi.left, |
Jeykumar Sankaran | 54a8018 | 2014-05-20 10:05:46 -0700 | [diff] [blame] | 637 | ctx->listStats[dpy].rRoi.bottom - ctx->listStats[dpy].rRoi.top); |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 638 | |
| 639 | if(!Overlay::displayCommit(ctx->dpyAttr[dpy].fd, lRoi, rRoi)) { |
Amara Venkata Mastan Manoj Kumar | 95e8bc6 | 2013-08-20 18:24:16 -0700 | [diff] [blame] | 640 | ALOGE("%s: display commit fail for %d dpy!", __FUNCTION__, dpy); |
Ramkumar Radhakrishnan | 68a5192 | 2013-05-11 16:51:49 -0700 | [diff] [blame] | 641 | ret = -1; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 642 | } |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 643 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 644 | } |
Saurabh Shah | 747af1e | 2013-02-26 10:25:12 -0800 | [diff] [blame] | 645 | |
| 646 | closeAcquireFds(list); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 647 | return ret; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | static int hwc_set_external(hwc_context_t *ctx, |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 651 | hwc_display_contents_1_t* list) |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 652 | { |
| 653 | ATRACE_CALL(); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 654 | int ret = 0; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 655 | |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 656 | const int dpy = HWC_DISPLAY_EXTERNAL; |
| 657 | |
| 658 | |
Amara Venkata Mastan Manoj Kumar | 57e3c81 | 2013-01-11 13:36:33 -0800 | [diff] [blame] | 659 | if (LIKELY(list) && ctx->dpyAttr[dpy].isActive && |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 660 | ctx->dpyAttr[dpy].connected && |
| 661 | !ctx->dpyAttr[dpy].isPause) { |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 662 | size_t last = list->numHwLayers - 1; |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 663 | hwc_layer_1_t *fbLayer = &list->hwLayers[last]; |
| 664 | int fd = -1; //FenceFD from the Copybit(valid in async mode) |
| 665 | bool copybitDone = false; |
| 666 | if(ctx->mCopyBit[dpy]) |
| 667 | copybitDone = ctx->mCopyBit[dpy]->draw(ctx, list, dpy, &fd); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 668 | |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 669 | if(list->numHwLayers > 1) |
| 670 | hwc_sync(ctx, list, dpy, fd); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 671 | |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 672 | // Dump the layers for external |
| 673 | if(ctx->mHwcDebug[dpy]) |
| 674 | ctx->mHwcDebug[dpy]->dumpLayers(list); |
Ramkumar Radhakrishnan | d224a1a | 2013-04-05 17:46:55 -0700 | [diff] [blame] | 675 | |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 676 | if (!ctx->mMDPComp[dpy]->draw(ctx, list)) { |
| 677 | ALOGE("%s: MDPComp draw failed", __FUNCTION__); |
| 678 | ret = -1; |
| 679 | } |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 680 | |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 681 | private_handle_t *hnd = (private_handle_t *)fbLayer->handle; |
Ramkumar Radhakrishnan | 3d86377 | 2014-08-12 16:49:03 -0700 | [diff] [blame] | 682 | if(copybitDone) { |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 683 | hnd = ctx->mCopyBit[dpy]->getCurrentRenderBuffer(); |
| 684 | } |
| 685 | |
Ramkumar Radhakrishnan | 3d86377 | 2014-08-12 16:49:03 -0700 | [diff] [blame] | 686 | if(hnd) { |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 687 | if (!ctx->mFBUpdate[dpy]->draw(ctx, hnd)) { |
| 688 | ALOGE("%s: FBUpdate::draw fail!", __FUNCTION__); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 689 | ret = -1; |
| 690 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 691 | } |
Jeykumar Sankaran | c1f8682 | 2013-02-20 18:32:01 -0800 | [diff] [blame] | 692 | |
Amara Venkata Mastan Manoj Kumar | 95e8bc6 | 2013-08-20 18:24:16 -0700 | [diff] [blame] | 693 | if(!Overlay::displayCommit(ctx->dpyAttr[dpy].fd)) { |
| 694 | ALOGE("%s: display commit fail for %d dpy!", __FUNCTION__, dpy); |
Saurabh Shah | 2b03339 | 2013-03-22 11:29:44 -0700 | [diff] [blame] | 695 | ret = -1; |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 696 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 697 | } |
Saurabh Shah | 747af1e | 2013-02-26 10:25:12 -0800 | [diff] [blame] | 698 | |
| 699 | closeAcquireFds(list); |
Saurabh Shah | eaf6791 | 2012-10-10 17:33:14 -0700 | [diff] [blame] | 700 | return ret; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 701 | } |
| 702 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 703 | static int hwc_set(hwc_composer_device_1 *dev, |
| 704 | size_t numDisplays, |
| 705 | hwc_display_contents_1_t** displays) |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 706 | { |
| 707 | int ret = 0; |
| 708 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Manoj Kumar AVM | 9591a5e | 2014-08-21 22:50:21 -0700 | [diff] [blame] | 709 | for (int dpy = 0; dpy < (int)numDisplays; dpy++) { |
| 710 | hwc_display_contents_1_t* list = displays[dpy]; |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 711 | switch(dpy) { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 712 | case HWC_DISPLAY_PRIMARY: |
| 713 | ret = hwc_set_primary(ctx, list); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 714 | break; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 715 | case HWC_DISPLAY_EXTERNAL: |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 716 | ret = hwc_set_external(ctx, list); |
| 717 | break; |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 718 | case HWC_DISPLAY_VIRTUAL: |
Ramkumar Radhakrishnan | 8bb48d3 | 2013-12-30 23:11:27 -0800 | [diff] [blame] | 719 | if(ctx->mHWCVirtual) |
| 720 | ret = ctx->mHWCVirtual->set(ctx, list); |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 721 | break; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 722 | default: |
| 723 | ret = -EINVAL; |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 724 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 725 | } |
Naseer Ahmed | 0d05d4f | 2013-03-28 14:49:07 -0400 | [diff] [blame] | 726 | // This is only indicative of how many times SurfaceFlinger posts |
| 727 | // frames to the display. |
| 728 | CALC_FPS(); |
Saurabh Shah | 2d998a9 | 2013-05-14 17:55:58 -0700 | [diff] [blame] | 729 | MDPComp::resetIdleFallBack(); |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 730 | ctx->mVideoTransFlag = false; |
Saurabh Shah | 188e433 | 2013-07-18 10:33:22 -0700 | [diff] [blame] | 731 | //Was locked at the beginning of prepare |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 732 | ctx->mDrawLock.unlock(); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 733 | return ret; |
| 734 | } |
| 735 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 736 | int hwc_getDisplayConfigs(struct hwc_composer_device_1* dev, int disp, |
| 737 | uint32_t* configs, size_t* numConfigs) { |
| 738 | int ret = 0; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 739 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 740 | //Currently we allow only 1 config, reported as config id # 0 |
| 741 | //This config is passed in to getDisplayAttributes. Ignored for now. |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 742 | switch(disp) { |
| 743 | case HWC_DISPLAY_PRIMARY: |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 744 | if(*numConfigs > 0) { |
| 745 | configs[0] = 0; |
| 746 | *numConfigs = 1; |
| 747 | } |
| 748 | ret = 0; //NO_ERROR |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 749 | break; |
| 750 | case HWC_DISPLAY_EXTERNAL: |
Amara Venkata Mastan Manoj Kumar | 7fb1327 | 2013-07-01 13:59:34 -0700 | [diff] [blame] | 751 | case HWC_DISPLAY_VIRTUAL: |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 752 | ret = -1; //Not connected |
Amara Venkata Mastan Manoj Kumar | 7fb1327 | 2013-07-01 13:59:34 -0700 | [diff] [blame] | 753 | if(ctx->dpyAttr[disp].connected) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 754 | ret = 0; //NO_ERROR |
| 755 | if(*numConfigs > 0) { |
| 756 | configs[0] = 0; |
| 757 | *numConfigs = 1; |
| 758 | } |
| 759 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 760 | break; |
| 761 | } |
| 762 | return ret; |
| 763 | } |
| 764 | |
| 765 | int hwc_getDisplayAttributes(struct hwc_composer_device_1* dev, int disp, |
Arun Kumar K.R | 2aa44c6 | 2014-01-21 23:08:28 -0800 | [diff] [blame] | 766 | uint32_t /*config*/, const uint32_t* attributes, int32_t* values) { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 767 | |
| 768 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Amara Venkata Mastan Manoj Kumar | 7fb1327 | 2013-07-01 13:59:34 -0700 | [diff] [blame] | 769 | //If hotpluggable displays(i.e, HDMI, WFD) are inactive return error |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 770 | if( (disp != HWC_DISPLAY_PRIMARY) && !ctx->dpyAttr[disp].connected) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 771 | return -1; |
| 772 | } |
| 773 | |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 774 | //From HWComposer |
| 775 | static const uint32_t DISPLAY_ATTRIBUTES[] = { |
| 776 | HWC_DISPLAY_VSYNC_PERIOD, |
| 777 | HWC_DISPLAY_WIDTH, |
| 778 | HWC_DISPLAY_HEIGHT, |
| 779 | HWC_DISPLAY_DPI_X, |
| 780 | HWC_DISPLAY_DPI_Y, |
| 781 | HWC_DISPLAY_NO_ATTRIBUTE, |
| 782 | }; |
| 783 | |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 784 | const size_t NUM_DISPLAY_ATTRIBUTES = (sizeof(DISPLAY_ATTRIBUTES) / |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 785 | sizeof(DISPLAY_ATTRIBUTES)[0]); |
| 786 | |
| 787 | for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) { |
| 788 | switch (attributes[i]) { |
| 789 | case HWC_DISPLAY_VSYNC_PERIOD: |
| 790 | values[i] = ctx->dpyAttr[disp].vsync_period; |
| 791 | break; |
| 792 | case HWC_DISPLAY_WIDTH: |
Dileep Kumar Reddi | e351d84 | 2014-03-25 10:39:21 +0530 | [diff] [blame] | 793 | if (ctx->dpyAttr[disp].customFBSize) |
| 794 | values[i] = ctx->dpyAttr[disp].xres_new; |
| 795 | else |
| 796 | values[i] = ctx->dpyAttr[disp].xres; |
| 797 | |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 798 | ALOGD("%s disp = %d, width = %d",__FUNCTION__, disp, |
Dileep Kumar Reddi | e351d84 | 2014-03-25 10:39:21 +0530 | [diff] [blame] | 799 | values[i]); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 800 | break; |
| 801 | case HWC_DISPLAY_HEIGHT: |
Dileep Kumar Reddi | e351d84 | 2014-03-25 10:39:21 +0530 | [diff] [blame] | 802 | if (ctx->dpyAttr[disp].customFBSize) |
| 803 | values[i] = ctx->dpyAttr[disp].yres_new; |
| 804 | else |
| 805 | values[i] = ctx->dpyAttr[disp].yres; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 806 | ALOGD("%s disp = %d, height = %d",__FUNCTION__, disp, |
Dileep Kumar Reddi | e351d84 | 2014-03-25 10:39:21 +0530 | [diff] [blame] | 807 | values[i]); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 808 | break; |
| 809 | case HWC_DISPLAY_DPI_X: |
Naseer Ahmed | 7b80d9c | 2012-09-26 20:14:38 -0400 | [diff] [blame] | 810 | values[i] = (int32_t) (ctx->dpyAttr[disp].xdpi*1000.0); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 811 | break; |
| 812 | case HWC_DISPLAY_DPI_Y: |
Naseer Ahmed | 7b80d9c | 2012-09-26 20:14:38 -0400 | [diff] [blame] | 813 | values[i] = (int32_t) (ctx->dpyAttr[disp].ydpi*1000.0); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 814 | break; |
| 815 | default: |
| 816 | ALOGE("Unknown display attribute %d", |
| 817 | attributes[i]); |
| 818 | return -EINVAL; |
| 819 | } |
| 820 | } |
| 821 | return 0; |
| 822 | } |
| 823 | |
Naseer Ahmed | 1d183f5 | 2012-11-26 12:35:16 -0500 | [diff] [blame] | 824 | void hwc_dump(struct hwc_composer_device_1* dev, char *buff, int buff_len) |
| 825 | { |
| 826 | hwc_context_t* ctx = (hwc_context_t*)(dev); |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 827 | Locker::Autolock _l(ctx->mDrawLock); |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 828 | android::String8 aBuf(""); |
| 829 | dumpsys_log(aBuf, "Qualcomm HWC state:\n"); |
| 830 | dumpsys_log(aBuf, " MDPVersion=%d\n", ctx->mMDP.version); |
| 831 | dumpsys_log(aBuf, " DisplayPanel=%c\n", ctx->mMDP.panel); |
Arun Kumar K.R | a727a88 | 2014-08-20 17:14:26 -0700 | [diff] [blame] | 832 | dumpsys_log(aBuf, " DynRefreshRate=%d\n", |
| 833 | ctx->dpyAttr[HWC_DISPLAY_PRIMARY].dynRefreshRate); |
Amara Venkata Mastan Manoj Kumar | 7fb1327 | 2013-07-01 13:59:34 -0700 | [diff] [blame] | 834 | for(int dpy = 0; dpy < HWC_NUM_DISPLAY_TYPES; dpy++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 835 | if(ctx->mMDPComp[dpy]) |
Jeykumar Sankaran | 6850ac6 | 2014-05-27 10:07:26 -0700 | [diff] [blame] | 836 | ctx->mMDPComp[dpy]->dump(aBuf, ctx); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 837 | } |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 838 | char ovDump[2048] = {'\0'}; |
| 839 | ctx->mOverlay->getDump(ovDump, 2048); |
| 840 | dumpsys_log(aBuf, ovDump); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 841 | ovDump[0] = '\0'; |
Saurabh Shah | ae61b2b | 2013-04-10 16:37:25 -0700 | [diff] [blame] | 842 | ctx->mRotMgr->getDump(ovDump, 1024); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 843 | dumpsys_log(aBuf, ovDump); |
Saurabh Shah | 7ef9ec9 | 2013-10-29 10:32:23 -0700 | [diff] [blame] | 844 | ovDump[0] = '\0'; |
Saurabh Shah | 7c8d34f | 2013-10-30 15:52:29 -0700 | [diff] [blame] | 845 | if(Writeback::getDump(ovDump, 1024)) { |
| 846 | dumpsys_log(aBuf, ovDump); |
| 847 | ovDump[0] = '\0'; |
| 848 | } |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 849 | strlcpy(buff, aBuf.string(), buff_len); |
Naseer Ahmed | 1d183f5 | 2012-11-26 12:35:16 -0500 | [diff] [blame] | 850 | } |
| 851 | |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 852 | int hwc_getActiveConfig(struct hwc_composer_device_1* /*dev*/, int /*disp*/) { |
| 853 | //Supports only the default config (0th index) for now |
| 854 | return 0; |
| 855 | } |
| 856 | |
| 857 | int hwc_setActiveConfig(struct hwc_composer_device_1* /*dev*/, int /*disp*/, |
| 858 | int index) { |
| 859 | //Supports only the default config (0th index) for now |
| 860 | return (index == 0) ? index : -EINVAL; |
| 861 | } |
| 862 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 863 | static int hwc_device_close(struct hw_device_t *dev) |
| 864 | { |
| 865 | if(!dev) { |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 866 | ALOGE("%s: NULL device pointer", __FUNCTION__); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 867 | return -1; |
| 868 | } |
| 869 | closeContext((hwc_context_t*)dev); |
| 870 | free(dev); |
| 871 | |
| 872 | return 0; |
| 873 | } |
| 874 | |
| 875 | static int hwc_device_open(const struct hw_module_t* module, const char* name, |
| 876 | struct hw_device_t** device) |
| 877 | { |
| 878 | int status = -EINVAL; |
| 879 | |
| 880 | if (!strcmp(name, HWC_HARDWARE_COMPOSER)) { |
| 881 | struct hwc_context_t *dev; |
| 882 | dev = (hwc_context_t*)malloc(sizeof(*dev)); |
Ramkumar Radhakrishnan | 36bd527 | 2014-01-31 20:03:01 -0800 | [diff] [blame] | 883 | if(dev == NULL) |
| 884 | return status; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 885 | memset(dev, 0, sizeof(*dev)); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 886 | |
| 887 | //Initialize hwc context |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 888 | initContext(dev); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 889 | |
| 890 | //Setup HWC methods |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 891 | dev->device.common.tag = HARDWARE_DEVICE_TAG; |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 892 | dev->device.common.version = HWC_DEVICE_API_VERSION_1_4; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 893 | dev->device.common.module = const_cast<hw_module_t*>(module); |
| 894 | dev->device.common.close = hwc_device_close; |
| 895 | dev->device.prepare = hwc_prepare; |
| 896 | dev->device.set = hwc_set; |
| 897 | dev->device.eventControl = hwc_eventControl; |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 898 | dev->device.setPowerMode = hwc_setPowerMode; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 899 | dev->device.query = hwc_query; |
| 900 | dev->device.registerProcs = hwc_registerProcs; |
Naseer Ahmed | 1d183f5 | 2012-11-26 12:35:16 -0500 | [diff] [blame] | 901 | dev->device.dump = hwc_dump; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 902 | dev->device.getDisplayConfigs = hwc_getDisplayConfigs; |
| 903 | dev->device.getDisplayAttributes = hwc_getDisplayAttributes; |
Saurabh Shah | da3dfc9 | 2014-07-25 15:17:06 -0700 | [diff] [blame] | 904 | dev->device.getActiveConfig = hwc_getActiveConfig; |
| 905 | dev->device.setActiveConfig = hwc_setActiveConfig; |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 906 | *device = &dev->device.common; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 907 | status = 0; |
| 908 | } |
| 909 | return status; |
| 910 | } |