Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 3 | * Copyright (c) 2011-2012, Code Aurora Forum. 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 <errno.h> |
| 20 | #include <pthread.h> |
| 21 | #include <unistd.h> |
| 22 | #include <string.h> |
| 23 | #include <stdarg.h> |
| 24 | |
| 25 | #include <sys/mman.h> |
| 26 | #include <sys/stat.h> |
| 27 | #include <sys/types.h> |
| 28 | #include <sys/ioctl.h> |
| 29 | #include <linux/ashmem.h> |
| 30 | |
| 31 | #include <cutils/log.h> |
| 32 | #include <cutils/atomic.h> |
| 33 | #include <cutils/ashmem.h> |
| 34 | |
| 35 | #include <hardware/hardware.h> |
| 36 | #include <hardware/gralloc.h> |
| 37 | #include <genlock.h> |
| 38 | |
| 39 | #include <linux/android_pmem.h> |
| 40 | |
| 41 | #include "gralloc_priv.h" |
| 42 | #include "gr.h" |
| 43 | #include "alloc_controller.h" |
| 44 | #include "memalloc.h" |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 45 | #include <qdMetaData.h> |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 46 | |
| 47 | using namespace gralloc; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 48 | /*****************************************************************************/ |
| 49 | |
| 50 | // Return the type of allocator - |
| 51 | // these are used for mapping/unmapping |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 52 | static IMemAlloc* getAllocator(int flags) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 53 | { |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 54 | IMemAlloc* memalloc; |
| 55 | IAllocController* alloc_ctrl = IAllocController::getInstance(); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 56 | memalloc = alloc_ctrl->getAllocator(flags); |
| 57 | return memalloc; |
| 58 | } |
| 59 | |
| 60 | static int gralloc_map(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 61 | buffer_handle_t handle, |
| 62 | void** vaddr) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 63 | { |
| 64 | private_handle_t* hnd = (private_handle_t*)handle; |
| 65 | void *mappedAddress; |
| 66 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) && |
| 67 | !(hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER)) { |
| 68 | size_t size = hnd->size; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 69 | IMemAlloc* memalloc = getAllocator(hnd->flags) ; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 70 | int err = memalloc->map_buffer(&mappedAddress, size, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 71 | hnd->offset, hnd->fd); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 72 | if(err || mappedAddress == MAP_FAILED) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 73 | ALOGE("Could not mmap handle %p, fd=%d (%s)", |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 74 | handle, hnd->fd, strerror(errno)); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 75 | hnd->base = 0; |
| 76 | return -errno; |
| 77 | } |
| 78 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 79 | hnd->base = intptr_t(mappedAddress) + hnd->offset; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 80 | //LOGD("gralloc_map() succeeded fd=%d, off=%d, size=%d, vaddr=%p", |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 81 | // hnd->fd, hnd->offset, hnd->size, mappedAddress); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 82 | mappedAddress = MAP_FAILED; |
| 83 | size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 84 | err = memalloc->map_buffer(&mappedAddress, size, |
| 85 | hnd->offset_metadata, hnd->fd_metadata); |
| 86 | if(err || mappedAddress == MAP_FAILED) { |
| 87 | ALOGE("Could not mmap handle %p, fd=%d (%s)", |
| 88 | handle, hnd->fd_metadata, strerror(errno)); |
| 89 | hnd->base_metadata = 0; |
| 90 | return -errno; |
| 91 | } |
| 92 | hnd->base_metadata = intptr_t(mappedAddress) + hnd->offset_metadata; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 93 | } |
| 94 | *vaddr = (void*)hnd->base; |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | static int gralloc_unmap(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 99 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 100 | { |
| 101 | private_handle_t* hnd = (private_handle_t*)handle; |
| 102 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { |
| 103 | int err = -EINVAL; |
| 104 | void* base = (void*)hnd->base; |
| 105 | size_t size = hnd->size; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 106 | IMemAlloc* memalloc = getAllocator(hnd->flags) ; |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 107 | if(memalloc != NULL) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 108 | err = memalloc->unmap_buffer(base, size, hnd->offset); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 109 | if (err) { |
| 110 | ALOGE("Could not unmap memory at address %p", base); |
| 111 | } |
| 112 | base = (void*)hnd->base_metadata; |
| 113 | size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 114 | err = memalloc->unmap_buffer(base, size, hnd->offset_metadata); |
| 115 | if (err) { |
| 116 | ALOGE("Could not unmap memory at address %p", base); |
| 117 | } |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | hnd->base = 0; |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | /*****************************************************************************/ |
| 125 | |
| 126 | static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER; |
| 127 | |
| 128 | /*****************************************************************************/ |
| 129 | |
| 130 | int gralloc_register_buffer(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 131 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 132 | { |
| 133 | if (private_handle_t::validate(handle) < 0) |
| 134 | return -EINVAL; |
| 135 | |
| 136 | // In this implementation, we don't need to do anything here |
| 137 | |
| 138 | /* NOTE: we need to initialize the buffer as not mapped/not locked |
| 139 | * because it shouldn't when this function is called the first time |
| 140 | * in a new process. Ideally these flags shouldn't be part of the |
| 141 | * handle, but instead maintained in the kernel or at least |
| 142 | * out-of-line |
| 143 | */ |
| 144 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 145 | private_handle_t* hnd = (private_handle_t*)handle; |
Kinjal Bhavsar | 139e162 | 2012-09-10 12:35:11 -0700 | [diff] [blame] | 146 | hnd->base = 0; |
| 147 | void *vaddr; |
| 148 | int err = gralloc_map(module, handle, &vaddr); |
| 149 | if (err) { |
| 150 | ALOGE("%s: gralloc_map failed", __FUNCTION__); |
| 151 | return err; |
| 152 | } |
| 153 | |
| 154 | // Reset the genlock private fd flag in the handle |
| 155 | hnd->genlockPrivFd = -1; |
| 156 | |
| 157 | // Check if there is a valid lock attached to the handle. |
| 158 | if (-1 == hnd->genlockHandle) { |
| 159 | ALOGE("%s: the lock is invalid.", __FUNCTION__); |
| 160 | gralloc_unmap(module, handle); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 161 | hnd->base = 0; |
Kinjal Bhavsar | 139e162 | 2012-09-10 12:35:11 -0700 | [diff] [blame] | 162 | return -EINVAL; |
| 163 | } |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 164 | |
Kinjal Bhavsar | 139e162 | 2012-09-10 12:35:11 -0700 | [diff] [blame] | 165 | // Attach the genlock handle |
| 166 | if (GENLOCK_NO_ERROR != genlock_attach_lock((native_handle_t *)handle)) { |
| 167 | ALOGE("%s: genlock_attach_lock failed", __FUNCTION__); |
| 168 | gralloc_unmap(module, handle); |
| 169 | hnd->base = 0; |
| 170 | return -EINVAL; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 171 | } |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | int gralloc_unregister_buffer(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 176 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 177 | { |
| 178 | if (private_handle_t::validate(handle) < 0) |
| 179 | return -EINVAL; |
| 180 | |
| 181 | /* |
| 182 | * If the buffer has been mapped during a lock operation, it's time |
| 183 | * to un-map it. It's an error to be here with a locked buffer. |
| 184 | * NOTE: the framebuffer is handled differently and is never unmapped. |
| 185 | */ |
| 186 | |
| 187 | private_handle_t* hnd = (private_handle_t*)handle; |
| 188 | |
Kinjal Bhavsar | 139e162 | 2012-09-10 12:35:11 -0700 | [diff] [blame] | 189 | if (hnd->base != 0) { |
| 190 | gralloc_unmap(module, handle); |
| 191 | } |
| 192 | hnd->base = 0; |
| 193 | // Release the genlock |
| 194 | if (-1 != hnd->genlockHandle) { |
| 195 | return genlock_release_lock((native_handle_t *)handle); |
| 196 | } else { |
| 197 | ALOGE("%s: there was no genlock attached to this buffer", __FUNCTION__); |
| 198 | return -EINVAL; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 199 | } |
| 200 | return 0; |
| 201 | } |
| 202 | |
| 203 | int terminateBuffer(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 204 | private_handle_t* hnd) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 205 | { |
| 206 | /* |
| 207 | * If the buffer has been mapped during a lock operation, it's time |
| 208 | * to un-map it. It's an error to be here with a locked buffer. |
| 209 | */ |
| 210 | |
| 211 | if (hnd->base != 0) { |
| 212 | // this buffer was mapped, unmap it now |
| 213 | if (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_PMEM | |
| 214 | private_handle_t::PRIV_FLAGS_USES_PMEM_ADSP | |
| 215 | private_handle_t::PRIV_FLAGS_USES_ASHMEM | |
| 216 | private_handle_t::PRIV_FLAGS_USES_ION)) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 217 | gralloc_unmap(module, hnd); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 218 | } else { |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 219 | ALOGE("terminateBuffer: unmapping a non pmem/ashmem buffer flags = 0x%x", |
| 220 | hnd->flags); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 221 | gralloc_unmap(module, hnd); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | return 0; |
| 226 | } |
| 227 | |
| 228 | int gralloc_lock(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 229 | buffer_handle_t handle, int usage, |
| 230 | int l, int t, int w, int h, |
| 231 | void** vaddr) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 232 | { |
| 233 | if (private_handle_t::validate(handle) < 0) |
| 234 | return -EINVAL; |
| 235 | |
| 236 | int err = 0; |
| 237 | private_handle_t* hnd = (private_handle_t*)handle; |
| 238 | if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) { |
| 239 | if (hnd->base == 0) { |
| 240 | // we need to map for real |
| 241 | pthread_mutex_t* const lock = &sMapLock; |
| 242 | pthread_mutex_lock(lock); |
| 243 | err = gralloc_map(module, handle, vaddr); |
| 244 | pthread_mutex_unlock(lock); |
| 245 | } |
| 246 | *vaddr = (void*)hnd->base; |
| 247 | |
| 248 | // Lock the buffer for read/write operation as specified. Write lock |
| 249 | // has a higher priority over read lock. |
| 250 | int lockType = 0; |
| 251 | if (usage & GRALLOC_USAGE_SW_WRITE_MASK) { |
| 252 | lockType = GENLOCK_WRITE_LOCK; |
| 253 | } else if (usage & GRALLOC_USAGE_SW_READ_MASK) { |
| 254 | lockType = GENLOCK_READ_LOCK; |
| 255 | } |
| 256 | |
| 257 | int timeout = GENLOCK_MAX_TIMEOUT; |
| 258 | if (GENLOCK_NO_ERROR != genlock_lock_buffer((native_handle_t *)handle, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 259 | (genlock_lock_type)lockType, |
| 260 | timeout)) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 261 | ALOGE("%s: genlock_lock_buffer (lockType=0x%x) failed", __FUNCTION__, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 262 | lockType); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 263 | return -EINVAL; |
| 264 | } else { |
| 265 | // Mark this buffer as locked for SW read/write operation. |
| 266 | hnd->flags |= private_handle_t::PRIV_FLAGS_SW_LOCK; |
| 267 | } |
| 268 | |
| 269 | if ((usage & GRALLOC_USAGE_SW_WRITE_MASK) && |
| 270 | !(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { |
| 271 | // Mark the buffer to be flushed after cpu read/write |
| 272 | hnd->flags |= private_handle_t::PRIV_FLAGS_NEEDS_FLUSH; |
| 273 | } |
| 274 | } |
| 275 | return err; |
| 276 | } |
| 277 | |
| 278 | int gralloc_unlock(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 279 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 280 | { |
| 281 | if (private_handle_t::validate(handle) < 0) |
| 282 | return -EINVAL; |
| 283 | |
| 284 | private_handle_t* hnd = (private_handle_t*)handle; |
| 285 | |
| 286 | if (hnd->flags & private_handle_t::PRIV_FLAGS_NEEDS_FLUSH) { |
| 287 | int err; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 288 | IMemAlloc* memalloc = getAllocator(hnd->flags) ; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 289 | err = memalloc->clean_buffer((void*)hnd->base, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 290 | hnd->size, hnd->offset, hnd->fd); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 291 | ALOGE_IF(err < 0, "cannot flush handle %p (offs=%x len=%x, flags = 0x%x) err=%s\n", |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 292 | hnd, hnd->offset, hnd->size, hnd->flags, strerror(errno)); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 293 | unsigned long size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 294 | err = memalloc->clean_buffer((void*)hnd->base_metadata, size, |
| 295 | hnd->offset_metadata, hnd->fd_metadata); |
| 296 | ALOGE_IF(err < 0, "cannot flush handle %p (offs=%x len=%lu, " |
| 297 | "flags = 0x%x) err=%s\n", hnd, hnd->offset_metadata, size, |
| 298 | hnd->flags, strerror(errno)); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 299 | hnd->flags &= ~private_handle_t::PRIV_FLAGS_NEEDS_FLUSH; |
| 300 | } |
| 301 | |
| 302 | if ((hnd->flags & private_handle_t::PRIV_FLAGS_SW_LOCK)) { |
| 303 | // Unlock the buffer. |
| 304 | if (GENLOCK_NO_ERROR != genlock_unlock_buffer((native_handle_t *)handle)) { |
| 305 | ALOGE("%s: genlock_unlock_buffer failed", __FUNCTION__); |
| 306 | return -EINVAL; |
| 307 | } else |
| 308 | hnd->flags &= ~private_handle_t::PRIV_FLAGS_SW_LOCK; |
| 309 | } |
| 310 | return 0; |
| 311 | } |
| 312 | |
| 313 | /*****************************************************************************/ |
| 314 | |
| 315 | int gralloc_perform(struct gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 316 | int operation, ... ) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 317 | { |
| 318 | int res = -EINVAL; |
| 319 | va_list args; |
| 320 | va_start(args, operation); |
| 321 | switch (operation) { |
| 322 | case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER: |
| 323 | { |
| 324 | int fd = va_arg(args, int); |
| 325 | size_t size = va_arg(args, size_t); |
| 326 | size_t offset = va_arg(args, size_t); |
| 327 | void* base = va_arg(args, void*); |
| 328 | int width = va_arg(args, int); |
| 329 | int height = va_arg(args, int); |
| 330 | int format = va_arg(args, int); |
| 331 | |
| 332 | native_handle_t** handle = va_arg(args, native_handle_t**); |
| 333 | int memoryFlags = va_arg(args, int); |
| 334 | private_handle_t* hnd = (private_handle_t*)native_handle_create( |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 335 | private_handle_t::sNumFds, private_handle_t::sNumInts); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 336 | hnd->magic = private_handle_t::sMagic; |
| 337 | hnd->fd = fd; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 338 | hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 339 | hnd->size = size; |
| 340 | hnd->offset = offset; |
| 341 | hnd->base = intptr_t(base) + offset; |
| 342 | hnd->gpuaddr = 0; |
| 343 | hnd->width = width; |
| 344 | hnd->height = height; |
| 345 | hnd->format = format; |
| 346 | *handle = (native_handle_t *)hnd; |
| 347 | res = 0; |
| 348 | break; |
| 349 | |
| 350 | } |
Ramkumar Radhakrishnan | 935cb68 | 2012-11-07 16:43:38 -0800 | [diff] [blame] | 351 | case GRALLOC_MODULE_PERFORM_UPDATE_BUFFER_GEOMETRY: |
| 352 | { |
| 353 | int width = va_arg(args, int); |
| 354 | int height = va_arg(args, int); |
| 355 | int format = va_arg(args, int); |
| 356 | private_handle_t* hnd = va_arg(args, private_handle_t*); |
| 357 | if (private_handle_t::validate(hnd)) { |
| 358 | return res; |
| 359 | } |
| 360 | hnd->width = width; |
| 361 | hnd->height = height; |
| 362 | hnd->format = format; |
| 363 | res = 0; |
| 364 | } |
| 365 | break; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 366 | default: |
| 367 | break; |
| 368 | } |
| 369 | va_end(args); |
| 370 | return res; |
| 371 | } |