Arun Kumar K.R | f6f49a1 | 2012-11-27 11:46:50 -0800 | [diff] [blame] | 1 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2010 The Android Open Source Project |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 4 | * Copyright (C) 2012-14, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 5 | * |
| 6 | * Not a Contribution, Apache license notifications and license are |
| 7 | * retained for attribution purposes only. |
| 8 | |
| 9 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | * you may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | * Unless required by applicable law or agreed to in writing, software |
| 16 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | * See the License for the specific language governing permissions and |
| 19 | * limitations under the License. |
| 20 | */ |
Saurabh Shah | 649cda6 | 2012-09-16 16:05:58 -0700 | [diff] [blame] | 21 | #define UEVENT_DEBUG 0 |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 22 | #include <hardware_legacy/uevent.h> |
| 23 | #include <utils/Log.h> |
| 24 | #include <sys/resource.h> |
Naseer Ahmed | ff4f025 | 2012-10-01 13:03:01 -0400 | [diff] [blame] | 25 | #include <sys/prctl.h> |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 26 | #include <string.h> |
| 27 | #include <stdlib.h> |
| 28 | #include "hwc_utils.h" |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 29 | #include "hwc_fbupdate.h" |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 30 | #include "hwc_mdpcomp.h" |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 31 | #include "hwc_copybit.h" |
| 32 | #include "comptype.h" |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 33 | #include "external.h" |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 34 | #include "virtual.h" |
Tatenda Chipeperekwa | 8f1b9d7 | 2014-02-11 16:20:50 -0800 | [diff] [blame] | 35 | #include "hwc_virtual.h" |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 36 | #include "mdp_version.h" |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 37 | using namespace overlay; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 38 | namespace qhwc { |
Amara Venkata Mastan Manoj Kumar | b156a2f | 2013-02-07 16:42:50 -0800 | [diff] [blame] | 39 | #define HWC_UEVENT_SWITCH_STR "change@/devices/virtual/switch/" |
Iliyan Malchev | 0f9c397 | 2012-10-11 15:16:15 -0700 | [diff] [blame] | 40 | #define HWC_UEVENT_THREAD_NAME "hwcUeventThread" |
| 41 | |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 42 | static void setup(hwc_context_t* ctx, int dpy) |
Amara Venkata Mastan Manoj Kumar | b156a2f | 2013-02-07 16:42:50 -0800 | [diff] [blame] | 43 | { |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 44 | ctx->mFBUpdate[dpy] = IFBUpdate::getObject(ctx, dpy); |
| 45 | ctx->mMDPComp[dpy] = MDPComp::getObject(ctx, dpy); |
Amara Venkata Mastan Manoj Kumar | b156a2f | 2013-02-07 16:42:50 -0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | static void clear(hwc_context_t* ctx, int dpy) |
| 49 | { |
| 50 | if(ctx->mFBUpdate[dpy]) { |
| 51 | delete ctx->mFBUpdate[dpy]; |
| 52 | ctx->mFBUpdate[dpy] = NULL; |
| 53 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 54 | if(ctx->mMDPComp[dpy]) { |
| 55 | delete ctx->mMDPComp[dpy]; |
| 56 | ctx->mMDPComp[dpy] = NULL; |
Amara Venkata Mastan Manoj Kumar | b156a2f | 2013-02-07 16:42:50 -0800 | [diff] [blame] | 57 | } |
| 58 | } |
| 59 | |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 60 | /* Parse uevent data for devices which we are interested */ |
| 61 | static int getConnectedDisplay(const char* strUdata) |
| 62 | { |
| 63 | if(strcasestr("change@/devices/virtual/switch/hdmi", strUdata)) |
| 64 | return HWC_DISPLAY_EXTERNAL; |
| 65 | if(strcasestr("change@/devices/virtual/switch/wfd", strUdata)) |
| 66 | return HWC_DISPLAY_VIRTUAL; |
| 67 | return -1; |
| 68 | } |
| 69 | |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 70 | static bool getPanelResetStatus(hwc_context_t* ctx, const char* strUdata, int len) |
| 71 | { |
| 72 | const char* iter_str = strUdata; |
| 73 | if (strcasestr("change@/devices/virtual/graphics/fb0", strUdata)) { |
| 74 | while(((iter_str - strUdata) <= len) && (*iter_str)) { |
| 75 | char* pstr = strstr(iter_str, "PANEL_ALIVE=0"); |
| 76 | if (pstr != NULL) { |
Arpita Banerjee | d896598 | 2013-11-08 17:27:33 -0800 | [diff] [blame] | 77 | ALOGI("%s: got change event in fb0 with PANEL_ALIVE=0", |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 78 | __FUNCTION__); |
| 79 | ctx->mPanelResetStatus = true; |
| 80 | return true; |
| 81 | } |
| 82 | iter_str += strlen(iter_str)+1; |
| 83 | } |
| 84 | } |
| 85 | return false; |
| 86 | } |
| 87 | |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 88 | /* Parse uevent data for action requested for the display */ |
| 89 | static int getConnectedState(const char* strUdata, int len) |
| 90 | { |
| 91 | const char* iter_str = strUdata; |
| 92 | while(((iter_str - strUdata) <= len) && (*iter_str)) { |
| 93 | char* pstr = strstr(iter_str, "SWITCH_STATE="); |
| 94 | if (pstr != NULL) { |
| 95 | return (atoi(pstr + strlen("SWITCH_STATE="))); |
| 96 | } |
| 97 | iter_str += strlen(iter_str)+1; |
| 98 | } |
| 99 | return -1; |
| 100 | } |
| 101 | |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 102 | void handle_pause(hwc_context_t* ctx, int dpy) { |
Tatenda Chipeperekwa | 8f1b9d7 | 2014-02-11 16:20:50 -0800 | [diff] [blame] | 103 | if(ctx->mHWCVirtual) { |
| 104 | ctx->mHWCVirtual->pause(ctx, dpy); |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 105 | } |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | void handle_resume(hwc_context_t* ctx, int dpy) { |
Tatenda Chipeperekwa | 8f1b9d7 | 2014-02-11 16:20:50 -0800 | [diff] [blame] | 110 | if(ctx->mHWCVirtual) { |
| 111 | ctx->mHWCVirtual->resume(ctx, dpy); |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 112 | } |
| 113 | return; |
| 114 | } |
| 115 | |
Manoj Kumar AVM | 1e8b3fe | 2014-01-07 15:31:51 -0800 | [diff] [blame] | 116 | static void teardownWfd(hwc_context_t* ctx) { |
| 117 | // Teardown WFD display |
| 118 | ALOGD_IF(UEVENT_DEBUG,"Received HDMI connection request when WFD is " |
| 119 | "active"); |
| 120 | { |
| 121 | Locker::Autolock _l(ctx->mDrawLock); |
| 122 | clear(ctx, HWC_DISPLAY_VIRTUAL); |
| 123 | ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].connected = false; |
| 124 | ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive = false; |
| 125 | } |
| 126 | |
| 127 | ctx->mVirtualDisplay->teardown(); |
| 128 | |
| 129 | /* Need to send hotplug only when connected WFD in proprietary path */ |
| 130 | if(ctx->mVirtualonExtActive) { |
| 131 | ALOGE_IF(UEVENT_DEBUG,"%s: Sending EXTERNAL OFFLINE" |
| 132 | "hotplug event for wfd display", __FUNCTION__); |
| 133 | ctx->proc->hotplug(ctx->proc, HWC_DISPLAY_EXTERNAL, |
| 134 | EXTERNAL_OFFLINE); |
| 135 | { |
| 136 | Locker::Autolock _l(ctx->mDrawLock); |
| 137 | ctx->mVirtualonExtActive = false; |
| 138 | } |
| 139 | } |
Raj kamal | 59fea56 | 2014-04-01 16:52:19 +0530 | [diff] [blame] | 140 | |
| 141 | if(ctx->mVDSEnabled) { |
| 142 | ctx->mWfdSyncLock.lock(); |
| 143 | ALOGD_IF(HWC_WFDDISPSYNC_LOG, |
| 144 | "%s: Waiting for wfd-teardown to be signalled",__FUNCTION__); |
| 145 | ctx->mWfdSyncLock.wait(); |
| 146 | ALOGD_IF(HWC_WFDDISPSYNC_LOG, |
| 147 | "%s: Teardown signalled. Completed waiting in uevent thread", |
| 148 | __FUNCTION__); |
| 149 | ctx->mWfdSyncLock.unlock(); |
| 150 | } else { |
| 151 | /*TODO: Remove this else block and have wait rather than usleep |
| 152 | once wfd module issues binder call on teardown.*/ |
| 153 | |
| 154 | /* For now, Wait for few frames for SF to tear down the WFD session.*/ |
| 155 | usleep(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period |
| 156 | * 2 / 1000); |
| 157 | } |
Manoj Kumar AVM | 1e8b3fe | 2014-01-07 15:31:51 -0800 | [diff] [blame] | 158 | } |
| 159 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 160 | static void handle_uevent(hwc_context_t* ctx, const char* udata, int len) |
| 161 | { |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 162 | bool bpanelReset = getPanelResetStatus(ctx, udata, len); |
| 163 | if (bpanelReset) { |
radhakrishna | 5d24c25 | 2013-12-19 18:03:56 +0530 | [diff] [blame] | 164 | ctx->proc->invalidate(ctx->proc); |
Veera Sankaran | 0dadfb3 | 2013-07-22 16:07:48 -0700 | [diff] [blame] | 165 | return; |
| 166 | } |
| 167 | |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 168 | int dpy = getConnectedDisplay(udata); |
| 169 | if(dpy < 0) { |
| 170 | ALOGD_IF(UEVENT_DEBUG, "%s: Not disp Event ", __FUNCTION__); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 171 | return; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 172 | } |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 173 | |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 174 | int switch_state = getConnectedState(udata, len); |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 175 | |
Raj kamal | 59fea56 | 2014-04-01 16:52:19 +0530 | [diff] [blame] | 176 | ALOGE_IF(UEVENT_DEBUG,"%s: uevent received: %s switch state: %d", |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 177 | __FUNCTION__,udata, switch_state); |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 178 | |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 179 | switch(switch_state) { |
| 180 | case EXTERNAL_OFFLINE: |
| 181 | { |
| 182 | /* Display not connected */ |
| 183 | if(!ctx->dpyAttr[dpy].connected){ |
| 184 | ALOGE_IF(UEVENT_DEBUG,"%s: Ignoring EXTERNAL_OFFLINE event" |
| 185 | "for display: %d", __FUNCTION__, dpy); |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 186 | break; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 187 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 188 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 189 | Locker::Autolock _l(ctx->mDrawLock); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 190 | clear(ctx, dpy); |
| 191 | ctx->dpyAttr[dpy].connected = false; |
| 192 | ctx->dpyAttr[dpy].isActive = false; |
| 193 | |
| 194 | if(dpy == HWC_DISPLAY_EXTERNAL) { |
| 195 | ctx->mExtDisplay->teardown(); |
| 196 | } else { |
| 197 | ctx->mVirtualDisplay->teardown(); |
| 198 | } |
| 199 | |
| 200 | /* We need to send hotplug to SF only when we are disconnecting |
| 201 | * (1) HDMI OR (2) proprietary WFD session */ |
| 202 | if(dpy == HWC_DISPLAY_EXTERNAL || |
| 203 | ctx->mVirtualonExtActive) { |
| 204 | ALOGE_IF(UEVENT_DEBUG,"%s:Sending EXTERNAL OFFLINE hotplug" |
| 205 | "event", __FUNCTION__); |
| 206 | ctx->proc->hotplug(ctx->proc, HWC_DISPLAY_EXTERNAL, |
| 207 | EXTERNAL_OFFLINE); |
Manoj Kumar AVM | 7afbcf9 | 2013-10-18 09:07:41 -0700 | [diff] [blame] | 208 | ctx->mVirtualonExtActive = false; |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 209 | } |
| 210 | break; |
| 211 | } |
| 212 | case EXTERNAL_ONLINE: |
| 213 | { |
| 214 | /* Display already connected */ |
| 215 | if(ctx->dpyAttr[dpy].connected) { |
| 216 | ALOGE_IF(UEVENT_DEBUG,"%s: Ignoring EXTERNAL_ONLINE event" |
| 217 | "for display: %d", __FUNCTION__, dpy); |
| 218 | break; |
| 219 | } |
| 220 | { |
| 221 | //Force composition to give up resources like pipes and |
| 222 | //close fb. For example if assertive display is going on, |
| 223 | //fb2 could be open, thus connecting Layer Mixer#0 to |
| 224 | //WriteBack module. If HDMI attempts to open fb1, the driver |
| 225 | //will try to attach Layer Mixer#0 to HDMI INT, which will |
| 226 | //fail, since Layer Mixer#0 is still connected to WriteBack. |
| 227 | //This block will force composition to close fb2 in above |
| 228 | //example. |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 229 | Locker::Autolock _l(ctx->mDrawLock); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 230 | ctx->dpyAttr[dpy].isConfiguring = true; |
| 231 | ctx->proc->invalidate(ctx->proc); |
| 232 | } |
| 233 | //2 cycles for slower content |
| 234 | usleep(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period |
| 235 | * 2 / 1000); |
| 236 | |
| 237 | if(dpy == HWC_DISPLAY_EXTERNAL) { |
Manoj Kumar AVM | fb472b0 | 2014-08-21 15:13:37 -0700 | [diff] [blame^] | 238 | if(isVDConnected(ctx)) { |
| 239 | // Do not initiate WFD teardown if WFD architecture is based |
| 240 | // on VDS mechanism. |
| 241 | // WFD Stack listens to HDMI intent and initiates virtual |
| 242 | // display teardown. |
| 243 | // ToDo: Currently non-WFD Virtual display clients do not |
| 244 | // involve HWC. If there is a change, we need to come up |
| 245 | // with mechanism of how to address non-WFD Virtual display |
| 246 | // clients + HDMI |
| 247 | if(isVDSEnabled(ctx)) { |
| 248 | ctx->mWfdSyncLock.lock(); |
| 249 | ALOGD_IF(HWC_WFDDISPSYNC_LOG, |
| 250 | "%s: Waiting for wfd-teardown to be signalled", |
| 251 | __FUNCTION__); |
| 252 | ctx->mWfdSyncLock.wait(); |
| 253 | ALOGD_IF(HWC_WFDDISPSYNC_LOG, |
| 254 | "%s: Teardown signalled. Completed waiting in" |
| 255 | "uevent thread", __FUNCTION__); |
| 256 | ctx->mWfdSyncLock.unlock(); |
| 257 | } else { |
| 258 | // Triple Display is supported on 8084 target |
| 259 | // WFD can be initiated by Wfd-client or Settings app |
| 260 | // 1. wfd-client use hdmi hotplug mechanism. |
| 261 | // If wfd is connected via wfd-client and if HDMI is |
| 262 | // connected, we have to teardown wfd session. |
| 263 | // (as SF support only one active External display |
| 264 | // at a given time). |
| 265 | // (ToDo: Once wfd-client migrates using virtual |
| 266 | // display apis, second condition is redundant). |
| 267 | // 2. Settings app use virtual display mechanism. |
| 268 | // In this approach, there is no limitation of |
| 269 | // supporting triple display. |
| 270 | if(!(qdutils::MDPVersion::getInstance().is8084() && |
| 271 | !ctx->mVirtualonExtActive)) { |
| 272 | teardownWfd(ctx); |
| 273 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 274 | } |
Amara Venkata Mastan Manoj Kumar | b156a2f | 2013-02-07 16:42:50 -0800 | [diff] [blame] | 275 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 276 | ctx->mExtDisplay->configure(); |
| 277 | } else { |
Saurabh Shah | 188e433 | 2013-07-18 10:33:22 -0700 | [diff] [blame] | 278 | { |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 279 | Locker::Autolock _l(ctx->mDrawLock); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 280 | /* TRUE only when we are on proprietary WFD session */ |
| 281 | ctx->mVirtualonExtActive = true; |
| 282 | char property[PROPERTY_VALUE_MAX]; |
| 283 | if((property_get("persist.sys.wfd.virtual", |
| 284 | property, NULL) > 0) && |
| 285 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 286 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
| 287 | // This means we are on Google's WFD session |
| 288 | ctx->mVirtualonExtActive = false; |
| 289 | } |
Saurabh Shah | 188e433 | 2013-07-18 10:33:22 -0700 | [diff] [blame] | 290 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 291 | ctx->mVirtualDisplay->configure(); |
Arun Kumar K.R | 361da4f | 2012-11-28 10:42:59 -0800 | [diff] [blame] | 292 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 293 | |
Saurabh Shah | b39f815 | 2013-08-22 10:21:44 -0700 | [diff] [blame] | 294 | Locker::Autolock _l(ctx->mDrawLock); |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 295 | setup(ctx, dpy); |
| 296 | ctx->dpyAttr[dpy].isPause = false; |
| 297 | ctx->dpyAttr[dpy].connected = true; |
| 298 | ctx->dpyAttr[dpy].isConfiguring = true; |
| 299 | |
Raj Kamal | 2464cce | 2013-09-06 16:20:12 +0530 | [diff] [blame] | 300 | if(dpy == HWC_DISPLAY_EXTERNAL || |
| 301 | ctx->mVirtualonExtActive) { |
| 302 | /* External display is HDMI or non-hybrid WFD solution */ |
Tatenda Chipeperekwa | 95799fa | 2014-07-22 18:38:16 -0700 | [diff] [blame] | 303 | ALOGE_IF(UEVENT_DEBUG, "%s: Sending EXTERNAL ONLINE" |
Raj Kamal | 2464cce | 2013-09-06 16:20:12 +0530 | [diff] [blame] | 304 | "hotplug event", __FUNCTION__); |
| 305 | ctx->proc->hotplug(ctx->proc,HWC_DISPLAY_EXTERNAL, |
| 306 | EXTERNAL_ONLINE); |
| 307 | } else { |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 308 | /* We wont be getting unblank for VIRTUAL DISPLAY and its |
| 309 | * always guaranteed from WFD stack that CONNECT uevent for |
| 310 | * VIRTUAL DISPLAY will be triggered before creating |
| 311 | * surface for the same. */ |
| 312 | ctx->dpyAttr[HWC_DISPLAY_VIRTUAL].isActive = true; |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 313 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 314 | break; |
| 315 | } |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 316 | case EXTERNAL_PAUSE: |
| 317 | { // pause case |
| 318 | ALOGD("%s Received Pause event",__FUNCTION__); |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 319 | handle_pause(ctx, dpy); |
| 320 | break; |
Amara Venkata Mastan Manoj Kumar | 11a380d | 2013-01-17 09:30:56 -0800 | [diff] [blame] | 321 | } |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 322 | case EXTERNAL_RESUME: |
| 323 | { // resume case |
| 324 | ALOGD("%s Received resume event",__FUNCTION__); |
| 325 | //Treat Resume as Online event |
| 326 | //Since external didnt have any pipes, force primary to give up |
| 327 | //its pipes; we don't allow inter-mixer pipe transfers. |
Arun Kumar K.R | c62935a | 2013-12-03 16:47:47 -0800 | [diff] [blame] | 328 | handle_resume(ctx, dpy); |
Amara Venkata Mastan Manoj Kumar | 5cbac94 | 2013-08-13 19:00:14 -0700 | [diff] [blame] | 329 | break; |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 330 | } |
Jeykumar Sankaran | 27dee26 | 2013-08-01 17:09:54 -0700 | [diff] [blame] | 331 | default: |
| 332 | { |
| 333 | ALOGE("%s: Invalid state to swtich:%d", __FUNCTION__, switch_state); |
| 334 | break; |
| 335 | } |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 336 | } |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | static void *uevent_loop(void *param) |
| 340 | { |
| 341 | int len = 0; |
Naseer Ahmed | ff4f025 | 2012-10-01 13:03:01 -0400 | [diff] [blame] | 342 | static char udata[PAGE_SIZE]; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 343 | hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param); |
Iliyan Malchev | 0f9c397 | 2012-10-11 15:16:15 -0700 | [diff] [blame] | 344 | char thread_name[64] = HWC_UEVENT_THREAD_NAME; |
Naseer Ahmed | ff4f025 | 2012-10-01 13:03:01 -0400 | [diff] [blame] | 345 | prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 346 | setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); |
Sravan Kumar D.V.N | 04ce9ad | 2013-10-23 15:57:57 +0530 | [diff] [blame] | 347 | if(!uevent_init()) { |
| 348 | ALOGE("%s: failed to init uevent ",__FUNCTION__); |
| 349 | return NULL; |
| 350 | } |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 351 | |
| 352 | while(1) { |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 353 | len = uevent_next_event(udata, (int)sizeof(udata) - 2); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 354 | handle_uevent(ctx, udata, len); |
| 355 | } |
| 356 | |
| 357 | return NULL; |
| 358 | } |
| 359 | |
| 360 | void init_uevent_thread(hwc_context_t* ctx) |
| 361 | { |
| 362 | pthread_t uevent_thread; |
Iliyan Malchev | 0f9c397 | 2012-10-11 15:16:15 -0700 | [diff] [blame] | 363 | int ret; |
| 364 | |
| 365 | ALOGI("Initializing UEVENT Thread"); |
| 366 | ret = pthread_create(&uevent_thread, NULL, uevent_loop, (void*) ctx); |
| 367 | if (ret) { |
| 368 | ALOGE("%s: failed to create %s: %s", __FUNCTION__, |
| 369 | HWC_UEVENT_THREAD_NAME, strerror(ret)); |
| 370 | } |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | }; //namespace |