Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * Copyright (c) 2011-2012 Code Aurora Forum. All rights reserved. |
| 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 | |
| 24 | #include <genlock.h> |
| 25 | |
| 26 | #include "gr.h" |
| 27 | #include "gpu.h" |
| 28 | #include "memalloc.h" |
| 29 | #include "alloc_controller.h" |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 30 | #include <qdMetaData.h> |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 31 | |
| 32 | using namespace gralloc; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 33 | |
| 34 | gpu_context_t::gpu_context_t(const private_module_t* module, |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 35 | IAllocController* alloc_ctrl ) : |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 36 | mAllocCtrl(alloc_ctrl) |
| 37 | { |
| 38 | // Zero out the alloc_device_t |
| 39 | memset(static_cast<alloc_device_t*>(this), 0, sizeof(alloc_device_t)); |
| 40 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 41 | // Initialize the procs |
| 42 | common.tag = HARDWARE_DEVICE_TAG; |
| 43 | common.version = 0; |
| 44 | common.module = const_cast<hw_module_t*>(&module->base.common); |
| 45 | common.close = gralloc_close; |
| 46 | alloc = gralloc_alloc; |
Ramkumar Radhakrishnan | 3d4c0ac | 2012-12-10 15:42:54 -0800 | [diff] [blame] | 47 | allocSize = gralloc_alloc_size; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 48 | free = gralloc_free; |
| 49 | |
| 50 | } |
| 51 | |
| 52 | 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] | 53 | buffer_handle_t* pHandle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 54 | { |
| 55 | private_module_t* m = reinterpret_cast<private_module_t*>(common.module); |
| 56 | |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 57 | // we don't support framebuffer allocations with graphics heap flags |
| 58 | if (usage & GRALLOC_HEAP_MASK) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 59 | return -EINVAL; |
| 60 | } |
| 61 | |
| 62 | if (m->framebuffer == NULL) { |
| 63 | ALOGE("%s: Invalid framebuffer", __FUNCTION__); |
| 64 | return -EINVAL; |
| 65 | } |
| 66 | |
| 67 | const uint32_t bufferMask = m->bufferMask; |
| 68 | const uint32_t numBuffers = m->numBuffers; |
| 69 | size_t bufferSize = m->finfo.line_length * m->info.yres; |
| 70 | |
| 71 | //adreno needs FB size to be page aligned |
| 72 | bufferSize = roundUpToPageSize(bufferSize); |
| 73 | |
| 74 | if (numBuffers == 1) { |
| 75 | // If we have only one buffer, we never use page-flipping. Instead, |
| 76 | // we return a regular buffer which will be memcpy'ed to the main |
| 77 | // screen when post is called. |
| 78 | int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D; |
| 79 | return gralloc_alloc_buffer(bufferSize, newUsage, pHandle, BUFFER_TYPE_UI, |
| 80 | m->fbFormat, m->info.xres, m->info.yres); |
| 81 | } |
| 82 | |
| 83 | if (bufferMask >= ((1LU<<numBuffers)-1)) { |
| 84 | // We ran out of buffers. |
| 85 | return -ENOMEM; |
| 86 | } |
| 87 | |
Naseer Ahmed | d7f8427 | 2012-12-13 13:09:53 -0500 | [diff] [blame] | 88 | // create a "fake" handle for it |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 89 | intptr_t vaddr = intptr_t(m->framebuffer->base); |
Naseer Ahmed | d7f8427 | 2012-12-13 13:09:53 -0500 | [diff] [blame] | 90 | private_handle_t* hnd = new private_handle_t( |
| 91 | dup(m->framebuffer->fd), bufferSize, |
| 92 | private_handle_t::PRIV_FLAGS_USES_ION | |
| 93 | private_handle_t::PRIV_FLAGS_FRAMEBUFFER, |
| 94 | BUFFER_TYPE_UI, m->fbFormat, m->info.xres, |
| 95 | m->info.yres); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 96 | |
| 97 | // find a free slot |
| 98 | for (uint32_t i=0 ; i<numBuffers ; i++) { |
| 99 | if ((bufferMask & (1LU<<i)) == 0) { |
| 100 | m->bufferMask |= (1LU<<i); |
| 101 | break; |
| 102 | } |
| 103 | vaddr += bufferSize; |
| 104 | } |
| 105 | |
| 106 | hnd->base = vaddr; |
| 107 | hnd->offset = vaddr - intptr_t(m->framebuffer->base); |
| 108 | *pHandle = hnd; |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | |
| 113 | int gpu_context_t::gralloc_alloc_framebuffer(size_t size, int usage, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 114 | buffer_handle_t* pHandle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 115 | { |
| 116 | private_module_t* m = reinterpret_cast<private_module_t*>(common.module); |
| 117 | pthread_mutex_lock(&m->lock); |
| 118 | int err = gralloc_alloc_framebuffer_locked(size, usage, pHandle); |
| 119 | pthread_mutex_unlock(&m->lock); |
| 120 | return err; |
| 121 | } |
| 122 | |
| 123 | int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage, |
| 124 | buffer_handle_t* pHandle, int bufferType, |
| 125 | int format, int width, int height) |
| 126 | { |
| 127 | int err = 0; |
| 128 | int flags = 0; |
| 129 | size = roundUpToPageSize(size); |
| 130 | alloc_data data; |
| 131 | data.offset = 0; |
| 132 | data.fd = -1; |
| 133 | data.base = 0; |
| 134 | data.size = size; |
| 135 | if(format == HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED) |
| 136 | data.align = 8192; |
| 137 | else |
| 138 | data.align = getpagesize(); |
| 139 | data.pHandle = (unsigned int) pHandle; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 140 | err = mAllocCtrl->allocate(data, usage); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 141 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 142 | if (!err) { |
| 143 | /* allocate memory for enhancement data */ |
| 144 | alloc_data eData; |
| 145 | eData.fd = -1; |
| 146 | eData.base = 0; |
| 147 | eData.offset = 0; |
| 148 | eData.size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 149 | eData.pHandle = data.pHandle; |
| 150 | eData.align = getpagesize(); |
| 151 | int eDataUsage = GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP; |
| 152 | int eDataErr = mAllocCtrl->allocate(eData, eDataUsage); |
| 153 | ALOGE_IF(eDataErr, "gralloc failed for eDataErr=%s", |
| 154 | strerror(-eDataErr)); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 155 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 156 | if (usage & GRALLOC_USAGE_PRIVATE_UNSYNCHRONIZED) { |
| 157 | flags |= private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 158 | } |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 159 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 160 | if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY) { |
| 161 | flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_ONLY; |
| 162 | //The EXTERNAL_BLOCK flag is always an add-on |
| 163 | if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK) { |
| 164 | flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_BLOCK; |
| 165 | } |
| 166 | if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_CC) { |
| 167 | flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_CC; |
| 168 | } |
| 169 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 170 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 171 | if (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER ) { |
| 172 | flags |= private_handle_t::PRIV_FLAGS_VIDEO_ENCODER; |
| 173 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 174 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 175 | if (usage & GRALLOC_USAGE_HW_CAMERA_WRITE) { |
| 176 | flags |= private_handle_t::PRIV_FLAGS_CAMERA_WRITE; |
| 177 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 178 | |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 179 | if (usage & GRALLOC_USAGE_HW_CAMERA_READ) { |
| 180 | flags |= private_handle_t::PRIV_FLAGS_CAMERA_READ; |
| 181 | } |
| 182 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 183 | flags |= data.allocType; |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 184 | int eBaseAddr = int(eData.base) + eData.offset; |
| 185 | private_handle_t *hnd = new private_handle_t(data.fd, size, flags, |
| 186 | bufferType, format, width, height, eData.fd, eData.offset, |
| 187 | eBaseAddr); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 188 | |
| 189 | hnd->offset = data.offset; |
| 190 | hnd->base = int(data.base) + data.offset; |
| 191 | *pHandle = hnd; |
| 192 | } |
| 193 | |
| 194 | ALOGE_IF(err, "gralloc failed err=%s", strerror(-err)); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 195 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 196 | return err; |
| 197 | } |
| 198 | |
| 199 | void gpu_context_t::getGrallocInformationFromFormat(int inputFormat, |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 200 | int *bufferType) |
| 201 | { |
| 202 | *bufferType = BUFFER_TYPE_VIDEO; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 203 | |
Naseer Ahmed | 65f1656 | 2012-06-15 20:53:42 -0700 | [diff] [blame] | 204 | if (inputFormat < 0x7) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 205 | // RGB formats |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 206 | *bufferType = BUFFER_TYPE_UI; |
| 207 | } else if ((inputFormat == HAL_PIXEL_FORMAT_R_8) || |
| 208 | (inputFormat == HAL_PIXEL_FORMAT_RG_88)) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 209 | *bufferType = BUFFER_TYPE_UI; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | 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] | 214 | buffer_handle_t* pHandle, int* pStride, |
| 215 | size_t bufferSize) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 216 | if (!pHandle || !pStride) |
| 217 | return -EINVAL; |
| 218 | |
| 219 | size_t size; |
| 220 | int alignedw, alignedh; |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 221 | int grallocFormat = format; |
| 222 | int bufferType; |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 223 | |
Saurabh Shah | aedf236 | 2012-09-05 11:30:59 -0700 | [diff] [blame] | 224 | //If input format is HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED then based on |
| 225 | //the usage bits, gralloc assigns a format. |
| 226 | if(format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) { |
| 227 | if(usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) |
| 228 | grallocFormat = HAL_PIXEL_FORMAT_YCbCr_420_SP; //NV12 |
| 229 | else if(usage & GRALLOC_USAGE_HW_CAMERA_READ) |
| 230 | grallocFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; //NV21 |
| 231 | else if(usage & GRALLOC_USAGE_HW_CAMERA_WRITE) |
| 232 | grallocFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP; //NV21 |
| 233 | } |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 234 | |
Saurabh Shah | aedf236 | 2012-09-05 11:30:59 -0700 | [diff] [blame] | 235 | getGrallocInformationFromFormat(grallocFormat, &bufferType); |
Naseer Ahmed | 5980250 | 2012-08-21 17:03:27 -0400 | [diff] [blame] | 236 | size = getBufferSizeAndDimensions(w, h, grallocFormat, alignedw, alignedh); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 237 | |
| 238 | if ((ssize_t)size <= 0) |
| 239 | return -EINVAL; |
Ramkumar Radhakrishnan | 3d4c0ac | 2012-12-10 15:42:54 -0800 | [diff] [blame] | 240 | size = (bufferSize != 0)? bufferSize : size; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 241 | |
| 242 | // All buffers marked as protected or for external |
| 243 | // display need to go to overlay |
| 244 | if ((usage & GRALLOC_USAGE_EXTERNAL_DISP) || |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 245 | (usage & GRALLOC_USAGE_PROTECTED) || |
| 246 | (usage & GRALLOC_USAGE_PRIVATE_CP_BUFFER)) { |
| 247 | bufferType = BUFFER_TYPE_VIDEO; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 248 | } |
Naseer Ahmed | 768619e | 2012-11-28 17:02:52 -0500 | [diff] [blame] | 249 | |
| 250 | int err = gralloc_alloc_buffer(size, usage, pHandle, bufferType, |
| 251 | grallocFormat, alignedw, alignedh); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 252 | |
| 253 | if (err < 0) { |
| 254 | return err; |
| 255 | } |
| 256 | |
| 257 | // Create a genlock lock for this buffer handle. |
| 258 | err = genlock_create_lock((native_handle_t*)(*pHandle)); |
| 259 | if (err) { |
| 260 | ALOGE("%s: genlock_create_lock failed", __FUNCTION__); |
| 261 | free_impl(reinterpret_cast<private_handle_t*>(pHandle)); |
| 262 | return err; |
| 263 | } |
| 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 | |
| 291 | // Release the genlock |
| 292 | int err = genlock_release_lock((native_handle_t*)hnd); |
| 293 | if (err) { |
| 294 | ALOGE("%s: genlock_release_lock failed", __FUNCTION__); |
| 295 | } |
| 296 | |
| 297 | delete hnd; |
| 298 | return 0; |
| 299 | } |
| 300 | |
| 301 | 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] | 302 | int usage, buffer_handle_t* pHandle, |
| 303 | int* pStride) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 304 | { |
| 305 | if (!dev) { |
| 306 | return -EINVAL; |
| 307 | } |
| 308 | gpu_context_t* gpu = reinterpret_cast<gpu_context_t*>(dev); |
| 309 | return gpu->alloc_impl(w, h, format, usage, pHandle, pStride, 0); |
| 310 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 311 | int gpu_context_t::gralloc_alloc_size(alloc_device_t* dev, int w, int h, |
| 312 | int format, int usage, |
| 313 | buffer_handle_t* pHandle, int* pStride, |
| 314 | int bufferSize) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 315 | { |
| 316 | if (!dev) { |
| 317 | return -EINVAL; |
| 318 | } |
| 319 | gpu_context_t* gpu = reinterpret_cast<gpu_context_t*>(dev); |
| 320 | return gpu->alloc_impl(w, h, format, usage, pHandle, pStride, bufferSize); |
| 321 | } |
| 322 | |
| 323 | |
| 324 | int gpu_context_t::gralloc_free(alloc_device_t* dev, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 325 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 326 | { |
| 327 | if (private_handle_t::validate(handle) < 0) |
| 328 | return -EINVAL; |
| 329 | |
| 330 | private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(handle); |
| 331 | gpu_context_t* gpu = reinterpret_cast<gpu_context_t*>(dev); |
| 332 | return gpu->free_impl(hnd); |
| 333 | } |
| 334 | |
| 335 | /*****************************************************************************/ |
| 336 | |
| 337 | int gpu_context_t::gralloc_close(struct hw_device_t *dev) |
| 338 | { |
| 339 | gpu_context_t* ctx = reinterpret_cast<gpu_context_t*>(dev); |
| 340 | if (ctx) { |
| 341 | /* TODO: keep a list of all buffer_handle_t created, and free them |
| 342 | * all here. |
| 343 | */ |
| 344 | delete ctx; |
| 345 | } |
| 346 | return 0; |
| 347 | } |
| 348 | |