blob: c419da6e4da368b691d6fcd50b14d831d91bf01a [file] [log] [blame]
Iliyan Malchev202a77d2012-06-11 14:41:12 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
Shuzhen Wangc502c872014-01-28 16:10:42 -08003 * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
Iliyan Malchev202a77d2012-06-11 14:41:12 -07004 *
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 Malchev202a77d2012-06-11 14:41:12 -070037
38#include "gralloc_priv.h"
39#include "gr.h"
40#include "alloc_controller.h"
41#include "memalloc.h"
Ramkumar Radhakrishnan47573e22012-11-07 11:36:41 -080042#include <qdMetaData.h>
Iliyan Malchev202a77d2012-06-11 14:41:12 -070043
44using namespace gralloc;
Iliyan Malchev202a77d2012-06-11 14:41:12 -070045/*****************************************************************************/
46
47// Return the type of allocator -
48// these are used for mapping/unmapping
Naseer Ahmed01d3fd32012-07-14 21:08:13 -070049static IMemAlloc* getAllocator(int flags)
Iliyan Malchev202a77d2012-06-11 14:41:12 -070050{
Naseer Ahmed01d3fd32012-07-14 21:08:13 -070051 IMemAlloc* memalloc;
52 IAllocController* alloc_ctrl = IAllocController::getInstance();
Iliyan Malchev202a77d2012-06-11 14:41:12 -070053 memalloc = alloc_ctrl->getAllocator(flags);
54 return memalloc;
55}
56
57static int gralloc_map(gralloc_module_t const* module,
Naseer Ahmed34d33bc2013-05-08 12:28:37 -040058 buffer_handle_t handle)
Iliyan Malchev202a77d2012-06-11 14:41:12 -070059{
Arun Kumar K.R6c85f052014-01-21 21:47:41 -080060 if(!module)
61 return -EINVAL;
62
Iliyan Malchev202a77d2012-06-11 14:41:12 -070063 private_handle_t* hnd = (private_handle_t*)handle;
64 void *mappedAddress;
65 if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) &&
66 !(hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER)) {
67 size_t size = hnd->size;
Naseer Ahmed01d3fd32012-07-14 21:08:13 -070068 IMemAlloc* memalloc = getAllocator(hnd->flags) ;
Iliyan Malchev202a77d2012-06-11 14:41:12 -070069 int err = memalloc->map_buffer(&mappedAddress, size,
Naseer Ahmed29a26812012-06-14 00:56:20 -070070 hnd->offset, hnd->fd);
Ramkumar Radhakrishnan47573e22012-11-07 11:36:41 -080071 if(err || mappedAddress == MAP_FAILED) {
Iliyan Malchev202a77d2012-06-11 14:41:12 -070072 ALOGE("Could not mmap handle %p, fd=%d (%s)",
Naseer Ahmed29a26812012-06-14 00:56:20 -070073 handle, hnd->fd, strerror(errno));
Iliyan Malchev202a77d2012-06-11 14:41:12 -070074 hnd->base = 0;
75 return -errno;
76 }
77
Iliyan Malchev202a77d2012-06-11 14:41:12 -070078 hnd->base = intptr_t(mappedAddress) + hnd->offset;
Ramkumar Radhakrishnan47573e22012-11-07 11:36:41 -080079 mappedAddress = MAP_FAILED;
80 size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
81 err = memalloc->map_buffer(&mappedAddress, size,
82 hnd->offset_metadata, hnd->fd_metadata);
83 if(err || mappedAddress == MAP_FAILED) {
84 ALOGE("Could not mmap handle %p, fd=%d (%s)",
85 handle, hnd->fd_metadata, strerror(errno));
86 hnd->base_metadata = 0;
87 return -errno;
88 }
89 hnd->base_metadata = intptr_t(mappedAddress) + hnd->offset_metadata;
Iliyan Malchev202a77d2012-06-11 14:41:12 -070090 }
Iliyan Malchev202a77d2012-06-11 14:41:12 -070091 return 0;
92}
93
94static int gralloc_unmap(gralloc_module_t const* module,
Naseer Ahmed29a26812012-06-14 00:56:20 -070095 buffer_handle_t handle)
Iliyan Malchev202a77d2012-06-11 14:41:12 -070096{
Arun Kumar K.R6c85f052014-01-21 21:47:41 -080097 if(!module)
98 return -EINVAL;
99
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700100 private_handle_t* hnd = (private_handle_t*)handle;
101 if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) {
102 int err = -EINVAL;
103 void* base = (void*)hnd->base;
104 size_t size = hnd->size;
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700105 IMemAlloc* memalloc = getAllocator(hnd->flags) ;
Ramkumar Radhakrishnan47573e22012-11-07 11:36:41 -0800106 if(memalloc != NULL) {
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700107 err = memalloc->unmap_buffer(base, size, hnd->offset);
Ramkumar Radhakrishnan47573e22012-11-07 11:36:41 -0800108 if (err) {
109 ALOGE("Could not unmap memory at address %p", base);
110 }
111 base = (void*)hnd->base_metadata;
112 size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
113 err = memalloc->unmap_buffer(base, size, hnd->offset_metadata);
114 if (err) {
115 ALOGE("Could not unmap memory at address %p", base);
116 }
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700117 }
118 }
Ramkumar Radhakrishnan7bf31c32013-01-28 22:51:51 -0800119 /* need to initialize the pointer to NULL otherwise unmapping for that
120 * buffer happens twice which leads to crash */
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700121 hnd->base = 0;
Ramkumar Radhakrishnan7bf31c32013-01-28 22:51:51 -0800122 hnd->base_metadata = 0;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700123 return 0;
124}
125
126/*****************************************************************************/
127
128static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER;
129
130/*****************************************************************************/
131
132int gralloc_register_buffer(gralloc_module_t const* module,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700133 buffer_handle_t handle)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700134{
Arun Kumar K.R6c85f052014-01-21 21:47:41 -0800135 if (!module || private_handle_t::validate(handle) < 0)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700136 return -EINVAL;
137
138 // In this implementation, we don't need to do anything here
139
140 /* NOTE: we need to initialize the buffer as not mapped/not locked
141 * because it shouldn't when this function is called the first time
142 * in a new process. Ideally these flags shouldn't be part of the
143 * handle, but instead maintained in the kernel or at least
144 * out-of-line
145 */
146
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700147 private_handle_t* hnd = (private_handle_t*)handle;
Kinjal Bhavsar139e1622012-09-10 12:35:11 -0700148 hnd->base = 0;
Ramkumar Radhakrishnan7bf31c32013-01-28 22:51:51 -0800149 hnd->base_metadata = 0;
Naseer Ahmed34d33bc2013-05-08 12:28:37 -0400150 int err = gralloc_map(module, handle);
Kinjal Bhavsar139e1622012-09-10 12:35:11 -0700151 if (err) {
152 ALOGE("%s: gralloc_map failed", __FUNCTION__);
153 return err;
154 }
155
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700156 return 0;
157}
158
159int gralloc_unregister_buffer(gralloc_module_t const* module,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700160 buffer_handle_t handle)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700161{
Arun Kumar K.R6c85f052014-01-21 21:47:41 -0800162 if (!module || private_handle_t::validate(handle) < 0)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700163 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 Bhavsar139e1622012-09-10 12:35:11 -0700173 if (hnd->base != 0) {
174 gralloc_unmap(module, handle);
175 }
176 hnd->base = 0;
Ramkumar Radhakrishnan7bf31c32013-01-28 22:51:51 -0800177 hnd->base_metadata = 0;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700178 return 0;
179}
180
181int terminateBuffer(gralloc_module_t const* module,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700182 private_handle_t* hnd)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700183{
Arun Kumar K.R6c85f052014-01-21 21:47:41 -0800184 if(!module)
185 return -EINVAL;
186
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700187 /*
188 * If the buffer has been mapped during a lock operation, it's time
189 * to un-map it. It's an error to be here with a locked buffer.
190 */
191
192 if (hnd->base != 0) {
193 // this buffer was mapped, unmap it now
194 if (hnd->flags & (private_handle_t::PRIV_FLAGS_USES_PMEM |
195 private_handle_t::PRIV_FLAGS_USES_PMEM_ADSP |
196 private_handle_t::PRIV_FLAGS_USES_ASHMEM |
197 private_handle_t::PRIV_FLAGS_USES_ION)) {
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700198 gralloc_unmap(module, hnd);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700199 } else {
Naseer Ahmed29a26812012-06-14 00:56:20 -0700200 ALOGE("terminateBuffer: unmapping a non pmem/ashmem buffer flags = 0x%x",
201 hnd->flags);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700202 gralloc_unmap(module, hnd);
203 }
204 }
205
206 return 0;
207}
208
Naseer Ahmed34d33bc2013-05-08 12:28:37 -0400209static int gralloc_map_and_invalidate (gralloc_module_t const* module,
210 buffer_handle_t handle, int usage)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700211{
Arun Kumar K.R6c85f052014-01-21 21:47:41 -0800212 if (!module || private_handle_t::validate(handle) < 0)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700213 return -EINVAL;
214
215 int err = 0;
216 private_handle_t* hnd = (private_handle_t*)handle;
217 if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) {
218 if (hnd->base == 0) {
219 // we need to map for real
220 pthread_mutex_t* const lock = &sMapLock;
221 pthread_mutex_lock(lock);
Naseer Ahmed34d33bc2013-05-08 12:28:37 -0400222 err = gralloc_map(module, handle);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700223 pthread_mutex_unlock(lock);
224 }
Naseer Ahmedec147982013-06-14 17:06:46 -0400225 if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) {
226 //Invalidate if reading in software. No need to do this for the
227 //metadata buffer as it is only read/written in software.
228 IMemAlloc* memalloc = getAllocator(hnd->flags) ;
229 err = memalloc->clean_buffer((void*)hnd->base,
230 hnd->size, hnd->offset, hnd->fd,
231 CACHE_INVALIDATE);
232 if (usage & GRALLOC_USAGE_SW_WRITE_MASK) {
233 // Mark the buffer to be flushed after cpu read/write
234 hnd->flags |= private_handle_t::PRIV_FLAGS_NEEDS_FLUSH;
235 }
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700236 }
Naseer Ahmedaeab91f2013-03-20 21:01:19 -0400237 } else {
238 hnd->flags |= private_handle_t::PRIV_FLAGS_DO_NOT_FLUSH;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700239 }
240 return err;
241}
242
Naseer Ahmed34d33bc2013-05-08 12:28:37 -0400243int gralloc_lock(gralloc_module_t const* module,
244 buffer_handle_t handle, int usage,
245 int /*l*/, int /*t*/, int /*w*/, int /*h*/,
246 void** vaddr)
247{
248 private_handle_t* hnd = (private_handle_t*)handle;
249 int err = gralloc_map_and_invalidate(module, handle, usage);
250 if(!err)
251 *vaddr = (void*)hnd->base;
252 return err;
253}
254
255int gralloc_lock_ycbcr(gralloc_module_t const* module,
256 buffer_handle_t handle, int usage,
257 int /*l*/, int /*t*/, int /*w*/, int /*h*/,
258 struct android_ycbcr *ycbcr)
259{
260 private_handle_t* hnd = (private_handle_t*)handle;
261 int err = gralloc_map_and_invalidate(module, handle, usage);
262 size_t ystride, cstride;
263 if(!err) {
264 //hnd->format holds our implementation defined format
265 //HAL_PIXEL_FORMAT_YCrCb_420_SP is the only one set right now.
266 switch (hnd->format) {
267 case HAL_PIXEL_FORMAT_YCrCb_420_SP:
268 ystride = ALIGN(hnd->width, 16);
269 cstride = ALIGN(hnd->width, 16)/2;
270 ycbcr->y = (void*)hnd->base;
271 ycbcr->cr = (void*)(hnd->base + ystride * hnd->height);
272 ycbcr->cb = (void*)(hnd->base + ystride * hnd->height + 1);
273 ycbcr->ystride = ystride;
274 ycbcr->cstride = cstride;
275 ycbcr->chroma_step = 2;
276 memset(ycbcr->reserved, 0, sizeof(ycbcr->reserved));
277 break;
278 default:
279 ALOGD("%s: Invalid format passed: 0x%x", __FUNCTION__,
280 hnd->format);
281 err = -EINVAL;
282 }
283 }
284 return err;
285}
286
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700287int gralloc_unlock(gralloc_module_t const* module,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700288 buffer_handle_t handle)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700289{
Arun Kumar K.R6c85f052014-01-21 21:47:41 -0800290 if (!module || private_handle_t::validate(handle) < 0)
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700291 return -EINVAL;
Arun Kumar K.R6c85f052014-01-21 21:47:41 -0800292
Naseer Ahmedaeab91f2013-03-20 21:01:19 -0400293 int err = 0;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700294 private_handle_t* hnd = (private_handle_t*)handle;
295
Naseer Ahmedec147982013-06-14 17:06:46 -0400296 if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) {
Naseer Ahmed69662ac2013-08-28 13:16:48 -0400297 IMemAlloc* memalloc = getAllocator(hnd->flags);
Naseer Ahmedec147982013-06-14 17:06:46 -0400298 if (hnd->flags & private_handle_t::PRIV_FLAGS_NEEDS_FLUSH) {
299 err = memalloc->clean_buffer((void*)hnd->base,
300 hnd->size, hnd->offset, hnd->fd,
301 CACHE_CLEAN_AND_INVALIDATE);
302 hnd->flags &= ~private_handle_t::PRIV_FLAGS_NEEDS_FLUSH;
303 } else if(hnd->flags & private_handle_t::PRIV_FLAGS_DO_NOT_FLUSH) {
304 hnd->flags &= ~private_handle_t::PRIV_FLAGS_DO_NOT_FLUSH;
305 } else {
306 //Probably a round about way to do this, but this avoids adding new
307 //flags
308 err = memalloc->clean_buffer((void*)hnd->base,
309 hnd->size, hnd->offset, hnd->fd,
310 CACHE_INVALIDATE);
311 }
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700312 }
313
Naseer Ahmedaeab91f2013-03-20 21:01:19 -0400314 return err;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700315}
316
317/*****************************************************************************/
318
319int gralloc_perform(struct gralloc_module_t const* module,
Naseer Ahmed29a26812012-06-14 00:56:20 -0700320 int operation, ... )
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700321{
322 int res = -EINVAL;
323 va_list args;
Arun Kumar K.R6c85f052014-01-21 21:47:41 -0800324 if(!module)
325 return res;
326
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700327 va_start(args, operation);
328 switch (operation) {
329 case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER:
330 {
331 int fd = va_arg(args, int);
332 size_t size = va_arg(args, size_t);
333 size_t offset = va_arg(args, size_t);
334 void* base = va_arg(args, void*);
335 int width = va_arg(args, int);
336 int height = va_arg(args, int);
337 int format = va_arg(args, int);
338
339 native_handle_t** handle = va_arg(args, native_handle_t**);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700340 private_handle_t* hnd = (private_handle_t*)native_handle_create(
Naseer Ahmed29a26812012-06-14 00:56:20 -0700341 private_handle_t::sNumFds, private_handle_t::sNumInts);
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700342 hnd->magic = private_handle_t::sMagic;
343 hnd->fd = fd;
Naseer Ahmed01d3fd32012-07-14 21:08:13 -0700344 hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700345 hnd->size = size;
346 hnd->offset = offset;
347 hnd->base = intptr_t(base) + offset;
348 hnd->gpuaddr = 0;
349 hnd->width = width;
350 hnd->height = height;
351 hnd->format = format;
352 *handle = (native_handle_t *)hnd;
353 res = 0;
354 break;
355
356 }
Naseer Ahmed74214722013-02-09 08:11:36 -0500357#ifdef QCOM_BSP
Ramkumar Radhakrishnan935cb682012-11-07 16:43:38 -0800358 case GRALLOC_MODULE_PERFORM_UPDATE_BUFFER_GEOMETRY:
359 {
360 int width = va_arg(args, int);
361 int height = va_arg(args, int);
362 int format = va_arg(args, int);
363 private_handle_t* hnd = va_arg(args, private_handle_t*);
364 if (private_handle_t::validate(hnd)) {
365 return res;
366 }
367 hnd->width = width;
368 hnd->height = height;
369 hnd->format = format;
370 res = 0;
371 }
372 break;
Naseer Ahmedc0593ea2013-03-18 11:46:24 -0400373#endif
Naomi Luisa44100c2013-02-08 12:42:03 -0800374 case GRALLOC_MODULE_PERFORM_GET_STRIDE:
375 {
376 int width = va_arg(args, int);
377 int format = va_arg(args, int);
378 int *stride = va_arg(args, int *);
Ramkumar Radhakrishnan473f4082013-11-04 14:29:18 -0800379 int alignedw = 0, alignedh = 0;
380 AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700381 0, format, false, alignedw, alignedh);
Ramkumar Radhakrishnan473f4082013-11-04 14:29:18 -0800382 *stride = alignedw;
Naomi Luisa44100c2013-02-08 12:42:03 -0800383 res = 0;
384 } break;
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700385
Naseer Ahmeda978f952013-09-26 14:36:28 -0400386 case GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE:
387 {
388 private_handle_t* hnd = va_arg(args, private_handle_t*);
389 int *stride = va_arg(args, int *);
390 if (private_handle_t::validate(hnd)) {
391 return res;
392 }
393 MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
394 if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
395 *stride = metadata->bufferDim.sliceWidth;
396 } else {
397 *stride = hnd->width;
398 }
399 res = 0;
400 } break;
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700401
Raj Kamal3d01d8d2014-03-04 05:25:33 +0530402 case GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE:
403 {
404 private_handle_t* hnd = va_arg(args, private_handle_t*);
405 int *stride = va_arg(args, int *);
406 int *height = va_arg(args, int *);
407 if (private_handle_t::validate(hnd)) {
408 return res;
409 }
410 MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
411 if(metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
412 *stride = metadata->bufferDim.sliceWidth;
413 *height = metadata->bufferDim.sliceHeight;
414 } else {
415 *stride = hnd->width;
416 *height = hnd->height;
417 }
418 res = 0;
419 } break;
420
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700421 case GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES:
422 {
423 int width = va_arg(args, int);
424 int height = va_arg(args, int);
425 int format = va_arg(args, int);
426 int usage = va_arg(args, int);
427 int *alignedWidth = va_arg(args, int *);
428 int *alignedHeight = va_arg(args, int *);
429 int *tileEnabled = va_arg(args,int *);
430 *tileEnabled = isMacroTileEnabled(format, usage);
431 AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(width,
432 height, format, *tileEnabled, *alignedWidth,
433 *alignedHeight);
434 res = 0;
435 } break;
436
Shuzhen Wangc502c872014-01-28 16:10:42 -0800437 case GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE:
438 {
439 private_handle_t* hnd = va_arg(args, private_handle_t*);
440 int *color_space = va_arg(args, int *);
441 if (private_handle_t::validate(hnd)) {
442 return res;
443 }
444 MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
445 if(metadata && metadata->operation & UPDATE_COLOR_SPACE) {
446 *color_space = metadata->colorSpace;
447 res = 0;
448 }
449 } break;
Iliyan Malchev202a77d2012-06-11 14:41:12 -0700450 default:
451 break;
452 }
453 va_end(args);
454 return res;
455}