Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Naseer Ahmed | a163b73 | 2013-02-12 14:53:33 -0500 | [diff] [blame] | 3 | * Copyright (c) 2011-2013 The Linux Foundation. All rights reserved. |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <limits.h> |
| 19 | #include <unistd.h> |
| 20 | #include <fcntl.h> |
| 21 | #include <cutils/properties.h> |
| 22 | #include <sys/mman.h> |
| 23 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 24 | #include "gr.h" |
| 25 | #include "gpu.h" |
| 26 | #include "memalloc.h" |
| 27 | #include "alloc_controller.h" |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 28 | #include <qdMetaData.h> |
Praveen Chavan | 4e931c1 | 2012-11-28 19:43:17 -0800 | [diff] [blame] | 29 | #include "mdp_version.h" |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 30 | |
| 31 | using namespace gralloc; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 32 | |
Praveen Chavan | 4e931c1 | 2012-11-28 19:43:17 -0800 | [diff] [blame] | 33 | #define SZ_1M 0x100000 |
| 34 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 35 | gpu_context_t::gpu_context_t(const private_module_t* module, |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 36 | IAllocController* alloc_ctrl ) : |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 37 | mAllocCtrl(alloc_ctrl) |
| 38 | { |
| 39 | // Zero out the alloc_device_t |
| 40 | memset(static_cast<alloc_device_t*>(this), 0, sizeof(alloc_device_t)); |
| 41 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 42 | // Initialize the procs |
| 43 | common.tag = HARDWARE_DEVICE_TAG; |
| 44 | common.version = 0; |
| 45 | common.module = const_cast<hw_module_t*>(&module->base.common); |
| 46 | common.close = gralloc_close; |
| 47 | alloc = gralloc_alloc; |
Naseer Ahmed | 7421472 | 2013-02-09 08:11:36 -0500 | [diff] [blame] | 48 | #ifdef QCOM_BSP |
Ramkumar Radhakrishnan | 3d4c0ac | 2012-12-10 15:42:54 -0800 | [diff] [blame] | 49 | allocSize = gralloc_alloc_size; |
Naseer Ahmed | 7421472 | 2013-02-09 08:11:36 -0500 | [diff] [blame] | 50 | #endif |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 51 | free = gralloc_free; |
| 52 | |
| 53 | } |
| 54 | |
| 55 | int gpu_context_t::gralloc_alloc_framebuffer_locked(size_t size, int usage, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 56 | buffer_handle_t* pHandle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 57 | { |
| 58 | private_module_t* m = reinterpret_cast<private_module_t*>(common.module); |
| 59 | |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 60 | // we don't support framebuffer allocations with graphics heap flags |
| 61 | if (usage & GRALLOC_HEAP_MASK) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 62 | return -EINVAL; |
| 63 | } |
| 64 | |
| 65 | if (m->framebuffer == NULL) { |
| 66 | ALOGE("%s: Invalid framebuffer", __FUNCTION__); |
| 67 | return -EINVAL; |
| 68 | } |
| 69 | |
| 70 | const uint32_t bufferMask = m->bufferMask; |
| 71 | const uint32_t numBuffers = m->numBuffers; |
| 72 | size_t bufferSize = m->finfo.line_length * m->info.yres; |
| 73 | |
| 74 | //adreno needs FB size to be page aligned |
| 75 | bufferSize = roundUpToPageSize(bufferSize); |
| 76 | |
| 77 | if (numBuffers == 1) { |
| 78 | // If we have only one buffer, we never use page-flipping. Instead, |
| 79 | // we return a regular buffer which will be memcpy'ed to the main |
| 80 | // screen when post is called. |
| 81 | int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D; |
| 82 | return gralloc_alloc_buffer(bufferSize, newUsage, pHandle, BUFFER_TYPE_UI, |
| 83 | m->fbFormat, m->info.xres, m->info.yres); |
| 84 | } |
| 85 | |
| 86 | if (bufferMask >= ((1LU<<numBuffers)-1)) { |
| 87 | // We ran out of buffers. |
| 88 | return -ENOMEM; |
| 89 | } |
| 90 | |
Naseer Ahmed | d7f8427 | 2012-12-13 13:09:53 -0500 | [diff] [blame] | 91 | // create a "fake" handle for it |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 92 | intptr_t vaddr = intptr_t(m->framebuffer->base); |
Naseer Ahmed | d7f8427 | 2012-12-13 13:09:53 -0500 | [diff] [blame] | 93 | private_handle_t* hnd = new private_handle_t( |
| 94 | dup(m->framebuffer->fd), bufferSize, |
| 95 | private_handle_t::PRIV_FLAGS_USES_ION | |
| 96 | private_handle_t::PRIV_FLAGS_FRAMEBUFFER, |
| 97 | BUFFER_TYPE_UI, m->fbFormat, m->info.xres, |
| 98 | m->info.yres); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 99 | |
| 100 | // find a free slot |
| 101 | for (uint32_t i=0 ; i<numBuffers ; i++) { |
| 102 | if ((bufferMask & (1LU<<i)) == 0) { |
| 103 | m->bufferMask |= (1LU<<i); |
| 104 | break; |
| 105 | } |
| 106 | vaddr += bufferSize; |
| 107 | } |
| 108 | |
| 109 | hnd->base = vaddr; |
| 110 | hnd->offset = vaddr - intptr_t(m->framebuffer->base); |
| 111 | *pHandle = hnd; |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | |
| 116 | int gpu_context_t::gralloc_alloc_framebuffer(size_t size, int usage, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 117 | buffer_handle_t* pHandle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 118 | { |
| 119 | private_module_t* m = reinterpret_cast<private_module_t*>(common.module); |
| 120 | pthread_mutex_lock(&m->lock); |
| 121 | int err = gralloc_alloc_framebuffer_locked(size, usage, pHandle); |
| 122 | pthread_mutex_unlock(&m->lock); |
| 123 | return err; |
| 124 | } |
| 125 | |
| 126 | int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage, |
| 127 | buffer_handle_t* pHandle, int bufferType, |
| 128 | int format, int width, int height) |
| 129 | { |
| 130 | int err = 0; |
| 131 | int flags = 0; |
| 132 | size = roundUpToPageSize(size); |
| 133 | alloc_data data; |
| 134 | data.offset = 0; |
| 135 | data.fd = -1; |
| 136 | data.base = 0; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 137 | if(format == HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED) |
| 138 | data.align = 8192; |
| 139 | else |
| 140 | data.align = getpagesize(); |
Praveen Chavan | 4e931c1 | 2012-11-28 19:43:17 -0800 | [diff] [blame] | 141 | |
| 142 | /* force 1MB alignment selectively for secure buffers, MDP5 onwards */ |
| 143 | if ((qdutils::MDPVersion::getInstance().getMDPVersion() >= \ |
| 144 | qdutils::MDSS_V5) && (usage & GRALLOC_USAGE_PROTECTED)) { |
| 145 | data.align = ALIGN(data.align, SZ_1M); |
| 146 | size = ALIGN(size, data.align); |
| 147 | } |
| 148 | data.size = size; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 149 | data.pHandle = (unsigned int) pHandle; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 150 | err = mAllocCtrl->allocate(data, usage); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 151 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 152 | if (!err) { |
| 153 | /* allocate memory for enhancement data */ |
| 154 | alloc_data eData; |
| 155 | eData.fd = -1; |
| 156 | eData.base = 0; |
| 157 | eData.offset = 0; |
| 158 | eData.size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 159 | eData.pHandle = data.pHandle; |
| 160 | eData.align = getpagesize(); |
| 161 | int eDataUsage = GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP; |
| 162 | int eDataErr = mAllocCtrl->allocate(eData, eDataUsage); |
| 163 | ALOGE_IF(eDataErr, "gralloc failed for eDataErr=%s", |
| 164 | strerror(-eDataErr)); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 165 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 166 | if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY) { |
| 167 | flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_ONLY; |
| 168 | //The EXTERNAL_BLOCK flag is always an add-on |
| 169 | if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK) { |
| 170 | flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_BLOCK; |
| 171 | } |
| 172 | if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_CC) { |
| 173 | flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_CC; |
| 174 | } |
| 175 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 176 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 177 | if (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER ) { |
| 178 | flags |= private_handle_t::PRIV_FLAGS_VIDEO_ENCODER; |
| 179 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 180 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 181 | if (usage & GRALLOC_USAGE_HW_CAMERA_WRITE) { |
| 182 | flags |= private_handle_t::PRIV_FLAGS_CAMERA_WRITE; |
| 183 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 184 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 185 | if (usage & GRALLOC_USAGE_HW_CAMERA_READ) { |
| 186 | flags |= private_handle_t::PRIV_FLAGS_CAMERA_READ; |
| 187 | } |
| 188 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 189 | flags |= data.allocType; |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 190 | int eBaseAddr = int(eData.base) + eData.offset; |
| 191 | private_handle_t *hnd = new private_handle_t(data.fd, size, flags, |
| 192 | bufferType, format, width, height, eData.fd, eData.offset, |
| 193 | eBaseAddr); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 194 | |
| 195 | hnd->offset = data.offset; |
| 196 | hnd->base = int(data.base) + data.offset; |
Naseer Ahmed | a163b73 | 2013-02-12 14:53:33 -0500 | [diff] [blame] | 197 | hnd->gpuaddr = 0; |
| 198 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 199 | *pHandle = hnd; |
| 200 | } |
| 201 | |
| 202 | ALOGE_IF(err, "gralloc failed err=%s", strerror(-err)); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 203 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 204 | return err; |
| 205 | } |
| 206 | |
| 207 | void gpu_context_t::getGrallocInformationFromFormat(int inputFormat, |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 208 | int *bufferType) |
| 209 | { |
| 210 | *bufferType = BUFFER_TYPE_VIDEO; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 211 | |
Naseer Ahmed | 65f1656 | 2012-06-15 20:53:42 -0700 | [diff] [blame] | 212 | if (inputFormat < 0x7) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 213 | // RGB formats |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 214 | *bufferType = BUFFER_TYPE_UI; |
| 215 | } else if ((inputFormat == HAL_PIXEL_FORMAT_R_8) || |
| 216 | (inputFormat == HAL_PIXEL_FORMAT_RG_88)) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 217 | *bufferType = BUFFER_TYPE_UI; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | int gpu_context_t::alloc_impl(int w, int h, int format, int usage, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 222 | buffer_handle_t* pHandle, int* pStride, |
| 223 | size_t bufferSize) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 224 | if (!pHandle || !pStride) |
| 225 | return -EINVAL; |
| 226 | |
| 227 | size_t size; |
| 228 | int alignedw, alignedh; |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 229 | int grallocFormat = format; |
| 230 | int bufferType; |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 231 | |
Saurabh Shah | aedf236 | 2012-09-05 11:30:59 -0700 | [diff] [blame] | 232 | //If input format is HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED then based on |
| 233 | //the usage bits, gralloc assigns a format. |
| 234 | if(format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) { |
| 235 | if(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) |
| 236 | grallocFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP; //NV12 |
| 237 | else if(usage & GRALLOC_USAGE_HW_CAMERA_READ) |
| 238 | grallocFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; //NV21 |
| 239 | else if(usage & GRALLOC_USAGE_HW_CAMERA_WRITE) |
| 240 | grallocFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; //NV21 |
| 241 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 242 | |
Saurabh Shah | aedf236 | 2012-09-05 11:30:59 -0700 | [diff] [blame] | 243 | getGrallocInformationFromFormat(grallocFormat, &bufferType); |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 244 | size = getBufferSizeAndDimensions(w, h, grallocFormat, alignedw, alignedh); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 245 | |
| 246 | if ((ssize_t)size <= 0) |
| 247 | return -EINVAL; |
Ramkumar Radhakrishnan | 3d4c0ac | 2012-12-10 15:42:54 -0800 | [diff] [blame] | 248 | size = (bufferSize != 0)? bufferSize : size; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 249 | |
| 250 | // All buffers marked as protected or for external |
| 251 | // display need to go to overlay |
| 252 | if ((usage & GRALLOC_USAGE_EXTERNAL_DISP) || |
Sushil Chauhan | 7651a80 | 2013-01-08 16:08:09 -0800 | [diff] [blame] | 253 | (usage & GRALLOC_USAGE_PROTECTED)) { |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 254 | bufferType = BUFFER_TYPE_VIDEO; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 255 | } |
Naseer Ahmed | 768619e | 2012-11-28 17:02:52 -0500 | [diff] [blame] | 256 | |
| 257 | int err = gralloc_alloc_buffer(size, usage, pHandle, bufferType, |
| 258 | grallocFormat, alignedw, alignedh); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 259 | |
| 260 | if (err < 0) { |
| 261 | return err; |
| 262 | } |
| 263 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 264 | *pStride = alignedw; |
| 265 | return 0; |
| 266 | } |
| 267 | |
| 268 | int gpu_context_t::free_impl(private_handle_t const* hnd) { |
| 269 | private_module_t* m = reinterpret_cast<private_module_t*>(common.module); |
| 270 | if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) { |
| 271 | // free this buffer |
| 272 | const size_t bufferSize = m->finfo.line_length * m->info.yres; |
| 273 | int index = (hnd->base - m->framebuffer->base) / bufferSize; |
| 274 | m->bufferMask &= ~(1<<index); |
| 275 | } else { |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 276 | terminateBuffer(&m->base, const_cast<private_handle_t*>(hnd)); |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 277 | IMemAlloc* memalloc = mAllocCtrl->getAllocator(hnd->flags); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 278 | int err = memalloc->free_buffer((void*)hnd->base, (size_t) hnd->size, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 279 | hnd->offset, hnd->fd); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 280 | if(err) |
| 281 | return err; |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 282 | // free the metadata space |
| 283 | unsigned long size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 284 | err = memalloc->free_buffer((void*)hnd->base_metadata, |
| 285 | (size_t) size, hnd->offset_metadata, |
| 286 | hnd->fd_metadata); |
| 287 | if (err) |
| 288 | return err; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 289 | } |
| 290 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 291 | delete hnd; |
| 292 | return 0; |
| 293 | } |
| 294 | |
| 295 | int gpu_context_t::gralloc_alloc(alloc_device_t* dev, int w, int h, int format, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 296 | int usage, buffer_handle_t* pHandle, |
| 297 | int* pStride) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 298 | { |
| 299 | if (!dev) { |
| 300 | return -EINVAL; |
| 301 | } |
| 302 | gpu_context_t* gpu = reinterpret_cast<gpu_context_t*>(dev); |
| 303 | return gpu->alloc_impl(w, h, format, usage, pHandle, pStride, 0); |
| 304 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 305 | int gpu_context_t::gralloc_alloc_size(alloc_device_t* dev, int w, int h, |
| 306 | int format, int usage, |
| 307 | buffer_handle_t* pHandle, int* pStride, |
| 308 | int bufferSize) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 309 | { |
| 310 | if (!dev) { |
| 311 | return -EINVAL; |
| 312 | } |
| 313 | gpu_context_t* gpu = reinterpret_cast<gpu_context_t*>(dev); |
| 314 | return gpu->alloc_impl(w, h, format, usage, pHandle, pStride, bufferSize); |
| 315 | } |
| 316 | |
| 317 | |
| 318 | int gpu_context_t::gralloc_free(alloc_device_t* dev, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 319 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 320 | { |
| 321 | if (private_handle_t::validate(handle) < 0) |
| 322 | return -EINVAL; |
| 323 | |
| 324 | private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(handle); |
| 325 | gpu_context_t* gpu = reinterpret_cast<gpu_context_t*>(dev); |
| 326 | return gpu->free_impl(hnd); |
| 327 | } |
| 328 | |
| 329 | /*****************************************************************************/ |
| 330 | |
| 331 | int gpu_context_t::gralloc_close(struct hw_device_t *dev) |
| 332 | { |
| 333 | gpu_context_t* ctx = reinterpret_cast<gpu_context_t*>(dev); |
| 334 | if (ctx) { |
| 335 | /* TODO: keep a list of all buffer_handle_t created, and free them |
| 336 | * all here. |
| 337 | */ |
| 338 | delete ctx; |
| 339 | } |
| 340 | return 0; |
| 341 | } |
| 342 | |