blob: 1cdabc4b5edff07c127f309894d44418318d5acb [file] [log] [blame]
Mathias Agopiana350ff92010-08-10 17:14:02 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Mathias Agopian2965b262012-04-08 15:13:32 -070017#define ATRACE_TAG ATRACE_TAG_GRAPHICS
18
Jesse Hall5880cc52012-06-05 23:40:32 -070019// Uncomment this to remove support for HWC_DEVICE_API_VERSION_0_3 and older
Mathias Agopian30bcc612012-08-22 15:39:48 -070020#define HWC_REMOVE_DEPRECATED_VERSIONS 1
Jesse Hall5880cc52012-06-05 23:40:32 -070021
Mathias Agopiana350ff92010-08-10 17:14:02 -070022#include <stdint.h>
Mathias Agopianf1352df2010-08-11 17:31:33 -070023#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070026#include <sys/types.h>
Mathias Agopian6b442672013-07-09 21:24:52 -070027#include <math.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070028
Mathias Agopian33ceeb32013-04-01 16:54:58 -070029#include <utils/CallStack.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070030#include <utils/Errors.h>
Mathias Agopianda27af92012-09-13 18:17:13 -070031#include <utils/misc.h>
Mathias Agopian83727852010-09-23 18:13:21 -070032#include <utils/String8.h>
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070033#include <utils/Thread.h>
Mathias Agopian2965b262012-04-08 15:13:32 -070034#include <utils/Trace.h>
Mathias Agopian22da60c2011-09-09 00:49:11 -070035#include <utils/Vector.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070036
Mathias Agopian921e6ac2012-07-23 23:11:29 -070037#include <ui/GraphicBuffer.h>
38
Mathias Agopiana350ff92010-08-10 17:14:02 -070039#include <hardware/hardware.h>
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070040#include <hardware/hwcomposer.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070041
Jesse Hall1c569c42013-04-05 13:44:52 -070042#include <android/configuration.h>
43
Mathias Agopiana350ff92010-08-10 17:14:02 -070044#include <cutils/log.h>
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -070045#include <cutils/properties.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070046
Mathias Agopiana350ff92010-08-10 17:14:02 -070047#include "HWComposer.h"
Mathias Agopian33ceeb32013-04-01 16:54:58 -070048
49#include "../Layer.h" // needed only for debugging
50#include "../SurfaceFlinger.h"
Mathias Agopiana350ff92010-08-10 17:14:02 -070051
52namespace android {
Jesse Hall5880cc52012-06-05 23:40:32 -070053
Jesse Halle737c112013-05-07 11:58:47 -070054// This is not a real HWC version. It's used for in-development features that
55// haven't been committed to a specific real HWC version.
56#define HWC_DEVICE_API_VERSION_1_EXP HARDWARE_DEVICE_API_VERSION_2(1, 0xFF, HWC_HEADER_VERSION)
57
Jesse Hall72960512013-01-10 16:19:56 -080058#define MIN_HWC_HEADER_VERSION HWC_HEADER_VERSION
Jesse Hall9eb1eb52012-08-29 10:39:38 -070059
Jesse Hallafaf14b2013-03-20 13:42:29 -070060#define NUM_PHYSICAL_DISPLAYS HWC_NUM_DISPLAY_TYPES
61#define VIRTUAL_DISPLAY_ID_BASE HWC_NUM_DISPLAY_TYPES
62
Jesse Hall9eb1eb52012-08-29 10:39:38 -070063static uint32_t hwcApiVersion(const hwc_composer_device_1_t* hwc) {
64 uint32_t hwcVersion = hwc->common.version;
Jesse Hall9eb1eb52012-08-29 10:39:38 -070065 return hwcVersion & HARDWARE_API_VERSION_2_MAJ_MIN_MASK;
66}
67
68static uint32_t hwcHeaderVersion(const hwc_composer_device_1_t* hwc) {
69 uint32_t hwcVersion = hwc->common.version;
Jesse Hall9eb1eb52012-08-29 10:39:38 -070070 return hwcVersion & HARDWARE_API_VERSION_2_HEADER_MASK;
71}
72
73static bool hwcHasApiVersion(const hwc_composer_device_1_t* hwc,
74 uint32_t version) {
75 return hwcApiVersion(hwc) >= (version & HARDWARE_API_VERSION_2_MAJ_MIN_MASK);
Jesse Hallbbd164a2012-08-21 12:05:09 -070076}
77
Mathias Agopiana350ff92010-08-10 17:14:02 -070078// ---------------------------------------------------------------------------
79
Mathias Agopian3e8b8532012-05-13 20:42:01 -070080struct HWComposer::cb_context {
81 struct callbacks : public hwc_procs_t {
82 // these are here to facilitate the transition when adding
83 // new callbacks (an implementation can check for NULL before
84 // calling a new callback).
85 void (*zero[4])(void);
86 };
87 callbacks procs;
88 HWComposer* hwc;
89};
90
91// ---------------------------------------------------------------------------
92
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070093HWComposer::HWComposer(
94 const sp<SurfaceFlinger>& flinger,
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070095 EventHandler& handler)
Mathias Agopianc7d14e22011-08-01 16:32:21 -070096 : mFlinger(flinger),
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070097 mFbDev(0), mHwc(0), mNumDisplays(1),
Mathias Agopian3e8b8532012-05-13 20:42:01 -070098 mCBContext(new cb_context),
Mathias Agopiane60b0682012-08-21 23:34:09 -070099 mEventHandler(handler),
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -0700100 mVSyncCount(0), mDebugForceFakeVSync(false)
Mathias Agopiana350ff92010-08-10 17:14:02 -0700101{
Mathias Agopiane60b0682012-08-21 23:34:09 -0700102 for (size_t i =0 ; i<MAX_DISPLAYS ; i++) {
103 mLists[i] = 0;
104 }
Jesse Hallb685c542012-07-31 14:32:56 -0700105
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -0700106 char value[PROPERTY_VALUE_MAX];
107 property_get("debug.sf.no_hw_vsync", value, "0");
108 mDebugForceFakeVSync = atoi(value);
109
Mathias Agopian028508c2012-07-25 21:12:12 -0700110 bool needVSyncThread = true;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700111
112 // Note: some devices may insist that the FB HAL be opened before HWC.
Jesse Hallef64b752013-03-18 11:28:50 -0700113 int fberr = loadFbHalModule();
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700114 loadHwcModule();
115
Mathias Agopianda27af92012-09-13 18:17:13 -0700116 if (mFbDev && mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
117 // close FB HAL if we don't needed it.
118 // FIXME: this is temporary until we're not forced to open FB HAL
119 // before HWC.
120 framebuffer_close(mFbDev);
121 mFbDev = NULL;
122 }
123
Andy McFaddenbabba182012-09-12 13:14:51 -0700124 // If we have no HWC, or a pre-1.1 HWC, an FB dev is mandatory.
125 if ((!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1))
126 && !mFbDev) {
Jesse Hallef64b752013-03-18 11:28:50 -0700127 ALOGE("ERROR: failed to open framebuffer (%s), aborting",
128 strerror(-fberr));
Andy McFadden43601a22012-09-11 15:15:13 -0700129 abort();
130 }
131
Andy McFadden620685c2012-10-19 12:53:46 -0700132 // these display IDs are always reserved
Jesse Hallafaf14b2013-03-20 13:42:29 -0700133 for (size_t i=0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) {
Andy McFadden620685c2012-10-19 12:53:46 -0700134 mAllocatedDisplayIDs.markBit(i);
135 }
136
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700137 if (mHwc) {
138 ALOGI("Using %s version %u.%u", HWC_HARDWARE_COMPOSER,
139 (hwcApiVersion(mHwc) >> 24) & 0xff,
140 (hwcApiVersion(mHwc) >> 16) & 0xff);
141 if (mHwc->registerProcs) {
142 mCBContext->hwc = this;
143 mCBContext->procs.invalidate = &hook_invalidate;
144 mCBContext->procs.vsync = &hook_vsync;
145 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1))
146 mCBContext->procs.hotplug = &hook_hotplug;
147 else
148 mCBContext->procs.hotplug = NULL;
149 memset(mCBContext->procs.zero, 0, sizeof(mCBContext->procs.zero));
150 mHwc->registerProcs(mHwc, &mCBContext->procs);
Jesse Hall5880cc52012-06-05 23:40:32 -0700151 }
152
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700153 // don't need a vsync thread if we have a hardware composer
154 needVSyncThread = false;
155 // always turn vsync off when we start
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700156 eventControl(HWC_DISPLAY_PRIMARY, HWC_EVENT_VSYNC, 0);
Jesse Hallbbd164a2012-08-21 12:05:09 -0700157
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700158 // the number of displays we actually have depends on the
159 // hw composer version
Jesse Halle737c112013-05-07 11:58:47 -0700160 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_EXP)) {
161 // 1.?? adds support for virtual displays
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700162 mNumDisplays = MAX_DISPLAYS;
163 } else if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
164 // 1.1 adds support for multiple displays
Jesse Hallafaf14b2013-03-20 13:42:29 -0700165 mNumDisplays = NUM_PHYSICAL_DISPLAYS;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700166 } else {
167 mNumDisplays = 1;
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700168 }
Mathias Agopian3a778712012-04-09 14:16:47 -0700169 }
170
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700171 if (mFbDev) {
Jesse Hall1bd20e02012-08-29 10:47:52 -0700172 ALOG_ASSERT(!(mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)),
173 "should only have fbdev if no hwc or hwc is 1.0");
174
Mathias Agopianf4358632012-08-22 17:16:19 -0700175 DisplayData& disp(mDisplayData[HWC_DISPLAY_PRIMARY]);
Mathias Agopian38e623b2012-09-20 19:27:07 -0700176 disp.connected = true;
Jesse Halldb276212012-09-07 11:20:56 -0700177 disp.width = mFbDev->width;
178 disp.height = mFbDev->height;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700179 disp.format = mFbDev->format;
180 disp.xdpi = mFbDev->xdpi;
181 disp.ydpi = mFbDev->ydpi;
Mathias Agopianf4358632012-08-22 17:16:19 -0700182 if (disp.refresh == 0) {
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700183 disp.refresh = nsecs_t(1e9 / mFbDev->fps);
Mathias Agopianf4358632012-08-22 17:16:19 -0700184 ALOGW("getting VSYNC period from fb HAL: %lld", disp.refresh);
Mathias Agopian888c8222012-08-04 21:10:38 -0700185 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700186 if (disp.refresh == 0) {
187 disp.refresh = nsecs_t(1e9 / 60.0);
Jesse Hall1bd20e02012-08-29 10:47:52 -0700188 ALOGW("getting VSYNC period from thin air: %lld",
189 mDisplayData[HWC_DISPLAY_PRIMARY].refresh);
Mathias Agopianf4358632012-08-22 17:16:19 -0700190 }
Jesse Hall1bd20e02012-08-29 10:47:52 -0700191 } else if (mHwc) {
Mathias Agopian1604f772012-09-18 21:54:42 -0700192 // here we're guaranteed to have at least HWC 1.1
Jesse Hallafaf14b2013-03-20 13:42:29 -0700193 for (size_t i =0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) {
Mathias Agopian1604f772012-09-18 21:54:42 -0700194 queryDisplayProperties(i);
195 }
Mathias Agopian888c8222012-08-04 21:10:38 -0700196 }
197
Mathias Agopian3a778712012-04-09 14:16:47 -0700198 if (needVSyncThread) {
199 // we don't have VSYNC support, we need to fake it
200 mVSyncThread = new VSyncThread(*this);
Mathias Agopiana350ff92010-08-10 17:14:02 -0700201 }
202}
203
204HWComposer::~HWComposer() {
Andy McFaddenbabba182012-09-12 13:14:51 -0700205 if (mHwc) {
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700206 eventControl(HWC_DISPLAY_PRIMARY, HWC_EVENT_VSYNC, 0);
Andy McFaddenbabba182012-09-12 13:14:51 -0700207 }
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700208 if (mVSyncThread != NULL) {
209 mVSyncThread->requestExitAndWait();
210 }
Mathias Agopiana350ff92010-08-10 17:14:02 -0700211 if (mHwc) {
Jesse Hall5880cc52012-06-05 23:40:32 -0700212 hwc_close_1(mHwc);
Mathias Agopiana350ff92010-08-10 17:14:02 -0700213 }
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700214 if (mFbDev) {
215 framebuffer_close(mFbDev);
216 }
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700217 delete mCBContext;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700218}
219
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700220// Load and prepare the hardware composer module. Sets mHwc.
221void HWComposer::loadHwcModule()
222{
223 hw_module_t const* module;
224
225 if (hw_get_module(HWC_HARDWARE_MODULE_ID, &module) != 0) {
226 ALOGE("%s module not found", HWC_HARDWARE_MODULE_ID);
227 return;
228 }
229
230 int err = hwc_open_1(module, &mHwc);
231 if (err) {
232 ALOGE("%s device failed to initialize (%s)",
233 HWC_HARDWARE_COMPOSER, strerror(-err));
234 return;
235 }
236
237 if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_0) ||
238 hwcHeaderVersion(mHwc) < MIN_HWC_HEADER_VERSION ||
239 hwcHeaderVersion(mHwc) > HWC_HEADER_VERSION) {
240 ALOGE("%s device version %#x unsupported, will not be used",
241 HWC_HARDWARE_COMPOSER, mHwc->common.version);
242 hwc_close_1(mHwc);
243 mHwc = NULL;
244 return;
245 }
246}
247
248// Load and prepare the FB HAL, which uses the gralloc module. Sets mFbDev.
Jesse Hallef64b752013-03-18 11:28:50 -0700249int HWComposer::loadFbHalModule()
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700250{
251 hw_module_t const* module;
252
Jesse Hallef64b752013-03-18 11:28:50 -0700253 int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
254 if (err != 0) {
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700255 ALOGE("%s module not found", GRALLOC_HARDWARE_MODULE_ID);
Jesse Hallef64b752013-03-18 11:28:50 -0700256 return err;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700257 }
258
Jesse Hallef64b752013-03-18 11:28:50 -0700259 return framebuffer_open(module, &mFbDev);
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700260}
261
Mathias Agopiana350ff92010-08-10 17:14:02 -0700262status_t HWComposer::initCheck() const {
263 return mHwc ? NO_ERROR : NO_INIT;
264}
265
Jesse Hallbbd164a2012-08-21 12:05:09 -0700266void HWComposer::hook_invalidate(const struct hwc_procs* procs) {
267 cb_context* ctx = reinterpret_cast<cb_context*>(
268 const_cast<hwc_procs_t*>(procs));
269 ctx->hwc->invalidate();
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700270}
271
Jesse Hall1bd20e02012-08-29 10:47:52 -0700272void HWComposer::hook_vsync(const struct hwc_procs* procs, int disp,
Jesse Hallbbd164a2012-08-21 12:05:09 -0700273 int64_t timestamp) {
274 cb_context* ctx = reinterpret_cast<cb_context*>(
275 const_cast<hwc_procs_t*>(procs));
Jesse Hall1bd20e02012-08-29 10:47:52 -0700276 ctx->hwc->vsync(disp, timestamp);
277}
278
279void HWComposer::hook_hotplug(const struct hwc_procs* procs, int disp,
280 int connected) {
281 cb_context* ctx = reinterpret_cast<cb_context*>(
282 const_cast<hwc_procs_t*>(procs));
283 ctx->hwc->hotplug(disp, connected);
Mathias Agopian31d28432012-04-03 16:31:39 -0700284}
285
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700286void HWComposer::invalidate() {
Mathias Agopiane2c2f922011-10-05 15:00:22 -0700287 mFlinger->repaintEverything();
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700288}
289
Jesse Hall1bd20e02012-08-29 10:47:52 -0700290void HWComposer::vsync(int disp, int64_t timestamp) {
Mathias Agopian2965b262012-04-08 15:13:32 -0700291 ATRACE_INT("VSYNC", ++mVSyncCount&1);
Jesse Hall1bd20e02012-08-29 10:47:52 -0700292 mEventHandler.onVSyncReceived(disp, timestamp);
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700293 Mutex::Autolock _l(mLock);
294 mLastHwVSync = timestamp;
295}
296
Jesse Hall1bd20e02012-08-29 10:47:52 -0700297void HWComposer::hotplug(int disp, int connected) {
Jesse Hallafaf14b2013-03-20 13:42:29 -0700298 if (disp == HWC_DISPLAY_PRIMARY || disp >= VIRTUAL_DISPLAY_ID_BASE) {
Jesse Hall1bd20e02012-08-29 10:47:52 -0700299 ALOGE("hotplug event received for invalid display: disp=%d connected=%d",
300 disp, connected);
301 return;
302 }
Mathias Agopianf5a33922012-09-19 18:16:22 -0700303 queryDisplayProperties(disp);
Mathias Agopian148994e2012-09-19 17:31:36 -0700304 mEventHandler.onHotplugReceived(disp, bool(connected));
Jesse Hall1bd20e02012-08-29 10:47:52 -0700305}
306
Jesse Hall1c569c42013-04-05 13:44:52 -0700307static float getDefaultDensity(uint32_t height) {
308 if (height >= 1080) return ACONFIGURATION_DENSITY_XHIGH;
309 else return ACONFIGURATION_DENSITY_TV;
310}
311
Jesse Hall1bd20e02012-08-29 10:47:52 -0700312static const uint32_t DISPLAY_ATTRIBUTES[] = {
313 HWC_DISPLAY_VSYNC_PERIOD,
Jesse Halldb276212012-09-07 11:20:56 -0700314 HWC_DISPLAY_WIDTH,
315 HWC_DISPLAY_HEIGHT,
Jesse Hall1bd20e02012-08-29 10:47:52 -0700316 HWC_DISPLAY_DPI_X,
317 HWC_DISPLAY_DPI_Y,
318 HWC_DISPLAY_NO_ATTRIBUTE,
319};
320#define NUM_DISPLAY_ATTRIBUTES (sizeof(DISPLAY_ATTRIBUTES) / sizeof(DISPLAY_ATTRIBUTES)[0])
321
Mathias Agopian1604f772012-09-18 21:54:42 -0700322status_t HWComposer::queryDisplayProperties(int disp) {
323
Mathias Agopianda27af92012-09-13 18:17:13 -0700324 LOG_ALWAYS_FATAL_IF(!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1));
Jesse Hall1bd20e02012-08-29 10:47:52 -0700325
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700326 // use zero as default value for unspecified attributes
Jesse Hall1bd20e02012-08-29 10:47:52 -0700327 int32_t values[NUM_DISPLAY_ATTRIBUTES - 1];
328 memset(values, 0, sizeof(values));
329
330 uint32_t config;
331 size_t numConfigs = 1;
332 status_t err = mHwc->getDisplayConfigs(mHwc, disp, &config, &numConfigs);
Mathias Agopian1604f772012-09-18 21:54:42 -0700333 if (err != NO_ERROR) {
334 // this can happen if an unpluggable display is not connected
Mathias Agopianf5a33922012-09-19 18:16:22 -0700335 mDisplayData[disp].connected = false;
Mathias Agopian1604f772012-09-18 21:54:42 -0700336 return err;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700337 }
338
Mathias Agopian9e2463e2012-09-21 18:26:16 -0700339 err = mHwc->getDisplayAttributes(mHwc, disp, config, DISPLAY_ATTRIBUTES, values);
340 if (err != NO_ERROR) {
341 // we can't get this display's info. turn it off.
342 mDisplayData[disp].connected = false;
343 return err;
344 }
Mathias Agopian1604f772012-09-18 21:54:42 -0700345
Jesse Hall1bd20e02012-08-29 10:47:52 -0700346 int32_t w = 0, h = 0;
347 for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) {
348 switch (DISPLAY_ATTRIBUTES[i]) {
349 case HWC_DISPLAY_VSYNC_PERIOD:
350 mDisplayData[disp].refresh = nsecs_t(values[i]);
351 break;
Jesse Halldb276212012-09-07 11:20:56 -0700352 case HWC_DISPLAY_WIDTH:
353 mDisplayData[disp].width = values[i];
Jesse Hall1bd20e02012-08-29 10:47:52 -0700354 break;
Jesse Halldb276212012-09-07 11:20:56 -0700355 case HWC_DISPLAY_HEIGHT:
356 mDisplayData[disp].height = values[i];
Jesse Hall1bd20e02012-08-29 10:47:52 -0700357 break;
358 case HWC_DISPLAY_DPI_X:
359 mDisplayData[disp].xdpi = values[i] / 1000.0f;
360 break;
361 case HWC_DISPLAY_DPI_Y:
362 mDisplayData[disp].ydpi = values[i] / 1000.0f;
363 break;
364 default:
Mathias Agopianda27af92012-09-13 18:17:13 -0700365 ALOG_ASSERT(false, "unknown display attribute[%d] %#x",
366 i, DISPLAY_ATTRIBUTES[i]);
Jesse Hall1bd20e02012-08-29 10:47:52 -0700367 break;
368 }
369 }
370
Mathias Agopianf5a33922012-09-19 18:16:22 -0700371 // FIXME: what should we set the format to?
372 mDisplayData[disp].format = HAL_PIXEL_FORMAT_RGBA_8888;
373 mDisplayData[disp].connected = true;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700374 if (mDisplayData[disp].xdpi == 0.0f || mDisplayData[disp].ydpi == 0.0f) {
Jesse Hall1c569c42013-04-05 13:44:52 -0700375 float dpi = getDefaultDensity(h);
376 mDisplayData[disp].xdpi = dpi;
377 mDisplayData[disp].ydpi = dpi;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700378 }
Mathias Agopian1604f772012-09-18 21:54:42 -0700379 return NO_ERROR;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700380}
381
Jesse Hall1c569c42013-04-05 13:44:52 -0700382status_t HWComposer::setVirtualDisplayProperties(int32_t id,
383 uint32_t w, uint32_t h, uint32_t format) {
384 if (id < VIRTUAL_DISPLAY_ID_BASE || id >= int32_t(mNumDisplays) ||
385 !mAllocatedDisplayIDs.hasBit(id)) {
386 return BAD_INDEX;
387 }
388 mDisplayData[id].width = w;
389 mDisplayData[id].height = h;
390 mDisplayData[id].format = format;
391 mDisplayData[id].xdpi = mDisplayData[id].ydpi = getDefaultDensity(h);
392 return NO_ERROR;
393}
394
Mathias Agopiane60b0682012-08-21 23:34:09 -0700395int32_t HWComposer::allocateDisplayId() {
Mathias Agopianf4358632012-08-22 17:16:19 -0700396 if (mAllocatedDisplayIDs.count() >= mNumDisplays) {
Mathias Agopiane60b0682012-08-21 23:34:09 -0700397 return NO_MEMORY;
398 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700399 int32_t id = mAllocatedDisplayIDs.firstUnmarkedBit();
400 mAllocatedDisplayIDs.markBit(id);
Jesse Hall7adb0f82013-03-06 16:13:49 -0800401 mDisplayData[id].connected = true;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700402 return id;
403}
404
405status_t HWComposer::freeDisplayId(int32_t id) {
Jesse Hallafaf14b2013-03-20 13:42:29 -0700406 if (id < NUM_PHYSICAL_DISPLAYS) {
Mathias Agopianf4358632012-08-22 17:16:19 -0700407 // cannot free the reserved IDs
Mathias Agopiane60b0682012-08-21 23:34:09 -0700408 return BAD_VALUE;
409 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700410 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) {
Mathias Agopiane60b0682012-08-21 23:34:09 -0700411 return BAD_INDEX;
412 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700413 mAllocatedDisplayIDs.clearBit(id);
Jesse Hall7adb0f82013-03-06 16:13:49 -0800414 mDisplayData[id].connected = false;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700415 return NO_ERROR;
416}
417
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700418nsecs_t HWComposer::getRefreshPeriod(int disp) const {
419 return mDisplayData[disp].refresh;
Mathias Agopian888c8222012-08-04 21:10:38 -0700420}
421
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700422nsecs_t HWComposer::getRefreshTimestamp(int disp) const {
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700423 // this returns the last refresh timestamp.
424 // if the last one is not available, we estimate it based on
425 // the refresh period and whatever closest timestamp we have.
426 Mutex::Autolock _l(mLock);
427 nsecs_t now = systemTime(CLOCK_MONOTONIC);
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700428 return now - ((now - mLastHwVSync) % mDisplayData[disp].refresh);
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700429}
430
Jamie Gennis2ec3e072012-11-11 16:24:33 -0800431sp<Fence> HWComposer::getDisplayFence(int disp) const {
432 return mDisplayData[disp].lastDisplayFence;
433}
434
Jesse Halldb276212012-09-07 11:20:56 -0700435uint32_t HWComposer::getWidth(int disp) const {
436 return mDisplayData[disp].width;
Mathias Agopian8b736f12012-08-13 17:54:26 -0700437}
438
Jesse Halldb276212012-09-07 11:20:56 -0700439uint32_t HWComposer::getHeight(int disp) const {
440 return mDisplayData[disp].height;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700441}
442
443uint32_t HWComposer::getFormat(int disp) const {
444 return mDisplayData[disp].format;
445}
446
447float HWComposer::getDpiX(int disp) const {
448 return mDisplayData[disp].xdpi;
449}
450
451float HWComposer::getDpiY(int disp) const {
452 return mDisplayData[disp].ydpi;
Mathias Agopian8b736f12012-08-13 17:54:26 -0700453}
454
Mathias Agopianf5a33922012-09-19 18:16:22 -0700455bool HWComposer::isConnected(int disp) const {
456 return mDisplayData[disp].connected;
457}
458
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700459void HWComposer::eventControl(int disp, int event, int enabled) {
460 if (uint32_t(disp)>31 || !mAllocatedDisplayIDs.hasBit(disp)) {
Andy McFadden620685c2012-10-19 12:53:46 -0700461 ALOGD("eventControl ignoring event %d on unallocated disp %d (en=%d)",
462 event, disp, enabled);
463 return;
464 }
465 if (event != EVENT_VSYNC) {
466 ALOGW("eventControl got unexpected event %d (disp=%d en=%d)",
467 event, disp, enabled);
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700468 return;
469 }
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700470 status_t err = NO_ERROR;
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700471 if (mHwc && !mDebugForceFakeVSync) {
472 // NOTE: we use our own internal lock here because we have to call
473 // into the HWC with the lock held, and we want to make sure
474 // that even if HWC blocks (which it shouldn't), it won't
475 // affect other threads.
476 Mutex::Autolock _l(mEventControlLock);
477 const int32_t eventBit = 1UL << event;
478 const int32_t newValue = enabled ? eventBit : 0;
479 const int32_t oldValue = mDisplayData[disp].events & eventBit;
480 if (newValue != oldValue) {
481 ATRACE_CALL();
482 err = mHwc->eventControl(mHwc, disp, event, enabled);
483 if (!err) {
484 int32_t& events(mDisplayData[disp].events);
485 events = (events & ~eventBit) | newValue;
486 }
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -0700487 }
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700488 // error here should not happen -- not sure what we should
489 // do if it does.
490 ALOGE_IF(err, "eventControl(%d, %d) failed %s",
491 event, enabled, strerror(-err));
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700492 }
Mathias Agopian3a778712012-04-09 14:16:47 -0700493
494 if (err == NO_ERROR && mVSyncThread != NULL) {
495 mVSyncThread->setEnabled(enabled);
496 }
Mathias Agopian31d28432012-04-03 16:31:39 -0700497}
498
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700499status_t HWComposer::createWorkList(int32_t id, size_t numLayers) {
Mathias Agopianf4358632012-08-22 17:16:19 -0700500 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) {
Mathias Agopian1e260872012-08-08 18:35:12 -0700501 return BAD_INDEX;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700502 }
Mathias Agopian1e260872012-08-08 18:35:12 -0700503
Mathias Agopian45721772010-08-12 15:03:26 -0700504 if (mHwc) {
Mathias Agopianf4358632012-08-22 17:16:19 -0700505 DisplayData& disp(mDisplayData[id]);
Mathias Agopianda27af92012-09-13 18:17:13 -0700506 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
507 // we need space for the HWC_FRAMEBUFFER_TARGET
508 numLayers++;
509 }
Andy McFadden13a082e2012-08-24 10:16:42 -0700510 if (disp.capacity < numLayers || disp.list == NULL) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700511 size_t size = sizeof(hwc_display_contents_1_t)
Mathias Agopianf4358632012-08-22 17:16:19 -0700512 + numLayers * sizeof(hwc_layer_1_t);
513 free(disp.list);
514 disp.list = (hwc_display_contents_1_t*)malloc(size);
515 disp.capacity = numLayers;
Mathias Agopian45721772010-08-12 15:03:26 -0700516 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700517 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
518 disp.framebufferTarget = &disp.list->hwLayers[numLayers - 1];
519 memset(disp.framebufferTarget, 0, sizeof(hwc_layer_1_t));
Andy McFadden8f06a8c2013-01-11 10:24:34 -0800520 const hwc_rect_t r = { 0, 0, (int) disp.width, (int) disp.height };
Mathias Agopianda27af92012-09-13 18:17:13 -0700521 disp.framebufferTarget->compositionType = HWC_FRAMEBUFFER_TARGET;
522 disp.framebufferTarget->hints = 0;
523 disp.framebufferTarget->flags = 0;
524 disp.framebufferTarget->handle = disp.fbTargetHandle;
525 disp.framebufferTarget->transform = 0;
526 disp.framebufferTarget->blending = HWC_BLENDING_PREMULT;
527 disp.framebufferTarget->sourceCrop = r;
528 disp.framebufferTarget->displayFrame = r;
529 disp.framebufferTarget->visibleRegionScreen.numRects = 1;
530 disp.framebufferTarget->visibleRegionScreen.rects =
531 &disp.framebufferTarget->displayFrame;
532 disp.framebufferTarget->acquireFenceFd = -1;
533 disp.framebufferTarget->releaseFenceFd = -1;
Mathias Agopian70a6e882013-03-21 16:25:12 -0700534 disp.framebufferTarget->planeAlpha = 0xFF;
Mathias Agopianda27af92012-09-13 18:17:13 -0700535 }
Jesse Halldb276212012-09-07 11:20:56 -0700536 disp.list->retireFenceFd = -1;
Mathias Agopianf4358632012-08-22 17:16:19 -0700537 disp.list->flags = HWC_GEOMETRY_CHANGED;
538 disp.list->numHwLayers = numLayers;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700539 }
540 return NO_ERROR;
541}
542
Mathias Agopianda27af92012-09-13 18:17:13 -0700543status_t HWComposer::setFramebufferTarget(int32_t id,
544 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buf) {
545 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) {
546 return BAD_INDEX;
547 }
548 DisplayData& disp(mDisplayData[id]);
549 if (!disp.framebufferTarget) {
550 // this should never happen, but apparently eglCreateWindowSurface()
Mathias Agopiane3c697f2013-02-14 17:11:02 -0800551 // triggers a Surface::queueBuffer() on some
Mathias Agopianda27af92012-09-13 18:17:13 -0700552 // devices (!?) -- log and ignore.
553 ALOGE("HWComposer: framebufferTarget is null");
Mathias Agopianda27af92012-09-13 18:17:13 -0700554 return NO_ERROR;
555 }
556
557 int acquireFenceFd = -1;
Jamie Gennis1df8c342012-12-20 14:05:45 -0800558 if (acquireFence->isValid()) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700559 acquireFenceFd = acquireFence->dup();
560 }
561
562 // ALOGD("fbPost: handle=%p, fence=%d", buf->handle, acquireFenceFd);
563 disp.fbTargetHandle = buf->handle;
564 disp.framebufferTarget->handle = disp.fbTargetHandle;
565 disp.framebufferTarget->acquireFenceFd = acquireFenceFd;
566 return NO_ERROR;
567}
568
Mathias Agopiane60b0682012-08-21 23:34:09 -0700569status_t HWComposer::prepare() {
Mathias Agopianf4358632012-08-22 17:16:19 -0700570 for (size_t i=0 ; i<mNumDisplays ; i++) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700571 DisplayData& disp(mDisplayData[i]);
572 if (disp.framebufferTarget) {
573 // make sure to reset the type to HWC_FRAMEBUFFER_TARGET
574 // DO NOT reset the handle field to NULL, because it's possible
575 // that we have nothing to redraw (eg: eglSwapBuffers() not called)
576 // in which case, we should continue to use the same buffer.
Andy McFadden27ec5732012-10-02 19:04:45 -0700577 LOG_FATAL_IF(disp.list == NULL);
Mathias Agopianda27af92012-09-13 18:17:13 -0700578 disp.framebufferTarget->compositionType = HWC_FRAMEBUFFER_TARGET;
579 }
Andy McFadden27ec5732012-10-02 19:04:45 -0700580 if (!disp.connected && disp.list != NULL) {
581 ALOGW("WARNING: disp %d: connected, non-null list, layers=%d",
582 i, disp.list->numHwLayers);
583 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700584 mLists[i] = disp.list;
Mathias Agopianf4358632012-08-22 17:16:19 -0700585 if (mLists[i]) {
Jesse Halle737c112013-05-07 11:58:47 -0700586 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_EXP)) {
Jesse Halldb276212012-09-07 11:20:56 -0700587 mLists[i]->outbuf = NULL;
588 mLists[i]->outbufAcquireFenceFd = -1;
589 } else if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
590 // garbage data to catch improper use
591 mLists[i]->dpy = (hwc_display_t)0xDEADBEEF;
592 mLists[i]->sur = (hwc_surface_t)0xDEADBEEF;
593 } else {
594 mLists[i]->dpy = EGL_NO_DISPLAY;
595 mLists[i]->sur = EGL_NO_SURFACE;
596 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700597 }
598 }
Jesse Halldb276212012-09-07 11:20:56 -0700599
Mathias Agopianf4358632012-08-22 17:16:19 -0700600 int err = mHwc->prepare(mHwc, mNumDisplays, mLists);
Mathias Agopianda27af92012-09-13 18:17:13 -0700601 ALOGE_IF(err, "HWComposer: prepare failed (%s)", strerror(-err));
602
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700603 if (err == NO_ERROR) {
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700604 // here we're just making sure that "skip" layers are set
605 // to HWC_FRAMEBUFFER and we're also counting how many layers
606 // we have of each type.
Mathias Agopianf4358632012-08-22 17:16:19 -0700607 for (size_t i=0 ; i<mNumDisplays ; i++) {
608 DisplayData& disp(mDisplayData[i]);
609 disp.hasFbComp = false;
610 disp.hasOvComp = false;
611 if (disp.list) {
612 for (size_t i=0 ; i<disp.list->numHwLayers ; i++) {
613 hwc_layer_1_t& l = disp.list->hwLayers[i];
Mathias Agopianda27af92012-09-13 18:17:13 -0700614
615 //ALOGD("prepare: %d, type=%d, handle=%p",
616 // i, l.compositionType, l.handle);
617
Mathias Agopianf4358632012-08-22 17:16:19 -0700618 if (l.flags & HWC_SKIP_LAYER) {
619 l.compositionType = HWC_FRAMEBUFFER;
620 }
621 if (l.compositionType == HWC_FRAMEBUFFER) {
622 disp.hasFbComp = true;
623 }
624 if (l.compositionType == HWC_OVERLAY) {
625 disp.hasOvComp = true;
626 }
627 }
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700628 }
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700629 }
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700630 }
Mathias Agopiana350ff92010-08-10 17:14:02 -0700631 return (status_t)err;
632}
633
Mathias Agopiane60b0682012-08-21 23:34:09 -0700634bool HWComposer::hasHwcComposition(int32_t id) const {
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700635 if (!mHwc || uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
Mathias Agopiane60b0682012-08-21 23:34:09 -0700636 return false;
637 return mDisplayData[id].hasOvComp;
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700638}
639
Mathias Agopiane60b0682012-08-21 23:34:09 -0700640bool HWComposer::hasGlesComposition(int32_t id) const {
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700641 if (!mHwc || uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
642 return true;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700643 return mDisplayData[id].hasFbComp;
644}
645
Jesse Hall13f01cb2013-03-20 11:37:21 -0700646sp<Fence> HWComposer::getAndResetReleaseFence(int32_t id) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700647 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
Jesse Hall13f01cb2013-03-20 11:37:21 -0700648 return Fence::NO_FENCE;
Mathias Agopianda27af92012-09-13 18:17:13 -0700649
650 int fd = INVALID_OPERATION;
651 if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
652 const DisplayData& disp(mDisplayData[id]);
653 if (disp.framebufferTarget) {
654 fd = disp.framebufferTarget->releaseFenceFd;
Jamie Gennisd30b36d2012-09-30 20:02:03 -0700655 disp.framebufferTarget->acquireFenceFd = -1;
Mathias Agopianda27af92012-09-13 18:17:13 -0700656 disp.framebufferTarget->releaseFenceFd = -1;
657 }
658 }
Jesse Hall13f01cb2013-03-20 11:37:21 -0700659 return fd >= 0 ? new Fence(fd) : Fence::NO_FENCE;
Mathias Agopianda27af92012-09-13 18:17:13 -0700660}
661
Mathias Agopian30bcc612012-08-22 15:39:48 -0700662status_t HWComposer::commit() {
Mathias Agopian86303202012-07-24 22:46:10 -0700663 int err = NO_ERROR;
664 if (mHwc) {
Jesse Hall9eb1eb52012-08-29 10:39:38 -0700665 if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
Mathias Agopian30bcc612012-08-22 15:39:48 -0700666 // On version 1.0, the OpenGL ES target surface is communicated
Mathias Agopianf4358632012-08-22 17:16:19 -0700667 // by the (dpy, sur) fields and we are guaranteed to have only
668 // a single display.
Mathias Agopian30bcc612012-08-22 15:39:48 -0700669 mLists[0]->dpy = eglGetCurrentDisplay();
670 mLists[0]->sur = eglGetCurrentSurface(EGL_DRAW);
Mathias Agopian86303202012-07-24 22:46:10 -0700671 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700672
Jesse Hallafaf14b2013-03-20 13:42:29 -0700673 for (size_t i=VIRTUAL_DISPLAY_ID_BASE; i<mNumDisplays; i++) {
Jesse Hall80e0a392013-03-15 12:32:10 -0700674 DisplayData& disp(mDisplayData[i]);
Jesse Hall851cfe82013-03-20 13:44:00 -0700675 if (disp.outbufHandle) {
676 mLists[i]->outbuf = disp.outbufHandle;
Jesse Hall80e0a392013-03-15 12:32:10 -0700677 mLists[i]->outbufAcquireFenceFd =
Jesse Hall851cfe82013-03-20 13:44:00 -0700678 disp.outbufAcquireFence->dup();
Jesse Hall80e0a392013-03-15 12:32:10 -0700679 }
680 }
681
Mathias Agopian30bcc612012-08-22 15:39:48 -0700682 err = mHwc->set(mHwc, mNumDisplays, mLists);
Mathias Agopianf4358632012-08-22 17:16:19 -0700683
684 for (size_t i=0 ; i<mNumDisplays ; i++) {
685 DisplayData& disp(mDisplayData[i]);
Jamie Gennis2ec3e072012-11-11 16:24:33 -0800686 disp.lastDisplayFence = disp.lastRetireFence;
Jamie Gennis1df8c342012-12-20 14:05:45 -0800687 disp.lastRetireFence = Fence::NO_FENCE;
Mathias Agopianf4358632012-08-22 17:16:19 -0700688 if (disp.list) {
Jesse Halldb276212012-09-07 11:20:56 -0700689 if (disp.list->retireFenceFd != -1) {
Jamie Gennis2ec3e072012-11-11 16:24:33 -0800690 disp.lastRetireFence = new Fence(disp.list->retireFenceFd);
Jesse Halldb276212012-09-07 11:20:56 -0700691 disp.list->retireFenceFd = -1;
Mathias Agopianf4358632012-08-22 17:16:19 -0700692 }
693 disp.list->flags &= ~HWC_GEOMETRY_CHANGED;
694 }
Mathias Agopian30bcc612012-08-22 15:39:48 -0700695 }
Mathias Agopian58959342010-10-07 14:57:04 -0700696 }
Mathias Agopiana350ff92010-08-10 17:14:02 -0700697 return (status_t)err;
698}
699
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700700status_t HWComposer::release(int disp) {
Jesse Hallafaf14b2013-03-20 13:42:29 -0700701 LOG_FATAL_IF(disp >= VIRTUAL_DISPLAY_ID_BASE);
Mathias Agopian7ee4cd52011-09-02 12:22:39 -0700702 if (mHwc) {
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700703 eventControl(disp, HWC_EVENT_VSYNC, 0);
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700704 return (status_t)mHwc->blank(mHwc, disp, 1);
Mathias Agopian7ee4cd52011-09-02 12:22:39 -0700705 }
706 return NO_ERROR;
707}
708
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700709status_t HWComposer::acquire(int disp) {
Jesse Hallafaf14b2013-03-20 13:42:29 -0700710 LOG_FATAL_IF(disp >= VIRTUAL_DISPLAY_ID_BASE);
Colin Cross10fbdb62012-07-12 17:56:34 -0700711 if (mHwc) {
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700712 return (status_t)mHwc->blank(mHwc, disp, 0);
Colin Cross10fbdb62012-07-12 17:56:34 -0700713 }
Colin Cross10fbdb62012-07-12 17:56:34 -0700714 return NO_ERROR;
715}
716
Andy McFadden27ec5732012-10-02 19:04:45 -0700717void HWComposer::disconnectDisplay(int disp) {
Andy McFadden5a8f9012012-10-04 19:09:45 -0700718 LOG_ALWAYS_FATAL_IF(disp < 0 || disp == HWC_DISPLAY_PRIMARY);
Andy McFadden27ec5732012-10-02 19:04:45 -0700719 DisplayData& dd(mDisplayData[disp]);
Jesse Hall851cfe82013-03-20 13:44:00 -0700720 free(dd.list);
721 dd.list = NULL;
722 dd.framebufferTarget = NULL; // points into dd.list
723 dd.fbTargetHandle = NULL;
724 dd.outbufHandle = NULL;
725 dd.lastRetireFence = Fence::NO_FENCE;
726 dd.lastDisplayFence = Fence::NO_FENCE;
727 dd.outbufAcquireFence = Fence::NO_FENCE;
Andy McFadden27ec5732012-10-02 19:04:45 -0700728}
729
Mathias Agopiancde87a32012-09-13 14:09:01 -0700730int HWComposer::getVisualID() const {
Jesse Halld3d35f12012-09-18 11:39:40 -0700731 if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700732 // FIXME: temporary hack until HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
733 // is supported by the implementation. we can only be in this case
734 // if we have HWC 1.1
735 return HAL_PIXEL_FORMAT_RGBA_8888;
736 //return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700737 } else {
Mathias Agopiancde87a32012-09-13 14:09:01 -0700738 return mFbDev->format;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700739 }
740}
741
Mathias Agopianda27af92012-09-13 18:17:13 -0700742bool HWComposer::supportsFramebufferTarget() const {
743 return (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1));
744}
745
746int HWComposer::fbPost(int32_t id,
747 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buffer) {
Jesse Halld3d35f12012-09-18 11:39:40 -0700748 if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700749 return setFramebufferTarget(id, acquireFence, buffer);
750 } else {
Mathias Agopianea74d3b2013-05-16 18:03:22 -0700751 acquireFence->waitForever("HWComposer::fbPost");
Mathias Agopianda27af92012-09-13 18:17:13 -0700752 return mFbDev->post(mFbDev, buffer->handle);
Mathias Agopiancde87a32012-09-13 14:09:01 -0700753 }
Mathias Agopiancde87a32012-09-13 14:09:01 -0700754}
755
756int HWComposer::fbCompositionComplete() {
Jesse Halld3d35f12012-09-18 11:39:40 -0700757 if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1))
Mathias Agopianda27af92012-09-13 18:17:13 -0700758 return NO_ERROR;
759
760 if (mFbDev->compositionComplete) {
761 return mFbDev->compositionComplete(mFbDev);
762 } else {
763 return INVALID_OPERATION;
Mathias Agopiancde87a32012-09-13 14:09:01 -0700764 }
Mathias Agopiancde87a32012-09-13 14:09:01 -0700765}
766
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700767void HWComposer::fbDump(String8& result) {
Mathias Agopiancde87a32012-09-13 14:09:01 -0700768 if (mFbDev && mFbDev->common.version >= 1 && mFbDev->dump) {
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700769 const size_t SIZE = 4096;
770 char buffer[SIZE];
771 mFbDev->dump(mFbDev, buffer, SIZE);
772 result.append(buffer);
773 }
774}
775
Jesse Hall851cfe82013-03-20 13:44:00 -0700776status_t HWComposer::setOutputBuffer(int32_t id, const sp<Fence>& acquireFence,
777 const sp<GraphicBuffer>& buf) {
778 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
779 return BAD_INDEX;
780 if (id < VIRTUAL_DISPLAY_ID_BASE)
781 return INVALID_OPERATION;
782
783 DisplayData& disp(mDisplayData[id]);
784 disp.outbufHandle = buf->handle;
785 disp.outbufAcquireFence = acquireFence;
786 return NO_ERROR;
787}
788
789sp<Fence> HWComposer::getLastRetireFence(int32_t id) {
790 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
791 return Fence::NO_FENCE;
792 return mDisplayData[id].lastRetireFence;
793}
794
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700795/*
796 * Helper template to implement a concrete HWCLayer
797 * This holds the pointer to the concrete hwc layer type
798 * and implements the "iterable" side of HWCLayer.
799 */
800template<typename CONCRETE, typename HWCTYPE>
801class Iterable : public HWComposer::HWCLayer {
802protected:
803 HWCTYPE* const mLayerList;
804 HWCTYPE* mCurrentLayer;
805 Iterable(HWCTYPE* layer) : mLayerList(layer), mCurrentLayer(layer) { }
806 inline HWCTYPE const * getLayer() const { return mCurrentLayer; }
807 inline HWCTYPE* getLayer() { return mCurrentLayer; }
808 virtual ~Iterable() { }
809private:
810 // returns a copy of ourselves
811 virtual HWComposer::HWCLayer* dup() {
812 return new CONCRETE( static_cast<const CONCRETE&>(*this) );
813 }
814 virtual status_t setLayer(size_t index) {
815 mCurrentLayer = &mLayerList[index];
816 return NO_ERROR;
817 }
818};
819
Jesse Hall5880cc52012-06-05 23:40:32 -0700820/*
821 * Concrete implementation of HWCLayer for HWC_DEVICE_API_VERSION_1_0.
822 * This implements the HWCLayer side of HWCIterableLayer.
823 */
824class HWCLayerVersion1 : public Iterable<HWCLayerVersion1, hwc_layer_1_t> {
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800825 struct hwc_composer_device_1* mHwc;
Jesse Hall5880cc52012-06-05 23:40:32 -0700826public:
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800827 HWCLayerVersion1(struct hwc_composer_device_1* hwc, hwc_layer_1_t* layer)
828 : Iterable<HWCLayerVersion1, hwc_layer_1_t>(layer), mHwc(hwc) { }
Jesse Hall5880cc52012-06-05 23:40:32 -0700829
830 virtual int32_t getCompositionType() const {
831 return getLayer()->compositionType;
832 }
833 virtual uint32_t getHints() const {
834 return getLayer()->hints;
835 }
Jesse Hall13f01cb2013-03-20 11:37:21 -0700836 virtual sp<Fence> getAndResetReleaseFence() {
Jesse Hallef194142012-06-14 14:45:17 -0700837 int fd = getLayer()->releaseFenceFd;
838 getLayer()->releaseFenceFd = -1;
Jesse Hall13f01cb2013-03-20 11:37:21 -0700839 return fd >= 0 ? new Fence(fd) : Fence::NO_FENCE;
Jesse Hallef194142012-06-14 14:45:17 -0700840 }
Jesse Halldc5b4852012-06-29 15:21:18 -0700841 virtual void setAcquireFenceFd(int fenceFd) {
842 getLayer()->acquireFenceFd = fenceFd;
843 }
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800844 virtual void setPerFrameDefaultState() {
845 //getLayer()->compositionType = HWC_FRAMEBUFFER;
846 }
847 virtual void setPlaneAlpha(uint8_t alpha) {
848 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_2)) {
849 getLayer()->planeAlpha = alpha;
850 } else {
Mathias Agopian5fe58b82013-02-07 16:22:50 -0800851 if (alpha < 0xFF) {
852 getLayer()->flags |= HWC_SKIP_LAYER;
853 }
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800854 }
855 }
Jesse Hall5880cc52012-06-05 23:40:32 -0700856 virtual void setDefaultState() {
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800857 hwc_layer_1_t* const l = getLayer();
858 l->compositionType = HWC_FRAMEBUFFER;
859 l->hints = 0;
860 l->flags = HWC_SKIP_LAYER;
861 l->handle = 0;
862 l->transform = 0;
863 l->blending = HWC_BLENDING_NONE;
864 l->visibleRegionScreen.numRects = 0;
865 l->visibleRegionScreen.rects = NULL;
866 l->acquireFenceFd = -1;
867 l->releaseFenceFd = -1;
868 l->planeAlpha = 0xFF;
Jesse Hall5880cc52012-06-05 23:40:32 -0700869 }
870 virtual void setSkip(bool skip) {
871 if (skip) {
872 getLayer()->flags |= HWC_SKIP_LAYER;
873 } else {
874 getLayer()->flags &= ~HWC_SKIP_LAYER;
875 }
876 }
877 virtual void setBlending(uint32_t blending) {
878 getLayer()->blending = blending;
879 }
880 virtual void setTransform(uint32_t transform) {
881 getLayer()->transform = transform;
882 }
883 virtual void setFrame(const Rect& frame) {
Mathias Agopian6b442672013-07-09 21:24:52 -0700884 getLayer()->displayFrame = reinterpret_cast<hwc_rect_t const&>(frame);
Jesse Hall5880cc52012-06-05 23:40:32 -0700885 }
Mathias Agopian6b442672013-07-09 21:24:52 -0700886 virtual void setCrop(const FloatRect& crop) {
887 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) {
888 getLayer()->sourceCropf = reinterpret_cast<hwc_frect_t const&>(crop);
889 } else {
890 /*
891 * Since h/w composer didn't support a flot crop rect before version 1.3,
892 * using integer coordinates instead produces a different output from the GL code in
893 * Layer::drawWithOpenGL(). The difference can be large if the buffer crop to
894 * window size ratio is large and a window crop is defined
895 * (i.e.: if we scale the buffer a lot and we also crop it with a window crop).
896 */
897 hwc_rect_t& r = getLayer()->sourceCrop;
898 r.left = int(ceilf(crop.left));
899 r.top = int(ceilf(crop.top));
900 r.right = int(floorf(crop.right));
901 r.bottom= int(floorf(crop.bottom));
902 }
Jesse Hall5880cc52012-06-05 23:40:32 -0700903 }
904 virtual void setVisibleRegionScreen(const Region& reg) {
Mathias Agopianc3973602012-08-31 17:51:25 -0700905 // Region::getSharedBuffer creates a reference to the underlying
906 // SharedBuffer of this Region, this reference is freed
907 // in onDisplayed()
908 hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen;
909 SharedBuffer const* sb = reg.getSharedBuffer(&visibleRegion.numRects);
910 visibleRegion.rects = reinterpret_cast<hwc_rect_t const *>(sb->data());
Jesse Hall5880cc52012-06-05 23:40:32 -0700911 }
912 virtual void setBuffer(const sp<GraphicBuffer>& buffer) {
913 if (buffer == 0 || buffer->handle == 0) {
914 getLayer()->compositionType = HWC_FRAMEBUFFER;
915 getLayer()->flags |= HWC_SKIP_LAYER;
916 getLayer()->handle = 0;
917 } else {
918 getLayer()->handle = buffer->handle;
919 }
920 }
Mathias Agopianc3973602012-08-31 17:51:25 -0700921 virtual void onDisplayed() {
922 hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen;
923 SharedBuffer const* sb = SharedBuffer::bufferFromData(visibleRegion.rects);
924 if (sb) {
925 sb->release();
926 // not technically needed but safer
927 visibleRegion.numRects = 0;
928 visibleRegion.rects = NULL;
929 }
Jesse Halle25d0052012-09-05 13:03:10 -0700930
931 getLayer()->acquireFenceFd = -1;
Mathias Agopianc3973602012-08-31 17:51:25 -0700932 }
Jesse Hall5880cc52012-06-05 23:40:32 -0700933};
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700934
935/*
936 * returns an iterator initialized at a given index in the layer list
937 */
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700938HWComposer::LayerListIterator HWComposer::getLayerIterator(int32_t id, size_t index) {
Mathias Agopianf4358632012-08-22 17:16:19 -0700939 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) {
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700940 return LayerListIterator();
Mathias Agopianf4358632012-08-22 17:16:19 -0700941 }
942 const DisplayData& disp(mDisplayData[id]);
943 if (!mHwc || !disp.list || index > disp.list->numHwLayers) {
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700944 return LayerListIterator();
Mathias Agopianf4358632012-08-22 17:16:19 -0700945 }
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800946 return LayerListIterator(new HWCLayerVersion1(mHwc, disp.list->hwLayers), index);
Mathias Agopiana350ff92010-08-10 17:14:02 -0700947}
948
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700949/*
950 * returns an iterator on the beginning of the layer list
951 */
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700952HWComposer::LayerListIterator HWComposer::begin(int32_t id) {
Mathias Agopian1e260872012-08-08 18:35:12 -0700953 return getLayerIterator(id, 0);
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700954}
955
956/*
957 * returns an iterator on the end of the layer list
958 */
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700959HWComposer::LayerListIterator HWComposer::end(int32_t id) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700960 size_t numLayers = 0;
961 if (uint32_t(id) <= 31 && mAllocatedDisplayIDs.hasBit(id)) {
962 const DisplayData& disp(mDisplayData[id]);
963 if (mHwc && disp.list) {
964 numLayers = disp.list->numHwLayers;
965 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
966 // with HWC 1.1, the last layer is always the HWC_FRAMEBUFFER_TARGET,
967 // which we ignore when iterating through the layer list.
968 ALOGE_IF(!numLayers, "mDisplayData[%d].list->numHwLayers is 0", id);
969 if (numLayers) {
970 numLayers--;
971 }
972 }
973 }
974 }
975 return getLayerIterator(id, numLayers);
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700976}
977
Mathias Agopian74d211a2013-04-22 16:55:35 +0200978void HWComposer::dump(String8& result) const {
Jesse Hallb685c542012-07-31 14:32:56 -0700979 if (mHwc) {
Mathias Agopiancde87a32012-09-13 14:09:01 -0700980 result.appendFormat("Hardware Composer state (version %8x):\n", hwcApiVersion(mHwc));
Mathias Agopianf4358632012-08-22 17:16:19 -0700981 result.appendFormat(" mDebugForceFakeVSync=%d\n", mDebugForceFakeVSync);
982 for (size_t i=0 ; i<mNumDisplays ; i++) {
983 const DisplayData& disp(mDisplayData[i]);
Jesse Hall02d86562013-03-25 14:43:23 -0700984 if (!disp.connected)
985 continue;
Mathias Agopianb4d18ed2012-09-20 23:14:05 -0700986
Mathias Agopian13127d82013-03-05 17:47:11 -0800987 const Vector< sp<Layer> >& visibleLayersSortedByZ =
Mathias Agopiancb558572012-10-04 15:58:54 -0700988 mFlinger->getLayerSortedByZForHwcDisplay(i);
989
Jesse Hall02d86562013-03-25 14:43:23 -0700990 result.appendFormat(
991 " Display[%d] : %ux%u, xdpi=%f, ydpi=%f, refresh=%lld\n",
992 i, disp.width, disp.height, disp.xdpi, disp.ydpi, disp.refresh);
Mathias Agopianb4d18ed2012-09-20 23:14:05 -0700993
Jesse Hall02d86562013-03-25 14:43:23 -0700994 if (disp.list) {
Mathias Agopianb4d18ed2012-09-20 23:14:05 -0700995 result.appendFormat(
996 " numHwLayers=%u, flags=%08x\n",
997 disp.list->numHwLayers, disp.list->flags);
998
Mathias Agopianf4358632012-08-22 17:16:19 -0700999 result.append(
Mathias Agopianda27af92012-09-13 18:17:13 -07001000 " type | handle | hints | flags | tr | blend | format | source crop | frame name \n"
1001 "------------+----------+----------+----------+----+-------+----------+---------------------------+--------------------------------\n");
1002 // " __________ | ________ | ________ | ________ | __ | _____ | ________ | [_____,_____,_____,_____] | [_____,_____,_____,_____]
Mathias Agopianf4358632012-08-22 17:16:19 -07001003 for (size_t i=0 ; i<disp.list->numHwLayers ; i++) {
1004 const hwc_layer_1_t&l = disp.list->hwLayers[i];
Mathias Agopianf4358632012-08-22 17:16:19 -07001005 int32_t format = -1;
Mathias Agopianda27af92012-09-13 18:17:13 -07001006 String8 name("unknown");
Mathias Agopiancb558572012-10-04 15:58:54 -07001007
Mathias Agopianda27af92012-09-13 18:17:13 -07001008 if (i < visibleLayersSortedByZ.size()) {
Mathias Agopian13127d82013-03-05 17:47:11 -08001009 const sp<Layer>& layer(visibleLayersSortedByZ[i]);
1010 const sp<GraphicBuffer>& buffer(
1011 layer->getActiveBuffer());
1012 if (buffer != NULL) {
1013 format = buffer->getPixelFormat();
Mathias Agopianf4358632012-08-22 17:16:19 -07001014 }
Mathias Agopianda27af92012-09-13 18:17:13 -07001015 name = layer->getName();
Mathias Agopianf4358632012-08-22 17:16:19 -07001016 }
Mathias Agopianda27af92012-09-13 18:17:13 -07001017
1018 int type = l.compositionType;
1019 if (type == HWC_FRAMEBUFFER_TARGET) {
1020 name = "HWC_FRAMEBUFFER_TARGET";
1021 format = disp.format;
1022 }
1023
1024 static char const* compositionTypeName[] = {
1025 "GLES",
1026 "HWC",
1027 "BACKGROUND",
1028 "FB TARGET",
1029 "UNKNOWN"};
1030 if (type >= NELEM(compositionTypeName))
1031 type = NELEM(compositionTypeName) - 1;
1032
Mathias Agopianf4358632012-08-22 17:16:19 -07001033 result.appendFormat(
Mathias Agopianda27af92012-09-13 18:17:13 -07001034 " %10s | %08x | %08x | %08x | %02x | %05x | %08x | [%5d,%5d,%5d,%5d] | [%5d,%5d,%5d,%5d] %s\n",
1035 compositionTypeName[type],
Mathias Agopianf4358632012-08-22 17:16:19 -07001036 intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, format,
1037 l.sourceCrop.left, l.sourceCrop.top, l.sourceCrop.right, l.sourceCrop.bottom,
1038 l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom,
Mathias Agopianda27af92012-09-13 18:17:13 -07001039 name.string());
Mathias Agopianfb4d5d52011-09-20 15:13:14 -07001040 }
1041 }
Mathias Agopian83727852010-09-23 18:13:21 -07001042 }
Erik Gilling1d21a9c2010-12-01 16:38:01 -08001043 }
Mathias Agopian30bcc612012-08-22 15:39:48 -07001044
1045 if (mHwc && mHwc->dump) {
Mathias Agopian74d211a2013-04-22 16:55:35 +02001046 const size_t SIZE = 4096;
1047 char buffer[SIZE];
Mathias Agopian30bcc612012-08-22 15:39:48 -07001048 mHwc->dump(mHwc, buffer, SIZE);
Erik Gilling1d21a9c2010-12-01 16:38:01 -08001049 result.append(buffer);
Mathias Agopian83727852010-09-23 18:13:21 -07001050 }
1051}
1052
Mathias Agopiana350ff92010-08-10 17:14:02 -07001053// ---------------------------------------------------------------------------
Mathias Agopian2965b262012-04-08 15:13:32 -07001054
1055HWComposer::VSyncThread::VSyncThread(HWComposer& hwc)
1056 : mHwc(hwc), mEnabled(false),
1057 mNextFakeVSync(0),
Andy McFaddenb0d1dd32012-09-10 14:08:09 -07001058 mRefreshPeriod(hwc.getRefreshPeriod(HWC_DISPLAY_PRIMARY))
Mathias Agopian2965b262012-04-08 15:13:32 -07001059{
1060}
1061
1062void HWComposer::VSyncThread::setEnabled(bool enabled) {
1063 Mutex::Autolock _l(mLock);
Mathias Agopian81cd5d32012-10-04 02:34:38 -07001064 if (mEnabled != enabled) {
1065 mEnabled = enabled;
1066 mCondition.signal();
1067 }
Mathias Agopian2965b262012-04-08 15:13:32 -07001068}
1069
1070void HWComposer::VSyncThread::onFirstRef() {
1071 run("VSyncThread", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE);
1072}
1073
1074bool HWComposer::VSyncThread::threadLoop() {
1075 { // scope for lock
1076 Mutex::Autolock _l(mLock);
1077 while (!mEnabled) {
1078 mCondition.wait(mLock);
1079 }
1080 }
1081
1082 const nsecs_t period = mRefreshPeriod;
1083 const nsecs_t now = systemTime(CLOCK_MONOTONIC);
1084 nsecs_t next_vsync = mNextFakeVSync;
1085 nsecs_t sleep = next_vsync - now;
1086 if (sleep < 0) {
1087 // we missed, find where the next vsync should be
1088 sleep = (period - ((now - next_vsync) % period));
1089 next_vsync = now + sleep;
1090 }
1091 mNextFakeVSync = next_vsync + period;
1092
1093 struct timespec spec;
1094 spec.tv_sec = next_vsync / 1000000000;
1095 spec.tv_nsec = next_vsync % 1000000000;
1096
1097 int err;
1098 do {
1099 err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL);
1100 } while (err<0 && errno == EINTR);
1101
1102 if (err == 0) {
1103 mHwc.mEventHandler.onVSyncReceived(0, next_vsync);
1104 }
1105
1106 return true;
1107}
1108
Jesse Halla9a1b002013-02-27 16:39:25 -08001109HWComposer::DisplayData::DisplayData()
1110: width(0), height(0), format(0),
1111 xdpi(0.0f), ydpi(0.0f),
1112 refresh(0),
1113 connected(false),
1114 hasFbComp(false), hasOvComp(false),
1115 capacity(0), list(NULL),
1116 framebufferTarget(NULL), fbTargetHandle(0),
1117 lastRetireFence(Fence::NO_FENCE), lastDisplayFence(Fence::NO_FENCE),
Jesse Hall851cfe82013-03-20 13:44:00 -07001118 outbufHandle(NULL), outbufAcquireFence(Fence::NO_FENCE),
Jesse Halla9a1b002013-02-27 16:39:25 -08001119 events(0)
1120{}
1121
1122HWComposer::DisplayData::~DisplayData() {
1123 free(list);
1124}
1125
Mathias Agopian2965b262012-04-08 15:13:32 -07001126// ---------------------------------------------------------------------------
Mathias Agopiana350ff92010-08-10 17:14:02 -07001127}; // namespace android