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