Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 <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> |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 37 | #include <linux/android_pmem.h> |
| 38 | |
| 39 | #include "gralloc_priv.h" |
| 40 | #include "gr.h" |
| 41 | #include "alloc_controller.h" |
| 42 | #include "memalloc.h" |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 43 | #include <qdMetaData.h> |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 44 | |
| 45 | using namespace gralloc; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 46 | /*****************************************************************************/ |
| 47 | |
| 48 | // Return the type of allocator - |
| 49 | // these are used for mapping/unmapping |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 50 | static IMemAlloc* getAllocator(int flags) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 51 | { |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 52 | IMemAlloc* memalloc; |
| 53 | IAllocController* alloc_ctrl = IAllocController::getInstance(); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 54 | memalloc = alloc_ctrl->getAllocator(flags); |
| 55 | return memalloc; |
| 56 | } |
| 57 | |
| 58 | static int gralloc_map(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 59 | buffer_handle_t handle, |
| 60 | void** vaddr) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 61 | { |
| 62 | private_handle_t* hnd = (private_handle_t*)handle; |
| 63 | void *mappedAddress; |
| 64 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) && |
| 65 | !(hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER)) { |
| 66 | size_t size = hnd->size; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 67 | IMemAlloc* memalloc = getAllocator(hnd->flags) ; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 68 | int err = memalloc->map_buffer(&mappedAddress, size, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 69 | hnd->offset, hnd->fd); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 70 | if(err || mappedAddress == MAP_FAILED) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 71 | ALOGE("Could not mmap handle %p, fd=%d (%s)", |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 72 | handle, hnd->fd, strerror(errno)); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 73 | hnd->base = 0; |
| 74 | return -errno; |
| 75 | } |
| 76 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 77 | hnd->base = intptr_t(mappedAddress) + hnd->offset; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 78 | //LOGD("gralloc_map() succeeded fd=%d, off=%d, size=%d, vaddr=%p", |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 79 | // hnd->fd, hnd->offset, hnd->size, mappedAddress); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 80 | mappedAddress = MAP_FAILED; |
| 81 | size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 82 | err = memalloc->map_buffer(&mappedAddress, size, |
| 83 | hnd->offset_metadata, hnd->fd_metadata); |
| 84 | if(err || mappedAddress == MAP_FAILED) { |
| 85 | ALOGE("Could not mmap handle %p, fd=%d (%s)", |
| 86 | handle, hnd->fd_metadata, strerror(errno)); |
| 87 | hnd->base_metadata = 0; |
| 88 | return -errno; |
| 89 | } |
| 90 | hnd->base_metadata = intptr_t(mappedAddress) + hnd->offset_metadata; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 91 | } |
| 92 | *vaddr = (void*)hnd->base; |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | static int gralloc_unmap(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 97 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 98 | { |
| 99 | private_handle_t* hnd = (private_handle_t*)handle; |
| 100 | if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { |
| 101 | int err = -EINVAL; |
| 102 | void* base = (void*)hnd->base; |
| 103 | size_t size = hnd->size; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 104 | IMemAlloc* memalloc = getAllocator(hnd->flags) ; |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 105 | if(memalloc != NULL) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 106 | err = memalloc->unmap_buffer(base, size, hnd->offset); |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 107 | if (err) { |
| 108 | ALOGE("Could not unmap memory at address %p", base); |
| 109 | } |
| 110 | base = (void*)hnd->base_metadata; |
| 111 | size = ROUND_UP_PAGESIZE(sizeof(MetaData_t)); |
| 112 | err = memalloc->unmap_buffer(base, size, hnd->offset_metadata); |
| 113 | if (err) { |
| 114 | ALOGE("Could not unmap memory at address %p", base); |
| 115 | } |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 116 | } |
| 117 | } |
Ramkumar Radhakrishnan | 7bf31c3 | 2013-01-28 22:51:51 -0800 | [diff] [blame] | 118 | /* need to initialize the pointer to NULL otherwise unmapping for that |
| 119 | * buffer happens twice which leads to crash */ |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 120 | hnd->base = 0; |
Ramkumar Radhakrishnan | 7bf31c3 | 2013-01-28 22:51:51 -0800 | [diff] [blame] | 121 | hnd->base_metadata = 0; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 122 | return 0; |
| 123 | } |
| 124 | |
| 125 | /*****************************************************************************/ |
| 126 | |
| 127 | static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER; |
| 128 | |
| 129 | /*****************************************************************************/ |
| 130 | |
| 131 | int gralloc_register_buffer(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 132 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 133 | { |
| 134 | if (private_handle_t::validate(handle) < 0) |
| 135 | return -EINVAL; |
| 136 | |
| 137 | // In this implementation, we don't need to do anything here |
| 138 | |
| 139 | /* NOTE: we need to initialize the buffer as not mapped/not locked |
| 140 | * because it shouldn't when this function is called the first time |
| 141 | * in a new process. Ideally these flags shouldn't be part of the |
| 142 | * handle, but instead maintained in the kernel or at least |
| 143 | * out-of-line |
| 144 | */ |
| 145 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 146 | private_handle_t* hnd = (private_handle_t*)handle; |
Kinjal Bhavsar | 139e162 | 2012-09-10 12:35:11 -0700 | [diff] [blame] | 147 | hnd->base = 0; |
Ramkumar Radhakrishnan | 7bf31c3 | 2013-01-28 22:51:51 -0800 | [diff] [blame] | 148 | hnd->base_metadata = 0; |
Kinjal Bhavsar | 139e162 | 2012-09-10 12:35:11 -0700 | [diff] [blame] | 149 | void *vaddr; |
| 150 | int err = gralloc_map(module, handle, &vaddr); |
| 151 | if (err) { |
| 152 | ALOGE("%s: gralloc_map failed", __FUNCTION__); |
| 153 | return err; |
| 154 | } |
| 155 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | int gralloc_unregister_buffer(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 160 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 161 | { |
| 162 | if (private_handle_t::validate(handle) < 0) |
| 163 | return -EINVAL; |
| 164 | |
| 165 | /* |
| 166 | * If the buffer has been mapped during a lock operation, it's time |
| 167 | * to un-map it. It's an error to be here with a locked buffer. |
| 168 | * NOTE: the framebuffer is handled differently and is never unmapped. |
| 169 | */ |
| 170 | |
| 171 | private_handle_t* hnd = (private_handle_t*)handle; |
| 172 | |
Kinjal Bhavsar | 139e162 | 2012-09-10 12:35:11 -0700 | [diff] [blame] | 173 | if (hnd->base != 0) { |
| 174 | gralloc_unmap(module, handle); |
| 175 | } |
| 176 | hnd->base = 0; |
Ramkumar Radhakrishnan | 7bf31c3 | 2013-01-28 22:51:51 -0800 | [diff] [blame] | 177 | hnd->base_metadata = 0; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 178 | return 0; |
| 179 | } |
| 180 | |
| 181 | int terminateBuffer(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 182 | private_handle_t* hnd) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 183 | { |
| 184 | /* |
| 185 | * If the buffer has been mapped during a lock operation, it's time |
| 186 | * to un-map it. It's an error to be here with a locked buffer. |
| 187 | */ |
| 188 | |
| 189 | if (hnd->base != 0) { |
| 190 | // this buffer was mapped, unmap it now |
| 191 | if (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_PMEM | |
| 192 | private_handle_t::PRIV_FLAGS_USES_PMEM_ADSP | |
| 193 | private_handle_t::PRIV_FLAGS_USES_ASHMEM | |
| 194 | private_handle_t::PRIV_FLAGS_USES_ION)) { |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 195 | gralloc_unmap(module, hnd); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 196 | } else { |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 197 | ALOGE("terminateBuffer: unmapping a non pmem/ashmem buffer flags = 0x%x", |
| 198 | hnd->flags); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 199 | gralloc_unmap(module, hnd); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | int gralloc_lock(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 207 | buffer_handle_t handle, int usage, |
| 208 | int l, int t, int w, int h, |
| 209 | void** vaddr) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 210 | { |
| 211 | if (private_handle_t::validate(handle) < 0) |
| 212 | return -EINVAL; |
| 213 | |
| 214 | int err = 0; |
| 215 | private_handle_t* hnd = (private_handle_t*)handle; |
| 216 | if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) { |
| 217 | if (hnd->base == 0) { |
| 218 | // we need to map for real |
| 219 | pthread_mutex_t* const lock = &sMapLock; |
| 220 | pthread_mutex_lock(lock); |
| 221 | err = gralloc_map(module, handle, vaddr); |
| 222 | pthread_mutex_unlock(lock); |
| 223 | } |
| 224 | *vaddr = (void*)hnd->base; |
Saurabh Shah | c282508 | 2014-09-17 16:40:44 -0700 | [diff] [blame] | 225 | if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION and |
Saurabh Shah | 74f3cb9 | 2014-12-19 10:05:41 -0800 | [diff] [blame] | 226 | hnd->flags & private_handle_t::PRIV_FLAGS_CACHED) { |
Saurabh Shah | c282508 | 2014-09-17 16:40:44 -0700 | [diff] [blame] | 227 | //Invalidate if CPU reads in software and there are non-CPU |
| 228 | //writers. No need to do this for the metadata buffer as it is |
| 229 | //only read/written in software. |
Saurabh Shah | 74f3cb9 | 2014-12-19 10:05:41 -0800 | [diff] [blame] | 230 | if ((usage & GRALLOC_USAGE_SW_READ_MASK) and |
| 231 | (hnd->flags & private_handle_t::PRIV_FLAGS_NON_CPU_WRITER)) |
| 232 | { |
Saurabh Shah | c282508 | 2014-09-17 16:40:44 -0700 | [diff] [blame] | 233 | IMemAlloc* memalloc = getAllocator(hnd->flags) ; |
| 234 | err = memalloc->clean_buffer((void*)hnd->base, |
| 235 | hnd->size, hnd->offset, hnd->fd, |
| 236 | CACHE_INVALIDATE); |
| 237 | } |
| 238 | //Mark the buffer to be flushed after CPU write. |
Naseer Ahmed | ec14798 | 2013-06-14 17:06:46 -0400 | [diff] [blame] | 239 | if (usage & GRALLOC_USAGE_SW_WRITE_MASK) { |
Naseer Ahmed | ec14798 | 2013-06-14 17:06:46 -0400 | [diff] [blame] | 240 | hnd->flags |= private_handle_t::PRIV_FLAGS_NEEDS_FLUSH; |
| 241 | } |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 242 | } |
| 243 | } |
Saurabh Shah | c282508 | 2014-09-17 16:40:44 -0700 | [diff] [blame] | 244 | |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 245 | return err; |
| 246 | } |
| 247 | |
| 248 | int gralloc_unlock(gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 249 | buffer_handle_t handle) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 250 | { |
| 251 | if (private_handle_t::validate(handle) < 0) |
| 252 | return -EINVAL; |
Naseer Ahmed | aeab91f | 2013-03-20 21:01:19 -0400 | [diff] [blame] | 253 | int err = 0; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 254 | private_handle_t* hnd = (private_handle_t*)handle; |
| 255 | |
Saurabh Shah | c282508 | 2014-09-17 16:40:44 -0700 | [diff] [blame] | 256 | IMemAlloc* memalloc = getAllocator(hnd->flags); |
| 257 | if (hnd->flags & private_handle_t::PRIV_FLAGS_NEEDS_FLUSH) { |
| 258 | err = memalloc->clean_buffer((void*)hnd->base, |
| 259 | hnd->size, hnd->offset, hnd->fd, |
| 260 | CACHE_CLEAN); |
| 261 | hnd->flags &= ~private_handle_t::PRIV_FLAGS_NEEDS_FLUSH; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Naseer Ahmed | aeab91f | 2013-03-20 21:01:19 -0400 | [diff] [blame] | 264 | return err; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | /*****************************************************************************/ |
| 268 | |
| 269 | int gralloc_perform(struct gralloc_module_t const* module, |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 270 | int operation, ... ) |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 271 | { |
| 272 | int res = -EINVAL; |
| 273 | va_list args; |
| 274 | va_start(args, operation); |
| 275 | switch (operation) { |
| 276 | case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER: |
| 277 | { |
| 278 | int fd = va_arg(args, int); |
| 279 | size_t size = va_arg(args, size_t); |
| 280 | size_t offset = va_arg(args, size_t); |
| 281 | void* base = va_arg(args, void*); |
| 282 | int width = va_arg(args, int); |
| 283 | int height = va_arg(args, int); |
| 284 | int format = va_arg(args, int); |
| 285 | |
| 286 | native_handle_t** handle = va_arg(args, native_handle_t**); |
| 287 | int memoryFlags = va_arg(args, int); |
| 288 | private_handle_t* hnd = (private_handle_t*)native_handle_create( |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 289 | private_handle_t::sNumFds, private_handle_t::sNumInts); |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 290 | hnd->magic = private_handle_t::sMagic; |
| 291 | hnd->fd = fd; |
Naseer Ahmed | 01d3fd3 | 2012-07-14 21:08:13 -0700 | [diff] [blame] | 292 | hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 293 | hnd->size = size; |
| 294 | hnd->offset = offset; |
| 295 | hnd->base = intptr_t(base) + offset; |
| 296 | hnd->gpuaddr = 0; |
| 297 | hnd->width = width; |
| 298 | hnd->height = height; |
| 299 | hnd->format = format; |
| 300 | *handle = (native_handle_t *)hnd; |
| 301 | res = 0; |
| 302 | break; |
| 303 | |
| 304 | } |
Naomi Luis | a44100c | 2013-02-08 12:42:03 -0800 | [diff] [blame] | 305 | case GRALLOC_MODULE_PERFORM_GET_STRIDE: |
| 306 | { |
| 307 | int width = va_arg(args, int); |
| 308 | int format = va_arg(args, int); |
| 309 | int *stride = va_arg(args, int *); |
Ramkumar Radhakrishnan | 473f408 | 2013-11-04 14:29:18 -0800 | [diff] [blame] | 310 | int alignedw = 0, alignedh = 0; |
| 311 | AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width, |
| 312 | 0, format, alignedw, alignedh); |
| 313 | *stride = alignedw; |
Naomi Luis | a44100c | 2013-02-08 12:42:03 -0800 | [diff] [blame] | 314 | res = 0; |
| 315 | } break; |
Raj Kamal | 9c1cb9e | 2014-03-04 05:25:33 +0530 | [diff] [blame] | 316 | case GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE: |
Naseer Ahmed | a978f95 | 2013-09-26 14:36:28 -0400 | [diff] [blame] | 317 | { |
| 318 | private_handle_t* hnd = va_arg(args, private_handle_t*); |
| 319 | int *stride = va_arg(args, int *); |
Raj Kamal | 9c1cb9e | 2014-03-04 05:25:33 +0530 | [diff] [blame] | 320 | int *height = va_arg(args, int *); |
Naseer Ahmed | a978f95 | 2013-09-26 14:36:28 -0400 | [diff] [blame] | 321 | if (private_handle_t::validate(hnd)) { |
| 322 | return res; |
| 323 | } |
| 324 | MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; |
| 325 | if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) { |
| 326 | *stride = metadata->bufferDim.sliceWidth; |
Raj Kamal | 9c1cb9e | 2014-03-04 05:25:33 +0530 | [diff] [blame] | 327 | *height = metadata->bufferDim.sliceHeight; |
Naseer Ahmed | a978f95 | 2013-09-26 14:36:28 -0400 | [diff] [blame] | 328 | } else { |
| 329 | *stride = hnd->width; |
Raj Kamal | 9c1cb9e | 2014-03-04 05:25:33 +0530 | [diff] [blame] | 330 | *height = hnd->height; |
Naseer Ahmed | a978f95 | 2013-09-26 14:36:28 -0400 | [diff] [blame] | 331 | } |
| 332 | res = 0; |
| 333 | } break; |
Iliyan Malchev | 202a77d | 2012-06-11 14:41:12 -0700 | [diff] [blame] | 334 | default: |
| 335 | break; |
| 336 | } |
| 337 | va_end(args); |
| 338 | return res; |
| 339 | } |