blob: f6256f994660920e04316073b2d3f71ec4ef2b58 [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
Mathias Agopiana350ff92010-08-10 17:14:02 -070019#include <stdint.h>
Mathias Agopianf1352df2010-08-11 17:31:33 -070020#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070023#include <sys/types.h>
Mathias Agopian6b442672013-07-09 21:24:52 -070024#include <math.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070025
Mathias Agopian33ceeb32013-04-01 16:54:58 -070026#include <utils/CallStack.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070027#include <utils/Errors.h>
Mathias Agopianda27af92012-09-13 18:17:13 -070028#include <utils/misc.h>
Mathias Agopian83727852010-09-23 18:13:21 -070029#include <utils/String8.h>
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070030#include <utils/Thread.h>
Mathias Agopian2965b262012-04-08 15:13:32 -070031#include <utils/Trace.h>
Mathias Agopian22da60c2011-09-09 00:49:11 -070032#include <utils/Vector.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070033
Mathias Agopian921e6ac2012-07-23 23:11:29 -070034#include <ui/GraphicBuffer.h>
35
Mathias Agopiana350ff92010-08-10 17:14:02 -070036#include <hardware/hardware.h>
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070037#include <hardware/hwcomposer.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070038
Jesse Hall1c569c42013-04-05 13:44:52 -070039#include <android/configuration.h>
40
Mathias Agopiana350ff92010-08-10 17:14:02 -070041#include <cutils/log.h>
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -070042#include <cutils/properties.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070043
Mathias Agopiana350ff92010-08-10 17:14:02 -070044#include "HWComposer.h"
Mathias Agopian33ceeb32013-04-01 16:54:58 -070045
46#include "../Layer.h" // needed only for debugging
47#include "../SurfaceFlinger.h"
Mathias Agopiana350ff92010-08-10 17:14:02 -070048
49namespace android {
Jesse Hall5880cc52012-06-05 23:40:32 -070050
Jesse Hall38efe862013-04-06 23:12:29 -070051#ifndef HWC_DEVICE_API_VERSION_1_3
52#define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION)
53#endif
Jesse Halle737c112013-05-07 11:58:47 -070054
Jesse Hall72960512013-01-10 16:19:56 -080055#define MIN_HWC_HEADER_VERSION HWC_HEADER_VERSION
Jesse Hall9eb1eb52012-08-29 10:39:38 -070056
Jesse Hallafaf14b2013-03-20 13:42:29 -070057#define NUM_PHYSICAL_DISPLAYS HWC_NUM_DISPLAY_TYPES
58#define VIRTUAL_DISPLAY_ID_BASE HWC_NUM_DISPLAY_TYPES
59
Jesse Hall9eb1eb52012-08-29 10:39:38 -070060static uint32_t hwcApiVersion(const hwc_composer_device_1_t* hwc) {
61 uint32_t hwcVersion = hwc->common.version;
Jesse Hall9eb1eb52012-08-29 10:39:38 -070062 return hwcVersion & HARDWARE_API_VERSION_2_MAJ_MIN_MASK;
63}
64
65static uint32_t hwcHeaderVersion(const hwc_composer_device_1_t* hwc) {
66 uint32_t hwcVersion = hwc->common.version;
Jesse Hall9eb1eb52012-08-29 10:39:38 -070067 return hwcVersion & HARDWARE_API_VERSION_2_HEADER_MASK;
68}
69
70static bool hwcHasApiVersion(const hwc_composer_device_1_t* hwc,
71 uint32_t version) {
72 return hwcApiVersion(hwc) >= (version & HARDWARE_API_VERSION_2_MAJ_MIN_MASK);
Jesse Hallbbd164a2012-08-21 12:05:09 -070073}
74
Mathias Agopiana350ff92010-08-10 17:14:02 -070075// ---------------------------------------------------------------------------
76
Mathias Agopian3e8b8532012-05-13 20:42:01 -070077struct HWComposer::cb_context {
78 struct callbacks : public hwc_procs_t {
79 // these are here to facilitate the transition when adding
80 // new callbacks (an implementation can check for NULL before
81 // calling a new callback).
82 void (*zero[4])(void);
83 };
84 callbacks procs;
85 HWComposer* hwc;
86};
87
88// ---------------------------------------------------------------------------
89
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070090HWComposer::HWComposer(
91 const sp<SurfaceFlinger>& flinger,
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070092 EventHandler& handler)
Mathias Agopianc7d14e22011-08-01 16:32:21 -070093 : mFlinger(flinger),
Andy McFaddenb0d1dd32012-09-10 14:08:09 -070094 mFbDev(0), mHwc(0), mNumDisplays(1),
Mathias Agopian3e8b8532012-05-13 20:42:01 -070095 mCBContext(new cb_context),
Mathias Agopiane60b0682012-08-21 23:34:09 -070096 mEventHandler(handler),
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -070097 mVSyncCount(0), mDebugForceFakeVSync(false)
Mathias Agopiana350ff92010-08-10 17:14:02 -070098{
Mathias Agopiane60b0682012-08-21 23:34:09 -070099 for (size_t i =0 ; i<MAX_DISPLAYS ; i++) {
100 mLists[i] = 0;
101 }
Jesse Hallb685c542012-07-31 14:32:56 -0700102
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -0700103 char value[PROPERTY_VALUE_MAX];
104 property_get("debug.sf.no_hw_vsync", value, "0");
105 mDebugForceFakeVSync = atoi(value);
106
Mathias Agopian028508c2012-07-25 21:12:12 -0700107 bool needVSyncThread = true;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700108
109 // Note: some devices may insist that the FB HAL be opened before HWC.
Jesse Hallef64b752013-03-18 11:28:50 -0700110 int fberr = loadFbHalModule();
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700111 loadHwcModule();
112
Mathias Agopianda27af92012-09-13 18:17:13 -0700113 if (mFbDev && mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
114 // close FB HAL if we don't needed it.
115 // FIXME: this is temporary until we're not forced to open FB HAL
116 // before HWC.
117 framebuffer_close(mFbDev);
118 mFbDev = NULL;
119 }
120
Andy McFaddenbabba182012-09-12 13:14:51 -0700121 // If we have no HWC, or a pre-1.1 HWC, an FB dev is mandatory.
122 if ((!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1))
123 && !mFbDev) {
Jesse Hallef64b752013-03-18 11:28:50 -0700124 ALOGE("ERROR: failed to open framebuffer (%s), aborting",
125 strerror(-fberr));
Andy McFadden43601a22012-09-11 15:15:13 -0700126 abort();
127 }
128
Andy McFadden620685c2012-10-19 12:53:46 -0700129 // these display IDs are always reserved
Jesse Hallafaf14b2013-03-20 13:42:29 -0700130 for (size_t i=0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) {
Andy McFadden620685c2012-10-19 12:53:46 -0700131 mAllocatedDisplayIDs.markBit(i);
132 }
133
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700134 if (mHwc) {
135 ALOGI("Using %s version %u.%u", HWC_HARDWARE_COMPOSER,
136 (hwcApiVersion(mHwc) >> 24) & 0xff,
137 (hwcApiVersion(mHwc) >> 16) & 0xff);
138 if (mHwc->registerProcs) {
139 mCBContext->hwc = this;
140 mCBContext->procs.invalidate = &hook_invalidate;
141 mCBContext->procs.vsync = &hook_vsync;
142 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1))
143 mCBContext->procs.hotplug = &hook_hotplug;
144 else
145 mCBContext->procs.hotplug = NULL;
146 memset(mCBContext->procs.zero, 0, sizeof(mCBContext->procs.zero));
147 mHwc->registerProcs(mHwc, &mCBContext->procs);
Jesse Hall5880cc52012-06-05 23:40:32 -0700148 }
149
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700150 // don't need a vsync thread if we have a hardware composer
151 needVSyncThread = false;
152 // always turn vsync off when we start
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700153 eventControl(HWC_DISPLAY_PRIMARY, HWC_EVENT_VSYNC, 0);
Jesse Hallbbd164a2012-08-21 12:05:09 -0700154
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700155 // the number of displays we actually have depends on the
156 // hw composer version
Jesse Hall38efe862013-04-06 23:12:29 -0700157 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) {
158 // 1.3 adds support for virtual displays
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700159 mNumDisplays = MAX_DISPLAYS;
160 } else if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
161 // 1.1 adds support for multiple displays
Jesse Hallafaf14b2013-03-20 13:42:29 -0700162 mNumDisplays = NUM_PHYSICAL_DISPLAYS;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700163 } else {
164 mNumDisplays = 1;
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700165 }
Mathias Agopian3a778712012-04-09 14:16:47 -0700166 }
167
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700168 if (mFbDev) {
Jesse Hall1bd20e02012-08-29 10:47:52 -0700169 ALOG_ASSERT(!(mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)),
170 "should only have fbdev if no hwc or hwc is 1.0");
171
Mathias Agopianf4358632012-08-22 17:16:19 -0700172 DisplayData& disp(mDisplayData[HWC_DISPLAY_PRIMARY]);
Mathias Agopian38e623b2012-09-20 19:27:07 -0700173 disp.connected = true;
Jesse Halldb276212012-09-07 11:20:56 -0700174 disp.width = mFbDev->width;
175 disp.height = mFbDev->height;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700176 disp.format = mFbDev->format;
177 disp.xdpi = mFbDev->xdpi;
178 disp.ydpi = mFbDev->ydpi;
Mathias Agopianf4358632012-08-22 17:16:19 -0700179 if (disp.refresh == 0) {
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700180 disp.refresh = nsecs_t(1e9 / mFbDev->fps);
Mathias Agopianf4358632012-08-22 17:16:19 -0700181 ALOGW("getting VSYNC period from fb HAL: %lld", disp.refresh);
Mathias Agopian888c8222012-08-04 21:10:38 -0700182 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700183 if (disp.refresh == 0) {
184 disp.refresh = nsecs_t(1e9 / 60.0);
Jesse Hall1bd20e02012-08-29 10:47:52 -0700185 ALOGW("getting VSYNC period from thin air: %lld",
186 mDisplayData[HWC_DISPLAY_PRIMARY].refresh);
Mathias Agopianf4358632012-08-22 17:16:19 -0700187 }
Jesse Hall1bd20e02012-08-29 10:47:52 -0700188 } else if (mHwc) {
Mathias Agopian1604f772012-09-18 21:54:42 -0700189 // here we're guaranteed to have at least HWC 1.1
Jesse Hallafaf14b2013-03-20 13:42:29 -0700190 for (size_t i =0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) {
Mathias Agopian1604f772012-09-18 21:54:42 -0700191 queryDisplayProperties(i);
192 }
Mathias Agopian888c8222012-08-04 21:10:38 -0700193 }
194
Mathias Agopian3a778712012-04-09 14:16:47 -0700195 if (needVSyncThread) {
196 // we don't have VSYNC support, we need to fake it
197 mVSyncThread = new VSyncThread(*this);
Mathias Agopiana350ff92010-08-10 17:14:02 -0700198 }
199}
200
201HWComposer::~HWComposer() {
Andy McFaddenbabba182012-09-12 13:14:51 -0700202 if (mHwc) {
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700203 eventControl(HWC_DISPLAY_PRIMARY, HWC_EVENT_VSYNC, 0);
Andy McFaddenbabba182012-09-12 13:14:51 -0700204 }
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700205 if (mVSyncThread != NULL) {
206 mVSyncThread->requestExitAndWait();
207 }
Mathias Agopiana350ff92010-08-10 17:14:02 -0700208 if (mHwc) {
Jesse Hall5880cc52012-06-05 23:40:32 -0700209 hwc_close_1(mHwc);
Mathias Agopiana350ff92010-08-10 17:14:02 -0700210 }
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700211 if (mFbDev) {
212 framebuffer_close(mFbDev);
213 }
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700214 delete mCBContext;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700215}
216
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700217// Load and prepare the hardware composer module. Sets mHwc.
218void HWComposer::loadHwcModule()
219{
220 hw_module_t const* module;
221
222 if (hw_get_module(HWC_HARDWARE_MODULE_ID, &module) != 0) {
223 ALOGE("%s module not found", HWC_HARDWARE_MODULE_ID);
224 return;
225 }
226
227 int err = hwc_open_1(module, &mHwc);
228 if (err) {
229 ALOGE("%s device failed to initialize (%s)",
230 HWC_HARDWARE_COMPOSER, strerror(-err));
231 return;
232 }
233
234 if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_0) ||
235 hwcHeaderVersion(mHwc) < MIN_HWC_HEADER_VERSION ||
236 hwcHeaderVersion(mHwc) > HWC_HEADER_VERSION) {
237 ALOGE("%s device version %#x unsupported, will not be used",
238 HWC_HARDWARE_COMPOSER, mHwc->common.version);
239 hwc_close_1(mHwc);
240 mHwc = NULL;
241 return;
242 }
243}
244
245// Load and prepare the FB HAL, which uses the gralloc module. Sets mFbDev.
Jesse Hallef64b752013-03-18 11:28:50 -0700246int HWComposer::loadFbHalModule()
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700247{
248 hw_module_t const* module;
249
Jesse Hallef64b752013-03-18 11:28:50 -0700250 int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
251 if (err != 0) {
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700252 ALOGE("%s module not found", GRALLOC_HARDWARE_MODULE_ID);
Jesse Hallef64b752013-03-18 11:28:50 -0700253 return err;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700254 }
255
Jesse Hallef64b752013-03-18 11:28:50 -0700256 return framebuffer_open(module, &mFbDev);
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700257}
258
Mathias Agopiana350ff92010-08-10 17:14:02 -0700259status_t HWComposer::initCheck() const {
260 return mHwc ? NO_ERROR : NO_INIT;
261}
262
Jesse Hallbbd164a2012-08-21 12:05:09 -0700263void HWComposer::hook_invalidate(const struct hwc_procs* procs) {
264 cb_context* ctx = reinterpret_cast<cb_context*>(
265 const_cast<hwc_procs_t*>(procs));
266 ctx->hwc->invalidate();
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700267}
268
Jesse Hall1bd20e02012-08-29 10:47:52 -0700269void HWComposer::hook_vsync(const struct hwc_procs* procs, int disp,
Jesse Hallbbd164a2012-08-21 12:05:09 -0700270 int64_t timestamp) {
271 cb_context* ctx = reinterpret_cast<cb_context*>(
272 const_cast<hwc_procs_t*>(procs));
Jesse Hall1bd20e02012-08-29 10:47:52 -0700273 ctx->hwc->vsync(disp, timestamp);
274}
275
276void HWComposer::hook_hotplug(const struct hwc_procs* procs, int disp,
277 int connected) {
278 cb_context* ctx = reinterpret_cast<cb_context*>(
279 const_cast<hwc_procs_t*>(procs));
280 ctx->hwc->hotplug(disp, connected);
Mathias Agopian31d28432012-04-03 16:31:39 -0700281}
282
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700283void HWComposer::invalidate() {
Mathias Agopiane2c2f922011-10-05 15:00:22 -0700284 mFlinger->repaintEverything();
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700285}
286
Jesse Hall1bd20e02012-08-29 10:47:52 -0700287void HWComposer::vsync(int disp, int64_t timestamp) {
Mathias Agopian2965b262012-04-08 15:13:32 -0700288 ATRACE_INT("VSYNC", ++mVSyncCount&1);
Jesse Hall1bd20e02012-08-29 10:47:52 -0700289 mEventHandler.onVSyncReceived(disp, timestamp);
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700290 Mutex::Autolock _l(mLock);
291 mLastHwVSync = timestamp;
292}
293
Jesse Hall1bd20e02012-08-29 10:47:52 -0700294void HWComposer::hotplug(int disp, int connected) {
Jesse Hallafaf14b2013-03-20 13:42:29 -0700295 if (disp == HWC_DISPLAY_PRIMARY || disp >= VIRTUAL_DISPLAY_ID_BASE) {
Jesse Hall1bd20e02012-08-29 10:47:52 -0700296 ALOGE("hotplug event received for invalid display: disp=%d connected=%d",
297 disp, connected);
298 return;
299 }
Mathias Agopianf5a33922012-09-19 18:16:22 -0700300 queryDisplayProperties(disp);
Mathias Agopian148994e2012-09-19 17:31:36 -0700301 mEventHandler.onHotplugReceived(disp, bool(connected));
Jesse Hall1bd20e02012-08-29 10:47:52 -0700302}
303
Jesse Hall1c569c42013-04-05 13:44:52 -0700304static float getDefaultDensity(uint32_t height) {
305 if (height >= 1080) return ACONFIGURATION_DENSITY_XHIGH;
306 else return ACONFIGURATION_DENSITY_TV;
307}
308
Jesse Hall1bd20e02012-08-29 10:47:52 -0700309static const uint32_t DISPLAY_ATTRIBUTES[] = {
310 HWC_DISPLAY_VSYNC_PERIOD,
Jesse Halldb276212012-09-07 11:20:56 -0700311 HWC_DISPLAY_WIDTH,
312 HWC_DISPLAY_HEIGHT,
Jesse Hall1bd20e02012-08-29 10:47:52 -0700313 HWC_DISPLAY_DPI_X,
314 HWC_DISPLAY_DPI_Y,
315 HWC_DISPLAY_NO_ATTRIBUTE,
316};
317#define NUM_DISPLAY_ATTRIBUTES (sizeof(DISPLAY_ATTRIBUTES) / sizeof(DISPLAY_ATTRIBUTES)[0])
318
Mathias Agopian1604f772012-09-18 21:54:42 -0700319status_t HWComposer::queryDisplayProperties(int disp) {
320
Mathias Agopianda27af92012-09-13 18:17:13 -0700321 LOG_ALWAYS_FATAL_IF(!mHwc || !hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1));
Jesse Hall1bd20e02012-08-29 10:47:52 -0700322
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700323 // use zero as default value for unspecified attributes
Jesse Hall1bd20e02012-08-29 10:47:52 -0700324 int32_t values[NUM_DISPLAY_ATTRIBUTES - 1];
325 memset(values, 0, sizeof(values));
326
327 uint32_t config;
328 size_t numConfigs = 1;
329 status_t err = mHwc->getDisplayConfigs(mHwc, disp, &config, &numConfigs);
Mathias Agopian1604f772012-09-18 21:54:42 -0700330 if (err != NO_ERROR) {
331 // this can happen if an unpluggable display is not connected
Mathias Agopianf5a33922012-09-19 18:16:22 -0700332 mDisplayData[disp].connected = false;
Mathias Agopian1604f772012-09-18 21:54:42 -0700333 return err;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700334 }
335
Mathias Agopian9e2463e2012-09-21 18:26:16 -0700336 err = mHwc->getDisplayAttributes(mHwc, disp, config, DISPLAY_ATTRIBUTES, values);
337 if (err != NO_ERROR) {
338 // we can't get this display's info. turn it off.
339 mDisplayData[disp].connected = false;
340 return err;
341 }
Mathias Agopian1604f772012-09-18 21:54:42 -0700342
Jesse Hall1bd20e02012-08-29 10:47:52 -0700343 int32_t w = 0, h = 0;
344 for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) {
345 switch (DISPLAY_ATTRIBUTES[i]) {
346 case HWC_DISPLAY_VSYNC_PERIOD:
347 mDisplayData[disp].refresh = nsecs_t(values[i]);
348 break;
Jesse Halldb276212012-09-07 11:20:56 -0700349 case HWC_DISPLAY_WIDTH:
350 mDisplayData[disp].width = values[i];
Jesse Hall1bd20e02012-08-29 10:47:52 -0700351 break;
Jesse Halldb276212012-09-07 11:20:56 -0700352 case HWC_DISPLAY_HEIGHT:
353 mDisplayData[disp].height = values[i];
Jesse Hall1bd20e02012-08-29 10:47:52 -0700354 break;
355 case HWC_DISPLAY_DPI_X:
356 mDisplayData[disp].xdpi = values[i] / 1000.0f;
357 break;
358 case HWC_DISPLAY_DPI_Y:
359 mDisplayData[disp].ydpi = values[i] / 1000.0f;
360 break;
361 default:
Mathias Agopianda27af92012-09-13 18:17:13 -0700362 ALOG_ASSERT(false, "unknown display attribute[%d] %#x",
363 i, DISPLAY_ATTRIBUTES[i]);
Jesse Hall1bd20e02012-08-29 10:47:52 -0700364 break;
365 }
366 }
367
Mathias Agopianf5a33922012-09-19 18:16:22 -0700368 // FIXME: what should we set the format to?
369 mDisplayData[disp].format = HAL_PIXEL_FORMAT_RGBA_8888;
370 mDisplayData[disp].connected = true;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700371 if (mDisplayData[disp].xdpi == 0.0f || mDisplayData[disp].ydpi == 0.0f) {
Jesse Hall1c569c42013-04-05 13:44:52 -0700372 float dpi = getDefaultDensity(h);
373 mDisplayData[disp].xdpi = dpi;
374 mDisplayData[disp].ydpi = dpi;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700375 }
Mathias Agopian1604f772012-09-18 21:54:42 -0700376 return NO_ERROR;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700377}
378
Jesse Hall1c569c42013-04-05 13:44:52 -0700379status_t HWComposer::setVirtualDisplayProperties(int32_t id,
380 uint32_t w, uint32_t h, uint32_t format) {
381 if (id < VIRTUAL_DISPLAY_ID_BASE || id >= int32_t(mNumDisplays) ||
382 !mAllocatedDisplayIDs.hasBit(id)) {
383 return BAD_INDEX;
384 }
385 mDisplayData[id].width = w;
386 mDisplayData[id].height = h;
387 mDisplayData[id].format = format;
388 mDisplayData[id].xdpi = mDisplayData[id].ydpi = getDefaultDensity(h);
389 return NO_ERROR;
390}
391
Mathias Agopiane60b0682012-08-21 23:34:09 -0700392int32_t HWComposer::allocateDisplayId() {
Mathias Agopianf4358632012-08-22 17:16:19 -0700393 if (mAllocatedDisplayIDs.count() >= mNumDisplays) {
Mathias Agopiane60b0682012-08-21 23:34:09 -0700394 return NO_MEMORY;
395 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700396 int32_t id = mAllocatedDisplayIDs.firstUnmarkedBit();
397 mAllocatedDisplayIDs.markBit(id);
Jesse Hall7adb0f82013-03-06 16:13:49 -0800398 mDisplayData[id].connected = true;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700399 return id;
400}
401
402status_t HWComposer::freeDisplayId(int32_t id) {
Jesse Hallafaf14b2013-03-20 13:42:29 -0700403 if (id < NUM_PHYSICAL_DISPLAYS) {
Mathias Agopianf4358632012-08-22 17:16:19 -0700404 // cannot free the reserved IDs
Mathias Agopiane60b0682012-08-21 23:34:09 -0700405 return BAD_VALUE;
406 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700407 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) {
Mathias Agopiane60b0682012-08-21 23:34:09 -0700408 return BAD_INDEX;
409 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700410 mAllocatedDisplayIDs.clearBit(id);
Jesse Hall7adb0f82013-03-06 16:13:49 -0800411 mDisplayData[id].connected = false;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700412 return NO_ERROR;
413}
414
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700415nsecs_t HWComposer::getRefreshPeriod(int disp) const {
416 return mDisplayData[disp].refresh;
Mathias Agopian888c8222012-08-04 21:10:38 -0700417}
418
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700419nsecs_t HWComposer::getRefreshTimestamp(int disp) const {
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700420 // this returns the last refresh timestamp.
421 // if the last one is not available, we estimate it based on
422 // the refresh period and whatever closest timestamp we have.
423 Mutex::Autolock _l(mLock);
424 nsecs_t now = systemTime(CLOCK_MONOTONIC);
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700425 return now - ((now - mLastHwVSync) % mDisplayData[disp].refresh);
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700426}
427
Jamie Gennis2ec3e072012-11-11 16:24:33 -0800428sp<Fence> HWComposer::getDisplayFence(int disp) const {
429 return mDisplayData[disp].lastDisplayFence;
430}
431
Jesse Halldb276212012-09-07 11:20:56 -0700432uint32_t HWComposer::getWidth(int disp) const {
433 return mDisplayData[disp].width;
Mathias Agopian8b736f12012-08-13 17:54:26 -0700434}
435
Jesse Halldb276212012-09-07 11:20:56 -0700436uint32_t HWComposer::getHeight(int disp) const {
437 return mDisplayData[disp].height;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700438}
439
440uint32_t HWComposer::getFormat(int disp) const {
441 return mDisplayData[disp].format;
442}
443
444float HWComposer::getDpiX(int disp) const {
445 return mDisplayData[disp].xdpi;
446}
447
448float HWComposer::getDpiY(int disp) const {
449 return mDisplayData[disp].ydpi;
Mathias Agopian8b736f12012-08-13 17:54:26 -0700450}
451
Mathias Agopianf5a33922012-09-19 18:16:22 -0700452bool HWComposer::isConnected(int disp) const {
453 return mDisplayData[disp].connected;
454}
455
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700456void HWComposer::eventControl(int disp, int event, int enabled) {
457 if (uint32_t(disp)>31 || !mAllocatedDisplayIDs.hasBit(disp)) {
Andy McFadden620685c2012-10-19 12:53:46 -0700458 ALOGD("eventControl ignoring event %d on unallocated disp %d (en=%d)",
459 event, disp, enabled);
460 return;
461 }
462 if (event != EVENT_VSYNC) {
463 ALOGW("eventControl got unexpected event %d (disp=%d en=%d)",
464 event, disp, enabled);
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700465 return;
466 }
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700467 status_t err = NO_ERROR;
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700468 if (mHwc && !mDebugForceFakeVSync) {
469 // NOTE: we use our own internal lock here because we have to call
470 // into the HWC with the lock held, and we want to make sure
471 // that even if HWC blocks (which it shouldn't), it won't
472 // affect other threads.
473 Mutex::Autolock _l(mEventControlLock);
474 const int32_t eventBit = 1UL << event;
475 const int32_t newValue = enabled ? eventBit : 0;
476 const int32_t oldValue = mDisplayData[disp].events & eventBit;
477 if (newValue != oldValue) {
478 ATRACE_CALL();
479 err = mHwc->eventControl(mHwc, disp, event, enabled);
480 if (!err) {
481 int32_t& events(mDisplayData[disp].events);
482 events = (events & ~eventBit) | newValue;
483 }
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -0700484 }
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700485 // error here should not happen -- not sure what we should
486 // do if it does.
487 ALOGE_IF(err, "eventControl(%d, %d) failed %s",
488 event, enabled, strerror(-err));
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700489 }
Mathias Agopian3a778712012-04-09 14:16:47 -0700490
491 if (err == NO_ERROR && mVSyncThread != NULL) {
492 mVSyncThread->setEnabled(enabled);
493 }
Mathias Agopian31d28432012-04-03 16:31:39 -0700494}
495
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700496status_t HWComposer::createWorkList(int32_t id, size_t numLayers) {
Mathias Agopianf4358632012-08-22 17:16:19 -0700497 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) {
Mathias Agopian1e260872012-08-08 18:35:12 -0700498 return BAD_INDEX;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700499 }
Mathias Agopian1e260872012-08-08 18:35:12 -0700500
Mathias Agopian45721772010-08-12 15:03:26 -0700501 if (mHwc) {
Mathias Agopianf4358632012-08-22 17:16:19 -0700502 DisplayData& disp(mDisplayData[id]);
Mathias Agopianda27af92012-09-13 18:17:13 -0700503 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
504 // we need space for the HWC_FRAMEBUFFER_TARGET
505 numLayers++;
506 }
Andy McFadden13a082e2012-08-24 10:16:42 -0700507 if (disp.capacity < numLayers || disp.list == NULL) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700508 size_t size = sizeof(hwc_display_contents_1_t)
Mathias Agopianf4358632012-08-22 17:16:19 -0700509 + numLayers * sizeof(hwc_layer_1_t);
510 free(disp.list);
511 disp.list = (hwc_display_contents_1_t*)malloc(size);
512 disp.capacity = numLayers;
Mathias Agopian45721772010-08-12 15:03:26 -0700513 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700514 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
515 disp.framebufferTarget = &disp.list->hwLayers[numLayers - 1];
516 memset(disp.framebufferTarget, 0, sizeof(hwc_layer_1_t));
Andy McFadden8f06a8c2013-01-11 10:24:34 -0800517 const hwc_rect_t r = { 0, 0, (int) disp.width, (int) disp.height };
Mathias Agopianda27af92012-09-13 18:17:13 -0700518 disp.framebufferTarget->compositionType = HWC_FRAMEBUFFER_TARGET;
519 disp.framebufferTarget->hints = 0;
520 disp.framebufferTarget->flags = 0;
521 disp.framebufferTarget->handle = disp.fbTargetHandle;
522 disp.framebufferTarget->transform = 0;
523 disp.framebufferTarget->blending = HWC_BLENDING_PREMULT;
524 disp.framebufferTarget->sourceCrop = r;
525 disp.framebufferTarget->displayFrame = r;
526 disp.framebufferTarget->visibleRegionScreen.numRects = 1;
527 disp.framebufferTarget->visibleRegionScreen.rects =
528 &disp.framebufferTarget->displayFrame;
529 disp.framebufferTarget->acquireFenceFd = -1;
530 disp.framebufferTarget->releaseFenceFd = -1;
Mathias Agopian70a6e882013-03-21 16:25:12 -0700531 disp.framebufferTarget->planeAlpha = 0xFF;
Mathias Agopianda27af92012-09-13 18:17:13 -0700532 }
Jesse Halldb276212012-09-07 11:20:56 -0700533 disp.list->retireFenceFd = -1;
Mathias Agopianf4358632012-08-22 17:16:19 -0700534 disp.list->flags = HWC_GEOMETRY_CHANGED;
535 disp.list->numHwLayers = numLayers;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700536 }
537 return NO_ERROR;
538}
539
Mathias Agopianda27af92012-09-13 18:17:13 -0700540status_t HWComposer::setFramebufferTarget(int32_t id,
541 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buf) {
542 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) {
543 return BAD_INDEX;
544 }
545 DisplayData& disp(mDisplayData[id]);
546 if (!disp.framebufferTarget) {
547 // this should never happen, but apparently eglCreateWindowSurface()
Mathias Agopiane3c697f2013-02-14 17:11:02 -0800548 // triggers a Surface::queueBuffer() on some
Mathias Agopianda27af92012-09-13 18:17:13 -0700549 // devices (!?) -- log and ignore.
550 ALOGE("HWComposer: framebufferTarget is null");
Mathias Agopianda27af92012-09-13 18:17:13 -0700551 return NO_ERROR;
552 }
553
554 int acquireFenceFd = -1;
Jamie Gennis1df8c342012-12-20 14:05:45 -0800555 if (acquireFence->isValid()) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700556 acquireFenceFd = acquireFence->dup();
557 }
558
559 // ALOGD("fbPost: handle=%p, fence=%d", buf->handle, acquireFenceFd);
560 disp.fbTargetHandle = buf->handle;
561 disp.framebufferTarget->handle = disp.fbTargetHandle;
562 disp.framebufferTarget->acquireFenceFd = acquireFenceFd;
563 return NO_ERROR;
564}
565
Mathias Agopiane60b0682012-08-21 23:34:09 -0700566status_t HWComposer::prepare() {
Mathias Agopianf4358632012-08-22 17:16:19 -0700567 for (size_t i=0 ; i<mNumDisplays ; i++) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700568 DisplayData& disp(mDisplayData[i]);
569 if (disp.framebufferTarget) {
570 // make sure to reset the type to HWC_FRAMEBUFFER_TARGET
571 // DO NOT reset the handle field to NULL, because it's possible
572 // that we have nothing to redraw (eg: eglSwapBuffers() not called)
573 // in which case, we should continue to use the same buffer.
Andy McFadden27ec5732012-10-02 19:04:45 -0700574 LOG_FATAL_IF(disp.list == NULL);
Mathias Agopianda27af92012-09-13 18:17:13 -0700575 disp.framebufferTarget->compositionType = HWC_FRAMEBUFFER_TARGET;
576 }
Andy McFadden27ec5732012-10-02 19:04:45 -0700577 if (!disp.connected && disp.list != NULL) {
578 ALOGW("WARNING: disp %d: connected, non-null list, layers=%d",
579 i, disp.list->numHwLayers);
580 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700581 mLists[i] = disp.list;
Mathias Agopianf4358632012-08-22 17:16:19 -0700582 if (mLists[i]) {
Jesse Hall38efe862013-04-06 23:12:29 -0700583 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) {
Jesse Halldb276212012-09-07 11:20:56 -0700584 mLists[i]->outbuf = NULL;
585 mLists[i]->outbufAcquireFenceFd = -1;
586 } else if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
587 // garbage data to catch improper use
588 mLists[i]->dpy = (hwc_display_t)0xDEADBEEF;
589 mLists[i]->sur = (hwc_surface_t)0xDEADBEEF;
590 } else {
591 mLists[i]->dpy = EGL_NO_DISPLAY;
592 mLists[i]->sur = EGL_NO_SURFACE;
593 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700594 }
595 }
Jesse Halldb276212012-09-07 11:20:56 -0700596
Mathias Agopianf4358632012-08-22 17:16:19 -0700597 int err = mHwc->prepare(mHwc, mNumDisplays, mLists);
Mathias Agopianda27af92012-09-13 18:17:13 -0700598 ALOGE_IF(err, "HWComposer: prepare failed (%s)", strerror(-err));
599
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700600 if (err == NO_ERROR) {
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700601 // here we're just making sure that "skip" layers are set
602 // to HWC_FRAMEBUFFER and we're also counting how many layers
603 // we have of each type.
Mathias Agopianf4358632012-08-22 17:16:19 -0700604 for (size_t i=0 ; i<mNumDisplays ; i++) {
605 DisplayData& disp(mDisplayData[i]);
606 disp.hasFbComp = false;
607 disp.hasOvComp = false;
608 if (disp.list) {
609 for (size_t i=0 ; i<disp.list->numHwLayers ; i++) {
610 hwc_layer_1_t& l = disp.list->hwLayers[i];
Mathias Agopianda27af92012-09-13 18:17:13 -0700611
612 //ALOGD("prepare: %d, type=%d, handle=%p",
613 // i, l.compositionType, l.handle);
614
Mathias Agopianf4358632012-08-22 17:16:19 -0700615 if (l.flags & HWC_SKIP_LAYER) {
616 l.compositionType = HWC_FRAMEBUFFER;
617 }
618 if (l.compositionType == HWC_FRAMEBUFFER) {
619 disp.hasFbComp = true;
620 }
621 if (l.compositionType == HWC_OVERLAY) {
622 disp.hasOvComp = true;
623 }
624 }
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700625 }
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700626 }
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700627 }
Mathias Agopiana350ff92010-08-10 17:14:02 -0700628 return (status_t)err;
629}
630
Mathias Agopiane60b0682012-08-21 23:34:09 -0700631bool HWComposer::hasHwcComposition(int32_t id) const {
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700632 if (!mHwc || uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
Mathias Agopiane60b0682012-08-21 23:34:09 -0700633 return false;
634 return mDisplayData[id].hasOvComp;
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700635}
636
Mathias Agopiane60b0682012-08-21 23:34:09 -0700637bool HWComposer::hasGlesComposition(int32_t id) const {
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700638 if (!mHwc || uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
639 return true;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700640 return mDisplayData[id].hasFbComp;
641}
642
Jesse Hall13f01cb2013-03-20 11:37:21 -0700643sp<Fence> HWComposer::getAndResetReleaseFence(int32_t id) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700644 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
Jesse Hall13f01cb2013-03-20 11:37:21 -0700645 return Fence::NO_FENCE;
Mathias Agopianda27af92012-09-13 18:17:13 -0700646
647 int fd = INVALID_OPERATION;
648 if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
649 const DisplayData& disp(mDisplayData[id]);
650 if (disp.framebufferTarget) {
651 fd = disp.framebufferTarget->releaseFenceFd;
Jamie Gennisd30b36d2012-09-30 20:02:03 -0700652 disp.framebufferTarget->acquireFenceFd = -1;
Mathias Agopianda27af92012-09-13 18:17:13 -0700653 disp.framebufferTarget->releaseFenceFd = -1;
654 }
655 }
Jesse Hall13f01cb2013-03-20 11:37:21 -0700656 return fd >= 0 ? new Fence(fd) : Fence::NO_FENCE;
Mathias Agopianda27af92012-09-13 18:17:13 -0700657}
658
Mathias Agopian30bcc612012-08-22 15:39:48 -0700659status_t HWComposer::commit() {
Mathias Agopian86303202012-07-24 22:46:10 -0700660 int err = NO_ERROR;
661 if (mHwc) {
Jesse Hall9eb1eb52012-08-29 10:39:38 -0700662 if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
Mathias Agopian30bcc612012-08-22 15:39:48 -0700663 // On version 1.0, the OpenGL ES target surface is communicated
Mathias Agopianf4358632012-08-22 17:16:19 -0700664 // by the (dpy, sur) fields and we are guaranteed to have only
665 // a single display.
Mathias Agopian30bcc612012-08-22 15:39:48 -0700666 mLists[0]->dpy = eglGetCurrentDisplay();
667 mLists[0]->sur = eglGetCurrentSurface(EGL_DRAW);
Mathias Agopian86303202012-07-24 22:46:10 -0700668 }
Mathias Agopianf4358632012-08-22 17:16:19 -0700669
Jesse Hallafaf14b2013-03-20 13:42:29 -0700670 for (size_t i=VIRTUAL_DISPLAY_ID_BASE; i<mNumDisplays; i++) {
Jesse Hall80e0a392013-03-15 12:32:10 -0700671 DisplayData& disp(mDisplayData[i]);
Jesse Hall851cfe82013-03-20 13:44:00 -0700672 if (disp.outbufHandle) {
673 mLists[i]->outbuf = disp.outbufHandle;
Jesse Hall80e0a392013-03-15 12:32:10 -0700674 mLists[i]->outbufAcquireFenceFd =
Jesse Hall851cfe82013-03-20 13:44:00 -0700675 disp.outbufAcquireFence->dup();
Jesse Hall80e0a392013-03-15 12:32:10 -0700676 }
677 }
678
Mathias Agopian30bcc612012-08-22 15:39:48 -0700679 err = mHwc->set(mHwc, mNumDisplays, mLists);
Mathias Agopianf4358632012-08-22 17:16:19 -0700680
681 for (size_t i=0 ; i<mNumDisplays ; i++) {
682 DisplayData& disp(mDisplayData[i]);
Jamie Gennis2ec3e072012-11-11 16:24:33 -0800683 disp.lastDisplayFence = disp.lastRetireFence;
Jamie Gennis1df8c342012-12-20 14:05:45 -0800684 disp.lastRetireFence = Fence::NO_FENCE;
Mathias Agopianf4358632012-08-22 17:16:19 -0700685 if (disp.list) {
Jesse Halldb276212012-09-07 11:20:56 -0700686 if (disp.list->retireFenceFd != -1) {
Jamie Gennis2ec3e072012-11-11 16:24:33 -0800687 disp.lastRetireFence = new Fence(disp.list->retireFenceFd);
Jesse Halldb276212012-09-07 11:20:56 -0700688 disp.list->retireFenceFd = -1;
Mathias Agopianf4358632012-08-22 17:16:19 -0700689 }
690 disp.list->flags &= ~HWC_GEOMETRY_CHANGED;
691 }
Mathias Agopian30bcc612012-08-22 15:39:48 -0700692 }
Mathias Agopian58959342010-10-07 14:57:04 -0700693 }
Mathias Agopiana350ff92010-08-10 17:14:02 -0700694 return (status_t)err;
695}
696
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700697status_t HWComposer::release(int disp) {
Jesse Hallafaf14b2013-03-20 13:42:29 -0700698 LOG_FATAL_IF(disp >= VIRTUAL_DISPLAY_ID_BASE);
Mathias Agopian7ee4cd52011-09-02 12:22:39 -0700699 if (mHwc) {
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700700 eventControl(disp, HWC_EVENT_VSYNC, 0);
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700701 return (status_t)mHwc->blank(mHwc, disp, 1);
Mathias Agopian7ee4cd52011-09-02 12:22:39 -0700702 }
703 return NO_ERROR;
704}
705
Mathias Agopian81cd5d32012-10-04 02:34:38 -0700706status_t HWComposer::acquire(int disp) {
Jesse Hallafaf14b2013-03-20 13:42:29 -0700707 LOG_FATAL_IF(disp >= VIRTUAL_DISPLAY_ID_BASE);
Colin Cross10fbdb62012-07-12 17:56:34 -0700708 if (mHwc) {
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700709 return (status_t)mHwc->blank(mHwc, disp, 0);
Colin Cross10fbdb62012-07-12 17:56:34 -0700710 }
Colin Cross10fbdb62012-07-12 17:56:34 -0700711 return NO_ERROR;
712}
713
Andy McFadden27ec5732012-10-02 19:04:45 -0700714void HWComposer::disconnectDisplay(int disp) {
Andy McFadden5a8f9012012-10-04 19:09:45 -0700715 LOG_ALWAYS_FATAL_IF(disp < 0 || disp == HWC_DISPLAY_PRIMARY);
Andy McFadden27ec5732012-10-02 19:04:45 -0700716 DisplayData& dd(mDisplayData[disp]);
Jesse Hall851cfe82013-03-20 13:44:00 -0700717 free(dd.list);
718 dd.list = NULL;
719 dd.framebufferTarget = NULL; // points into dd.list
720 dd.fbTargetHandle = NULL;
721 dd.outbufHandle = NULL;
722 dd.lastRetireFence = Fence::NO_FENCE;
723 dd.lastDisplayFence = Fence::NO_FENCE;
724 dd.outbufAcquireFence = Fence::NO_FENCE;
Andy McFadden27ec5732012-10-02 19:04:45 -0700725}
726
Mathias Agopiancde87a32012-09-13 14:09:01 -0700727int HWComposer::getVisualID() const {
Jesse Halld3d35f12012-09-18 11:39:40 -0700728 if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700729 // FIXME: temporary hack until HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
730 // is supported by the implementation. we can only be in this case
731 // if we have HWC 1.1
732 return HAL_PIXEL_FORMAT_RGBA_8888;
733 //return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700734 } else {
Mathias Agopiancde87a32012-09-13 14:09:01 -0700735 return mFbDev->format;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700736 }
737}
738
Mathias Agopianda27af92012-09-13 18:17:13 -0700739bool HWComposer::supportsFramebufferTarget() const {
740 return (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1));
741}
742
743int HWComposer::fbPost(int32_t id,
744 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buffer) {
Jesse Halld3d35f12012-09-18 11:39:40 -0700745 if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700746 return setFramebufferTarget(id, acquireFence, buffer);
747 } else {
Mathias Agopianea74d3b2013-05-16 18:03:22 -0700748 acquireFence->waitForever("HWComposer::fbPost");
Mathias Agopianda27af92012-09-13 18:17:13 -0700749 return mFbDev->post(mFbDev, buffer->handle);
Mathias Agopiancde87a32012-09-13 14:09:01 -0700750 }
Mathias Agopiancde87a32012-09-13 14:09:01 -0700751}
752
753int HWComposer::fbCompositionComplete() {
Jesse Halld3d35f12012-09-18 11:39:40 -0700754 if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1))
Mathias Agopianda27af92012-09-13 18:17:13 -0700755 return NO_ERROR;
756
757 if (mFbDev->compositionComplete) {
758 return mFbDev->compositionComplete(mFbDev);
759 } else {
760 return INVALID_OPERATION;
Mathias Agopiancde87a32012-09-13 14:09:01 -0700761 }
Mathias Agopiancde87a32012-09-13 14:09:01 -0700762}
763
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700764void HWComposer::fbDump(String8& result) {
Mathias Agopiancde87a32012-09-13 14:09:01 -0700765 if (mFbDev && mFbDev->common.version >= 1 && mFbDev->dump) {
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700766 const size_t SIZE = 4096;
767 char buffer[SIZE];
768 mFbDev->dump(mFbDev, buffer, SIZE);
769 result.append(buffer);
770 }
771}
772
Jesse Hall851cfe82013-03-20 13:44:00 -0700773status_t HWComposer::setOutputBuffer(int32_t id, const sp<Fence>& acquireFence,
774 const sp<GraphicBuffer>& buf) {
775 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
776 return BAD_INDEX;
777 if (id < VIRTUAL_DISPLAY_ID_BASE)
778 return INVALID_OPERATION;
779
780 DisplayData& disp(mDisplayData[id]);
781 disp.outbufHandle = buf->handle;
782 disp.outbufAcquireFence = acquireFence;
783 return NO_ERROR;
784}
785
786sp<Fence> HWComposer::getLastRetireFence(int32_t id) {
787 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id))
788 return Fence::NO_FENCE;
789 return mDisplayData[id].lastRetireFence;
790}
791
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700792/*
793 * Helper template to implement a concrete HWCLayer
794 * This holds the pointer to the concrete hwc layer type
795 * and implements the "iterable" side of HWCLayer.
796 */
797template<typename CONCRETE, typename HWCTYPE>
798class Iterable : public HWComposer::HWCLayer {
799protected:
800 HWCTYPE* const mLayerList;
801 HWCTYPE* mCurrentLayer;
802 Iterable(HWCTYPE* layer) : mLayerList(layer), mCurrentLayer(layer) { }
803 inline HWCTYPE const * getLayer() const { return mCurrentLayer; }
804 inline HWCTYPE* getLayer() { return mCurrentLayer; }
805 virtual ~Iterable() { }
806private:
807 // returns a copy of ourselves
808 virtual HWComposer::HWCLayer* dup() {
809 return new CONCRETE( static_cast<const CONCRETE&>(*this) );
810 }
811 virtual status_t setLayer(size_t index) {
812 mCurrentLayer = &mLayerList[index];
813 return NO_ERROR;
814 }
815};
816
Jesse Hall5880cc52012-06-05 23:40:32 -0700817/*
818 * Concrete implementation of HWCLayer for HWC_DEVICE_API_VERSION_1_0.
819 * This implements the HWCLayer side of HWCIterableLayer.
820 */
821class HWCLayerVersion1 : public Iterable<HWCLayerVersion1, hwc_layer_1_t> {
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800822 struct hwc_composer_device_1* mHwc;
Jesse Hall5880cc52012-06-05 23:40:32 -0700823public:
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800824 HWCLayerVersion1(struct hwc_composer_device_1* hwc, hwc_layer_1_t* layer)
825 : Iterable<HWCLayerVersion1, hwc_layer_1_t>(layer), mHwc(hwc) { }
Jesse Hall5880cc52012-06-05 23:40:32 -0700826
827 virtual int32_t getCompositionType() const {
828 return getLayer()->compositionType;
829 }
830 virtual uint32_t getHints() const {
831 return getLayer()->hints;
832 }
Jesse Hall13f01cb2013-03-20 11:37:21 -0700833 virtual sp<Fence> getAndResetReleaseFence() {
Jesse Hallef194142012-06-14 14:45:17 -0700834 int fd = getLayer()->releaseFenceFd;
835 getLayer()->releaseFenceFd = -1;
Jesse Hall13f01cb2013-03-20 11:37:21 -0700836 return fd >= 0 ? new Fence(fd) : Fence::NO_FENCE;
Jesse Hallef194142012-06-14 14:45:17 -0700837 }
Jesse Halldc5b4852012-06-29 15:21:18 -0700838 virtual void setAcquireFenceFd(int fenceFd) {
839 getLayer()->acquireFenceFd = fenceFd;
840 }
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800841 virtual void setPerFrameDefaultState() {
842 //getLayer()->compositionType = HWC_FRAMEBUFFER;
843 }
844 virtual void setPlaneAlpha(uint8_t alpha) {
845 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_2)) {
846 getLayer()->planeAlpha = alpha;
847 } else {
Mathias Agopian5fe58b82013-02-07 16:22:50 -0800848 if (alpha < 0xFF) {
849 getLayer()->flags |= HWC_SKIP_LAYER;
850 }
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800851 }
852 }
Jesse Hall5880cc52012-06-05 23:40:32 -0700853 virtual void setDefaultState() {
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800854 hwc_layer_1_t* const l = getLayer();
855 l->compositionType = HWC_FRAMEBUFFER;
856 l->hints = 0;
857 l->flags = HWC_SKIP_LAYER;
858 l->handle = 0;
859 l->transform = 0;
860 l->blending = HWC_BLENDING_NONE;
861 l->visibleRegionScreen.numRects = 0;
862 l->visibleRegionScreen.rects = NULL;
863 l->acquireFenceFd = -1;
864 l->releaseFenceFd = -1;
865 l->planeAlpha = 0xFF;
Jesse Hall5880cc52012-06-05 23:40:32 -0700866 }
867 virtual void setSkip(bool skip) {
868 if (skip) {
869 getLayer()->flags |= HWC_SKIP_LAYER;
870 } else {
871 getLayer()->flags &= ~HWC_SKIP_LAYER;
872 }
873 }
874 virtual void setBlending(uint32_t blending) {
875 getLayer()->blending = blending;
876 }
877 virtual void setTransform(uint32_t transform) {
878 getLayer()->transform = transform;
879 }
880 virtual void setFrame(const Rect& frame) {
Mathias Agopian6b442672013-07-09 21:24:52 -0700881 getLayer()->displayFrame = reinterpret_cast<hwc_rect_t const&>(frame);
Jesse Hall5880cc52012-06-05 23:40:32 -0700882 }
Mathias Agopian6b442672013-07-09 21:24:52 -0700883 virtual void setCrop(const FloatRect& crop) {
884 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) {
885 getLayer()->sourceCropf = reinterpret_cast<hwc_frect_t const&>(crop);
886 } else {
887 /*
888 * Since h/w composer didn't support a flot crop rect before version 1.3,
889 * using integer coordinates instead produces a different output from the GL code in
890 * Layer::drawWithOpenGL(). The difference can be large if the buffer crop to
891 * window size ratio is large and a window crop is defined
892 * (i.e.: if we scale the buffer a lot and we also crop it with a window crop).
893 */
894 hwc_rect_t& r = getLayer()->sourceCrop;
895 r.left = int(ceilf(crop.left));
896 r.top = int(ceilf(crop.top));
897 r.right = int(floorf(crop.right));
898 r.bottom= int(floorf(crop.bottom));
899 }
Jesse Hall5880cc52012-06-05 23:40:32 -0700900 }
901 virtual void setVisibleRegionScreen(const Region& reg) {
Mathias Agopianc3973602012-08-31 17:51:25 -0700902 // Region::getSharedBuffer creates a reference to the underlying
903 // SharedBuffer of this Region, this reference is freed
904 // in onDisplayed()
905 hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen;
906 SharedBuffer const* sb = reg.getSharedBuffer(&visibleRegion.numRects);
907 visibleRegion.rects = reinterpret_cast<hwc_rect_t const *>(sb->data());
Jesse Hall5880cc52012-06-05 23:40:32 -0700908 }
909 virtual void setBuffer(const sp<GraphicBuffer>& buffer) {
910 if (buffer == 0 || buffer->handle == 0) {
911 getLayer()->compositionType = HWC_FRAMEBUFFER;
912 getLayer()->flags |= HWC_SKIP_LAYER;
913 getLayer()->handle = 0;
914 } else {
915 getLayer()->handle = buffer->handle;
916 }
917 }
Mathias Agopianc3973602012-08-31 17:51:25 -0700918 virtual void onDisplayed() {
919 hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen;
920 SharedBuffer const* sb = SharedBuffer::bufferFromData(visibleRegion.rects);
921 if (sb) {
922 sb->release();
923 // not technically needed but safer
924 visibleRegion.numRects = 0;
925 visibleRegion.rects = NULL;
926 }
Jesse Halle25d0052012-09-05 13:03:10 -0700927
928 getLayer()->acquireFenceFd = -1;
Mathias Agopianc3973602012-08-31 17:51:25 -0700929 }
Jesse Hall5880cc52012-06-05 23:40:32 -0700930};
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700931
932/*
933 * returns an iterator initialized at a given index in the layer list
934 */
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700935HWComposer::LayerListIterator HWComposer::getLayerIterator(int32_t id, size_t index) {
Mathias Agopianf4358632012-08-22 17:16:19 -0700936 if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) {
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700937 return LayerListIterator();
Mathias Agopianf4358632012-08-22 17:16:19 -0700938 }
939 const DisplayData& disp(mDisplayData[id]);
940 if (!mHwc || !disp.list || index > disp.list->numHwLayers) {
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700941 return LayerListIterator();
Mathias Agopianf4358632012-08-22 17:16:19 -0700942 }
Mathias Agopian9f8386e2013-01-29 18:56:42 -0800943 return LayerListIterator(new HWCLayerVersion1(mHwc, disp.list->hwLayers), index);
Mathias Agopiana350ff92010-08-10 17:14:02 -0700944}
945
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700946/*
947 * returns an iterator on the beginning of the layer list
948 */
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700949HWComposer::LayerListIterator HWComposer::begin(int32_t id) {
Mathias Agopian1e260872012-08-08 18:35:12 -0700950 return getLayerIterator(id, 0);
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700951}
952
953/*
954 * returns an iterator on the end of the layer list
955 */
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700956HWComposer::LayerListIterator HWComposer::end(int32_t id) {
Mathias Agopianda27af92012-09-13 18:17:13 -0700957 size_t numLayers = 0;
958 if (uint32_t(id) <= 31 && mAllocatedDisplayIDs.hasBit(id)) {
959 const DisplayData& disp(mDisplayData[id]);
960 if (mHwc && disp.list) {
961 numLayers = disp.list->numHwLayers;
962 if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) {
963 // with HWC 1.1, the last layer is always the HWC_FRAMEBUFFER_TARGET,
964 // which we ignore when iterating through the layer list.
965 ALOGE_IF(!numLayers, "mDisplayData[%d].list->numHwLayers is 0", id);
966 if (numLayers) {
967 numLayers--;
968 }
969 }
970 }
971 }
972 return getLayerIterator(id, numLayers);
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700973}
974
Mathias Agopian74d211a2013-04-22 16:55:35 +0200975void HWComposer::dump(String8& result) const {
Jesse Hallb685c542012-07-31 14:32:56 -0700976 if (mHwc) {
Mathias Agopiancde87a32012-09-13 14:09:01 -0700977 result.appendFormat("Hardware Composer state (version %8x):\n", hwcApiVersion(mHwc));
Mathias Agopianf4358632012-08-22 17:16:19 -0700978 result.appendFormat(" mDebugForceFakeVSync=%d\n", mDebugForceFakeVSync);
979 for (size_t i=0 ; i<mNumDisplays ; i++) {
980 const DisplayData& disp(mDisplayData[i]);
Jesse Hall02d86562013-03-25 14:43:23 -0700981 if (!disp.connected)
982 continue;
Mathias Agopianb4d18ed2012-09-20 23:14:05 -0700983
Mathias Agopian13127d82013-03-05 17:47:11 -0800984 const Vector< sp<Layer> >& visibleLayersSortedByZ =
Mathias Agopiancb558572012-10-04 15:58:54 -0700985 mFlinger->getLayerSortedByZForHwcDisplay(i);
986
Jesse Hall02d86562013-03-25 14:43:23 -0700987 result.appendFormat(
988 " Display[%d] : %ux%u, xdpi=%f, ydpi=%f, refresh=%lld\n",
989 i, disp.width, disp.height, disp.xdpi, disp.ydpi, disp.refresh);
Mathias Agopianb4d18ed2012-09-20 23:14:05 -0700990
Jesse Hall02d86562013-03-25 14:43:23 -0700991 if (disp.list) {
Mathias Agopianb4d18ed2012-09-20 23:14:05 -0700992 result.appendFormat(
993 " numHwLayers=%u, flags=%08x\n",
994 disp.list->numHwLayers, disp.list->flags);
995
Mathias Agopianf4358632012-08-22 17:16:19 -0700996 result.append(
Mathias Agopianda27af92012-09-13 18:17:13 -0700997 " type | handle | hints | flags | tr | blend | format | source crop | frame name \n"
998 "------------+----------+----------+----------+----+-------+----------+---------------------------+--------------------------------\n");
999 // " __________ | ________ | ________ | ________ | __ | _____ | ________ | [_____,_____,_____,_____] | [_____,_____,_____,_____]
Mathias Agopianf4358632012-08-22 17:16:19 -07001000 for (size_t i=0 ; i<disp.list->numHwLayers ; i++) {
1001 const hwc_layer_1_t&l = disp.list->hwLayers[i];
Mathias Agopianf4358632012-08-22 17:16:19 -07001002 int32_t format = -1;
Mathias Agopianda27af92012-09-13 18:17:13 -07001003 String8 name("unknown");
Mathias Agopiancb558572012-10-04 15:58:54 -07001004
Mathias Agopianda27af92012-09-13 18:17:13 -07001005 if (i < visibleLayersSortedByZ.size()) {
Mathias Agopian13127d82013-03-05 17:47:11 -08001006 const sp<Layer>& layer(visibleLayersSortedByZ[i]);
1007 const sp<GraphicBuffer>& buffer(
1008 layer->getActiveBuffer());
1009 if (buffer != NULL) {
1010 format = buffer->getPixelFormat();
Mathias Agopianf4358632012-08-22 17:16:19 -07001011 }
Mathias Agopianda27af92012-09-13 18:17:13 -07001012 name = layer->getName();
Mathias Agopianf4358632012-08-22 17:16:19 -07001013 }
Mathias Agopianda27af92012-09-13 18:17:13 -07001014
1015 int type = l.compositionType;
1016 if (type == HWC_FRAMEBUFFER_TARGET) {
1017 name = "HWC_FRAMEBUFFER_TARGET";
1018 format = disp.format;
1019 }
1020
1021 static char const* compositionTypeName[] = {
1022 "GLES",
1023 "HWC",
1024 "BACKGROUND",
1025 "FB TARGET",
1026 "UNKNOWN"};
1027 if (type >= NELEM(compositionTypeName))
1028 type = NELEM(compositionTypeName) - 1;
1029
Mathias Agopianf4358632012-08-22 17:16:19 -07001030 result.appendFormat(
Mathias Agopianda27af92012-09-13 18:17:13 -07001031 " %10s | %08x | %08x | %08x | %02x | %05x | %08x | [%5d,%5d,%5d,%5d] | [%5d,%5d,%5d,%5d] %s\n",
1032 compositionTypeName[type],
Mathias Agopianf4358632012-08-22 17:16:19 -07001033 intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, format,
1034 l.sourceCrop.left, l.sourceCrop.top, l.sourceCrop.right, l.sourceCrop.bottom,
1035 l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom,
Mathias Agopianda27af92012-09-13 18:17:13 -07001036 name.string());
Mathias Agopianfb4d5d52011-09-20 15:13:14 -07001037 }
1038 }
Mathias Agopian83727852010-09-23 18:13:21 -07001039 }
Erik Gilling1d21a9c2010-12-01 16:38:01 -08001040 }
Mathias Agopian30bcc612012-08-22 15:39:48 -07001041
1042 if (mHwc && mHwc->dump) {
Mathias Agopian74d211a2013-04-22 16:55:35 +02001043 const size_t SIZE = 4096;
1044 char buffer[SIZE];
Mathias Agopian30bcc612012-08-22 15:39:48 -07001045 mHwc->dump(mHwc, buffer, SIZE);
Erik Gilling1d21a9c2010-12-01 16:38:01 -08001046 result.append(buffer);
Mathias Agopian83727852010-09-23 18:13:21 -07001047 }
1048}
1049
Mathias Agopiana350ff92010-08-10 17:14:02 -07001050// ---------------------------------------------------------------------------
Mathias Agopian2965b262012-04-08 15:13:32 -07001051
1052HWComposer::VSyncThread::VSyncThread(HWComposer& hwc)
1053 : mHwc(hwc), mEnabled(false),
1054 mNextFakeVSync(0),
Andy McFaddenb0d1dd32012-09-10 14:08:09 -07001055 mRefreshPeriod(hwc.getRefreshPeriod(HWC_DISPLAY_PRIMARY))
Mathias Agopian2965b262012-04-08 15:13:32 -07001056{
1057}
1058
1059void HWComposer::VSyncThread::setEnabled(bool enabled) {
1060 Mutex::Autolock _l(mLock);
Mathias Agopian81cd5d32012-10-04 02:34:38 -07001061 if (mEnabled != enabled) {
1062 mEnabled = enabled;
1063 mCondition.signal();
1064 }
Mathias Agopian2965b262012-04-08 15:13:32 -07001065}
1066
1067void HWComposer::VSyncThread::onFirstRef() {
1068 run("VSyncThread", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE);
1069}
1070
1071bool HWComposer::VSyncThread::threadLoop() {
1072 { // scope for lock
1073 Mutex::Autolock _l(mLock);
1074 while (!mEnabled) {
1075 mCondition.wait(mLock);
1076 }
1077 }
1078
1079 const nsecs_t period = mRefreshPeriod;
1080 const nsecs_t now = systemTime(CLOCK_MONOTONIC);
1081 nsecs_t next_vsync = mNextFakeVSync;
1082 nsecs_t sleep = next_vsync - now;
1083 if (sleep < 0) {
1084 // we missed, find where the next vsync should be
1085 sleep = (period - ((now - next_vsync) % period));
1086 next_vsync = now + sleep;
1087 }
1088 mNextFakeVSync = next_vsync + period;
1089
1090 struct timespec spec;
1091 spec.tv_sec = next_vsync / 1000000000;
1092 spec.tv_nsec = next_vsync % 1000000000;
1093
1094 int err;
1095 do {
1096 err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL);
1097 } while (err<0 && errno == EINTR);
1098
1099 if (err == 0) {
1100 mHwc.mEventHandler.onVSyncReceived(0, next_vsync);
1101 }
1102
1103 return true;
1104}
1105
Jesse Halla9a1b002013-02-27 16:39:25 -08001106HWComposer::DisplayData::DisplayData()
1107: width(0), height(0), format(0),
1108 xdpi(0.0f), ydpi(0.0f),
1109 refresh(0),
1110 connected(false),
1111 hasFbComp(false), hasOvComp(false),
1112 capacity(0), list(NULL),
1113 framebufferTarget(NULL), fbTargetHandle(0),
1114 lastRetireFence(Fence::NO_FENCE), lastDisplayFence(Fence::NO_FENCE),
Jesse Hall851cfe82013-03-20 13:44:00 -07001115 outbufHandle(NULL), outbufAcquireFence(Fence::NO_FENCE),
Jesse Halla9a1b002013-02-27 16:39:25 -08001116 events(0)
1117{}
1118
1119HWComposer::DisplayData::~DisplayData() {
1120 free(list);
1121}
1122
Mathias Agopian2965b262012-04-08 15:13:32 -07001123// ---------------------------------------------------------------------------
Mathias Agopiana350ff92010-08-10 17:14:02 -07001124}; // namespace android