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