blob: 50528c7f7a9fb268672dcda8987d83488f45eb32 [file] [log] [blame]
Iliyan Malchev202a77d2012-06-11 14:41:12 -07001/*
Duy Truong73d36df2013-02-09 20:33:23 -08002 * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
Iliyan Malchev202a77d2012-06-11 14:41:12 -07003
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
Duy Truong73d36df2013-02-09 20:33:23 -080013 * * Neither the name of The Linux Foundation nor the names of its
Iliyan Malchev202a77d2012-06-11 14:41:12 -070014 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <cutils/log.h>
Iliyan Malchev202a77d2012-06-11 14:41:12 -070031#include <fcntl.h>
Naomi Luis01f5c8e2013-02-11 12:46:24 -080032#include <dlfcn.h>
Iliyan Malchev202a77d2012-06-11 14:41:12 -070033#include "gralloc_priv.h"
34#include "alloc_controller.h"
35#include "memalloc.h"
36#include "ionalloc.h"
Iliyan Malchev202a77d2012-06-11 14:41:12 -070037#include "gr.h"
Naseer Ahmeda87da602012-07-01 23:54:19 -070038#include "comptype.h"
Iliyan Malchev202a77d2012-06-11 14:41:12 -070039
Sushil Chauhanc6bd6d92012-12-12 12:33:01 -080040#ifdef VENUS_COLOR_FORMAT
41#include <media/msm_media_info.h>
42#else
43#define VENUS_Y_STRIDE(args...) 0
44#define VENUS_Y_SCANLINES(args...) 0
45#define VENUS_BUFFER_SIZE(args...) 0
46#endif
47
Iliyan Malchev202a77d2012-06-11 14:41:12 -070048using namespace gralloc;
Naseer Ahmeda87da602012-07-01 23:54:19 -070049using namespace qdutils;
Iliyan Malchev202a77d2012-06-11 14:41:12 -070050
Naomi Luisa44100c2013-02-08 12:42:03 -080051ANDROID_SINGLETON_STATIC_INSTANCE(AdrenoMemInfo);
52
Iliyan Malchev202a77d2012-06-11 14:41:12 -070053//Common functions
Naseer Ahmed29a26812012-06-14 00:56:20 -070054static bool canFallback(int usage, bool triedSystem)
Iliyan Malchev202a77d2012-06-11 14:41:12 -070055{
56 // Fallback to system heap when alloc fails unless
57 // 1. Composition type is MDP
58 // 2. Alloc from system heap was already tried
59 // 3. The heap type is requsted explicitly
60 // 4. The heap type is protected
61 // 5. The buffer is meant for external display only
62
Naseer Ahmeda87da602012-07-01 23:54:19 -070063 if(QCCompositionType::getInstance().getCompositionType() &
64 COMPOSITION_TYPE_MDP)
Iliyan Malchev202a77d2012-06-11 14:41:12 -070065 return false;
66 if(triedSystem)
67 return false;
Sushil Chauhan7651a802013-01-08 16:08:09 -080068 if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_PROTECTED))
Iliyan Malchev202a77d2012-06-11 14:41:12 -070069 return false;
Naseer Ahmed4c588a22012-07-31 19:12:17 -070070 if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY))
Iliyan Malchev202a77d2012-06-11 14:41:12 -070071 return false;
72 //Return true by default
73 return true;
74}
75
76static bool useUncached(int usage)
77{
Arun Kumar K.R5a9bc432013-05-30 15:18:40 -070078 if (usage & GRALLOC_USAGE_PRIVATE_UNCACHED ||
79 usage & GRALLOC_USAGE_SW_WRITE_RARELY ||
80 usage & GRALLOC_USAGE_SW_READ_RARELY)
Iliyan Malchev202a77d2012-06-11 14:41:12 -070081 return true;
82 return false;
83}
84
Naomi Luisa44100c2013-02-08 12:42:03 -080085//-------------- AdrenoMemInfo-----------------------//
Naomi Luis01f5c8e2013-02-11 12:46:24 -080086AdrenoMemInfo::AdrenoMemInfo()
87{
88 libadreno_utils = ::dlopen("libadreno_utils.so", RTLD_NOW);
89 if (libadreno_utils) {
90 *(void **)&LINK_adreno_compute_padding = ::dlsym(libadreno_utils,
91 "compute_surface_padding");
92 }
93}
94
95AdrenoMemInfo::~AdrenoMemInfo()
96{
97 if (libadreno_utils) {
98 ::dlclose(libadreno_utils);
99 }
100}
101
Naomi Luisa44100c2013-02-08 12:42:03 -0800102int AdrenoMemInfo::getStride(int width, int format)
103{
104 int stride = ALIGN(width, 32);
Naomi Luis01f5c8e2013-02-11 12:46:24 -0800105 // Currently surface padding is only computed for RGB* surfaces.
106 if (format < 0x7) {
Naomi Luis1b379692013-05-06 12:13:07 -0700107 // Don't add any additional padding if debug.gralloc.map_fb_memory
108 // is enabled
109 char property[PROPERTY_VALUE_MAX];
110 if((property_get("debug.gralloc.map_fb_memory", property, NULL) > 0) &&
111 (!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
112 (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
113 return stride;
114 }
115
Naomi Luis01f5c8e2013-02-11 12:46:24 -0800116 int bpp = 4;
117 switch(format)
118 {
119 case HAL_PIXEL_FORMAT_RGB_888:
120 bpp = 3;
121 break;
122 case HAL_PIXEL_FORMAT_RGB_565:
123 case HAL_PIXEL_FORMAT_RGBA_5551:
124 case HAL_PIXEL_FORMAT_RGBA_4444:
125 bpp = 2;
126 break;
127 default: break;
128 }
129 if ((libadreno_utils) && (LINK_adreno_compute_padding)) {
130 int surface_tile_height = 1; // Linear surface
Naomi Luisb65b2342013-03-27 23:32:06 -0700131 int raster_mode = 0; // Adreno unknown raster mode.
Naomi Luis01f5c8e2013-02-11 12:46:24 -0800132 int padding_threshold = 512; // Threshold for padding surfaces.
133 // the function below expects the width to be a multiple of
134 // 32 pixels, hence we pass stride instead of width.
135 stride = LINK_adreno_compute_padding(stride, bpp,
136 surface_tile_height, raster_mode,
137 padding_threshold);
138 }
139 } else {
140 switch (format)
141 {
142 case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:
Naseer Ahmed7669dae2013-04-17 20:23:53 -0400143 case HAL_PIXEL_FORMAT_RAW_SENSOR:
Naomi Luis01f5c8e2013-02-11 12:46:24 -0800144 stride = ALIGN(width, 32);
145 break;
146 case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
147 stride = ALIGN(width, 128);
148 break;
Naomi Luis01f5c8e2013-02-11 12:46:24 -0800149 case HAL_PIXEL_FORMAT_YCbCr_420_SP:
150 case HAL_PIXEL_FORMAT_YCrCb_420_SP:
151 case HAL_PIXEL_FORMAT_YV12:
152 case HAL_PIXEL_FORMAT_YCbCr_422_SP:
153 case HAL_PIXEL_FORMAT_YCrCb_422_SP:
154 stride = ALIGN(width, 16);
155 break;
156 case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
Naseer Ahmedce0c9502013-08-15 13:07:24 -0400157 case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
Naomi Luis01f5c8e2013-02-11 12:46:24 -0800158 stride = VENUS_Y_STRIDE(COLOR_FMT_NV12, width);
159 break;
Naseer Ahmed7669dae2013-04-17 20:23:53 -0400160 case HAL_PIXEL_FORMAT_BLOB:
161 stride = width;
162 break;
Naomi Luis01f5c8e2013-02-11 12:46:24 -0800163 default: break;
164 }
Naomi Luisa44100c2013-02-08 12:42:03 -0800165 }
166 return stride;
167}
168
169//-------------- IAllocController-----------------------//
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700170IAllocController* IAllocController::sController = NULL;
171IAllocController* IAllocController::getInstance(void)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700172{
173 if(sController == NULL) {
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700174 sController = new IonController();
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700175 }
176 return sController;
177}
178
179
180//-------------- IonController-----------------------//
181IonController::IonController()
182{
183 mIonAlloc = new IonAlloc();
Prabhanjan Kandula92896b82013-05-07 19:58:24 +0530184 mUseTZProtection = false;
185 char property[PROPERTY_VALUE_MAX];
186 if ((property_get("persist.gralloc.cp.level3", property, NULL) <= 0) ||
187 (atoi(property) != 1)) {
188 mUseTZProtection = true;
189 }
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700190}
191
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700192int IonController::allocate(alloc_data& data, int usage)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700193{
194 int ionFlags = 0;
195 int ret;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700196
197 data.uncached = useUncached(usage);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700198 data.allocType = 0;
199
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700200 if(usage & GRALLOC_USAGE_PRIVATE_UI_CONTIG_HEAP)
201 ionFlags |= ION_HEAP(ION_SF_HEAP_ID);
202
Naseer Ahmedc5e6fb02013-03-07 13:42:20 -0500203 if(usage & GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700204 ionFlags |= ION_HEAP(ION_SYSTEM_HEAP_ID);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700205
Naseer Ahmedc5e6fb02013-03-07 13:42:20 -0500206 if(usage & GRALLOC_USAGE_PRIVATE_IOMMU_HEAP)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700207 ionFlags |= ION_HEAP(ION_IOMMU_HEAP_ID);
208
Prabhanjan Kandula92896b82013-05-07 19:58:24 +0530209 if(usage & GRALLOC_USAGE_PROTECTED) {
210 if ((mUseTZProtection) && (usage & GRALLOC_USAGE_PRIVATE_MM_HEAP)) {
Naseer Ahmedc5e6fb02013-03-07 13:42:20 -0500211 ionFlags |= ION_HEAP(ION_CP_MM_HEAP_ID);
212 ionFlags |= ION_SECURE;
Prabhanjan Kandula92896b82013-05-07 19:58:24 +0530213 } else {
214 // for targets/OEMs which do not need HW level protection
215 // do not set ion secure flag & MM heap. Fallback to IOMMU heap.
Naseer Ahmedc5e6fb02013-03-07 13:42:20 -0500216 ionFlags |= ION_HEAP(ION_IOMMU_HEAP_ID);
217 }
Prabhanjan Kandula92896b82013-05-07 19:58:24 +0530218 } else if(usage & GRALLOC_USAGE_PRIVATE_MM_HEAP) {
219 //MM Heap is exclusively a secure heap.
220 //If it is used for non secure cases, fallback to IOMMU heap
221 ALOGW("GRALLOC_USAGE_PRIVATE_MM_HEAP \
222 cannot be used as an insecure heap!\
223 trying to use IOMMU instead !!");
224 ionFlags |= ION_HEAP(ION_IOMMU_HEAP_ID);
Naseer Ahmedc5e6fb02013-03-07 13:42:20 -0500225 }
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700226
Arun Kumar K.Rff78b892013-05-24 12:37:51 -0700227 if(usage & GRALLOC_USAGE_PRIVATE_CAMERA_HEAP)
228 ionFlags |= ION_HEAP(ION_CAMERA_HEAP_ID);
229
Arun Kumar K.R0daaa992013-03-12 15:08:29 -0700230 if(usage & GRALLOC_USAGE_PRIVATE_ADSP_HEAP)
231 ionFlags |= ION_HEAP(ION_ADSP_HEAP_ID);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700232
Prabhanjan Kandula92896b82013-05-07 19:58:24 +0530233 if(ionFlags & ION_SECURE)
Naseer Ahmedc5e6fb02013-03-07 13:42:20 -0500234 data.allocType |= private_handle_t::PRIV_FLAGS_SECURE_BUFFER;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700235
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700236 // if no flags are set, default to
237 // SF + IOMMU heaps, so that bypass can work
238 // we can fall back to system heap if
239 // we run out.
240 if(!ionFlags)
241 ionFlags = ION_HEAP(ION_SF_HEAP_ID) | ION_HEAP(ION_IOMMU_HEAP_ID);
242
243 data.flags = ionFlags;
244 ret = mIonAlloc->alloc_buffer(data);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700245
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700246 // Fallback
Naseer Ahmed29a26812012-06-14 00:56:20 -0700247 if(ret < 0 && canFallback(usage,
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700248 (ionFlags & ION_SYSTEM_HEAP_ID)))
249 {
250 ALOGW("Falling back to system heap");
251 data.flags = ION_HEAP(ION_SYSTEM_HEAP_ID);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700252 ret = mIonAlloc->alloc_buffer(data);
253 }
254
255 if(ret >= 0 ) {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700256 data.allocType |= private_handle_t::PRIV_FLAGS_USES_ION;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700257 }
258
259 return ret;
260}
261
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700262IMemAlloc* IonController::getAllocator(int flags)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700263{
Naseer Ahmedb16edac2012-07-15 23:56:21 -0700264 IMemAlloc* memalloc = NULL;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700265 if (flags & private_handle_t::PRIV_FLAGS_USES_ION) {
266 memalloc = mIonAlloc;
267 } else {
268 ALOGE("%s: Invalid flags passed: 0x%x", __FUNCTION__, flags);
269 }
270
271 return memalloc;
272}
273
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700274size_t getBufferSizeAndDimensions(int width, int height, int format,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700275 int& alignedw, int &alignedh)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700276{
277 size_t size;
278
Naomi Luisa44100c2013-02-08 12:42:03 -0800279 alignedw = AdrenoMemInfo::getInstance().getStride(width, format);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700280 alignedh = ALIGN(height, 32);
281 switch (format) {
282 case HAL_PIXEL_FORMAT_RGBA_8888:
283 case HAL_PIXEL_FORMAT_RGBX_8888:
284 case HAL_PIXEL_FORMAT_BGRA_8888:
285 size = alignedw * alignedh * 4;
286 break;
287 case HAL_PIXEL_FORMAT_RGB_888:
288 size = alignedw * alignedh * 3;
289 break;
290 case HAL_PIXEL_FORMAT_RGB_565:
291 case HAL_PIXEL_FORMAT_RGBA_5551:
292 case HAL_PIXEL_FORMAT_RGBA_4444:
Naseer Ahmed7669dae2013-04-17 20:23:53 -0400293 case HAL_PIXEL_FORMAT_RAW_SENSOR:
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700294 size = alignedw * alignedh * 2;
295 break;
296
297 // adreno formats
298 case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO: // NV21
299 size = ALIGN(alignedw*alignedh, 4096);
300 size += ALIGN(2 * ALIGN(width/2, 32) * ALIGN(height/2, 32), 4096);
301 break;
302 case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED: // NV12
303 // The chroma plane is subsampled,
304 // but the pitch in bytes is unchanged
305 // The GPU needs 4K alignment, but the video decoder needs 8K
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700306 size = ALIGN( alignedw * alignedh, 8192);
307 size += ALIGN( alignedw * ALIGN(height/2, 32), 8192);
308 break;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700309 case HAL_PIXEL_FORMAT_YV12:
310 if ((format == HAL_PIXEL_FORMAT_YV12) && ((width&1) || (height&1))) {
311 ALOGE("w or h is odd for the YV12 format");
312 return -EINVAL;
313 }
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700314 alignedh = height;
Naseer Ahmedce0c9502013-08-15 13:07:24 -0400315 size = alignedw*alignedh +
Naseer Ahmed29a26812012-06-14 00:56:20 -0700316 (ALIGN(alignedw/2, 16) * (alignedh/2))*2;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700317 size = ALIGN(size, 4096);
318 break;
Ramkumar Radhakrishnan73f952a2013-03-05 14:14:24 -0800319 case HAL_PIXEL_FORMAT_YCbCr_420_SP:
320 case HAL_PIXEL_FORMAT_YCrCb_420_SP:
321 alignedh = height;
322 size = ALIGN((alignedw*alignedh) + (alignedw* alignedh)/2, 4096);
323 break;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700324 case HAL_PIXEL_FORMAT_YCbCr_422_SP:
325 case HAL_PIXEL_FORMAT_YCrCb_422_SP:
326 if(width & 1) {
327 ALOGE("width is odd for the YUV422_SP format");
328 return -EINVAL;
329 }
Naseer Ahmed29a26812012-06-14 00:56:20 -0700330 alignedh = height;
331 size = ALIGN(alignedw * alignedh * 2, 4096);
332 break;
Sushil Chauhanc5e61482012-08-22 17:13:32 -0700333 case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
Naseer Ahmedce0c9502013-08-15 13:07:24 -0400334 case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
Sushil Chauhan73dcce42012-11-15 14:25:19 -0800335 alignedh = VENUS_Y_SCANLINES(COLOR_FMT_NV12, height);
Sushil Chauhane8a01792012-11-01 16:25:45 -0700336 size = VENUS_BUFFER_SIZE(COLOR_FMT_NV12, width, height);
Sushil Chauhanc5e61482012-08-22 17:13:32 -0700337 break;
Naseer Ahmed7669dae2013-04-17 20:23:53 -0400338 case HAL_PIXEL_FORMAT_BLOB:
339 if(height != 1) {
340 ALOGE("%s: Buffers with format HAL_PIXEL_FORMAT_BLOB \
341 must have height==1 ", __FUNCTION__);
342 return -EINVAL;
343 }
344 alignedh = height;
345 alignedw = width;
346 size = width;
347 break;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700348 default:
Naseer Ahmed29a26812012-06-14 00:56:20 -0700349 ALOGE("unrecognized pixel format: 0x%x", format);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700350 return -EINVAL;
351 }
352
353 return size;
354}
355
356// Allocate buffer from width, height and format into a
357// private_handle_t. It is the responsibility of the caller
358// to free the buffer using the free_buffer function
359int alloc_buffer(private_handle_t **pHnd, int w, int h, int format, int usage)
360{
Naseer Ahmed29a26812012-06-14 00:56:20 -0700361 alloc_data data;
362 int alignedw, alignedh;
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700363 gralloc::IAllocController* sAlloc =
364 gralloc::IAllocController::getInstance();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700365 data.base = 0;
366 data.fd = -1;
367 data.offset = 0;
368 data.size = getBufferSizeAndDimensions(w, h, format, alignedw, alignedh);
369 data.align = getpagesize();
370 data.uncached = useUncached(usage);
371 int allocFlags = usage;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700372
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700373 int err = sAlloc->allocate(data, allocFlags);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700374 if (0 != err) {
375 ALOGE("%s: allocate failed", __FUNCTION__);
376 return -ENOMEM;
377 }
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700378
Naseer Ahmed29a26812012-06-14 00:56:20 -0700379 private_handle_t* hnd = new private_handle_t(data.fd, data.size,
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700380 data.allocType, 0, format,
381 alignedw, alignedh);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700382 hnd->base = (int) data.base;
383 hnd->offset = data.offset;
384 hnd->gpuaddr = 0;
385 *pHnd = hnd;
386 return 0;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700387}
388
389void free_buffer(private_handle_t *hnd)
390{
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700391 gralloc::IAllocController* sAlloc =
392 gralloc::IAllocController::getInstance();
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700393 if (hnd && hnd->fd > 0) {
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700394 IMemAlloc* memalloc = sAlloc->getAllocator(hnd->flags);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700395 memalloc->free_buffer((void*)hnd->base, hnd->size, hnd->offset, hnd->fd);
396 }
397 if(hnd)
398 delete hnd;
399
400}